From b338de406ca471d55bf96e863c6b2950b7f9d533 Mon Sep 17 00:00:00 2001 From: Anders Gustafsson Date: Tue, 17 Jan 2023 09:16:12 +0100 Subject: [PATCH] Add support for new aws-github connection --- .../deployment/testservers/status/status.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/commands/deployment/testservers/status/status.ts b/src/commands/deployment/testservers/status/status.ts index a6131a0..06f7944 100644 --- a/src/commands/deployment/testservers/status/status.ts +++ b/src/commands/deployment/testservers/status/status.ts @@ -17,7 +17,7 @@ module.exports = { description: 'Show status for available testservers (s)', hidden: false, run: async (toolbox: GluegunMenuToolbox) => { - + const { system, strings } = toolbox const stacks = JSON.parse(strings.trim(await system.run(`aws cloudformation list-stacks`))); @@ -25,9 +25,10 @@ module.exports = { if (item.StackName.indexOf('photowall-test-') > -1 && ['CREATE_COMPLETE', 'UPDATE_COMPLETE', 'UPDATE_IN_PROGRESS', 'UPDATE_FAILED', 'CREATE_FAILED', 'CREATE_IN_PROGRESS'].includes(item.StackStatus)) { try { const pipeline = JSON.parse(strings.trim(await system.run(`aws codepipeline get-pipeline --name ${item.StackName}Pipeline`))); - const branch = pipeline.pipeline.stages.filter(stage => { + const sourceStage = pipeline.pipeline.stages.filter(stage => { return stage.name === 'Source'; - })[0].actions[0].configuration.Branch; + }); + const branch = sourceStage[0].actions[0].configuration.Branch ?? sourceStage[0].actions[0].configuration.BranchName; const lastUpdated = pipeline.metadata.updated; return { name: item.StackName, @@ -45,14 +46,14 @@ module.exports = { updated: '', } } - + } return Promise.resolve(null); })); const curratedStacks: Stack[] = teststacks.filter(Boolean); - const status = (status: string) => { + const status = (status: string) => { switch(status) { case 'NO_STATUS': return `(${chalk.red.bold('?')})`; @@ -83,9 +84,9 @@ module.exports = { const timeSince = (date: number) => { const now = Date.now(); const seconds = Math.floor((now - date) / 1000); - + let interval = seconds / 31536000; - + if (interval > 1) { return Math.floor(interval) + " years"; }