fix create/delete when there exists broken stacks
This commit is contained in:
@@ -3,6 +3,7 @@ const chalk = require('chalk');
|
||||
const { AutoComplete, Input, Confirm } = require('enquirer');
|
||||
import { Octokit } from '@octokit/core';
|
||||
import { exit } from 'process';
|
||||
import { getTestStacksInfo } from '../../../../common/testservers';
|
||||
import {
|
||||
defaultMenuSettings,
|
||||
getCurrentBranch,
|
||||
@@ -99,47 +100,8 @@ module.exports = {
|
||||
);
|
||||
}
|
||||
|
||||
const stacks = JSON.parse(
|
||||
strings.trim(await system.run(`aws cloudformation list-stacks`))
|
||||
);
|
||||
const teststacks: Stack[] = await Promise.all(
|
||||
stacks.StackSummaries.map(async item => {
|
||||
if (
|
||||
item.StackName.indexOf('photowall-test-') > -1 &&
|
||||
[
|
||||
'CREATE_COMPLETE',
|
||||
'UPDATE_COMPLETE',
|
||||
'UPDATE_IN_PROGRESS',
|
||||
'UPDATE_FAILED',
|
||||
'CREATE_FAILED',
|
||||
'CREATE_IN_PROGRESS'
|
||||
].includes(item.StackStatus)
|
||||
) {
|
||||
const pipeline = JSON.parse(
|
||||
strings.trim(
|
||||
await system.run(
|
||||
`aws codepipeline get-pipeline --name ${item.StackName}Pipeline`
|
||||
)
|
||||
)
|
||||
);
|
||||
const branch = pipeline.pipeline.stages.filter(stage => {
|
||||
return stage.name === 'Source';
|
||||
})[0].actions[0].configuration.Branch;
|
||||
const lastUpdated = pipeline.metadata.updated;
|
||||
return {
|
||||
name: item.StackName,
|
||||
status: item.StackStatus,
|
||||
drift_status: item.DriftInformation.StackDriftStatus,
|
||||
branch: branch,
|
||||
updated: lastUpdated
|
||||
};
|
||||
}
|
||||
return Promise.resolve(null);
|
||||
})
|
||||
);
|
||||
|
||||
const curratedStacks: Stack[] = teststacks.filter(Boolean);
|
||||
const options = curratedStacks.map(item => {
|
||||
const testStacks = await getTestStacksInfo(toolbox);
|
||||
const options = testStacks.map(item => {
|
||||
return item.name;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user