updated listing in testserver status
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { GluegunMenuToolbox } from '@lenne.tech/gluegun-menu'
|
||||
import chalk = require('chalk');
|
||||
import { defaultMenuSettings } from '../../../../globals';
|
||||
const tto = require('terminal-table-output').create();
|
||||
|
||||
@@ -67,11 +68,49 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
|
||||
const stackUrl = (stackname: string) => {
|
||||
return `https://test-${stackname.split('photowall-test-')[1]}.photowall-test.com/us`;
|
||||
};
|
||||
|
||||
const ellipsis = (a: string, max: number) => {
|
||||
return a.length > max ? a.substr(0, max) + '..' : a;
|
||||
};
|
||||
|
||||
const timeSince = (date: number) => {
|
||||
const now = Date.now();
|
||||
var seconds = Math.floor((now - date) / 1000);
|
||||
|
||||
var interval = seconds / 31536000;
|
||||
|
||||
if (interval > 1) {
|
||||
return Math.floor(interval) + " years";
|
||||
}
|
||||
interval = seconds / 2592000;
|
||||
if (interval > 1) {
|
||||
return `${chalk.red(Math.floor(interval) + " months")}`;
|
||||
}
|
||||
interval = seconds / 86400;
|
||||
if (interval > 1) {
|
||||
const days = Math.floor(interval);
|
||||
return `${chalk[days >= 14 ? 'yellow' : 'green'](days + " days")}`;
|
||||
}
|
||||
interval = seconds / 3600;
|
||||
if (interval > 1) {
|
||||
return `${chalk.green(Math.floor(interval) + " hours")}`;
|
||||
}
|
||||
interval = seconds / 60;
|
||||
if (interval > 1) {
|
||||
return `${chalk.green(Math.floor(interval) + " minutes")}`;
|
||||
}
|
||||
return Math.floor(seconds) + " seconds";
|
||||
}
|
||||
|
||||
tto.line('-');
|
||||
tto.pushrow(['| status', 'stack', 'branch', 'updated'])
|
||||
tto.pushrow(['| status', 'stack', 'branch', 'time since update', 'url'])
|
||||
.line('-');
|
||||
for (const stack of curratedStacks) {
|
||||
tto.pushrow([status(stack.status), stack.name, stack.branch, stack.updated]);
|
||||
const t = new Date(stack.updated);
|
||||
tto.pushrow([status(stack.status), stack.name, ellipsis(stack.branch, 24), timeSince(t.getTime()), stackUrl(stack.name)]);
|
||||
}
|
||||
tto.print(true);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user