@pwrdrvr/microapps-publish 0.0.23 → 0.0.27
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/dist/commands/nextjs-docker-auto.d.ts +6 -0
- package/dist/commands/nextjs-docker-auto.d.ts.map +1 -1
- package/dist/commands/nextjs-docker-auto.js +109 -31
- package/dist/commands/nextjs-docker-auto.js.map +1 -1
- package/dist/commands/nextjs-version-restore.d.ts.map +1 -1
- package/dist/commands/nextjs-version-restore.js +1 -6
- package/dist/commands/nextjs-version-restore.js.map +1 -1
- package/dist/commands/nextjs-version.d.ts.map +1 -1
- package/dist/commands/nextjs-version.js +1 -6
- package/dist/commands/nextjs-version.js.map +1 -1
- package/dist/commands/preflight.d.ts +1 -0
- package/dist/commands/preflight.d.ts.map +1 -1
- package/dist/commands/preflight.js +18 -11
- package/dist/commands/preflight.js.map +1 -1
- package/dist/commands/publish-static.d.ts +20 -0
- package/dist/commands/publish-static.d.ts.map +1 -0
- package/dist/commands/publish-static.js +281 -0
- package/dist/commands/publish-static.js.map +1 -0
- package/dist/commands/publish.d.ts +4 -0
- package/dist/commands/publish.d.ts.map +1 -1
- package/dist/commands/publish.js +83 -22
- package/dist/commands/publish.js.map +1 -1
- package/dist/lib/DeployClient.d.ts +10 -2
- package/dist/lib/DeployClient.d.ts.map +1 -1
- package/dist/lib/DeployClient.js +9 -4
- package/dist/lib/DeployClient.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/nextjs-docker-auto.ts +122 -38
- package/src/commands/nextjs-version-restore.ts +1 -6
- package/src/commands/nextjs-version.ts +1 -6
- package/src/commands/preflight.ts +19 -13
- package/src/commands/publish-static.ts +322 -0
- package/src/commands/publish.ts +95 -28
- package/src/lib/DeployClient.ts +15 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeployClient.js","sourceRoot":"","sources":["../../src/lib/DeployClient.ts"],"names":[],"mappings":";;;AAAA,uEAAiD;AAejD,MAAq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CAAC,qBAAqB,MAAM,CAAC,GAAG,CAAC,IAAI,IAAI,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;aACrE;iBAAM;gBACL,MAAM,CAAC,uBAAuB,SAAS,CAAC,UAAU,EAAE,CAAC,CAAC;gBACtD,MAAM,IAAI,KAAK,CAAC,4CAA4C,SAAS,CAAC,UAAU,EAAE,CAAC,CAAC;aACrF;SACF;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,wCAAwC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;SACrF;IACH,CAAC;;AAzHH,+BA0HC;AAzHiB,oBAAO,GAAG,IAAI,MAAM,CAAC,YAAY,CAAC;IAChD,WAAW,EAAE,CAAC;CACf,CAAC,CAAC;AACa,qBAAQ,GAAG,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -5,7 +5,6 @@ import * as lambda from '@aws-sdk/client-lambda';
|
|
|
5
5
|
import * as s3 from '@aws-sdk/client-s3';
|
|
6
6
|
import * as sts from '@aws-sdk/client-sts';
|
|
7
7
|
import { Command, flags as flagsParser } from '@oclif/command';
|
|
8
|
-
import * as chalk from 'chalk';
|
|
9
8
|
import * as path from 'path';
|
|
10
9
|
import { promises as fs, pathExists, createReadStream } from 'fs-extra';
|
|
11
10
|
import { Listr, ListrTask } from 'listr2';
|
|
@@ -81,11 +80,49 @@ export class DockerAutoCommand extends Command {
|
|
|
81
80
|
description: 'Name (not URI) of the Docker repo for the app',
|
|
82
81
|
}),
|
|
83
82
|
leaveCopy: flagsParser.boolean({
|
|
84
|
-
char: '
|
|
83
|
+
char: 'f',
|
|
85
84
|
default: false,
|
|
86
85
|
required: false,
|
|
87
86
|
description: 'Leave a copy of the modifed files as .modified',
|
|
88
87
|
}),
|
|
88
|
+
appLambdaName: flagsParser.string({
|
|
89
|
+
char: 'l',
|
|
90
|
+
multiple: false,
|
|
91
|
+
required: false,
|
|
92
|
+
description: 'Name of the application lambda function',
|
|
93
|
+
}),
|
|
94
|
+
appName: flagsParser.string({
|
|
95
|
+
char: 'a',
|
|
96
|
+
multiple: false,
|
|
97
|
+
required: false,
|
|
98
|
+
description: 'MicroApps app name',
|
|
99
|
+
}),
|
|
100
|
+
staticAssetsPath: flagsParser.string({
|
|
101
|
+
char: 's',
|
|
102
|
+
multiple: false,
|
|
103
|
+
required: false,
|
|
104
|
+
description:
|
|
105
|
+
'Path to files to be uploaded to S3 static bucket at app/version/ path. Do include app/version/ in path if files are already "rooted" under that path locally.',
|
|
106
|
+
}),
|
|
107
|
+
defaultFile: flagsParser.string({
|
|
108
|
+
char: 'i',
|
|
109
|
+
multiple: false,
|
|
110
|
+
required: false,
|
|
111
|
+
description:
|
|
112
|
+
'Default file to return when the app is loaded via the router without a version (e.g. when app/ is requested).',
|
|
113
|
+
}),
|
|
114
|
+
overwrite: flagsParser.boolean({
|
|
115
|
+
char: 'o',
|
|
116
|
+
required: false,
|
|
117
|
+
default: false,
|
|
118
|
+
description:
|
|
119
|
+
'Allow overwrite - Warn but do not fail if version exists. Discouraged outside of test envs if cacheable static files have changed.',
|
|
120
|
+
}),
|
|
121
|
+
noCache: flagsParser.boolean({
|
|
122
|
+
required: false,
|
|
123
|
+
default: false,
|
|
124
|
+
description: 'Force revalidation of CloudFront and browser caching of static assets',
|
|
125
|
+
}),
|
|
89
126
|
};
|
|
90
127
|
|
|
91
128
|
private VersionAndAlias: IVersions;
|
|
@@ -95,20 +132,31 @@ export class DockerAutoCommand extends Command {
|
|
|
95
132
|
private _restoreFilesStarted = false;
|
|
96
133
|
|
|
97
134
|
async run(): Promise<void> {
|
|
135
|
+
const config = Config.instance;
|
|
136
|
+
|
|
98
137
|
// const RUNNING_TEXT = ' RUNS ';
|
|
99
138
|
// const RUNNING = chalk.reset.inverse.yellow.bold(RUNNING_TEXT) + ' ';
|
|
100
139
|
const RUNNING = ''; //chalk.reset.inverse.yellow.bold(RUNNING_TEXT) + ' ';
|
|
101
140
|
|
|
102
141
|
const { flags: parsedFlags } = this.parse(DockerAutoCommand);
|
|
103
|
-
const
|
|
142
|
+
const appLambdaName = parsedFlags.appLambdaName ?? config.app.lambdaName;
|
|
143
|
+
const appName = parsedFlags.appName ?? config.app.name;
|
|
104
144
|
const leaveFiles = parsedFlags.leaveCopy;
|
|
105
|
-
const
|
|
106
|
-
const
|
|
145
|
+
const deployerLambdaName = parsedFlags.deployerLambdaName ?? config.deployer.lambdaName;
|
|
146
|
+
const semVer = parsedFlags.newVersion ?? config.app.semVer;
|
|
147
|
+
const ecrRepo = parsedFlags.repoName ?? config.app.ecrRepoName;
|
|
148
|
+
const staticAssetsPath = parsedFlags.staticAssetsPath ?? config.app.staticAssetsPath;
|
|
149
|
+
const defaultFile = parsedFlags.defaultFile ?? config.app.defaultFile;
|
|
150
|
+
const overwrite = parsedFlags.overwrite;
|
|
151
|
+
const noCache = parsedFlags.noCache;
|
|
107
152
|
|
|
108
153
|
// Override the config value
|
|
109
|
-
|
|
110
|
-
config.
|
|
111
|
-
config.app.
|
|
154
|
+
config.deployer.lambdaName = deployerLambdaName;
|
|
155
|
+
config.app.lambdaName = appLambdaName;
|
|
156
|
+
config.app.name = appName;
|
|
157
|
+
config.app.semVer = semVer;
|
|
158
|
+
config.app.staticAssetsPath = staticAssetsPath;
|
|
159
|
+
config.app.defaultFile = defaultFile;
|
|
112
160
|
|
|
113
161
|
// Get the account ID and region from STS
|
|
114
162
|
// TODO: Move this to the right place
|
|
@@ -133,7 +181,7 @@ export class DockerAutoCommand extends Command {
|
|
|
133
181
|
config.app.ecrRepoName = `microapps-app-${config.app.name}${Config.envLevel}-repo`;
|
|
134
182
|
}
|
|
135
183
|
|
|
136
|
-
this.VersionAndAlias = createVersions(
|
|
184
|
+
this.VersionAndAlias = createVersions(semVer);
|
|
137
185
|
const versionOnly = { version: this.VersionAndAlias.version };
|
|
138
186
|
|
|
139
187
|
this.FILES_TO_MODIFY = [
|
|
@@ -154,11 +202,8 @@ export class DockerAutoCommand extends Command {
|
|
|
154
202
|
await restoreFiles(this.FILES_TO_MODIFY);
|
|
155
203
|
});
|
|
156
204
|
|
|
157
|
-
if (config === undefined) {
|
|
158
|
-
this.error('Failed to load the config file');
|
|
159
|
-
}
|
|
160
205
|
if (config.app.staticAssetsPath === undefined) {
|
|
161
|
-
this.error('
|
|
206
|
+
this.error('staticAssetsPath must be specified');
|
|
162
207
|
}
|
|
163
208
|
|
|
164
209
|
//
|
|
@@ -202,16 +247,23 @@ export class DockerAutoCommand extends Command {
|
|
|
202
247
|
task.title = RUNNING + origTitle;
|
|
203
248
|
|
|
204
249
|
// Confirm the Version Does Not Exist in Published State
|
|
205
|
-
task.output = `Checking if deployed app/version already exists for ${config.app.name}/${
|
|
250
|
+
task.output = `Checking if deployed app/version already exists for ${config.app.name}/${semVer}`;
|
|
206
251
|
ctx.preflightResult = await DeployClient.DeployVersionPreflight({
|
|
207
252
|
config,
|
|
253
|
+
overwrite,
|
|
208
254
|
output: (message: string) => (task.output = message),
|
|
209
255
|
});
|
|
210
256
|
if (ctx.preflightResult.exists) {
|
|
211
|
-
|
|
257
|
+
if (!overwrite) {
|
|
258
|
+
throw new Error(
|
|
259
|
+
`App/Version already exists: ${config.app.name}/${config.app.semVer}`,
|
|
260
|
+
);
|
|
261
|
+
} else {
|
|
262
|
+
task.title = `Warning: App/Version already exists: ${config.app.name}/${config.app.semVer}`;
|
|
263
|
+
}
|
|
264
|
+
} else {
|
|
265
|
+
task.title = `App/Version does not exist: ${config.app.name}/${config.app.semVer}`;
|
|
212
266
|
}
|
|
213
|
-
|
|
214
|
-
task.title = origTitle;
|
|
215
267
|
},
|
|
216
268
|
},
|
|
217
269
|
{
|
|
@@ -220,7 +272,7 @@ export class DockerAutoCommand extends Command {
|
|
|
220
272
|
const origTitle = task.title;
|
|
221
273
|
task.title = RUNNING + origTitle;
|
|
222
274
|
|
|
223
|
-
task.output = `Invoking serverless next.js build for ${config.app.name}/${
|
|
275
|
+
task.output = `Invoking serverless next.js build for ${config.app.name}/${semVer}`;
|
|
224
276
|
|
|
225
277
|
// Run the serverless next.js build
|
|
226
278
|
await asyncExec('serverless');
|
|
@@ -256,7 +308,7 @@ export class DockerAutoCommand extends Command {
|
|
|
256
308
|
task.title = RUNNING + origTitle;
|
|
257
309
|
|
|
258
310
|
// Update the Lambda function
|
|
259
|
-
await this.deployToLambda(config, this.VersionAndAlias, task);
|
|
311
|
+
await this.deployToLambda({ config, versions: this.VersionAndAlias, overwrite, task });
|
|
260
312
|
|
|
261
313
|
task.title = origTitle;
|
|
262
314
|
},
|
|
@@ -318,6 +370,16 @@ export class DockerAutoCommand extends Command {
|
|
|
318
370
|
},
|
|
319
371
|
});
|
|
320
372
|
|
|
373
|
+
// Setup caching on static assets
|
|
374
|
+
// NoCache - Only used for test deploys, requires browser and CloudFront to refetch every time
|
|
375
|
+
// Overwrite - Reduces default cache time period from 24 hours to 15 minutes
|
|
376
|
+
// Default - 24 hours
|
|
377
|
+
const CacheControl = noCache
|
|
378
|
+
? 'max-age=0, must-revalidate, public'
|
|
379
|
+
: overwrite
|
|
380
|
+
? `max-age=${15 * 60}, public`
|
|
381
|
+
: `max-age=${24 * 60 * 60}, public`;
|
|
382
|
+
|
|
321
383
|
const pathWithoutAppAndVer = path.join(S3Uploader.TempDir, destinationPrefix);
|
|
322
384
|
|
|
323
385
|
const tasks: ListrTask<IContext>[] = ctx.files.map((filePath) => ({
|
|
@@ -335,7 +397,7 @@ export class DockerAutoCommand extends Command {
|
|
|
335
397
|
Key: path.relative(S3Uploader.TempDir, filePath),
|
|
336
398
|
Body: createReadStream(filePath),
|
|
337
399
|
ContentType: contentType(path.basename(filePath)) || 'application/octet-stream',
|
|
338
|
-
CacheControl
|
|
400
|
+
CacheControl,
|
|
339
401
|
},
|
|
340
402
|
});
|
|
341
403
|
await upload.done();
|
|
@@ -363,7 +425,7 @@ export class DockerAutoCommand extends Command {
|
|
|
363
425
|
task.title = RUNNING + origTitle;
|
|
364
426
|
|
|
365
427
|
// Call Deployer to Create App if Not Exists
|
|
366
|
-
await DeployClient.CreateApp(config);
|
|
428
|
+
await DeployClient.CreateApp({ config });
|
|
367
429
|
|
|
368
430
|
task.title = origTitle;
|
|
369
431
|
},
|
|
@@ -375,7 +437,12 @@ export class DockerAutoCommand extends Command {
|
|
|
375
437
|
task.title = RUNNING + origTitle;
|
|
376
438
|
|
|
377
439
|
// Call Deployer to Deploy AppName/Version
|
|
378
|
-
await DeployClient.DeployVersion(
|
|
440
|
+
await DeployClient.DeployVersion({
|
|
441
|
+
config,
|
|
442
|
+
appType: 'lambda',
|
|
443
|
+
overwrite,
|
|
444
|
+
output: (message: string) => (task.output = message),
|
|
445
|
+
});
|
|
379
446
|
|
|
380
447
|
task.title = origTitle;
|
|
381
448
|
},
|
|
@@ -390,9 +457,6 @@ export class DockerAutoCommand extends Command {
|
|
|
390
457
|
|
|
391
458
|
try {
|
|
392
459
|
await tasks.run();
|
|
393
|
-
// this.log(`Published: ${config.app.name}/${config.app.semVer}`);
|
|
394
|
-
} catch (error) {
|
|
395
|
-
this.log(`Caught exception: ${error.message}`);
|
|
396
460
|
} finally {
|
|
397
461
|
await S3Uploader.removeTempDirIfExists();
|
|
398
462
|
await restoreFiles(this.FILES_TO_MODIFY);
|
|
@@ -439,11 +503,14 @@ export class DockerAutoCommand extends Command {
|
|
|
439
503
|
* @param config
|
|
440
504
|
* @param versions
|
|
441
505
|
*/
|
|
442
|
-
private async deployToLambda(
|
|
443
|
-
config: IConfig
|
|
444
|
-
versions: IVersions
|
|
445
|
-
|
|
446
|
-
|
|
506
|
+
private async deployToLambda(opts: {
|
|
507
|
+
config: IConfig;
|
|
508
|
+
versions: IVersions;
|
|
509
|
+
overwrite: boolean;
|
|
510
|
+
task: TaskWrapper<IContext, typeof DefaultRenderer>;
|
|
511
|
+
}): Promise<void> {
|
|
512
|
+
const { config, versions, overwrite, task } = opts;
|
|
513
|
+
|
|
447
514
|
// Create Lambda version
|
|
448
515
|
task.output = 'Updating Lambda code to point to new Docker image';
|
|
449
516
|
const resultUpdate = await lambdaClient.send(
|
|
@@ -487,13 +554,30 @@ export class DockerAutoCommand extends Command {
|
|
|
487
554
|
|
|
488
555
|
// Create Lambda alias point
|
|
489
556
|
task.output = `Creating the lambda alias for the new version: ${lambdaVersion}`;
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
557
|
+
try {
|
|
558
|
+
const resultLambdaAlias = await lambdaClient.send(
|
|
559
|
+
new lambda.CreateAliasCommand({
|
|
560
|
+
FunctionName: config.app.lambdaName,
|
|
561
|
+
Name: versions.alias,
|
|
562
|
+
FunctionVersion: lambdaVersion,
|
|
563
|
+
}),
|
|
564
|
+
);
|
|
565
|
+
task.output = `Lambda alias created, name: ${resultLambdaAlias.Name}`;
|
|
566
|
+
} catch (error) {
|
|
567
|
+
if (overwrite && error.name === 'ResourceConflictException') {
|
|
568
|
+
task.output = `Alias exists, updating the lambda alias for version: ${lambdaVersion}`;
|
|
569
|
+
|
|
570
|
+
const resultLambdaAlias = await lambdaClient.send(
|
|
571
|
+
new lambda.UpdateAliasCommand({
|
|
572
|
+
FunctionName: config.app.lambdaName,
|
|
573
|
+
Name: versions.alias,
|
|
574
|
+
FunctionVersion: lambdaVersion,
|
|
575
|
+
}),
|
|
576
|
+
);
|
|
577
|
+
task.output = `Lambda alias updated, name: ${resultLambdaAlias.Name}`;
|
|
578
|
+
} else {
|
|
579
|
+
throw error;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
498
582
|
}
|
|
499
583
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import { Command, flags as flagsParser } from '@oclif/command';
|
|
3
|
-
import * as chalk from 'chalk';
|
|
4
3
|
import { Listr } from 'listr2';
|
|
5
4
|
import { createVersions, IVersions, restoreFiles } from '../lib/Versions';
|
|
6
5
|
|
|
@@ -65,10 +64,6 @@ export class NextJSVersionRestoreCommand extends Command {
|
|
|
65
64
|
},
|
|
66
65
|
);
|
|
67
66
|
|
|
68
|
-
|
|
69
|
-
await tasks.run();
|
|
70
|
-
} catch (error) {
|
|
71
|
-
this.log(`Caught exception: ${error.message}`);
|
|
72
|
-
}
|
|
67
|
+
await tasks.run();
|
|
73
68
|
}
|
|
74
69
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import { Command, flags as flagsParser } from '@oclif/command';
|
|
3
|
-
import * as chalk from 'chalk';
|
|
4
3
|
import { Listr } from 'listr2';
|
|
5
4
|
import { Config } from '../config/Config';
|
|
6
5
|
import { createVersions, IVersions, restoreFiles, writeNewVersions } from '../lib/Versions';
|
|
@@ -105,10 +104,6 @@ export class NextJSVersionCommand extends Command {
|
|
|
105
104
|
},
|
|
106
105
|
);
|
|
107
106
|
|
|
108
|
-
|
|
109
|
-
await tasks.run();
|
|
110
|
-
} catch (error) {
|
|
111
|
-
this.log(`Caught exception: ${error.message}`);
|
|
112
|
-
}
|
|
107
|
+
await tasks.run();
|
|
113
108
|
}
|
|
114
109
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import * as sts from '@aws-sdk/client-sts';
|
|
3
3
|
import { Command, flags as flagsParser } from '@oclif/command';
|
|
4
|
-
import * as chalk from 'chalk';
|
|
5
4
|
import { Listr } from 'listr2';
|
|
6
5
|
import { Config } from '../config/Config';
|
|
7
6
|
import DeployClient from '../lib/DeployClient';
|
|
@@ -38,6 +37,13 @@ export class PreflightCommand extends Command {
|
|
|
38
37
|
required: true,
|
|
39
38
|
description: 'Name of the deployer lambda function',
|
|
40
39
|
}),
|
|
40
|
+
overwrite: flagsParser.boolean({
|
|
41
|
+
char: 'o',
|
|
42
|
+
required: false,
|
|
43
|
+
default: false,
|
|
44
|
+
description:
|
|
45
|
+
'Allow overwrite - Warn but do not fail if version exists. Discouraged outside of test envs if cacheable static files have changed.',
|
|
46
|
+
}),
|
|
41
47
|
};
|
|
42
48
|
|
|
43
49
|
async run(): Promise<void> {
|
|
@@ -52,6 +58,7 @@ export class PreflightCommand extends Command {
|
|
|
52
58
|
const appName = parsedFlags.appName ?? config.app.name;
|
|
53
59
|
const deployerLambdaName = parsedFlags.deployerLambdaName ?? config.deployer.lambdaName;
|
|
54
60
|
const semVer = parsedFlags.newVersion ?? config.app.semVer;
|
|
61
|
+
const overwrite = parsedFlags.overwrite;
|
|
55
62
|
|
|
56
63
|
// Override the config value
|
|
57
64
|
config.deployer.lambdaName = deployerLambdaName;
|
|
@@ -75,10 +82,6 @@ export class PreflightCommand extends Command {
|
|
|
75
82
|
}
|
|
76
83
|
}
|
|
77
84
|
|
|
78
|
-
if (config === undefined) {
|
|
79
|
-
this.error('Failed to load the config file');
|
|
80
|
-
}
|
|
81
|
-
|
|
82
85
|
//
|
|
83
86
|
// Setup Tasks
|
|
84
87
|
//
|
|
@@ -96,13 +99,20 @@ export class PreflightCommand extends Command {
|
|
|
96
99
|
const preflightResult = await DeployClient.DeployVersionPreflight({
|
|
97
100
|
config,
|
|
98
101
|
needS3Creds: false,
|
|
102
|
+
overwrite,
|
|
99
103
|
output: (message: string) => (task.output = message),
|
|
100
104
|
});
|
|
101
105
|
if (preflightResult.exists) {
|
|
102
|
-
|
|
106
|
+
if (!overwrite) {
|
|
107
|
+
throw new Error(
|
|
108
|
+
`App/Version already exists: ${config.app.name}/${config.app.semVer}`,
|
|
109
|
+
);
|
|
110
|
+
} else {
|
|
111
|
+
task.title = `Warning: App/Version already exists: ${config.app.name}/${config.app.semVer}`;
|
|
112
|
+
}
|
|
113
|
+
} else {
|
|
114
|
+
task.title = `App/Version does not exist: ${config.app.name}/${config.app.semVer}`;
|
|
103
115
|
}
|
|
104
|
-
|
|
105
|
-
task.title = origTitle;
|
|
106
116
|
},
|
|
107
117
|
},
|
|
108
118
|
],
|
|
@@ -113,10 +123,6 @@ export class PreflightCommand extends Command {
|
|
|
113
123
|
},
|
|
114
124
|
);
|
|
115
125
|
|
|
116
|
-
|
|
117
|
-
await tasks.run();
|
|
118
|
-
} catch (error) {
|
|
119
|
-
this.log(`Caught exception: ${error.message}`);
|
|
120
|
-
}
|
|
126
|
+
await tasks.run();
|
|
121
127
|
}
|
|
122
128
|
}
|