devcore-ai 1.1.1 → 1.1.3
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/dist/ai/index.d.ts.map +1 -1
- package/dist/ai/index.js +15 -8
- package/dist/ai/index.js.map +1 -1
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +79 -14
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/init-command.d.ts +2 -0
- package/dist/commands/init-command.d.ts.map +1 -0
- package/dist/commands/init-command.js +167 -0
- package/dist/commands/init-command.js.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/init/gitignore.d.ts +3 -0
- package/dist/init/gitignore.d.ts.map +1 -0
- package/dist/init/gitignore.js +78 -0
- package/dist/init/gitignore.js.map +1 -0
- package/dist/init/index.d.ts +7 -0
- package/dist/init/index.d.ts.map +1 -0
- package/dist/init/index.js +25 -0
- package/dist/init/index.js.map +1 -0
- package/dist/init/installer.d.ts +9 -0
- package/dist/init/installer.d.ts.map +1 -0
- package/dist/init/installer.js +58 -0
- package/dist/init/installer.js.map +1 -0
- package/dist/init/progress.d.ts +6 -0
- package/dist/init/progress.d.ts.map +1 -0
- package/dist/init/progress.js +35 -0
- package/dist/init/progress.js.map +1 -0
- package/dist/init/project-generator.d.ts +6 -0
- package/dist/init/project-generator.d.ts.map +1 -0
- package/dist/init/project-generator.js +55 -0
- package/dist/init/project-generator.js.map +1 -0
- package/dist/init/readme.d.ts +3 -0
- package/dist/init/readme.d.ts.map +1 -0
- package/dist/init/readme.js +61 -0
- package/dist/init/readme.js.map +1 -0
- package/dist/init/templates.d.ts +3 -0
- package/dist/init/templates.d.ts.map +1 -0
- package/dist/init/templates.js +924 -0
- package/dist/init/templates.js.map +1 -0
- package/dist/types.d.ts +24 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,924 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTemplate = getTemplate;
|
|
4
|
+
function pkg(obj) {
|
|
5
|
+
return JSON.stringify(obj, null, 2) + "\n";
|
|
6
|
+
}
|
|
7
|
+
function reactTemplate(o) {
|
|
8
|
+
const ts = o.language === "typescript";
|
|
9
|
+
const ext = ts ? "tsx" : "jsx";
|
|
10
|
+
const files = [
|
|
11
|
+
{
|
|
12
|
+
path: "package.json",
|
|
13
|
+
content: pkg({
|
|
14
|
+
name: o.projectName,
|
|
15
|
+
private: true,
|
|
16
|
+
version: "0.0.0",
|
|
17
|
+
type: "module",
|
|
18
|
+
scripts: {
|
|
19
|
+
dev: "vite",
|
|
20
|
+
build: ts ? "tsc && vite build" : "vite build",
|
|
21
|
+
preview: "vite preview",
|
|
22
|
+
},
|
|
23
|
+
dependencies: {
|
|
24
|
+
react: "^18.3.1",
|
|
25
|
+
"react-dom": "^18.3.1",
|
|
26
|
+
},
|
|
27
|
+
devDependencies: {
|
|
28
|
+
"@vitejs/plugin-react": "^4.3.1",
|
|
29
|
+
vite: "^5.4.0",
|
|
30
|
+
...(ts
|
|
31
|
+
? {
|
|
32
|
+
"@types/react": "^18.3.3",
|
|
33
|
+
"@types/react-dom": "^18.3.0",
|
|
34
|
+
typescript: "^5.5.3",
|
|
35
|
+
}
|
|
36
|
+
: {}),
|
|
37
|
+
},
|
|
38
|
+
}),
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
path: "index.html",
|
|
42
|
+
content: `<!DOCTYPE html>
|
|
43
|
+
<html lang="en">
|
|
44
|
+
<head>
|
|
45
|
+
<meta charset="UTF-8" />
|
|
46
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
47
|
+
<title>${o.projectName}</title>
|
|
48
|
+
</head>
|
|
49
|
+
<body>
|
|
50
|
+
<div id="root"></div>
|
|
51
|
+
<script type="module" src="/src/main.${ext}"></script>
|
|
52
|
+
</body>
|
|
53
|
+
</html>
|
|
54
|
+
`,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
path: `vite.config.${ts ? "ts" : "js"}`,
|
|
58
|
+
content: ts
|
|
59
|
+
? `import { defineConfig } from "vite";
|
|
60
|
+
import react from "@vitejs/plugin-react";
|
|
61
|
+
|
|
62
|
+
export default defineConfig({
|
|
63
|
+
plugins: [react()],
|
|
64
|
+
});
|
|
65
|
+
`
|
|
66
|
+
: `import { defineConfig } from "vite";
|
|
67
|
+
import react from "@vitejs/plugin-react";
|
|
68
|
+
|
|
69
|
+
export default defineConfig({
|
|
70
|
+
plugins: [react()],
|
|
71
|
+
});
|
|
72
|
+
`,
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
path: "src/main." + ext,
|
|
76
|
+
content: ts
|
|
77
|
+
? `import React from "react";
|
|
78
|
+
import ReactDOM from "react-dom/client";
|
|
79
|
+
import App from "./App";
|
|
80
|
+
import "./index.css";
|
|
81
|
+
|
|
82
|
+
ReactDOM.createRoot(document.getElementById("root")!).render(
|
|
83
|
+
<React.StrictMode>
|
|
84
|
+
<App />
|
|
85
|
+
</React.StrictMode>
|
|
86
|
+
);
|
|
87
|
+
`
|
|
88
|
+
: `import React from "react";
|
|
89
|
+
import ReactDOM from "react-dom/client";
|
|
90
|
+
import App from "./App";
|
|
91
|
+
import "./index.css";
|
|
92
|
+
|
|
93
|
+
ReactDOM.createRoot(document.getElementById("root")).render(
|
|
94
|
+
<React.StrictMode>
|
|
95
|
+
<App />
|
|
96
|
+
</React.StrictMode>
|
|
97
|
+
);
|
|
98
|
+
`,
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
path: "src/App." + ext,
|
|
102
|
+
content: ts
|
|
103
|
+
? `function App() {
|
|
104
|
+
return (
|
|
105
|
+
<div style={{ padding: "2rem", fontFamily: "sans-serif" }}>
|
|
106
|
+
<h1>Welcome to ${o.projectName}</h1>
|
|
107
|
+
<p>Get started by editing <code>src/App.tsx</code></p>
|
|
108
|
+
</div>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export default App;
|
|
113
|
+
`
|
|
114
|
+
: `function App() {
|
|
115
|
+
return (
|
|
116
|
+
<div style={{ padding: "2rem", fontFamily: "sans-serif" }}>
|
|
117
|
+
<h1>Welcome to ${o.projectName}</h1>
|
|
118
|
+
<p>Get started by editing <code>src/App.jsx</code></p>
|
|
119
|
+
</div>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export default App;
|
|
124
|
+
`,
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
path: "src/index.css",
|
|
128
|
+
content: `* {
|
|
129
|
+
margin: 0;
|
|
130
|
+
padding: 0;
|
|
131
|
+
box-sizing: border-box;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
body {
|
|
135
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
136
|
+
-webkit-font-smoothing: antialiased;
|
|
137
|
+
}
|
|
138
|
+
`,
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
path: "src/App.css",
|
|
142
|
+
content: `/* App styles */
|
|
143
|
+
`,
|
|
144
|
+
},
|
|
145
|
+
];
|
|
146
|
+
if (ts) {
|
|
147
|
+
files.push({
|
|
148
|
+
path: "tsconfig.json",
|
|
149
|
+
content: pkg({
|
|
150
|
+
compilerOptions: {
|
|
151
|
+
target: "ES2020",
|
|
152
|
+
useDefineForClassFields: true,
|
|
153
|
+
lib: ["ES2020", "DOM", "DOM.Iterable"],
|
|
154
|
+
module: "ESNext",
|
|
155
|
+
skipLibCheck: true,
|
|
156
|
+
moduleResolution: "bundler",
|
|
157
|
+
allowImportingTsExtensions: true,
|
|
158
|
+
resolveJsonModule: true,
|
|
159
|
+
isolatedModules: true,
|
|
160
|
+
noEmit: true,
|
|
161
|
+
jsx: "react-jsx",
|
|
162
|
+
strict: true,
|
|
163
|
+
noUnusedLocals: true,
|
|
164
|
+
noUnusedParameters: true,
|
|
165
|
+
noFallthroughCasesInSwitch: true,
|
|
166
|
+
},
|
|
167
|
+
include: ["src"],
|
|
168
|
+
}),
|
|
169
|
+
});
|
|
170
|
+
files.push({
|
|
171
|
+
path: "tsconfig.node.json",
|
|
172
|
+
content: pkg({
|
|
173
|
+
compilerOptions: {
|
|
174
|
+
composite: true,
|
|
175
|
+
skipLibCheck: true,
|
|
176
|
+
module: "ESNext",
|
|
177
|
+
moduleResolution: "bundler",
|
|
178
|
+
allowSyntheticDefaultImports: true,
|
|
179
|
+
},
|
|
180
|
+
include: ["vite.config.ts"],
|
|
181
|
+
}),
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
return {
|
|
185
|
+
name: "React",
|
|
186
|
+
framework: "react",
|
|
187
|
+
directories: ["src", "src/components", "src/pages", "src/hooks", "src/assets", "public"],
|
|
188
|
+
files,
|
|
189
|
+
dependencies: { react: "^18.3.1", "react-dom": "^18.3.1" },
|
|
190
|
+
devDependencies: { "@vitejs/plugin-react": "^4.3.1", vite: "^5.4.0" },
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
function nextjsTemplate(o) {
|
|
194
|
+
const ts = o.language === "typescript";
|
|
195
|
+
const ext = ts ? "tsx" : "jsx";
|
|
196
|
+
const files = [
|
|
197
|
+
{
|
|
198
|
+
path: "package.json",
|
|
199
|
+
content: pkg({
|
|
200
|
+
name: o.projectName,
|
|
201
|
+
version: "0.1.0",
|
|
202
|
+
private: true,
|
|
203
|
+
scripts: {
|
|
204
|
+
dev: "next dev",
|
|
205
|
+
build: "next build",
|
|
206
|
+
start: "next start",
|
|
207
|
+
lint: "next lint",
|
|
208
|
+
},
|
|
209
|
+
dependencies: {
|
|
210
|
+
next: "^14.2.5",
|
|
211
|
+
react: "^18.3.1",
|
|
212
|
+
"react-dom": "^18.3.1",
|
|
213
|
+
},
|
|
214
|
+
devDependencies: {
|
|
215
|
+
...(ts ? { typescript: "^5.5.3", "@types/node": "^20.14.0", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0" } : {}),
|
|
216
|
+
},
|
|
217
|
+
}),
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
path: "next.config.js",
|
|
221
|
+
content: `/** @type {import('next').NextConfig} */
|
|
222
|
+
const nextConfig = {};
|
|
223
|
+
|
|
224
|
+
module.exports = nextConfig;
|
|
225
|
+
`,
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
path: "app/layout." + ext,
|
|
229
|
+
content: ts
|
|
230
|
+
? `import type { Metadata } from "next";
|
|
231
|
+
import "./globals.css";
|
|
232
|
+
|
|
233
|
+
export const metadata: Metadata = {
|
|
234
|
+
title: "${o.projectName}",
|
|
235
|
+
description: "Created with DevCore AI",
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
export default function RootLayout({
|
|
239
|
+
children,
|
|
240
|
+
}: {
|
|
241
|
+
children: React.ReactNode;
|
|
242
|
+
}) {
|
|
243
|
+
return (
|
|
244
|
+
<html lang="en">
|
|
245
|
+
<body>{children}</body>
|
|
246
|
+
</html>
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
`
|
|
250
|
+
: `import "./globals.css";
|
|
251
|
+
|
|
252
|
+
export const metadata = {
|
|
253
|
+
title: "${o.projectName}",
|
|
254
|
+
description: "Created with DevCore AI",
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
export default function RootLayout({ children }) {
|
|
258
|
+
return (
|
|
259
|
+
<html lang="en">
|
|
260
|
+
<body>{children}</body>
|
|
261
|
+
</html>
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
`,
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
path: "app/page." + ext,
|
|
268
|
+
content: ts
|
|
269
|
+
? `export default function Home() {
|
|
270
|
+
return (
|
|
271
|
+
<main style={{ padding: "2rem", fontFamily: "sans-serif" }}>
|
|
272
|
+
<h1>Welcome to ${o.projectName}</h1>
|
|
273
|
+
<p>Get started by editing <code>app/page.tsx</code></p>
|
|
274
|
+
</main>
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
`
|
|
278
|
+
: `export default function Home() {
|
|
279
|
+
return (
|
|
280
|
+
<main style={{ padding: "2rem", fontFamily: "sans-serif" }}>
|
|
281
|
+
<h1>Welcome to ${o.projectName}</h1>
|
|
282
|
+
<p>Get started by editing <code>app/page.jsx</code></p>
|
|
283
|
+
</main>
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
`,
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
path: "app/globals.css",
|
|
290
|
+
content: `* {
|
|
291
|
+
margin: 0;
|
|
292
|
+
padding: 0;
|
|
293
|
+
box-sizing: border-box;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
body {
|
|
297
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
298
|
+
-webkit-font-smoothing: antialiased;
|
|
299
|
+
}
|
|
300
|
+
`,
|
|
301
|
+
},
|
|
302
|
+
];
|
|
303
|
+
if (ts) {
|
|
304
|
+
files.push({
|
|
305
|
+
path: "tsconfig.json",
|
|
306
|
+
content: pkg({
|
|
307
|
+
compilerOptions: {
|
|
308
|
+
target: "ES2017",
|
|
309
|
+
lib: ["dom", "dom.iterable", "esnext"],
|
|
310
|
+
allowJs: true,
|
|
311
|
+
skipLibCheck: true,
|
|
312
|
+
strict: true,
|
|
313
|
+
noEmit: true,
|
|
314
|
+
esModuleInterop: true,
|
|
315
|
+
module: "esnext",
|
|
316
|
+
moduleResolution: "bundler",
|
|
317
|
+
resolveJsonModule: true,
|
|
318
|
+
isolatedModules: true,
|
|
319
|
+
jsx: "preserve",
|
|
320
|
+
incremental: true,
|
|
321
|
+
plugins: [{ name: "next" }],
|
|
322
|
+
paths: { "@/*": ["./src/*"] },
|
|
323
|
+
},
|
|
324
|
+
include: ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
|
325
|
+
exclude: ["node_modules"],
|
|
326
|
+
}),
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
return {
|
|
330
|
+
name: "Next.js",
|
|
331
|
+
framework: "nextjs",
|
|
332
|
+
directories: ["app", "components", "lib", "public"],
|
|
333
|
+
files,
|
|
334
|
+
dependencies: { next: "^14.2.5", react: "^18.3.1", "react-dom": "^18.3.1" },
|
|
335
|
+
devDependencies: {},
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
function expressTemplate(o) {
|
|
339
|
+
const ts = o.language === "typescript";
|
|
340
|
+
const ext = ts ? "ts" : "js";
|
|
341
|
+
const files = [
|
|
342
|
+
{
|
|
343
|
+
path: "package.json",
|
|
344
|
+
content: pkg({
|
|
345
|
+
name: o.projectName,
|
|
346
|
+
version: "1.0.0",
|
|
347
|
+
scripts: {
|
|
348
|
+
dev: ts ? "nodemon src/index.ts" : "nodemon src/index.js",
|
|
349
|
+
build: ts ? "tsc" : "echo 'No build step'",
|
|
350
|
+
start: ts ? "node dist/index.js" : "node src/index.js",
|
|
351
|
+
},
|
|
352
|
+
dependencies: {
|
|
353
|
+
cors: "^2.8.5",
|
|
354
|
+
dotenv: "^16.4.5",
|
|
355
|
+
express: "^4.19.2",
|
|
356
|
+
},
|
|
357
|
+
devDependencies: {
|
|
358
|
+
nodemon: "^3.1.4",
|
|
359
|
+
...(ts
|
|
360
|
+
? {
|
|
361
|
+
"@types/cors": "^2.8.17",
|
|
362
|
+
"@types/express": "^4.17.21",
|
|
363
|
+
"@types/node": "^20.14.0",
|
|
364
|
+
"ts-node": "^10.9.2",
|
|
365
|
+
typescript: "^5.5.3",
|
|
366
|
+
}
|
|
367
|
+
: {}),
|
|
368
|
+
},
|
|
369
|
+
}),
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
path: "src/index." + ext,
|
|
373
|
+
content: ts
|
|
374
|
+
? `import express from "express";
|
|
375
|
+
import cors from "cors";
|
|
376
|
+
import dotenv from "dotenv";
|
|
377
|
+
import { router } from "./routes";
|
|
378
|
+
|
|
379
|
+
dotenv.config();
|
|
380
|
+
|
|
381
|
+
const app = express();
|
|
382
|
+
const PORT = process.env.PORT || 3000;
|
|
383
|
+
|
|
384
|
+
app.use(cors());
|
|
385
|
+
app.use(express.json());
|
|
386
|
+
app.use("/api", router);
|
|
387
|
+
|
|
388
|
+
app.get("/", (_req, res) => {
|
|
389
|
+
res.json({ message: "Welcome to ${o.projectName}" });
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
app.listen(PORT, () => {
|
|
393
|
+
console.log(\`Server running on http://localhost:\${PORT}\`);
|
|
394
|
+
});
|
|
395
|
+
`
|
|
396
|
+
: `const express = require("express");
|
|
397
|
+
const cors = require("cors");
|
|
398
|
+
const dotenv = require("dotenv");
|
|
399
|
+
const { router } = require("./routes");
|
|
400
|
+
|
|
401
|
+
dotenv.config();
|
|
402
|
+
|
|
403
|
+
const app = express();
|
|
404
|
+
const PORT = process.env.PORT || 3000;
|
|
405
|
+
|
|
406
|
+
app.use(cors());
|
|
407
|
+
app.use(express.json());
|
|
408
|
+
app.use("/api", router);
|
|
409
|
+
|
|
410
|
+
app.get("/", (_req, res) => {
|
|
411
|
+
res.json({ message: "Welcome to ${o.projectName}" });
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
app.listen(PORT, () => {
|
|
415
|
+
console.log(\`Server running on http://localhost:\${PORT}\`);
|
|
416
|
+
});
|
|
417
|
+
`,
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
path: "src/routes/index." + ext,
|
|
421
|
+
content: ts
|
|
422
|
+
? `import { Router } from "express";
|
|
423
|
+
|
|
424
|
+
export const router = Router();
|
|
425
|
+
|
|
426
|
+
router.get("/health", (_req, res) => {
|
|
427
|
+
res.json({ status: "ok" });
|
|
428
|
+
});
|
|
429
|
+
`
|
|
430
|
+
: `const { Router } = require("express");
|
|
431
|
+
|
|
432
|
+
const router = Router();
|
|
433
|
+
|
|
434
|
+
router.get("/health", (_req, res) => {
|
|
435
|
+
res.json({ status: "ok" });
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
module.exports = { router };
|
|
439
|
+
`,
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
path: ".env",
|
|
443
|
+
content: `PORT=3000
|
|
444
|
+
`,
|
|
445
|
+
},
|
|
446
|
+
];
|
|
447
|
+
if (ts) {
|
|
448
|
+
files.push({
|
|
449
|
+
path: "tsconfig.json",
|
|
450
|
+
content: pkg({
|
|
451
|
+
compilerOptions: {
|
|
452
|
+
target: "ES2020",
|
|
453
|
+
module: "commonjs",
|
|
454
|
+
lib: ["ES2020"],
|
|
455
|
+
outDir: "./dist",
|
|
456
|
+
rootDir: "./src",
|
|
457
|
+
strict: true,
|
|
458
|
+
esModuleInterop: true,
|
|
459
|
+
skipLibCheck: true,
|
|
460
|
+
forceConsistentCasingInFileNames: true,
|
|
461
|
+
resolveJsonModule: true,
|
|
462
|
+
declaration: true,
|
|
463
|
+
sourceMap: true,
|
|
464
|
+
},
|
|
465
|
+
include: ["src/**/*"],
|
|
466
|
+
exclude: ["node_modules", "dist"],
|
|
467
|
+
}),
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
files.push({
|
|
471
|
+
path: "nodemon.json",
|
|
472
|
+
content: pkg({
|
|
473
|
+
watch: ["src"],
|
|
474
|
+
ext: ts ? "ts,js" : "js",
|
|
475
|
+
ignore: ["node_modules", "dist"],
|
|
476
|
+
}),
|
|
477
|
+
});
|
|
478
|
+
return {
|
|
479
|
+
name: "Express",
|
|
480
|
+
framework: "express",
|
|
481
|
+
directories: ["src", "src/routes", "src/controllers", "src/middlewares", "src/utils"],
|
|
482
|
+
files,
|
|
483
|
+
dependencies: { cors: "^2.8.5", dotenv: "^16.4.5", express: "^4.19.2" },
|
|
484
|
+
devDependencies: { nodemon: "^3.1.4" },
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
function nodeCliTemplate(o) {
|
|
488
|
+
const ts = o.language === "typescript";
|
|
489
|
+
const ext = ts ? "ts" : "js";
|
|
490
|
+
const files = [
|
|
491
|
+
{
|
|
492
|
+
path: "package.json",
|
|
493
|
+
content: pkg({
|
|
494
|
+
name: o.projectName,
|
|
495
|
+
version: "1.0.0",
|
|
496
|
+
bin: { [o.projectName]: ts ? "dist/index.js" : "src/index.js" },
|
|
497
|
+
scripts: {
|
|
498
|
+
dev: ts ? "ts-node src/index.ts" : "node src/index.js",
|
|
499
|
+
build: ts ? "tsc" : "echo 'No build step'",
|
|
500
|
+
start: ts ? "node dist/index.js" : "node src/index.js",
|
|
501
|
+
},
|
|
502
|
+
dependencies: {
|
|
503
|
+
commander: "^12.1.0",
|
|
504
|
+
chalk: "^4.1.2",
|
|
505
|
+
},
|
|
506
|
+
devDependencies: {
|
|
507
|
+
...(ts
|
|
508
|
+
? {
|
|
509
|
+
"@types/node": "^20.14.0",
|
|
510
|
+
typescript: "^5.5.3",
|
|
511
|
+
}
|
|
512
|
+
: {}),
|
|
513
|
+
},
|
|
514
|
+
}),
|
|
515
|
+
},
|
|
516
|
+
{
|
|
517
|
+
path: "src/index." + ext,
|
|
518
|
+
content: ts
|
|
519
|
+
? `#!/usr/bin/env node
|
|
520
|
+
import { Command } from "commander";
|
|
521
|
+
import chalk from "chalk";
|
|
522
|
+
|
|
523
|
+
const program = new Command();
|
|
524
|
+
|
|
525
|
+
program
|
|
526
|
+
.name("${o.projectName}")
|
|
527
|
+
.description("CLI tool created with DevCore AI")
|
|
528
|
+
.version("1.0.0");
|
|
529
|
+
|
|
530
|
+
program
|
|
531
|
+
.command("hello")
|
|
532
|
+
.description("Say hello")
|
|
533
|
+
.argument("[name]", "Name to greet", "World")
|
|
534
|
+
.action((name: string) => {
|
|
535
|
+
console.log(chalk.cyan(\`Hello, \${name}!\`));
|
|
536
|
+
});
|
|
537
|
+
|
|
538
|
+
program.parse();
|
|
539
|
+
`
|
|
540
|
+
: `#!/usr/bin/env node
|
|
541
|
+
const { Command } = require("commander");
|
|
542
|
+
const chalk = require("chalk");
|
|
543
|
+
|
|
544
|
+
const program = new Command();
|
|
545
|
+
|
|
546
|
+
program
|
|
547
|
+
.name("${o.projectName}")
|
|
548
|
+
.description("CLI tool created with DevCore AI")
|
|
549
|
+
.version("1.0.0");
|
|
550
|
+
|
|
551
|
+
program
|
|
552
|
+
.command("hello")
|
|
553
|
+
.description("Say hello")
|
|
554
|
+
.argument("[name]", "Name to greet", "World")
|
|
555
|
+
.action((name) => {
|
|
556
|
+
console.log(chalk.cyan(\`Hello, \${name}!\`));
|
|
557
|
+
});
|
|
558
|
+
|
|
559
|
+
program.parse();
|
|
560
|
+
`,
|
|
561
|
+
},
|
|
562
|
+
];
|
|
563
|
+
if (ts) {
|
|
564
|
+
files.push({
|
|
565
|
+
path: "tsconfig.json",
|
|
566
|
+
content: pkg({
|
|
567
|
+
compilerOptions: {
|
|
568
|
+
target: "ES2020",
|
|
569
|
+
module: "commonjs",
|
|
570
|
+
lib: ["ES2020"],
|
|
571
|
+
outDir: "./dist",
|
|
572
|
+
rootDir: "./src",
|
|
573
|
+
strict: true,
|
|
574
|
+
esModuleInterop: true,
|
|
575
|
+
skipLibCheck: true,
|
|
576
|
+
forceConsistentCasingInFileNames: true,
|
|
577
|
+
resolveJsonModule: true,
|
|
578
|
+
declaration: true,
|
|
579
|
+
sourceMap: true,
|
|
580
|
+
},
|
|
581
|
+
include: ["src/**/*"],
|
|
582
|
+
exclude: ["node_modules", "dist"],
|
|
583
|
+
}),
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
return {
|
|
587
|
+
name: "Node CLI",
|
|
588
|
+
framework: "node-cli",
|
|
589
|
+
directories: ["src", "src/commands", "src/utils"],
|
|
590
|
+
files,
|
|
591
|
+
dependencies: { commander: "^12.1.0", chalk: "^4.1.2" },
|
|
592
|
+
devDependencies: {},
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
function discordBotTemplate(o) {
|
|
596
|
+
const ts = o.language === "typescript";
|
|
597
|
+
const ext = ts ? "ts" : "js";
|
|
598
|
+
const files = [
|
|
599
|
+
{
|
|
600
|
+
path: "package.json",
|
|
601
|
+
content: pkg({
|
|
602
|
+
name: o.projectName,
|
|
603
|
+
version: "1.0.0",
|
|
604
|
+
scripts: {
|
|
605
|
+
dev: ts ? "ts-node src/index.ts" : "node src/index.js",
|
|
606
|
+
build: ts ? "tsc" : "echo 'No build step'",
|
|
607
|
+
start: ts ? "node dist/index.js" : "node src/index.js",
|
|
608
|
+
},
|
|
609
|
+
dependencies: {
|
|
610
|
+
"discord.js": "^14.15.3",
|
|
611
|
+
dotenv: "^16.4.5",
|
|
612
|
+
},
|
|
613
|
+
devDependencies: {
|
|
614
|
+
...(ts
|
|
615
|
+
? {
|
|
616
|
+
"@types/node": "^20.14.0",
|
|
617
|
+
typescript: "^5.5.3",
|
|
618
|
+
}
|
|
619
|
+
: {}),
|
|
620
|
+
},
|
|
621
|
+
}),
|
|
622
|
+
},
|
|
623
|
+
{
|
|
624
|
+
path: "src/index." + ext,
|
|
625
|
+
content: ts
|
|
626
|
+
? `import { Client, GatewayIntentBits } from "discord.js";
|
|
627
|
+
import dotenv from "dotenv";
|
|
628
|
+
|
|
629
|
+
dotenv.config();
|
|
630
|
+
|
|
631
|
+
const client = new Client({
|
|
632
|
+
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages],
|
|
633
|
+
});
|
|
634
|
+
|
|
635
|
+
client.once("ready", () => {
|
|
636
|
+
console.log(\`Logged in as \${client.user?.tag}\`);
|
|
637
|
+
});
|
|
638
|
+
|
|
639
|
+
client.on("messageCreate", (message) => {
|
|
640
|
+
if (message.author.bot) return;
|
|
641
|
+
|
|
642
|
+
if (message.content === "!ping") {
|
|
643
|
+
message.reply("Pong!");
|
|
644
|
+
}
|
|
645
|
+
});
|
|
646
|
+
|
|
647
|
+
client.login(process.env.DISCORD_TOKEN);
|
|
648
|
+
`
|
|
649
|
+
: `const { Client, GatewayIntentBits } = require("discord.js");
|
|
650
|
+
require("dotenv").config();
|
|
651
|
+
|
|
652
|
+
const client = new Client({
|
|
653
|
+
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages],
|
|
654
|
+
});
|
|
655
|
+
|
|
656
|
+
client.once("ready", () => {
|
|
657
|
+
console.log(\`Logged in as \${client.user?.tag}\`);
|
|
658
|
+
});
|
|
659
|
+
|
|
660
|
+
client.on("messageCreate", (message) => {
|
|
661
|
+
if (message.author.bot) return;
|
|
662
|
+
|
|
663
|
+
if (message.content === "!ping") {
|
|
664
|
+
message.reply("Pong!");
|
|
665
|
+
}
|
|
666
|
+
});
|
|
667
|
+
|
|
668
|
+
client.login(process.env.DISCORD_TOKEN);
|
|
669
|
+
`,
|
|
670
|
+
},
|
|
671
|
+
{
|
|
672
|
+
path: ".env",
|
|
673
|
+
content: `DISCORD_TOKEN=your-token-here
|
|
674
|
+
`,
|
|
675
|
+
},
|
|
676
|
+
];
|
|
677
|
+
if (ts) {
|
|
678
|
+
files.push({
|
|
679
|
+
path: "tsconfig.json",
|
|
680
|
+
content: pkg({
|
|
681
|
+
compilerOptions: {
|
|
682
|
+
target: "ES2020",
|
|
683
|
+
module: "commonjs",
|
|
684
|
+
lib: ["ES2020"],
|
|
685
|
+
outDir: "./dist",
|
|
686
|
+
rootDir: "./src",
|
|
687
|
+
strict: true,
|
|
688
|
+
esModuleInterop: true,
|
|
689
|
+
skipLibCheck: true,
|
|
690
|
+
forceConsistentCasingInFileNames: true,
|
|
691
|
+
resolveJsonModule: true,
|
|
692
|
+
declaration: true,
|
|
693
|
+
sourceMap: true,
|
|
694
|
+
},
|
|
695
|
+
include: ["src/**/*"],
|
|
696
|
+
exclude: ["node_modules", "dist"],
|
|
697
|
+
}),
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
return {
|
|
701
|
+
name: "Discord Bot",
|
|
702
|
+
framework: "discord-bot",
|
|
703
|
+
directories: ["src", "src/commands", "src/events"],
|
|
704
|
+
files,
|
|
705
|
+
dependencies: { "discord.js": "^14.15.3", dotenv: "^16.4.5" },
|
|
706
|
+
devDependencies: {},
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
function fastApiTemplate(_o) {
|
|
710
|
+
const files = [
|
|
711
|
+
{
|
|
712
|
+
path: "requirements.txt",
|
|
713
|
+
content: `fastapi==0.111.0
|
|
714
|
+
uvicorn[standard]==0.30.1
|
|
715
|
+
`,
|
|
716
|
+
},
|
|
717
|
+
{
|
|
718
|
+
path: "main.py",
|
|
719
|
+
content: `from fastapi import FastAPI
|
|
720
|
+
|
|
721
|
+
app = FastAPI(title="${_o.projectName}")
|
|
722
|
+
|
|
723
|
+
|
|
724
|
+
@app.get("/")
|
|
725
|
+
def read_root():
|
|
726
|
+
return {"Hello": "World"}
|
|
727
|
+
|
|
728
|
+
|
|
729
|
+
@app.get("/health")
|
|
730
|
+
def health_check():
|
|
731
|
+
return {"status": "ok"}
|
|
732
|
+
`,
|
|
733
|
+
},
|
|
734
|
+
{
|
|
735
|
+
path: "app/__init__.py",
|
|
736
|
+
content: "",
|
|
737
|
+
},
|
|
738
|
+
{
|
|
739
|
+
path: "app/routers/__init__.py",
|
|
740
|
+
content: "",
|
|
741
|
+
},
|
|
742
|
+
{
|
|
743
|
+
path: "app/models/__init__.py",
|
|
744
|
+
content: "",
|
|
745
|
+
},
|
|
746
|
+
];
|
|
747
|
+
return {
|
|
748
|
+
name: "FastAPI",
|
|
749
|
+
framework: "fastapi",
|
|
750
|
+
directories: ["app", "app/routers", "app/models"],
|
|
751
|
+
files,
|
|
752
|
+
dependencies: {},
|
|
753
|
+
devDependencies: {},
|
|
754
|
+
};
|
|
755
|
+
}
|
|
756
|
+
function nestTemplate(o) {
|
|
757
|
+
const files = [
|
|
758
|
+
{
|
|
759
|
+
path: "package.json",
|
|
760
|
+
content: pkg({
|
|
761
|
+
name: o.projectName,
|
|
762
|
+
version: "0.0.1",
|
|
763
|
+
scripts: {
|
|
764
|
+
build: "nest build",
|
|
765
|
+
start: "nest start",
|
|
766
|
+
dev: "nest start --watch",
|
|
767
|
+
"start:prod": "node dist/main",
|
|
768
|
+
lint: "eslint \"{src,test}/**/*.ts\" --fix",
|
|
769
|
+
test: "jest",
|
|
770
|
+
},
|
|
771
|
+
dependencies: {
|
|
772
|
+
"@nestjs/common": "^10.3.8",
|
|
773
|
+
"@nestjs/core": "^10.3.8",
|
|
774
|
+
"@nestjs/platform-express": "^10.3.8",
|
|
775
|
+
"reflect-metadata": "^0.2.2",
|
|
776
|
+
rxjs: "^7.8.1",
|
|
777
|
+
},
|
|
778
|
+
devDependencies: {
|
|
779
|
+
"@nestjs/cli": "^10.4.2",
|
|
780
|
+
"@nestjs/schematics": "^10.1.3",
|
|
781
|
+
"@types/express": "^4.17.21",
|
|
782
|
+
"@types/node": "^20.14.0",
|
|
783
|
+
typescript: "^5.5.3",
|
|
784
|
+
},
|
|
785
|
+
}),
|
|
786
|
+
},
|
|
787
|
+
{
|
|
788
|
+
path: "tsconfig.json",
|
|
789
|
+
content: pkg({
|
|
790
|
+
compilerOptions: {
|
|
791
|
+
module: "commonjs",
|
|
792
|
+
declaration: true,
|
|
793
|
+
removeComments: true,
|
|
794
|
+
emitDecoratorMetadata: true,
|
|
795
|
+
experimentalDecorators: true,
|
|
796
|
+
allowSyntheticDefaultImports: true,
|
|
797
|
+
target: "ES2021",
|
|
798
|
+
sourceMap: true,
|
|
799
|
+
outDir: "./dist",
|
|
800
|
+
baseUrl: "./",
|
|
801
|
+
increment: true,
|
|
802
|
+
skipLibCheck: true,
|
|
803
|
+
strictNullChecks: false,
|
|
804
|
+
noImplicitAny: false,
|
|
805
|
+
strictBindCallApply: false,
|
|
806
|
+
forceConsistentCasingInFileNames: false,
|
|
807
|
+
noFallthroughCasesInSwitch: false,
|
|
808
|
+
},
|
|
809
|
+
}),
|
|
810
|
+
},
|
|
811
|
+
{
|
|
812
|
+
path: "tsconfig.build.json",
|
|
813
|
+
content: pkg({
|
|
814
|
+
extends: "./tsconfig.json",
|
|
815
|
+
exclude: ["node_modules", "test", "dist", "**/*spec.ts"],
|
|
816
|
+
}),
|
|
817
|
+
},
|
|
818
|
+
{
|
|
819
|
+
path: "nest-cli.json",
|
|
820
|
+
content: pkg({
|
|
821
|
+
$schema: "https://json.schemastore.org/nest-cli",
|
|
822
|
+
collection: "@nestjs/schematics",
|
|
823
|
+
sourceRoot: "src",
|
|
824
|
+
compilerOptions: {
|
|
825
|
+
deleteOutDir: true,
|
|
826
|
+
},
|
|
827
|
+
}),
|
|
828
|
+
},
|
|
829
|
+
{
|
|
830
|
+
path: "src/main.ts",
|
|
831
|
+
content: `import { NestFactory } from "@nestjs/core";
|
|
832
|
+
import { AppModule } from "./app.module";
|
|
833
|
+
|
|
834
|
+
async function bootstrap() {
|
|
835
|
+
const app = await NestFactory.create(AppModule);
|
|
836
|
+
await app.listen(3000);
|
|
837
|
+
console.log("Application is running on: http://localhost:3000");
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
bootstrap();
|
|
841
|
+
`,
|
|
842
|
+
},
|
|
843
|
+
{
|
|
844
|
+
path: "src/app.module.ts",
|
|
845
|
+
content: `import { Module } from "@nestjs/common";
|
|
846
|
+
import { AppController } from "./app.controller";
|
|
847
|
+
import { AppService } from "./app.service";
|
|
848
|
+
|
|
849
|
+
@Module({
|
|
850
|
+
imports: [],
|
|
851
|
+
controllers: [AppController],
|
|
852
|
+
providers: [AppService],
|
|
853
|
+
})
|
|
854
|
+
export class AppModule {}
|
|
855
|
+
`,
|
|
856
|
+
},
|
|
857
|
+
{
|
|
858
|
+
path: "src/app.controller.ts",
|
|
859
|
+
content: `import { Controller, Get } from "@nestjs/common";
|
|
860
|
+
import { AppService } from "./app.service";
|
|
861
|
+
|
|
862
|
+
@Controller()
|
|
863
|
+
export class AppController {
|
|
864
|
+
constructor(private readonly appService: AppService) {}
|
|
865
|
+
|
|
866
|
+
@Get()
|
|
867
|
+
getHello(): string {
|
|
868
|
+
return this.appService.getHello();
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
`,
|
|
872
|
+
},
|
|
873
|
+
{
|
|
874
|
+
path: "src/app.service.ts",
|
|
875
|
+
content: `import { Injectable } from "@nestjs/common";
|
|
876
|
+
|
|
877
|
+
@Injectable()
|
|
878
|
+
export class AppService {
|
|
879
|
+
getHello(): string {
|
|
880
|
+
return "Hello World!";
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
`,
|
|
884
|
+
},
|
|
885
|
+
];
|
|
886
|
+
return {
|
|
887
|
+
name: "NestJS",
|
|
888
|
+
framework: "nest",
|
|
889
|
+
directories: ["src"],
|
|
890
|
+
files,
|
|
891
|
+
dependencies: {
|
|
892
|
+
"@nestjs/common": "^10.3.8",
|
|
893
|
+
"@nestjs/core": "^10.3.8",
|
|
894
|
+
"@nestjs/platform-express": "^10.3.8",
|
|
895
|
+
"reflect-metadata": "^0.2.2",
|
|
896
|
+
rxjs: "^7.8.1",
|
|
897
|
+
},
|
|
898
|
+
devDependencies: {
|
|
899
|
+
"@nestjs/cli": "^10.4.2",
|
|
900
|
+
typescript: "^5.5.3",
|
|
901
|
+
},
|
|
902
|
+
};
|
|
903
|
+
}
|
|
904
|
+
function getTemplate(options) {
|
|
905
|
+
switch (options.framework) {
|
|
906
|
+
case "react":
|
|
907
|
+
return reactTemplate(options);
|
|
908
|
+
case "nextjs":
|
|
909
|
+
return nextjsTemplate(options);
|
|
910
|
+
case "express":
|
|
911
|
+
return expressTemplate(options);
|
|
912
|
+
case "node-cli":
|
|
913
|
+
return nodeCliTemplate(options);
|
|
914
|
+
case "discord-bot":
|
|
915
|
+
return discordBotTemplate(options);
|
|
916
|
+
case "fastapi":
|
|
917
|
+
return fastApiTemplate(options);
|
|
918
|
+
case "nest":
|
|
919
|
+
return nestTemplate(options);
|
|
920
|
+
default:
|
|
921
|
+
return reactTemplate(options);
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
//# sourceMappingURL=templates.js.map
|