genbox 1.0.35 → 1.0.36
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/status.js +28 -0
- package/package.json +1 -1
package/dist/commands/status.js
CHANGED
|
@@ -198,6 +198,34 @@ exports.statusCommand = new commander_1.Command('status')
|
|
|
198
198
|
const durationStr = setupDuration ? formatDuration(setupDuration) : 'unknown';
|
|
199
199
|
console.log(chalk_1.default.green(`[SUCCESS] Setup completed! (took ${durationStr})`));
|
|
200
200
|
console.log('');
|
|
201
|
+
// Show billing info
|
|
202
|
+
const billing = {
|
|
203
|
+
creditsPerHour: target.creditsPerHour || 1,
|
|
204
|
+
totalCreditsUsed: target.totalCreditsUsed || 0,
|
|
205
|
+
totalHoursUsed: target.totalHoursUsed || 0,
|
|
206
|
+
currentHourEnd: target.currentHourEnd,
|
|
207
|
+
lastActivityAt: target.lastActivityAt,
|
|
208
|
+
autoDestroyOnInactivity: target.autoDestroyOnInactivity ?? true,
|
|
209
|
+
};
|
|
210
|
+
const now = new Date();
|
|
211
|
+
const minutesUntilBilling = billing.currentHourEnd
|
|
212
|
+
? Math.max(0, Math.ceil((new Date(billing.currentHourEnd).getTime() - now.getTime()) / (60 * 1000)))
|
|
213
|
+
: 0;
|
|
214
|
+
const minutesInactive = billing.lastActivityAt
|
|
215
|
+
? Math.floor((now.getTime() - new Date(billing.lastActivityAt).getTime()) / (60 * 1000))
|
|
216
|
+
: 0;
|
|
217
|
+
console.log(chalk_1.default.blue('[INFO] === Billing ==='));
|
|
218
|
+
console.log(` Size: ${target.size} (${billing.creditsPerHour} credit${billing.creditsPerHour > 1 ? 's' : ''}/hr)`);
|
|
219
|
+
console.log(` Current hour ends in: ${chalk_1.default.cyan(minutesUntilBilling + ' min')}`);
|
|
220
|
+
console.log(` Last activity: ${minutesInactive < 1 ? 'just now' : minutesInactive + ' min ago'}`);
|
|
221
|
+
console.log(` Total: ${billing.totalHoursUsed} hour${billing.totalHoursUsed !== 1 ? 's' : ''}, ${billing.totalCreditsUsed} credit${billing.totalCreditsUsed !== 1 ? 's' : ''}`);
|
|
222
|
+
if (billing.autoDestroyOnInactivity) {
|
|
223
|
+
const minutesUntilDestroy = Math.max(0, 60 - minutesInactive);
|
|
224
|
+
if (minutesInactive >= 45) {
|
|
225
|
+
console.log(chalk_1.default.yellow(` Auto-destroy in: ${minutesUntilDestroy} min (inactive)`));
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
console.log('');
|
|
201
229
|
// Show Docker containers status
|
|
202
230
|
const dockerStatus = sshExec(target.ipAddress, keyPath, 'docker ps --format "{{.Names}}\\t{{.Status}}" 2>/dev/null', 10);
|
|
203
231
|
if (dockerStatus && dockerStatus.trim()) {
|