@webiny/cli-aws 0.0.0-unstable.0156a4c312
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/LICENSE +21 -0
- package/README.md +11 -0
- package/bin.d.ts +3 -0
- package/bin.js +16 -0
- package/bin.js.map +1 -0
- package/decorators/DeployCommandWithTelemetry.d.ts +11 -0
- package/decorators/DeployCommandWithTelemetry.js +81 -0
- package/decorators/DeployCommandWithTelemetry.js.map +1 -0
- package/decorators/index.d.ts +1 -0
- package/decorators/index.js +1 -0
- package/features/DeployCommand/DeployCommand.d.ts +12 -0
- package/features/DeployCommand/DeployCommand.js +176 -0
- package/features/DeployCommand/DeployCommand.js.map +1 -0
- package/features/DeployCommand/deployOutputs/BaseDeployOutput.d.ts +20 -0
- package/features/DeployCommand/deployOutputs/BaseDeployOutput.js +15 -0
- package/features/DeployCommand/deployOutputs/BaseDeployOutput.js.map +1 -0
- package/features/DeployCommand/deployOutputs/DeployOutput.d.ts +5 -0
- package/features/DeployCommand/deployOutputs/DeployOutput.js +23 -0
- package/features/DeployCommand/deployOutputs/DeployOutput.js.map +1 -0
- package/features/DeployCommand/deployOutputs/NoDeploymentLogsDeployOutput.d.ts +4 -0
- package/features/DeployCommand/deployOutputs/NoDeploymentLogsDeployOutput.js +96 -0
- package/features/DeployCommand/deployOutputs/NoDeploymentLogsDeployOutput.js.map +1 -0
- package/features/DeployCommand/deployOutputs/WithDeploymentLogsDeployOutput.d.ts +4 -0
- package/features/DeployCommand/deployOutputs/WithDeploymentLogsDeployOutput.js +31 -0
- package/features/DeployCommand/deployOutputs/WithDeploymentLogsDeployOutput.js.map +1 -0
- package/features/DeployCommand/index.d.ts +1 -0
- package/features/DeployCommand/index.js +1 -0
- package/features/DestroyCommand/DestroyCommand.d.ts +22 -0
- package/features/DestroyCommand/DestroyCommand.js +82 -0
- package/features/DestroyCommand/DestroyCommand.js.map +1 -0
- package/features/DestroyCommand/index.d.ts +1 -0
- package/features/DestroyCommand/index.js +1 -0
- package/features/OutputCommand.d.ts +12 -0
- package/features/OutputCommand.js +66 -0
- package/features/OutputCommand.js.map +1 -0
- package/features/PulumiCommand/PulumiCommand.d.ts +13 -0
- package/features/PulumiCommand/PulumiCommand.js +57 -0
- package/features/PulumiCommand/PulumiCommand.js.map +1 -0
- package/features/PulumiCommand/index.d.ts +1 -0
- package/features/PulumiCommand/index.js +1 -0
- package/features/RefreshCommand/RefreshCommand.d.ts +12 -0
- package/features/RefreshCommand/RefreshCommand.js +51 -0
- package/features/RefreshCommand/RefreshCommand.js.map +1 -0
- package/features/RefreshCommand/index.d.ts +1 -0
- package/features/RefreshCommand/index.js +1 -0
- package/features/WatchCommand/WatchCommand.d.ts +11 -0
- package/features/WatchCommand/WatchCommand.js +143 -0
- package/features/WatchCommand/WatchCommand.js.map +1 -0
- package/features/WatchCommand/createPrefixer.d.ts +2 -0
- package/features/WatchCommand/createPrefixer.js +16 -0
- package/features/WatchCommand/createPrefixer.js.map +1 -0
- package/features/WatchCommand/getRandomColorForString.d.ts +1 -0
- package/features/WatchCommand/getRandomColorForString.js +89 -0
- package/features/WatchCommand/getRandomColorForString.js.map +1 -0
- package/features/WatchCommand/index.d.ts +1 -0
- package/features/WatchCommand/index.js +1 -0
- package/features/gracefulErrorHandlers/DdbPutItemConditionalCheckFailedGracefulErrorHandler.d.ts +6 -0
- package/features/gracefulErrorHandlers/DdbPutItemConditionalCheckFailedGracefulErrorHandler.js +27 -0
- package/features/gracefulErrorHandlers/DdbPutItemConditionalCheckFailedGracefulErrorHandler.js.map +1 -0
- package/features/gracefulErrorHandlers/PendingOperationsGracefulErrorHandler.d.ts +6 -0
- package/features/gracefulErrorHandlers/PendingOperationsGracefulErrorHandler.js +29 -0
- package/features/gracefulErrorHandlers/PendingOperationsGracefulErrorHandler.js.map +1 -0
- package/features/gracefulErrorHandlers/index.d.ts +2 -0
- package/features/gracefulErrorHandlers/index.js +2 -0
- package/features/index.d.ts +7 -0
- package/features/index.js +7 -0
- package/index.d.ts +3 -0
- package/index.js +3 -0
- package/package.json +41 -0
- package/registerAwsFeatures.d.ts +2 -0
- package/registerAwsFeatures.js +18 -0
- package/registerAwsFeatures.js.map +1 -0
- package/services/GetProjectSdkService.d.ts +9 -0
- package/services/GetProjectSdkService.js +33 -0
- package/services/GetProjectSdkService.js.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Webiny
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# @webiny/cli-aws
|
|
2
|
+
|
|
3
|
+
> [!NOTE]
|
|
4
|
+
> This package is part of the [Webiny](https://www.webiny.com) monorepo.
|
|
5
|
+
> It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
|
|
6
|
+
|
|
7
|
+
📘 **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
_This README file is automatically generated during the publish process._
|
package/bin.d.ts
ADDED
package/bin.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import "tsx/esm";
|
|
3
|
+
import "@webiny/cli-core/utils/suppressPunycodeWarnings.js";
|
|
4
|
+
import { Cli } from "@webiny/cli-core";
|
|
5
|
+
import { ensureSameWebinyPackageVersions } from "@webiny/cli-core/utils/ensureSameWebinyPackageVersions/index.js";
|
|
6
|
+
import { registerAwsFeatures } from "./index.js";
|
|
7
|
+
import { ensureSystemRequirements } from "@webiny/system-requirements";
|
|
8
|
+
import { startTrace, trace, traceAsync } from "@webiny/project/utils/trace/index.js";
|
|
9
|
+
startTrace("Webiny CLI (aws)");
|
|
10
|
+
process.env.WEBINY_HOSTING_TYPE = "aws";
|
|
11
|
+
trace("check system requirements", ()=>ensureSystemRequirements());
|
|
12
|
+
trace("check @webiny package versions", ()=>ensureSameWebinyPackageVersions());
|
|
13
|
+
const cli = await traceAsync("initialize CLI", ()=>Cli.init({}, registerAwsFeatures));
|
|
14
|
+
await traceAsync("run command", ()=>cli.run());
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=bin.js.map
|
package/bin.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.js","sources":["../src/bin.ts"],"sourcesContent":["#!/usr/bin/env node\nimport \"tsx/esm\";\n\n// Suppress punycode warnings. This is a known issue we can't fix.\nimport \"@webiny/cli-core/utils/suppressPunycodeWarnings.js\";\n\nimport { Cli } from \"@webiny/cli-core\";\nimport { ensureSameWebinyPackageVersions } from \"@webiny/cli-core/utils/ensureSameWebinyPackageVersions/index.js\";\nimport { registerAwsFeatures } from \"./index.js\";\nimport { ensureSystemRequirements } from \"@webiny/system-requirements\";\nimport { startTrace } from \"@webiny/project/utils/trace/index.js\";\nimport { trace } from \"@webiny/project/utils/trace/index.js\";\nimport { traceAsync } from \"@webiny/project/utils/trace/index.js\";\n\n// Time the run when `--trace` or `WEBINY_CLI_TRACE=1` is used. Must be the first statement, so that\n// the time spent loading the imports above is attributed.\nstartTrace(\"Webiny CLI (aws)\");\n\n// Hosting-type marker — lets webiny.config.tsx branch on which CLI is running (e.g. Cognito for AWS,\n// SelfHostedAuth + Admin.ApiUrl for server). Read at build/watch time when the config is evaluated.\nprocess.env.WEBINY_HOSTING_TYPE = \"aws\";\n\n// Ensure system requirements are met.\ntrace(\"check system requirements\", () => ensureSystemRequirements());\n\n// Ensure all @webiny/* packages use the same version.\ntrace(\"check @webiny package versions\", () => ensureSameWebinyPackageVersions());\n\nconst cli = await traceAsync(\"initialize CLI\", () => Cli.init({}, registerAwsFeatures));\n\nawait traceAsync(\"run command\", () => cli.run());\n"],"names":["startTrace","process","trace","ensureSystemRequirements","ensureSameWebinyPackageVersions","cli","traceAsync","Cli","registerAwsFeatures"],"mappings":";;;;;;;;AAgBAA,WAAW;AAIXC,QAAQ,GAAG,CAAC,mBAAmB,GAAG;AAGlCC,MAAM,6BAA6B,IAAMC;AAGzCD,MAAM,kCAAkC,IAAME;AAE9C,MAAMC,MAAM,MAAMC,WAAW,kBAAkB,IAAMC,IAAI,IAAI,CAAC,CAAC,GAAGC;AAElE,MAAMF,WAAW,eAAe,IAAMD,IAAI,GAAG"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CliCommandFactory, GetProjectSdkService } from "@webiny/cli-core/abstractions/index.js";
|
|
2
|
+
export declare class DeployCommandWithTelemetry<TParams> implements CliCommandFactory.Interface<TParams> {
|
|
3
|
+
private getProjectSdkService;
|
|
4
|
+
private decoratee;
|
|
5
|
+
constructor(getProjectSdkService: GetProjectSdkService.Interface, decoratee: CliCommandFactory.Interface<TParams>);
|
|
6
|
+
execute(): Promise<import("@webiny/cli-core/abstractions/features/CliCommand").ICliCommandDefinition<TParams>>;
|
|
7
|
+
private sendEvent;
|
|
8
|
+
}
|
|
9
|
+
export declare const deployCommandWithTelemetry: typeof DeployCommandWithTelemetry & {
|
|
10
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/cli-core/abstractions/features/CliCommand").ICliCommand<any>>;
|
|
11
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { isEnabled, sendEvent } from "@webiny/telemetry/cli.js";
|
|
2
|
+
import { CliCommandFactory, GetProjectSdkService } from "@webiny/cli-core/abstractions/index.js";
|
|
3
|
+
import { GracefulError } from "@webiny/project";
|
|
4
|
+
const isDeployCommand = (command)=>"deploy" === command.name;
|
|
5
|
+
class DeployCommandWithTelemetry {
|
|
6
|
+
constructor(getProjectSdkService, decoratee){
|
|
7
|
+
this.getProjectSdkService = getProjectSdkService;
|
|
8
|
+
this.decoratee = decoratee;
|
|
9
|
+
}
|
|
10
|
+
async execute() {
|
|
11
|
+
const command = await this.decoratee.execute();
|
|
12
|
+
if (!isDeployCommand(command)) return command;
|
|
13
|
+
if (!isEnabled()) return command;
|
|
14
|
+
const projectSdk = await this.getProjectSdkService.execute();
|
|
15
|
+
const projectSdkTelemetryEnabled = await projectSdk.isTelemetryEnabled();
|
|
16
|
+
if (!projectSdkTelemetryEnabled) return command;
|
|
17
|
+
const deployCommand = command;
|
|
18
|
+
const originalCommandHandler = deployCommand.handler;
|
|
19
|
+
deployCommand.handler = async (params)=>{
|
|
20
|
+
if ("app" in params) {
|
|
21
|
+
const telemetryProperties = {
|
|
22
|
+
app: params.app || "unknown",
|
|
23
|
+
env: params.env || "unknown",
|
|
24
|
+
variant: params.variant || "unknown",
|
|
25
|
+
region: params.region || "unknown",
|
|
26
|
+
commandParams: JSON.stringify(params)
|
|
27
|
+
};
|
|
28
|
+
try {
|
|
29
|
+
await this.sendEvent("cli-pulumi-command-deploy-start", telemetryProperties);
|
|
30
|
+
const result = await originalCommandHandler(params);
|
|
31
|
+
await this.sendEvent("cli-pulumi-command-deploy-end", telemetryProperties);
|
|
32
|
+
return result;
|
|
33
|
+
} catch (e) {
|
|
34
|
+
const event = e instanceof GracefulError ? "cli-pulumi-command-deploy-error-graceful" : "cli-pulumi-command-deploy-error";
|
|
35
|
+
await this.sendEvent(event, {
|
|
36
|
+
...telemetryProperties,
|
|
37
|
+
errorMessage: e.message,
|
|
38
|
+
errorStack: e.stack
|
|
39
|
+
});
|
|
40
|
+
throw e;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const telemetryProperties = {
|
|
44
|
+
env: params.env || "unknown",
|
|
45
|
+
variant: params.variant || "unknown",
|
|
46
|
+
region: params.region || "unknown",
|
|
47
|
+
commandParams: JSON.stringify(params)
|
|
48
|
+
};
|
|
49
|
+
try {
|
|
50
|
+
await this.sendEvent("cli-project-deploy-start", telemetryProperties);
|
|
51
|
+
const result = await originalCommandHandler(params);
|
|
52
|
+
await this.sendEvent("cli-project-deploy-end", telemetryProperties);
|
|
53
|
+
return result;
|
|
54
|
+
} catch (e) {
|
|
55
|
+
const event = e instanceof GracefulError ? "cli-project-deploy-error-graceful" : "cli-project-deploy-error";
|
|
56
|
+
await this.sendEvent(event, {
|
|
57
|
+
...telemetryProperties,
|
|
58
|
+
errorMessage: e.message,
|
|
59
|
+
errorStack: e.stack
|
|
60
|
+
});
|
|
61
|
+
throw e;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
return command;
|
|
65
|
+
}
|
|
66
|
+
sendEvent(event, properties = {}) {
|
|
67
|
+
return sendEvent({
|
|
68
|
+
event,
|
|
69
|
+
properties
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const deployCommandWithTelemetry = CliCommandFactory.createDecorator({
|
|
74
|
+
decorator: DeployCommandWithTelemetry,
|
|
75
|
+
dependencies: [
|
|
76
|
+
GetProjectSdkService
|
|
77
|
+
]
|
|
78
|
+
});
|
|
79
|
+
export { DeployCommandWithTelemetry, deployCommandWithTelemetry };
|
|
80
|
+
|
|
81
|
+
//# sourceMappingURL=DeployCommandWithTelemetry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorators/DeployCommandWithTelemetry.js","sources":["../../src/decorators/DeployCommandWithTelemetry.ts"],"sourcesContent":["import {\n isEnabled as globalIsTelemetryEnabled,\n sendEvent as telemetrySendEvent\n} from \"@webiny/telemetry/cli.js\";\nimport { CliCommandFactory, GetProjectSdkService } from \"@webiny/cli-core/abstractions/index.js\";\nimport { IDeployCommandParams } from \"@webiny/cli-core/features/DeployCommand/index.js\";\nimport { GracefulError } from \"@webiny/project\";\n\nconst isDeployCommand = (\n command: CliCommandFactory.CommandDefinition<any>\n): command is CliCommandFactory.CommandDefinition<IDeployCommandParams> => {\n return command.name === \"deploy\";\n};\n\nexport class DeployCommandWithTelemetry<TParams> implements CliCommandFactory.Interface<TParams> {\n constructor(\n private getProjectSdkService: GetProjectSdkService.Interface,\n private decoratee: CliCommandFactory.Interface<TParams>\n ) {}\n\n async execute() {\n const command = await this.decoratee.execute();\n\n if (!isDeployCommand(command)) {\n return command;\n }\n\n if (!globalIsTelemetryEnabled()) {\n return command;\n }\n\n const projectSdk = await this.getProjectSdkService.execute();\n const projectSdkTelemetryEnabled = await projectSdk.isTelemetryEnabled();\n if (!projectSdkTelemetryEnabled) {\n return command;\n }\n\n const deployCommand = command as CliCommandFactory.CommandDefinition<IDeployCommandParams>;\n const originalCommandHandler = deployCommand.handler;\n\n deployCommand.handler = async (params: IDeployCommandParams) => {\n if (\"app\" in params) {\n const telemetryProperties = {\n app: params.app || \"unknown\",\n env: params.env || \"unknown\",\n variant: params.variant || \"unknown\",\n region: params.region || \"unknown\",\n commandParams: JSON.stringify(params)\n };\n\n try {\n await this.sendEvent(\"cli-pulumi-command-deploy-start\", telemetryProperties);\n\n const result = await originalCommandHandler(params);\n\n await this.sendEvent(\"cli-pulumi-command-deploy-end\", telemetryProperties);\n\n return result;\n } catch (e) {\n const event =\n e instanceof GracefulError\n ? \"cli-pulumi-command-deploy-error-graceful\"\n : \"cli-pulumi-command-deploy-error\";\n\n await this.sendEvent(event, {\n ...telemetryProperties,\n errorMessage: e.message,\n errorStack: e.stack\n });\n\n throw e;\n }\n }\n\n const telemetryProperties = {\n env: params.env || \"unknown\",\n variant: params.variant || \"unknown\",\n region: params.region || \"unknown\",\n commandParams: JSON.stringify(params)\n };\n\n try {\n await this.sendEvent(\"cli-project-deploy-start\", telemetryProperties);\n const result = await originalCommandHandler(params);\n await this.sendEvent(\"cli-project-deploy-end\", telemetryProperties);\n return result;\n } catch (e) {\n const event =\n e instanceof GracefulError\n ? \"cli-project-deploy-error-graceful\"\n : \"cli-project-deploy-error\";\n\n await this.sendEvent(event, {\n ...telemetryProperties,\n errorMessage: e.message,\n errorStack: e.stack\n });\n\n throw e;\n }\n };\n\n return command;\n }\n\n private sendEvent(event: string, properties: Record<string, any> = {}) {\n return telemetrySendEvent({\n event,\n properties\n });\n }\n}\n\nexport const deployCommandWithTelemetry = CliCommandFactory.createDecorator({\n decorator: DeployCommandWithTelemetry,\n dependencies: [GetProjectSdkService]\n});\n"],"names":["isDeployCommand","command","DeployCommandWithTelemetry","getProjectSdkService","decoratee","globalIsTelemetryEnabled","projectSdk","projectSdkTelemetryEnabled","deployCommand","originalCommandHandler","params","telemetryProperties","JSON","result","e","event","GracefulError","properties","telemetrySendEvent","deployCommandWithTelemetry","CliCommandFactory","GetProjectSdkService"],"mappings":";;;AAQA,MAAMA,kBAAkB,CACpBC,UAEOA,AAAiB,aAAjBA,QAAQ,IAAI;AAGhB,MAAMC;IACT,YACYC,oBAAoD,EACpDC,SAA+C,CACzD;aAFUD,oBAAoB,GAApBA;aACAC,SAAS,GAATA;IACT;IAEH,MAAM,UAAU;QACZ,MAAMH,UAAU,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO;QAE5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BACR,MAAMC,QACFD,aAAaE,gBACP,sCACA;gBAEV,MAAM,IAAI,CAAC,SAAS,CAACD,OAAO;oBACxB,GAAGJ,mBAAmB;oBACtB,cAAcG,EAAE,OAAO;oBACvB,YAAYA,EAAE,KAAK;gBACvB;gBAEA,MAAMA;YACV;QACJ;QAEA,OAAOb;IACX;IAEQ,UAAUc,KAAa,EAAEE,aAAkC,CAAC,CAAC,EAAE;QACnE,OAAOC,UAAmB;YACtBH;YACAE;QACJ;IACJ;AACJ;AAEO,MAAME,6BAA6BC,kBAAkB,eAAe,CAAC;IACxE,WAAWlB;IACX,cAAc;QAACmB;KAAqB;AACxC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./DeployCommandWithTelemetry.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./DeployCommandWithTelemetry.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CliCommandFactory, GetProjectSdkService, StdioService, UiService } from "@webiny/cli-core/abstractions/index.js";
|
|
2
|
+
import { IDeployCommandParams, IDeploySingleAppParams } from "@webiny/cli-core/features/DeployCommand/index.js";
|
|
3
|
+
export type { IDeployCommandParams, IDeploySingleAppParams };
|
|
4
|
+
export declare class DeployCommand implements CliCommandFactory.Interface<IDeployCommandParams> {
|
|
5
|
+
private getProjectSdkService;
|
|
6
|
+
private uiService;
|
|
7
|
+
private stdioService;
|
|
8
|
+
constructor(getProjectSdkService: GetProjectSdkService.Interface, uiService: UiService.Interface, stdioService: StdioService.Interface);
|
|
9
|
+
execute(): Promise<CliCommandFactory.CommandDefinition<IDeployCommandParams>>;
|
|
10
|
+
private deployApp;
|
|
11
|
+
}
|
|
12
|
+
export declare const deployCommand: import("@webiny/di").Implementation<typeof DeployCommand>;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { createImplementation } from "@webiny/di";
|
|
2
|
+
import { setTimeout as promises_setTimeout } from "node:timers/promises";
|
|
3
|
+
import open_0 from "open";
|
|
4
|
+
import ora from "ora";
|
|
5
|
+
import { CliCommandFactory, GetProjectSdkService, StdioService, UiService } from "@webiny/cli-core/abstractions/index.js";
|
|
6
|
+
import { BuildRunner } from "@webiny/cli-core/features/BuildCommand/buildRunners/BuildRunner.js";
|
|
7
|
+
import { createBaseAppOptions } from "@webiny/cli-core/features/common/index.js";
|
|
8
|
+
import { DeployOutput } from "./deployOutputs/DeployOutput.js";
|
|
9
|
+
import { PrintInfoForEnv } from "@webiny/cli-core/features/InfoCommand/PrintInfoForEnv.js";
|
|
10
|
+
const sleep = (ms = 1500)=>promises_setTimeout(ms);
|
|
11
|
+
class DeployCommand {
|
|
12
|
+
constructor(getProjectSdkService, uiService, stdioService){
|
|
13
|
+
this.getProjectSdkService = getProjectSdkService;
|
|
14
|
+
this.uiService = uiService;
|
|
15
|
+
this.stdioService = stdioService;
|
|
16
|
+
}
|
|
17
|
+
async execute() {
|
|
18
|
+
const projectSdk = await this.getProjectSdkService.execute();
|
|
19
|
+
const ui = this.uiService;
|
|
20
|
+
return {
|
|
21
|
+
name: "deploy",
|
|
22
|
+
description: "Deploys specified app or all apps in the project",
|
|
23
|
+
examples: [
|
|
24
|
+
"$0 deploy api --env dev",
|
|
25
|
+
"$0 deploy core api --env dev",
|
|
26
|
+
"$0 deploy admin --env prod",
|
|
27
|
+
"$0 deploy --env prod",
|
|
28
|
+
"$0 deploy"
|
|
29
|
+
],
|
|
30
|
+
params: [
|
|
31
|
+
{
|
|
32
|
+
name: "apps",
|
|
33
|
+
description: "Name of the app(s) to deploy (core, admin, or api). You can specify multiple apps.",
|
|
34
|
+
type: "string",
|
|
35
|
+
array: true
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
options: [
|
|
39
|
+
...createBaseAppOptions(projectSdk),
|
|
40
|
+
{
|
|
41
|
+
name: "build",
|
|
42
|
+
description: "Build packages before deploying",
|
|
43
|
+
type: "boolean",
|
|
44
|
+
default: true
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: "preview",
|
|
48
|
+
description: "Preview the deploy instead of actually performing it",
|
|
49
|
+
type: "boolean",
|
|
50
|
+
default: false
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: "show-deployment-logs",
|
|
54
|
+
description: "Print deployment logs (automatically enabled in CI environments)",
|
|
55
|
+
type: "boolean",
|
|
56
|
+
default: false
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: "allow-local-state-files",
|
|
60
|
+
description: "Allow using local Pulumi state files with production environment deployment (not recommended).",
|
|
61
|
+
type: "boolean"
|
|
62
|
+
}
|
|
63
|
+
],
|
|
64
|
+
handler: async (params)=>{
|
|
65
|
+
if (params.apps && params.apps.length > 0) for (const appName of params.apps){
|
|
66
|
+
const appParams = {
|
|
67
|
+
...params,
|
|
68
|
+
app: appName
|
|
69
|
+
};
|
|
70
|
+
const app = await projectSdk.getApp(appName);
|
|
71
|
+
ui.info("Deploying %s app...", app.getDisplayName());
|
|
72
|
+
await this.deployApp(appParams);
|
|
73
|
+
ui.emptyLine();
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
ui.info(`You're using Webiny v${projectSdk.getProjectVersion()}`);
|
|
77
|
+
ui.emptyLine();
|
|
78
|
+
const isCi = projectSdk.isCi();
|
|
79
|
+
const coreStack = await projectSdk.getAppStackOutput("core");
|
|
80
|
+
const isFirstDeployment = !isCi && !coreStack?.deploymentId;
|
|
81
|
+
if (isFirstDeployment) {
|
|
82
|
+
ui.info("Looks like this is your first time deploying the project.");
|
|
83
|
+
ui.info("Note that the initial deployment can take up to %s, so please be patient.", "10 minutes");
|
|
84
|
+
await sleep();
|
|
85
|
+
}
|
|
86
|
+
isFirstDeployment && ui.emptyLine();
|
|
87
|
+
ui.info("Deploying %s app...", "Core");
|
|
88
|
+
await this.deployApp({
|
|
89
|
+
...params,
|
|
90
|
+
app: "core"
|
|
91
|
+
});
|
|
92
|
+
ui.emptyLine();
|
|
93
|
+
ui.info("Deploying %s app...", "API");
|
|
94
|
+
await this.deployApp({
|
|
95
|
+
...params,
|
|
96
|
+
app: "api"
|
|
97
|
+
});
|
|
98
|
+
ui.emptyLine();
|
|
99
|
+
ui.info("Deploying %s app...", "Admin");
|
|
100
|
+
await this.deployApp({
|
|
101
|
+
...params,
|
|
102
|
+
app: "admin"
|
|
103
|
+
});
|
|
104
|
+
if (isFirstDeployment) ui.success("Congratulations! You've just deployed a brand new project!");
|
|
105
|
+
else ui.success("Project deployed.");
|
|
106
|
+
const printInfoForEnv = new PrintInfoForEnv({
|
|
107
|
+
getProjectSdkService: this.getProjectSdkService,
|
|
108
|
+
uiService: this.uiService
|
|
109
|
+
});
|
|
110
|
+
ui.emptyLine();
|
|
111
|
+
ui.textBold("Project Details");
|
|
112
|
+
await printInfoForEnv.execute(params);
|
|
113
|
+
const adminAppOutput = await projectSdk.getAppStackOutput("admin");
|
|
114
|
+
if (isFirstDeployment && adminAppOutput) {
|
|
115
|
+
ui.emptyLine();
|
|
116
|
+
ui.info("The final step is to open the %s app in your browser and complete the installation wizard.", "Admin");
|
|
117
|
+
const spinner = ora("Opening Admin in your browser...").start();
|
|
118
|
+
try {
|
|
119
|
+
await sleep(7000);
|
|
120
|
+
open_0(adminAppOutput.appUrl);
|
|
121
|
+
spinner.succeed("Successfully opened Admin app in your browser.");
|
|
122
|
+
} catch {
|
|
123
|
+
spinner.fail("Failed to open Admin in your browser.");
|
|
124
|
+
await sleep(1000);
|
|
125
|
+
ui.emptyLine();
|
|
126
|
+
ui.warning("Failed to open %s app in your browser. To finish the setup and start using the project, please visit %s and complete the installation wizard.", "Admin", adminAppOutput.appUrl);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
async deployApp(params) {
|
|
134
|
+
const projectSdk = await this.getProjectSdkService.execute();
|
|
135
|
+
const ui = this.uiService;
|
|
136
|
+
const stdio = this.stdioService;
|
|
137
|
+
if (false !== params.build) {
|
|
138
|
+
const packagesBuilder = await projectSdk.buildApp(params);
|
|
139
|
+
const buildRunner = new BuildRunner({
|
|
140
|
+
stdio,
|
|
141
|
+
ui,
|
|
142
|
+
packagesBuilder
|
|
143
|
+
});
|
|
144
|
+
if (!buildRunner.isEmpty()) {
|
|
145
|
+
await buildRunner.run();
|
|
146
|
+
ui.emptyLine();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
const showDeploymentLogs = Boolean(projectSdk.isCi() || params.preview || params.showDeploymentLogs);
|
|
150
|
+
return await projectSdk.deployApp({
|
|
151
|
+
...params,
|
|
152
|
+
output: (pulumiProcess)=>{
|
|
153
|
+
const deployOutput = new DeployOutput({
|
|
154
|
+
stdio,
|
|
155
|
+
ui,
|
|
156
|
+
showDeploymentLogs,
|
|
157
|
+
deployProcess: pulumiProcess,
|
|
158
|
+
deployParams: params
|
|
159
|
+
});
|
|
160
|
+
return deployOutput.output();
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
const deployCommand = createImplementation({
|
|
166
|
+
abstraction: CliCommandFactory,
|
|
167
|
+
implementation: DeployCommand,
|
|
168
|
+
dependencies: [
|
|
169
|
+
GetProjectSdkService,
|
|
170
|
+
UiService,
|
|
171
|
+
StdioService
|
|
172
|
+
]
|
|
173
|
+
});
|
|
174
|
+
export { DeployCommand, deployCommand };
|
|
175
|
+
|
|
176
|
+
//# sourceMappingURL=DeployCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/DeployCommand/DeployCommand.js","sources":["../../../src/features/DeployCommand/DeployCommand.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { setTimeout } from \"node:timers/promises\";\nimport open from \"open\";\nimport ora from \"ora\";\nimport {\n CliCommandFactory,\n GetProjectSdkService,\n StdioService,\n UiService\n} from \"@webiny/cli-core/abstractions/index.js\";\nimport { BuildRunner } from \"@webiny/cli-core/features/BuildCommand/buildRunners/BuildRunner.js\";\nimport { createBaseAppOptions } from \"@webiny/cli-core/features/common/index.js\";\nimport { DeployOutput } from \"./deployOutputs/DeployOutput.js\";\nimport {\n IDeployCommandParams,\n IDeploySingleAppParams\n} from \"@webiny/cli-core/features/DeployCommand/index.js\";\n\n// TODO: convert to a real service.\nimport { PrintInfoForEnv } from \"@webiny/cli-core/features/InfoCommand/PrintInfoForEnv.js\";\n\nexport type { IDeployCommandParams, IDeploySingleAppParams };\n\nconst sleep = (ms: number = 1500) => setTimeout(ms);\n\nexport class DeployCommand implements CliCommandFactory.Interface<IDeployCommandParams> {\n constructor(\n private getProjectSdkService: GetProjectSdkService.Interface,\n private uiService: UiService.Interface,\n private stdioService: StdioService.Interface\n ) {}\n\n async execute(): Promise<CliCommandFactory.CommandDefinition<IDeployCommandParams>> {\n const projectSdk = await this.getProjectSdkService.execute();\n const ui = this.uiService;\n\n return {\n name: \"deploy\",\n description: \"Deploys specified app or all apps in the project\",\n examples: [\n \"$0 deploy api --env dev\",\n \"$0 deploy core api --env dev\",\n \"$0 deploy admin --env prod\",\n \"$0 deploy --env prod\",\n \"$0 deploy\"\n ],\n params: [\n {\n name: \"apps\",\n description:\n \"Name of the app(s) to deploy (core, admin, or api). You can specify multiple apps.\",\n type: \"string\",\n array: true\n }\n ],\n options: [\n ...createBaseAppOptions(projectSdk),\n {\n name: \"build\",\n description: \"Build packages before deploying\",\n type: \"boolean\",\n default: true\n },\n {\n name: \"preview\",\n description: \"Preview the deploy instead of actually performing it\",\n type: \"boolean\",\n default: false\n },\n {\n name: \"show-deployment-logs\",\n description: \"Print deployment logs (automatically enabled in CI environments)\",\n type: \"boolean\",\n default: false\n },\n {\n name: \"allow-local-state-files\",\n description:\n \"Allow using local Pulumi state files with production environment deployment (not recommended).\",\n type: \"boolean\"\n }\n ],\n handler: async (params: IDeployCommandParams) => {\n if (params.apps && params.apps.length > 0) {\n for (const appName of params.apps) {\n const appParams: IDeploySingleAppParams = {\n ...params,\n app: appName\n };\n\n const app = await projectSdk.getApp(appName);\n ui.info(\"Deploying %s app...\", app.getDisplayName());\n await this.deployApp(appParams);\n ui.emptyLine();\n }\n } else {\n ui.info(`You're using Webiny v${projectSdk.getProjectVersion()}`);\n ui.emptyLine();\n\n const isCi = projectSdk.isCi();\n const coreStack = await projectSdk.getAppStackOutput(\"core\");\n\n const isFirstDeployment = !isCi && !coreStack?.deploymentId;\n if (isFirstDeployment) {\n ui.info(`Looks like this is your first time deploying the project.`);\n ui.info(\n `Note that the initial deployment can take up to %s, so please be patient.`,\n \"10 minutes\"\n );\n await sleep();\n }\n\n isFirstDeployment && ui.emptyLine();\n\n ui.info(\"Deploying %s app...\", \"Core\");\n await this.deployApp({ ...params, app: \"core\" });\n ui.emptyLine();\n\n ui.info(\"Deploying %s app...\", \"API\");\n await this.deployApp({ ...params, app: \"api\" });\n ui.emptyLine();\n ui.info(\"Deploying %s app...\", \"Admin\");\n await this.deployApp({ ...params, app: \"admin\" });\n\n if (isFirstDeployment) {\n ui.success(`Congratulations! You've just deployed a brand new project!`);\n } else {\n ui.success(`Project deployed.`);\n }\n\n const printInfoForEnv = new PrintInfoForEnv({\n getProjectSdkService: this.getProjectSdkService,\n uiService: this.uiService\n });\n\n ui.emptyLine();\n ui.textBold(\"Project Details\");\n await printInfoForEnv.execute(params);\n\n const adminAppOutput = await projectSdk.getAppStackOutput(\"admin\");\n\n if (isFirstDeployment && adminAppOutput) {\n ui.emptyLine();\n ui.info(\n \"The final step is to open the %s app in your browser and complete the installation wizard.\",\n \"Admin\"\n );\n\n const spinner = ora(`Opening Admin in your browser...`).start();\n\n try {\n await sleep(7000);\n open(adminAppOutput.appUrl as string);\n spinner.succeed(`Successfully opened Admin app in your browser.`);\n } catch {\n spinner.fail(`Failed to open Admin in your browser.`);\n\n await sleep(1000);\n ui.emptyLine();\n ui.warning(\n `Failed to open %s app in your browser. To finish the setup and start using the project, please visit %s and complete the installation wizard.`,\n \"Admin\",\n adminAppOutput.appUrl\n );\n }\n }\n }\n }\n };\n }\n\n private async deployApp(params: IDeploySingleAppParams) {\n const projectSdk = await this.getProjectSdkService.execute();\n\n const ui = this.uiService;\n const stdio = this.stdioService;\n\n if (params.build !== false) {\n const packagesBuilder = await projectSdk.buildApp(params);\n\n const buildRunner = new BuildRunner({\n stdio,\n ui,\n packagesBuilder\n });\n\n if (!buildRunner.isEmpty()) {\n await buildRunner.run();\n ui.emptyLine();\n }\n }\n\n const showDeploymentLogs = Boolean(\n projectSdk.isCi() || params.preview || params.showDeploymentLogs\n );\n\n return await projectSdk.deployApp({\n ...params,\n output: pulumiProcess => {\n const deployOutput = new DeployOutput({\n stdio,\n ui,\n showDeploymentLogs,\n deployProcess: pulumiProcess,\n deployParams: params\n });\n\n return deployOutput.output();\n }\n });\n }\n}\n\nexport const deployCommand = createImplementation({\n abstraction: CliCommandFactory,\n implementation: DeployCommand,\n dependencies: [GetProjectSdkService, UiService, StdioService]\n});\n"],"names":["sleep","ms","setTimeout","DeployCommand","getProjectSdkService","uiService","stdioService","projectSdk","ui","createBaseAppOptions","params","appName","appParams","app","isCi","coreStack","isFirstDeployment","printInfoForEnv","PrintInfoForEnv","adminAppOutput","spinner","ora","open","stdio","packagesBuilder","buildRunner","BuildRunner","showDeploymentLogs","Boolean","pulumiProcess","deployOutput","DeployOutput","deployCommand","createImplementation","CliCommandFactory","GetProjectSdkService","UiService","StdioService"],"mappings":";;;;;;;;;AAuBA,MAAMA,QAAQ,CAACC,KAAa,IAAI,GAAKC,oBAAWD;AAEzC,MAAME;IACT,YACYC,oBAAoD,EACpDC,SAA8B,EAC9BC,YAAoC,CAC9C;aAHUF,oBAAoB,GAApBA;aACAC,SAAS,GAATA;aACAC,YAAY,GAAZA;IACT;IAEH,MAAM,UAA8E;QAChF,MAAMC,aAAa,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO;QAC1D,MAAMC,KAAK,IAAI,CAAC,SAAS;QAEzB,OAAO;YACH,MAAM;YACN,aAAa;YACb,UAAU;gBACN;gBACA;gBACA;gBACA;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gBACAf;gBACAgB;YACJ;YAEA,IAAI,CAACC,YAAY,OAAO,IAAI;gBACxB,MAAMA,YAAY,GAAG;gBACrBjB,GAAG,SAAS;YAChB;QACJ;QAEA,MAAMmB,qBAAqBC,QACvBrB,WAAW,IAAI,MAAMG,OAAO,OAAO,IAAIA,OAAO,kBAAkB;QAGpE,OAAO,MAAMH,WAAW,SAAS,CAAC;YAC9B,GAAGG,MAAM;YACT,QAAQmB,CAAAA;gBACJ,MAAMC,eAAe,IAAIC,aAAa;oBAClCR;oBACAf;oBACAmB;oBACA,eAAeE;oBACf,cAAcnB;gBAClB;gBAEA,OAAOoB,aAAa,MAAM;YAC9B;QACJ;IACJ;AACJ;AAEO,MAAME,gBAAgBC,qBAAqB;IAC9C,aAAaC;IACb,gBAAgB/B;IAChB,cAAc;QAACgC;QAAsBC;QAAWC;KAAa;AACjE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { UiService, StdioService } from "@webiny/cli-core/abstractions/index.js";
|
|
2
|
+
import { IDeploySingleAppParams } from "../DeployCommand.js";
|
|
3
|
+
import { type PulumiProcess } from "@webiny/pulumi-sdk";
|
|
4
|
+
export type IDeployProcess = PulumiProcess;
|
|
5
|
+
export interface IBaseDeployOutputParams {
|
|
6
|
+
deployProcess: IDeployProcess;
|
|
7
|
+
stdio: StdioService.Interface;
|
|
8
|
+
ui: UiService.Interface;
|
|
9
|
+
showDeploymentLogs: boolean;
|
|
10
|
+
deployParams: IDeploySingleAppParams;
|
|
11
|
+
}
|
|
12
|
+
export declare class BaseDeployOutput {
|
|
13
|
+
readonly deployProcess: IDeployProcess;
|
|
14
|
+
readonly stdio: StdioService.Interface;
|
|
15
|
+
readonly ui: UiService.Interface;
|
|
16
|
+
readonly showDeploymentLogs: boolean;
|
|
17
|
+
readonly deployParams: IDeploySingleAppParams;
|
|
18
|
+
constructor({ deployProcess, stdio, ui, showDeploymentLogs, deployParams }: IBaseDeployOutputParams);
|
|
19
|
+
output(): Promise<void>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
class BaseDeployOutput {
|
|
2
|
+
constructor({ deployProcess, stdio, ui, showDeploymentLogs, deployParams }){
|
|
3
|
+
this.deployProcess = deployProcess;
|
|
4
|
+
this.stdio = stdio;
|
|
5
|
+
this.ui = ui;
|
|
6
|
+
this.showDeploymentLogs = showDeploymentLogs;
|
|
7
|
+
this.deployParams = deployParams;
|
|
8
|
+
}
|
|
9
|
+
async output() {
|
|
10
|
+
throw new Error("Not implemented.");
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export { BaseDeployOutput };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=BaseDeployOutput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/DeployCommand/deployOutputs/BaseDeployOutput.js","sources":["../../../../src/features/DeployCommand/deployOutputs/BaseDeployOutput.ts"],"sourcesContent":["import { UiService, StdioService } from \"@webiny/cli-core/abstractions/index.js\";\nimport { IDeploySingleAppParams } from \"../DeployCommand.js\";\nimport { type PulumiProcess } from \"@webiny/pulumi-sdk\";\n\nexport type IDeployProcess = PulumiProcess;\n\nexport interface IBaseDeployOutputParams {\n deployProcess: IDeployProcess;\n stdio: StdioService.Interface;\n ui: UiService.Interface;\n showDeploymentLogs: boolean;\n deployParams: IDeploySingleAppParams;\n}\n\nexport class BaseDeployOutput {\n public readonly deployProcess: IDeployProcess;\n public readonly stdio: StdioService.Interface;\n public readonly ui: UiService.Interface;\n public readonly showDeploymentLogs: boolean;\n public readonly deployParams: IDeploySingleAppParams;\n\n public constructor({\n deployProcess,\n stdio,\n ui,\n showDeploymentLogs,\n deployParams\n }: IBaseDeployOutputParams) {\n this.deployProcess = deployProcess;\n this.stdio = stdio;\n this.ui = ui;\n this.showDeploymentLogs = showDeploymentLogs;\n this.deployParams = deployParams;\n }\n\n public async output(): Promise<void> {\n throw new Error(\"Not implemented.\");\n }\n}\n"],"names":["BaseDeployOutput","deployProcess","stdio","ui","showDeploymentLogs","deployParams","Error"],"mappings":"AAcO,MAAMA;IAOT,YAAmB,EACfC,aAAa,EACbC,KAAK,EACLC,EAAE,EACFC,kBAAkB,EAClBC,YAAY,EACU,CAAE;QACxB,IAAI,CAAC,aAAa,GAAGJ;QACrB,IAAI,CAAC,KAAK,GAAGC;QACb,IAAI,CAAC,EAAE,GAAGC;QACV,IAAI,CAAC,kBAAkB,GAAGC;QAC1B,IAAI,CAAC,YAAY,GAAGC;IACxB;IAEA,MAAa,SAAwB;QACjC,MAAM,IAAIC,MAAM;IACpB;AACJ"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { BaseDeployOutput } from "./BaseDeployOutput.js";
|
|
2
|
+
import { NoDeploymentLogsDeployOutput } from "./NoDeploymentLogsDeployOutput.js";
|
|
3
|
+
import { WithDeploymentLogsDeployOutput } from "./WithDeploymentLogsDeployOutput.js";
|
|
4
|
+
class DeployOutput extends BaseDeployOutput {
|
|
5
|
+
async output() {
|
|
6
|
+
const OutputClass = this.getOutputClass();
|
|
7
|
+
const output = new OutputClass({
|
|
8
|
+
deployProcess: this.deployProcess,
|
|
9
|
+
stdio: this.stdio,
|
|
10
|
+
ui: this.ui,
|
|
11
|
+
showDeploymentLogs: this.showDeploymentLogs,
|
|
12
|
+
deployParams: this.deployParams
|
|
13
|
+
});
|
|
14
|
+
return output.output();
|
|
15
|
+
}
|
|
16
|
+
getOutputClass() {
|
|
17
|
+
if (this.showDeploymentLogs) return WithDeploymentLogsDeployOutput;
|
|
18
|
+
return NoDeploymentLogsDeployOutput;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export { DeployOutput };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=DeployOutput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/DeployCommand/deployOutputs/DeployOutput.js","sources":["../../../../src/features/DeployCommand/deployOutputs/DeployOutput.ts"],"sourcesContent":["import { BaseDeployOutput } from \"./BaseDeployOutput.js\";\nimport { NoDeploymentLogsDeployOutput } from \"./NoDeploymentLogsDeployOutput.js\";\nimport { WithDeploymentLogsDeployOutput } from \"./WithDeploymentLogsDeployOutput.js\";\n\nexport class DeployOutput extends BaseDeployOutput {\n public override async output() {\n const OutputClass = this.getOutputClass();\n\n const output = new OutputClass({\n deployProcess: this.deployProcess,\n stdio: this.stdio,\n ui: this.ui,\n showDeploymentLogs: this.showDeploymentLogs,\n deployParams: this.deployParams\n });\n\n return output.output();\n }\n\n private getOutputClass() {\n if (this.showDeploymentLogs) {\n return WithDeploymentLogsDeployOutput;\n }\n\n return NoDeploymentLogsDeployOutput;\n }\n}\n"],"names":["DeployOutput","BaseDeployOutput","OutputClass","output","WithDeploymentLogsDeployOutput","NoDeploymentLogsDeployOutput"],"mappings":";;;AAIO,MAAMA,qBAAqBC;IAC9B,MAAsB,SAAS;QAC3B,MAAMC,cAAc,IAAI,CAAC,cAAc;QAEvC,MAAMC,SAAS,IAAID,YAAY;YAC3B,eAAe,IAAI,CAAC,aAAa;YACjC,OAAO,IAAI,CAAC,KAAK;YACjB,IAAI,IAAI,CAAC,EAAE;YACX,oBAAoB,IAAI,CAAC,kBAAkB;YAC3C,cAAc,IAAI,CAAC,YAAY;QACnC;QAEA,OAAOC,OAAO,MAAM;IACxB;IAEQ,iBAAiB;QACrB,IAAI,IAAI,CAAC,kBAAkB,EACvB,OAAOC;QAGX,OAAOC;IACX;AACJ"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { measureDuration } from "@webiny/cli-core/features/utils/index.js";
|
|
2
|
+
import { BaseDeployOutput } from "./BaseDeployOutput.js";
|
|
3
|
+
import ora from "ora";
|
|
4
|
+
const SPINNER_MESSAGES = [
|
|
5
|
+
[
|
|
6
|
+
60,
|
|
7
|
+
"Still deploying..."
|
|
8
|
+
],
|
|
9
|
+
[
|
|
10
|
+
120,
|
|
11
|
+
"Still deploying, please wait..."
|
|
12
|
+
],
|
|
13
|
+
[
|
|
14
|
+
180,
|
|
15
|
+
"Some resources take some time to become ready, please wait..."
|
|
16
|
+
],
|
|
17
|
+
[
|
|
18
|
+
270,
|
|
19
|
+
"Still deploying, please don't interrupt..."
|
|
20
|
+
],
|
|
21
|
+
[
|
|
22
|
+
360,
|
|
23
|
+
"Still deploying, please be patient..."
|
|
24
|
+
],
|
|
25
|
+
[
|
|
26
|
+
450,
|
|
27
|
+
"Still deploying, please don't interrupt..."
|
|
28
|
+
],
|
|
29
|
+
[
|
|
30
|
+
540,
|
|
31
|
+
"Still deploying, please be patient..."
|
|
32
|
+
],
|
|
33
|
+
[
|
|
34
|
+
600,
|
|
35
|
+
"Deploying for 10 minutes now, probably a couple more to go..."
|
|
36
|
+
],
|
|
37
|
+
[
|
|
38
|
+
720,
|
|
39
|
+
"Still deploying, shouldn't be much longer now..."
|
|
40
|
+
],
|
|
41
|
+
[
|
|
42
|
+
840,
|
|
43
|
+
"Looks like it's taking a bit longer than usual, please wait..."
|
|
44
|
+
],
|
|
45
|
+
[
|
|
46
|
+
900,
|
|
47
|
+
"Deploying for 15 minutes now, hopefully it's almost done..."
|
|
48
|
+
],
|
|
49
|
+
[
|
|
50
|
+
1200,
|
|
51
|
+
"Deploying for 20 minutes now, hopefully it's almost done..."
|
|
52
|
+
]
|
|
53
|
+
];
|
|
54
|
+
class NoDeploymentLogsDeployOutput extends BaseDeployOutput {
|
|
55
|
+
async output() {
|
|
56
|
+
const deployProcess = this.deployProcess;
|
|
57
|
+
const ui = this.ui;
|
|
58
|
+
const params = this.deployParams;
|
|
59
|
+
const isPreview = !!params.preview;
|
|
60
|
+
const getDeploymentDuration = measureDuration();
|
|
61
|
+
const spinner = ora(isPreview ? "Previewing deployment..." : "Deploying...");
|
|
62
|
+
const spinnerMessagesTimeouts = SPINNER_MESSAGES.map(([seconds, message])=>setTimeout(()=>{
|
|
63
|
+
spinner.text = message;
|
|
64
|
+
}, 1000 * seconds));
|
|
65
|
+
const threeDotsInterval = setInterval(()=>{
|
|
66
|
+
const spinnerText = spinner.text;
|
|
67
|
+
if (spinnerText.endsWith("...")) spinner.text = spinnerText.substring(0, spinnerText.length - 3);
|
|
68
|
+
else spinner.text = spinnerText + ".";
|
|
69
|
+
}, 1000);
|
|
70
|
+
try {
|
|
71
|
+
spinner.start();
|
|
72
|
+
await deployProcess;
|
|
73
|
+
if (isPreview) spinner.succeed(`Preview completed in ${getDeploymentDuration()}.`);
|
|
74
|
+
else spinner.succeed(`Deployed in ${getDeploymentDuration()}.`);
|
|
75
|
+
} catch (e) {
|
|
76
|
+
if (isPreview) {
|
|
77
|
+
spinner.fail("Preview failed.");
|
|
78
|
+
ui.emptyLine();
|
|
79
|
+
ui.text(e.message);
|
|
80
|
+
ui.error("Preview failed, please check the details above.");
|
|
81
|
+
} else {
|
|
82
|
+
spinner.fail("Deployment failed.");
|
|
83
|
+
ui.emptyLine();
|
|
84
|
+
ui.text(e.message);
|
|
85
|
+
ui.error("Deployment failed, please check the details above.");
|
|
86
|
+
}
|
|
87
|
+
throw e;
|
|
88
|
+
} finally{
|
|
89
|
+
spinnerMessagesTimeouts.forEach(clearTimeout);
|
|
90
|
+
clearInterval(threeDotsInterval);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
export { NoDeploymentLogsDeployOutput };
|
|
95
|
+
|
|
96
|
+
//# sourceMappingURL=NoDeploymentLogsDeployOutput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/DeployCommand/deployOutputs/NoDeploymentLogsDeployOutput.js","sources":["../../../../src/features/DeployCommand/deployOutputs/NoDeploymentLogsDeployOutput.ts"],"sourcesContent":["import { measureDuration } from \"@webiny/cli-core/features/utils/index.js\";\nimport { BaseDeployOutput } from \"./BaseDeployOutput.js\";\nimport ora from \"ora\";\n\nconst SPINNER_MESSAGES: [number, string][] = [\n [60, \"Still deploying...\"],\n [120, \"Still deploying, please wait...\"],\n [180, \"Some resources take some time to become ready, please wait...\"],\n\n [270, \"Still deploying, please don't interrupt...\"],\n [360, \"Still deploying, please be patient...\"],\n [450, \"Still deploying, please don't interrupt...\"],\n [540, \"Still deploying, please be patient...\"],\n\n [600, \"Deploying for 10 minutes now, probably a couple more to go...\"],\n [720, \"Still deploying, shouldn't be much longer now...\"],\n\n [840, \"Looks like it's taking a bit longer than usual, please wait...\"],\n [900, \"Deploying for 15 minutes now, hopefully it's almost done...\"],\n\n [1200, \"Deploying for 20 minutes now, hopefully it's almost done...\"]\n];\n\nexport class NoDeploymentLogsDeployOutput extends BaseDeployOutput {\n public override async output() {\n const deployProcess = this.deployProcess;\n const ui = this.ui;\n const params = this.deployParams;\n\n const isPreview = !!params.preview;\n\n const getDeploymentDuration = measureDuration();\n\n const spinner = ora(isPreview ? \"Previewing deployment...\" : \"Deploying...\");\n\n const spinnerMessagesTimeouts = SPINNER_MESSAGES.map(([seconds, message]) => {\n return setTimeout(() => {\n spinner.text = message;\n }, seconds * 1000);\n });\n\n const threeDotsInterval = setInterval(() => {\n const spinnerText = spinner.text;\n if (spinnerText.endsWith(\"...\")) {\n spinner.text = spinnerText.substring(0, spinnerText.length - 3);\n } else {\n spinner.text = spinnerText + \".\";\n }\n }, 1000);\n\n try {\n spinner.start();\n await deployProcess;\n\n if (isPreview) {\n spinner.succeed(`Preview completed in ${getDeploymentDuration()}.`);\n } else {\n spinner.succeed(`Deployed in ${getDeploymentDuration()}.`);\n }\n } catch (e) {\n if (isPreview) {\n spinner.fail(\"Preview failed.\");\n ui.emptyLine();\n ui.text(e.message);\n ui.error(\"Preview failed, please check the details above.\");\n } else {\n spinner.fail(\"Deployment failed.\");\n ui.emptyLine();\n ui.text(e.message);\n ui.error(\"Deployment failed, please check the details above.\");\n }\n\n throw e;\n } finally {\n spinnerMessagesTimeouts.forEach(clearTimeout);\n clearInterval(threeDotsInterval);\n }\n }\n}\n"],"names":["SPINNER_MESSAGES","NoDeploymentLogsDeployOutput","BaseDeployOutput","deployProcess","ui","params","isPreview","getDeploymentDuration","measureDuration","spinner","ora","spinnerMessagesTimeouts","seconds","message","setTimeout","threeDotsInterval","setInterval","spinnerText","e","clearTimeout","clearInterval"],"mappings":";;;AAIA,MAAMA,mBAAuC;IACzC;QAAC;QAAI;KAAqB;IAC1B;QAAC;QAAK;KAAkC;IACxC;QAAC;QAAK;KAAgE;IAEtE;QAAC;QAAK;KAA6C;IACnD;QAAC;QAAK;KAAwC;IAC9C;QAAC;QAAK;KAA6C;IACnD;QAAC;QAAK;KAAwC;IAE9C;QAAC;QAAK;KAAgE;IACtE;QAAC;QAAK;KAAmD;IAEzD;QAAC;QAAK;KAAiE;IACvE;QAAC;QAAK;KAA8D;IAEpE;QAAC;QAAM;KAA8D;CACxE;AAEM,MAAMC,qCAAqCC;IAC9C,MAAsB,SAAS;QAC3B,MAAMC,gBAAgB,IAAI,CAAC,aAAa;QACxC,MAAMC,KAAK,IAAI,CAAC,EAAE;QAClB,MAAMC,SAAS,IAAI,CAAC,YAAY;QAEhC,MAAMC,YAAY,CAAC,CAACD,OAAO,OAAO;QAElC,MAAME,wBAAwBC;QAE9B,MAAMC,UAAUC,IAAIJ,YAAY,6BAA6B;QAE7D,MAAMK,0BAA0BX,iBAAiB,GAAG,CAAC,CAAC,CAACY,SAASC,QAAQ,GAC7DC,WAAW;gBACdL,QAAQ,IAAI,GAAGI;YACnB,GAAGD,AAAU,OAAVA;QAGP,MAAMG,oBAAoBC,YAAY;YAClC,MAAMC,cAAcR,QAAQ,IAAI;YAChC,IAAIQ,YAAY,QAAQ,CAAC,QACrBR,QAAQ,IAAI,GAAGQ,YAAY,SAAS,CAAC,GAAGA,YAAY,MAAM,GAAG;iBAE7DR,QAAQ,IAAI,GAAGQ,cAAc;QAErC,GAAG;QAEH,IAAI;YACAR,QAAQ,KAAK;YACb,MAAMN;YAEN,IAAIG,WACAG,QAAQ,OAAO,CAAC,CAAC,qBAAqB,EAAEF,wBAAwB,CAAC,CAAC;iBAElEE,QAAQ,OAAO,CAAC,CAAC,YAAY,EAAEF,wBAAwB,CAAC,CAAC;QAEjE,EAAE,OAAOW,GAAG;YACR,IAAIZ,WAAW;gBACXG,QAAQ,IAAI,CAAC;gBACbL,GAAG,SAAS;gBACZA,GAAG,IAAI,CAACc,EAAE,OAAO;gBACjBd,GAAG,KAAK,CAAC;YACb,OAAO;gBACHK,QAAQ,IAAI,CAAC;gBACbL,GAAG,SAAS;gBACZA,GAAG,IAAI,CAACc,EAAE,OAAO;gBACjBd,GAAG,KAAK,CAAC;YACb;YAEA,MAAMc;QACV,SAAU;YACNP,wBAAwB,OAAO,CAACQ;YAChCC,cAAcL;QAClB;IACJ;AACJ"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { measureDuration } from "@webiny/cli-core/features/utils/index.js";
|
|
2
|
+
import { BaseDeployOutput } from "./BaseDeployOutput.js";
|
|
3
|
+
class WithDeploymentLogsDeployOutput extends BaseDeployOutput {
|
|
4
|
+
async output() {
|
|
5
|
+
const deployProcess = this.deployProcess;
|
|
6
|
+
const ui = this.ui;
|
|
7
|
+
const stdio = this.stdio;
|
|
8
|
+
const params = this.deployParams;
|
|
9
|
+
const isPreview = !!params.preview;
|
|
10
|
+
const getDeploymentDuration = measureDuration();
|
|
11
|
+
try {
|
|
12
|
+
if (isPreview) ui.info("Previewing deployment for %s app...", params.app);
|
|
13
|
+
else ui.info("Deploying %s app...", params.app);
|
|
14
|
+
ui.emptyLine();
|
|
15
|
+
this.deployProcess.stdout.pipe(stdio.getStdout());
|
|
16
|
+
this.deployProcess.stderr.pipe(stdio.getStderr());
|
|
17
|
+
await deployProcess;
|
|
18
|
+
if (isPreview) ui.success(`Preview completed in ${getDeploymentDuration()}.`);
|
|
19
|
+
else ui.success(`Deployed in ${getDeploymentDuration()}.`);
|
|
20
|
+
} catch (e) {
|
|
21
|
+
const { PulumiError } = await import("@webiny/pulumi-sdk");
|
|
22
|
+
e instanceof PulumiError || ui.text(e.message);
|
|
23
|
+
if (isPreview) ui.error("Preview failed, please check the details above.");
|
|
24
|
+
else ui.error("Deployment failed, please check the details above.");
|
|
25
|
+
throw e;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export { WithDeploymentLogsDeployOutput };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=WithDeploymentLogsDeployOutput.js.map
|