create-yassin 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 +98 -0
- package/myapp/backend/index.html +0 -0
- package/myapp/backend/server.js +40 -0
- package/myapp/backend/{ +0 -0
- package/myapp/myapp/backend/server.js +13 -0
- package/myapp/myapp/frontend/index.html +16 -0
- package/package.json +22 -0
package/index.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const chalk = require("chalk");
|
|
6
|
+
|
|
7
|
+
// input sentence
|
|
8
|
+
const input = process.argv.slice(2).join(" ").toLowerCase();
|
|
9
|
+
|
|
10
|
+
// š FIX: dynamic project name
|
|
11
|
+
const projectName = "myapp";
|
|
12
|
+
const project = path.join(process.cwd(), projectName);
|
|
13
|
+
|
|
14
|
+
// SAFE CLEAN
|
|
15
|
+
if (fs.existsSync(project)) {
|
|
16
|
+
fs.rmSync(project, { recursive: true, force: true });
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// SAFE CREATE
|
|
20
|
+
fs.mkdirSync(project, { recursive: true });
|
|
21
|
+
fs.mkdirSync(path.join(project, "backend"), { recursive: true });
|
|
22
|
+
fs.mkdirSync(path.join(project, "backend/routes"), { recursive: true });
|
|
23
|
+
fs.mkdirSync(path.join(project, "backend/models"), { recursive: true });
|
|
24
|
+
fs.mkdirSync(path.join(project, "frontend"), { recursive: true });
|
|
25
|
+
fs.mkdirSync(path.join(project, "frontend/pages"), { recursive: true });
|
|
26
|
+
|
|
27
|
+
// ================= AI ENGINE =================
|
|
28
|
+
function systemName(text) {
|
|
29
|
+
if (text.includes("hospital")) return "Hospital Management System";
|
|
30
|
+
if (text.includes("school")) return "School Management System";
|
|
31
|
+
if (text.includes("exam")) return "Exam Management System";
|
|
32
|
+
if (text.includes("shop") || text.includes("ecommerce")) return "E-Commerce System";
|
|
33
|
+
return "Custom AI Generated System";
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function modules(text) {
|
|
37
|
+
let mods = [];
|
|
38
|
+
|
|
39
|
+
if (text.includes("hospital")) mods.push("patients", "doctors");
|
|
40
|
+
if (text.includes("appointment")) mods.push("appointments");
|
|
41
|
+
if (text.includes("billing") || text.includes("payment")) mods.push("billing");
|
|
42
|
+
|
|
43
|
+
if (text.includes("school")) mods.push("students", "teachers", "classes");
|
|
44
|
+
if (text.includes("exam")) mods.push("questions", "results");
|
|
45
|
+
|
|
46
|
+
if (mods.length === 0) mods = ["dashboard", "users"];
|
|
47
|
+
|
|
48
|
+
return [...new Set(mods)];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const system = systemName(input);
|
|
52
|
+
const mods = modules(input);
|
|
53
|
+
|
|
54
|
+
// UI
|
|
55
|
+
console.log(chalk.cyan("\nš¤ Yassin AI Builder"));
|
|
56
|
+
console.log(chalk.green("š Generating: " + system));
|
|
57
|
+
|
|
58
|
+
// BACKEND
|
|
59
|
+
const backendCode = `
|
|
60
|
+
const express = require("express");
|
|
61
|
+
const app = express();
|
|
62
|
+
|
|
63
|
+
app.use(express.json());
|
|
64
|
+
|
|
65
|
+
app.get("/", (req,res)=>{
|
|
66
|
+
res.send("${system} running š");
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
app.listen(5000, ()=>{
|
|
70
|
+
console.log("Backend running on port 5000");
|
|
71
|
+
});
|
|
72
|
+
`;
|
|
73
|
+
|
|
74
|
+
// FRONTEND
|
|
75
|
+
const frontendCode = `
|
|
76
|
+
<!DOCTYPE html>
|
|
77
|
+
<html>
|
|
78
|
+
<head>
|
|
79
|
+
<title>${system}</title>
|
|
80
|
+
</head>
|
|
81
|
+
<body>
|
|
82
|
+
<h1>${system}</h1>
|
|
83
|
+
<h3>Modules:</h3>
|
|
84
|
+
<ul>
|
|
85
|
+
${mods.map(m => `<li>${m}</li>`).join("\n")}
|
|
86
|
+
</ul>
|
|
87
|
+
</body>
|
|
88
|
+
</html>
|
|
89
|
+
`;
|
|
90
|
+
|
|
91
|
+
// WRITE FILES
|
|
92
|
+
fs.writeFileSync(path.join(project, "backend/server.js"), backendCode);
|
|
93
|
+
fs.writeFileSync(path.join(project, "frontend/index.html"), frontendCode);
|
|
94
|
+
|
|
95
|
+
// FINAL OUTPUT
|
|
96
|
+
console.log(chalk.yellow("\nš¦ Modules: " + mods.join(", ")));
|
|
97
|
+
console.log(chalk.green("\nā
System Generated Successfully!"));
|
|
98
|
+
console.log(chalk.blue("\nš Run: cd myapp && npm install express && node backend/server.js"));
|
|
File without changes
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const express = require("express");
|
|
2
|
+
const app = express();
|
|
3
|
+
|
|
4
|
+
app.use(express.json());
|
|
5
|
+
|
|
6
|
+
let data = [];
|
|
7
|
+
|
|
8
|
+
// HOME ROUTE (NEW)
|
|
9
|
+
app.get("/", (req, res) => {
|
|
10
|
+
res.send("Backend is working š");
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
// CREATE
|
|
14
|
+
app.post("/api/add", (req,res)=>{
|
|
15
|
+
data.push(req.body);
|
|
16
|
+
res.json({ message: "Added", data });
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// READ
|
|
20
|
+
app.get("/api/all", (req,res)=>{
|
|
21
|
+
res.json(data);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// UPDATE
|
|
25
|
+
app.put("/api/update/:id", (req,res)=>{
|
|
26
|
+
const id = req.params.id;
|
|
27
|
+
data[id] = req.body;
|
|
28
|
+
res.json({ message: "Updated", data });
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// DELETE
|
|
32
|
+
app.delete("/api/delete/:id", (req,res)=>{
|
|
33
|
+
const id = req.params.id;
|
|
34
|
+
data.splice(id,1);
|
|
35
|
+
res.json({ message: "Deleted", data });
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
app.listen(5000, ()=>{
|
|
39
|
+
console.log("Backend running on port 5000");
|
|
40
|
+
});
|
package/myapp/backend/{
ADDED
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
|
|
2
|
+
const express = require("express");
|
|
3
|
+
const app = express();
|
|
4
|
+
|
|
5
|
+
app.use(express.json());
|
|
6
|
+
|
|
7
|
+
app.get("/", (req,res)=>{
|
|
8
|
+
res.send("AI Generated System running š");
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
app.listen(5000, ()=>{
|
|
12
|
+
console.log("Backend running on port 5000");
|
|
13
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-yassin",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Yassin CLI system generator",
|
|
5
|
+
"bin": {
|
|
6
|
+
"create-yassin": "./index.js"
|
|
7
|
+
},
|
|
8
|
+
"keywords": [
|
|
9
|
+
"cli",
|
|
10
|
+
"generator",
|
|
11
|
+
"scaffold"
|
|
12
|
+
],
|
|
13
|
+
"author": "Yassin",
|
|
14
|
+
"license": "ISC",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"chalk": "^4.1.2",
|
|
17
|
+
"express": "^5.2.1",
|
|
18
|
+
"fs-extra": "^11.3.5",
|
|
19
|
+
"mongoose": "^9.6.2",
|
|
20
|
+
"readline-sync": "^1.4.10"
|
|
21
|
+
}
|
|
22
|
+
}
|