create-backlist 6.1.0 → 6.1.3

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.0",
3
+ "version": "6.1.3",
4
4
  "description": "An advanced, multi-language backend generator based on frontend analysis.",
5
5
  "type": "commonjs",
6
6
  "bin": {
@@ -88,12 +88,19 @@ async function generateNodeProject(options) {
88
88
  // --- Step 2: Identify Models to Generate ---
89
89
  const modelsToGenerate = new Map();
90
90
  endpoints.forEach(ep => {
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.
93
- if (ep.schemaFields && ep.controllerName !== 'Default' && ep.controllerName !== 'Auth' && !modelsToGenerate.has(ep.controllerName)) {
91
+ // 🔥 FIX: 'ep.schemaFields' තිබ්බත් නැතත් Controller එක හදන්න ඕන.
92
+ // නැත්නම් Routes Import එකේදි Error එනවා.
93
+ if (ep.controllerName !== 'Default' && ep.controllerName !== 'Auth' && !modelsToGenerate.has(ep.controllerName)) {
94
+
95
+ // Schema Fields නැත්නම් හිස් Array එකක් ගන්න
96
+ let fields = [];
97
+ if (ep.schemaFields) {
98
+ fields = Object.entries(ep.schemaFields).map(([key, type]) => ({ name: key, type, isUnique: key === 'email' }));
99
+ }
100
+
94
101
  modelsToGenerate.set(ep.controllerName, {
95
102
  name: ep.controllerName,
96
- fields: Object.entries(ep.schemaFields).map(([key, type]) => ({ name: key, type, isUnique: key === 'email' }))
103
+ fields: fields
97
104
  });
98
105
  }
99
106
  });
@@ -221,10 +228,22 @@ async function generateNodeProject(options) {
221
228
  }
222
229
 
223
230
  // --- Step 9: Generate Main Route File & Inject Logic into Server ---
224
- // IMPORTANT: 'endpoints' variable eka dan sanitized version eka.
225
- await renderAndWrite(getTemplatePath('node-ts-express/partials/routes.ts.ejs'), path.join(destSrcDir, 'routes.ts'), { endpoints, addAuth, dbType });
231
+ // 🔥 FIX: Auth Endpoints ටික routes.ts එකට යවන්න එපා.
232
+ // මොකද ඒවා Auth.routes.ts එකෙන් වෙනම හැන්ඩ්ල් වෙනවා.
233
+ const nonAuthEndpoints = endpoints.filter(ep => ep.controllerName !== 'Auth');
234
+
235
+ // IMPORTANT: Pass 'nonAuthEndpoints' instead of 'endpoints'
236
+ await renderAndWrite(
237
+ getTemplatePath('node-ts-express/partials/routes.ts.ejs'),
238
+ path.join(destSrcDir, 'routes.ts'),
239
+ { endpoints: nonAuthEndpoints, addAuth, dbType }
240
+ );
226
241
 
227
242
  let serverFileContent = await fs.readFile(path.join(destSrcDir, 'server.ts'), 'utf-8');
243
+
244
+ // =========================================================================
245
+ // 👇 මේ ටික තමයි උඹේ Code එකෙන් Missing වෙලා තිබ්බේ. මේක නැතුව DB Connect වෙන්නේ නෑ.
246
+ // =========================================================================
228
247
  let dbConnectionCode = '', swaggerInjector = '', authRoutesInjector = '';
229
248
 
230
249
  if (dbType === 'mongoose') {
@@ -246,6 +265,8 @@ async function generateNodeProject(options) {
246
265
  const listenRegex = /(app\.listen\()/;
247
266
  serverFileContent = serverFileContent.replace(listenRegex, `${swaggerInjector}\n$1`);
248
267
  await fs.writeFile(path.join(destSrcDir, 'server.ts'), serverFileContent);
268
+ // =========================================================================
269
+
249
270
 
250
271
  // --- Step 10: Install Dependencies & Run Post-install Scripts ---
251
272
  console.log(chalk.magenta(' -> Installing dependencies... This may take a moment.'));