@open-mercato/cli 0.11.1-develop.8589.1.db1a76ea60 → 0.11.1-develop.8593.1.50784dae35
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/.turbo/turbo-build.log +1 -1
- package/AGENTS.md +1 -0
- package/dist/agentic/guides/module-facts.json +164 -164
- package/dist/agentic/guides/module-facts.v2.json +164 -164
- package/dist/agentic/guides/modules/agent_orchestrator/index.md +1 -1
- package/dist/agentic/guides/modules/ai_assistant/index.md +1 -1
- package/dist/agentic/guides/modules/api_docs/index.md +1 -1
- package/dist/agentic/guides/modules/api_keys/index.md +1 -1
- package/dist/agentic/guides/modules/attachments/index.md +1 -1
- package/dist/agentic/guides/modules/audit_logs/index.md +1 -1
- package/dist/agentic/guides/modules/auth/index.md +1 -1
- package/dist/agentic/guides/modules/availability/index.md +1 -1
- package/dist/agentic/guides/modules/backups/index.md +1 -1
- package/dist/agentic/guides/modules/business_rules/index.md +1 -1
- package/dist/agentic/guides/modules/carrier_inpost/index.md +1 -1
- package/dist/agentic/guides/modules/cart/index.md +1 -1
- package/dist/agentic/guides/modules/catalog/index.md +1 -1
- package/dist/agentic/guides/modules/channel_apns/index.md +1 -1
- package/dist/agentic/guides/modules/channel_discord/index.md +1 -1
- package/dist/agentic/guides/modules/channel_expo/index.md +1 -1
- package/dist/agentic/guides/modules/channel_fcm/index.md +1 -1
- package/dist/agentic/guides/modules/channel_gmail/index.md +1 -1
- package/dist/agentic/guides/modules/channel_imap/index.md +1 -1
- package/dist/agentic/guides/modules/channel_resend/index.md +1 -1
- package/dist/agentic/guides/modules/channel_ses/index.md +1 -1
- package/dist/agentic/guides/modules/channel_smtp/index.md +1 -1
- package/dist/agentic/guides/modules/checkout/index.md +1 -1
- package/dist/agentic/guides/modules/communication_channels/index.md +1 -1
- package/dist/agentic/guides/modules/configs/index.md +1 -1
- package/dist/agentic/guides/modules/content/index.md +1 -1
- package/dist/agentic/guides/modules/currencies/index.md +1 -1
- package/dist/agentic/guides/modules/customer_accounts/index.md +1 -1
- package/dist/agentic/guides/modules/customer_groups/index.md +1 -1
- package/dist/agentic/guides/modules/customers/index.md +1 -1
- package/dist/agentic/guides/modules/dashboards/index.md +1 -1
- package/dist/agentic/guides/modules/data_sync/index.md +1 -1
- package/dist/agentic/guides/modules/design_system/index.md +1 -1
- package/dist/agentic/guides/modules/devices/index.md +1 -1
- package/dist/agentic/guides/modules/dictionaries/index.md +1 -1
- package/dist/agentic/guides/modules/directory/index.md +1 -1
- package/dist/agentic/guides/modules/documents/index.md +1 -1
- package/dist/agentic/guides/modules/ecommerce/index.md +1 -1
- package/dist/agentic/guides/modules/entities/index.md +1 -1
- package/dist/agentic/guides/modules/eudr/index.md +1 -1
- package/dist/agentic/guides/modules/events/index.md +1 -1
- package/dist/agentic/guides/modules/feature_toggles/index.md +1 -1
- package/dist/agentic/guides/modules/forms/index.md +1 -1
- package/dist/agentic/guides/modules/gateway_autopay/index.md +1 -1
- package/dist/agentic/guides/modules/gateway_stripe/index.md +1 -1
- package/dist/agentic/guides/modules/gateway_tpay/index.md +1 -1
- package/dist/agentic/guides/modules/generators/index.md +1 -1
- package/dist/agentic/guides/modules/inbox_ops/index.md +1 -1
- package/dist/agentic/guides/modules/integrations/index.md +1 -1
- package/dist/agentic/guides/modules/messages/index.md +1 -1
- package/dist/agentic/guides/modules/notifications/index.md +1 -1
- package/dist/agentic/guides/modules/onboarding/index.md +1 -1
- package/dist/agentic/guides/modules/payment_gateways/index.md +1 -1
- package/dist/agentic/guides/modules/perspectives/index.md +1 -1
- package/dist/agentic/guides/modules/phone_calls/index.md +1 -1
- package/dist/agentic/guides/modules/planner/index.md +1 -1
- package/dist/agentic/guides/modules/portal/index.md +1 -1
- package/dist/agentic/guides/modules/progress/index.md +1 -1
- package/dist/agentic/guides/modules/promotions/index.md +1 -1
- package/dist/agentic/guides/modules/push_notifications/index.md +1 -1
- package/dist/agentic/guides/modules/query_index/index.md +1 -1
- package/dist/agentic/guides/modules/record_locks/index.md +1 -1
- package/dist/agentic/guides/modules/resources/index.md +1 -1
- package/dist/agentic/guides/modules/sales/index.md +1 -1
- package/dist/agentic/guides/modules/scheduler/index.md +1 -1
- package/dist/agentic/guides/modules/search/index.md +1 -1
- package/dist/agentic/guides/modules/security/index.md +1 -1
- package/dist/agentic/guides/modules/seeds/index.md +1 -1
- package/dist/agentic/guides/modules/shipping_carriers/index.md +1 -1
- package/dist/agentic/guides/modules/sso/index.md +1 -1
- package/dist/agentic/guides/modules/staff/index.md +1 -1
- package/dist/agentic/guides/modules/storage_s3/index.md +1 -1
- package/dist/agentic/guides/modules/sync_akeneo/index.md +1 -1
- package/dist/agentic/guides/modules/sync_excel/index.md +1 -1
- package/dist/agentic/guides/modules/system_status_overlays/index.md +1 -1
- package/dist/agentic/guides/modules/telemetry/index.md +1 -1
- package/dist/agentic/guides/modules/tillio/index.md +1 -1
- package/dist/agentic/guides/modules/translations/index.md +1 -1
- package/dist/agentic/guides/modules/warranty_claims/index.md +1 -1
- package/dist/agentic/guides/modules/webhooks/index.md +1 -1
- package/dist/agentic/guides/modules/wms/index.md +1 -1
- package/dist/agentic/guides/modules/workflows/index.md +1 -1
- package/dist/agentic/guides/reference-module-facts.json +1 -1
- package/dist/agentic/guides/upstream/manifest.json +1 -1
- package/dist/lib/generate-child-process.js +21 -3
- package/dist/lib/generate-child-process.js.map +2 -2
- package/dist/lib/generate-watch-events.js +135 -19
- package/dist/lib/generate-watch-events.js.map +2 -2
- package/dist/lib/generate-watch-plan.js +166 -0
- package/dist/lib/generate-watch-plan.js.map +7 -0
- package/dist/lib/generate-watch-runner.js +53 -0
- package/dist/lib/generate-watch-runner.js.map +7 -0
- package/dist/lib/generate-watch-structure.js +576 -203
- package/dist/lib/generate-watch-structure.js.map +3 -3
- package/dist/lib/generators/extensions/agent-files.js +1 -0
- package/dist/lib/generators/extensions/agent-files.js.map +2 -2
- package/dist/lib/generators/module-registry.js +148 -191
- package/dist/lib/generators/module-registry.js.map +3 -3
- package/dist/lib/generators/openapi.js +24 -1
- package/dist/lib/generators/openapi.js.map +2 -2
- package/dist/lib/generators/web-research-adapters.js +54 -22
- package/dist/lib/generators/web-research-adapters.js.map +2 -2
- package/dist/lib/in-process-generate-watcher.js +98 -75
- package/dist/lib/in-process-generate-watcher.js.map +2 -2
- package/dist/mercato.js +74 -46
- package/dist/mercato.js.map +2 -2
- package/package.json +7 -7
- package/src/lib/__tests__/generate-child-process.test.ts +30 -0
- package/src/lib/__tests__/generate-watch-events.test.ts +377 -8
- package/src/lib/__tests__/generate-watch-plan.test.ts +98 -0
- package/src/lib/__tests__/generate-watch-runner.test.ts +126 -0
- package/src/lib/__tests__/generate-watch-structure.test.ts +522 -1
- package/src/lib/__tests__/in-process-generate-watcher.test.ts +393 -6
- package/src/lib/__tests__/module-inspection.test.ts +17 -11
- package/src/lib/generate-child-process.ts +26 -3
- package/src/lib/generate-watch-events.ts +189 -17
- package/src/lib/generate-watch-plan.ts +177 -0
- package/src/lib/generate-watch-runner.ts +62 -0
- package/src/lib/generate-watch-structure.ts +666 -227
- package/src/lib/generators/__tests__/incremental-registry.test.ts +262 -0
- package/src/lib/generators/__tests__/openapi.test.ts +91 -1
- package/src/lib/generators/__tests__/web-research-adapters.test.ts +298 -87
- package/src/lib/generators/extension.ts +2 -0
- package/src/lib/generators/extensions/agent-files.ts +1 -0
- package/src/lib/generators/module-registry.ts +168 -200
- package/src/lib/generators/openapi.ts +34 -0
- package/src/lib/generators/web-research-adapters.ts +76 -21
- package/src/lib/in-process-generate-watcher.ts +151 -96
- package/src/mercato.ts +85 -53
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
type DevSupervisorWorkerDescriptor,
|
|
15
15
|
} from '../dev-supervisor-manifest'
|
|
16
16
|
import {
|
|
17
|
+
calculateChecksum,
|
|
17
18
|
calculateStructureChecksum,
|
|
18
19
|
toVar,
|
|
19
20
|
moduleHasExport,
|
|
@@ -91,6 +92,8 @@ type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'
|
|
|
91
92
|
export interface ModuleRegistryOptions {
|
|
92
93
|
resolver: PackageResolver
|
|
93
94
|
quiet?: boolean
|
|
95
|
+
/** Undefined generates every output; an explicit list selects output families. */
|
|
96
|
+
outputGroups?: readonly string[]
|
|
94
97
|
}
|
|
95
98
|
|
|
96
99
|
interface ModuleRegistryDiscovery {
|
|
@@ -3652,14 +3655,16 @@ function renderI18nLocaleLoadersFile(locales: string[]): string {
|
|
|
3652
3655
|
return `// AUTO-GENERATED by mercato generate registry (locale-specific i18n loaders)\nimport type { Module } from '@open-mercato/shared/modules/registry'\n\nexport async function loadI18nModules(locale: string): Promise<Module[]> {\n switch (locale) {\n${cases ? `${cases}\n` : ''} default:\n return []\n }\n}\n`
|
|
3653
3656
|
}
|
|
3654
3657
|
|
|
3655
|
-
function removeStaleI18nLocaleShards(outputDir: string, expectedFileNames: Set<string
|
|
3658
|
+
function removeStaleI18nLocaleShards(outputDir: string, expectedFileNames: Set<string>, result: GeneratorResult): void {
|
|
3656
3659
|
if (!fs.existsSync(outputDir)) return
|
|
3657
3660
|
for (const entry of fs.readdirSync(outputDir, { withFileTypes: true })) {
|
|
3658
3661
|
if (!entry.isFile()) continue
|
|
3659
3662
|
if (!/^modules\.i18n\..+\.generated\.(?:ts|checksum)$/.test(entry.name)) continue
|
|
3660
3663
|
if (entry.name.startsWith('modules.i18n.loaders.generated.')) continue
|
|
3661
3664
|
if (expectedFileNames.has(entry.name)) continue
|
|
3662
|
-
|
|
3665
|
+
const stalePath = path.join(outputDir, entry.name)
|
|
3666
|
+
fs.unlinkSync(stalePath)
|
|
3667
|
+
result.filesWritten.push(stalePath)
|
|
3663
3668
|
}
|
|
3664
3669
|
}
|
|
3665
3670
|
|
|
@@ -3687,30 +3692,44 @@ function resolveConventionFile(
|
|
|
3687
3692
|
|
|
3688
3693
|
type ModuleRegistryRenderOptions = ModuleRegistryOptions & {
|
|
3689
3694
|
discovery: ModuleRegistryDiscovery
|
|
3695
|
+
skipCommands?: boolean
|
|
3696
|
+
}
|
|
3697
|
+
|
|
3698
|
+
function selectsRegistryOutput(options: ModuleRegistryOptions, group: string): boolean {
|
|
3699
|
+
return options.outputGroups === undefined || options.outputGroups.includes(group)
|
|
3700
|
+
}
|
|
3701
|
+
|
|
3702
|
+
function createRegistryOutputWriter(options: ModuleRegistryRenderOptions, result: GeneratorResult) {
|
|
3703
|
+
const outputDir = options.resolver.getOutputDir()
|
|
3704
|
+
return (group: string, fileName: string, render: () => string): void => {
|
|
3705
|
+
if (!selectsRegistryOutput(options, group)) return
|
|
3706
|
+
const content = render()
|
|
3707
|
+
writeGeneratedFile({
|
|
3708
|
+
outFile: path.join(outputDir, fileName),
|
|
3709
|
+
checksumFile: path.join(outputDir, fileName.replace(/\.(ts|json)$/, '.checksum')),
|
|
3710
|
+
content,
|
|
3711
|
+
// Incremental output identity must not depend on unrelated module-root mtimes.
|
|
3712
|
+
// Keep the historical checksum format and value on the default full path.
|
|
3713
|
+
structureChecksum: options.outputGroups === undefined
|
|
3714
|
+
? options.discovery.getStructureChecksum()
|
|
3715
|
+
: calculateChecksum(content),
|
|
3716
|
+
result,
|
|
3717
|
+
quiet: options.quiet,
|
|
3718
|
+
})
|
|
3719
|
+
}
|
|
3690
3720
|
}
|
|
3691
3721
|
|
|
3692
3722
|
async function generateModuleRegistryFromDiscovery(options: ModuleRegistryRenderOptions): Promise<GeneratorResult> {
|
|
3693
3723
|
const { resolver, quiet = false } = options
|
|
3694
3724
|
const { discovery } = options
|
|
3695
3725
|
const result = createGeneratorResult()
|
|
3726
|
+
if (options.outputGroups !== undefined && !options.outputGroups.some((group) =>
|
|
3727
|
+
['main', 'runtime', 'frontend-routes', 'backend-routes', 'api-routes', 'commands', 'plugins', 'bootstrap-registrations'].includes(group)
|
|
3728
|
+
|| group.startsWith('registry.'),
|
|
3729
|
+
)) return result
|
|
3730
|
+
const writeOutput = createRegistryOutputWriter(options, result)
|
|
3696
3731
|
|
|
3697
3732
|
const outputDir = resolver.getOutputDir()
|
|
3698
|
-
const outFile = path.join(outputDir, 'modules.generated.ts')
|
|
3699
|
-
const checksumFile = path.join(outputDir, 'modules.generated.checksum')
|
|
3700
|
-
const runtimeOutFile = path.join(outputDir, 'modules.runtime.generated.ts')
|
|
3701
|
-
const runtimeChecksumFile = path.join(outputDir, 'modules.runtime.generated.checksum')
|
|
3702
|
-
const frontendRoutesOutFile = path.join(outputDir, 'frontend-routes.generated.ts')
|
|
3703
|
-
const frontendRoutesChecksumFile = path.join(outputDir, 'frontend-routes.generated.checksum')
|
|
3704
|
-
const backendRoutesOutFile = path.join(outputDir, 'backend-routes.generated.ts')
|
|
3705
|
-
const backendRoutesChecksumFile = path.join(outputDir, 'backend-routes.generated.checksum')
|
|
3706
|
-
const apiRoutesOutFile = path.join(outputDir, 'api-routes.generated.ts')
|
|
3707
|
-
const apiRoutesChecksumFile = path.join(outputDir, 'api-routes.generated.checksum')
|
|
3708
|
-
const bootstrapRegsOutFile = path.join(outputDir, 'bootstrap-registrations.generated.ts')
|
|
3709
|
-
const bootstrapRegsChecksumFile = path.join(outputDir, 'bootstrap-registrations.generated.checksum')
|
|
3710
|
-
const legacySubscribersOutFile = path.join(outputDir, 'subscribers.generated.ts')
|
|
3711
|
-
const legacySubscribersChecksumFile = path.join(outputDir, 'subscribers.generated.checksum')
|
|
3712
|
-
const commandLoadersOutFile = path.join(outputDir, 'command-loaders.generated.ts')
|
|
3713
|
-
const commandLoadersChecksumFile = path.join(outputDir, 'command-loaders.generated.checksum')
|
|
3714
3733
|
|
|
3715
3734
|
const enabled = discovery.enabled
|
|
3716
3735
|
const extensions = loadGeneratorExtensions(resolver)
|
|
@@ -3869,6 +3888,9 @@ async function generateModuleRegistryFromDiscovery(options: ModuleRegistryRender
|
|
|
3869
3888
|
sanitizeGeneratedModuleSpecifier,
|
|
3870
3889
|
}
|
|
3871
3890
|
for (const extension of extensions) {
|
|
3891
|
+
// Extensions with no shared import IDs can skip discovery as well as emission.
|
|
3892
|
+
// Other scans retain canonical full-generation numbering for selected outputs.
|
|
3893
|
+
if (extension.usesSharedImportIds === false && !selectsRegistryOutput(options, extension.id)) continue
|
|
3872
3894
|
extension.scanModule(extensionContext)
|
|
3873
3895
|
}
|
|
3874
3896
|
|
|
@@ -4276,49 +4298,69 @@ async function generateModuleRegistryFromDiscovery(options: ModuleRegistryRender
|
|
|
4276
4298
|
}
|
|
4277
4299
|
}
|
|
4278
4300
|
|
|
4279
|
-
|
|
4301
|
+
exitOnMissingModuleRequires(discovery.identities, requiresByModule)
|
|
4302
|
+
|
|
4303
|
+
writeOutput('main', 'modules.generated.ts', () => renderAstModuleRegistryFile({
|
|
4280
4304
|
fileName: 'modules.generated.ts',
|
|
4281
4305
|
generator: 'registry',
|
|
4282
4306
|
imports,
|
|
4283
4307
|
moduleEntries: moduleDecls,
|
|
4284
4308
|
includeCreateElementImport: hasRouteComponents,
|
|
4285
4309
|
includeAbandonHookImport: hasAbandonHookWorkers,
|
|
4286
|
-
})
|
|
4287
|
-
|
|
4310
|
+
}))
|
|
4311
|
+
writeOutput('runtime', 'modules.runtime.generated.ts', () => renderAstModuleRegistryFile({
|
|
4288
4312
|
fileName: 'modules.runtime.generated.ts',
|
|
4289
4313
|
generator: 'registry',
|
|
4290
4314
|
imports: runtimeImports,
|
|
4291
4315
|
moduleEntries: runtimeModuleDecls,
|
|
4292
4316
|
includeCreateElementImport: true,
|
|
4293
4317
|
includeAbandonHookImport: hasAbandonHookWorkers,
|
|
4294
|
-
})
|
|
4295
|
-
|
|
4318
|
+
}))
|
|
4319
|
+
writeOutput('frontend-routes', 'frontend-routes.generated.ts', () => renderAstManifestFile({
|
|
4296
4320
|
fileName: 'frontend-routes.generated.ts',
|
|
4297
4321
|
typeName: 'FrontendRouteManifestEntry',
|
|
4298
4322
|
exportName: 'frontendRoutes',
|
|
4299
4323
|
imports: frontendRouteManifestImports,
|
|
4300
4324
|
entries: frontendRouteManifestDecls,
|
|
4301
|
-
})
|
|
4302
|
-
|
|
4325
|
+
}))
|
|
4326
|
+
writeOutput('backend-routes', 'backend-routes.generated.ts', () => renderAstManifestFile({
|
|
4303
4327
|
fileName: 'backend-routes.generated.ts',
|
|
4304
4328
|
typeName: 'BackendRouteManifestEntry',
|
|
4305
4329
|
exportName: 'backendRoutes',
|
|
4306
4330
|
imports: backendRouteManifestImports,
|
|
4307
4331
|
entries: backendRouteManifestDecls,
|
|
4308
|
-
})
|
|
4309
|
-
|
|
4332
|
+
}))
|
|
4333
|
+
writeOutput('api-routes', 'api-routes.generated.ts', () => renderAstManifestFile({
|
|
4310
4334
|
fileName: 'api-routes.generated.ts',
|
|
4311
4335
|
typeName: 'ApiRouteManifestEntry',
|
|
4312
4336
|
exportName: 'apiRoutes',
|
|
4313
4337
|
entries: apiRouteManifestDecls,
|
|
4314
|
-
})
|
|
4315
|
-
const
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4338
|
+
}))
|
|
4339
|
+
for (const kind of ['backend', 'api'] as const) {
|
|
4340
|
+
const group = `${kind}-routes`
|
|
4341
|
+
if (!selectsRegistryOutput(options, group)) continue
|
|
4342
|
+
const routeManifestOutputs = [
|
|
4343
|
+
...renderRouteManifestShardOutputs(kind, kind === 'backend' ? backendRouteShardEntries : apiRouteShardEntries),
|
|
4344
|
+
renderRouteMetadataOutput(kind, kind === 'backend' ? backendRouteMetadataEntries : apiRouteMetadataEntries),
|
|
4345
|
+
]
|
|
4346
|
+
const expectedRouteManifestFiles = new Set(routeManifestOutputs.flatMap(({ fileName }) => [
|
|
4347
|
+
fileName,
|
|
4348
|
+
fileName.replace(/\.ts$/, '.checksum'),
|
|
4349
|
+
]))
|
|
4350
|
+
if (fs.existsSync(outputDir)) {
|
|
4351
|
+
for (const entry of fs.readdirSync(outputDir, { withFileTypes: true })) {
|
|
4352
|
+
if (!entry.isFile() || !entry.name.startsWith(`${kind}-route-shard.`) || !routeManifestShardFilePattern.test(entry.name)) continue
|
|
4353
|
+
if (expectedRouteManifestFiles.has(entry.name)) continue
|
|
4354
|
+
const stalePath = path.join(outputDir, entry.name)
|
|
4355
|
+
fs.unlinkSync(stalePath)
|
|
4356
|
+
result.filesWritten.push(stalePath)
|
|
4357
|
+
}
|
|
4358
|
+
}
|
|
4359
|
+
for (const routeOutput of routeManifestOutputs) {
|
|
4360
|
+
writeOutput(group, routeOutput.fileName, () => routeOutput.content)
|
|
4361
|
+
}
|
|
4362
|
+
}
|
|
4363
|
+
writeOutput('runtime', 'subscribers.generated.ts', () => renderAstLegacyAliasFile({
|
|
4322
4364
|
fileName: 'subscribers.generated.ts',
|
|
4323
4365
|
exportName: 'moduleSubscribers',
|
|
4324
4366
|
exportType: "NonNullable<Module['subscribers']>",
|
|
@@ -4334,78 +4376,41 @@ async function generateModuleRegistryFromDiscovery(options: ModuleRegistryRender
|
|
|
4334
4376
|
),
|
|
4335
4377
|
}),
|
|
4336
4378
|
]),
|
|
4337
|
-
})
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
const structureChecksum = discovery.getStructureChecksum()
|
|
4341
|
-
|
|
4342
|
-
writeGeneratedFile({ outFile, checksumFile, content: output, structureChecksum, result, quiet })
|
|
4343
|
-
writeGeneratedFile({ outFile: runtimeOutFile, checksumFile: runtimeChecksumFile, content: runtimeOutput, structureChecksum, result, quiet })
|
|
4344
|
-
writeGeneratedFile({ outFile: frontendRoutesOutFile, checksumFile: frontendRoutesChecksumFile, content: frontendRoutesOutput, structureChecksum, result, quiet })
|
|
4345
|
-
writeGeneratedFile({ outFile: backendRoutesOutFile, checksumFile: backendRoutesChecksumFile, content: backendRoutesOutput, structureChecksum, result, quiet })
|
|
4346
|
-
writeGeneratedFile({ outFile: apiRoutesOutFile, checksumFile: apiRoutesChecksumFile, content: apiRoutesOutput, structureChecksum, result, quiet })
|
|
4347
|
-
const expectedRouteManifestFiles = new Set(routeManifestOutputs.flatMap(({ fileName }) => [
|
|
4348
|
-
fileName,
|
|
4349
|
-
fileName.replace(/\.ts$/, '.checksum'),
|
|
4350
|
-
]))
|
|
4351
|
-
if (fs.existsSync(outputDir)) {
|
|
4352
|
-
for (const entry of fs.readdirSync(outputDir, { withFileTypes: true })) {
|
|
4353
|
-
if (!entry.isFile() || !routeManifestShardFilePattern.test(entry.name)) continue
|
|
4354
|
-
if (expectedRouteManifestFiles.has(entry.name)) continue
|
|
4355
|
-
const stalePath = path.join(outputDir, entry.name)
|
|
4356
|
-
fs.unlinkSync(stalePath)
|
|
4357
|
-
result.filesWritten.push(stalePath)
|
|
4358
|
-
}
|
|
4359
|
-
}
|
|
4360
|
-
for (const routeOutput of routeManifestOutputs) {
|
|
4361
|
-
writeGeneratedFile({
|
|
4362
|
-
outFile: path.join(outputDir, routeOutput.fileName),
|
|
4363
|
-
checksumFile: path.join(outputDir, routeOutput.fileName.replace(/\.ts$/, '.checksum')),
|
|
4364
|
-
content: routeOutput.content,
|
|
4365
|
-
structureChecksum,
|
|
4366
|
-
result,
|
|
4367
|
-
quiet,
|
|
4368
|
-
})
|
|
4379
|
+
}))
|
|
4380
|
+
if (!options.skipCommands) {
|
|
4381
|
+
writeOutput('commands', 'command-loaders.generated.ts', () => renderCommandLoadersFile(commandLoaderEntries))
|
|
4369
4382
|
}
|
|
4370
|
-
writeGeneratedFile({ outFile: legacySubscribersOutFile, checksumFile: legacySubscribersChecksumFile, content: legacySubscribersOutput, structureChecksum, result, quiet })
|
|
4371
|
-
const commandLoadersOutput = renderCommandLoadersFile(commandLoaderEntries)
|
|
4372
|
-
writeGeneratedFile({ outFile: commandLoadersOutFile, checksumFile: commandLoadersChecksumFile, content: commandLoadersOutput, structureChecksum, result, quiet })
|
|
4373
4383
|
|
|
4374
4384
|
for (const extension of extensions) {
|
|
4385
|
+
// generateOutput may write outside outputDir (notably file agents), so select before calling it.
|
|
4386
|
+
if (!selectsRegistryOutput(options, extension.id)) continue
|
|
4375
4387
|
const outputs = extension.generateOutput()
|
|
4376
4388
|
for (const [fileName, content] of outputs) {
|
|
4377
|
-
|
|
4378
|
-
outFile: path.join(outputDir, fileName),
|
|
4379
|
-
checksumFile: path.join(outputDir, fileName.replace('.ts', '.checksum')),
|
|
4380
|
-
content,
|
|
4381
|
-
structureChecksum,
|
|
4382
|
-
result,
|
|
4383
|
-
quiet,
|
|
4384
|
-
})
|
|
4389
|
+
writeOutput(extension.id, fileName, () => content)
|
|
4385
4390
|
}
|
|
4386
4391
|
}
|
|
4387
4392
|
|
|
4388
4393
|
// Generator plugin outputs (registered via modules' generators.ts)
|
|
4389
|
-
|
|
4390
|
-
const
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
}
|
|
4394
|
+
if (selectsRegistryOutput(options, 'plugins')) {
|
|
4395
|
+
for (const [pluginId, plugin] of pluginRegistry) {
|
|
4396
|
+
const state = pluginState.get(pluginId)!
|
|
4397
|
+
writeOutput('plugins', pluginOutputNames.get(pluginId)!, () => plugin.buildOutput({
|
|
4398
|
+
importSection: state.imports.join('\n'),
|
|
4399
|
+
entriesLiteral: state.configs.join(',\n '),
|
|
4400
|
+
}))
|
|
4401
|
+
}
|
|
4402
|
+
reconcileGeneratorPluginOutputs({
|
|
4403
|
+
outputDir,
|
|
4404
|
+
outputNames: pluginOutputNames.values(),
|
|
4405
|
+
result,
|
|
4406
|
+
})
|
|
4407
|
+
}
|
|
4403
4408
|
|
|
4404
4409
|
// Bootstrap registrations: aggregate core registrations + plugin bootstrap-registration hooks
|
|
4405
4410
|
// into one file. Always written (with at least the core backend route registration) so bootstrap.ts
|
|
4406
4411
|
// can unconditionally import it and every runtime consumer sees a populated route manifest
|
|
4407
4412
|
// regardless of Next.js server bundle isolation.
|
|
4408
|
-
{
|
|
4413
|
+
if (selectsRegistryOutput(options, 'bootstrap-registrations')) {
|
|
4409
4414
|
const bootstrapPlugins = [...pluginRegistry.values()].filter((p) => p.bootstrapRegistration)
|
|
4410
4415
|
const allEntryImports: string[] = [
|
|
4411
4416
|
buildImportStatement(`{ backendRouteFacades }`, `./backend-route-shards.generated`),
|
|
@@ -4425,12 +4430,11 @@ async function generateModuleRegistryFromDiscovery(options: ModuleRegistryRender
|
|
|
4425
4430
|
allRegImports.push(...reg.registrationImports)
|
|
4426
4431
|
allCalls.push(reg.buildCall(reg.entriesExportName))
|
|
4427
4432
|
}
|
|
4428
|
-
|
|
4433
|
+
writeOutput('bootstrap-registrations', 'bootstrap-registrations.generated.ts', () => renderBootstrapRegistrationsFile({
|
|
4429
4434
|
entryImports: allEntryImports,
|
|
4430
4435
|
registrationImports: allRegImports,
|
|
4431
4436
|
calls: allCalls,
|
|
4432
|
-
})
|
|
4433
|
-
writeGeneratedFile({ outFile: bootstrapRegsOutFile, checksumFile: bootstrapRegsChecksumFile, content: bootstrapRegsOutput, structureChecksum, result, quiet })
|
|
4437
|
+
}))
|
|
4434
4438
|
}
|
|
4435
4439
|
|
|
4436
4440
|
return result
|
|
@@ -4440,22 +4444,13 @@ async function generateModuleRegistryAppFromDiscovery(options: ModuleRegistryRen
|
|
|
4440
4444
|
const { resolver, quiet = false } = options
|
|
4441
4445
|
const { discovery } = options
|
|
4442
4446
|
const result = createGeneratorResult()
|
|
4447
|
+
if (options.outputGroups !== undefined && !options.outputGroups.some((group) =>
|
|
4448
|
+
['app', 'bootstrap', 'i18n', 'enabled-ids'].includes(group)
|
|
4449
|
+
|| (group === 'commands' && !options.skipCommands),
|
|
4450
|
+
)) return result
|
|
4451
|
+
const writeOutput = createRegistryOutputWriter(options, result)
|
|
4443
4452
|
|
|
4444
4453
|
const outputDir = resolver.getOutputDir()
|
|
4445
|
-
const outFile = path.join(outputDir, 'modules.app.generated.ts')
|
|
4446
|
-
const checksumFile = path.join(outputDir, 'modules.app.generated.checksum')
|
|
4447
|
-
const bootstrapOutFile = path.join(outputDir, 'modules.bootstrap.generated.ts')
|
|
4448
|
-
const bootstrapChecksumFile = path.join(outputDir, 'modules.bootstrap.generated.checksum')
|
|
4449
|
-
const i18nOutFile = path.join(outputDir, 'modules.i18n.generated.ts')
|
|
4450
|
-
const i18nChecksumFile = path.join(outputDir, 'modules.i18n.generated.checksum')
|
|
4451
|
-
const i18nLoadersOutFile = path.join(outputDir, 'modules.i18n.loaders.generated.ts')
|
|
4452
|
-
const i18nLoadersChecksumFile = path.join(outputDir, 'modules.i18n.loaders.generated.checksum')
|
|
4453
|
-
const legacyOutFile = path.join(outputDir, 'bootstrap-modules.generated.ts')
|
|
4454
|
-
const legacyChecksumFile = path.join(outputDir, 'bootstrap-modules.generated.checksum')
|
|
4455
|
-
const enabledIdsOutFile = path.join(outputDir, 'enabled-module-ids.generated.ts')
|
|
4456
|
-
const enabledIdsChecksumFile = path.join(outputDir, 'enabled-module-ids.generated.checksum')
|
|
4457
|
-
const commandLoadersOutFile = path.join(outputDir, 'command-loaders.generated.ts')
|
|
4458
|
-
const commandLoadersChecksumFile = path.join(outputDir, 'command-loaders.generated.checksum')
|
|
4459
4454
|
|
|
4460
4455
|
const enabled = discovery.enabled
|
|
4461
4456
|
const imports: string[] = []
|
|
@@ -4764,84 +4759,64 @@ async function generateModuleRegistryAppFromDiscovery(options: ModuleRegistryRen
|
|
|
4764
4759
|
i18nModuleDecls.push(objectLiteral(i18nModuleEntries))
|
|
4765
4760
|
}
|
|
4766
4761
|
|
|
4767
|
-
|
|
4762
|
+
|
|
4763
|
+
exitOnMissingModuleRequires(discovery.identities, requiresByModule)
|
|
4764
|
+
|
|
4765
|
+
writeOutput('app', 'modules.app.generated.ts', () => renderAstModuleRegistryFile({
|
|
4768
4766
|
fileName: 'modules.app.generated.ts',
|
|
4769
4767
|
generator: 'registry (app version)',
|
|
4770
4768
|
imports,
|
|
4771
4769
|
moduleEntries: moduleDecls,
|
|
4772
4770
|
includeCreateElementImport: hasRouteComponents,
|
|
4773
4771
|
includeAbandonHookImport: hasAbandonHookWorkers,
|
|
4774
|
-
})
|
|
4775
|
-
|
|
4772
|
+
}))
|
|
4773
|
+
writeOutput('bootstrap', 'modules.bootstrap.generated.ts', () => renderAstModuleRegistryFile({
|
|
4776
4774
|
fileName: 'modules.bootstrap.generated.ts',
|
|
4777
4775
|
generator: 'registry (bootstrap version)',
|
|
4778
4776
|
imports: bootstrapImports,
|
|
4779
4777
|
moduleEntries: bootstrapModuleDecls,
|
|
4780
4778
|
includeAbandonHookImport: hasAbandonHookWorkers,
|
|
4781
|
-
})
|
|
4782
|
-
|
|
4779
|
+
}))
|
|
4780
|
+
writeOutput('i18n', 'modules.i18n.generated.ts', () => renderAstModuleRegistryFile({
|
|
4783
4781
|
fileName: 'modules.i18n.generated.ts',
|
|
4784
4782
|
generator: 'registry (i18n version)',
|
|
4785
4783
|
imports: i18nImports,
|
|
4786
4784
|
moduleEntries: i18nModuleDecls,
|
|
4787
4785
|
includeAbandonHookImport: hasAbandonHookWorkers,
|
|
4788
|
-
})
|
|
4789
|
-
|
|
4786
|
+
}))
|
|
4787
|
+
if (selectsRegistryOutput(options, 'i18n')) {
|
|
4788
|
+
const i18nLocales = [...i18nLocaleShards.keys()].sort((a, b) => a.localeCompare(b))
|
|
4789
|
+
const shardFileNames = new Set<string>()
|
|
4790
|
+
const expectedShardArtifacts = new Set<string>()
|
|
4791
|
+
for (const locale of i18nLocales) {
|
|
4792
|
+
const fileName = buildI18nLocaleShardFileName(locale)
|
|
4793
|
+
if (shardFileNames.has(fileName)) {
|
|
4794
|
+
throw new Error(`Locale names produce the same generated i18n shard file: ${locale}`)
|
|
4795
|
+
}
|
|
4796
|
+
shardFileNames.add(fileName)
|
|
4797
|
+
expectedShardArtifacts.add(fileName)
|
|
4798
|
+
expectedShardArtifacts.add(fileName.replace(/\.ts$/, '.checksum'))
|
|
4799
|
+
const shard = i18nLocaleShards.get(locale)!
|
|
4800
|
+
writeOutput('i18n', fileName, () => renderAstI18nLocaleRegistryFile({
|
|
4801
|
+
fileName,
|
|
4802
|
+
imports: shard.imports,
|
|
4803
|
+
moduleEntries: shard.moduleDecls,
|
|
4804
|
+
}))
|
|
4805
|
+
}
|
|
4806
|
+
removeStaleI18nLocaleShards(outputDir, expectedShardArtifacts, result)
|
|
4807
|
+
writeOutput('i18n', 'modules.i18n.loaders.generated.ts', () => renderI18nLocaleLoadersFile(i18nLocales))
|
|
4808
|
+
}
|
|
4809
|
+
writeOutput('bootstrap', 'bootstrap-modules.generated.ts', () => renderAstLegacyAliasFile({
|
|
4790
4810
|
fileName: 'bootstrap-modules.generated.ts',
|
|
4791
4811
|
exportName: 'bootstrapModules',
|
|
4792
4812
|
exportType: 'Module[]',
|
|
4793
4813
|
sourceFileName: 'modules.bootstrap.generated.ts',
|
|
4794
4814
|
initializer: identifier('modules'),
|
|
4795
|
-
})
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
const structureChecksum = discovery.getStructureChecksum()
|
|
4800
|
-
writeGeneratedFile({ outFile, checksumFile, content: output, structureChecksum, result, quiet })
|
|
4801
|
-
writeGeneratedFile({ outFile: bootstrapOutFile, checksumFile: bootstrapChecksumFile, content: bootstrapOutput, structureChecksum, result, quiet })
|
|
4802
|
-
writeGeneratedFile({ outFile: i18nOutFile, checksumFile: i18nChecksumFile, content: i18nOutput, structureChecksum, result, quiet })
|
|
4803
|
-
const i18nLocales = [...i18nLocaleShards.keys()].sort((a, b) => a.localeCompare(b))
|
|
4804
|
-
const shardFileNames = new Set<string>()
|
|
4805
|
-
const expectedShardArtifacts = new Set<string>()
|
|
4806
|
-
for (const locale of i18nLocales) {
|
|
4807
|
-
const fileName = buildI18nLocaleShardFileName(locale)
|
|
4808
|
-
if (shardFileNames.has(fileName)) {
|
|
4809
|
-
throw new Error(`Locale names produce the same generated i18n shard file: ${locale}`)
|
|
4810
|
-
}
|
|
4811
|
-
shardFileNames.add(fileName)
|
|
4812
|
-
expectedShardArtifacts.add(fileName)
|
|
4813
|
-
expectedShardArtifacts.add(fileName.replace(/\.ts$/, '.checksum'))
|
|
4814
|
-
const shard = i18nLocaleShards.get(locale)!
|
|
4815
|
-
const content = renderAstI18nLocaleRegistryFile({
|
|
4816
|
-
fileName,
|
|
4817
|
-
imports: shard.imports,
|
|
4818
|
-
moduleEntries: shard.moduleDecls,
|
|
4819
|
-
})
|
|
4820
|
-
writeGeneratedFile({
|
|
4821
|
-
outFile: path.join(outputDir, fileName),
|
|
4822
|
-
checksumFile: path.join(outputDir, fileName.replace(/\.ts$/, '.checksum')),
|
|
4823
|
-
content,
|
|
4824
|
-
structureChecksum,
|
|
4825
|
-
result,
|
|
4826
|
-
quiet,
|
|
4827
|
-
})
|
|
4815
|
+
}))
|
|
4816
|
+
writeOutput('enabled-ids', 'enabled-module-ids.generated.ts', () => renderEnabledModuleIdsFile(enabled.map((entry) => entry.id)))
|
|
4817
|
+
if (!options.skipCommands) {
|
|
4818
|
+
writeOutput('commands', 'command-loaders.generated.ts', () => renderCommandLoadersFile(commandLoaderEntries))
|
|
4828
4819
|
}
|
|
4829
|
-
removeStaleI18nLocaleShards(outputDir, expectedShardArtifacts)
|
|
4830
|
-
writeGeneratedFile({
|
|
4831
|
-
outFile: i18nLoadersOutFile,
|
|
4832
|
-
checksumFile: i18nLoadersChecksumFile,
|
|
4833
|
-
content: renderI18nLocaleLoadersFile(i18nLocales),
|
|
4834
|
-
structureChecksum,
|
|
4835
|
-
result,
|
|
4836
|
-
quiet,
|
|
4837
|
-
})
|
|
4838
|
-
writeGeneratedFile({ outFile: legacyOutFile, checksumFile: legacyChecksumFile, content: legacyOutput, structureChecksum, result, quiet })
|
|
4839
|
-
|
|
4840
|
-
const enabledIdsOutput = renderEnabledModuleIdsFile(enabled.map((entry) => entry.id))
|
|
4841
|
-
writeGeneratedFile({ outFile: enabledIdsOutFile, checksumFile: enabledIdsChecksumFile, content: enabledIdsOutput, structureChecksum, result, quiet })
|
|
4842
|
-
|
|
4843
|
-
const commandLoadersOutput = renderCommandLoadersFile(commandLoaderEntries)
|
|
4844
|
-
writeGeneratedFile({ outFile: commandLoadersOutFile, checksumFile: commandLoadersChecksumFile, content: commandLoadersOutput, structureChecksum, result, quiet })
|
|
4845
4820
|
|
|
4846
4821
|
return result
|
|
4847
4822
|
}
|
|
@@ -4859,16 +4834,11 @@ async function generateModuleRegistryCliFromDiscovery(options: ModuleRegistryRen
|
|
|
4859
4834
|
const { resolver, quiet = false } = options
|
|
4860
4835
|
const { discovery } = options
|
|
4861
4836
|
const result = createGeneratorResult()
|
|
4837
|
+
if (options.outputGroups !== undefined && !options.outputGroups.some((group) =>
|
|
4838
|
+
['cli', 'supervisor'].includes(group) || (group === 'commands' && !options.skipCommands),
|
|
4839
|
+
)) return result
|
|
4840
|
+
const writeOutput = createRegistryOutputWriter(options, result)
|
|
4862
4841
|
|
|
4863
|
-
const outputDir = resolver.getOutputDir()
|
|
4864
|
-
const outFile = path.join(outputDir, 'modules.cli.generated.ts')
|
|
4865
|
-
const checksumFile = path.join(outputDir, 'modules.cli.generated.checksum')
|
|
4866
|
-
const legacyOutFile = path.join(outputDir, 'cli-modules.generated.ts')
|
|
4867
|
-
const legacyChecksumFile = path.join(outputDir, 'cli-modules.generated.checksum')
|
|
4868
|
-
const commandLoadersOutFile = path.join(outputDir, 'command-loaders.generated.ts')
|
|
4869
|
-
const commandLoadersChecksumFile = path.join(outputDir, 'command-loaders.generated.checksum')
|
|
4870
|
-
const devSupervisorOutFile = path.join(outputDir, DEV_SUPERVISOR_MANIFEST_FILE)
|
|
4871
|
-
const devSupervisorChecksumFile = path.join(outputDir, 'dev-supervisor.generated.checksum')
|
|
4872
4842
|
|
|
4873
4843
|
const enabled = discovery.enabled
|
|
4874
4844
|
const imports: string[] = []
|
|
@@ -4879,8 +4849,10 @@ async function generateModuleRegistryCliFromDiscovery(options: ModuleRegistryRen
|
|
|
4879
4849
|
const commandLoaderEntries: CommandLoaderGenerationEntry[] = []
|
|
4880
4850
|
const devSupervisorWorkers: DevSupervisorWorkerDescriptor[] = []
|
|
4881
4851
|
let schedulerStartStatus: DevSupervisorSchedulerStartStatus = 'missing-module'
|
|
4882
|
-
let requiresFullBootstrap =
|
|
4852
|
+
let requiresFullBootstrap = selectsRegistryOutput(options, 'supervisor') && (
|
|
4853
|
+
enabled.some((entry) => entry.devSupervisorRequiresFullBootstrap === true)
|
|
4883
4854
|
|| appDeclaresProgrammaticDevSupervisorOverrides(resolver.getAppDir())
|
|
4855
|
+
)
|
|
4884
4856
|
|
|
4885
4857
|
for (const discovered of discovery.modules) {
|
|
4886
4858
|
const { modId, imps, appImportBase } = discovered
|
|
@@ -5138,14 +5110,17 @@ async function generateModuleRegistryCliFromDiscovery(options: ModuleRegistryRen
|
|
|
5138
5110
|
moduleDecls.push(objectLiteral(moduleEntries))
|
|
5139
5111
|
}
|
|
5140
5112
|
|
|
5141
|
-
|
|
5113
|
+
|
|
5114
|
+
exitOnMissingModuleRequires(discovery.identities, requiresByModule)
|
|
5115
|
+
|
|
5116
|
+
writeOutput('cli', 'modules.cli.generated.ts', () => renderAstModuleRegistryFile({
|
|
5142
5117
|
fileName: 'modules.cli.generated.ts',
|
|
5143
5118
|
generator: 'registry (CLI version)',
|
|
5144
5119
|
imports,
|
|
5145
5120
|
moduleEntries: moduleDecls,
|
|
5146
5121
|
includeAbandonHookImport: hasAbandonHookWorkers,
|
|
5147
|
-
})
|
|
5148
|
-
|
|
5122
|
+
}))
|
|
5123
|
+
writeOutput('cli', 'cli-modules.generated.ts', () => renderAstLegacyAliasFile({
|
|
5149
5124
|
fileName: 'cli-modules.generated.ts',
|
|
5150
5125
|
exportName: 'cliModules',
|
|
5151
5126
|
exportType: "Pick<Module, 'id' | 'cli'>[]",
|
|
@@ -5159,53 +5134,46 @@ async function generateModuleRegistryCliFromDiscovery(options: ModuleRegistryRen
|
|
|
5159
5134
|
])),
|
|
5160
5135
|
}),
|
|
5161
5136
|
]),
|
|
5162
|
-
})
|
|
5163
|
-
|
|
5164
|
-
exitOnMissingModuleRequires(discovery.identities, requiresByModule)
|
|
5165
|
-
|
|
5166
|
-
const structureChecksum = discovery.getStructureChecksum()
|
|
5167
|
-
writeGeneratedFile({ outFile, checksumFile, content: output, structureChecksum, result, quiet })
|
|
5168
|
-
writeGeneratedFile({ outFile: legacyOutFile, checksumFile: legacyChecksumFile, content: legacyOutput, structureChecksum, result, quiet })
|
|
5169
|
-
const devSupervisorOutput = `${JSON.stringify({
|
|
5137
|
+
}))
|
|
5138
|
+
writeOutput('supervisor', DEV_SUPERVISOR_MANIFEST_FILE, () => `${JSON.stringify({
|
|
5170
5139
|
version: DEV_SUPERVISOR_MANIFEST_VERSION,
|
|
5171
5140
|
workers: devSupervisorWorkers,
|
|
5172
5141
|
schedulerStartStatus,
|
|
5173
5142
|
requiresFullBootstrap,
|
|
5174
|
-
}, null, 2)}\n`
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
content: devSupervisorOutput,
|
|
5179
|
-
structureChecksum,
|
|
5180
|
-
result,
|
|
5181
|
-
quiet,
|
|
5182
|
-
})
|
|
5183
|
-
const commandLoadersOutput = renderCommandLoadersFile(commandLoaderEntries)
|
|
5184
|
-
writeGeneratedFile({ outFile: commandLoadersOutFile, checksumFile: commandLoadersChecksumFile, content: commandLoadersOutput, structureChecksum, result, quiet })
|
|
5143
|
+
}, null, 2)}\n`)
|
|
5144
|
+
if (!options.skipCommands) {
|
|
5145
|
+
writeOutput('commands', 'command-loaders.generated.ts', () => renderCommandLoadersFile(commandLoaderEntries))
|
|
5146
|
+
}
|
|
5185
5147
|
|
|
5186
5148
|
return result
|
|
5187
5149
|
}
|
|
5188
5150
|
|
|
5189
5151
|
export async function generateModuleRegistry(options: ModuleRegistryOptions): Promise<GeneratorResult> {
|
|
5152
|
+
if (options.outputGroups?.length === 0) return createGeneratorResult()
|
|
5190
5153
|
const discovery = await createModuleRegistryDiscovery(options.resolver, options.quiet ?? false)
|
|
5191
5154
|
return generateModuleRegistryFromDiscovery({ ...options, discovery })
|
|
5192
5155
|
}
|
|
5193
5156
|
|
|
5194
5157
|
export async function generateModuleRegistryApp(options: ModuleRegistryOptions): Promise<GeneratorResult> {
|
|
5158
|
+
if (options.outputGroups?.length === 0) return createGeneratorResult()
|
|
5195
5159
|
const discovery = await createModuleRegistryDiscovery(options.resolver, options.quiet ?? false)
|
|
5196
5160
|
return generateModuleRegistryAppFromDiscovery({ ...options, discovery })
|
|
5197
5161
|
}
|
|
5198
5162
|
|
|
5199
5163
|
export async function generateModuleRegistryCli(options: ModuleRegistryOptions): Promise<GeneratorResult> {
|
|
5164
|
+
if (options.outputGroups?.length === 0) return createGeneratorResult()
|
|
5200
5165
|
const discovery = await createModuleRegistryDiscovery(options.resolver, options.quiet ?? false)
|
|
5201
5166
|
return generateModuleRegistryCliFromDiscovery({ ...options, discovery })
|
|
5202
5167
|
}
|
|
5203
5168
|
|
|
5204
5169
|
export async function generateModuleRegistries(options: ModuleRegistryOptions): Promise<GeneratorResult[]> {
|
|
5170
|
+
if (options.outputGroups?.length === 0) {
|
|
5171
|
+
return [createGeneratorResult(), createGeneratorResult(), createGeneratorResult()]
|
|
5172
|
+
}
|
|
5205
5173
|
const discovery = await createModuleRegistryDiscovery(options.resolver, options.quiet ?? false)
|
|
5206
5174
|
return [
|
|
5207
5175
|
await generateModuleRegistryFromDiscovery({ ...options, discovery }),
|
|
5208
|
-
await generateModuleRegistryAppFromDiscovery({ ...options, discovery }),
|
|
5209
|
-
await generateModuleRegistryCliFromDiscovery({ ...options, discovery }),
|
|
5176
|
+
await generateModuleRegistryAppFromDiscovery({ ...options, discovery, skipCommands: true }),
|
|
5177
|
+
await generateModuleRegistryCliFromDiscovery({ ...options, discovery, skipCommands: true }),
|
|
5210
5178
|
]
|
|
5211
5179
|
}
|
|
@@ -94,6 +94,40 @@ function readOpenApiInputManifest(filePath: string): OpenApiInputManifest | null
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
/** All successful bundle inputs, including generated producers; null means unknown. */
|
|
98
|
+
export function getOpenApiGeneratorDependencies(resolver: PackageResolver): readonly string[] | null {
|
|
99
|
+
return readOpenApiInputManifest(
|
|
100
|
+
path.join(resolver.getOutputDir(), 'openapi.generated.inputs.json'),
|
|
101
|
+
)?.inputPaths ?? null
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Returns source inputs from the last successful bundle, including paths since
|
|
106
|
+
* deleted. An empty result does not prove that no dependencies exist: missing or
|
|
107
|
+
* invalid manifests require the watcher's conservative unknown-change fallback.
|
|
108
|
+
*/
|
|
109
|
+
export function getOpenApiWatchInputs(resolver: PackageResolver): string[] {
|
|
110
|
+
const inputPaths = getOpenApiGeneratorDependencies(resolver)
|
|
111
|
+
if (!inputPaths) return []
|
|
112
|
+
|
|
113
|
+
const packageNames = new Set([
|
|
114
|
+
'@open-mercato/core',
|
|
115
|
+
...resolver.loadEnabledModules().map((entry) => entry.from ?? '@open-mercato/core'),
|
|
116
|
+
])
|
|
117
|
+
const generatedRoots = Array.from(new Set([
|
|
118
|
+
path.resolve(resolver.getOutputDir()),
|
|
119
|
+
...Array.from(packageNames, (name) => path.resolve(resolver.getPackageOutputDir(name))),
|
|
120
|
+
]))
|
|
121
|
+
return inputPaths.filter((inputPath) => !generatedRoots.some((root) => {
|
|
122
|
+
const relative = path.relative(root, inputPath)
|
|
123
|
+
return relative === '' || (
|
|
124
|
+
relative !== '..'
|
|
125
|
+
&& !relative.startsWith(`..${path.sep}`)
|
|
126
|
+
&& !path.isAbsolute(relative)
|
|
127
|
+
)
|
|
128
|
+
}))
|
|
129
|
+
}
|
|
130
|
+
|
|
97
131
|
function trackedPathRecord(filePath: string): string {
|
|
98
132
|
try {
|
|
99
133
|
const stat = fs.statSync(filePath)
|