@open-mercato/cli 0.6.1-develop.3187.1.4c96d17341 → 0.6.1-develop.3191.1.2511ae315f
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/generators/module-registry.js +31 -0
- package/dist/lib/generators/module-registry.js.map +2 -2
- package/package.json +5 -5
- package/src/lib/generators/__tests__/output-snapshots.test.ts +2 -0
- package/src/lib/generators/__tests__/structural-contracts.test.ts +19 -0
- package/src/lib/generators/module-registry.ts +35 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-mercato/cli",
|
|
3
|
-
"version": "0.6.1-develop.
|
|
3
|
+
"version": "0.6.1-develop.3191.1.2511ae315f",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
"@mikro-orm/decorators": "^7.0.14",
|
|
60
60
|
"@mikro-orm/migrations": "^7.0.14",
|
|
61
61
|
"@mikro-orm/postgresql": "^7.0.14",
|
|
62
|
-
"@open-mercato/queue": "0.6.1-develop.
|
|
63
|
-
"@open-mercato/shared": "0.6.1-develop.
|
|
62
|
+
"@open-mercato/queue": "0.6.1-develop.3191.1.2511ae315f",
|
|
63
|
+
"@open-mercato/shared": "0.6.1-develop.3191.1.2511ae315f",
|
|
64
64
|
"cross-spawn": "^7.0.6",
|
|
65
65
|
"pg": "8.20.0",
|
|
66
66
|
"semver": "^7.7.4",
|
|
@@ -70,10 +70,10 @@
|
|
|
70
70
|
"typescript": "^5.9.3"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
|
-
"@open-mercato/shared": "0.6.1-develop.
|
|
73
|
+
"@open-mercato/shared": "0.6.1-develop.3191.1.2511ae315f"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
|
-
"@open-mercato/shared": "0.6.1-develop.
|
|
76
|
+
"@open-mercato/shared": "0.6.1-develop.3191.1.2511ae315f",
|
|
77
77
|
"@types/jest": "^30.0.0",
|
|
78
78
|
"jest": "^30.3.0",
|
|
79
79
|
"ts-jest": "^29.4.9"
|
|
@@ -721,6 +721,7 @@ describe('generator output compatibility', () => {
|
|
|
721
721
|
'entity-fields-registry.ts',
|
|
722
722
|
'modules.app.generated.ts',
|
|
723
723
|
'modules.cli.generated.ts',
|
|
724
|
+
'enabled-module-ids.generated.ts',
|
|
724
725
|
]))
|
|
725
726
|
})
|
|
726
727
|
|
|
@@ -779,6 +780,7 @@ describe('generator output compatibility', () => {
|
|
|
779
780
|
'entity-fields-registry.ts',
|
|
780
781
|
'modules.app.generated.ts',
|
|
781
782
|
'modules.cli.generated.ts',
|
|
783
|
+
'enabled-module-ids.generated.ts',
|
|
782
784
|
]))
|
|
783
785
|
})
|
|
784
786
|
|
|
@@ -1226,6 +1226,25 @@ describe('bootstrap-modules.generated.ts', () => {
|
|
|
1226
1226
|
})
|
|
1227
1227
|
})
|
|
1228
1228
|
|
|
1229
|
+
describe('enabled-module-ids.generated.ts', () => {
|
|
1230
|
+
it('exports a plain string array of every enabled module id without runtime imports', async () => {
|
|
1231
|
+
const enabled = scaffoldFixture()
|
|
1232
|
+
const resolver = createMockResolver(enabled)
|
|
1233
|
+
await generateModuleRegistryApp({ resolver, quiet: true })
|
|
1234
|
+
const content = readGenerated('enabled-module-ids.generated.ts')
|
|
1235
|
+
|
|
1236
|
+
expect(content).toContain('export const enabledModuleIds: readonly string[]')
|
|
1237
|
+
expect(content).toContain('"orders"')
|
|
1238
|
+
expect(content).toContain('"products"')
|
|
1239
|
+
expect(content).toContain('"custom_app"')
|
|
1240
|
+
|
|
1241
|
+
expect(content).not.toMatch(/^import\s+/m)
|
|
1242
|
+
expect(content).not.toContain('@open-mercato/')
|
|
1243
|
+
expect(content).not.toContain('createElement')
|
|
1244
|
+
expect(content).not.toContain('createLazyModuleSubscriber')
|
|
1245
|
+
})
|
|
1246
|
+
})
|
|
1247
|
+
|
|
1229
1248
|
// ---------------------------------------------------------------------------
|
|
1230
1249
|
// modules.cli.generated.ts
|
|
1231
1250
|
// ---------------------------------------------------------------------------
|
|
@@ -41,6 +41,7 @@ import {
|
|
|
41
41
|
spreadExpression,
|
|
42
42
|
type GeneratedObjectEntry,
|
|
43
43
|
variableStatement,
|
|
44
|
+
writeArrayLiteral,
|
|
44
45
|
writeValue,
|
|
45
46
|
writeStatements,
|
|
46
47
|
} from './ast'
|
|
@@ -1989,6 +1990,35 @@ function renderAstLegacyAliasFile(options: {
|
|
|
1989
1990
|
return getSourceText(sourceFile)
|
|
1990
1991
|
}
|
|
1991
1992
|
|
|
1993
|
+
function renderEnabledModuleIdsFile(moduleIds: readonly string[]): string {
|
|
1994
|
+
const sourceFile = createGeneratedSourceFile('enabled-module-ids.generated.ts')
|
|
1995
|
+
addAutoGeneratedComment(sourceFile, 'registry (enabled-module-ids version)')
|
|
1996
|
+
|
|
1997
|
+
sourceFile.addVariableStatement({
|
|
1998
|
+
declarationKind: VariableDeclarationKind.Const,
|
|
1999
|
+
isExported: true,
|
|
2000
|
+
leadingTrivia: (writer) => {
|
|
2001
|
+
writer.newLine()
|
|
2002
|
+
writer.writeLine('// This file lists every enabled module ID without importing module runtime')
|
|
2003
|
+
writer.writeLine('// surfaces. It is safe to import from client bundles (no node:* dependencies).')
|
|
2004
|
+
},
|
|
2005
|
+
declarations: [
|
|
2006
|
+
{
|
|
2007
|
+
name: 'enabledModuleIds',
|
|
2008
|
+
type: 'readonly string[]',
|
|
2009
|
+
initializer: (writer) => {
|
|
2010
|
+
writeArrayLiteral(writer, moduleIds, (w, id) => {
|
|
2011
|
+
w.write(JSON.stringify(id))
|
|
2012
|
+
})
|
|
2013
|
+
writer.write(' as const')
|
|
2014
|
+
},
|
|
2015
|
+
},
|
|
2016
|
+
],
|
|
2017
|
+
})
|
|
2018
|
+
|
|
2019
|
+
return getSourceText(sourceFile)
|
|
2020
|
+
}
|
|
2021
|
+
|
|
1992
2022
|
function renderLegacyCompatibleArray(entries: readonly string[]): string {
|
|
1993
2023
|
return `[
|
|
1994
2024
|
${entries.join(',\n ')}
|
|
@@ -3084,6 +3114,8 @@ export async function generateModuleRegistryApp(options: ModuleRegistryOptions):
|
|
|
3084
3114
|
const checksumFile = path.join(outputDir, 'modules.app.generated.checksum')
|
|
3085
3115
|
const legacyOutFile = path.join(outputDir, 'bootstrap-modules.generated.ts')
|
|
3086
3116
|
const legacyChecksumFile = path.join(outputDir, 'bootstrap-modules.generated.checksum')
|
|
3117
|
+
const enabledIdsOutFile = path.join(outputDir, 'enabled-module-ids.generated.ts')
|
|
3118
|
+
const enabledIdsChecksumFile = path.join(outputDir, 'enabled-module-ids.generated.checksum')
|
|
3087
3119
|
|
|
3088
3120
|
const enabled = resolver.loadEnabledModules()
|
|
3089
3121
|
const imports: string[] = []
|
|
@@ -3392,6 +3424,9 @@ export async function generateModuleRegistryApp(options: ModuleRegistryOptions):
|
|
|
3392
3424
|
writeGeneratedFile({ outFile, checksumFile, content: output, structureChecksum, result, quiet })
|
|
3393
3425
|
writeGeneratedFile({ outFile: legacyOutFile, checksumFile: legacyChecksumFile, content: legacyOutput, structureChecksum, result, quiet })
|
|
3394
3426
|
|
|
3427
|
+
const enabledIdsOutput = renderEnabledModuleIdsFile(enabled.map((entry) => entry.id))
|
|
3428
|
+
writeGeneratedFile({ outFile: enabledIdsOutFile, checksumFile: enabledIdsChecksumFile, content: enabledIdsOutput, structureChecksum, result, quiet })
|
|
3429
|
+
|
|
3395
3430
|
return result
|
|
3396
3431
|
}
|
|
3397
3432
|
|