genbox 1.0.203 → 1.0.205

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.
@@ -211,7 +211,7 @@ _genbox_completions() {
211
211
  # Subcommands for grouped commands
212
212
  local db_commands="sync restore snapshots"
213
213
  local config_commands="show diff"
214
- local template_commands="build list status delete"
214
+ local template_commands="build list ls status delete"
215
215
  local profiles_commands="list"
216
216
  local backups_commands="list restore delete"
217
217
 
@@ -557,7 +557,7 @@ complete -c genbox -c gb -n "__fish_seen_subcommand_from config" -a "diff" -d "C
557
557
 
558
558
  # Subcommands for template
559
559
  complete -c genbox -c gb -n "__fish_seen_subcommand_from template" -a "build" -d "Build template"
560
- complete -c genbox -c gb -n "__fish_seen_subcommand_from template" -a "list" -d "List templates"
560
+ complete -c genbox -c gb -n "__fish_seen_subcommand_from template" -a "list ls" -d "List templates"
561
561
  complete -c genbox -c gb -n "__fish_seen_subcommand_from template" -a "status" -d "Check status"
562
562
  complete -c genbox -c gb -n "__fish_seen_subcommand_from template" -a "delete" -d "Delete template"
563
563
 
@@ -232,51 +232,6 @@ async function provisionGenbox(payload) {
232
232
  body: JSON.stringify(payload),
233
233
  });
234
234
  }
235
- /**
236
- * Prompt user for environment name
237
- */
238
- async function promptForName(skipPrompts) {
239
- if (skipPrompts) {
240
- return (0, random_name_1.generateRandomName)();
241
- }
242
- const suggestions = (0, random_name_1.generateNameSuggestions)(3);
243
- const nameChoice = await prompts.select({
244
- message: 'Environment name:',
245
- choices: [
246
- {
247
- name: `${suggestions[0]} (random)`,
248
- value: suggestions[0],
249
- },
250
- {
251
- name: `${suggestions[1]} (random)`,
252
- value: suggestions[1],
253
- },
254
- {
255
- name: `${suggestions[2]} (random)`,
256
- value: suggestions[2],
257
- },
258
- {
259
- name: 'Enter custom name...',
260
- value: '__custom__',
261
- },
262
- ],
263
- });
264
- if (nameChoice === '__custom__') {
265
- const customName = await prompts.input({
266
- message: 'Enter environment name:',
267
- validate: (value) => {
268
- if (!value.trim())
269
- return 'Name is required';
270
- if (!/^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$/.test(value.trim())) {
271
- return 'Name must be lowercase, start/end with letter or number, and contain only letters, numbers, and hyphens';
272
- }
273
- return true;
274
- },
275
- });
276
- return customName.trim();
277
- }
278
- return nameChoice;
279
- }
280
235
  /**
281
236
  * Prompt user to select a profile
282
237
  */
