From cabe8d9026ee2069bcbe1329d4920bad9f16e16f Mon Sep 17 00:00:00 2001 From: Shazron Abdullah Date: Mon, 7 Apr 2025 16:26:07 +0800 Subject: [PATCH] fix: remove @openwhisk/wskdebug from the default action generator --- .gitattributes | 1 + lib/ActionGenerator.js | 5 +++-- test/lib/ActionGenerator.test.js | 12 ++++++------ 3 files changed, 10 insertions(+), 8 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..176a458 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto diff --git a/lib/ActionGenerator.js b/lib/ActionGenerator.js index 9b8ad47..777c407 100644 --- a/lib/ActionGenerator.js +++ b/lib/ActionGenerator.js @@ -135,8 +135,9 @@ Note: characters can only be split by '-'. if (options.dependencies) { utils.addDependencies(this, options.dependencies) } - // make sure wskdebug is there - utils.addDependencies(this, { '@openwhisk/wskdebug': '^1.3.0', ...options.devDependencies }, true) + if (options.devDependencies) { + utils.addDependencies(this, options.devDependencies, true) + } // make sure the node engines are added this.addPackageJsonNodeEngines() } diff --git a/test/lib/ActionGenerator.test.js b/test/lib/ActionGenerator.test.js index 7207a96..e1d13bf 100644 --- a/test/lib/ActionGenerator.test.js +++ b/test/lib/ActionGenerator.test.js @@ -181,6 +181,7 @@ Note: characters can only be split by '-'. utils.readPackageJson.mockReturnValue({}) utils.readYAMLConfig.mockReturnValue({}) + // third parameter options is {} by default here actionGenerator.addAction('myAction', './templateFile.js') // 1. test copy action template to right destination @@ -192,9 +193,8 @@ Note: characters can only be split by '-'. 'runtimeManifest', // function path should be checked to be relative to config file { packages: { 'dx-excshell-1': { actions: { myAction: { annotations: { 'require-adobe-auth': true }, function: expect.stringContaining('myAction/index.js'), runtime: constants.defaultRuntimeKind, web: 'yes' } }, license: 'Apache-2.0' } } }) - - // 3. make sure wskdebug dev dependency was added to package.json - expect(utils.addDependencies).toHaveBeenCalledWith(actionGenerator, { '@openwhisk/wskdebug': expect.any(String) }, true) + // dev or prod + expect(utils.addDependencies).not.toHaveBeenCalled() }) test('with extra dependencies and manifest already exists', () => { @@ -226,13 +226,13 @@ Note: characters can only be split by '-'. // 3. make sure wskdebug dev dependency was added to package.json // prod expect(utils.addDependencies).toHaveBeenCalledWith(actionGenerator, { - abc: '1.2.3', def: '4.5.6' + abc: '1.2.3', + def: '4.5.6' }) // dev expect(utils.addDependencies).toHaveBeenCalledWith(actionGenerator, { xyz: '3.2.1', - vuw: '6.5.4', - '@openwhisk/wskdebug': expect.any(String) + vuw: '6.5.4' }, true) })