neatnode 3.1.5 → 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/bin/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import("../src/cli.js");
2
+ import "../src/cli.js";
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "neatnode",
3
- "version": "3.1.5",
3
+ "version": "3.1.7",
4
4
  "description": "Plug & Play Node.js backend starter templates — build REST APIs, socket servers, and more in seconds.",
5
5
  "bin": {
6
- "neatnode": "./bin/index.js"
6
+ "neatnode": "bin/index.js"
7
7
  },
8
8
  "keywords": [
9
9
  "nodejs",
@@ -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 }) {
12
+ export async function createProject({ projectName, repoPath, includeCrud, crudName, langKey, isModular }) {
13
13
  try {
14
14
  const targetPath = projectName === "."
15
15
  ? process.cwd()
@@ -33,10 +33,17 @@ 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
- removeCrud(targetPath, crudName);
39
- removeCrudReferences(path.join(targetPath, "src", "app.js"));
38
+
39
+ if (isModular) {
40
+ removeCrudModule(targetPath, crudName);
41
+ removeCrudReferences(path.join(targetPath, "src", `routes/index.route.${langKey}`));
42
+
43
+ }
44
+
45
+ removeCrud(targetPath, crudName, langKey);
46
+ removeCrudReferences(path.join(targetPath, "src", `app.${langKey}`));
40
47
  }
41
48
 
42
49
  console.log(`\nāœ… Project "${projectName}" created successfully!\n`);
@@ -2,16 +2,16 @@ import fs from "fs";
2
2
  import path from "path";
3
3
 
4
4
 
5
- export function removeCrud(targetPath, name) {
5
+ export function removeCrud(targetPath, name, langKey) {
6
6
  try {
7
7
  const crudPaths = [
8
- `src/models/${name}.model.js`,
9
- `src/controllers/${name}.controller.js`,
10
- `src/routes/${name}.route.js`,
11
- `src/services/${name}.service.js`,
12
- `src/validations/${name}.validation.js`,
13
- "src/middlewares/auth.middleware.js",
14
- `src/schemas/${name}.schema.js`
8
+ `src/models/${name}.model.${langKey}`,
9
+ `src/controllers/${name}.controller.${langKey}`,
10
+ `src/routes/${name}.route.${langKey}`,
11
+ `src/services/${name}.service.${langKey}`,
12
+ `src/validations/${name}.validation.${langKey}`,
13
+ `src/middlewares/auth.middleware.${langKey}`,
14
+ `src/schemas/${name}.schema.${langKey}`
15
15
  ];
16
16
 
17
17
  crudPaths.forEach(relPath => {
@@ -29,7 +29,6 @@ export function removeCrud(targetPath, name) {
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") {
@@ -72,13 +73,40 @@ async function main() {
72
73
  crudName = "user";
73
74
  }
74
75
 
76
+ if (chosen.name === "Basic Express (TS)") {
77
+ const { includeCrud: answer } = await inquirer.prompt([
78
+ {
79
+ type: "confirm",
80
+ name: "includeCrud",
81
+ message: "Include example Todo CRUD?",
82
+ default: true,
83
+ },
84
+ ]);
85
+ includeCrud = answer;
86
+ crudName = "todo";
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
+ }
101
+
75
102
  // STEP 5 — Create Project (Remote download logic inside)
76
103
  await createProject({
77
104
  projectName,
78
105
  repoPath: chosen.repoPath,
79
106
  includeCrud,
80
107
  crudName,
81
- language: langKey,
108
+ langKey,
109
+ isModular,
82
110
  });
83
111
 
84
112
 
@@ -7,7 +7,7 @@ export default {
7
7
 
8
8
  ts: [
9
9
  { name: "Basic Express (TS)", repoPath: "templates/ts/basic-express" },
10
- // { name: "REST API (TS)", repoPath: "templates/ts/express-rest-api" },
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
  };