genbox 1.0.21 → 1.0.22
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/create.js +5 -0
- package/dist/commands/rebuild.js +56 -35
- package/package.json +1 -1
package/dist/commands/create.js
CHANGED
|
@@ -641,6 +641,11 @@ function buildPayload(resolved, config, publicKey, privateKey, configLoader) {
|
|
|
641
641
|
mode: i.mode,
|
|
642
642
|
})),
|
|
643
643
|
database: resolved.database,
|
|
644
|
+
// Configuration tracking (for rebuild)
|
|
645
|
+
profile: resolved.profile,
|
|
646
|
+
branch: resolved.repos[0]?.branch,
|
|
647
|
+
newBranch: resolved.repos[0]?.newBranch,
|
|
648
|
+
sourceBranch: resolved.repos[0]?.sourceBranch,
|
|
644
649
|
};
|
|
645
650
|
}
|
|
646
651
|
/**
|
package/dist/commands/rebuild.js
CHANGED
|
@@ -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('
|
|
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
|
-
//
|
|
433
|
-
const
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
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
|
-
|
|
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,39 @@ 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 = `${
|
|
484
|
+
newBranchName = `${selectedName}-${timestamp}`;
|
|
474
485
|
console.log(chalk_1.default.dim(` Auto-generated branch name: ${newBranchName}`));
|
|
475
486
|
}
|
|
476
|
-
//
|
|
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:
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
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
|
|
489
|
-
if (!options.branch && !options.newBranch && !options.yes && resolved.repos.length > 0) {
|
|
509
|
+
// Interactive branch selection only if no branch specified and no stored branch
|
|
510
|
+
if (!options.branch && !storedBranch && !options.newBranch && !options.yes && resolved.repos.length > 0) {
|
|
490
511
|
resolved = await promptForBranchOptions(resolved, config);
|
|
491
512
|
}
|
|
492
513
|
// Display what will be rebuilt
|
|
493
514
|
console.log(chalk_1.default.bold('Rebuild Configuration:'));
|
|
494
515
|
console.log(chalk_1.default.dim('───────────────────────────────────────────────'));
|
|
495
|
-
console.log(` ${chalk_1.default.bold('Name:')} ${
|
|
516
|
+
console.log(` ${chalk_1.default.bold('Name:')} ${selectedName}`);
|
|
496
517
|
console.log(` ${chalk_1.default.bold('Project:')} ${resolved.project.name}`);
|
|
497
518
|
if (resolved.profile) {
|
|
498
519
|
console.log(` ${chalk_1.default.bold('Profile:')} ${resolved.profile}`);
|
|
@@ -523,7 +544,7 @@ exports.rebuildCommand = new commander_1.Command('rebuild')
|
|
|
523
544
|
console.log(chalk_1.default.yellow('All unsaved work on the server will be lost.'));
|
|
524
545
|
console.log('');
|
|
525
546
|
const confirm = await prompts.confirm({
|
|
526
|
-
message: `Rebuild genbox '${
|
|
547
|
+
message: `Rebuild genbox '${selectedName}'?`,
|
|
527
548
|
default: false,
|
|
528
549
|
});
|
|
529
550
|
if (!confirm) {
|
|
@@ -553,15 +574,15 @@ exports.rebuildCommand = new commander_1.Command('rebuild')
|
|
|
553
574
|
// Build payload
|
|
554
575
|
const payload = buildRebuildPayload(resolved, config, publicKey, privateKeyContent, configLoader);
|
|
555
576
|
// Execute rebuild
|
|
556
|
-
const rebuildSpinner = (0, ora_1.default)(`Rebuilding Genbox '${
|
|
577
|
+
const rebuildSpinner = (0, ora_1.default)(`Rebuilding Genbox '${selectedName}'...`).start();
|
|
557
578
|
try {
|
|
558
579
|
await rebuildGenbox(genbox._id, payload);
|
|
559
|
-
rebuildSpinner.succeed(chalk_1.default.green(`Genbox '${
|
|
580
|
+
rebuildSpinner.succeed(chalk_1.default.green(`Genbox '${selectedName}' rebuild initiated!`));
|
|
560
581
|
console.log('');
|
|
561
582
|
console.log(chalk_1.default.dim('Server is rebuilding. This may take a few minutes.'));
|
|
562
583
|
console.log(chalk_1.default.dim('SSH connection will be temporarily unavailable.'));
|
|
563
584
|
console.log('');
|
|
564
|
-
console.log(`Run ${chalk_1.default.cyan(`genbox status ${
|
|
585
|
+
console.log(`Run ${chalk_1.default.cyan(`genbox status ${selectedName}`)} to check progress.`);
|
|
565
586
|
}
|
|
566
587
|
catch (error) {
|
|
567
588
|
rebuildSpinner.fail(chalk_1.default.red(`Failed to rebuild: ${error.message}`));
|