genbox 1.0.78 → 1.0.79

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.
@@ -7,17 +7,18 @@ exports.extendCommand = void 0;
7
7
  const commander_1 = require("commander");
8
8
  const chalk_1 = __importDefault(require("chalk"));
9
9
  const ora_1 = __importDefault(require("ora"));
10
+ const select_1 = __importDefault(require("@inquirer/select"));
11
+ const input_1 = __importDefault(require("@inquirer/input"));
10
12
  const api_1 = require("../api");
11
13
  const genbox_selector_1 = require("../genbox-selector");
12
14
  exports.extendCommand = new commander_1.Command('extend')
13
15
  .description('Extend genbox and reset inactivity timer')
14
16
  .argument('[name]', 'Name of the Genbox (optional - will auto-select or prompt)')
15
- .argument('[hours]', 'Hours to extend (default: 1)', '1')
17
+ .option('-h, --hours <hours>', 'Hours to extend (skip prompt)')
16
18
  .option('--no-auto-destroy', 'Disable auto-destroy on inactivity')
17
19
  .option('--enable-auto-destroy', 'Re-enable auto-destroy on inactivity')
18
- .action(async (name, hoursArg, options) => {
20
+ .action(async (name, options) => {
19
21
  try {
20
- const hours = parseInt(hoursArg, 10) || 1;
21
22
  // Select genbox
22
23
  const { genbox: target, cancelled } = await (0, genbox_selector_1.selectGenbox)(name, {
23
24
  selectMessage: 'Select a genbox to extend:',
@@ -33,6 +34,45 @@ exports.extendCommand = new commander_1.Command('extend')
33
34
  console.error(chalk_1.default.red(`Error: Genbox '${target.name}' is not running (status: ${target.status})`));
34
35
  return;
35
36
  }
37
+ // Determine hours - from option or prompt
38
+ let hours;
39
+ if (options.hours) {
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'));
43
+ return;
44
+ }
45
+ }
46
+ else {
47
+ // Show selection prompt
48
+ const choice = await (0, select_1.default)({
49
+ message: 'How long do you want to extend?',
50
+ choices: [
51
+ { name: '1 hour', value: 1 },
52
+ { name: '2 hours', value: 2 },
53
+ { name: '4 hours', value: 4 },
54
+ { name: '8 hours', value: 8 },
55
+ { name: 'Custom...', value: 0 },
56
+ ],
57
+ });
58
+ if (choice === 0) {
59
+ const customHours = await (0, input_1.default)({
60
+ message: 'Enter number of hours:',
61
+ validate: (val) => {
62
+ const num = parseInt(val, 10);
63
+ if (isNaN(num) || num < 1)
64
+ return 'Please enter a positive number';
65
+ if (num > 24)
66
+ return 'Maximum 24 hours';
67
+ return true;
68
+ },
69
+ });
70
+ hours = parseInt(customHours, 10);
71
+ }
72
+ else {
73
+ hours = choice;
74
+ }
75
+ }
36
76
  // Determine disableAutoDestroy value
37
77
  let disableAutoDestroy;
38
78
  if (options.autoDestroy === false) {
@@ -41,7 +81,7 @@ exports.extendCommand = new commander_1.Command('extend')
41
81
  else if (options.enableAutoDestroy) {
42
82
  disableAutoDestroy = false; // --enable-auto-destroy flag
43
83
  }
44
- const spinner = (0, ora_1.default)(`Extending ${target.name}...`).start();
84
+ const spinner = (0, ora_1.default)(`Extending ${target.name} by ${hours} hour${hours > 1 ? 's' : ''}...`).start();
45
85
  const result = await (0, api_1.fetchApi)(`/genboxes/${target._id}/extend`, {
46
86
  method: 'POST',
47
87
  body: JSON.stringify({
@@ -58,6 +98,7 @@ exports.extendCommand = new commander_1.Command('extend')
58
98
  console.log(chalk_1.default.dim(` Current hour ends in: ${minutesUntil} minutes`));
59
99
  }
60
100
  console.log(chalk_1.default.dim(` Auto-destroy: ${result.autoDestroyEnabled ? 'enabled' : 'disabled'}`));
101
+ console.log(chalk_1.default.dim(` Note: Credits charged at the end of each hour`));
61
102
  }
62
103
  else {
63
104
  console.error(chalk_1.default.red(`Error: ${result.message}`));