genbox 1.0.103 → 1.0.105

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.
@@ -36,10 +36,10 @@ exports.extendCommand = new commander_1.Command('extend')
36
36
  }
37
37
  // Determine hours - from option or prompt
38
38
  let hours;
39
- if (options.hours) {
39
+ if (options.hours !== undefined) {
40
40
  hours = parseInt(options.hours, 10);
41
- if (isNaN(hours) || hours < 1) {
42
- console.error(chalk_1.default.red('Error: Hours must be a positive number'));
41
+ if (isNaN(hours) || hours < 0) {
42
+ console.error(chalk_1.default.red('Error: Hours must be 0 or a positive number'));
43
43
  return;
44
44
  }
45
45
  }
@@ -52,7 +52,8 @@ exports.extendCommand = new commander_1.Command('extend')
52
52
  { name: '2 hours', value: 2 },
53
53
  { name: '4 hours', value: 4 },
54
54
  { name: '8 hours', value: 8 },
55
- { name: 'Custom...', value: 0 },
55
+ { name: 'Custom...', value: -2 },
56
+ { name: 'Clear extension', value: 0 },
56
57
  { name: 'Remove auto expiry', value: -1 },
57
58
  ],
58
59
  });
@@ -61,13 +62,13 @@ exports.extendCommand = new commander_1.Command('extend')
61
62
  hours = 1;
62
63
  options.autoDestroy = false; // This will set disableAutoDestroy = true
63
64
  }
64
- else if (choice === 0) {
65
+ else if (choice === -2) {
65
66
  const customHours = await (0, input_1.default)({
66
- message: 'Enter number of hours:',
67
+ message: 'Enter number of hours (0 to clear):',
67
68
  validate: (val) => {
68
69
  const num = parseInt(val, 10);
69
- if (isNaN(num) || num < 1)
70
- return 'Please enter a positive number';
70
+ if (isNaN(num) || num < 0)
71
+ return 'Please enter 0 or a positive number';
71
72
  if (num > 24)
72
73
  return 'Maximum 24 hours';
73
74
  return true;
@@ -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 projectInfo = options.all && genbox.project
57
- ? chalk_1.default.dim(` [${genbox.project}]`)
58
- : '';
59
- console.log(`${chalk_1.default.cyan(genbox.name)}${projectInfo} \t ${statusColor(genbox.status)} \t ${chalk_1.default.dim(genbox.ipAddress || 'Pending IP')} \t (${genbox.size})`);
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "genbox",
3
- "version": "1.0.103",
3
+ "version": "1.0.105",
4
4
  "description": "Genbox CLI - AI-Powered Development Environments",
5
5
  "main": "dist/index.js",
6
6
  "bin": {