@@ -338,7 +293,12 @@ async function createLocalGenboxFullReplica(nameArg, options, config, configLoad
338
293
  // Interactive name prompt if not provided
339
294
  let name = nameArg;
340
295
  if (!name && !options.yes) {
341
- name = await promptForName(false);
296
+ const promptedName = await (0, genbox_wizard_1.promptForName)();
297
+ if (!promptedName) {
298
+ console.log(chalk_1.default.dim('Cancelled.'));
299
+ return;
300
+ }
301
+ name = promptedName;
342
302
  }
343
303
  else if (!name && options.yes) {
344
304
  name = (0, random_name_1.generateRandomName)();
@@ -491,7 +451,12 @@ async function createLocalGenboxSimple(nameArg, options) {
491
451
  console.log('');
492
452
  console.log(chalk_1.default.blue('=== Create Local Native Session ==='));
493
453
  console.log('');
494
- name = await promptForName(false);
454
+ const promptedName = await (0, genbox_wizard_1.promptForName)();
455
+ if (!promptedName) {
456
+ console.log(chalk_1.default.dim('Cancelled.'));
457
+ return;
458
+ }
459
+ name = promptedName;
495
460
  }
496
461
  else if (!name && options.yes) {
497
462
  // Auto-generate name in non-interactive mode
@@ -611,6 +576,12 @@ exports.createCommand = new commander_1.Command('create')
611
576
  await createLocalGenbox(nameArg, options);
612
577
  return;
613
578
  }
579
+ // Ensure user has a username (required for proper URL routing)
580
+ const usernameResult = await (0, genbox_wizard_1.ensureUsername)();
581
+ if (!usernameResult) {
582
+ console.log(chalk_1.default.dim('\nCancelled. Set a username first with: gb username set <name>'));
583
+ return;
584
+ }
614
585
  // Show config warnings (if any)
615
586
  (0, config_warnings_1.showConfigWarnings)();
616
587
  // Handle restore mode
@@ -634,8 +605,8 @@ exports.createCommand = new commander_1.Command('create')
634
605
  // Support both v3 and v4 configs
635
606
  const config = loadResult.config;
636
607
  const profileResolver = new profile_resolver_1.ProfileResolver(configLoader);
637
- // Get workspace early for backup resolution
638
- const workspace = config.project?.name || 'default';
608
+ // Use username as workspace for URL routing (project name is still used for grouping/backup)
609
+ const workspace = usernameResult.username;
639
610
  // Handle --restore option: fetch backup info by genbox name
640
611
  if (options.restore) {
641
612
  // Require genbox name for restore
@@ -697,7 +668,12 @@ exports.createCommand = new commander_1.Command('create')
697
668
  // Interactive name prompt if not provided
698
669
  let name = nameArg;
699
670
  if (!name && !options.yes) {
700
- name = await promptForName(false);
671
+ const promptedName = await (0, genbox_wizard_1.promptForName)();
672
+ if (!promptedName) {
673
+ console.log(chalk_1.default.dim('Cancelled.'));
674
+ return;
675
+ }
676
+ name = promptedName;
701
677
  }
702
678
  else if (!name && options.yes) {
703
679
  // Auto-generate name in non-interactive mode
@@ -709,29 +685,11 @@ exports.createCommand = new commander_1.Command('create')
709
685
  if (!selectedProfile && !options.yes && config.profiles && Object.keys(config.profiles).length > 0) {
710
686
  selectedProfile = await promptForProfile(config.profiles);
711
687
  }
712
- // Check if name is available in workspace, add suffix if taken
713
- try {
714
- let { available } = await (0, api_1.checkNameAvailability)(name, workspace);
715
- if (!available) {
716
- // Add random suffix and retry
717
- const originalName = name;
718
- const suffix = Math.random().toString(36).substring(2, 6);
719
- name = `${originalName}-${suffix}`;
720
- // Verify the new name is available
721
- const recheck = await (0, api_1.checkNameAvailability)(name, workspace);
722
- if (!recheck.available) {
723
- // Extremely unlikely, but fall back to timestamp
724
- name = `${originalName}-${Date.now().toString(36)}`;
725
- }
726
- console.log(chalk_1.default.yellow(` Name '${originalName}' is already in use, using '${name}' instead`));
727
- }
728
- }
729
- catch (error) {
730
- // If check fails (e.g., not logged in), continue - API will catch it on create
731
- if (error instanceof api_1.AuthenticationError) {
732
- throw error;
733
- }
734
- // Silently continue for other errors - the create API will validate
688
+ // Check if name is available in workspace, add incremental suffix if taken
689
+ const uniqueResult = await (0, genbox_wizard_1.ensureUniqueName)(name, workspace);
690
+ if (uniqueResult.wasModified) {
691
+ console.log(chalk_1.default.yellow(` Name '${name}' is already in use, using '${uniqueResult.name}' instead`));
692
+ name = uniqueResult.name;
735
693
  }
736
694
  // Determine branch configuration
737
695
  // Default: create new branch from configured default (or 'main') with name = environment name