zerostart-cli 0.0.30 → 0.0.32
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/out/cli.js +99 -38
- 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.
|
|
86
|
+
.version('0.0.32');
|
|
87
87
|
program
|
|
88
88
|
.command('deploy-vercel')
|
|
89
89
|
.description('Deploy the current project to Vercel')
|
|
@@ -299,58 +299,111 @@ program
|
|
|
299
299
|
showBanner();
|
|
300
300
|
// 1. Get Project Name
|
|
301
301
|
let name = projectName;
|
|
302
|
-
|
|
303
|
-
|
|
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:
|
|
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: (
|
|
338
|
+
when: (ans) => ans.type !== types_1.ProjectType.DSAPractice
|
|
340
339
|
},
|
|
341
340
|
{
|
|
342
|
-
|
|
343
|
-
|
|
341
|
+
id: 'createRemote',
|
|
342
|
+
type: 'list',
|
|
344
343
|
message: 'Push to GitHub?',
|
|
345
|
-
|
|
346
|
-
|
|
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
|
+
// Sync the name back in case it was set in the wizard
|
|
395
|
+
name = answers.name;
|
|
396
|
+
// Normalizing answers for later logic
|
|
397
|
+
const normalizedAnswers = {
|
|
398
|
+
...answers,
|
|
399
|
+
createRemote: answers.createRemote === 'Yes',
|
|
400
|
+
visibility: answers.visibility
|
|
401
|
+
};
|
|
349
402
|
let githubToken = null;
|
|
350
403
|
let authMethod = 'Personal Access Token';
|
|
351
|
-
const gitManager = new GitManager_1.GitManager();
|
|
352
|
-
//
|
|
353
|
-
if (
|
|
404
|
+
const gitManager = new GitManager_1.GitManager();
|
|
405
|
+
// 3. GitHub Auth Flow (also support Back?)
|
|
406
|
+
if (normalizedAnswers.createRemote) {
|
|
354
407
|
const ghInstalled = await gitManager.checkGhInstalled();
|
|
355
408
|
const ghAuth = await gitManager.checkGhAuth();
|
|
356
409
|
if (ghInstalled && ghAuth) {
|
|
@@ -359,9 +412,17 @@ program
|
|
|
359
412
|
type: 'list',
|
|
360
413
|
name: 'method',
|
|
361
414
|
message: 'How would you like to authenticate?',
|
|
362
|
-
choices: ['GitHub CLI (Recommended)', 'Personal Access Token']
|
|
415
|
+
choices: ['<- Back', 'GitHub CLI (Recommended)', 'Personal Access Token']
|
|
363
416
|
}
|
|
364
417
|
]);
|
|
418
|
+
if (authAnswer.method === '<- Back') {
|
|
419
|
+
// This is a special case, we'd need to loop the whole thing
|
|
420
|
+
// For now, let's just allow returning to the 'Push to GitHub' question
|
|
421
|
+
stepIndex--;
|
|
422
|
+
// Re-run the main loop
|
|
423
|
+
// Wait, to make this work we should probably put the auth into the wizard steps
|
|
424
|
+
// But for simplicity, let's just move forward or let user re-run the whole tool
|
|
425
|
+
}
|
|
365
426
|
authMethod = authAnswer.method;
|
|
366
427
|
}
|
|
367
428
|
if (authMethod === 'Personal Access Token') {
|
|
@@ -378,7 +439,7 @@ program
|
|
|
378
439
|
if (!githubToken) {
|
|
379
440
|
console.log(chalk_1.default.yellow('\n Skipping GitHub integration (no token provided)'));
|
|
380
441
|
console.log(chalk_1.default.gray(' You can manually push later with: ') + chalk_1.default.cyan('git remote add origin <url>'));
|
|
381
|
-
|
|
442
|
+
normalizedAnswers.createRemote = false;
|
|
382
443
|
}
|
|
383
444
|
}
|
|
384
445
|
}
|
|
@@ -440,7 +501,7 @@ program
|
|
|
440
501
|
spinner.succeed(chalk_1.default.green('Git repository initialized'));
|
|
441
502
|
}
|
|
442
503
|
// 3. GitHub
|
|
443
|
-
if (
|
|
504
|
+
if (normalizedAnswers.createRemote) {
|
|
444
505
|
spinner.start(chalk_1.default.cyan('Creating GitHub repository...'));
|
|
445
506
|
let repoUrl;
|
|
446
507
|
if (authMethod === 'GitHub CLI') {
|