create-backlist 6.1.9 → 6.2.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-backlist",
3
- "version": "6.1.9",
3
+ "version": "6.2.1",
4
4
  "description": "An advanced, multi-language backend generator based on frontend analysis.",
5
5
  "type": "commonjs",
6
6
  "bin": {
@@ -68,7 +68,6 @@ async function appendApplicationProperties(projectDir, artifactId) {
68
68
  }
69
69
 
70
70
  function buildModelsFromEndpoints(endpoints) {
71
- // Create models even when schemaFields is null (GET-only APIs).
72
71
  const modelsToGenerate = new Map();
73
72
 
74
73
  (Array.isArray(endpoints) ? endpoints : []).forEach((ep) => {
@@ -161,7 +160,6 @@ async function generateJavaProject(options) {
161
160
 
162
161
  const modelsToGenerate = buildModelsFromEndpoints(endpoints);
163
162
 
164
- // Spring Initializr extracts into projectDir directly. Java package folder:
165
163
  const javaSrcRoot = path.join(
166
164
  projectDir,
167
165
  "src",
@@ -171,7 +169,6 @@ async function generateJavaProject(options) {
171
169
  artifactId.replace(/-/g, "")
172
170
  );
173
171
 
174
- // Always ensure base package dirs exist
175
172
  await fs.ensureDir(javaSrcRoot);
176
173
 
177
174
  if (modelsToGenerate.size > 0) {
@@ -186,22 +183,23 @@ async function generateJavaProject(options) {
186
183
  await fs.ensureDir(controllerDir);
187
184
 
188
185
  for (const model of modelsToGenerate.values()) {
186
+ // FIXED: Added 'group' key to all renderAndWrite calls
189
187
  await renderAndWrite(
190
188
  getTemplatePath("java-spring/partials/Entity.java.ejs"),
191
189
  path.join(entityDir, `${model.name}.java`),
192
- { projectName, groupId, artifactId, model }
190
+ { projectName, groupId, artifactId, group: groupId, model }
193
191
  );
194
192
 
195
193
  await renderAndWrite(
196
194
  getTemplatePath("java-spring/partials/Repository.java.ejs"),
197
195
  path.join(repoDir, `${model.name}Repository.java`),
198
- { projectName, groupId, artifactId, model }
196
+ { projectName, groupId, artifactId, group: groupId, model }
199
197
  );
200
198
 
201
199
  await renderAndWrite(
202
200
  getTemplatePath("java-spring/partials/Controller.java.ejs"),
203
201
  path.join(controllerDir, `${model.name}Controller.java`),
204
- { projectName, groupId, artifactId, model }
202
+ { projectName, groupId, artifactId, group: groupId, model }
205
203
  );
206
204
  }
207
205
  } else {
@@ -215,10 +213,8 @@ async function generateJavaProject(options) {
215
213
  console.log(chalk.cyan(` cd ${path.basename(projectDir)}`));
216
214
  console.log(chalk.cyan(" ./mvnw spring-boot:run # or use your IDE to run the Application class"));
217
215
  } catch (error) {
218
- // Better Initializr error print
219
216
  if (error && error.response && error.response.status) {
220
217
  console.error(chalk.red(` -> Initializr error status: ${error.response.status}`));
221
-
222
218
  try {
223
219
  if (error.response.data) {
224
220
  let text = "";
@@ -228,10 +224,8 @@ async function generateJavaProject(options) {
228
224
  } catch {
229
225
  // ignore
230
226
  }
231
-
232
227
  throw new Error(`Failed to download from Spring Initializr. Status: ${error.response.status}`);
233
228
  }
234
-
235
229
  throw error;
236
230
  }
237
231
  }
@@ -12,7 +12,6 @@ function stripQuery(p) {
12
12
  }
13
13
 
14
14
  function safePascalName(name) {
15
- // remove query + invalid filename chars, keep alphanumerics only
16
15
  const cleaned = String(name || "Default")
17
16
  .split("?")[0]
18
17
  .replace(/[^a-zA-Z0-9]/g, "");
@@ -25,10 +24,8 @@ function sanitizeEndpoints(endpoints) {
25
24
  if (!Array.isArray(endpoints)) return [];
26
25
 
27
26
  return endpoints.map((ep) => {
28
- // IMPORTANT: strip query string so it never leaks into names
29
27
  const rawPath = stripQuery(ep.path || ep.route || "/");
30
28
 
31
- // remove empty, api, and version segments (v1/v2/v10...)
32
29
  const parts = rawPath
33
30
  .split("/")
34
31
  .filter(Boolean)
@@ -39,7 +36,6 @@ function sanitizeEndpoints(endpoints) {
39
36
 
40
37
  let functionName = "";
41
38
 
42
- // AUTH naming
43
39
  if (controllerName.toLowerCase() === "auth") {
44
40
  if (rawPath.includes("login")) functionName = "loginUser";
45
41
  else if (rawPath.includes("register")) functionName = "registerUser";
@@ -54,9 +50,9 @@ function sanitizeEndpoints(endpoints) {
54
50
  const method = String(ep.method || "GET").toUpperCase();
55
51
 
56
52
  const hasId =
57
- rawPath.includes(":") || // :id style
58
- rawPath.includes("{") || // {id} style
59
- /\/\d+/.test(rawPath); // numeric
53
+ rawPath.includes(":") ||
54
+ rawPath.includes("{") ||
55
+ /\/\d+/.test(rawPath);
60
56
 
61
57
  if (method === "GET") {
62
58
  functionName = hasId ? `get${pascalSingular}ById` : `getAll${pascalPlural}`;
@@ -71,7 +67,6 @@ function sanitizeEndpoints(endpoints) {
71
67
  }
72
68
  }
73
69
 
74
- // return with clean path (query removed)
75
70
  return { ...ep, path: rawPath, controllerName, functionName };
76
71
  });
77
72
  }
@@ -107,7 +102,6 @@ async function generateNodeProject(options) {
107
102
 
108
103
  endpoints.forEach((ep) => {
109
104
  if (!ep) return;
110
-
111
105
  const ctrl = safePascalName(ep.controllerName);
112
106
  if (ctrl === "Default" || ctrl === "Auth") return;
113
107
 
@@ -263,7 +257,7 @@ async function generateNodeProject(options) {
263
257
  );
264
258
  }
265
259
 
266
- // --- Step 8: Extras ---
260
+ // --- Step 8: Extras (FIXED) ---
267
261
  if (extraFeatures.includes("docker")) {
268
262
  console.log(chalk.blue(" -> Generating Docker files..."));
269
263
  await renderAndWrite(
@@ -281,10 +275,11 @@ async function generateNodeProject(options) {
281
275
  if (extraFeatures.includes("swagger")) {
282
276
  console.log(chalk.blue(" -> Generating API documentation setup..."));
283
277
  await fs.ensureDir(path.join(destSrcDir, "utils"));
278
+ // FIX: Added 'paths' to the EJS data object
284
279
  await renderAndWrite(
285
280
  getTemplatePath("node-ts-express/partials/ApiDocs.ts.ejs"),
286
281
  path.join(destSrcDir, "utils", "swagger.ts"),
287
- { projectName, port, addAuth }
282
+ { projectName, port, addAuth, paths: endpoints }
288
283
  );
289
284
  }
290
285