create-devarchitect 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/index.js +283 -0
- package/package.json +39 -0
package/index.js
ADDED
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import inquirer from "inquirer";
|
|
4
|
+
import fs from "fs";
|
|
5
|
+
import { execSync } from "child_process";
|
|
6
|
+
import chalk from "chalk";
|
|
7
|
+
import ora from "ora";
|
|
8
|
+
|
|
9
|
+
// Banner
|
|
10
|
+
console.log(
|
|
11
|
+
chalk.cyan(`
|
|
12
|
+
🚀 Welcome To DevArchitect
|
|
13
|
+
Build Full Stack Apps Instantly
|
|
14
|
+
`)
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
// Questions
|
|
18
|
+
const answers = await inquirer.prompt([
|
|
19
|
+
{
|
|
20
|
+
type: "input",
|
|
21
|
+
name: "projectName",
|
|
22
|
+
message: "Enter project name:"
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
{
|
|
26
|
+
type: "select",
|
|
27
|
+
name: "projectType",
|
|
28
|
+
message: "Select project type:",
|
|
29
|
+
|
|
30
|
+
choices: [
|
|
31
|
+
{
|
|
32
|
+
name: "Frontend",
|
|
33
|
+
value: "frontend"
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
{
|
|
37
|
+
name: "Backend",
|
|
38
|
+
value: "backend"
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
{
|
|
42
|
+
name: "Full Stack",
|
|
43
|
+
value: "fullstack"
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
{
|
|
49
|
+
type: "confirm",
|
|
50
|
+
name: "useTailwind",
|
|
51
|
+
message: "Do you want Tailwind CSS?",
|
|
52
|
+
default: true,
|
|
53
|
+
|
|
54
|
+
when: (answers) =>
|
|
55
|
+
answers.projectType === "frontend" ||
|
|
56
|
+
answers.projectType === "fullstack"
|
|
57
|
+
}
|
|
58
|
+
]);
|
|
59
|
+
|
|
60
|
+
// Create Main Project Folder
|
|
61
|
+
if (!fs.existsSync(answers.projectName)) {
|
|
62
|
+
|
|
63
|
+
fs.mkdirSync(answers.projectName);
|
|
64
|
+
|
|
65
|
+
console.log(
|
|
66
|
+
chalk.green("✅ Project folder created")
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
} else {
|
|
70
|
+
|
|
71
|
+
console.log(
|
|
72
|
+
chalk.red("❌ Folder already exists")
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
process.exit();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// ================= FRONTEND =================
|
|
79
|
+
|
|
80
|
+
function createFrontend(projectName) {
|
|
81
|
+
|
|
82
|
+
const frontendSpinner = ora(
|
|
83
|
+
"Creating Frontend..."
|
|
84
|
+
).start();
|
|
85
|
+
|
|
86
|
+
// Create React App
|
|
87
|
+
execSync(
|
|
88
|
+
`cd ${projectName} && npm create vite@latest frontend -- --template react`,
|
|
89
|
+
{
|
|
90
|
+
stdio: "inherit",
|
|
91
|
+
shell: true
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
// Install Dependencies
|
|
96
|
+
execSync(
|
|
97
|
+
`cd ${projectName}/frontend && npm install`,
|
|
98
|
+
{
|
|
99
|
+
stdio: "inherit",
|
|
100
|
+
shell: true
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
// Create Folder Structure
|
|
105
|
+
fs.mkdirSync(`${projectName}/frontend/src/components`);
|
|
106
|
+
fs.mkdirSync(`${projectName}/frontend/src/pages`);
|
|
107
|
+
fs.mkdirSync(`${projectName}/frontend/src/hooks`);
|
|
108
|
+
fs.mkdirSync(`${projectName}/frontend/src/services`);
|
|
109
|
+
fs.mkdirSync(`${projectName}/frontend/src/assets`);
|
|
110
|
+
|
|
111
|
+
// Install React Router + Axios
|
|
112
|
+
execSync(
|
|
113
|
+
`cd ${projectName}/frontend && npm install react-router-dom axios`,
|
|
114
|
+
{
|
|
115
|
+
stdio: "inherit",
|
|
116
|
+
shell: true
|
|
117
|
+
}
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
// Tailwind Setup
|
|
121
|
+
if (answers.useTailwind) {
|
|
122
|
+
|
|
123
|
+
execSync(
|
|
124
|
+
`cd ${projectName}/frontend && npm install -D tailwindcss postcss autoprefixer`,
|
|
125
|
+
{
|
|
126
|
+
stdio: "inherit",
|
|
127
|
+
shell: true
|
|
128
|
+
}
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
execSync(
|
|
132
|
+
`cd ${projectName}/frontend && npx tailwindcss init -p`,
|
|
133
|
+
{
|
|
134
|
+
stdio: "inherit",
|
|
135
|
+
shell: true
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
console.log(
|
|
140
|
+
chalk.green("✅ Tailwind Installed")
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
frontendSpinner.succeed(
|
|
145
|
+
"Frontend created successfully"
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// ================= BACKEND =================
|
|
150
|
+
|
|
151
|
+
function createBackend(projectName) {
|
|
152
|
+
|
|
153
|
+
const backendSpinner = ora(
|
|
154
|
+
"Creating Backend..."
|
|
155
|
+
).start();
|
|
156
|
+
|
|
157
|
+
// Create Backend Folder
|
|
158
|
+
fs.mkdirSync(`${projectName}/backend`);
|
|
159
|
+
|
|
160
|
+
// Initialize npm
|
|
161
|
+
execSync(
|
|
162
|
+
`cd ${projectName}/backend && npm init -y`,
|
|
163
|
+
{
|
|
164
|
+
stdio: "inherit",
|
|
165
|
+
shell: true
|
|
166
|
+
}
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
// Install Backend Packages
|
|
170
|
+
execSync(
|
|
171
|
+
`cd ${projectName}/backend && npm install express mongoose cors dotenv bcryptjs jsonwebtoken`,
|
|
172
|
+
{
|
|
173
|
+
stdio: "inherit",
|
|
174
|
+
shell: true
|
|
175
|
+
}
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
// Install Nodemon
|
|
179
|
+
execSync(
|
|
180
|
+
`cd ${projectName}/backend && npm install -D nodemon`,
|
|
181
|
+
{
|
|
182
|
+
stdio: "inherit",
|
|
183
|
+
shell: true
|
|
184
|
+
}
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
// Create Backend Structure
|
|
188
|
+
fs.mkdirSync(`${projectName}/backend/routes`);
|
|
189
|
+
fs.mkdirSync(`${projectName}/backend/controllers`);
|
|
190
|
+
fs.mkdirSync(`${projectName}/backend/models`);
|
|
191
|
+
fs.mkdirSync(`${projectName}/backend/middleware`);
|
|
192
|
+
fs.mkdirSync(`${projectName}/backend/config`);
|
|
193
|
+
fs.mkdirSync(`${projectName}/backend/utils`);
|
|
194
|
+
|
|
195
|
+
// Create server.js
|
|
196
|
+
const serverCode = `
|
|
197
|
+
import express from "express";
|
|
198
|
+
import dotenv from "dotenv";
|
|
199
|
+
import cors from "cors";
|
|
200
|
+
|
|
201
|
+
const app = express();
|
|
202
|
+
|
|
203
|
+
dotenv.config();
|
|
204
|
+
|
|
205
|
+
app.use(cors());
|
|
206
|
+
app.use(express.json());
|
|
207
|
+
|
|
208
|
+
app.get("/", (req, res) => {
|
|
209
|
+
res.send("API Running 🚀");
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
const PORT = process.env.PORT || 5000;
|
|
213
|
+
|
|
214
|
+
app.listen(PORT, () => {
|
|
215
|
+
console.log(\`Server running on port \${PORT}\`);
|
|
216
|
+
});
|
|
217
|
+
`;
|
|
218
|
+
|
|
219
|
+
fs.writeFileSync(
|
|
220
|
+
`${projectName}/backend/server.js`,
|
|
221
|
+
serverCode
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
// Create .env
|
|
225
|
+
const envCode = `
|
|
226
|
+
PORT=5000
|
|
227
|
+
MONGO_URI=
|
|
228
|
+
JWT_SECRET=
|
|
229
|
+
`;
|
|
230
|
+
|
|
231
|
+
fs.writeFileSync(
|
|
232
|
+
`${projectName}/backend/.env`,
|
|
233
|
+
envCode
|
|
234
|
+
);
|
|
235
|
+
|
|
236
|
+
backendSpinner.succeed(
|
|
237
|
+
"Backend created successfully"
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// ================= MAIN LOGIC =================
|
|
242
|
+
|
|
243
|
+
try {
|
|
244
|
+
|
|
245
|
+
// Frontend Only
|
|
246
|
+
if (answers.projectType === "frontend") {
|
|
247
|
+
|
|
248
|
+
createFrontend(answers.projectName);
|
|
249
|
+
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// Backend Only
|
|
253
|
+
else if (answers.projectType === "backend") {
|
|
254
|
+
|
|
255
|
+
createBackend(answers.projectName);
|
|
256
|
+
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// Full Stack
|
|
260
|
+
else if (answers.projectType === "fullstack") {
|
|
261
|
+
|
|
262
|
+
console.log(
|
|
263
|
+
chalk.yellow("🚀 Creating Full Stack App...")
|
|
264
|
+
);
|
|
265
|
+
|
|
266
|
+
createBackend(answers.projectName);
|
|
267
|
+
createFrontend(answers.projectName);
|
|
268
|
+
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
console.log(
|
|
272
|
+
chalk.green(`
|
|
273
|
+
🎉 Project Setup Complete!
|
|
274
|
+
Happy Coding 🚀
|
|
275
|
+
`)
|
|
276
|
+
);
|
|
277
|
+
|
|
278
|
+
} catch (error) {
|
|
279
|
+
|
|
280
|
+
console.log(
|
|
281
|
+
chalk.red("❌ Error:", error.message)
|
|
282
|
+
);
|
|
283
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-devarchitect",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "CLI tool to generate full stack applications instantly",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
|
|
8
|
+
"bin": {
|
|
9
|
+
"create-devarchitect": "./index.js"
|
|
10
|
+
},
|
|
11
|
+
|
|
12
|
+
"preferGlobal": true,
|
|
13
|
+
|
|
14
|
+
"scripts": {
|
|
15
|
+
"start": "node index.js"
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
"keywords": [
|
|
19
|
+
"cli",
|
|
20
|
+
"fullstack",
|
|
21
|
+
"react",
|
|
22
|
+
"express",
|
|
23
|
+
"mern",
|
|
24
|
+
"generator"
|
|
25
|
+
],
|
|
26
|
+
|
|
27
|
+
"author": "Santosh",
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=16"
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"chalk": "^5.6.2",
|
|
36
|
+
"inquirer": "^13.4.3",
|
|
37
|
+
"ora": "^9.4.0"
|
|
38
|
+
}
|
|
39
|
+
}
|