genbox 1.0.103 → 1.0.104
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/list.js +54 -4
- package/package.json +1 -1
package/dist/commands/list.js
CHANGED
|
@@ -49,14 +49,64 @@ exports.listCommand = new commander_1.Command('list')
|
|
|
49
49
|
}
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
|
+
// Calculate column widths
|
|
53
|
+
const nameWidth = Math.max(12, ...genboxes.map(g => g.name.length + (options.all && g.project ? g.project.length + 3 : 0)));
|
|
54
|
+
const statusWidth = 12;
|
|
55
|
+
const ipWidth = 16;
|
|
56
|
+
const sizeWidth = 8;
|
|
52
57
|
genboxes.forEach((genbox) => {
|
|
53
58
|
const statusColor = genbox.status === 'running' ? chalk_1.default.green :
|
|
54
59
|
genbox.status === 'terminated' ? chalk_1.default.red : chalk_1.default.yellow;
|
|
55
60
|
// Show project info when listing all
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
61
|
+
const projectSuffix = options.all && genbox.project ? ` [${genbox.project}]` : '';
|
|
62
|
+
const nameWithProject = genbox.name + projectSuffix;
|
|
63
|
+
// Format end hour as relative time
|
|
64
|
+
let endHourInfo = '';
|
|
65
|
+
if (genbox.currentHourEnd && genbox.status === 'running') {
|
|
66
|
+
const endTime = new Date(genbox.currentHourEnd);
|
|
67
|
+
const now = new Date();
|
|
68
|
+
const diffMs = endTime.getTime() - now.getTime();
|
|
69
|
+
if (diffMs > 0) {
|
|
70
|
+
const totalSeconds = Math.floor(diffMs / 1000);
|
|
71
|
+
const mins = Math.floor(totalSeconds / 60);
|
|
72
|
+
const secs = totalSeconds % 60;
|
|
73
|
+
if (mins > 0) {
|
|
74
|
+
endHourInfo = ` hour ends in ${mins}m:${secs.toString().padStart(2, '0')}s`;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
endHourInfo = ` hour ends in ${secs}s`;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
endHourInfo = ' hour renewing...';
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// Show auto-destroy status
|
|
85
|
+
let protectedInfo = '';
|
|
86
|
+
if (genbox.autoDestroyOnInactivity === false) {
|
|
87
|
+
protectedInfo = chalk_1.default.yellow(' [protected]');
|
|
88
|
+
}
|
|
89
|
+
else if (genbox.protectedUntil) {
|
|
90
|
+
const protectedUntil = new Date(genbox.protectedUntil);
|
|
91
|
+
const now = new Date();
|
|
92
|
+
const diffMs = protectedUntil.getTime() - now.getTime();
|
|
93
|
+
const hoursRemaining = Math.ceil(diffMs / (1000 * 60 * 60));
|
|
94
|
+
if (hoursRemaining > 0) {
|
|
95
|
+
protectedInfo = chalk_1.default.cyan(` [extended ${hoursRemaining}h]`);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
protectedInfo = chalk_1.default.dim(' [auto-destroy]');
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
protectedInfo = chalk_1.default.dim(' [auto-destroy]');
|
|
103
|
+
}
|
|
104
|
+
const namePart = chalk_1.default.cyan(nameWithProject.padEnd(nameWidth));
|
|
105
|
+
const statusPart = statusColor(genbox.status.padEnd(statusWidth));
|
|
106
|
+
const ipPart = chalk_1.default.dim((genbox.ipAddress || 'Pending IP').padEnd(ipWidth));
|
|
107
|
+
const sizePart = `(${genbox.size})`.padEnd(sizeWidth);
|
|
108
|
+
const extraInfo = chalk_1.default.dim(endHourInfo) + protectedInfo;
|
|
109
|
+
console.log(`${namePart} ${statusPart} ${ipPart} ${sizePart}${extraInfo}`);
|
|
60
110
|
});
|
|
61
111
|
console.log(chalk_1.default.dim('────────────────────────────────────────────────────'));
|
|
62
112
|
// Show hint if in project context and not showing all
|