@open-mercato/cli 0.6.6-develop.6290.1.4bb5a8ba3f → 0.6.6-develop.6296.1.5e8bdfee17
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": "@open-mercato/cli",
|
|
3
|
-
"version": "0.6.6-develop.
|
|
3
|
+
"version": "0.6.6-develop.6296.1.5e8bdfee17",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"@mikro-orm/decorators": "^7.1.4",
|
|
61
61
|
"@mikro-orm/migrations": "^7.1.4",
|
|
62
62
|
"@mikro-orm/postgresql": "^7.1.4",
|
|
63
|
-
"@open-mercato/queue": "0.6.6-develop.
|
|
64
|
-
"@open-mercato/shared": "0.6.6-develop.
|
|
63
|
+
"@open-mercato/queue": "0.6.6-develop.6296.1.5e8bdfee17",
|
|
64
|
+
"@open-mercato/shared": "0.6.6-develop.6296.1.5e8bdfee17",
|
|
65
65
|
"cross-spawn": "^7.0.6",
|
|
66
66
|
"pg": "8.22.0",
|
|
67
67
|
"semver": "^7.8.5",
|
|
@@ -71,10 +71,10 @@
|
|
|
71
71
|
"typescript": "^6.0.3"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
|
-
"@open-mercato/shared": "0.6.6-develop.
|
|
74
|
+
"@open-mercato/shared": "0.6.6-develop.6296.1.5e8bdfee17"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
|
-
"@open-mercato/shared": "0.6.6-develop.
|
|
77
|
+
"@open-mercato/shared": "0.6.6-develop.6296.1.5e8bdfee17",
|
|
78
78
|
"@types/jest": "^30.0.0",
|
|
79
79
|
"jest": "^30.4.2",
|
|
80
80
|
"ts-jest": "^29.4.11"
|
|
@@ -266,39 +266,16 @@ describe('generateModuleRegistry with module subsets', () => {
|
|
|
266
266
|
const result = await generateModuleRegistry({ resolver, quiet: true })
|
|
267
267
|
|
|
268
268
|
expect(result.errors).toEqual([])
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
id: "orders",
|
|
280
|
-
info: I0_orders.metadata,
|
|
281
|
-
frontendRoutes: [{ pattern: "/", requireAuth: ((CM2_orders_index as any).metadata)?.requireAuth, requireRoles: ((CM2_orders_index as any).metadata)?.requireRoles, requireFeatures: ((CM2_orders_index as any).metadata)?.requireFeatures, requireCustomerAuth: ((CM2_orders_index as any).metadata)?.requireCustomerAuth, requireCustomerFeatures: ((CM2_orders_index as any).metadata)?.requireCustomerFeatures, nav: ((CM2_orders_index as any).metadata)?.nav, title: ((CM2_orders_index as any).metadata)?.pageTitle ?? ((CM2_orders_index as any).metadata)?.title, titleKey: ((CM2_orders_index as any).metadata)?.pageTitleKey ?? ((CM2_orders_index as any).metadata)?.titleKey, group: ((CM2_orders_index as any).metadata)?.pageGroup ?? ((CM2_orders_index as any).metadata)?.group, groupKey: ((CM2_orders_index as any).metadata)?.pageGroupKey ?? ((CM2_orders_index as any).metadata)?.groupKey, icon: ((CM2_orders_index as any).metadata)?.icon, order: ((CM2_orders_index as any).metadata)?.pageOrder ?? ((CM2_orders_index as any).metadata)?.order, priority: ((CM2_orders_index as any).metadata)?.pagePriority ?? ((CM2_orders_index as any).metadata)?.priority, navHidden: ((CM2_orders_index as any).metadata)?.navHidden, visible: ((CM2_orders_index as any).metadata)?.visible, enabled: ((CM2_orders_index as any).metadata)?.enabled, breadcrumb: ((CM2_orders_index as any).metadata)?.breadcrumb, pageContext: ((CM2_orders_index as any).metadata)?.pageContext, placement: ((CM2_orders_index as any).metadata)?.placement, Component: C1_orders_index }],
|
|
282
|
-
backendRoutes: [{ pattern: "/backend/orders", requireAuth: ((BM6_orders_index as any).metadata)?.requireAuth, requireRoles: ((BM6_orders_index as any).metadata)?.requireRoles, requireFeatures: ((BM6_orders_index as any).metadata)?.requireFeatures, requireCustomerAuth: ((BM6_orders_index as any).metadata)?.requireCustomerAuth, requireCustomerFeatures: ((BM6_orders_index as any).metadata)?.requireCustomerFeatures, nav: ((BM6_orders_index as any).metadata)?.nav, title: ((BM6_orders_index as any).metadata)?.pageTitle ?? ((BM6_orders_index as any).metadata)?.title, titleKey: ((BM6_orders_index as any).metadata)?.pageTitleKey ?? ((BM6_orders_index as any).metadata)?.titleKey, group: ((BM6_orders_index as any).metadata)?.pageGroup ?? ((BM6_orders_index as any).metadata)?.group, groupKey: ((BM6_orders_index as any).metadata)?.pageGroupKey ?? ((BM6_orders_index as any).metadata)?.groupKey, icon: ((BM6_orders_index as any).metadata)?.icon, order: ((BM6_orders_index as any).metadata)?.pageOrder ?? ((BM6_orders_index as any).metadata)?.order, priority: ((BM6_orders_index as any).metadata)?.pagePriority ?? ((BM6_orders_index as any).metadata)?.priority, navHidden: ((BM6_orders_index as any).metadata)?.navHidden, visible: ((BM6_orders_index as any).metadata)?.visible, enabled: ((BM6_orders_index as any).metadata)?.enabled, breadcrumb: ((BM6_orders_index as any).metadata)?.breadcrumb, pageContext: ((BM6_orders_index as any).metadata)?.pageContext, placement: ((BM6_orders_index as any).metadata)?.placement, Component: B5_orders_index }],
|
|
283
|
-
apis: [{ path: ((R9_orders_orders as any).metadata?.path ?? "/orders/orders"), metadata: (R9_orders_orders as any).metadata, handlers: R9_orders_orders as any }],
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
customFieldSets: [],
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
}
|
|
298
|
-
]
|
|
299
|
-
export const modulesInfo = modules.map(m => ({ id: m.id, ...(m.info || {}) }))
|
|
300
|
-
export default modules
|
|
301
|
-
`))
|
|
269
|
+
const modulesGenerated = readGenerated(tmpDir, 'modules.generated.ts')
|
|
270
|
+
expect(modulesGenerated).toContain(`import { createElement } from 'react'`)
|
|
271
|
+
expect(modulesGenerated).toContain(`import * as I0_orders from "@open-mercato/core/modules/orders/index"`)
|
|
272
|
+
expect(modulesGenerated).not.toContain(`import C1_orders_index`)
|
|
273
|
+
expect(modulesGenerated).not.toContain(`import B5_orders_index`)
|
|
274
|
+
expect(modulesGenerated).toContain(`frontendRoutes: [{ pattern: "/"`)
|
|
275
|
+
expect(modulesGenerated).toContain(`backendRoutes: [{ pattern: "/backend/orders"`)
|
|
276
|
+
expect(modulesGenerated).toContain(`Component: async (props: any) => { const mod = await import("@open-mercato/core/modules/orders/frontend/page")`)
|
|
277
|
+
expect(modulesGenerated).toContain(`Component: async (props: any) => { const mod = await import("@open-mercato/core/modules/orders/backend/page")`)
|
|
278
|
+
expect(modulesGenerated).toContain(`apis: [{ path: ((R9_orders_orders as any).metadata?.path ?? "/orders/orders"), metadata: (R9_orders_orders as any).metadata, handlers: R9_orders_orders as any }]`)
|
|
302
279
|
expect(readGenerated(tmpDir, 'modules.runtime.generated.ts')).toBe(dedent(`
|
|
303
280
|
// AUTO-GENERATED by mercato generate registry
|
|
304
281
|
import { createElement } from 'react'
|
|
@@ -1378,8 +1378,6 @@ async function processPageFiles(options: {
|
|
|
1378
1378
|
importIdRef: { value: number }
|
|
1379
1379
|
}): Promise<PageRouteGenerationResult> {
|
|
1380
1380
|
const { files, type, modId, appDir, pkgDir, appImportBase, pkgImportBase, eagerImports, runtimeImports, manifestImports, importIdRef } = options
|
|
1381
|
-
const prefix = type === 'frontend' ? 'C' : 'B'
|
|
1382
|
-
const modPrefix = type === 'frontend' ? 'CM' : 'BM'
|
|
1383
1381
|
const metaPrefix = type === 'frontend' ? 'M' : 'BM'
|
|
1384
1382
|
const eagerRoutes: string[] = []
|
|
1385
1383
|
const runtimeRoutes: string[] = []
|
|
@@ -1390,8 +1388,8 @@ async function processPageFiles(options: {
|
|
|
1390
1388
|
const segs = relPath.split('/')
|
|
1391
1389
|
const pageFile = segs.pop()!
|
|
1392
1390
|
const pageBaseName = stripModuleCodeExtension(pageFile)
|
|
1393
|
-
|
|
1394
|
-
|
|
1391
|
+
importIdRef.value++
|
|
1392
|
+
importIdRef.value++
|
|
1395
1393
|
const runtimeMetaName = `${metaPrefix}Runtime${importIdRef.value++}_${toVar(modId)}_${toVar(segs.join('_') || 'index')}`
|
|
1396
1394
|
const sub = segs.length ? `${segs.join('/')}/${pageBaseName}` : pageBaseName
|
|
1397
1395
|
const importPath = sanitizeGeneratedModuleSpecifier(`${fromApp ? appImportBase : pkgImportBase}/${type}/${sub}`)
|
|
@@ -1426,10 +1424,14 @@ async function processPageFiles(options: {
|
|
|
1426
1424
|
if (manifestMetadata.requiresRuntimeImport) {
|
|
1427
1425
|
manifestImportStatement = buildImportStatement(`* as ${manifestMetaImportName}`, metaImportPath)
|
|
1428
1426
|
}
|
|
1429
|
-
eagerImports.push(buildImportStatement(importName, importPath))
|
|
1430
1427
|
} else {
|
|
1431
|
-
metaExpr = `(${pageModName} as any).metadata`
|
|
1432
1428
|
runtimeMetaExpr = `(((${runtimeMetaName} as any).metadata) as any)`
|
|
1429
|
+
const staticMetadata = await loadPageMetadataForManifest({
|
|
1430
|
+
sourceFile,
|
|
1431
|
+
runtimeExpr: '(undefined as any)',
|
|
1432
|
+
allowRuntimeFallback: false,
|
|
1433
|
+
})
|
|
1434
|
+
metaExpr = staticMetadata.manifestExpr
|
|
1433
1435
|
const manifestMetaImportName = `${metaPrefix}Manifest${importIdRef.value++}_${toVar(modId)}_${toVar(segs.join('_') || 'index')}`
|
|
1434
1436
|
const manifestMetadata = await loadPageMetadataForManifest({
|
|
1435
1437
|
sourceFile,
|
|
@@ -1440,7 +1442,6 @@ async function processPageFiles(options: {
|
|
|
1440
1442
|
if (manifestMetadata.requiresRuntimeImport) {
|
|
1441
1443
|
manifestImportStatement = buildImportStatement(`* as ${manifestMetaImportName}`, importPath)
|
|
1442
1444
|
}
|
|
1443
|
-
eagerImports.push(buildImportStatement(`${importName}, * as ${pageModName}`, importPath))
|
|
1444
1445
|
runtimeImports.push(buildImportStatement(`* as ${runtimeMetaName}`, importPath))
|
|
1445
1446
|
}
|
|
1446
1447
|
if (manifestImportStatement) {
|
|
@@ -1449,8 +1450,8 @@ async function processPageFiles(options: {
|
|
|
1449
1450
|
const baseProps = buildPageRouteProps(metaExpr, routePath)
|
|
1450
1451
|
const runtimeBaseProps = buildPageRouteProps(runtimeMetaExpr, routePath)
|
|
1451
1452
|
const manifestBaseProps = buildPageRouteProps(manifestMetaExpr, routePath)
|
|
1452
|
-
eagerRoutes.push(`{ ${baseProps}, Component: ${
|
|
1453
|
-
runtimeRoutes.push(`{ ${runtimeBaseProps}, Component:
|
|
1453
|
+
eagerRoutes.push(`{ ${baseProps}, Component: ${buildLazyRouteComponentExpression(importPath)} }`)
|
|
1454
|
+
runtimeRoutes.push(`{ ${runtimeBaseProps}, Component: ${buildLazyRouteComponentExpression(importPath)} }`)
|
|
1454
1455
|
manifestRoutes.push(`{ moduleId: ${toLiteral(modId)}, ${manifestBaseProps}, load: async () => { const mod = await ${buildDynamicImportExpression(importPath)}; return (mod.default ?? mod) as any } }`)
|
|
1455
1456
|
}
|
|
1456
1457
|
|
|
@@ -1460,8 +1461,8 @@ async function processPageFiles(options: {
|
|
|
1460
1461
|
const file = segs.pop()!
|
|
1461
1462
|
const name = stripModuleCodeExtension(file)
|
|
1462
1463
|
const routeSegs = [...segs, name].filter(Boolean)
|
|
1463
|
-
|
|
1464
|
-
|
|
1464
|
+
importIdRef.value++
|
|
1465
|
+
importIdRef.value++
|
|
1465
1466
|
const runtimeMetaName = `${metaPrefix}Runtime${importIdRef.value++}_${toVar(modId)}_${toVar(routeSegs.join('_') || 'index')}`
|
|
1466
1467
|
const importPath = sanitizeGeneratedModuleSpecifier(
|
|
1467
1468
|
`${fromApp ? appImportBase : pkgImportBase}/${type}/${[...segs, name].join('/')}`
|
|
@@ -1501,10 +1502,14 @@ async function processPageFiles(options: {
|
|
|
1501
1502
|
if (manifestMetadata.requiresRuntimeImport) {
|
|
1502
1503
|
manifestImportStatement = buildImportStatement(`* as ${manifestMetaImportName}`, metaImportPath)
|
|
1503
1504
|
}
|
|
1504
|
-
eagerImports.push(buildImportStatement(importName, importPath))
|
|
1505
1505
|
} else {
|
|
1506
|
-
metaExpr = `(${pageModName} as any).metadata`
|
|
1507
1506
|
runtimeMetaExpr = `(((${runtimeMetaName} as any).metadata) as any)`
|
|
1507
|
+
const staticMetadata = await loadPageMetadataForManifest({
|
|
1508
|
+
sourceFile,
|
|
1509
|
+
runtimeExpr: '(undefined as any)',
|
|
1510
|
+
allowRuntimeFallback: false,
|
|
1511
|
+
})
|
|
1512
|
+
metaExpr = staticMetadata.manifestExpr
|
|
1508
1513
|
const manifestMetaImportName = `${metaPrefix}Manifest${importIdRef.value++}_${toVar(modId)}_${toVar(routeSegs.join('_') || 'index')}`
|
|
1509
1514
|
const manifestMetadata = await loadPageMetadataForManifest({
|
|
1510
1515
|
sourceFile,
|
|
@@ -1515,7 +1520,6 @@ async function processPageFiles(options: {
|
|
|
1515
1520
|
if (manifestMetadata.requiresRuntimeImport) {
|
|
1516
1521
|
manifestImportStatement = buildImportStatement(`* as ${manifestMetaImportName}`, importPath)
|
|
1517
1522
|
}
|
|
1518
|
-
eagerImports.push(buildImportStatement(`${importName}, * as ${pageModName}`, importPath))
|
|
1519
1523
|
runtimeImports.push(buildImportStatement(`* as ${runtimeMetaName}`, importPath))
|
|
1520
1524
|
}
|
|
1521
1525
|
if (manifestImportStatement) {
|
|
@@ -1524,8 +1528,8 @@ async function processPageFiles(options: {
|
|
|
1524
1528
|
const baseProps = buildPageRouteProps(metaExpr, routePath)
|
|
1525
1529
|
const runtimeBaseProps = buildPageRouteProps(runtimeMetaExpr, routePath)
|
|
1526
1530
|
const manifestBaseProps = buildPageRouteProps(manifestMetaExpr, routePath)
|
|
1527
|
-
eagerRoutes.push(`{ ${baseProps}, Component: ${
|
|
1528
|
-
runtimeRoutes.push(`{ ${runtimeBaseProps}, Component:
|
|
1531
|
+
eagerRoutes.push(`{ ${baseProps}, Component: ${buildLazyRouteComponentExpression(importPath)} }`)
|
|
1532
|
+
runtimeRoutes.push(`{ ${runtimeBaseProps}, Component: ${buildLazyRouteComponentExpression(importPath)} }`)
|
|
1529
1533
|
manifestRoutes.push(`{ moduleId: ${toLiteral(modId)}, ${manifestBaseProps}, load: async () => { const mod = await ${buildDynamicImportExpression(importPath)}; return (mod.default ?? mod) as any } }`)
|
|
1530
1534
|
}
|
|
1531
1535
|
|
|
@@ -2090,6 +2094,10 @@ function renderLegacyCompatibleArray(entries: readonly string[]): string {
|
|
|
2090
2094
|
]`
|
|
2091
2095
|
}
|
|
2092
2096
|
|
|
2097
|
+
function buildLazyRouteComponentExpression(importPath: string): string {
|
|
2098
|
+
return `async (props: any) => { const mod = await ${buildDynamicImportExpression(importPath)}; const Component = (mod.default ?? mod) as any; return createElement(Component, props) }`
|
|
2099
|
+
}
|
|
2100
|
+
|
|
2093
2101
|
function renderAstLegacyModuleRegistryOutput(options: {
|
|
2094
2102
|
fileName: string
|
|
2095
2103
|
imports: GeneratedImportStatement[]
|
|
@@ -2164,6 +2172,10 @@ function buildRuntimeRouteComponent(importPath: string): WriterFunction {
|
|
|
2164
2172
|
})
|
|
2165
2173
|
}
|
|
2166
2174
|
|
|
2175
|
+
function rawExpression(source: string): WriterFunction {
|
|
2176
|
+
return (writer) => writer.write(source)
|
|
2177
|
+
}
|
|
2178
|
+
|
|
2167
2179
|
function buildPageRouteEntries(metaExpr: WriterFunction, routePath: string): GeneratedObjectEntry[] {
|
|
2168
2180
|
const meta = parenthesized(metaExpr)
|
|
2169
2181
|
return [
|
|
@@ -2298,15 +2310,15 @@ async function processPageFilesAst(options: {
|
|
|
2298
2310
|
continue
|
|
2299
2311
|
}
|
|
2300
2312
|
|
|
2301
|
-
const
|
|
2302
|
-
|
|
2313
|
+
const staticMetadata = await loadPageMetadataForManifest({
|
|
2314
|
+
sourceFile,
|
|
2315
|
+
runtimeExpr: '(undefined as any)',
|
|
2316
|
+
allowRuntimeFallback: false,
|
|
2317
|
+
})
|
|
2303
2318
|
addRoute({
|
|
2304
2319
|
importPath,
|
|
2305
2320
|
routePath,
|
|
2306
|
-
metaExpr:
|
|
2307
|
-
propertyAccess(asExpression(identifier(metaImportName), 'any'), 'metadata'),
|
|
2308
|
-
'any',
|
|
2309
|
-
),
|
|
2321
|
+
metaExpr: rawExpression(staticMetadata.manifestExpr),
|
|
2310
2322
|
})
|
|
2311
2323
|
}
|
|
2312
2324
|
|
|
@@ -2347,15 +2359,15 @@ async function processPageFilesAst(options: {
|
|
|
2347
2359
|
continue
|
|
2348
2360
|
}
|
|
2349
2361
|
|
|
2350
|
-
const
|
|
2351
|
-
|
|
2362
|
+
const staticMetadata = await loadPageMetadataForManifest({
|
|
2363
|
+
sourceFile,
|
|
2364
|
+
runtimeExpr: '(undefined as any)',
|
|
2365
|
+
allowRuntimeFallback: false,
|
|
2366
|
+
})
|
|
2352
2367
|
addRoute({
|
|
2353
2368
|
importPath,
|
|
2354
2369
|
routePath,
|
|
2355
|
-
metaExpr:
|
|
2356
|
-
propertyAccess(asExpression(identifier(metaImportName), 'any'), 'metadata'),
|
|
2357
|
-
'any',
|
|
2358
|
-
),
|
|
2370
|
+
metaExpr: rawExpression(staticMetadata.manifestExpr),
|
|
2359
2371
|
})
|
|
2360
2372
|
}
|
|
2361
2373
|
|
|
@@ -2609,6 +2621,7 @@ export async function generateModuleRegistry(options: ModuleRegistryOptions): Pr
|
|
|
2609
2621
|
const importIdRef = { value: 0 }
|
|
2610
2622
|
const trackedRoots = new Set<string>()
|
|
2611
2623
|
const requiresByModule = new Map<string, string[]>()
|
|
2624
|
+
let hasRouteComponents = false
|
|
2612
2625
|
|
|
2613
2626
|
// UMES conflict detection: collect file paths during module processing
|
|
2614
2627
|
const umesConflictSources: Array<{
|
|
@@ -2690,6 +2703,7 @@ export async function generateModuleRegistry(options: ModuleRegistryOptions): Pr
|
|
|
2690
2703
|
frontendRoutes.push(...generatedFrontendRoutes.eagerRoutes)
|
|
2691
2704
|
runtimeFrontendRoutes.push(...generatedFrontendRoutes.runtimeRoutes)
|
|
2692
2705
|
frontendRouteManifestDecls.push(...generatedFrontendRoutes.manifestRoutes)
|
|
2706
|
+
hasRouteComponents = true
|
|
2693
2707
|
}
|
|
2694
2708
|
}
|
|
2695
2709
|
|
|
@@ -2808,6 +2822,7 @@ export async function generateModuleRegistry(options: ModuleRegistryOptions): Pr
|
|
|
2808
2822
|
backendRoutes.push(...generatedBackendRoutes.eagerRoutes)
|
|
2809
2823
|
runtimeBackendRoutes.push(...generatedBackendRoutes.runtimeRoutes)
|
|
2810
2824
|
backendRouteManifestDecls.push(...generatedBackendRoutes.manifestRoutes)
|
|
2825
|
+
hasRouteComponents = true
|
|
2811
2826
|
}
|
|
2812
2827
|
}
|
|
2813
2828
|
|
|
@@ -3031,6 +3046,7 @@ export async function generateModuleRegistry(options: ModuleRegistryOptions): Pr
|
|
|
3031
3046
|
fileName: 'modules.generated.ts',
|
|
3032
3047
|
imports,
|
|
3033
3048
|
moduleEntries: moduleDecls,
|
|
3049
|
+
includeCreateElementImport: hasRouteComponents,
|
|
3034
3050
|
})
|
|
3035
3051
|
const runtimeOutput = renderAstLegacyModuleRegistryOutput({
|
|
3036
3052
|
fileName: 'modules.runtime.generated.ts',
|