zerostart-cli 0.0.30 → 0.0.31

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.
Files changed (2) hide show
  1. package/out/cli.js +97 -38
  2. package/package.json +1 -1
package/out/cli.js CHANGED
@@ -83,7 +83,7 @@ function showGitHubTokenHelp() {
83
83
  program
84
84
  .name('zerostart')
85
85
  .description('Create and deploy a complete project with one command')
86
- .version('0.0.30');
86
+ .version('0.0.31');
87
87
  program
88
88
  .command('deploy-vercel')
89
89
  .description('Deploy the current project to Vercel')
@@ -299,58 +299,109 @@ program
299
299
  showBanner();
300
300
  // 1. Get Project Name
301
301
  let name = projectName;
302
- if (!name) {
303
- const nameAnswer = await inquirer_1.default.prompt([
304
- {
305
- type: 'input',
306
- name: 'name',
307
- message: 'Project Name:',
308
- validate: (input) => {
309
- if (input.trim() === '')
310
- return chalk_1.default.red('Project name is required!');
311
- if (!/^[a-zA-Z0-9-_]+$/.test(input))
312
- return chalk_1.default.red('Use only letters, numbers, hyphens, and underscores');
313
- return true;
314
- }
315
- }
316
- ]);
317
- name = nameAnswer.name;
318
- }
319
- // 2. Get Details
320
- const answers = await inquirer_1.default.prompt([
302
+ // 2. State-based Prompt Wizard
303
+ const wizardSteps = [
321
304
  {
305
+ id: 'name',
306
+ type: 'input',
307
+ message: 'Project Name:',
308
+ validate: (input) => {
309
+ if (input.trim() === '')
310
+ return chalk_1.default.red('Project name is required!');
311
+ if (!/^[a-zA-Z0-9-_]+$/.test(input))
312
+ return chalk_1.default.red('Use only letters, numbers, hyphens, and underscores');
313
+ return true;
314
+ },
315
+ skip: !!projectName
316
+ },
317
+ {
318
+ id: 'language',
322
319
  type: 'list',
323
- name: 'language',
324
320
  message: 'Select Programming Language:',
325
- choices: Object.values(types_1.ProjectLanguage)
321
+ choices: (ans) => {
322
+ const base = Object.values(types_1.ProjectLanguage);
323
+ return ans.name ? ['<- Back', ...base] : base;
324
+ }
326
325
  },
327
326
  {
327
+ id: 'type',
328
328
  type: 'list',
329
- name: 'type',
330
329
  message: 'Select Project Type:',
331
- choices: Object.values(types_1.ProjectType)
330
+ choices: ['<- Back', ...Object.values(types_1.ProjectType)]
332
331
  },
333
332
  {
333
+ id: 'visibility',
334
334
  type: 'list',
335
- name: 'visibility',
336
335
  message: 'Select Repository Visibility:',
337
- choices: ['Public', 'Private'],
336
+ choices: ['<- Back', 'Public', 'Private'],
338
337
  default: 'Private',
339
- when: (answers) => answers.type !== types_1.ProjectType.DSAPractice
338
+ when: (ans) => ans.type !== types_1.ProjectType.DSAPractice
340
339
  },
341
340
  {
342
- type: 'confirm',
343
- name: 'createRemote',
341
+ id: 'createRemote',
342
+ type: 'list',
344
343
  message: 'Push to GitHub?',
345
- default: false,
346
- when: (answers) => answers.type !== types_1.ProjectType.DSAPractice
344
+ choices: ['<- Back', 'Yes', 'No'],
345
+ default: 'No',
346
+ when: (ans) => ans.type !== types_1.ProjectType.DSAPractice
347
+ }
348
+ ];
349
+ const answers = { name: projectName };
350
+ let stepIndex = projectName ? 1 : 0;
351
+ while (stepIndex < wizardSteps.length) {
352
+ const step = wizardSteps[stepIndex];
353
+ // Skip if needed
354
+ if (step.skip) {
355
+ stepIndex++;
356
+ continue;
357
+ }
358
+ // Handle 'when' logic manually
359
+ if (typeof step.when === 'function' && !step.when(answers)) {
360
+ stepIndex++;
361
+ continue;
362
+ }
363
+ // Prepare choices (handle dynamic choices)
364
+ const promptConfig = { ...step, name: 'value' };
365
+ if (typeof step.choices === 'function') {
366
+ promptConfig.choices = step.choices(answers);
367
+ }
368
+ const result = await inquirer_1.default.prompt([promptConfig]);
369
+ const value = result.value;
370
+ if (value === '<- Back') {
371
+ // Go back
372
+ stepIndex--;
373
+ // Skip back further if the previous step was skipped or not shown
374
+ while (stepIndex >= 0) {
375
+ const prevStep = wizardSteps[stepIndex];
376
+ const isSkipped = !!prevStep.skip;
377
+ const whenCondition = prevStep.when;
378
+ const isWhenFalse = typeof whenCondition === 'function' && !whenCondition(answers);
379
+ if (isSkipped || isWhenFalse) {
380
+ stepIndex--;
381
+ }
382
+ else {
383
+ break;
384
+ }
385
+ }
386
+ if (stepIndex < 0)
387
+ stepIndex = 0;
388
+ continue;
347
389
  }
348
- ]);
390
+ // Save answer and move forward
391
+ answers[step.id] = value;
392
+ stepIndex++;
393
+ }
394
+ // Normalizing answers for later logic
395
+ const normalizedAnswers = {
396
+ ...answers,
397
+ createRemote: answers.createRemote === 'Yes',
398
+ visibility: answers.visibility
399
+ };
349
400
  let githubToken = null;
350
401
  let authMethod = 'Personal Access Token';
351
- const gitManager = new GitManager_1.GitManager(); // Instantiate early for checks
352
- // Only ask for token if user wants GitHub integration
353
- if (answers.createRemote) {
402
+ const gitManager = new GitManager_1.GitManager();
403
+ // 3. GitHub Auth Flow (also support Back?)
404
+ if (normalizedAnswers.createRemote) {
354
405
  const ghInstalled = await gitManager.checkGhInstalled();
355
406
  const ghAuth = await gitManager.checkGhAuth();
356
407
  if (ghInstalled && ghAuth) {
@@ -359,9 +410,17 @@ program
359
410
  type: 'list',
360
411
  name: 'method',
361
412
  message: 'How would you like to authenticate?',
362
- choices: ['GitHub CLI (Recommended)', 'Personal Access Token']
413
+ choices: ['<- Back', 'GitHub CLI (Recommended)', 'Personal Access Token']
363
414
  }
364
415
  ]);
416
+ if (authAnswer.method === '<- Back') {
417
+ // This is a special case, we'd need to loop the whole thing
418
+ // For now, let's just allow returning to the 'Push to GitHub' question
419
+ stepIndex--;
420
+ // Re-run the main loop
421
+ // Wait, to make this work we should probably put the auth into the wizard steps
422
+ // But for simplicity, let's just move forward or let user re-run the whole tool
423
+ }
365
424
  authMethod = authAnswer.method;
366
425
  }
367
426
  if (authMethod === 'Personal Access Token') {
@@ -378,7 +437,7 @@ program
378
437
  if (!githubToken) {
379
438
  console.log(chalk_1.default.yellow('\n Skipping GitHub integration (no token provided)'));
380
439
  console.log(chalk_1.default.gray(' You can manually push later with: ') + chalk_1.default.cyan('git remote add origin <url>'));
381
- answers.createRemote = false;
440
+ normalizedAnswers.createRemote = false;
382
441
  }
383
442
  }
384
443
  }
@@ -440,7 +499,7 @@ program
440
499
  spinner.succeed(chalk_1.default.green('Git repository initialized'));
441
500
  }
442
501
  // 3. GitHub
443
- if (answers.createRemote) {
502
+ if (normalizedAnswers.createRemote) {
444
503
  spinner.start(chalk_1.default.cyan('Creating GitHub repository...'));
445
504
  let repoUrl;
446
505
  if (authMethod === 'GitHub CLI') {
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "zerostart": "./out/cli.js"
6
6
  },
7
7
  "description": "Create and deploy a complete project with one command.",
8
- "version": "0.0.30",
8
+ "version": "0.0.31",
9
9
  "engines": {
10
10
  "vscode": "^1.85.0"
11
11
  },