genbox 1.0.21 → 1.0.23

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.
@@ -162,8 +162,9 @@ exports.createCommand = new commander_1.Command('create')
162
162
  console.log(chalk_1.default.blue('Resolving configuration...'));
163
163
  console.log('');
164
164
  let resolved = await profileResolver.resolve(config, createOptions);
165
- // Interactive branch selection if no branch was specified
166
- if (!options.branch && !options.newBranch && !options.yes && resolved.repos.length > 0) {
165
+ // Interactive branch selection if no branch options were specified
166
+ // Skip if: -b (existing branch), -f (new branch from source), -n (explicit new branch name), or -y (skip prompts)
167
+ if (!options.branch && !options.fromBranch && !options.newBranch && !options.yes && resolved.repos.length > 0) {
167
168
  resolved = await promptForBranchOptions(resolved, config);
168
169
  }
169
170
  // Display resolved configuration
@@ -641,6 +642,11 @@ function buildPayload(resolved, config, publicKey, privateKey, configLoader) {
641
642
  mode: i.mode,
642
643
  })),
643
644
  database: resolved.database,
645
+ // Configuration tracking (for rebuild)
646
+ profile: resolved.profile,
647
+ branch: resolved.repos[0]?.branch,
648
+ newBranch: resolved.repos[0]?.newBranch,
649
+ sourceBranch: resolved.repos[0]?.sourceBranch,
644
650
  };
645
651
  }
