create-backlist 6.0.9 → 6.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-backlist",
3
- "version": "6.0.9",
3
+ "version": "6.1.0",
4
4
  "description": "An advanced, multi-language backend generator based on frontend analysis.",
5
5
  "type": "commonjs",
6
6
  "bin": {
@@ -14,6 +14,8 @@ async function generateNodeProject(options) {
14
14
  try {
15
15
  // --- Step 1: Analyze Frontend ---
16
16
  console.log(chalk.blue(' -> Analyzing frontend for API endpoints...'));
17
+
18
+ // NOTE: 'let' use kala api endpoints wenas karana nisa
17
19
  let endpoints = await analyzeFrontend(frontendSrcDir);
18
20
 
19
21
  if (endpoints.length > 0) {
@@ -23,18 +25,19 @@ async function generateNodeProject(options) {
23
25
  // 🔥 FIX START: Sanitizing Endpoints Logic
24
26
  // ============================================================
25
27
  endpoints = endpoints.map(ep => {
26
- // 1. Path එක සුද්ද කිරීම (/api/v1/users -> ['users'])
27
- // 'api', 'v1', හිස්තැන් අයින් කරනවා
28
+ // 1. Path eka sudda kirima (/api/v1/users -> ['users'])
29
+ // 'api', 'v1', histhan ain karanawa
28
30
  const parts = ep.path.split('/').filter(part => part !== '' && part !== 'api' && part !== 'v1');
29
31
 
30
- // Resource එක හොයාගැනීම (e.g., 'users')
32
+ // Resource eka hoyaganeema (e.g., 'users')
31
33
  let resource = parts[0] || 'Default';
32
34
 
33
- // 2. Controller Name එක හැදීම (CamelCase: 'users' -> 'Users')
34
- // Special Case: resource එක 'auth' නම් Controller එක 'Auth'
35
+ // 2. Controller Name eka hadeema (CamelCase: 'users' -> 'Users')
36
+ // Special Case: resource eka 'auth' nam Controller eka 'Auth'
37
+ // 'V1' kiyana eka ain wenne methanin
35
38
  let controllerName = resource.charAt(0).toUpperCase() + resource.slice(1);
36
39
 
37
- // 3. Function Names හරියටම මැප් කිරීම
40
+ // 3. Function Names hariyatama map kirima
38
41
  let functionName = '';
39
42
 
40
43
  // --- AUTH LOGIC ---
@@ -45,8 +48,7 @@ async function generateNodeProject(options) {
45
48
  }
46
49
  // --- GENERAL RESOURCES LOGIC ---
47
50
  else {
48
- // 'users' -> 'User' (Singular form for function names like createUser)
49
- // 'users' -> 'Users' (Plural form for lists)
51
+ // Singular/Plural logic to avoid 'Userss'
50
52
  const singularName = resource.endsWith('s') ? resource.slice(0, -1) : resource;
51
53
  const pluralName = resource.endsWith('s') ? resource : resource + 's';
52
54
 
@@ -68,10 +70,11 @@ async function generateNodeProject(options) {
68
70
  }
69
71
 
70
72
  // Update the endpoint object
73
+ // meka ejs file ekedi <%= ep.functionName %> kiyala use karanna puluwan
71
74
  return {
72
75
  ...ep,
73
76
  controllerName,
74
- functionName // ejs file එකේදි <%= ep.functionName %> කියලා පාවිච්චි කරන්න පුළුවන් දැන්
77
+ functionName
75
78
  };
76
79
  });
77
80
  // ============================================================
@@ -85,7 +88,8 @@ async function generateNodeProject(options) {
85
88
  // --- Step 2: Identify Models to Generate ---
86
89
  const modelsToGenerate = new Map();
87
90
  endpoints.forEach(ep => {
88
- // Default සහ Auth වලට Model හදන්න ඕන නෑ (Auth එකට User Model එක යටින් හදනවා)
91
+ // Default saha Auth walata Model hadanna ona na (Auth ekata User Model eka yatin hadanawa)
92
+ // ep.controllerName dan hariyatama 'Users' kiyala enawa, 'V1' enne na.
89
93
  if (ep.schemaFields && ep.controllerName !== 'Default' && ep.controllerName !== 'Auth' && !modelsToGenerate.has(ep.controllerName)) {
90
94
  modelsToGenerate.set(ep.controllerName, {
91
95
  name: ep.controllerName,
@@ -160,7 +164,7 @@ async function generateNodeProject(options) {
160
164
  console.log(chalk.blue(' -> Generating controllers...'));
161
165
  for (const [modelName] of modelsToGenerate.entries()) {
162
166
  const templateFile = dbType === 'mongoose' ? 'Controller.ts.ejs' : 'PrismaController.ts.ejs';
163
- // මෙතන Controller එක හදද්දි Auth එක Skip කරනවා (මොකද ඒක පහළ වෙනම හදනවා)
167
+ // Controller hadaddi Auth eka skip karanawa (mokada eka yatin wenama hadanawa)
164
168
  if (modelName !== 'Auth') {
165
169
  await renderAndWrite(getTemplatePath(`node-ts-express/partials/${templateFile}`), path.join(destSrcDir, 'controllers', `${modelName}.controller.ts`), { modelName, projectName });
166
170
  }
@@ -217,7 +221,7 @@ async function generateNodeProject(options) {
217
221
  }
218
222
 
219
223
  // --- Step 9: Generate Main Route File & Inject Logic into Server ---
220
- // Updated endpoints passed here
224
+ // IMPORTANT: 'endpoints' variable eka dan sanitized version eka.
221
225
  await renderAndWrite(getTemplatePath('node-ts-express/partials/routes.ts.ejs'), path.join(destSrcDir, 'routes.ts'), { endpoints, addAuth, dbType });
222
226
 
223
227
  let serverFileContent = await fs.readFile(path.join(destSrcDir, 'server.ts'), 'utf-8');