@adobe/helix-deploy 5.0.3 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,31 @@
1
+ # [5.1.0](https://github.com/adobe/helix-deploy/compare/v5.0.6...v5.1.0) (2022-01-12)
2
+
3
+
4
+ ### Features
5
+
6
+ * use lambda adapter to validate bundle and execute it ([#354](https://github.com/adobe/helix-deploy/issues/354)) ([c48b4f0](https://github.com/adobe/helix-deploy/commit/c48b4f0dfcae09fd784212b770bcdc7246a7d332)), closes [#353](https://github.com/adobe/helix-deploy/issues/353)
7
+
8
+ ## [5.0.6](https://github.com/adobe/helix-deploy/compare/v5.0.5...v5.0.6) (2022-01-11)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **deps:** update external fixes ([#352](https://github.com/adobe/helix-deploy/issues/352)) ([ee411f3](https://github.com/adobe/helix-deploy/commit/ee411f3c03993f23eecbd024eff8d2a7e0b97ab7))
14
+
15
+ ## [5.0.5](https://github.com/adobe/helix-deploy/compare/v5.0.4...v5.0.5) (2022-01-03)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * use fixed import conditions ([#350](https://github.com/adobe/helix-deploy/issues/350)) ([28464d2](https://github.com/adobe/helix-deploy/commit/28464d245229236ff15bad6e20278ce5ebd8594b))
21
+
22
+ ## [5.0.4](https://github.com/adobe/helix-deploy/compare/v5.0.3...v5.0.4) (2022-01-03)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * **deps:** update external fixes ([#349](https://github.com/adobe/helix-deploy/issues/349)) ([ab4ceda](https://github.com/adobe/helix-deploy/commit/ab4cedaf66372443c401d0a476af3b5f11860c4b))
28
+
1
29
  ## [5.0.3](https://github.com/adobe/helix-deploy/compare/v5.0.2...v5.0.3) (2021-12-14)
2
30
 
3
31
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-deploy",
3
- "version": "5.0.3",
3
+ "version": "5.1.0",
4
4
  "description": "Library and Commandline Tools to build and deploy OpenWhisk Actions",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/adobe/helix-deploy#readme",
@@ -39,59 +39,59 @@
39
39
  "dependencies": {
40
40
  "@adobe/fastly-native-promises": "2.0.0",
41
41
  "@adobe/helix-fetch": "3.0.0",
42
- "@aws-sdk/client-apigatewayv2": "3.43.0",
43
- "@aws-sdk/client-lambda": "3.43.0",
44
- "@aws-sdk/client-s3": "3.44.0",
45
- "@aws-sdk/client-secrets-manager": "3.43.0",
46
- "@aws-sdk/client-ssm": "3.44.0",
42
+ "@aws-sdk/client-apigatewayv2": "3.46.0",
43
+ "@aws-sdk/client-lambda": "3.46.0",
44
+ "@aws-sdk/client-s3": "3.46.0",
45
+ "@aws-sdk/client-secrets-manager": "3.46.0",
46
+ "@aws-sdk/client-ssm": "3.46.0",
47
47
  "@azure/arm-appservice": "9.0.0",
48
- "@azure/ms-rest-nodeauth": "3.1.0",
48
+ "@azure/ms-rest-nodeauth": "3.1.1",
49
49
  "@fastly/js-compute": "0.2.1",
50
50
  "@google-cloud/functions": "1.2.0",
51
51
  "@google-cloud/secret-manager": "3.10.1",
52
- "@google-cloud/storage": "5.16.1",
53
- "@rollup/plugin-alias": "3.1.8",
52
+ "@google-cloud/storage": "5.17.0",
53
+ "@rollup/plugin-alias": "3.1.9",
54
54
  "@rollup/plugin-commonjs": "21.0.1",
55
55
  "@rollup/plugin-json": "4.1.0",
56
- "@rollup/plugin-node-resolve": "13.0.6",
56
+ "@rollup/plugin-node-resolve": "13.1.3",
57
57
  "archiver": "5.3.0",
58
58
  "chalk-template": "0.2.0",
59
59
  "constants-browserify": "1.0.0",
60
60
  "dotenv": "10.0.0",
61
- "express": "4.17.1",
61
+ "express": "4.17.2",
62
62
  "form-data": "4.0.0",
63
63
  "fs-extra": "10.0.0",
64
64
  "get-stream": "6.0.1",
65
- "isomorphic-git": "1.10.2",
66
- "openwhisk": "3.21.5",
65
+ "isomorphic-git": "1.10.3",
66
+ "openwhisk": "3.21.6",
67
67
  "proxyquire": "2.1.3",
68
- "rollup": "2.61.1",
68
+ "rollup": "2.63.0",
69
69
  "rollup-plugin-terser": "7.0.2",
70
70
  "semver": "7.3.5",
71
71
  "tar": "6.1.11",
72
72
  "webpack": "5.65.0",
73
- "yargs": "17.3.0"
73
+ "yargs": "17.3.1"
74
74
  },
75
75
  "devDependencies": {
76
- "@adobe/eslint-config-helix": "1.3.1",
76
+ "@adobe/eslint-config-helix": "1.3.2",
77
77
  "@adobe/helix-shared-wrap": "1.0.0",
78
78
  "@adobe/helix-status": "9.2.4",
79
79
  "@adobe/helix-universal-logger": "2.0.0",
80
80
  "@semantic-release/changelog": "6.0.1",
81
81
  "@semantic-release/git": "10.0.1",
82
- "c8": "7.10.0",
82
+ "c8": "7.11.0",
83
83
  "chai": "4.3.4",
84
84
  "chai-http": "4.3.0",
85
85
  "codecov": "3.8.3",
86
- "eslint": "8.4.1",
86
+ "eslint": "8.6.0",
87
87
  "eslint-plugin-header": "3.1.1",
88
- "eslint-plugin-import": "2.25.3",
88
+ "eslint-plugin-import": "2.25.4",
89
89
  "husky": "7.0.4",
90
- "lint-staged": "12.1.2",
90
+ "lint-staged": "12.1.7",
91
91
  "mocha": "9.1.3",
92
92
  "mocha-junit-reporter": "2.0.2",
93
93
  "mocha-multi-reporters": "1.5.1",
94
- "nock": "13.2.1",
94
+ "nock": "13.2.2",
95
95
  "semantic-release": "18.0.1",
96
96
  "sinon": "12.0.1",
97
97
  "yauzl": "2.10.0"
@@ -381,6 +381,10 @@ export default class ActionBuilder {
381
381
  for (const bundler of this.bundlers) {
382
382
  await bundler.createBundle();
383
383
  await bundler.createArchive();
384
+ }
385
+ }
386
+ if (cfg.build || cfg.test !== undefined || cfg.testBundle !== undefined) {
387
+ for (const bundler of this.bundlers) {
384
388
  await bundler.validateBundle();
385
389
  }
386
390
  }
@@ -408,7 +412,7 @@ export default class ActionBuilder {
408
412
  await this.delete();
409
413
  }
410
414
 
411
- if (typeof cfg.test === 'string' || Object.keys(cfg.testParams).length) {
415
+ if (cfg.test !== undefined || Object.keys(cfg.testParams).length) {
412
416
  await this.validateDeployers();
413
417
  await this.test();
414
418
  }
package/src/BaseConfig.js CHANGED
@@ -58,6 +58,7 @@ export default class BaseConfig {
58
58
  nodeVersion: null,
59
59
  deploy: false,
60
60
  test: null,
61
+ testBundle: null,
61
62
  testUrl: null,
62
63
  testParams: {},
63
64
  testHeaders: {},
@@ -173,6 +174,7 @@ export default class BaseConfig {
173
174
  .withDelete(argv.delete)
174
175
  .withDeploy(argv.deploy)
175
176
  .withTest(argv.test)
177
+ .withTestBundle(argv.testBundle)
176
178
  .withTestParams(argv.testParams)
177
179
  .withTestHeaders(argv.testHeaders)
178
180
  .withTestUrl(argv.testUrl)
@@ -279,6 +281,11 @@ export default class BaseConfig {
279
281
  return this;
280
282
  }
281
283
 
284
+ withTestBundle(enable) {
285
+ this.testBundle = enable;
286
+ return this;
287
+ }
288
+
282
289
  withTestUrl(value) {
283
290
  this.testUrl = value;
284
291
  return this;
@@ -572,7 +579,7 @@ export default class BaseConfig {
572
579
  default: '.',
573
580
  })
574
581
 
575
- .group(['help', 'build', 'deploy', 'test', 'update-package', 'version-link', 'delete'], 'Operation Options')
582
+ .group(['help', 'build', 'deploy', 'test', 'test-bundle', 'update-package', 'version-link', 'delete'], 'Operation Options')
576
583
  .option('build', {
577
584
  description: 'Build the deployment package',
578
585
  type: 'boolean',
@@ -587,6 +594,10 @@ export default class BaseConfig {
587
594
  description: 'Invoke action after deployment. Can be relative url or "true"',
588
595
  type: 'string',
589
596
  })
597
+ .option('test-bundle', {
598
+ description: 'Invoke bundle after build. Can be relative url or "true". Defaults to the same as --test',
599
+ type: 'string',
600
+ })
590
601
  .option('version-link', {
591
602
  alias: 'l',
592
603
  description: 'Create symlinks (sequences) after deployment. "major" and "minor" will create respective version links',
@@ -60,12 +60,15 @@ export default class BaseBundler {
60
60
  async validateBundle() {
61
61
  const { cfg } = this;
62
62
  cfg.log.info('--: validating bundle ...');
63
- const result = await validateBundle(cfg.bundle);
63
+ const result = await validateBundle(cfg.bundle, cfg);
64
64
  if (result.error) {
65
- cfg.log.error(chalk`{red error:}`, result.error);
66
65
  throw Error(`Validation failed: ${result.error}`);
67
66
  }
68
- cfg.log.info(chalk`{green ok:} bundle can be loaded and has a {grey main()} function.`);
67
+ if (result.response) {
68
+ cfg.log.info(chalk`{green ok:} bundle can be loaded and {grey lambda()} function can be executed.`);
69
+ } else {
70
+ cfg.log.info(chalk`{green ok:} bundle can be loaded and has a {grey lambda()} function.`);
71
+ }
69
72
  }
70
73
 
71
74
  async createArchive() {
@@ -74,6 +74,8 @@ export default class WebpackBundler extends BaseBundler {
74
74
  // the main.js is imported in the universal adapter and is _the_ action entry point
75
75
  './main.js': cfg.file,
76
76
  },
77
+ // use fixed conditions to omit the `development` condition.
78
+ conditionNames: ['node', 'require'],
77
79
  },
78
80
  node: {
79
81
  __dirname: true,
@@ -9,19 +9,54 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
- async function run(bundlePath, opts) {
12
+ async function run(bundlePath, cfg) {
13
13
  const result = {
14
+ status: 'ok',
14
15
  };
15
16
  try {
16
17
  const bundle = await import(bundlePath);
17
- const main = bundle.default?.main;
18
- if (!main || typeof main !== 'function') {
19
- throw Error('Action has no main() function.');
18
+ const lambda = bundle.default?.lambda;
19
+ if (!lambda || typeof lambda !== 'function') {
20
+ throw Error('Action has no lambda() function.');
20
21
  }
21
- if (opts.invoke) {
22
- result.response = await main({});
22
+ const test = cfg.testBundle ?? cfg.test;
23
+ if (test !== undefined) {
24
+ const event = {
25
+ headers: cfg.testHeaders || {},
26
+ rawPath: `/${cfg.packageName}/${cfg.baseName}/${cfg.version}`,
27
+ rawQueryString: '',
28
+ pathParameters: {
29
+ path: '',
30
+ },
31
+ requestContext: {
32
+ domainName: 'localhost',
33
+ http: {
34
+ method: 'get',
35
+ },
36
+ },
37
+ };
38
+
39
+ const testUrl = String(test).startsWith('/') ? test : cfg.testUrl;
40
+ if (testUrl) {
41
+ const url = new URL(testUrl, 'https://localhost/');
42
+ event.pathParameters.path = url.pathname.substring(1);
43
+ event.rawPath += url.pathname;
44
+ event.rawQueryString = url.searchParams.toString();
45
+ }
46
+ const fn = typeof lambda.raw === 'function' ? lambda.raw : lambda;
47
+ result.response = await fn(event, {
48
+ invokedFunctionArn: `arn:aws:lambda:us-east-1:118435662149:function:${cfg.packageName}--${cfg.baseName}:${cfg.version}`,
49
+ getRemainingTimeInMillis: () => 60 * 1000,
50
+ });
51
+ if (cfg.verbose) {
52
+ // eslint-disable-next-line no-console
53
+ console.log(result.response);
54
+ }
55
+ if (result.response.statusCode !== 200) {
56
+ result.status = 'error';
57
+ result.error = result.response.statusCode;
58
+ }
23
59
  }
24
- result.status = 'ok';
25
60
  } catch (e) {
26
61
  result.status = 'error';
27
62
  result.error = `${e.message}\n${e.stack}`;
package/src/utils.js CHANGED
@@ -155,12 +155,9 @@ export function filterActions(fns, now, {
155
155
  ...cleanmajorbyage, ...cleanmajorbycount];
156
156
  }
157
157
 
158
- export async function validateBundle(bundlePath, invoke = false) {
158
+ export async function validateBundle(bundlePath, cfg) {
159
159
  try {
160
- const opts = {
161
- invoke,
162
- };
163
- const child = fork(path.resolve(__dirname, 'template', 'validate-bundle.js'), [bundlePath, JSON.stringify(opts)]);
160
+ const child = fork(path.resolve(__dirname, 'template', 'validate-bundle.js'), [bundlePath, JSON.stringify(cfg)]);
164
161
  const ret = await new Promise((resolve, reject) => {
165
162
  child.on('message', resolve);
166
163
  child.on('error', reject);