Cleanup code readability of base stack

pull/310/head
Frostebite 2021-12-29 14:41:57 +00:00
parent d608318778
commit f7b7752040
3 changed files with 13 additions and 9 deletions

9
dist/index.js vendored
View File

@ -851,14 +851,17 @@ class AWSBaseStack {
Parameters: parameters,
Capabilities: ['CAPABILITY_IAM'],
};
const stacks = (_a = (yield CF.listStacks({ StackStatusFilter: ['UPDATE_COMPLETE', 'CREATE_COMPLETE', 'ROLLBACK_COMPLETE'] }).promise()).StackSummaries) === null || _a === void 0 ? void 0 : _a.map((x) => x.StackName);
const stackExists = (stacks === null || stacks === void 0 ? void 0 : stacks.includes(baseStackName)) || false;
const stacks = yield CF.listStacks({
StackStatusFilter: ['UPDATE_COMPLETE', 'CREATE_COMPLETE', 'ROLLBACK_COMPLETE'],
}).promise();
const stackNames = ((_a = stacks.StackSummaries) === null || _a === void 0 ? void 0 : _a.map((x) => x.StackName)) || [];
const stackExists = stackNames.includes(baseStackName) || false;
const describeStack = () => __awaiter(this, void 0, void 0, function* () {
return yield CF.describeStacks(describeStackInput).promise();
});
try {
if (!stackExists) {
cloud_runner_logger_1.default.log(`${baseStackName} stack does not exist (${JSON.stringify(stacks)})`);
cloud_runner_logger_1.default.log(`${baseStackName} stack does not exist (${JSON.stringify(stackNames)})`);
yield CF.createStack(createStackInput).promise();
cloud_runner_logger_1.default.log(`created stack (version: ${parametersHash})`);
}

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -44,16 +44,17 @@ export class AWSBaseStack {
Capabilities: ['CAPABILITY_IAM'],
};
const stacks = (
await CF.listStacks({ StackStatusFilter: ['UPDATE_COMPLETE', 'CREATE_COMPLETE', 'ROLLBACK_COMPLETE'] }).promise()
).StackSummaries?.map((x) => x.StackName);
const stackExists: Boolean = stacks?.includes(baseStackName) || false;
const stacks = await CF.listStacks({
StackStatusFilter: ['UPDATE_COMPLETE', 'CREATE_COMPLETE', 'ROLLBACK_COMPLETE'],
}).promise();
const stackNames = stacks.StackSummaries?.map((x) => x.StackName) || [];
const stackExists: Boolean = stackNames.includes(baseStackName) || false;
const describeStack = async () => {
return await CF.describeStacks(describeStackInput).promise();
};
try {
if (!stackExists) {
CloudRunnerLogger.log(`${baseStackName} stack does not exist (${JSON.stringify(stacks)})`);
CloudRunnerLogger.log(`${baseStackName} stack does not exist (${JSON.stringify(stackNames)})`);
await CF.createStack(createStackInput).promise();
CloudRunnerLogger.log(`created stack (version: ${parametersHash})`);
}