diff --git a/src/commands/deployment/testservers/status/status.ts b/src/commands/deployment/testservers/status/status.ts index e135062..0cf4d2b 100644 --- a/src/commands/deployment/testservers/status/status.ts +++ b/src/commands/deployment/testservers/status/status.ts @@ -94,26 +94,58 @@ module.exports = { let interval = seconds / 31536000; + // Years if (interval > 1) { return Math.floor(interval) + ' years'; } + // Months interval = seconds / 2592000; if (interval > 1) { - return `${chalk.red(Math.floor(interval) + ' months')}`; + return `${chalk.red('WTF!')}`; } + // Days interval = seconds / 86400; if (interval > 1) { const days = Math.floor(interval); - return `${chalk[days >= 14 ? 'yellow' : 'green'](days + ' days')}`; + let color = 'green'; + + if (days >= 2) { + if (days <= 12) { + // Gradient from yellow (#FFFF00) to dark red (#8B0000) over 10 days (days 2-12) + const gradientColors = [ + '#FFFF00', // 2 days - yellow + '#FFE600', // 3 days + '#FFCC00', // 4 days + '#FFB300', // 5 days + '#FF9900', // 6 days + '#FF8000', // 7 days + '#FF6600', // 8 days + '#FF4D00', // 9 days + '#FF3300', // 10 days + '#CC2900', // 11 days + '#8B0000', // 12 days - dark red + ]; + const colorIndex = Math.min(days - 2, gradientColors.length - 1); + color = gradientColors[colorIndex]; + } else { + color = '#8B0000'; // dark red for 12+ days + } + return `${chalk.hex(color)(days + ' days')}`; + } else { + return `${chalk.green(days + ' days')}`; + } } + // Hours interval = seconds / 3600; if (interval > 1) { return `${chalk.green(Math.floor(interval) + ' hours')}`; } + // Minutes interval = seconds / 60; if (interval > 1) { return `${chalk.green(Math.floor(interval) + ' minutes')}`; } + // Seconds return Math.floor(seconds) + ' seconds'; }; @@ -124,8 +156,8 @@ module.exports = { 'stack', 'branch', 'issue status', - 'issue updated', - 'stack updated', + // 'issue updated', + 'last commit', // 'url' ]) .line('-'); @@ -149,6 +181,13 @@ module.exports = { } const issueStatuses = await Promise.all(issueStatusPromises); + // Sort the testStacks list on number. They are named like photowall-test-XX where XX is the number. + testStacks.sort((a, b) => { + const aNumber = parseInt(a.name.split('photowall-test-')[1]); + const bNumber = parseInt(b.name.split('photowall-test-')[1]); + return aNumber - bNumber; + }); + for (const stack of testStacks) { const regex = /^(\d+)/; const match = stack.branch.match(regex); @@ -160,17 +199,17 @@ module.exports = { stack.name, ellipsis(stack.branch, 24), printIssueStatus(issueStatuses, branchIssueNumber), - issueStatuses.find( - (issueStatus) => issueStatus.issue === branchIssueNumber, - ) - ? timeSince( - new Date( - issueStatuses.find( - (issueStatus) => issueStatus.issue === branchIssueNumber, - ).issueUpdated, - ).getTime(), - ) - : '-', + // issueStatuses.find( + // (issueStatus) => issueStatus.issue === branchIssueNumber, + // ) + // ? timeSince( + // new Date( + // issueStatuses.find( + // (issueStatus) => issueStatus.issue === branchIssueNumber, + // ).issueUpdated, + // ).getTime(), + // ) + // : '-', !isNaN(t.getTime()) ? timeSince(t.getTime()) : timeSince(new Date(stack.created).getTime()),