zerostart-cli 0.0.42 → 0.0.43
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 +24 -3
- package/out/managers/TemplateManager.js +314 -1
- package/out/types.js +4 -0
- package/package.json +1 -1
package/out/cli.js
CHANGED
|
@@ -568,6 +568,10 @@ const shortcuts = [
|
|
|
568
568
|
{ cmd: 'dsa-java', lang: types_1.ProjectLanguage.Java, type: types_1.ProjectType.DSAPractice },
|
|
569
569
|
{ cmd: 'dsa-cpp', lang: types_1.ProjectLanguage.CPP, type: types_1.ProjectType.DSAPractice },
|
|
570
570
|
{ cmd: 'web-react', lang: types_1.ProjectLanguage.React, type: types_1.ProjectType.WebApp },
|
|
571
|
+
{ cmd: 'web-next', lang: types_1.ProjectLanguage.Nextjs, type: types_1.ProjectType.WebApp },
|
|
572
|
+
{ cmd: 'web-vue', lang: types_1.ProjectLanguage.Vue, type: types_1.ProjectType.WebApp },
|
|
573
|
+
{ cmd: 'web-svelte', lang: types_1.ProjectLanguage.Svelte, type: types_1.ProjectType.WebApp },
|
|
574
|
+
{ cmd: 'web-express', lang: types_1.ProjectLanguage.Express, type: types_1.ProjectType.WebApp },
|
|
571
575
|
{ cmd: 'web-html', lang: types_1.ProjectLanguage.HTMLCSS, type: types_1.ProjectType.WebApp },
|
|
572
576
|
{ cmd: 'web-py', lang: types_1.ProjectLanguage.Python, type: types_1.ProjectType.WebApp },
|
|
573
577
|
{ cmd: 'web-java', lang: types_1.ProjectLanguage.Java, type: types_1.ProjectType.WebApp },
|
|
@@ -618,7 +622,17 @@ async function startWizard(initialName) {
|
|
|
618
622
|
}
|
|
619
623
|
else if (step === 2) {
|
|
620
624
|
const langChoices = category === CAT_WEB
|
|
621
|
-
? [
|
|
625
|
+
? [
|
|
626
|
+
types_1.ProjectLanguage.React,
|
|
627
|
+
types_1.ProjectLanguage.Nextjs,
|
|
628
|
+
types_1.ProjectLanguage.Vue,
|
|
629
|
+
types_1.ProjectLanguage.Svelte,
|
|
630
|
+
types_1.ProjectLanguage.Express,
|
|
631
|
+
types_1.ProjectLanguage.TypeScript,
|
|
632
|
+
types_1.ProjectLanguage.HTMLCSS,
|
|
633
|
+
new inquirer_1.default.Separator(),
|
|
634
|
+
BACK
|
|
635
|
+
]
|
|
622
636
|
: [types_1.ProjectLanguage.CPP, types_1.ProjectLanguage.Java, types_1.ProjectLanguage.Python, new inquirer_1.default.Separator(), BACK];
|
|
623
637
|
const langAns = await inquirer_1.default.prompt([{
|
|
624
638
|
type: 'list',
|
|
@@ -793,11 +807,18 @@ async function startWizard(initialName) {
|
|
|
793
807
|
else if (category === CAT_WEB && deployChoice === 'local') {
|
|
794
808
|
console.log();
|
|
795
809
|
console.log(chalk_1.default.bold.cyan(' 💻 Run your project locally:'));
|
|
796
|
-
if (
|
|
810
|
+
if ([types_1.ProjectLanguage.React, types_1.ProjectLanguage.Nextjs, types_1.ProjectLanguage.Vue, types_1.ProjectLanguage.Svelte, types_1.ProjectLanguage.TypeScript].includes(language)) {
|
|
797
811
|
console.log(chalk_1.default.gray(' - ') + chalk_1.default.cyan(`cd ${name}`));
|
|
798
812
|
console.log(chalk_1.default.gray(' - ') + chalk_1.default.cyan('npm install'));
|
|
799
813
|
console.log(chalk_1.default.gray(' - ') + chalk_1.default.cyan('npm run dev'));
|
|
800
|
-
|
|
814
|
+
const port = language === types_1.ProjectLanguage.Nextjs ? '3000' : '5173';
|
|
815
|
+
console.log(chalk_1.default.gray('\n Then open: ') + chalk_1.default.cyan(`http://localhost:${port}`));
|
|
816
|
+
}
|
|
817
|
+
else if (language === types_1.ProjectLanguage.Express) {
|
|
818
|
+
console.log(chalk_1.default.gray(' - ') + chalk_1.default.cyan(`cd ${name}`));
|
|
819
|
+
console.log(chalk_1.default.gray(' - ') + chalk_1.default.cyan('npm install'));
|
|
820
|
+
console.log(chalk_1.default.gray(' - ') + chalk_1.default.cyan('npm run dev'));
|
|
821
|
+
console.log(chalk_1.default.gray('\n Server running on: ') + chalk_1.default.cyan('http://localhost:3000'));
|
|
801
822
|
}
|
|
802
823
|
else if (language === types_1.ProjectLanguage.HTMLCSS) {
|
|
803
824
|
console.log(chalk_1.default.gray(' - ') + chalk_1.default.cyan(`cd ${name}`));
|
|
@@ -63,6 +63,18 @@ class TemplateManager {
|
|
|
63
63
|
case types_1.ProjectLanguage.React:
|
|
64
64
|
await this.createReactStructure(config);
|
|
65
65
|
break;
|
|
66
|
+
case types_1.ProjectLanguage.Nextjs:
|
|
67
|
+
await this.createNextjsStructure(config);
|
|
68
|
+
break;
|
|
69
|
+
case types_1.ProjectLanguage.Vue:
|
|
70
|
+
await this.createVueStructure(config);
|
|
71
|
+
break;
|
|
72
|
+
case types_1.ProjectLanguage.Svelte:
|
|
73
|
+
await this.createSvelteStructure(config);
|
|
74
|
+
break;
|
|
75
|
+
case types_1.ProjectLanguage.Express:
|
|
76
|
+
await this.createExpressStructure(config);
|
|
77
|
+
break;
|
|
66
78
|
case types_1.ProjectLanguage.TypeScript:
|
|
67
79
|
await this.createTypeScriptStructure(config);
|
|
68
80
|
break;
|
|
@@ -181,8 +193,12 @@ npm start # or python main.py / java -jar target/app.jar
|
|
|
181
193
|
let content = '';
|
|
182
194
|
switch (config.language) {
|
|
183
195
|
case types_1.ProjectLanguage.React:
|
|
196
|
+
case types_1.ProjectLanguage.Nextjs:
|
|
197
|
+
case types_1.ProjectLanguage.Vue:
|
|
198
|
+
case types_1.ProjectLanguage.Svelte:
|
|
199
|
+
case types_1.ProjectLanguage.Express:
|
|
184
200
|
case types_1.ProjectLanguage.TypeScript:
|
|
185
|
-
content = 'node_modules/\n.env\ndist/\nbuild/';
|
|
201
|
+
content = 'node_modules/\n.env\ndist/\nbuild/\n.next/\n.svelte-kit/';
|
|
186
202
|
break;
|
|
187
203
|
case types_1.ProjectLanguage.Python:
|
|
188
204
|
content = '__pycache__/\n*.pyc\nvenv/\n.env';
|
|
@@ -400,6 +416,303 @@ console.log("${config.name} initialized!");
|
|
|
400
416
|
`;
|
|
401
417
|
fs.writeFileSync(path.join(config.path, 'netlify.toml'), netlifyContent);
|
|
402
418
|
}
|
|
419
|
+
async createNextjsStructure(config) {
|
|
420
|
+
const packageJson = {
|
|
421
|
+
name: config.name,
|
|
422
|
+
version: "0.1.0",
|
|
423
|
+
private: true,
|
|
424
|
+
scripts: {
|
|
425
|
+
dev: "next dev",
|
|
426
|
+
build: "next build",
|
|
427
|
+
start: "next start",
|
|
428
|
+
lint: "next lint"
|
|
429
|
+
},
|
|
430
|
+
dependencies: {
|
|
431
|
+
"next": "14.1.0",
|
|
432
|
+
"react": "^18",
|
|
433
|
+
"react-dom": "^18"
|
|
434
|
+
},
|
|
435
|
+
devDependencies: {
|
|
436
|
+
"typescript": "^5",
|
|
437
|
+
"@types/node": "^20",
|
|
438
|
+
"@types/react": "^18",
|
|
439
|
+
"@types/react-dom": "^18",
|
|
440
|
+
"autoprefixer": "^10.0.1",
|
|
441
|
+
"postcss": "^8",
|
|
442
|
+
"tailwindcss": "^3.3.0",
|
|
443
|
+
"eslint": "^8",
|
|
444
|
+
"eslint-config-next": "14.1.0"
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
fs.writeFileSync(path.join(config.path, 'package.json'), JSON.stringify(packageJson, null, 2));
|
|
448
|
+
const app = path.join(config.path, 'app');
|
|
449
|
+
if (!fs.existsSync(app))
|
|
450
|
+
fs.mkdirSync(app);
|
|
451
|
+
fs.writeFileSync(path.join(app, 'layout.tsx'), `
|
|
452
|
+
import type { Metadata } from "next";
|
|
453
|
+
import "./globals.css";
|
|
454
|
+
|
|
455
|
+
export const metadata: Metadata = {
|
|
456
|
+
title: "${config.name}",
|
|
457
|
+
description: "${config.description}",
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
export default function RootLayout({
|
|
461
|
+
children,
|
|
462
|
+
}: Readonly<{
|
|
463
|
+
children: React.ReactNode;
|
|
464
|
+
}>) {
|
|
465
|
+
return (
|
|
466
|
+
<html lang="en">
|
|
467
|
+
<body>{children}</body>
|
|
468
|
+
</html>
|
|
469
|
+
);
|
|
470
|
+
}
|
|
471
|
+
`);
|
|
472
|
+
fs.writeFileSync(path.join(app, 'page.tsx'), `
|
|
473
|
+
export default function Home() {
|
|
474
|
+
return (
|
|
475
|
+
<main className="flex min-h-screen flex-col items-center justify-between p-24">
|
|
476
|
+
<h1 className="text-4xl font-bold">Welcome to ${config.name} (Next.js)</h1>
|
|
477
|
+
</main>
|
|
478
|
+
);
|
|
479
|
+
}
|
|
480
|
+
`);
|
|
481
|
+
fs.writeFileSync(path.join(app, 'globals.css'), `
|
|
482
|
+
@tailwind base;
|
|
483
|
+
@tailwind components;
|
|
484
|
+
@tailwind utilities;
|
|
485
|
+
`);
|
|
486
|
+
fs.writeFileSync(path.join(config.path, 'tailwind.config.ts'), `
|
|
487
|
+
import type { Config } from "tailwindcss";
|
|
488
|
+
|
|
489
|
+
const config: Config = {
|
|
490
|
+
content: [
|
|
491
|
+
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
|
|
492
|
+
"./components/**/*.{js,ts,jsx,tsx,mdx}",
|
|
493
|
+
"./app/**/*.{js,ts,jsx,tsx,mdx}",
|
|
494
|
+
],
|
|
495
|
+
theme: {
|
|
496
|
+
extend: {},
|
|
497
|
+
},
|
|
498
|
+
plugins: [],
|
|
499
|
+
};
|
|
500
|
+
export default config;
|
|
501
|
+
`);
|
|
502
|
+
fs.writeFileSync(path.join(config.path, 'next.config.mjs'), `
|
|
503
|
+
/** @type {import('next').NextConfig} */
|
|
504
|
+
const nextConfig = {};
|
|
505
|
+
|
|
506
|
+
export default nextConfig;
|
|
507
|
+
`);
|
|
508
|
+
fs.writeFileSync(path.join(config.path, 'tsconfig.json'), `
|
|
509
|
+
{
|
|
510
|
+
"compilerOptions": {
|
|
511
|
+
"lib": ["dom", "dom.iterable", "esnext"],
|
|
512
|
+
"allowJs": true,
|
|
513
|
+
"skipLibCheck": true,
|
|
514
|
+
"strict": true,
|
|
515
|
+
"noEmit": true,
|
|
516
|
+
"esModuleInterop": true,
|
|
517
|
+
"module": "esnext",
|
|
518
|
+
"moduleResolution": "bundler",
|
|
519
|
+
"resolveJsonModule": true,
|
|
520
|
+
"isolatedModules": true,
|
|
521
|
+
"jsx": "preserve",
|
|
522
|
+
"incremental": true,
|
|
523
|
+
"plugins": [
|
|
524
|
+
{
|
|
525
|
+
"name": "next"
|
|
526
|
+
}
|
|
527
|
+
],
|
|
528
|
+
"paths": {
|
|
529
|
+
"@/*": ["./*"]
|
|
530
|
+
}
|
|
531
|
+
},
|
|
532
|
+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
|
533
|
+
"exclude": ["node_modules"]
|
|
534
|
+
}
|
|
535
|
+
`);
|
|
536
|
+
this.createNetlifyConfig(config);
|
|
537
|
+
}
|
|
538
|
+
async createVueStructure(config) {
|
|
539
|
+
const packageJson = {
|
|
540
|
+
name: config.name,
|
|
541
|
+
version: "0.0.0",
|
|
542
|
+
private: true,
|
|
543
|
+
type: "module",
|
|
544
|
+
scripts: {
|
|
545
|
+
dev: "vite",
|
|
546
|
+
build: "vue-tsc && vite build",
|
|
547
|
+
preview: "vite preview"
|
|
548
|
+
},
|
|
549
|
+
dependencies: {
|
|
550
|
+
"vue": "^3.4.15"
|
|
551
|
+
},
|
|
552
|
+
devDependencies: {
|
|
553
|
+
"@vitejs/plugin-vue": "^5.0.3",
|
|
554
|
+
"typescript": "^5.3.3",
|
|
555
|
+
"vite": "^5.0.12",
|
|
556
|
+
"vue-tsc": "^1.8.27"
|
|
557
|
+
}
|
|
558
|
+
};
|
|
559
|
+
fs.writeFileSync(path.join(config.path, 'package.json'), JSON.stringify(packageJson, null, 2));
|
|
560
|
+
const src = path.join(config.path, 'src');
|
|
561
|
+
if (!fs.existsSync(src))
|
|
562
|
+
fs.mkdirSync(src);
|
|
563
|
+
fs.writeFileSync(path.join(src, 'App.vue'), `
|
|
564
|
+
<template>
|
|
565
|
+
<div>
|
|
566
|
+
<h1>Hello Vue 3 + Vite!</h1>
|
|
567
|
+
</div>
|
|
568
|
+
</template>
|
|
569
|
+
`);
|
|
570
|
+
fs.writeFileSync(path.join(src, 'main.ts'), `
|
|
571
|
+
import { createApp } from 'vue'
|
|
572
|
+
import App from './App.vue'
|
|
573
|
+
|
|
574
|
+
createApp(App).mount('#app')
|
|
575
|
+
`);
|
|
576
|
+
fs.writeFileSync(path.join(config.path, 'index.html'), `
|
|
577
|
+
<!DOCTYPE html>
|
|
578
|
+
<html lang="en">
|
|
579
|
+
<head>
|
|
580
|
+
<meta charset="UTF-8" />
|
|
581
|
+
<title>${config.name}</title>
|
|
582
|
+
</head>
|
|
583
|
+
<body>
|
|
584
|
+
<div id="app"></div>
|
|
585
|
+
<script type="module" src="/src/main.ts"></script>
|
|
586
|
+
</body>
|
|
587
|
+
</html>
|
|
588
|
+
`);
|
|
589
|
+
fs.writeFileSync(path.join(config.path, 'vite.config.ts'), `
|
|
590
|
+
import { defineConfig } from 'vite'
|
|
591
|
+
import vue from '@vitejs/plugin-vue'
|
|
592
|
+
|
|
593
|
+
export default defineConfig({
|
|
594
|
+
plugins: [vue()],
|
|
595
|
+
})
|
|
596
|
+
`);
|
|
597
|
+
this.createNetlifyConfig(config);
|
|
598
|
+
}
|
|
599
|
+
async createSvelteStructure(config) {
|
|
600
|
+
const packageJson = {
|
|
601
|
+
name: config.name,
|
|
602
|
+
version: "0.0.1",
|
|
603
|
+
private: true,
|
|
604
|
+
type: "module",
|
|
605
|
+
scripts: {
|
|
606
|
+
dev: "vite",
|
|
607
|
+
build: "vite build",
|
|
608
|
+
preview: "vite preview",
|
|
609
|
+
check: "svelte-check --tsconfig ./tsconfig.json"
|
|
610
|
+
},
|
|
611
|
+
devDependencies: {
|
|
612
|
+
"@sveltejs/vite-plugin-svelte": "^3.0.1",
|
|
613
|
+
"@tsconfig/svelte": "^5.0.2",
|
|
614
|
+
"svelte": "^4.2.9",
|
|
615
|
+
"svelte-check": "^3.6.3",
|
|
616
|
+
"tslib": "^2.6.2",
|
|
617
|
+
"typescript": "^5.3.3",
|
|
618
|
+
"vite": "^5.0.12"
|
|
619
|
+
}
|
|
620
|
+
};
|
|
621
|
+
fs.writeFileSync(path.join(config.path, 'package.json'), JSON.stringify(packageJson, null, 2));
|
|
622
|
+
const src = path.join(config.path, 'src');
|
|
623
|
+
if (!fs.existsSync(src))
|
|
624
|
+
fs.mkdirSync(src);
|
|
625
|
+
fs.writeFileSync(path.join(src, 'App.svelte'), `
|
|
626
|
+
<script lang="ts">
|
|
627
|
+
let name = "${config.name}";
|
|
628
|
+
</script>
|
|
629
|
+
|
|
630
|
+
<main>
|
|
631
|
+
<h1>Hello {name} (Svelte)</h1>
|
|
632
|
+
</main>
|
|
633
|
+
`);
|
|
634
|
+
fs.writeFileSync(path.join(src, 'main.ts'), `
|
|
635
|
+
import './app.css'
|
|
636
|
+
import App from './App.svelte'
|
|
637
|
+
|
|
638
|
+
const app = new App({
|
|
639
|
+
target: document.getElementById('app')!,
|
|
640
|
+
})
|
|
641
|
+
|
|
642
|
+
export default app
|
|
643
|
+
`);
|
|
644
|
+
fs.writeFileSync(path.join(src, 'app.css'), `
|
|
645
|
+
:root {
|
|
646
|
+
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
|
|
647
|
+
}
|
|
648
|
+
`);
|
|
649
|
+
fs.writeFileSync(path.join(config.path, 'index.html'), `
|
|
650
|
+
<!doctype html>
|
|
651
|
+
<html lang="en">
|
|
652
|
+
<head>
|
|
653
|
+
<meta charset="UTF-8" />
|
|
654
|
+
<title>${config.name}</title>
|
|
655
|
+
</head>
|
|
656
|
+
<body>
|
|
657
|
+
<div id="app"></div>
|
|
658
|
+
<script type="module" src="/src/main.ts"></script>
|
|
659
|
+
</body>
|
|
660
|
+
</html>
|
|
661
|
+
`);
|
|
662
|
+
fs.writeFileSync(path.join(config.path, 'vite.config.ts'), `
|
|
663
|
+
import { defineConfig } from 'vite'
|
|
664
|
+
import { svelte } from '@sveltejs/vite-plugin-svelte'
|
|
665
|
+
|
|
666
|
+
export default defineConfig({
|
|
667
|
+
plugins: [svelte()],
|
|
668
|
+
})
|
|
669
|
+
`);
|
|
670
|
+
this.createNetlifyConfig(config);
|
|
671
|
+
}
|
|
672
|
+
async createExpressStructure(config) {
|
|
673
|
+
const packageJson = {
|
|
674
|
+
name: config.name,
|
|
675
|
+
version: "1.0.0",
|
|
676
|
+
description: config.description,
|
|
677
|
+
main: "src/index.js",
|
|
678
|
+
scripts: {
|
|
679
|
+
start: "node src/index.js",
|
|
680
|
+
dev: "nodemon src/index.js"
|
|
681
|
+
},
|
|
682
|
+
dependencies: {
|
|
683
|
+
"express": "^4.18.2",
|
|
684
|
+
"cors": "^2.8.5",
|
|
685
|
+
"dotenv": "^16.3.1"
|
|
686
|
+
},
|
|
687
|
+
devDependencies: {
|
|
688
|
+
"nodemon": "^3.0.2"
|
|
689
|
+
}
|
|
690
|
+
};
|
|
691
|
+
fs.writeFileSync(path.join(config.path, 'package.json'), JSON.stringify(packageJson, null, 2));
|
|
692
|
+
const src = path.join(config.path, 'src');
|
|
693
|
+
if (!fs.existsSync(src))
|
|
694
|
+
fs.mkdirSync(src);
|
|
695
|
+
fs.writeFileSync(path.join(src, 'index.js'), `
|
|
696
|
+
const express = require('express');
|
|
697
|
+
const cors = require('cors');
|
|
698
|
+
require('dotenv').config();
|
|
699
|
+
|
|
700
|
+
const app = express();
|
|
701
|
+
const PORT = process.env.PORT || 3000;
|
|
702
|
+
|
|
703
|
+
app.use(cors());
|
|
704
|
+
app.use(express.json());
|
|
705
|
+
|
|
706
|
+
app.get('/', (req, res) => {
|
|
707
|
+
res.json({ message: 'Welcome to ${config.name} API' });
|
|
708
|
+
});
|
|
709
|
+
|
|
710
|
+
app.listen(PORT, () => {
|
|
711
|
+
console.log(\`Server is running on http://localhost:\${PORT}\`);
|
|
712
|
+
});
|
|
713
|
+
`);
|
|
714
|
+
fs.writeFileSync(path.join(config.path, '.env'), "PORT=3000\n");
|
|
715
|
+
}
|
|
403
716
|
createNetlifyConfig(config) {
|
|
404
717
|
const content = `[build]
|
|
405
718
|
command = "npm run build"
|
package/out/types.js
CHANGED
|
@@ -4,6 +4,10 @@ exports.ProjectType = exports.ProjectLanguage = void 0;
|
|
|
4
4
|
var ProjectLanguage;
|
|
5
5
|
(function (ProjectLanguage) {
|
|
6
6
|
ProjectLanguage["React"] = "React";
|
|
7
|
+
ProjectLanguage["Nextjs"] = "Next.js";
|
|
8
|
+
ProjectLanguage["Vue"] = "Vue";
|
|
9
|
+
ProjectLanguage["Svelte"] = "Svelte";
|
|
10
|
+
ProjectLanguage["Express"] = "Express";
|
|
7
11
|
ProjectLanguage["TypeScript"] = "TypeScript";
|
|
8
12
|
ProjectLanguage["HTMLCSS"] = "HTML/CSS";
|
|
9
13
|
ProjectLanguage["Python"] = "Python";
|