@open-mercato/cli 0.4.2-canary-eb5f87d5f9 → 0.4.2-canary-5035717565

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.
@@ -10,15 +10,6 @@ import {
10
10
  logGenerationResult,
11
11
  createGeneratorResult
12
12
  } from "../utils.js";
13
- function findModuleFile(basePath, ...segments) {
14
- const name = segments.pop();
15
- const dir = segments.length ? path.join(basePath, ...segments) : basePath;
16
- const tsPath = path.join(dir, `${name}.ts`);
17
- if (fs.existsSync(tsPath)) return tsPath;
18
- const jsPath = path.join(dir, `${name}.js`);
19
- if (fs.existsSync(jsPath)) return jsPath;
20
- return null;
21
- }
22
13
  async function generateModuleRegistry(options) {
23
14
  const { resolver, quiet = false } = options;
24
15
  const result = createGeneratorResult();
@@ -69,9 +60,9 @@ async function generateModuleRegistry(options) {
69
60
  const dashboardWidgets = [];
70
61
  const injectionWidgets = [];
71
62
  let injectionTableImportName = null;
72
- const appIndex = findModuleFile(roots.appBase, "index");
73
- const pkgIndex = findModuleFile(roots.pkgBase, "index");
74
- const indexTs = appIndex ?? pkgIndex;
63
+ const appIndex = path.join(roots.appBase, "index.ts");
64
+ const pkgIndex = path.join(roots.pkgBase, "index.ts");
65
+ const indexTs = fs.existsSync(appIndex) ? appIndex : fs.existsSync(pkgIndex) ? pkgIndex : null;
75
66
  if (indexTs) {
76
67
  infoImportName = `I${importId++}_${toVar(modId)}`;
77
68
  const importPath = indexTs.startsWith(roots.appBase) ? `${appImportBase}/index` : `${imps.pkgBase}/index`;
@@ -170,10 +161,10 @@ async function generateModuleRegistry(options) {
170
161
  }
171
162
  }
172
163
  {
173
- const appFile = findModuleFile(roots.appBase, "data", "extensions");
174
- const pkgFile = findModuleFile(roots.pkgBase, "data", "extensions");
175
- const hasApp = !!appFile;
176
- const hasPkg = !!pkgFile;
164
+ const appFile = path.join(roots.appBase, "data", "extensions.ts");
165
+ const pkgFile = path.join(roots.pkgBase, "data", "extensions.ts");
166
+ const hasApp = fs.existsSync(appFile);
167
+ const hasPkg = fs.existsSync(pkgFile);
177
168
  if (hasApp || hasPkg) {
178
169
  const importName = `X_${toVar(modId)}_${importId++}`;
179
170
  const importPath = hasApp ? `${appImportBase}/data/extensions` : `${imps.pkgBase}/data/extensions`;
@@ -182,22 +173,22 @@ async function generateModuleRegistry(options) {
182
173
  }
183
174
  }
184
175
  {
185
- const rootApp = findModuleFile(roots.appBase, "acl");
186
- const rootPkg = findModuleFile(roots.pkgBase, "acl");
187
- const hasRoot = rootApp || rootPkg;
176
+ const rootApp = path.join(roots.appBase, "acl.ts");
177
+ const rootPkg = path.join(roots.pkgBase, "acl.ts");
178
+ const hasRoot = fs.existsSync(rootApp) || fs.existsSync(rootPkg);
188
179
  if (hasRoot) {
189
180
  const importName = `ACL_${toVar(modId)}_${importId++}`;
190
- const useApp = rootApp ?? rootPkg;
181
+ const useApp = fs.existsSync(rootApp) ? rootApp : rootPkg;
191
182
  const importPath = useApp.startsWith(roots.appBase) ? `${appImportBase}/acl` : `${imps.pkgBase}/acl`;
192
183
  imports.push(`import * as ${importName} from '${importPath}'`);
193
184
  featuresImportName = importName;
194
185
  }
195
186
  }
196
187
  {
197
- const appFile = findModuleFile(roots.appBase, "ce");
198
- const pkgFile = findModuleFile(roots.pkgBase, "ce");
199
- const hasApp = !!appFile;
200
- const hasPkg = !!pkgFile;
188
+ const appFile = path.join(roots.appBase, "ce.ts");
189
+ const pkgFile = path.join(roots.pkgBase, "ce.ts");
190
+ const hasApp = fs.existsSync(appFile);
191
+ const hasPkg = fs.existsSync(pkgFile);
201
192
  if (hasApp || hasPkg) {
202
193
  const importName = `CE_${toVar(modId)}_${importId++}`;
203
194
  const importPath = hasApp ? `${appImportBase}/ce` : `${imps.pkgBase}/ce`;
@@ -206,10 +197,10 @@ async function generateModuleRegistry(options) {
206
197
  }
207
198
  }
208
199
  {
209
- const appFile = findModuleFile(roots.appBase, "search");
210
- const pkgFile = findModuleFile(roots.pkgBase, "search");
211
- const hasApp = !!appFile;
212
- const hasPkg = !!pkgFile;
200
+ const appFile = path.join(roots.appBase, "search.ts");
201
+ const pkgFile = path.join(roots.pkgBase, "search.ts");
202
+ const hasApp = fs.existsSync(appFile);
203
+ const hasPkg = fs.existsSync(pkgFile);
213
204
  if (hasApp || hasPkg) {
214
205
  const importName = `SEARCH_${toVar(modId)}_${importId++}`;
215
206
  const importPath = hasApp ? `${appImportBase}/search` : `${imps.pkgBase}/search`;
@@ -220,10 +211,10 @@ async function generateModuleRegistry(options) {
220
211
  }
221
212
  }
222
213
  {
223
- const appFile = findModuleFile(roots.appBase, "data", "fields");
224
- const pkgFile = findModuleFile(roots.pkgBase, "data", "fields");
225
- const hasApp = !!appFile;
226
- const hasPkg = !!pkgFile;
214
+ const appFile = path.join(roots.appBase, "data", "fields.ts");
215
+ const pkgFile = path.join(roots.pkgBase, "data", "fields.ts");
216
+ const hasApp = fs.existsSync(appFile);
217
+ const hasPkg = fs.existsSync(pkgFile);
227
218
  if (hasApp || hasPkg) {
228
219
  const importName = `F_${toVar(modId)}_${importId++}`;
229
220
  const importPath = hasApp ? `${appImportBase}/data/fields` : `${imps.pkgBase}/data/fields`;
@@ -326,14 +317,12 @@ async function generateModuleRegistry(options) {
326
317
  if (e.isDirectory()) {
327
318
  if (e.name === "__tests__" || e.name === "__mocks__") continue;
328
319
  walk(path.join(dir, e.name), [...rel, e.name]);
329
- } else if (e.isFile() && (e.name === "route.ts" || e.name === "route.js")) {
330
- routeFiles.push([...rel, e.name].join("/"));
331
- }
320
+ } else if (e.isFile() && e.name === "route.ts") routeFiles.push([...rel, e.name].join("/"));
332
321
  }
333
322
  };
334
323
  if (fs.existsSync(apiPkg)) walk(apiPkg);
335
324
  if (fs.existsSync(apiApp)) walk(apiApp);
336
- const routeList = Array.from(new Set(routeFiles.map((f) => f.replace(/\.(ts|js)$/, ""))));
325
+ const routeList = Array.from(new Set(routeFiles));
337
326
  const isDynamicRoute = (p) => p.split("/").some((seg) => /\[|\[\[\.\.\./.test(seg));
338
327
  routeList.sort((a, b) => {
339
328
  const ad = isDynamicRoute(a) ? 1 : 0;
@@ -346,15 +335,12 @@ async function generateModuleRegistry(options) {
346
335
  segs.pop();
347
336
  const reqSegs = [modId, ...segs];
348
337
  const importName = `R${importId++}_${toVar(modId)}_${toVar(segs.join("_") || "index")}`;
349
- const appFileTs = path.join(apiApp, ...segs, "route.ts");
350
- const appFileJs = path.join(apiApp, ...segs, "route.js");
351
- const fromApp = fs.existsSync(appFileTs) || fs.existsSync(appFileJs);
338
+ const appFile = path.join(apiApp, ...segs, "route.ts");
339
+ const fromApp = fs.existsSync(appFile);
352
340
  const apiSegPath = segs.join("/");
353
341
  const importPath = `${fromApp ? appImportBase : imps.pkgBase}/api${apiSegPath ? `/${apiSegPath}` : ""}/route`;
354
342
  const routePath = "/" + reqSegs.filter(Boolean).join("/");
355
- const pkgFileTs = path.join(apiPkg, ...segs, "route.ts");
356
- const pkgFileJs = path.join(apiPkg, ...segs, "route.js");
357
- const sourceFile = fromApp ? fs.existsSync(appFileTs) ? appFileTs : appFileJs : fs.existsSync(pkgFileTs) ? pkgFileTs : pkgFileJs;
343
+ const sourceFile = fromApp ? appFile : path.join(apiPkg, ...segs, "route.ts");
358
344
  const hasOpenApi = await moduleHasExport(sourceFile, "openApi");
359
345
  const docsPart = hasOpenApi ? `, docs: ${importName}.openApi` : "";
360
346
  imports.push(`import * as ${importName} from '${importPath}'`);
@@ -368,30 +354,28 @@ async function generateModuleRegistry(options) {
368
354
  if (methodNames.has(e.name.toLowerCase())) continue;
369
355
  if (e.name === "__tests__" || e.name === "__mocks__") continue;
370
356
  walkPlain(path.join(dir, e.name), [...rel, e.name]);
371
- } else if (e.isFile() && (e.name.endsWith(".ts") || e.name.endsWith(".js")) && !e.name.startsWith("route.")) {
372
- if (/\.(test|spec)\.(ts|js)$/.test(e.name)) continue;
373
- if (e.name.endsWith(".d.ts")) continue;
357
+ } else if (e.isFile() && e.name.endsWith(".ts") && e.name !== "route.ts") {
358
+ if (/\.(test|spec)\.ts$/.test(e.name)) continue;
374
359
  plainFiles.push([...rel, e.name].join("/"));
375
360
  }
376
361
  }
377
362
  };
378
363
  if (fs.existsSync(apiPkg)) walkPlain(apiPkg);
379
364
  if (fs.existsSync(apiApp)) walkPlain(apiApp);
380
- const plainList = Array.from(new Set(plainFiles.map((f) => f.replace(/\.(ts|js)$/, ""))));
365
+ const plainList = Array.from(new Set(plainFiles));
381
366
  for (const rel of plainList) {
382
367
  const segs = rel.split("/");
383
- const pathWithoutExt = segs.pop();
368
+ const file = segs.pop();
369
+ const pathWithoutExt = file.replace(/\.ts$/, "");
384
370
  const fullSegs = [...segs, pathWithoutExt];
385
371
  const routePath = "/" + [modId, ...fullSegs].filter(Boolean).join("/");
386
372
  const importName = `R${importId++}_${toVar(modId)}_${toVar(fullSegs.join("_") || "index")}`;
387
- const appFileTs = path.join(apiApp, ...fullSegs) + ".ts";
388
- const appFileJs = path.join(apiApp, ...fullSegs) + ".js";
389
- const fromApp = fs.existsSync(appFileTs) || fs.existsSync(appFileJs);
373
+ const appFile = path.join(apiApp, ...fullSegs) + ".ts";
374
+ const fromApp = fs.existsSync(appFile);
390
375
  const plainSegPath = fullSegs.join("/");
391
376
  const importPath = `${fromApp ? appImportBase : imps.pkgBase}/api${plainSegPath ? `/${plainSegPath}` : ""}`;
392
- const pkgFileTs = path.join(apiPkg, ...fullSegs) + ".ts";
393
- const pkgFileJs = path.join(apiPkg, ...fullSegs) + ".js";
394
- const sourceFile = fromApp ? fs.existsSync(appFileTs) ? appFileTs : appFileJs : fs.existsSync(pkgFileTs) ? pkgFileTs : pkgFileJs;
377
+ const pkgFile = path.join(apiPkg, ...fullSegs) + ".ts";
378
+ const sourceFile = fromApp ? appFile : pkgFile;
395
379
  const hasOpenApi = await moduleHasExport(sourceFile, "openApi");
396
380
  const docsPart = hasOpenApi ? `, docs: ${importName}.openApi` : "";
397
381
  imports.push(`import * as ${importName} from '${importPath}'`);
@@ -409,27 +393,25 @@ async function generateModuleRegistry(options) {
409
393
  if (e.isDirectory()) {
410
394
  if (e.name === "__tests__" || e.name === "__mocks__") continue;
411
395
  walk2(path.join(dir, e.name), [...rel, e.name]);
412
- } else if (e.isFile() && (e.name.endsWith(".ts") || e.name.endsWith(".js"))) {
413
- if (/\.(test|spec)\.(ts|js)$/.test(e.name)) continue;
414
- if (e.name.endsWith(".d.ts")) continue;
396
+ } else if (e.isFile() && e.name.endsWith(".ts")) {
397
+ if (/\.(test|spec)\.ts$/.test(e.name)) continue;
415
398
  apiFiles.push([...rel, e.name].join("/"));
416
399
  }
417
400
  }
418
401
  };
419
402
  walk2(methodDir);
420
- const methodList = Array.from(new Set(apiFiles.map((f) => f.replace(/\.(ts|js)$/, ""))));
403
+ const methodList = Array.from(new Set(apiFiles));
421
404
  for (const rel of methodList) {
422
405
  const segs = rel.split("/");
423
- const pathWithoutExt = segs.pop();
406
+ const file = segs.pop();
407
+ const pathWithoutExt = file.replace(/\.ts$/, "");
424
408
  const fullSegs = [...segs, pathWithoutExt];
425
409
  const routePath = "/" + [modId, ...fullSegs].filter(Boolean).join("/");
426
410
  const importName = `H${importId++}_${toVar(modId)}_${toVar(method)}_${toVar(fullSegs.join("_"))}`;
427
411
  const fromApp = methodDir === appMethodDir;
428
412
  const importPath = `${fromApp ? appImportBase : imps.pkgBase}/api/${method.toLowerCase()}/${fullSegs.join("/")}`;
429
413
  const metaName = `RM${importId++}_${toVar(modId)}_${toVar(method)}_${toVar(fullSegs.join("_"))}`;
430
- const sourceFileTs = path.join(methodDir, ...segs, `${pathWithoutExt}.ts`);
431
- const sourceFileJs = path.join(methodDir, ...segs, `${pathWithoutExt}.js`);
432
- const sourceFile = fs.existsSync(sourceFileTs) ? sourceFileTs : sourceFileJs;
414
+ const sourceFile = path.join(methodDir, ...segs, file);
433
415
  const hasOpenApi = await moduleHasExport(sourceFile, "openApi");
434
416
  const docsPart = hasOpenApi ? `, docs: ${metaName}.openApi` : "";
435
417
  imports.push(`import ${importName}, * as ${metaName} from '${importPath}'`);
@@ -437,9 +419,9 @@ async function generateModuleRegistry(options) {
437
419
  }
438
420
  }
439
421
  }
440
- const cliApp = findModuleFile(roots.appBase, "cli");
441
- const cliPkg = findModuleFile(roots.pkgBase, "cli");
442
- const cliPath = cliApp ?? cliPkg;
422
+ const cliApp = path.join(roots.appBase, "cli.ts");
423
+ const cliPkg = path.join(roots.pkgBase, "cli.ts");
424
+ const cliPath = fs.existsSync(cliApp) ? cliApp : fs.existsSync(cliPkg) ? cliPkg : null;
443
425
  if (cliPath) {
444
426
  const importName = `CLI_${toVar(modId)}`;
445
427
  const importPath = cliPath.startsWith(roots.appBase) ? `${appImportBase}/cli` : `${imps.pkgBase}/cli`;
@@ -487,9 +469,8 @@ async function generateModuleRegistry(options) {
487
469
  if (e.isDirectory()) {
488
470
  if (e.name === "__tests__" || e.name === "__mocks__") continue;
489
471
  walk(path.join(dir, e.name), [...rel, e.name]);
490
- } else if (e.isFile() && (e.name.endsWith(".ts") || e.name.endsWith(".js"))) {
491
- if (/\.(test|spec)\.(ts|js)$/.test(e.name)) continue;
492
- if (e.name.endsWith(".d.ts")) continue;
472
+ } else if (e.isFile() && e.name.endsWith(".ts")) {
473
+ if (/\.(test|spec)\.ts$/.test(e.name)) continue;
493
474
  found.push([...rel, e.name].join("/"));
494
475
  }
495
476
  }
@@ -500,12 +481,11 @@ async function generateModuleRegistry(options) {
500
481
  for (const rel of files) {
501
482
  const segs = rel.split("/");
502
483
  const file = segs.pop();
503
- const name = file.replace(/\.(ts|js)$/, "");
484
+ const name = file.replace(/\.ts$/, "");
504
485
  const importName = `Subscriber${importId++}_${toVar(modId)}_${toVar([...segs, name].join("_") || "index")}`;
505
486
  const metaName = `SubscriberMeta${importId++}_${toVar(modId)}_${toVar([...segs, name].join("_") || "index")}`;
506
- const appFileTs = path.join(subApp, ...segs, `${name}.ts`);
507
- const appFileJs = path.join(subApp, ...segs, `${name}.js`);
508
- const fromApp = fs.existsSync(appFileTs) || fs.existsSync(appFileJs);
487
+ const appFile = path.join(subApp, ...segs, `${name}.ts`);
488
+ const fromApp = fs.existsSync(appFile);
509
489
  const importPath = `${fromApp ? appImportBase : imps.pkgBase}/subscribers/${[...segs, name].join("/")}`;
510
490
  imports.push(`import ${importName}, * as ${metaName} from '${importPath}'`);
511
491
  const sid = [modId, ...segs, name].filter(Boolean).join(":");
@@ -524,9 +504,8 @@ async function generateModuleRegistry(options) {
524
504
  if (e.isDirectory()) {
525
505
  if (e.name === "__tests__" || e.name === "__mocks__") continue;
526
506
  walk(path.join(dir, e.name), [...rel, e.name]);
527
- } else if (e.isFile() && (e.name.endsWith(".ts") || e.name.endsWith(".js"))) {
528
- if (/\.(test|spec)\.(ts|js)$/.test(e.name)) continue;
529
- if (e.name.endsWith(".d.ts")) continue;
507
+ } else if (e.isFile() && e.name.endsWith(".ts")) {
508
+ if (/\.(test|spec)\.ts$/.test(e.name)) continue;
530
509
  found.push([...rel, e.name].join("/"));
531
510
  }
532
511
  }
@@ -537,10 +516,9 @@ async function generateModuleRegistry(options) {
537
516
  for (const rel of files) {
538
517
  const segs = rel.split("/");
539
518
  const file = segs.pop();
540
- const name = file.replace(/\.(ts|js)$/, "");
541
- const appFileTs = path.join(wrkApp, ...segs, `${name}.ts`);
542
- const appFileJs = path.join(wrkApp, ...segs, `${name}.js`);
543
- const fromApp = fs.existsSync(appFileTs) || fs.existsSync(appFileJs);
519
+ const name = file.replace(/\.ts$/, "");
520
+ const appFile = path.join(wrkApp, ...segs, `${name}.ts`);
521
+ const fromApp = fs.existsSync(appFile);
544
522
  const importPath = `${fromApp ? appImportBase : imps.pkgBase}/workers/${[...segs, name].join("/")}`;
545
523
  if (!await moduleHasExport(importPath, "metadata")) continue;
546
524
  const importName = `Worker${importId++}_${toVar(modId)}_${toVar([...segs, name].join("_") || "index")}`;
@@ -841,9 +819,9 @@ async function generateModuleRegistryCli(options) {
841
819
  let customEntitiesImportName = null;
842
820
  let vectorImportName = null;
843
821
  let customFieldSetsExpr = "[]";
844
- const appIndex = findModuleFile(roots.appBase, "index");
845
- const pkgIndex = findModuleFile(roots.pkgBase, "index");
846
- const indexTs = appIndex ?? pkgIndex;
822
+ const appIndex = path.join(roots.appBase, "index.ts");
823
+ const pkgIndex = path.join(roots.pkgBase, "index.ts");
824
+ const indexTs = fs.existsSync(appIndex) ? appIndex : fs.existsSync(pkgIndex) ? pkgIndex : null;
847
825
  if (indexTs) {
848
826
  infoImportName = `I${importId++}_${toVar(modId)}`;
849
827
  const importPath = indexTs.startsWith(roots.appBase) ? `${appImportBase}/index` : `${imps.pkgBase}/index`;
@@ -856,10 +834,10 @@ async function generateModuleRegistryCli(options) {
856
834
  }
857
835
  }
858
836
  {
859
- const appFile = findModuleFile(roots.appBase, "data", "extensions");
860
- const pkgFile = findModuleFile(roots.pkgBase, "data", "extensions");
861
- const hasApp = !!appFile;
862
- const hasPkg = !!pkgFile;
837
+ const appFile = path.join(roots.appBase, "data", "extensions.ts");
838
+ const pkgFile = path.join(roots.pkgBase, "data", "extensions.ts");
839
+ const hasApp = fs.existsSync(appFile);
840
+ const hasPkg = fs.existsSync(pkgFile);
863
841
  if (hasApp || hasPkg) {
864
842
  const importName = `X_${toVar(modId)}_${importId++}`;
865
843
  const importPath = hasApp ? `${appImportBase}/data/extensions` : `${imps.pkgBase}/data/extensions`;
@@ -868,22 +846,22 @@ async function generateModuleRegistryCli(options) {
868
846
  }
869
847
  }
870
848
  {
871
- const rootApp = findModuleFile(roots.appBase, "acl");
872
- const rootPkg = findModuleFile(roots.pkgBase, "acl");
873
- const hasRoot = rootApp || rootPkg;
849
+ const rootApp = path.join(roots.appBase, "acl.ts");
850
+ const rootPkg = path.join(roots.pkgBase, "acl.ts");
851
+ const hasRoot = fs.existsSync(rootApp) || fs.existsSync(rootPkg);
874
852
  if (hasRoot) {
875
853
  const importName = `ACL_${toVar(modId)}_${importId++}`;
876
- const useApp = rootApp ?? rootPkg;
854
+ const useApp = fs.existsSync(rootApp) ? rootApp : rootPkg;
877
855
  const importPath = useApp.startsWith(roots.appBase) ? `${appImportBase}/acl` : `${imps.pkgBase}/acl`;
878
856
  imports.push(`import * as ${importName} from '${importPath}'`);
879
857
  featuresImportName = importName;
880
858
  }
881
859
  }
882
860
  {
883
- const appFile = findModuleFile(roots.appBase, "ce");
884
- const pkgFile = findModuleFile(roots.pkgBase, "ce");
885
- const hasApp = !!appFile;
886
- const hasPkg = !!pkgFile;
861
+ const appFile = path.join(roots.appBase, "ce.ts");
862
+ const pkgFile = path.join(roots.pkgBase, "ce.ts");
863
+ const hasApp = fs.existsSync(appFile);
864
+ const hasPkg = fs.existsSync(pkgFile);
887
865
  if (hasApp || hasPkg) {
888
866
  const importName = `CE_${toVar(modId)}_${importId++}`;
889
867
  const importPath = hasApp ? `${appImportBase}/ce` : `${imps.pkgBase}/ce`;
@@ -892,10 +870,10 @@ async function generateModuleRegistryCli(options) {
892
870
  }
893
871
  }
894
872
  {
895
- const appFile = findModuleFile(roots.appBase, "vector");
896
- const pkgFile = findModuleFile(roots.pkgBase, "vector");
897
- const hasApp = !!appFile;
898
- const hasPkg = !!pkgFile;
873
+ const appFile = path.join(roots.appBase, "vector.ts");
874
+ const pkgFile = path.join(roots.pkgBase, "vector.ts");
875
+ const hasApp = fs.existsSync(appFile);
876
+ const hasPkg = fs.existsSync(pkgFile);
899
877
  if (hasApp || hasPkg) {
900
878
  const importName = `VECTOR_${toVar(modId)}_${importId++}`;
901
879
  const importPath = hasApp ? `${appImportBase}/vector` : `${imps.pkgBase}/vector`;
@@ -904,10 +882,10 @@ async function generateModuleRegistryCli(options) {
904
882
  }
905
883
  }
906
884
  {
907
- const appFile = findModuleFile(roots.appBase, "data", "fields");
908
- const pkgFile = findModuleFile(roots.pkgBase, "data", "fields");
909
- const hasApp = !!appFile;
910
- const hasPkg = !!pkgFile;
885
+ const appFile = path.join(roots.appBase, "data", "fields.ts");
886
+ const pkgFile = path.join(roots.pkgBase, "data", "fields.ts");
887
+ const hasApp = fs.existsSync(appFile);
888
+ const hasPkg = fs.existsSync(pkgFile);
911
889
  if (hasApp || hasPkg) {
912
890
  const importName = `F_${toVar(modId)}_${importId++}`;
913
891
  const importPath = hasApp ? `${appImportBase}/data/fields` : `${imps.pkgBase}/data/fields`;
@@ -915,9 +893,9 @@ async function generateModuleRegistryCli(options) {
915
893
  fieldsImportName = importName;
916
894
  }
917
895
  }
918
- const cliApp = findModuleFile(roots.appBase, "cli");
919
- const cliPkg = findModuleFile(roots.pkgBase, "cli");
920
- const cliPath = cliApp ?? cliPkg;
896
+ const cliApp = path.join(roots.appBase, "cli.ts");
897
+ const cliPkg = path.join(roots.pkgBase, "cli.ts");
898
+ const cliPath = fs.existsSync(cliApp) ? cliApp : fs.existsSync(cliPkg) ? cliPkg : null;
921
899
  if (cliPath) {
922
900
  const importName = `CLI_${toVar(modId)}`;
923
901
  const importPath = cliPath.startsWith(roots.appBase) ? `${appImportBase}/cli` : `${imps.pkgBase}/cli`;
@@ -965,9 +943,8 @@ async function generateModuleRegistryCli(options) {
965
943
  if (e.isDirectory()) {
966
944
  if (e.name === "__tests__" || e.name === "__mocks__") continue;
967
945
  walk(path.join(dir, e.name), [...rel, e.name]);
968
- } else if (e.isFile() && (e.name.endsWith(".ts") || e.name.endsWith(".js"))) {
969
- if (/\.(test|spec)\.(ts|js)$/.test(e.name)) continue;
970
- if (e.name.endsWith(".d.ts")) continue;
946
+ } else if (e.isFile() && e.name.endsWith(".ts")) {
947
+ if (/\.(test|spec)\.ts$/.test(e.name)) continue;
971
948
  found.push([...rel, e.name].join("/"));
972
949
  }
973
950
  }
@@ -978,12 +955,11 @@ async function generateModuleRegistryCli(options) {
978
955
  for (const rel of files) {
979
956
  const segs = rel.split("/");
980
957
  const file = segs.pop();
981
- const name = file.replace(/\.(ts|js)$/, "");
958
+ const name = file.replace(/\.ts$/, "");
982
959
  const importName = `Subscriber${importId++}_${toVar(modId)}_${toVar([...segs, name].join("_") || "index")}`;
983
960
  const metaName = `SubscriberMeta${importId++}_${toVar(modId)}_${toVar([...segs, name].join("_") || "index")}`;
984
- const appFileTs = path.join(subApp, ...segs, `${name}.ts`);
985
- const appFileJs = path.join(subApp, ...segs, `${name}.js`);
986
- const fromApp = fs.existsSync(appFileTs) || fs.existsSync(appFileJs);
961
+ const appFile = path.join(subApp, ...segs, `${name}.ts`);
962
+ const fromApp = fs.existsSync(appFile);
987
963
  const importPath = `${fromApp ? appImportBase : imps.pkgBase}/subscribers/${[...segs, name].join("/")}`;
988
964
  imports.push(`import ${importName}, * as ${metaName} from '${importPath}'`);
989
965
  const sid = [modId, ...segs, name].filter(Boolean).join(":");
@@ -1002,9 +978,8 @@ async function generateModuleRegistryCli(options) {
1002
978
  if (e.isDirectory()) {
1003
979
  if (e.name === "__tests__" || e.name === "__mocks__") continue;
1004
980
  walk(path.join(dir, e.name), [...rel, e.name]);
1005
- } else if (e.isFile() && (e.name.endsWith(".ts") || e.name.endsWith(".js"))) {
1006
- if (/\.(test|spec)\.(ts|js)$/.test(e.name)) continue;
1007
- if (e.name.endsWith(".d.ts")) continue;
981
+ } else if (e.isFile() && e.name.endsWith(".ts")) {
982
+ if (/\.(test|spec)\.ts$/.test(e.name)) continue;
1008
983
  found.push([...rel, e.name].join("/"));
1009
984
  }
1010
985
  }
@@ -1015,10 +990,9 @@ async function generateModuleRegistryCli(options) {
1015
990
  for (const rel of files) {
1016
991
  const segs = rel.split("/");
1017
992
  const file = segs.pop();
1018
- const name = file.replace(/\.(ts|js)$/, "");
1019
- const appFileTs = path.join(wrkApp, ...segs, `${name}.ts`);
1020
- const appFileJs = path.join(wrkApp, ...segs, `${name}.js`);
1021
- const fromApp = fs.existsSync(appFileTs) || fs.existsSync(appFileJs);
993
+ const name = file.replace(/\.ts$/, "");
994
+ const appFile = path.join(wrkApp, ...segs, `${name}.ts`);
995
+ const fromApp = fs.existsSync(appFile);
1022
996
  const importPath = `${fromApp ? appImportBase : imps.pkgBase}/workers/${[...segs, name].join("/")}`;
1023
997
  if (!await moduleHasExport(importPath, "metadata")) continue;
1024
998
  const importName = `Worker${importId++}_${toVar(modId)}_${toVar([...segs, name].join("_") || "index")}`;