@pwrdrvr/microapps-publish 0.3.5-alpha.2 → 0.3.5-alpha.3
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-version-restore.d.ts.map +1 -1
- package/dist/commands/nextjs-version-restore.js +2 -1
- 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 +2 -1
- package/dist/commands/nextjs-version.js.map +1 -1
- package/dist/commands/publish-static.js +2 -2
- package/dist/commands/publish-static.js.map +1 -1
- package/dist/commands/publish.d.ts +3 -0
- package/dist/commands/publish.d.ts.map +1 -1
- package/dist/commands/publish.js +82 -22
- package/dist/commands/publish.js.map +1 -1
- package/dist/config/Application.d.ts +0 -8
- package/dist/config/Application.d.ts.map +1 -1
- package/dist/config/Application.js +3 -32
- package/dist/config/Application.js.map +1 -1
- package/dist/lib/DeployClient.d.ts +39 -1
- package/dist/lib/DeployClient.d.ts.map +1 -1
- package/dist/lib/DeployClient.js +87 -4
- package/dist/lib/DeployClient.js.map +1 -1
- package/dist/lib/Versions.d.ts +1 -13
- package/dist/lib/Versions.d.ts.map +1 -1
- package/dist/lib/Versions.js +1 -10
- package/dist/lib/Versions.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/nextjs-version-restore.ts +2 -1
- package/src/commands/nextjs-version.ts +2 -1
- package/src/commands/publish-static.ts +1 -1
- package/src/commands/publish.ts +85 -22
- package/src/commands-deprecated/{nextjs-docker-auto.ts → nextjs-docker-auto.skip} +2 -7
- package/src/config/Application.ts +3 -35
- package/src/lib/DeployClient.ts +130 -5
- package/src/lib/Versions.ts +1 -17
- package/dist/commands-deprecated/nextjs-docker-auto.d.ts +0 -44
- package/dist/commands-deprecated/nextjs-docker-auto.d.ts.map +0 -1
- package/dist/commands-deprecated/nextjs-docker-auto.js +0 -505
- package/dist/commands-deprecated/nextjs-docker-auto.js.map +0 -1
package/src/lib/DeployClient.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import * as lambda from '@aws-sdk/client-lambda';
|
|
2
2
|
import {
|
|
3
|
-
IDeployVersionPreflightRequest,
|
|
4
|
-
IDeployVersionPreflightResponse,
|
|
5
3
|
ICreateApplicationRequest,
|
|
6
4
|
IDeployerResponse,
|
|
5
|
+
IDeployVersionPreflightRequest,
|
|
6
|
+
IDeployVersionPreflightResponse,
|
|
7
7
|
IDeployVersionRequest,
|
|
8
8
|
IDeleteVersionRequest,
|
|
9
|
+
ILambdaAliasRequest,
|
|
10
|
+
ILambdaAliasResponse,
|
|
9
11
|
} from '@pwrdrvr/microapps-deployer-lib';
|
|
10
12
|
import { IConfig } from '../config/Config';
|
|
11
13
|
|
|
@@ -17,6 +19,8 @@ export interface IDeployVersionPreflightResult {
|
|
|
17
19
|
response: IDeployVersionPreflightResponse;
|
|
18
20
|
}
|
|
19
21
|
|
|
22
|
+
export type DeployVersionArgs = Parameters<typeof DeployClient.DeployVersionLite>;
|
|
23
|
+
|
|
20
24
|
export default class DeployClient {
|
|
21
25
|
static readonly _client = new lambda.LambdaClient({
|
|
22
26
|
maxAttempts: 8,
|
|
@@ -138,6 +142,59 @@ export default class DeployClient {
|
|
|
138
142
|
}
|
|
139
143
|
}
|
|
140
144
|
|
|
145
|
+
/**
|
|
146
|
+
* Create or update Lambda alias for specified Lambda version
|
|
147
|
+
* @param config
|
|
148
|
+
* @param output
|
|
149
|
+
* @returns
|
|
150
|
+
*/
|
|
151
|
+
public static async LambdaAlias(opts: {
|
|
152
|
+
appName: string;
|
|
153
|
+
semVer: string;
|
|
154
|
+
lambdaVersionArn: string;
|
|
155
|
+
overwrite: boolean;
|
|
156
|
+
deployerLambdaName: string;
|
|
157
|
+
output: (message: string) => void;
|
|
158
|
+
}): Promise<{ response: ILambdaAliasResponse }> {
|
|
159
|
+
const { appName, deployerLambdaName, lambdaVersionArn, overwrite, output, semVer } = opts;
|
|
160
|
+
|
|
161
|
+
const request: ILambdaAliasRequest = {
|
|
162
|
+
type: 'lambdaAlias',
|
|
163
|
+
appName,
|
|
164
|
+
semVer,
|
|
165
|
+
lambdaARN: lambdaVersionArn,
|
|
166
|
+
overwrite,
|
|
167
|
+
};
|
|
168
|
+
output(`Creating alias for version ARN: ${lambdaVersionArn}`);
|
|
169
|
+
const response = await this._client.send(
|
|
170
|
+
new lambda.InvokeCommand({
|
|
171
|
+
FunctionName: deployerLambdaName,
|
|
172
|
+
Payload: Buffer.from(JSON.stringify(request)),
|
|
173
|
+
}),
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
if (response.$metadata.httpStatusCode === 200 && response.Payload !== undefined) {
|
|
177
|
+
const dResponse = JSON.parse(
|
|
178
|
+
Buffer.from(response.Payload).toString('utf-8'),
|
|
179
|
+
) as ILambdaAliasResponse;
|
|
180
|
+
if (dResponse.statusCode > 299) {
|
|
181
|
+
output(`LambdaAlias failed: ${JSON.stringify(dResponse)}`);
|
|
182
|
+
throw new Error('LambdaAlias failed');
|
|
183
|
+
} else if (!dResponse.functionUrl) {
|
|
184
|
+
output(`LambdaAlias failed to return functionUrl: ${JSON.stringify(dResponse)}`);
|
|
185
|
+
throw new Error('LambdaAlias failed to return functionUrl');
|
|
186
|
+
} else if (dResponse.statusCode === 201) {
|
|
187
|
+
output(`Alias created: ${dResponse.lambdaAliasARN}`);
|
|
188
|
+
return { response: dResponse };
|
|
189
|
+
} else {
|
|
190
|
+
output(`Alias ${dResponse.actionTaken}: ${dResponse.lambdaAliasARN}`);
|
|
191
|
+
return { response: dResponse };
|
|
192
|
+
}
|
|
193
|
+
} else {
|
|
194
|
+
throw new Error(`Lambda call to LambdaAlias failed: ${JSON.stringify(response)}`);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
141
198
|
/**
|
|
142
199
|
* Copy S3 static assets from staging to live bucket.
|
|
143
200
|
* Create API Gateway Integration for app (if needed).
|
|
@@ -154,6 +211,7 @@ export default class DeployClient {
|
|
|
154
211
|
deployerLambdaName: string;
|
|
155
212
|
appType: 'lambda' | 'static' | 'lambda-url' | 'url';
|
|
156
213
|
startupType?: 'iframe' | 'direct';
|
|
214
|
+
url?: string;
|
|
157
215
|
overwrite: boolean;
|
|
158
216
|
output: (message: string) => void;
|
|
159
217
|
}): Promise<void> {
|
|
@@ -165,6 +223,7 @@ export default class DeployClient {
|
|
|
165
223
|
deployerLambdaName,
|
|
166
224
|
appType,
|
|
167
225
|
startupType = 'iframe',
|
|
226
|
+
url,
|
|
168
227
|
overwrite,
|
|
169
228
|
output,
|
|
170
229
|
} = opts;
|
|
@@ -172,9 +231,10 @@ export default class DeployClient {
|
|
|
172
231
|
type: 'deployVersion',
|
|
173
232
|
appType,
|
|
174
233
|
startupType,
|
|
175
|
-
appName
|
|
176
|
-
semVer
|
|
234
|
+
appName,
|
|
235
|
+
semVer,
|
|
177
236
|
defaultFile: defaultFile,
|
|
237
|
+
url,
|
|
178
238
|
overwrite,
|
|
179
239
|
...(['lambda', 'lambda-url'].includes(appType) ? { lambdaARN: lambdaAliasArn } : {}),
|
|
180
240
|
};
|
|
@@ -193,10 +253,75 @@ export default class DeployClient {
|
|
|
193
253
|
output(`Deploy succeeded: ${appName}/${semVer}`);
|
|
194
254
|
} else {
|
|
195
255
|
output(`Deploy failed with: ${dResponse.statusCode}`);
|
|
196
|
-
throw new Error(`Lambda call to
|
|
256
|
+
throw new Error(`Lambda call to DeployVersion failed with: ${dResponse.statusCode}`);
|
|
197
257
|
}
|
|
198
258
|
} else {
|
|
199
259
|
throw new Error(`Lambda call to DeployVersion failed: ${JSON.stringify(response)}`);
|
|
200
260
|
}
|
|
201
261
|
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Copy S3 static assets from staging to live bucket.
|
|
265
|
+
* Create DB records.
|
|
266
|
+
* Proxied to parent account if needed.
|
|
267
|
+
*
|
|
268
|
+
* @param config
|
|
269
|
+
* @param task
|
|
270
|
+
*/
|
|
271
|
+
public static async DeployVersionLite(opts: {
|
|
272
|
+
appName: string;
|
|
273
|
+
semVer: string;
|
|
274
|
+
defaultFile?: string;
|
|
275
|
+
lambdaAliasArn?: string;
|
|
276
|
+
deployerLambdaName: string;
|
|
277
|
+
appType: 'lambda' | 'static' | 'lambda-url' | 'url';
|
|
278
|
+
startupType?: 'iframe' | 'direct';
|
|
279
|
+
url?: string;
|
|
280
|
+
overwrite: boolean;
|
|
281
|
+
output: (message: string) => void;
|
|
282
|
+
}): Promise<void> {
|
|
283
|
+
const {
|
|
284
|
+
appName,
|
|
285
|
+
semVer,
|
|
286
|
+
defaultFile,
|
|
287
|
+
lambdaAliasArn,
|
|
288
|
+
deployerLambdaName,
|
|
289
|
+
appType,
|
|
290
|
+
startupType = 'iframe',
|
|
291
|
+
url,
|
|
292
|
+
overwrite,
|
|
293
|
+
output,
|
|
294
|
+
} = opts;
|
|
295
|
+
const request: IDeployVersionRequest = {
|
|
296
|
+
type: 'deployVersionLite',
|
|
297
|
+
appType,
|
|
298
|
+
startupType,
|
|
299
|
+
appName,
|
|
300
|
+
semVer,
|
|
301
|
+
defaultFile: defaultFile,
|
|
302
|
+
url,
|
|
303
|
+
overwrite,
|
|
304
|
+
...(['lambda', 'lambda-url'].includes(appType) ? { lambdaARN: lambdaAliasArn } : {}),
|
|
305
|
+
};
|
|
306
|
+
const response = await this._client.send(
|
|
307
|
+
new lambda.InvokeCommand({
|
|
308
|
+
FunctionName: deployerLambdaName,
|
|
309
|
+
Payload: Buffer.from(JSON.stringify(request)),
|
|
310
|
+
}),
|
|
311
|
+
);
|
|
312
|
+
|
|
313
|
+
if (response.$metadata.httpStatusCode === 200 && response.Payload !== undefined) {
|
|
314
|
+
const dResponse = JSON.parse(
|
|
315
|
+
Buffer.from(response.Payload).toString('utf-8'),
|
|
316
|
+
) as IDeployerResponse;
|
|
317
|
+
if (dResponse.statusCode === 201) {
|
|
318
|
+
output(`Deploy succeeded: ${appName}/${semVer}`);
|
|
319
|
+
} else {
|
|
320
|
+
output(`Deploy failed with: ${dResponse.statusCode}`);
|
|
321
|
+
throw new Error(`Lambda call to DeployVersionLite failed with: ${dResponse.statusCode}`);
|
|
322
|
+
}
|
|
323
|
+
} else {
|
|
324
|
+
throw new Error(`Lambda call to DeployVersionLite failed: ${JSON.stringify(response)}`);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
202
327
|
}
|
package/src/lib/Versions.ts
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import { promises as fs } from 'fs-extra';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Represents a Versions
|
|
5
|
-
*/
|
|
6
|
-
export interface IVersions {
|
|
7
|
-
version: string;
|
|
8
|
-
alias?: string;
|
|
9
|
-
}
|
|
2
|
+
import { IVersions } from '@pwrdrvr/microapps-deployer-lib';
|
|
10
3
|
|
|
11
4
|
/**
|
|
12
5
|
* Represents a File To Modify
|
|
@@ -21,15 +14,6 @@ function escapeRegExp(value: string): string {
|
|
|
21
14
|
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
|
22
15
|
}
|
|
23
16
|
|
|
24
|
-
/**
|
|
25
|
-
* Setup version and alias strings
|
|
26
|
-
* @param version
|
|
27
|
-
* @returns
|
|
28
|
-
*/
|
|
29
|
-
export function createVersions(version: string): IVersions {
|
|
30
|
-
return { version, alias: `v${version.replace(/\./g, '_')}` };
|
|
31
|
-
}
|
|
32
|
-
|
|
33
17
|
/**
|
|
34
18
|
* Write new versions into specified config file
|
|
35
19
|
* @param path
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import 'reflect-metadata';
|
|
2
|
-
import { Command, flags as flagsParser } from '@oclif/command';
|
|
3
|
-
export declare class DockerAutoCommand extends Command {
|
|
4
|
-
static description: string;
|
|
5
|
-
static examples: string[];
|
|
6
|
-
static flags: {
|
|
7
|
-
version: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
8
|
-
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
9
|
-
deployerLambdaName: flagsParser.IOptionFlag<string>;
|
|
10
|
-
newVersion: flagsParser.IOptionFlag<string>;
|
|
11
|
-
repoName: flagsParser.IOptionFlag<string>;
|
|
12
|
-
leaveCopy: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
13
|
-
appLambdaName: flagsParser.IOptionFlag<string>;
|
|
14
|
-
appName: flagsParser.IOptionFlag<string>;
|
|
15
|
-
staticAssetsPath: flagsParser.IOptionFlag<string>;
|
|
16
|
-
defaultFile: flagsParser.IOptionFlag<string>;
|
|
17
|
-
overwrite: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
18
|
-
noCache: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
19
|
-
};
|
|
20
|
-
private VersionAndAlias;
|
|
21
|
-
private IMAGE_TAG;
|
|
22
|
-
private IMAGE_URI;
|
|
23
|
-
private FILES_TO_MODIFY;
|
|
24
|
-
private _restoreFilesStarted;
|
|
25
|
-
run(): Promise<void>;
|
|
26
|
-
/**
|
|
27
|
-
* Login to ECR for Lambda Docker functions
|
|
28
|
-
* @param config
|
|
29
|
-
* @returns
|
|
30
|
-
*/
|
|
31
|
-
private loginToECR;
|
|
32
|
-
/**
|
|
33
|
-
* Publish to ECR for Lambda Docker function
|
|
34
|
-
* @param config
|
|
35
|
-
*/
|
|
36
|
-
private publishToECR;
|
|
37
|
-
/**
|
|
38
|
-
* Publish an app version to Lambda
|
|
39
|
-
* @param config
|
|
40
|
-
* @param versions
|
|
41
|
-
*/
|
|
42
|
-
private deployToLambda;
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=nextjs-docker-auto.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nextjs-docker-auto.d.ts","sourceRoot":"","sources":["../../src/commands-deprecated/nextjs-docker-auto.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAM1B,OAAO,EAAE,OAAO,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,gBAAgB,CAAC;AA+B/D,qBAAa,iBAAkB,SAAQ,OAAO;IAC5C,MAAM,CAAC,WAAW,SACwF;IAE1G,MAAM,CAAC,QAAQ,WAeb;IAEF,MAAM,CAAC,KAAK;;;;;;;;;;;;;MAmEV;IAEF,OAAO,CAAC,eAAe,CAAY;IACnC,OAAO,CAAC,SAAS,CAAM;IACvB,OAAO,CAAC,SAAS,CAAM;IACvB,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,oBAAoB,CAAS;IAE/B,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAwV1B;;;;OAIG;YACW,UAAU;IAexB;;;OAGG;YACW,YAAY;IAW1B;;;;OAIG;YACW,cAAc;CA6E7B"}
|