@adobe/helix-deploy 5.0.6 → 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 +7 -0
- package/package.json +1 -1
- package/src/ActionBuilder.js +5 -1
- package/src/BaseConfig.js +12 -1
- package/src/bundler/BaseBundler.js +6 -3
- package/src/template/validate-bundle.js +42 -7
- package/src/utils.js +2 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
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
|
+
|
|
1
8
|
## [5.0.6](https://github.com/adobe/helix-deploy/compare/v5.0.5...v5.0.6) (2022-01-11)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/ActionBuilder.js
CHANGED
|
@@ -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 (
|
|
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
|
-
|
|
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() {
|
|
@@ -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,
|
|
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
|
|
18
|
-
if (!
|
|
19
|
-
throw Error('Action has no
|
|
18
|
+
const lambda = bundle.default?.lambda;
|
|
19
|
+
if (!lambda || typeof lambda !== 'function') {
|
|
20
|
+
throw Error('Action has no lambda() function.');
|
|
20
21
|
}
|
|
21
|
-
|
|
22
|
-
|
|
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,
|
|
158
|
+
export async function validateBundle(bundlePath, cfg) {
|
|
159
159
|
try {
|
|
160
|
-
const
|
|
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);
|