zerostart-cli 0.0.45 → 0.0.47
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/README.md +1 -0
- package/out/cli.js +110 -35
- package/out/services/GitHubServiceCLI.js +7 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,6 +31,7 @@ npm install -g zerostart-cli
|
|
|
31
31
|
- **🚀 One-Command Setup**: Scaffold, initialize Git, and deploy in seconds.
|
|
32
32
|
- **📦 Pre-built Templates**: React, Next.js, Express, C++, Java, Python, and more.
|
|
33
33
|
- **🐙 GitHub Integration**: Auto-create repositories and push with human-style commits.
|
|
34
|
+
- **🏆 CP Smart Practice**: Choose between an online compiler, local terminal, or both for your competitive programming practice.
|
|
34
35
|
- **🌐 Instant Deployment**: Vercel and Netlify support built-in.
|
|
35
36
|
|
|
36
37
|
---
|
package/out/cli.js
CHANGED
|
@@ -144,26 +144,31 @@ async function initializeProject(name, language, type, options) {
|
|
|
144
144
|
console.log(chalk_1.default.gray(' Location: ') + chalk_1.default.cyan(projectPath));
|
|
145
145
|
console.log();
|
|
146
146
|
// ── CP languages: open browser + interactive terminal ─────────────
|
|
147
|
-
if ([types_1.ProjectLanguage.Python, types_1.ProjectLanguage.Java, types_1.ProjectLanguage.CPP].includes(language)) {
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
147
|
+
if (type === types_1.ProjectType.DSAPractice && [types_1.ProjectLanguage.Python, types_1.ProjectLanguage.Java, types_1.ProjectLanguage.CPP].includes(language)) {
|
|
148
|
+
const cpChoice = options.cpInterface || 'both';
|
|
149
|
+
if (cpChoice === 'online' || cpChoice === 'both') {
|
|
150
|
+
const gdbLinks = {
|
|
151
|
+
[types_1.ProjectLanguage.Python]: 'https://www.onlinegdb.com/online_python_compiler',
|
|
152
|
+
[types_1.ProjectLanguage.Java]: 'https://www.onlinegdb.com/online_java_compiler',
|
|
153
|
+
[types_1.ProjectLanguage.CPP]: 'https://www.onlinegdb.com/online_c++_compiler'
|
|
154
|
+
};
|
|
155
|
+
const link = gdbLinks[language];
|
|
156
|
+
console.log(chalk_1.default.bold.yellow(' Practice Online:'));
|
|
157
|
+
console.log(chalk_1.default.gray(' - ') + chalk_1.default.cyan(link));
|
|
158
|
+
console.log(chalk_1.default.gray(' (Opening in your browser...)'));
|
|
159
|
+
openUrl(link);
|
|
160
|
+
}
|
|
161
|
+
if (cpChoice === 'terminal' || cpChoice === 'both') {
|
|
162
|
+
const terminalCmds = {
|
|
163
|
+
[types_1.ProjectLanguage.Python]: 'start cmd /k "python"',
|
|
164
|
+
[types_1.ProjectLanguage.Java]: `start cmd /k "cd /d ${projectPath} && javac src/main/java/com/example/Main.java && java -cp src/main/java com.example.Main"`,
|
|
165
|
+
[types_1.ProjectLanguage.CPP]: `start cmd /k "cd /d ${projectPath} && g++ main.cpp -o main && main"`,
|
|
166
|
+
};
|
|
167
|
+
const termCmd = terminalCmds[language];
|
|
168
|
+
if (termCmd) {
|
|
169
|
+
console.log(chalk_1.default.bold.yellow(' Opening interactive terminal...'));
|
|
170
|
+
(0, child_process_1.exec)(termCmd, { cwd: projectPath });
|
|
171
|
+
}
|
|
167
172
|
}
|
|
168
173
|
}
|
|
169
174
|
console.log(chalk_1.default.bold('\n Get started:'));
|
|
@@ -180,7 +185,7 @@ async function initializeProject(name, language, type, options) {
|
|
|
180
185
|
program
|
|
181
186
|
.name('zerostart')
|
|
182
187
|
.description('Create and deploy a complete project with one command')
|
|
183
|
-
.version('0.0.
|
|
188
|
+
.version('0.0.47');
|
|
184
189
|
// zerostart init [project-name]
|
|
185
190
|
program
|
|
186
191
|
.command('init [project-name]')
|
|
@@ -518,7 +523,7 @@ program
|
|
|
518
523
|
return;
|
|
519
524
|
}
|
|
520
525
|
const latestVersion = stdout.trim();
|
|
521
|
-
const currentVersion = '0.0.
|
|
526
|
+
const currentVersion = '0.0.47';
|
|
522
527
|
if (latestVersion === currentVersion) {
|
|
523
528
|
spinner.succeed(chalk_1.default.green('You are using the latest version!'));
|
|
524
529
|
}
|
|
@@ -593,9 +598,30 @@ const shortcuts = [
|
|
|
593
598
|
{ cmd: 'ml-cpp', lang: types_1.ProjectLanguage.CPP, type: types_1.ProjectType.MLProject },
|
|
594
599
|
];
|
|
595
600
|
shortcuts.forEach(s => {
|
|
596
|
-
program.command(s.cmd).argument('[name]', 'Project name', `my-${s.cmd}`).action(n => {
|
|
601
|
+
program.command(s.cmd).argument('[name]', 'Project name', `my-${s.cmd}`).action(async (n) => {
|
|
597
602
|
showBanner();
|
|
598
|
-
|
|
603
|
+
let cpInterface = 'both';
|
|
604
|
+
if (s.type === types_1.ProjectType.DSAPractice) {
|
|
605
|
+
const ans = await inquirer_1.default.prompt([{
|
|
606
|
+
type: 'list',
|
|
607
|
+
name: 'cpInterface',
|
|
608
|
+
message: 'Choose Practice Interface:',
|
|
609
|
+
choices: [
|
|
610
|
+
{ name: '🌐 Online Compiler (browser)', value: 'online' },
|
|
611
|
+
{ name: '💻 Local Terminal (cmd)', value: 'terminal' },
|
|
612
|
+
{ name: '🔥 Both', value: 'both' }
|
|
613
|
+
],
|
|
614
|
+
default: 'both'
|
|
615
|
+
}]);
|
|
616
|
+
cpInterface = ans.cpInterface;
|
|
617
|
+
}
|
|
618
|
+
await initializeProject(n, s.lang, s.type, {
|
|
619
|
+
isPublic: false,
|
|
620
|
+
createRemote: false,
|
|
621
|
+
githubToken: null,
|
|
622
|
+
authMethod: 'none',
|
|
623
|
+
cpInterface
|
|
624
|
+
});
|
|
599
625
|
});
|
|
600
626
|
});
|
|
601
627
|
async function startWizard(initialName) {
|
|
@@ -613,10 +639,12 @@ async function startWizard(initialName) {
|
|
|
613
639
|
let language;
|
|
614
640
|
let github = false;
|
|
615
641
|
let githubToken = null;
|
|
642
|
+
let isPublic = false;
|
|
643
|
+
let cpInterface = 'both';
|
|
616
644
|
const BACK = '< Back';
|
|
617
645
|
const CAT_WEB = '🌐 Web Development (React, TS, HTML/CSS)';
|
|
618
646
|
const CAT_CP = '🏆 Competitive Programming (C++, Java, Python)';
|
|
619
|
-
while (step > 0 && step <=
|
|
647
|
+
while (step > 0 && step <= 7) {
|
|
620
648
|
// ── STEP 1: Category ────────────────────────────────────────────────
|
|
621
649
|
if (step === 1) {
|
|
622
650
|
const ans = await inquirer_1.default.prompt([{
|
|
@@ -696,13 +724,59 @@ async function startWizard(initialName) {
|
|
|
696
724
|
}
|
|
697
725
|
}
|
|
698
726
|
else {
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
727
|
+
const ans = await inquirer_1.default.prompt([{
|
|
728
|
+
type: 'list',
|
|
729
|
+
name: 'cpInterface',
|
|
730
|
+
message: 'Choose Practice Interface:',
|
|
731
|
+
choices: [
|
|
732
|
+
{ name: '🌐 Online Compiler (browser)', value: 'online' },
|
|
733
|
+
{ name: '💻 Local Terminal (cmd)', value: 'terminal' },
|
|
734
|
+
{ name: '🔥 Both', value: 'both' },
|
|
735
|
+
new inquirer_1.default.Separator(),
|
|
736
|
+
{ name: BACK, value: 'back' }
|
|
737
|
+
],
|
|
738
|
+
default: 'both'
|
|
739
|
+
}]);
|
|
740
|
+
if (ans.cpInterface === 'back') {
|
|
741
|
+
name = undefined;
|
|
742
|
+
step--;
|
|
743
|
+
}
|
|
744
|
+
else {
|
|
745
|
+
cpInterface = ans.cpInterface;
|
|
746
|
+
github = false;
|
|
747
|
+
step = 8; // CP projects skip to execution
|
|
748
|
+
}
|
|
702
749
|
}
|
|
703
|
-
// ── STEP 5:
|
|
750
|
+
// ── STEP 5: Public or Private? ───────────────────────────────────────
|
|
704
751
|
}
|
|
705
752
|
else if (step === 5) {
|
|
753
|
+
if (github) {
|
|
754
|
+
const ans = await inquirer_1.default.prompt([{
|
|
755
|
+
type: 'list',
|
|
756
|
+
name: 'isPublic',
|
|
757
|
+
message: 'Repository visibility:',
|
|
758
|
+
choices: [
|
|
759
|
+
{ name: '🔓 Public (everyone can see)', value: true },
|
|
760
|
+
{ name: '🔒 Private (only you can see)', value: false },
|
|
761
|
+
new inquirer_1.default.Separator(),
|
|
762
|
+
{ name: BACK, value: 'back' }
|
|
763
|
+
],
|
|
764
|
+
default: false
|
|
765
|
+
}]);
|
|
766
|
+
if (ans.isPublic === 'back') {
|
|
767
|
+
step--;
|
|
768
|
+
}
|
|
769
|
+
else {
|
|
770
|
+
isPublic = ans.isPublic;
|
|
771
|
+
step++;
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
else {
|
|
775
|
+
step++;
|
|
776
|
+
}
|
|
777
|
+
// ── STEP 6: GitHub Token ────────────────────────────────────────────
|
|
778
|
+
}
|
|
779
|
+
else if (step === 6) {
|
|
706
780
|
if (github) {
|
|
707
781
|
showGitHubTokenHelp();
|
|
708
782
|
console.log(chalk_1.default.gray(' 💡 Tip: ') + chalk_1.default.white('Your token can be saved and reused for all future ZeroStart projects.'));
|
|
@@ -735,16 +809,16 @@ async function startWizard(initialName) {
|
|
|
735
809
|
}
|
|
736
810
|
else {
|
|
737
811
|
spinner.fail(chalk_1.default.red('Invalid token or no internet. Please try again.'));
|
|
738
|
-
// Stay on step
|
|
812
|
+
// Stay on step 6 to retry
|
|
739
813
|
}
|
|
740
814
|
}
|
|
741
815
|
}
|
|
742
816
|
else {
|
|
743
817
|
step++; // No GitHub — skip token step
|
|
744
818
|
}
|
|
745
|
-
// ── STEP
|
|
819
|
+
// ── STEP 7: Run locally or Deploy to Vercel? (Web Dev only) ────────
|
|
746
820
|
}
|
|
747
|
-
else if (step ===
|
|
821
|
+
else if (step === 7) {
|
|
748
822
|
const deployAns = await inquirer_1.default.prompt([{
|
|
749
823
|
type: 'list',
|
|
750
824
|
name: 'action',
|
|
@@ -768,17 +842,18 @@ async function startWizard(initialName) {
|
|
|
768
842
|
}
|
|
769
843
|
}
|
|
770
844
|
// ── Execute the project creation ─────────────────────────────────────────
|
|
771
|
-
if ((step >
|
|
845
|
+
if ((step > 7 || step === 8) && name && language) {
|
|
772
846
|
let type = types_1.ProjectType.WebApp;
|
|
773
847
|
if (language === types_1.ProjectLanguage.TypeScript)
|
|
774
848
|
type = types_1.ProjectType.CLITool;
|
|
775
849
|
if (category === CAT_CP)
|
|
776
850
|
type = types_1.ProjectType.DSAPractice;
|
|
777
851
|
const projectPath = await initializeProject(name, language, type, {
|
|
778
|
-
isPublic:
|
|
852
|
+
isPublic: isPublic,
|
|
779
853
|
createRemote: !!githubToken,
|
|
780
854
|
githubToken,
|
|
781
|
-
authMethod: 'none'
|
|
855
|
+
authMethod: 'none',
|
|
856
|
+
cpInterface: cpInterface
|
|
782
857
|
});
|
|
783
858
|
// ── Post-creation: Web Dev deploy / local run ─────────────────────
|
|
784
859
|
const deployChoice = startWizard._deployChoice;
|
|
@@ -59,7 +59,13 @@ class GitHubServiceCLI {
|
|
|
59
59
|
return `https://${this.token}@github.com/${user.login}/${config.name}.git`;
|
|
60
60
|
}
|
|
61
61
|
catch (error) {
|
|
62
|
-
|
|
62
|
+
if (error.response) {
|
|
63
|
+
console.error(`GitHub API Error (${error.status}): ${error.message}`);
|
|
64
|
+
// console.debug(`Response:`, error.response.data);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
console.error(`GitHub API Error: ${error.message}`);
|
|
68
|
+
}
|
|
63
69
|
// Don't throw, just return undefined so the process continues locally
|
|
64
70
|
return undefined;
|
|
65
71
|
}
|