646
652
  /**
@@ -47,6 +47,7 @@ const os = __importStar(require("os"));
47
47
  const config_loader_1 = require("../config-loader");
48
48
  const profile_resolver_1 = require("../profile-resolver");
49
49
  const api_1 = require("../api");
50
+ const genbox_selector_1 = require("../genbox-selector");
50
51
  const schema_v4_1 = require("../schema-v4");
51
52
  function getPublicSshKey() {
52
53
  const home = os.homedir();
@@ -76,10 +77,6 @@ function getPrivateSshKey() {
76
77
  }
77
78
  return undefined;
78
79
  }
79
- async function findGenboxByName(name) {
80
- const genboxes = await (0, api_1.fetchApi)('/genboxes');
81
- return genboxes.find((g) => g.name === name);
82
- }
83
80
  async function rebuildGenbox(id, payload) {
84
81
  return (0, api_1.fetchApi)(`/genboxes/${id}/rebuild`, {
85
82
  method: 'POST',
@@ -421,34 +418,48 @@ async function promptForBranchOptions(resolved, config) {
421
418
  }
422
419
  exports.rebuildCommand = new commander_1.Command('rebuild')
423
420
  .description('Rebuild an existing Genbox environment with updated configuration')
424
- .argument('<name>', 'Name of the Genbox to rebuild')
421
+ .argument('[name]', 'Name of the Genbox to rebuild (optional - will prompt if not provided)')
425
422
  .option('-p, --profile <profile>', 'Use a predefined profile')
423
+ .option('-a, --all', 'Select from all genboxes (not just current project)')
426
424
  .option('-b, --branch <branch>', 'Git branch to checkout')
427
425
  .option('-n, --new-branch <name>', 'Create a new branch with this name')
428
426
  .option('-f, --from-branch <branch>', 'Source branch to create new branch from')
429
427
  .option('-y, --yes', 'Skip interactive prompts')
430
428
  .action(async (name, options) => {
431
429
  try {
432
- // Find existing genbox
433
- const spinner = (0, ora_1.default)(`Finding Genbox '${name}'...`).start();
434
- let genbox;
435
- try {
436
- genbox = await findGenboxByName(name);
437
- }
438
- catch (error) {
439
- spinner.fail(chalk_1.default.red(`Failed to find Genbox: ${error.message}`));
440
- if (error instanceof api_1.AuthenticationError) {
441
- console.log('');
442
- console.log(chalk_1.default.yellow(' Please authenticate first:'));
443
- console.log(chalk_1.default.cyan(' $ genbox login'));
444
- }
430
+ // Select genbox (interactive if no name provided)
431
+ const { genbox, cancelled } = await (0, genbox_selector_1.selectGenbox)(name, {
432
+ all: options.all,
433
+ selectMessage: 'Select a genbox to rebuild:',
434
+ });
435
+ if (cancelled) {
436
+ console.log(chalk_1.default.dim('Cancelled.'));
445
437
  return;
446
438
  }
447
439
  if (!genbox) {
448
- spinner.fail(chalk_1.default.red(`Genbox '${name}' not found`));
449
440
  return;
450
441
  }
451
- spinner.succeed(`Found Genbox '${name}'`);
442
+ const selectedName = genbox.name;
443
+ // Check if genbox has stored configuration (profile/apps/branch)
444
+ const storedProfile = genbox.profile;
445
+ const storedApps = genbox.apps && genbox.apps.length > 0 ? genbox.apps : null;
446
+ const storedBranch = genbox.branch;
447
+ const storedNewBranch = genbox.newBranch;
448
+ const storedSourceBranch = genbox.sourceBranch;
449
+ if (storedProfile || storedApps || storedBranch) {
450
+ console.log(chalk_1.default.dim(`Using stored configuration from '${selectedName}':`));
451
+ if (storedProfile)
452
+ console.log(chalk_1.default.dim(` Profile: ${storedProfile}`));
453
+ if (storedApps)
454
+ console.log(chalk_1.default.dim(` Apps: ${storedApps.join(', ')}`));
455
+ if (storedNewBranch) {
456
+ console.log(chalk_1.default.dim(` Branch: ${storedNewBranch} (created from ${storedSourceBranch || 'main'})`));
457
+ }
458
+ else if (storedBranch) {
459
+ console.log(chalk_1.default.dim(` Branch: ${storedBranch}`));
460
+ }
461
+ console.log('');
462
+ }
452
463
  // Load configuration
453
464
  const configLoader = new config_loader_1.ConfigLoader();
454
465
  const loadResult = await configLoader.load();
@@ -470,29 +481,40 @@ exports.rebuildCommand = new commander_1.Command('rebuild')
470
481
  if (options.fromBranch && !options.newBranch) {
471
482
  // Generate unique branch name: {genbox-name}-{short-timestamp}
472
483
  const timestamp = Date.now().toString(36);
473
- newBranchName = `${name}-${timestamp}`;
484
+ newBranchName = `${selectedName}-${timestamp}`;
474
485
  console.log(chalk_1.default.dim(` Auto-generated branch name: ${newBranchName}`));
475
486
  }
476
- // Build options for resolving
487
+ // Use stored profile/apps/branch if available and not overridden by CLI options
488
+ const effectiveProfile = options.profile || storedProfile;
489
+ const effectiveApps = storedApps; // Use stored apps for rebuild
490
+ // For branch: CLI options override, then stored newBranch (if it was created), then stored branch
491
+ const effectiveBranch = options.branch || storedNewBranch || storedBranch;
492
+ // For new branch creation: only use CLI options (user must explicitly request new branch on rebuild)
493
+ const effectiveNewBranch = newBranchName;
494
+ const effectiveSourceBranch = options.fromBranch;
495
+ // Build options for resolving - use stored config, skip interactive prompts
477
496
  const createOptions = {
478
- name,
479
- profile: options.profile,
480
- branch: options.branch,
481
- newBranch: newBranchName,
482
- sourceBranch: options.fromBranch,
483
- yes: options.yes,
497
+ name: selectedName,
498
+ profile: effectiveProfile,
499
+ apps: effectiveApps || undefined, // Pre-select stored apps
500
+ branch: effectiveBranch,
501
+ newBranch: effectiveNewBranch,
502
+ sourceBranch: effectiveSourceBranch,
503
+ // Skip interactive prompts if we have stored config
504
+ yes: options.yes || !!(storedProfile || storedApps),
484
505
  };
485
506
  console.log(chalk_1.default.blue('Resolving configuration...'));
486
507
  console.log('');
487
508
  let resolved = await profileResolver.resolve(config, createOptions);
488
- // Interactive branch selection if no branch was specified
489
- if (!options.branch && !options.newBranch && !options.yes && resolved.repos.length > 0) {
509
+ // Interactive branch selection only if no branch options specified and no stored branch
510
+ // Skip if: -b, -f, -n, stored branch, or -y
511
+ if (!options.branch && !options.fromBranch && !storedBranch && !options.newBranch && !options.yes && resolved.repos.length > 0) {
490
512
  resolved = await promptForBranchOptions(resolved, config);
491
513
  }
492
514
  // Display what will be rebuilt
493
515
  console.log(chalk_1.default.bold('Rebuild Configuration:'));
494
516
  console.log(chalk_1.default.dim('───────────────────────────────────────────────'));
495
- console.log(` ${chalk_1.default.bold('Name:')} ${name}`);
517
+ console.log(` ${chalk_1.default.bold('Name:')} ${selectedName}`);
496
518
  console.log(` ${chalk_1.default.bold('Project:')} ${resolved.project.name}`);
497
519
  if (resolved.profile) {
498
520
  console.log(` ${chalk_1.default.bold('Profile:')} ${resolved.profile}`);
@@ -523,7 +545,7 @@ exports.rebuildCommand = new commander_1.Command('rebuild')
523
545
  console.log(chalk_1.default.yellow('All unsaved work on the server will be lost.'));
524
546
  console.log('');
525
547
  const confirm = await prompts.confirm({
526
- message: `Rebuild genbox '${name}'?`,
548
+ message: `Rebuild genbox '${selectedName}'?`,
527
549
  default: false,
528
550
  });
529
551
  if (!confirm) {
@@ -553,15 +575,15 @@ exports.rebuildCommand = new commander_1.Command('rebuild')
553
575
  // Build payload
554
576
  const payload = buildRebuildPayload(resolved, config, publicKey, privateKeyContent, configLoader);
555
577
  // Execute rebuild
556
- const rebuildSpinner = (0, ora_1.default)(`Rebuilding Genbox '${name}'...`).start();
578
+ const rebuildSpinner = (0, ora_1.default)(`Rebuilding Genbox '${selectedName}'...`).start();
557
579
  try {
558
580
  await rebuildGenbox(genbox._id, payload);
559
- rebuildSpinner.succeed(chalk_1.default.green(`Genbox '${name}' rebuild initiated!`));
581
+ rebuildSpinner.succeed(chalk_1.default.green(`Genbox '${selectedName}' rebuild initiated!`));
560
582
  console.log('');
561
583
  console.log(chalk_1.default.dim('Server is rebuilding. This may take a few minutes.'));
562
584
  console.log(chalk_1.default.dim('SSH connection will be temporarily unavailable.'));
563
585
  console.log('');
564
- console.log(`Run ${chalk_1.default.cyan(`genbox status ${name}`)} to check progress.`);
586
+ console.log(`Run ${chalk_1.default.cyan(`genbox status ${selectedName}`)} to check progress.`);
565
587
  }
566
588
  catch (error) {
567
589
  rebuildSpinner.fail(chalk_1.default.red(`Failed to rebuild: ${error.message}`));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "genbox",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
4
4
  "description": "Genbox CLI - AI-Powered Development Environments",
5
5
  "main": "dist/index.js",
6
6
  "bin": {