genbox 1.0.36 → 1.0.38
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/profiles.js +17 -45
- package/dist/commands/status.js +23 -5
- package/dist/config-loader.js +2 -19
- package/package.json +1 -1
|
@@ -42,7 +42,6 @@ const prompts = __importStar(require("@inquirer/prompts"));
|
|
|
42
42
|
const chalk_1 = __importDefault(require("chalk"));
|
|
43
43
|
const yaml = __importStar(require("js-yaml"));
|
|
44
44
|
const fs = __importStar(require("fs"));
|
|
45
|
-
const path = __importStar(require("path"));
|
|
46
45
|
const config_loader_1 = require("../config-loader");
|
|
47
46
|
const schema_v4_1 = require("../schema-v4");
|
|
48
47
|
exports.profilesCommand = new commander_1.Command('profiles')
|
|
@@ -278,29 +277,15 @@ exports.profilesCommand
|
|
|
278
277
|
source: dbMode.includes('staging') ? 'staging' : dbMode.includes('production') ? 'production' : undefined,
|
|
279
278
|
} : undefined,
|
|
280
279
|
};
|
|
281
|
-
//
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
choices: [
|
|
285
|
-
{ name: 'genbox.yaml (shared with team)', value: 'project' },
|
|
286
|
-
{ name: '~/.genbox/profiles.yaml (personal)', value: 'user' },
|
|
287
|
-
],
|
|
288
|
-
});
|
|
289
|
-
if (saveLocation === 'user') {
|
|
290
|
-
configLoader.saveUserProfile(profileName, profile);
|
|
291
|
-
console.log(chalk_1.default.green(`\n✔ Profile '${profileName}' saved to ~/.genbox/profiles.yaml`));
|
|
292
|
-
}
|
|
293
|
-
else {
|
|
294
|
-
// Add to project config
|
|
295
|
-
if (!config.profiles) {
|
|
296
|
-
config.profiles = {};
|
|
297
|
-
}
|
|
298
|
-
config.profiles[profileName] = profile;
|
|
299
|
-
const configPath = configLoader.getConfigPath();
|
|
300
|
-
const yamlContent = yaml.dump(config, { lineWidth: 120, noRefs: true });
|
|
301
|
-
fs.writeFileSync(configPath, yamlContent);
|
|
302
|
-
console.log(chalk_1.default.green(`\n✔ Profile '${profileName}' added to genbox.yaml`));
|
|
280
|
+
// Save to project config (user/global profiles removed - they reference project-specific apps)
|
|
281
|
+
if (!config.profiles) {
|
|
282
|
+
config.profiles = {};
|
|
303
283
|
}
|
|
284
|
+
config.profiles[profileName] = profile;
|
|
285
|
+
const configPath = configLoader.getConfigPath();
|
|
286
|
+
const yamlContent = yaml.dump(config, { lineWidth: 120, noRefs: true });
|
|
287
|
+
fs.writeFileSync(configPath, yamlContent);
|
|
288
|
+
console.log(chalk_1.default.green(`\n✔ Profile '${profileName}' added to genbox.yaml`));
|
|
304
289
|
console.log(chalk_1.default.dim(`Use: genbox create <name> --profile ${profileName}`));
|
|
305
290
|
}
|
|
306
291
|
catch (error) {
|
|
@@ -315,8 +300,7 @@ exports.profilesCommand
|
|
|
315
300
|
exports.profilesCommand
|
|
316
301
|
.command('delete <name>')
|
|
317
302
|
.description('Delete a profile')
|
|
318
|
-
.
|
|
319
|
-
.action(async (name, options) => {
|
|
303
|
+
.action(async (name) => {
|
|
320
304
|
try {
|
|
321
305
|
const configLoader = new config_loader_1.ConfigLoader();
|
|
322
306
|
const loadResult = await configLoader.load();
|
|
@@ -331,12 +315,9 @@ exports.profilesCommand
|
|
|
331
315
|
return;
|
|
332
316
|
}
|
|
333
317
|
const config = loadResult.config;
|
|
334
|
-
// Check if profile exists
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
const inUser = userProfiles?.profiles?.[name];
|
|
338
|
-
if (!inProject && !inUser) {
|
|
339
|
-
console.log(chalk_1.default.red(`Profile '${name}' not found`));
|
|
318
|
+
// Check if profile exists in project
|
|
319
|
+
if (!config.profiles?.[name]) {
|
|
320
|
+
console.log(chalk_1.default.red(`Profile '${name}' not found in genbox.yaml`));
|
|
340
321
|
return;
|
|
341
322
|
}
|
|
342
323
|
// Confirm deletion
|
|
@@ -348,20 +329,11 @@ exports.profilesCommand
|
|
|
348
329
|
console.log(chalk_1.default.dim('Cancelled.'));
|
|
349
330
|
return;
|
|
350
331
|
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
console.log(chalk_1.default.green(`✔ Deleted '${name}' from user profiles`));
|
|
357
|
-
}
|
|
358
|
-
else if (inProject) {
|
|
359
|
-
// Delete from project config
|
|
360
|
-
delete config.profiles[name];
|
|
361
|
-
const configPath = configLoader.getConfigPath();
|
|
362
|
-
fs.writeFileSync(configPath, yaml.dump(config, { lineWidth: 120, noRefs: true }));
|
|
363
|
-
console.log(chalk_1.default.green(`✔ Deleted '${name}' from genbox.yaml`));
|
|
364
|
-
}
|
|
332
|
+
// Delete from project config
|
|
333
|
+
delete config.profiles[name];
|
|
334
|
+
const configPath = configLoader.getConfigPath();
|
|
335
|
+
fs.writeFileSync(configPath, yaml.dump(config, { lineWidth: 120, noRefs: true }));
|
|
336
|
+
console.log(chalk_1.default.green(`✔ Deleted '${name}' from genbox.yaml`));
|
|
365
337
|
}
|
|
366
338
|
catch (error) {
|
|
367
339
|
if (error.name === 'ExitPromptError') {
|
package/dist/commands/status.js
CHANGED
|
@@ -193,10 +193,14 @@ exports.statusCommand = new commander_1.Command('status')
|
|
|
193
193
|
const dbStatus = target.status; // 'provisioning' | 'running' | 'error' etc.
|
|
194
194
|
const setupDuration = target.setupDuration;
|
|
195
195
|
const setupCompletedAt = target.setupCompletedAt;
|
|
196
|
-
// If DB says RUNNING
|
|
197
|
-
if (dbStatus === 'running'
|
|
198
|
-
|
|
199
|
-
|
|
196
|
+
// If DB says RUNNING, setup is complete (use DB as source of truth)
|
|
197
|
+
if (dbStatus === 'running') {
|
|
198
|
+
if (setupCompletedAt && setupDuration) {
|
|
199
|
+
console.log(chalk_1.default.green(`[SUCCESS] Setup completed! (took ${formatDuration(setupDuration)})`));
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
console.log(chalk_1.default.green(`[SUCCESS] Genbox is running`));
|
|
203
|
+
}
|
|
200
204
|
console.log('');
|
|
201
205
|
// Show billing info
|
|
202
206
|
const billing = {
|
|
@@ -322,7 +326,21 @@ exports.statusCommand = new commander_1.Command('status')
|
|
|
322
326
|
console.log(chalk_1.default.dim(' Run `genbox connect` to investigate.'));
|
|
323
327
|
return;
|
|
324
328
|
}
|
|
325
|
-
//
|
|
329
|
+
// If DB says TERMINATED
|
|
330
|
+
if (dbStatus === 'terminated') {
|
|
331
|
+
const destroyReason = target.destroyReason;
|
|
332
|
+
console.log(chalk_1.default.red(`[TERMINATED] Genbox has been destroyed`));
|
|
333
|
+
if (destroyReason) {
|
|
334
|
+
console.log(chalk_1.default.dim(` Reason: ${destroyReason}`));
|
|
335
|
+
}
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
// If DB says STOPPED
|
|
339
|
+
if (dbStatus === 'stopped') {
|
|
340
|
+
console.log(chalk_1.default.yellow('[STOPPED] Genbox is stopped'));
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
// Fallback: try legacy cloud-init check for backwards compatibility (should rarely reach here)
|
|
326
344
|
let status = sshExec(target.ipAddress, keyPath, 'cloud-init status 2>&1');
|
|
327
345
|
if (!status || status.includes('not found')) {
|
|
328
346
|
// No cloud-init, check our status file
|
package/dist/config-loader.js
CHANGED
|
@@ -467,7 +467,8 @@ class ConfigLoader {
|
|
|
467
467
|
*/
|
|
468
468
|
listProfiles(config) {
|
|
469
469
|
const profiles = [];
|
|
470
|
-
// Project profiles
|
|
470
|
+
// Project profiles only (user/global profiles removed - they don't make sense
|
|
471
|
+
// because profiles reference project-specific app names)
|
|
471
472
|
for (const [name, profile] of Object.entries(config.profiles || {})) {
|
|
472
473
|
const resolved = this.getProfile(config, name);
|
|
473
474
|
profiles.push({
|
|
@@ -479,24 +480,6 @@ class ConfigLoader {
|
|
|
479
480
|
connection: resolved ? getProfileConnection(resolved) : undefined,
|
|
480
481
|
});
|
|
481
482
|
}
|
|
482
|
-
// User profiles
|
|
483
|
-
const userProfiles = this.loadUserProfiles();
|
|
484
|
-
if (userProfiles) {
|
|
485
|
-
for (const [name, profile] of Object.entries(userProfiles.profiles || {})) {
|
|
486
|
-
// Skip if already defined in project
|
|
487
|
-
if (config.profiles?.[name])
|
|
488
|
-
continue;
|
|
489
|
-
const resolved = this.getProfile(config, name);
|
|
490
|
-
profiles.push({
|
|
491
|
-
name,
|
|
492
|
-
description: profile.description,
|
|
493
|
-
source: 'user',
|
|
494
|
-
apps: resolved?.apps || [],
|
|
495
|
-
size: resolved?.size,
|
|
496
|
-
connection: resolved ? getProfileConnection(resolved) : undefined,
|
|
497
|
-
});
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
483
|
return profiles;
|
|
501
484
|
}
|
|
502
485
|
/**
|