From 87bbc14dadf8ecd1fcb93380da30adde16de74c4 Mon Sep 17 00:00:00 2001 From: Anders Gustafsson Date: Wed, 12 Apr 2023 10:29:51 +0200 Subject: [PATCH] Fix status for failed stacks --- .../deployment/testservers/status/status.ts | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/commands/deployment/testservers/status/status.ts b/src/commands/deployment/testservers/status/status.ts index cce7a6f..bd2bcf9 100644 --- a/src/commands/deployment/testservers/status/status.ts +++ b/src/commands/deployment/testservers/status/status.ts @@ -9,6 +9,7 @@ type Stack = { drift_status: string; branch: string; updated: string; + created: string; }; module.exports = { @@ -32,7 +33,8 @@ module.exports = { 'UPDATE_IN_PROGRESS', 'UPDATE_FAILED', 'CREATE_FAILED', - 'CREATE_IN_PROGRESS' + 'CREATE_IN_PROGRESS', + 'ROLLBACK_COMPLETE', ].includes(item.StackStatus) ) { try { @@ -55,15 +57,17 @@ module.exports = { status: item.StackStatus, drift_status: item.DriftInformation.StackDriftStatus, branch: branch, - updated: lastUpdated + updated: lastUpdated, + created: item.CreationTime, }; } catch (e) { return { name: item.StackName, - status: 'NO_STATUS', + status: item.StackStatus, drift_status: '', branch: '', - updated: '' + updated: '', + created: item.CreationTime, }; } } @@ -75,17 +79,18 @@ module.exports = { const status = (status: string) => { switch (status) { - case 'NO_STATUS': - return `(${chalk.red.bold('?')})`; case 'UPDATE_FAILED': case 'CREATE_FAILED': - return `(${chalk.red.bold('FAILED')})`; + case 'ROLLBACK_COMPLETE': + return `(${chalk.red('FAILED')})`; case 'UPDATE_IN_PROGRESS': case 'CREATE_IN_PROGRESS': - return `(${chalk.yellow.bold('IN PROGRESS')})`; + return `(${chalk.yellow('IN PROGRESS')})`; case 'UPDATE_COMPLETE': case 'CREATE_COMPLETE': return `(${chalk.greenBright('OK')})`; + default: + return `(${chalk.red.bold('?')})`; } }; @@ -148,7 +153,7 @@ module.exports = { status(stack.status), stack.name, ellipsis(stack.branch, 24), - timeSince(t.getTime()), + !isNaN(t.getTime()) ? timeSince(t.getTime()) : timeSince((new Date(stack.created)).getTime()), stackUrl(stack.name) ]); }