aks-template-gen 1.0.0
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 +63 -0
- package/bin/index.js +26 -0
- package/package.json +29 -0
- package/src/commands/create.js +97 -0
- package/templates/express/package.json +17 -0
- package/templates/next/package.json +18 -0
- package/templates/node/package.json +16 -0
- package/templates/react/package.json +18 -0
package/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# š¦ aks-template-gen
|
|
2
|
+
|
|
3
|
+
A powerful interactive CLI tool to generate full-stack project templates in seconds.
|
|
4
|
+
Built with **Commander.js** & **Inquirer.js**, supporting multiple frameworks and optional features like **TypeScript, Docker, and Prisma**.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## ⨠Features
|
|
9
|
+
|
|
10
|
+
- š Create new projects instantly
|
|
11
|
+
- š§© Interactive prompts for:
|
|
12
|
+
- Project name
|
|
13
|
+
- Framework selection
|
|
14
|
+
- Feature selection
|
|
15
|
+
- š¦ Supports React, Next.js, Vue, and Svelte
|
|
16
|
+
- š§ Optional features:
|
|
17
|
+
- TypeScript
|
|
18
|
+
- Tailwind CSS
|
|
19
|
+
- Docker
|
|
20
|
+
- Prisma ORM
|
|
21
|
+
- š Template-based project generation
|
|
22
|
+
- š Auto-generates `cli.config.json`
|
|
23
|
+
- ā Skip installation using `--no-install`
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## š„ Installation
|
|
28
|
+
|
|
29
|
+
Install globally:
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
npm install -g aks-template-gen
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## š Usage
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
aks-template-gen
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## š Auto-generates `cli.config.json`
|
|
44
|
+
|
|
45
|
+
```json
|
|
46
|
+
{
|
|
47
|
+
"projectName": "my-app",
|
|
48
|
+
"framework": "React",
|
|
49
|
+
"features": [
|
|
50
|
+
"TypeScript"
|
|
51
|
+
],
|
|
52
|
+
"installDeps": true,
|
|
53
|
+
"template": "react"
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## š¦ Template-based project generation
|
|
60
|
+
|
|
61
|
+
```sh
|
|
62
|
+
aks-template-gen --template react
|
|
63
|
+
```
|
package/bin/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { Command } = require("commander");
|
|
4
|
+
const program = new Command();
|
|
5
|
+
|
|
6
|
+
// version
|
|
7
|
+
program
|
|
8
|
+
.version("1.0.0")
|
|
9
|
+
.name("aks-template-gen")
|
|
10
|
+
.description("A template generator for common projects");
|
|
11
|
+
|
|
12
|
+
// load commands
|
|
13
|
+
program
|
|
14
|
+
.command("create [projectName]")
|
|
15
|
+
.description("Create a new project")
|
|
16
|
+
.option("--template [name]", "Template folder to use")
|
|
17
|
+
.option("-t, --typescript", "Use TypeScript")
|
|
18
|
+
.option("-d, --docker", "Include Docker support")
|
|
19
|
+
.option("-p, --prisma", "Add Prisma ORM")
|
|
20
|
+
.option("--no-install", "Skip package installation")
|
|
21
|
+
.action((projectName, options) => {
|
|
22
|
+
const create = require("../src/commands/create");
|
|
23
|
+
create(projectName, options);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
program.parse(process.argv);
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "aks-template-gen",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A template generator for common projects",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"type": "commonjs",
|
|
7
|
+
"bin": {
|
|
8
|
+
"aks-template-gen": "bin/index.js"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"template",
|
|
12
|
+
"generator",
|
|
13
|
+
"cli",
|
|
14
|
+
"project"
|
|
15
|
+
],
|
|
16
|
+
"author": "Abhishek Singh",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "https://github.com/DEV-AK-Singh/aks-template-gen.git"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"commander": "^14.0.2",
|
|
27
|
+
"inquirer": "^12.11.1"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// src/commands/create.js
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const inquirer = require("inquirer");
|
|
5
|
+
|
|
6
|
+
// copyFiles
|
|
7
|
+
function copyFiles(srcDir, destDir) {
|
|
8
|
+
const files = fs.readdirSync(srcDir);
|
|
9
|
+
files.forEach(file => {
|
|
10
|
+
const srcFile = path.join(srcDir, file);
|
|
11
|
+
const destFile = path.join(destDir, file);
|
|
12
|
+
if (fs.statSync(srcFile).isDirectory()) {
|
|
13
|
+
fs.mkdirSync(destFile);
|
|
14
|
+
copyFiles(srcFile, destFile);
|
|
15
|
+
} else {
|
|
16
|
+
fs.copyFileSync(srcFile, destFile);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async function create(projectName, opts) {
|
|
22
|
+
try {
|
|
23
|
+
const prompt = inquirer.createPromptModule();
|
|
24
|
+
|
|
25
|
+
if(!projectName) {
|
|
26
|
+
const answers = await prompt([
|
|
27
|
+
{
|
|
28
|
+
type: "input",
|
|
29
|
+
name: "projectName",
|
|
30
|
+
message: "Project name:",
|
|
31
|
+
},
|
|
32
|
+
]);
|
|
33
|
+
projectName = answers.projectName;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if(!opts.template) {
|
|
37
|
+
const answers = await prompt([
|
|
38
|
+
{
|
|
39
|
+
type: "select",
|
|
40
|
+
name: "template",
|
|
41
|
+
message: "Template name:",
|
|
42
|
+
choices: ["node", "express", "react", "next"],
|
|
43
|
+
},
|
|
44
|
+
]);
|
|
45
|
+
opts.template = answers.template;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const selectedFeatures = [];
|
|
49
|
+
if(opts.typescript) selectedFeatures.push("TypeScript");
|
|
50
|
+
if(opts.docker) selectedFeatures.push("Docker");
|
|
51
|
+
if(opts.prisma) selectedFeatures.push("Prisma");
|
|
52
|
+
|
|
53
|
+
const projectConfig = {
|
|
54
|
+
name: projectName,
|
|
55
|
+
template: opts.template,
|
|
56
|
+
installDeps: opts.install,
|
|
57
|
+
features: selectedFeatures,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
console.log("\nā
Project config:");
|
|
61
|
+
console.log(projectConfig);
|
|
62
|
+
|
|
63
|
+
const templatePath = path.join(__dirname, "../../templates", projectConfig.template);
|
|
64
|
+
const projectPath = path.join(process.cwd(), projectName);
|
|
65
|
+
|
|
66
|
+
if(fs.existsSync(projectPath)) {
|
|
67
|
+
console.log("\nā Project already exists in this folder.");
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
fs.mkdirSync(projectPath);
|
|
72
|
+
|
|
73
|
+
copyFiles(templatePath, projectPath);
|
|
74
|
+
console.log("\nā
Project created successfully in", projectPath);
|
|
75
|
+
|
|
76
|
+
} catch (err) {
|
|
77
|
+
console.error("\nā Failed to create project:");
|
|
78
|
+
console.error(err && err.stack ? err.stack : err);
|
|
79
|
+
process.exitCode = 1;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
module.exports = create;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Quick test harness:
|
|
87
|
+
* Run: node src/commands/create.js
|
|
88
|
+
* This allows testing the script directly (useful while developing).
|
|
89
|
+
* When used by commander, commander will call the exported function instead.
|
|
90
|
+
*/
|
|
91
|
+
if (require.main === module) {
|
|
92
|
+
// Example: run interactive test if executed directly
|
|
93
|
+
(async () => {
|
|
94
|
+
console.log("Running create.js directly for testing...");
|
|
95
|
+
await create(undefined, {}); // interactive run
|
|
96
|
+
})();
|
|
97
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name":"express",
|
|
3
|
+
"version":"1.0.0",
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"express": "^4.18.2"
|
|
6
|
+
},
|
|
7
|
+
"devDependencies": {
|
|
8
|
+
"@babel/runtime": "7.13.8",
|
|
9
|
+
"typescript": "4.1.3"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"start": "node server.js",
|
|
13
|
+
"build": "echo 'No build script defined'",
|
|
14
|
+
"test": "echo 'No test script defined'",
|
|
15
|
+
"eject": "echo 'No eject script defined'"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name":"next",
|
|
3
|
+
"dependencies": {
|
|
4
|
+
"react": "^18.2.0",
|
|
5
|
+
"react-dom": "^18.2.0",
|
|
6
|
+
"react-scripts": "5.0.1"
|
|
7
|
+
},
|
|
8
|
+
"devDependencies": {
|
|
9
|
+
"@babel/runtime": "7.13.8",
|
|
10
|
+
"typescript": "4.1.3"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"start": "react-scripts start",
|
|
14
|
+
"build": "react-scripts build",
|
|
15
|
+
"test": "react-scripts test --env=jsdom",
|
|
16
|
+
"eject": "react-scripts eject"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name":"node",
|
|
3
|
+
"dependencies": {
|
|
4
|
+
"express": "^4.18.2"
|
|
5
|
+
},
|
|
6
|
+
"devDependencies": {
|
|
7
|
+
"@babel/runtime": "7.13.8",
|
|
8
|
+
"typescript": "4.1.3"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"start": "node server.js",
|
|
12
|
+
"build": "echo 'No build script defined'",
|
|
13
|
+
"test": "echo 'No test script defined'",
|
|
14
|
+
"eject": "echo 'No eject script defined'"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name":"react",
|
|
3
|
+
"dependencies": {
|
|
4
|
+
"react": "^18.2.0",
|
|
5
|
+
"react-dom": "^18.2.0",
|
|
6
|
+
"react-scripts": "5.0.1"
|
|
7
|
+
},
|
|
8
|
+
"devDependencies": {
|
|
9
|
+
"@babel/runtime": "7.13.8",
|
|
10
|
+
"typescript": "4.1.3"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"start": "react-scripts start",
|
|
14
|
+
"build": "react-scripts build",
|
|
15
|
+
"test": "react-scripts test --env=jsdom",
|
|
16
|
+
"eject": "react-scripts eject"
|
|
17
|
+
}
|
|
18
|
+
}
|