@open-mercato/cli 0.4.2-canary-f80d1bfa83 → 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.
- package/dist/lib/db/commands.js +17 -8
- package/dist/lib/db/commands.js.map +2 -2
- package/dist/lib/generators/entity-ids.js +2 -3
- package/dist/lib/generators/entity-ids.js.map +2 -2
- package/dist/lib/generators/module-di.js +4 -6
- package/dist/lib/generators/module-di.js.map +2 -2
- package/dist/lib/generators/module-entities.js +3 -4
- package/dist/lib/generators/module-entities.js.map +2 -2
- package/dist/lib/generators/module-registry.js +72 -89
- package/dist/lib/generators/module-registry.js.map +2 -2
- package/dist/lib/resolver.js +2 -2
- package/dist/lib/resolver.js.map +2 -2
- package/dist/mercato.js +21 -33
- package/dist/mercato.js.map +2 -2
- package/package.json +2 -2
- package/src/lib/db/commands.ts +19 -12
- package/src/lib/generators/entity-ids.ts +2 -4
- package/src/lib/generators/module-di.ts +4 -7
- package/src/lib/generators/module-entities.ts +3 -4
- package/src/lib/generators/module-registry.ts +76 -99
- package/src/lib/resolver.ts +5 -4
- package/src/mercato.ts +21 -40
|
@@ -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 =
|
|
73
|
-
const pkgIndex =
|
|
74
|
-
const indexTs = appIndex
|
|
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 =
|
|
174
|
-
const pkgFile =
|
|
175
|
-
const hasApp =
|
|
176
|
-
const hasPkg =
|
|
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 =
|
|
186
|
-
const rootPkg =
|
|
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
|
|
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 =
|
|
198
|
-
const pkgFile =
|
|
199
|
-
const hasApp =
|
|
200
|
-
const hasPkg =
|
|
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 =
|
|
210
|
-
const pkgFile =
|
|
211
|
-
const hasApp =
|
|
212
|
-
const hasPkg =
|
|
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 =
|
|
224
|
-
const pkgFile =
|
|
225
|
-
const hasApp =
|
|
226
|
-
const hasPkg =
|
|
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`;
|
|
@@ -428,9 +419,9 @@ async function generateModuleRegistry(options) {
|
|
|
428
419
|
}
|
|
429
420
|
}
|
|
430
421
|
}
|
|
431
|
-
const cliApp =
|
|
432
|
-
const cliPkg =
|
|
433
|
-
const cliPath = cliApp
|
|
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;
|
|
434
425
|
if (cliPath) {
|
|
435
426
|
const importName = `CLI_${toVar(modId)}`;
|
|
436
427
|
const importPath = cliPath.startsWith(roots.appBase) ? `${appImportBase}/cli` : `${imps.pkgBase}/cli`;
|
|
@@ -478,9 +469,8 @@ async function generateModuleRegistry(options) {
|
|
|
478
469
|
if (e.isDirectory()) {
|
|
479
470
|
if (e.name === "__tests__" || e.name === "__mocks__") continue;
|
|
480
471
|
walk(path.join(dir, e.name), [...rel, e.name]);
|
|
481
|
-
} else if (e.isFile() &&
|
|
482
|
-
if (/\.(test|spec)\.
|
|
483
|
-
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;
|
|
484
474
|
found.push([...rel, e.name].join("/"));
|
|
485
475
|
}
|
|
486
476
|
}
|
|
@@ -491,12 +481,11 @@ async function generateModuleRegistry(options) {
|
|
|
491
481
|
for (const rel of files) {
|
|
492
482
|
const segs = rel.split("/");
|
|
493
483
|
const file = segs.pop();
|
|
494
|
-
const name = file.replace(/\.
|
|
484
|
+
const name = file.replace(/\.ts$/, "");
|
|
495
485
|
const importName = `Subscriber${importId++}_${toVar(modId)}_${toVar([...segs, name].join("_") || "index")}`;
|
|
496
486
|
const metaName = `SubscriberMeta${importId++}_${toVar(modId)}_${toVar([...segs, name].join("_") || "index")}`;
|
|
497
|
-
const
|
|
498
|
-
const
|
|
499
|
-
const fromApp = fs.existsSync(appFileTs) || fs.existsSync(appFileJs);
|
|
487
|
+
const appFile = path.join(subApp, ...segs, `${name}.ts`);
|
|
488
|
+
const fromApp = fs.existsSync(appFile);
|
|
500
489
|
const importPath = `${fromApp ? appImportBase : imps.pkgBase}/subscribers/${[...segs, name].join("/")}`;
|
|
501
490
|
imports.push(`import ${importName}, * as ${metaName} from '${importPath}'`);
|
|
502
491
|
const sid = [modId, ...segs, name].filter(Boolean).join(":");
|
|
@@ -515,9 +504,8 @@ async function generateModuleRegistry(options) {
|
|
|
515
504
|
if (e.isDirectory()) {
|
|
516
505
|
if (e.name === "__tests__" || e.name === "__mocks__") continue;
|
|
517
506
|
walk(path.join(dir, e.name), [...rel, e.name]);
|
|
518
|
-
} else if (e.isFile() &&
|
|
519
|
-
if (/\.(test|spec)\.
|
|
520
|
-
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;
|
|
521
509
|
found.push([...rel, e.name].join("/"));
|
|
522
510
|
}
|
|
523
511
|
}
|
|
@@ -528,10 +516,9 @@ async function generateModuleRegistry(options) {
|
|
|
528
516
|
for (const rel of files) {
|
|
529
517
|
const segs = rel.split("/");
|
|
530
518
|
const file = segs.pop();
|
|
531
|
-
const name = file.replace(/\.
|
|
532
|
-
const
|
|
533
|
-
const
|
|
534
|
-
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);
|
|
535
522
|
const importPath = `${fromApp ? appImportBase : imps.pkgBase}/workers/${[...segs, name].join("/")}`;
|
|
536
523
|
if (!await moduleHasExport(importPath, "metadata")) continue;
|
|
537
524
|
const importName = `Worker${importId++}_${toVar(modId)}_${toVar([...segs, name].join("_") || "index")}`;
|
|
@@ -832,9 +819,9 @@ async function generateModuleRegistryCli(options) {
|
|
|
832
819
|
let customEntitiesImportName = null;
|
|
833
820
|
let vectorImportName = null;
|
|
834
821
|
let customFieldSetsExpr = "[]";
|
|
835
|
-
const appIndex =
|
|
836
|
-
const pkgIndex =
|
|
837
|
-
const indexTs = appIndex
|
|
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;
|
|
838
825
|
if (indexTs) {
|
|
839
826
|
infoImportName = `I${importId++}_${toVar(modId)}`;
|
|
840
827
|
const importPath = indexTs.startsWith(roots.appBase) ? `${appImportBase}/index` : `${imps.pkgBase}/index`;
|
|
@@ -847,10 +834,10 @@ async function generateModuleRegistryCli(options) {
|
|
|
847
834
|
}
|
|
848
835
|
}
|
|
849
836
|
{
|
|
850
|
-
const appFile =
|
|
851
|
-
const pkgFile =
|
|
852
|
-
const hasApp =
|
|
853
|
-
const hasPkg =
|
|
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);
|
|
854
841
|
if (hasApp || hasPkg) {
|
|
855
842
|
const importName = `X_${toVar(modId)}_${importId++}`;
|
|
856
843
|
const importPath = hasApp ? `${appImportBase}/data/extensions` : `${imps.pkgBase}/data/extensions`;
|
|
@@ -859,22 +846,22 @@ async function generateModuleRegistryCli(options) {
|
|
|
859
846
|
}
|
|
860
847
|
}
|
|
861
848
|
{
|
|
862
|
-
const rootApp =
|
|
863
|
-
const rootPkg =
|
|
864
|
-
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);
|
|
865
852
|
if (hasRoot) {
|
|
866
853
|
const importName = `ACL_${toVar(modId)}_${importId++}`;
|
|
867
|
-
const useApp = rootApp
|
|
854
|
+
const useApp = fs.existsSync(rootApp) ? rootApp : rootPkg;
|
|
868
855
|
const importPath = useApp.startsWith(roots.appBase) ? `${appImportBase}/acl` : `${imps.pkgBase}/acl`;
|
|
869
856
|
imports.push(`import * as ${importName} from '${importPath}'`);
|
|
870
857
|
featuresImportName = importName;
|
|
871
858
|
}
|
|
872
859
|
}
|
|
873
860
|
{
|
|
874
|
-
const appFile =
|
|
875
|
-
const pkgFile =
|
|
876
|
-
const hasApp =
|
|
877
|
-
const hasPkg =
|
|
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);
|
|
878
865
|
if (hasApp || hasPkg) {
|
|
879
866
|
const importName = `CE_${toVar(modId)}_${importId++}`;
|
|
880
867
|
const importPath = hasApp ? `${appImportBase}/ce` : `${imps.pkgBase}/ce`;
|
|
@@ -883,10 +870,10 @@ async function generateModuleRegistryCli(options) {
|
|
|
883
870
|
}
|
|
884
871
|
}
|
|
885
872
|
{
|
|
886
|
-
const appFile =
|
|
887
|
-
const pkgFile =
|
|
888
|
-
const hasApp =
|
|
889
|
-
const hasPkg =
|
|
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);
|
|
890
877
|
if (hasApp || hasPkg) {
|
|
891
878
|
const importName = `VECTOR_${toVar(modId)}_${importId++}`;
|
|
892
879
|
const importPath = hasApp ? `${appImportBase}/vector` : `${imps.pkgBase}/vector`;
|
|
@@ -895,10 +882,10 @@ async function generateModuleRegistryCli(options) {
|
|
|
895
882
|
}
|
|
896
883
|
}
|
|
897
884
|
{
|
|
898
|
-
const appFile =
|
|
899
|
-
const pkgFile =
|
|
900
|
-
const hasApp =
|
|
901
|
-
const hasPkg =
|
|
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);
|
|
902
889
|
if (hasApp || hasPkg) {
|
|
903
890
|
const importName = `F_${toVar(modId)}_${importId++}`;
|
|
904
891
|
const importPath = hasApp ? `${appImportBase}/data/fields` : `${imps.pkgBase}/data/fields`;
|
|
@@ -906,9 +893,9 @@ async function generateModuleRegistryCli(options) {
|
|
|
906
893
|
fieldsImportName = importName;
|
|
907
894
|
}
|
|
908
895
|
}
|
|
909
|
-
const cliApp =
|
|
910
|
-
const cliPkg =
|
|
911
|
-
const cliPath = cliApp
|
|
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;
|
|
912
899
|
if (cliPath) {
|
|
913
900
|
const importName = `CLI_${toVar(modId)}`;
|
|
914
901
|
const importPath = cliPath.startsWith(roots.appBase) ? `${appImportBase}/cli` : `${imps.pkgBase}/cli`;
|
|
@@ -956,9 +943,8 @@ async function generateModuleRegistryCli(options) {
|
|
|
956
943
|
if (e.isDirectory()) {
|
|
957
944
|
if (e.name === "__tests__" || e.name === "__mocks__") continue;
|
|
958
945
|
walk(path.join(dir, e.name), [...rel, e.name]);
|
|
959
|
-
} else if (e.isFile() &&
|
|
960
|
-
if (/\.(test|spec)\.
|
|
961
|
-
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;
|
|
962
948
|
found.push([...rel, e.name].join("/"));
|
|
963
949
|
}
|
|
964
950
|
}
|
|
@@ -969,12 +955,11 @@ async function generateModuleRegistryCli(options) {
|
|
|
969
955
|
for (const rel of files) {
|
|
970
956
|
const segs = rel.split("/");
|
|
971
957
|
const file = segs.pop();
|
|
972
|
-
const name = file.replace(/\.
|
|
958
|
+
const name = file.replace(/\.ts$/, "");
|
|
973
959
|
const importName = `Subscriber${importId++}_${toVar(modId)}_${toVar([...segs, name].join("_") || "index")}`;
|
|
974
960
|
const metaName = `SubscriberMeta${importId++}_${toVar(modId)}_${toVar([...segs, name].join("_") || "index")}`;
|
|
975
|
-
const
|
|
976
|
-
const
|
|
977
|
-
const fromApp = fs.existsSync(appFileTs) || fs.existsSync(appFileJs);
|
|
961
|
+
const appFile = path.join(subApp, ...segs, `${name}.ts`);
|
|
962
|
+
const fromApp = fs.existsSync(appFile);
|
|
978
963
|
const importPath = `${fromApp ? appImportBase : imps.pkgBase}/subscribers/${[...segs, name].join("/")}`;
|
|
979
964
|
imports.push(`import ${importName}, * as ${metaName} from '${importPath}'`);
|
|
980
965
|
const sid = [modId, ...segs, name].filter(Boolean).join(":");
|
|
@@ -993,9 +978,8 @@ async function generateModuleRegistryCli(options) {
|
|
|
993
978
|
if (e.isDirectory()) {
|
|
994
979
|
if (e.name === "__tests__" || e.name === "__mocks__") continue;
|
|
995
980
|
walk(path.join(dir, e.name), [...rel, e.name]);
|
|
996
|
-
} else if (e.isFile() &&
|
|
997
|
-
if (/\.(test|spec)\.
|
|
998
|
-
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;
|
|
999
983
|
found.push([...rel, e.name].join("/"));
|
|
1000
984
|
}
|
|
1001
985
|
}
|
|
@@ -1006,10 +990,9 @@ async function generateModuleRegistryCli(options) {
|
|
|
1006
990
|
for (const rel of files) {
|
|
1007
991
|
const segs = rel.split("/");
|
|
1008
992
|
const file = segs.pop();
|
|
1009
|
-
const name = file.replace(/\.
|
|
1010
|
-
const
|
|
1011
|
-
const
|
|
1012
|
-
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);
|
|
1013
996
|
const importPath = `${fromApp ? appImportBase : imps.pkgBase}/workers/${[...segs, name].join("/")}`;
|
|
1014
997
|
if (!await moduleHasExport(importPath, "metadata")) continue;
|
|
1015
998
|
const importName = `Worker${importId++}_${toVar(modId)}_${toVar([...segs, name].join("_") || "index")}`;
|