neatnode 3.1.6 → 3.1.7
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/package.json +1 -1
- package/src/actions/createProject.js +10 -3
- package/src/actions/removeCRUD.js +14 -1
- package/src/cli.js +16 -1
- package/src/config/templates.js +1 -1
package/package.json
CHANGED
|
@@ -3,13 +3,13 @@ import path from "path";
|
|
|
3
3
|
import os from "os";
|
|
4
4
|
import { fileURLToPath } from "url";
|
|
5
5
|
import { copyTemplate } from "../utils/copyTemplate.js";
|
|
6
|
-
import { removeCrud, removeCrudReferences } from "./removeCRUD.js";
|
|
6
|
+
import { removeCrud, removeCrudModule, removeCrudReferences } from "./removeCRUD.js";
|
|
7
7
|
import { downloadTemplate } from "../utils/downloadRepoTemplate.js";
|
|
8
8
|
|
|
9
9
|
const __filename = fileURLToPath(import.meta.url);
|
|
10
10
|
const __dirname = path.dirname(__filename);
|
|
11
11
|
|
|
12
|
-
export async function createProject({ projectName, repoPath, includeCrud, crudName, langKey }) {
|
|
12
|
+
export async function createProject({ projectName, repoPath, includeCrud, crudName, langKey, isModular }) {
|
|
13
13
|
try {
|
|
14
14
|
const targetPath = projectName === "."
|
|
15
15
|
? process.cwd()
|
|
@@ -33,8 +33,15 @@ export async function createProject({ projectName, repoPath, includeCrud, crudNa
|
|
|
33
33
|
"author": os.userInfo().username || "author",
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
-
if (!includeCrud && crudName
|
|
36
|
+
if (!includeCrud && crudName) {
|
|
37
37
|
console.log("🗑 Removing CRUD files...");
|
|
38
|
+
|
|
39
|
+
if (isModular) {
|
|
40
|
+
removeCrudModule(targetPath, crudName);
|
|
41
|
+
removeCrudReferences(path.join(targetPath, "src", `routes/index.route.${langKey}`));
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
38
45
|
removeCrud(targetPath, crudName, langKey);
|
|
39
46
|
removeCrudReferences(path.join(targetPath, "src", `app.${langKey}`));
|
|
40
47
|
}
|
|
@@ -29,7 +29,6 @@ export function removeCrud(targetPath, name, langKey) {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
|
|
33
32
|
export function removeCrudReferences(appJsPath) {
|
|
34
33
|
let content = fs.readFileSync(appJsPath, "utf8");
|
|
35
34
|
|
|
@@ -47,3 +46,17 @@ export function removeCrudReferences(appJsPath) {
|
|
|
47
46
|
|
|
48
47
|
fs.writeFileSync(appJsPath, content, "utf8");
|
|
49
48
|
}
|
|
49
|
+
|
|
50
|
+
export function removeCrudModule(targetPath, name) {
|
|
51
|
+
try {
|
|
52
|
+
const modulePath = path.join(targetPath, `src/modules/${name}`);
|
|
53
|
+
if (fs.existsSync(modulePath)) {
|
|
54
|
+
fs.rmSync(modulePath, { recursive: true, force: true });
|
|
55
|
+
console.log(`✔ Removed module: ${name}`);
|
|
56
|
+
} else {
|
|
57
|
+
console.log(`Skipped module (not found): ${name}`);
|
|
58
|
+
}
|
|
59
|
+
} catch (err) {
|
|
60
|
+
console.error("❌ Error while removing CRUD module:", err.message);
|
|
61
|
+
}
|
|
62
|
+
}
|
package/src/cli.js
CHANGED
|
@@ -44,6 +44,7 @@ async function main() {
|
|
|
44
44
|
|
|
45
45
|
// STEP 4 — CRUD Optional (only for some templates)
|
|
46
46
|
let includeCrud = false;
|
|
47
|
+
let isModular = chosen.isModular || false;
|
|
47
48
|
let crudName = "";
|
|
48
49
|
|
|
49
50
|
if (chosen.name === "Basic Express") {
|
|
@@ -77,13 +78,26 @@ async function main() {
|
|
|
77
78
|
{
|
|
78
79
|
type: "confirm",
|
|
79
80
|
name: "includeCrud",
|
|
80
|
-
message: "Include example
|
|
81
|
+
message: "Include example Todo CRUD?",
|
|
81
82
|
default: true,
|
|
82
83
|
},
|
|
83
84
|
]);
|
|
84
85
|
includeCrud = answer;
|
|
85
86
|
crudName = "todo";
|
|
86
87
|
}
|
|
88
|
+
if (chosen.name === "REST API (TS)") {
|
|
89
|
+
const { includeCrud: answer } = await inquirer.prompt([
|
|
90
|
+
{
|
|
91
|
+
type: "confirm",
|
|
92
|
+
name: "includeCrud",
|
|
93
|
+
message: "Include example Auth CRUD?",
|
|
94
|
+
default: true,
|
|
95
|
+
},
|
|
96
|
+
]);
|
|
97
|
+
includeCrud = answer;
|
|
98
|
+
crudName = "auth";
|
|
99
|
+
isModular = chosen.isModular;
|
|
100
|
+
}
|
|
87
101
|
|
|
88
102
|
// STEP 5 — Create Project (Remote download logic inside)
|
|
89
103
|
await createProject({
|
|
@@ -92,6 +106,7 @@ async function main() {
|
|
|
92
106
|
includeCrud,
|
|
93
107
|
crudName,
|
|
94
108
|
langKey,
|
|
109
|
+
isModular,
|
|
95
110
|
});
|
|
96
111
|
|
|
97
112
|
|
package/src/config/templates.js
CHANGED
|
@@ -7,7 +7,7 @@ export default {
|
|
|
7
7
|
|
|
8
8
|
ts: [
|
|
9
9
|
{ name: "Basic Express (TS)", repoPath: "templates/ts/basic-express" },
|
|
10
|
-
|
|
10
|
+
{ name: "REST API (TS)", repoPath: "templates/ts/express-rest-api", isModular: true },
|
|
11
11
|
// { name: "Socket.IO (TS)", repoPath: "templates/ts/express-socket" },
|
|
12
12
|
],
|
|
13
13
|
};
|