forked from anomalyco/sst
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.js
More file actions
38 lines (31 loc) · 1 KB
/
Copy pathdeploy.js
File metadata and controls
38 lines (31 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"use strict";
const path = require("path");
const paths = require("./util/paths");
const { synth, deploy, writeOutputsFile } = require("./util/cdkHelpers");
const { STACK_DEPLOY_STATUS } = require("@serverless-stack/core");
module.exports = async function (argv, config, cliInfo) {
// Normalize stack name
const stackPrefix = `${config.stage}-${config.name}-`;
let stackName = argv.stack;
if (stackName) {
stackName = stackName.startsWith(stackPrefix)
? stackName
: `${stackPrefix}${stackName}`;
}
// Run CDK Synth
await synth(cliInfo.cdkOptions);
// Run CDK Deploy
const stacksData = await deploy(cliInfo.cdkOptions, stackName);
// Write outputsFile
if (argv.outputsFile) {
await writeOutputsFile(
stacksData,
path.join(paths.appPath, argv.outputsFile)
);
}
// Check all stacks deployed successfully
if (stacksData.some(({ status }) => status === STACK_DEPLOY_STATUS.FAILED)) {
throw new Error(`Failed to deploy the app`);
}
return stacksData;
};