@open-mercato/cli 0.11.1-develop.8784.1.e9d95a72f5 → 0.11.1-develop.8805.1.6357054d1a
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 +4 -2
- package/AGENTS.md +2 -0
- package/dist/agentic/guides/architecture.md +1 -0
- package/dist/agentic/guides/module-facts.json +2014 -1099
- package/dist/agentic/guides/module-facts.v2.json +2014 -1099
- 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/ai_assistant/owned-contract-module-metadata.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/assisted_selling/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/auth/owned-contract-module-metadata.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/cart/owned-contract-module-metadata.md +1 -1
- package/dist/agentic/guides/modules/catalog/di-registrations-rich.md +11 -8
- package/dist/agentic/guides/modules/catalog/di-service-tokens.md +5 -5
- package/dist/agentic/guides/modules/catalog/exact-override-targets.md +11 -8
- package/dist/agentic/guides/modules/catalog/index.md +2 -2
- package/dist/agentic/guides/modules/catalog/owned-contract-module-metadata.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_gmail/owned-contract-module-metadata.md +1 -1
- package/dist/agentic/guides/modules/channel_imap/index.md +1 -1
- package/dist/agentic/guides/modules/channel_imap/owned-contract-module-metadata.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/exact-override-targets.md +1 -1
- package/dist/agentic/guides/modules/communication_channels/index.md +1 -1
- package/dist/agentic/guides/modules/communication_channels/owned-contract-module-metadata.md +1 -1
- package/dist/agentic/guides/modules/communication_channels/workers.md +1 -1
- package/dist/agentic/guides/modules/configs/acl-features.md +2 -1
- package/dist/agentic/guides/modules/configs/backend-pages.md +1 -0
- package/dist/agentic/guides/modules/configs/exact-override-targets.md +2 -0
- package/dist/agentic/guides/modules/configs/host-extension-points.md +10 -0
- package/dist/agentic/guides/modules/configs/index.md +5 -3
- package/dist/agentic/guides/modules/configs/owned-contract-module-metadata.md +1 -1
- package/dist/agentic/guides/modules/configs/setup.md +1 -1
- package/dist/agentic/guides/modules/configs/umes-diagnostics.md +9 -0
- package/dist/agentic/guides/modules/configs/umes-hosts.md +9 -0
- 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/active-extension-bindings.md +2 -0
- package/dist/agentic/guides/modules/customers/contribution-resolutions.md +2 -0
- package/dist/agentic/guides/modules/customers/di-registrations-rich.md +8 -5
- package/dist/agentic/guides/modules/customers/exact-override-targets.md +10 -5
- package/dist/agentic/guides/modules/customers/index.md +5 -5
- package/dist/agentic/guides/modules/customers/owned-contract-module-metadata.md +1 -1
- package/dist/agentic/guides/modules/customers/umes-contributions.md +2 -0
- package/dist/agentic/guides/modules/dashboards/active-extension-bindings.md +0 -10
- package/dist/agentic/guides/modules/dashboards/contribution-resolutions.md +0 -10
- package/dist/agentic/guides/modules/dashboards/exact-override-targets.md +0 -10
- package/dist/agentic/guides/modules/dashboards/index.md +5 -5
- package/dist/agentic/guides/modules/dashboards/umes-contributions.md +0 -10
- 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/entities/owned-contract-module-metadata.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/events/owned-contract-module-metadata.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/integrations/owned-contract-module-metadata.md +1 -1
- package/dist/agentic/guides/modules/ledger/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/active-extension-bindings.md +8 -0
- package/dist/agentic/guides/modules/sales/contribution-resolutions.md +8 -0
- package/dist/agentic/guides/modules/sales/di-registrations-rich.md +31 -30
- package/dist/agentic/guides/modules/sales/di-service-tokens.md +5 -5
- package/dist/agentic/guides/modules/sales/exact-override-targets.md +39 -30
- package/dist/agentic/guides/modules/sales/index.md +5 -5
- package/dist/agentic/guides/modules/sales/owned-contract-module-metadata.md +1 -1
- package/dist/agentic/guides/modules/sales/umes-contributions.md +8 -0
- 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/search/owned-contract-module-metadata.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/active-extension-bindings.md +2 -1
- package/dist/agentic/guides/modules/staff/contribution-resolutions.md +1 -0
- package/dist/agentic/guides/modules/staff/exact-override-targets.md +1 -0
- package/dist/agentic/guides/modules/staff/index.md +8 -8
- package/dist/agentic/guides/modules/staff/umes-contributions.md +1 -0
- 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/upgrade_actions/contribution-resolutions.md +12 -0
- package/dist/agentic/guides/modules/upgrade_actions/exact-override-targets.md +11 -0
- package/dist/agentic/guides/modules/upgrade_actions/index.md +15 -0
- package/dist/agentic/guides/modules/upgrade_actions/owned-contract-module-metadata.md +11 -0
- package/dist/agentic/guides/modules/upgrade_actions/umes-contributions.md +12 -0
- 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/generators/extensions/dashboard-widgets.js +46 -4
- package/dist/lib/generators/extensions/dashboard-widgets.js.map +2 -2
- package/dist/lib/generators/extensions/workflows.js +25 -2
- package/dist/lib/generators/extensions/workflows.js.map +2 -2
- package/dist/lib/generators/module-facts.js +2 -0
- package/dist/lib/generators/module-facts.js.map +2 -2
- package/dist/lib/generators/module-registry.js +7 -6
- package/dist/lib/generators/module-registry.js.map +2 -2
- package/dist/lib/module-coupling/analyze.js +391 -0
- package/dist/lib/module-coupling/analyze.js.map +7 -0
- package/dist/lib/module-diagnostics.js +160 -0
- package/dist/lib/module-diagnostics.js.map +7 -0
- package/dist/lib/module-index.js +103 -0
- package/dist/lib/module-index.js.map +7 -0
- package/dist/lib/testing/integration-discovery.js +20 -15
- package/dist/lib/testing/integration-discovery.js.map +3 -3
- package/dist/mercato.js +19 -2
- package/dist/mercato.js.map +2 -2
- package/package.json +7 -7
- package/src/__tests__/rotation-json-output.test.ts +13 -0
- package/src/lib/__tests__/module-diagnostics.test.ts +207 -0
- package/src/lib/generators/__tests__/module-facts.owned-contracts.test.ts +2 -2
- package/src/lib/generators/__tests__/output-snapshots.test.ts +19 -0
- package/src/lib/generators/__tests__/structural-contracts.test.ts +18 -0
- package/src/lib/generators/extensions/dashboard-widgets.ts +49 -3
- package/src/lib/generators/extensions/workflows.ts +26 -2
- package/src/lib/generators/module-facts.ts +2 -0
- package/src/lib/generators/module-registry.ts +11 -7
- package/src/lib/module-coupling/analyze.ts +464 -0
- package/src/lib/module-diagnostics.ts +182 -0
- package/src/lib/module-index.ts +133 -0
- package/src/lib/testing/__tests__/integration-discovery.test.ts +26 -2
- package/src/lib/testing/integration-discovery.ts +19 -11
- package/src/mercato.ts +21 -2
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
import { resolveModuleIdentity, type ModuleIdentity } from '@open-mercato/shared/modules/module-locators'
|
|
4
|
+
import { extractModuleRequiresFromSource } from './generators/module-registry'
|
|
5
|
+
import { MODULE_CODE_EXTENSIONS } from './generators/scanner'
|
|
6
|
+
import { discoverModulesInPackage } from './module-package'
|
|
7
|
+
import { createResolver, type ModuleEntry, type PackageResolver } from './resolver'
|
|
8
|
+
|
|
9
|
+
export type IndexedModule = ModuleIdentity & {
|
|
10
|
+
packageName: string
|
|
11
|
+
version: string | null
|
|
12
|
+
roots: string[]
|
|
13
|
+
enabled: boolean
|
|
14
|
+
requires: string[]
|
|
15
|
+
optionalRequires: string[]
|
|
16
|
+
notAnalyzed?: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function existingDirectories(paths: string[]): string[] {
|
|
20
|
+
return [...new Set(paths)].filter((candidate) => fs.existsSync(candidate) && fs.statSync(candidate).isDirectory())
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function moduleIndexFile(roots: string[]): string | undefined {
|
|
24
|
+
return roots.flatMap((root) => MODULE_CODE_EXTENSIONS.map((extension) => path.join(root, `index${extension}`)))
|
|
25
|
+
.find((candidate) => fs.existsSync(candidate))
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function readModule(resolver: PackageResolver, entry: ModuleEntry, enabled: boolean): IndexedModule {
|
|
29
|
+
const packageName = entry.from ?? '@open-mercato/core'
|
|
30
|
+
const packageRoot = resolver.getPackageRoot(packageName)
|
|
31
|
+
const { appBase, pkgBase } = resolver.getModulePaths(entry)
|
|
32
|
+
const roots = existingDirectories(packageName === '@app' ? [appBase] : [appBase, pkgBase])
|
|
33
|
+
const indexFile = moduleIndexFile(roots)
|
|
34
|
+
const requires = indexFile ? extractModuleRequiresFromSource(indexFile) : null
|
|
35
|
+
const optionalRequires = indexFile ? extractModuleRequiresFromSource(indexFile, 'optionalRequires') : null
|
|
36
|
+
const notAnalyzed = !indexFile
|
|
37
|
+
? 'module index source is unavailable'
|
|
38
|
+
: requires?.status === 'unresolvable'
|
|
39
|
+
? requires.reason
|
|
40
|
+
: optionalRequires?.status === 'unresolvable'
|
|
41
|
+
? optionalRequires.reason
|
|
42
|
+
: undefined
|
|
43
|
+
let version: string | null = null
|
|
44
|
+
try {
|
|
45
|
+
const manifest: { version?: unknown } = JSON.parse(fs.readFileSync(path.join(
|
|
46
|
+
packageName === '@app' ? resolver.getAppDir() : packageRoot, 'package.json',
|
|
47
|
+
), 'utf8'))
|
|
48
|
+
if (typeof manifest.version === 'string') version = manifest.version
|
|
49
|
+
} catch {
|
|
50
|
+
// Module diagnostics remain available even if package version metadata is absent.
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
id: entry.id,
|
|
54
|
+
packageName,
|
|
55
|
+
version,
|
|
56
|
+
roots,
|
|
57
|
+
enabled,
|
|
58
|
+
locators: [...new Set([entry.locator, entry.packageName, packageName].filter((locator): locator is string => !!locator && locator !== '@app'))],
|
|
59
|
+
requires: requires?.status === 'declared' ? requires.requires : [],
|
|
60
|
+
optionalRequires: optionalRequires?.status === 'declared' ? optionalRequires.requires : [],
|
|
61
|
+
...(notAnalyzed ? { notAnalyzed } : {}),
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function buildModuleIndex(resolver: PackageResolver = createResolver(), includeInactive = true): IndexedModule[] {
|
|
66
|
+
const enabled = resolver.loadEnabledModules()
|
|
67
|
+
const result = enabled.map((entry) => readModule(resolver, entry, true))
|
|
68
|
+
if (!includeInactive) return result
|
|
69
|
+
|
|
70
|
+
const keys = new Set(result.map((entry) => `${entry.packageName}:${entry.id}`))
|
|
71
|
+
const appModules = path.join(resolver.getAppDir(), 'src', 'modules')
|
|
72
|
+
if (fs.existsSync(appModules)) {
|
|
73
|
+
const enabledIds = new Set(enabled.map((entry) => entry.id))
|
|
74
|
+
for (const entry of fs.readdirSync(appModules, { withFileTypes: true })) {
|
|
75
|
+
if (!entry.isDirectory() || entry.name.startsWith('.') || enabledIds.has(entry.name)) continue
|
|
76
|
+
result.push(readModule(resolver, { id: entry.name, from: '@app' }, false))
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const packages = new Map(resolver.discoverPackages().map((pkg) => [pkg.name, pkg.path]))
|
|
81
|
+
const appManifest = path.join(resolver.getAppDir(), 'package.json')
|
|
82
|
+
try {
|
|
83
|
+
const manifest: { dependencies?: Record<string, string>; optionalDependencies?: Record<string, string> } =
|
|
84
|
+
JSON.parse(fs.readFileSync(appManifest, 'utf8'))
|
|
85
|
+
for (const packageName of Object.keys({ ...manifest.dependencies, ...manifest.optionalDependencies })) {
|
|
86
|
+
if (!packages.has(packageName)) packages.set(packageName, resolver.getPackageRoot(packageName))
|
|
87
|
+
}
|
|
88
|
+
} catch {
|
|
89
|
+
// Missing app package metadata does not prevent inspecting known installed packages.
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
for (const [packageName, packageRoot] of packages) {
|
|
93
|
+
for (const entry of discoverModulesInPackage(packageRoot)) {
|
|
94
|
+
if (keys.has(`${packageName}:${entry.moduleId}`)) continue
|
|
95
|
+
result.push(readModule(resolver, { id: entry.moduleId, from: packageName }, false))
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return result.sort((left, right) => left.id.localeCompare(right.id) || left.packageName.localeCompare(right.packageName))
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function resolveIndexedModule(requirement: string, modules: IndexedModule[]): IndexedModule | undefined {
|
|
102
|
+
// The enabled instance takes precedence over any other installed provider for the same id.
|
|
103
|
+
const activeFirst = [...modules.filter((entry) => entry.enabled), ...modules.filter((entry) => !entry.enabled)]
|
|
104
|
+
return resolveModuleIdentity(requirement, activeFirst)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function missingModuleRequirements(
|
|
108
|
+
entry: IndexedModule,
|
|
109
|
+
modules: IndexedModule[],
|
|
110
|
+
): Array<{ requirement: string; path: string[] }> {
|
|
111
|
+
const visited = new Set([entry.id])
|
|
112
|
+
const missing = new Map<string, string[]>()
|
|
113
|
+
|
|
114
|
+
function visit(source: IndexedModule, trail: string[]): void {
|
|
115
|
+
for (const requirement of source.requires) {
|
|
116
|
+
const target = resolveIndexedModule(requirement, modules)
|
|
117
|
+
const nextTrail = [...trail, target?.id ?? requirement]
|
|
118
|
+
if ((!target || !target.enabled) && !missing.has(requirement)) missing.set(requirement, nextTrail)
|
|
119
|
+
if (!target || visited.has(target.id)) continue
|
|
120
|
+
visited.add(target.id)
|
|
121
|
+
visit(target, nextTrail)
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
visit(entry, [entry.id])
|
|
126
|
+
return [...missing].map(([requirement, path]) => ({ requirement, path }))
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export function inactiveModuleDependencies(modules: IndexedModule[]): Array<{ source: IndexedModule; target: string }> {
|
|
130
|
+
return modules.filter((module) => module.enabled).flatMap((source) => source.optionalRequires
|
|
131
|
+
.filter((target) => !resolveIndexedModule(target, modules)?.enabled)
|
|
132
|
+
.map((target) => ({ source, target })))
|
|
133
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import os from 'node:os'
|
|
2
2
|
import path from 'node:path'
|
|
3
|
-
import { mkdtemp, mkdir, rm, writeFile } from 'node:fs/promises'
|
|
4
|
-
import { discoverIntegrationSpecFiles, isAppOwnedIntegrationSpecPath } from '../integration-discovery'
|
|
3
|
+
import { mkdtemp, mkdir, readFile, rm, writeFile } from 'node:fs/promises'
|
|
4
|
+
import { discoverIntegrationSpecFiles, isAppOwnedIntegrationSpecPath, resolveModuleDependenciesForSpec } from '../integration-discovery'
|
|
5
5
|
|
|
6
6
|
async function writeTestFile(projectRoot: string, relativePath: string, content = 'export {}\n'): Promise<void> {
|
|
7
7
|
const absolutePath = path.join(projectRoot, relativePath)
|
|
@@ -19,6 +19,7 @@ describe('integration discovery', () => {
|
|
|
19
19
|
'OM_TEST_APP_ROOT',
|
|
20
20
|
'OM_INTEGRATION_APP_ONLY',
|
|
21
21
|
'OM_INTEGRATION_SKIP_METADATA_FILTERS',
|
|
22
|
+
'OM_INTEGRATION_DISCOVERY_SELECTION_REPORT',
|
|
22
23
|
] as const
|
|
23
24
|
const previousTestEnvValues = new Map<string, string | undefined>()
|
|
24
25
|
|
|
@@ -88,6 +89,16 @@ describe('integration discovery', () => {
|
|
|
88
89
|
])
|
|
89
90
|
})
|
|
90
91
|
|
|
92
|
+
it('keeps optional module probes runnable when their peer is disabled', async () => {
|
|
93
|
+
const spec = 'apps/mercato/src/modules/sales/__integration__/TC-SALES-003.spec.ts'
|
|
94
|
+
await writeTestFile(tempRoot, spec, "export const integrationMeta = { optionalModules: ['currencies'] }")
|
|
95
|
+
|
|
96
|
+
expect(discoverIntegrationSpecFiles(tempRoot, path.join(tempRoot, '.ai', 'qa', 'tests'))).toEqual([
|
|
97
|
+
expect.objectContaining({ path: spec, requiredModules: [] }),
|
|
98
|
+
])
|
|
99
|
+
expect(resolveModuleDependenciesForSpec(tempRoot, spec, { includeOptional: true })).toEqual(['currencies'])
|
|
100
|
+
})
|
|
101
|
+
|
|
91
102
|
it('loads enterprise integration tests only when enterprise modules are enabled', async () => {
|
|
92
103
|
await writeTestFile(tempRoot, 'packages/core/src/modules/sales/.gitkeep')
|
|
93
104
|
await writeTestFile(
|
|
@@ -162,6 +173,19 @@ describe('integration discovery', () => {
|
|
|
162
173
|
])
|
|
163
174
|
})
|
|
164
175
|
|
|
176
|
+
it('writes the normal filtered test selection for preset verification', async () => {
|
|
177
|
+
const selected = 'packages/core/src/modules/catalog/__integration__/TC-CAT-001.spec.ts'
|
|
178
|
+
await writeTestFile(tempRoot, selected)
|
|
179
|
+
await writeTestFile(tempRoot, 'packages/core/src/modules/catalog/__integration__/TC-CAT-002.spec.ts',
|
|
180
|
+
"export const meta = { dependsOnModules: ['missing'] }")
|
|
181
|
+
const report = path.join(tempRoot, 'selection.json')
|
|
182
|
+
process.env.OM_INTEGRATION_DISCOVERY_SELECTION_REPORT = report
|
|
183
|
+
|
|
184
|
+
discoverIntegrationSpecFiles(tempRoot, path.join(tempRoot, '.ai', 'qa', 'tests'))
|
|
185
|
+
|
|
186
|
+
expect(JSON.parse(await readFile(report, 'utf8'))).toEqual({ projectRoot: tempRoot, paths: [selected] })
|
|
187
|
+
})
|
|
188
|
+
|
|
165
189
|
it('uses OM_TEST_APP_ROOT and its actual modules.ts for dependency filtering', async () => {
|
|
166
190
|
const standaloneRoot = path.join(tempRoot, 'standalone-app')
|
|
167
191
|
await writeTestFile(
|
|
@@ -29,6 +29,7 @@ const DISCOVERY_IGNORED_DIRS = new Set([
|
|
|
29
29
|
])
|
|
30
30
|
const INTEGRATION_META_FILE_NAMES = ['meta.ts', 'index.ts'] as const
|
|
31
31
|
const INTEGRATION_META_DEPENDENCY_KEYS = ['dependsOnModules', 'requiredModules', 'requiresModules'] as const
|
|
32
|
+
const INTEGRATION_META_ALL_DEPENDENCY_KEYS = [...INTEGRATION_META_DEPENDENCY_KEYS, 'optionalModules'] as const
|
|
32
33
|
const INTEGRATION_META_REQUIRED_ENV_KEYS = ['requiredEnvVars', 'requiresEnvVars'] as const
|
|
33
34
|
const INTEGRATION_META_REQUIRED_ANY_ENV_KEYS = ['requiredAnyEnvVars', 'requiresAnyEnvVars'] as const
|
|
34
35
|
const DEFAULT_OVERLAY_ROOT = 'packages/enterprise'
|
|
@@ -315,8 +316,9 @@ function extractStringArrayFromSource(source: string, keys: readonly string[]):
|
|
|
315
316
|
return Array.from(collected)
|
|
316
317
|
}
|
|
317
318
|
|
|
318
|
-
function extractDependencyListFromSource(source: string): string[] {
|
|
319
|
-
|
|
319
|
+
function extractDependencyListFromSource(source: string, includeOptional: boolean): string[] {
|
|
320
|
+
const keys = includeOptional ? INTEGRATION_META_ALL_DEPENDENCY_KEYS : INTEGRATION_META_DEPENDENCY_KEYS
|
|
321
|
+
return extractStringArrayFromSource(source, keys).map(normalizeModuleId)
|
|
320
322
|
}
|
|
321
323
|
|
|
322
324
|
function extractRequiredEnvVarsFromSource(source: string): string[] {
|
|
@@ -327,9 +329,9 @@ function extractRequiredAnyEnvVarsFromSource(source: string): string[] {
|
|
|
327
329
|
return extractStringArrayFromSource(source, INTEGRATION_META_REQUIRED_ANY_ENV_KEYS)
|
|
328
330
|
}
|
|
329
331
|
|
|
330
|
-
function readDependenciesFromMetadataFile(absolutePath: string): string[] {
|
|
332
|
+
function readDependenciesFromMetadataFile(absolutePath: string, includeOptional: boolean): string[] {
|
|
331
333
|
try {
|
|
332
|
-
return extractDependencyListFromSource(readFileSync(absolutePath, 'utf8'))
|
|
334
|
+
return extractDependencyListFromSource(readFileSync(absolutePath, 'utf8'), includeOptional)
|
|
333
335
|
} catch {
|
|
334
336
|
return []
|
|
335
337
|
}
|
|
@@ -360,7 +362,11 @@ function resolveIntegrationRootDirectory(relativeSpecPath: string): string | nul
|
|
|
360
362
|
return segments.slice(0, integrationDirectoryIndex + 1).join('/')
|
|
361
363
|
}
|
|
362
364
|
|
|
363
|
-
function
|
|
365
|
+
export function resolveModuleDependenciesForSpec(
|
|
366
|
+
projectRoot: string,
|
|
367
|
+
relativeSpecPath: string,
|
|
368
|
+
{ includeOptional = false }: { includeOptional?: boolean } = {},
|
|
369
|
+
): string[] {
|
|
364
370
|
const requiredModules = new Set<string>()
|
|
365
371
|
const normalizedSpecPath = normalizePath(relativeSpecPath)
|
|
366
372
|
const absoluteSpecPath = path.join(projectRoot, normalizedSpecPath)
|
|
@@ -384,15 +390,15 @@ function resolveRequiredModulesForSpec(projectRoot: string, relativeSpecPath: st
|
|
|
384
390
|
for (const directoryPath of traversal) {
|
|
385
391
|
for (const metadataFileName of INTEGRATION_META_FILE_NAMES) {
|
|
386
392
|
const metadataPath = path.join(directoryPath, metadataFileName)
|
|
387
|
-
readDependenciesFromMetadataFile(metadataPath).forEach((dependency) => requiredModules.add(dependency))
|
|
393
|
+
readDependenciesFromMetadataFile(metadataPath, includeOptional).forEach((dependency) => requiredModules.add(dependency))
|
|
388
394
|
}
|
|
389
395
|
}
|
|
390
396
|
}
|
|
391
397
|
|
|
392
|
-
readDependenciesFromMetadataFile(absoluteSpecPath).forEach((dependency) => requiredModules.add(dependency))
|
|
398
|
+
readDependenciesFromMetadataFile(absoluteSpecPath, includeOptional).forEach((dependency) => requiredModules.add(dependency))
|
|
393
399
|
const specFileName = path.basename(normalizedSpecPath, '.spec.ts')
|
|
394
400
|
const perTestMetadataPath = path.join(path.dirname(absoluteSpecPath), `${specFileName}.meta.ts`)
|
|
395
|
-
readDependenciesFromMetadataFile(perTestMetadataPath).forEach((dependency) => requiredModules.add(dependency))
|
|
401
|
+
readDependenciesFromMetadataFile(perTestMetadataPath, includeOptional).forEach((dependency) => requiredModules.add(dependency))
|
|
396
402
|
|
|
397
403
|
return Array.from(requiredModules)
|
|
398
404
|
}
|
|
@@ -494,7 +500,7 @@ export function discoverIntegrationSpecFiles(projectRoot: string, legacyIntegrat
|
|
|
494
500
|
path: relativePath,
|
|
495
501
|
moduleName: extractModuleNameFromIntegrationPath(relativePath),
|
|
496
502
|
isOverlay: isOverlayIntegrationPath(relativePath, overlayRoot),
|
|
497
|
-
requiredModules:
|
|
503
|
+
requiredModules: resolveModuleDependenciesForSpec(projectRoot, relativePath),
|
|
498
504
|
requiredEnvVars: resolveRequiredEnvVarsForSpec(projectRoot, relativePath),
|
|
499
505
|
requiredAnyEnvVars: resolveRequiredAnyEnvVarsForSpec(projectRoot, relativePath),
|
|
500
506
|
})
|
|
@@ -508,7 +514,7 @@ export function discoverIntegrationSpecFiles(projectRoot: string, legacyIntegrat
|
|
|
508
514
|
path: relativePath,
|
|
509
515
|
moduleName: extractModuleNameFromIntegrationPath(relativePath),
|
|
510
516
|
isOverlay: isOverlayIntegrationPath(relativePath, overlayRoot),
|
|
511
|
-
requiredModules:
|
|
517
|
+
requiredModules: resolveModuleDependenciesForSpec(projectRoot, relativePath),
|
|
512
518
|
requiredEnvVars: resolveRequiredEnvVarsForSpec(projectRoot, relativePath),
|
|
513
519
|
requiredAnyEnvVars: resolveRequiredAnyEnvVarsForSpec(projectRoot, relativePath),
|
|
514
520
|
})
|
|
@@ -533,7 +539,7 @@ export function discoverIntegrationSpecFiles(projectRoot: string, legacyIntegrat
|
|
|
533
539
|
}
|
|
534
540
|
}
|
|
535
541
|
|
|
536
|
-
|
|
542
|
+
const selected = discovered
|
|
537
543
|
.filter((file) => {
|
|
538
544
|
if (file.requiredModules.some((moduleId) => !enabledModules.has(normalizeModuleId(moduleId)))) {
|
|
539
545
|
return false
|
|
@@ -568,4 +574,6 @@ export function discoverIntegrationSpecFiles(projectRoot: string, legacyIntegrat
|
|
|
568
574
|
return enabledModules.has(normalizeModuleId(file.moduleName))
|
|
569
575
|
})
|
|
570
576
|
.sort((left, right) => left.path.localeCompare(right.path))
|
|
577
|
+
writeDiscoverySelectionReport(projectRoot, selected)
|
|
578
|
+
return selected
|
|
571
579
|
}
|
package/src/mercato.ts
CHANGED
|
@@ -222,6 +222,9 @@ function detectDatabaseConnectionIssue(
|
|
|
222
222
|
|
|
223
223
|
function formatCliFailureMessage(modName: string, cmdName: string, error: unknown): string {
|
|
224
224
|
const fallbackMessage = getFallbackErrorMessage(error)
|
|
225
|
+
if (modName === 'entities' && cmdName === 'rotate-encryption-key' && process.env.OM_ROTATION_PROGRESS !== 'json') {
|
|
226
|
+
return fallbackMessage.replace(/^\[internal\] /, '')
|
|
227
|
+
}
|
|
225
228
|
const databaseIssue = detectDatabaseConnectionIssue(error)
|
|
226
229
|
|
|
227
230
|
const isDatabaseCommand = modName === 'db' && ['migrate', 'generate', 'greenfield'].includes(cmdName)
|
|
@@ -1571,16 +1574,23 @@ export async function run(argv = process.argv) {
|
|
|
1571
1574
|
const commandArgs = remaining.filter(Boolean)
|
|
1572
1575
|
|
|
1573
1576
|
if (!subcommand || subcommand === 'help' || subcommand === '--help' || subcommand === '-h') {
|
|
1574
|
-
console.log('Usage: yarn mercato module <add|enable|eject|search|info|scaffold> ...')
|
|
1577
|
+
console.log('Usage: yarn mercato module <add|enable|eject|search|info|list|doctor|scaffold> ...')
|
|
1575
1578
|
console.log(' yarn mercato module add <packageSpec> [--module <moduleId>] [--eject] [--allow-third-party]')
|
|
1576
1579
|
console.log(' yarn mercato module enable <packageName> [--module <moduleId>] [--eject] [--allow-third-party]')
|
|
1577
1580
|
console.log(' yarn mercato module eject <moduleId>')
|
|
1578
1581
|
console.log(' yarn mercato module search [<query>] [--category <id>] [--kind <kind>] [--all-lines] [--limit <n>] [--json]')
|
|
1579
1582
|
console.log(' yarn mercato module info <package-or-module-id> [--json]')
|
|
1583
|
+
console.log(' yarn mercato module list [--all] [--json]')
|
|
1584
|
+
console.log(' yarn mercato module doctor [--strict] [--json]')
|
|
1580
1585
|
console.log(' yarn mercato module scaffold <moduleId> --entity <entity> --fields "<fields>" [--with-ui] [--target app|packages/core] [--features-prefix <prefix>] [--dry-run]')
|
|
1581
1586
|
return 0
|
|
1582
1587
|
}
|
|
1583
1588
|
|
|
1589
|
+
if (subcommand === 'list' || subcommand === 'doctor') {
|
|
1590
|
+
const { runModuleDiagnostics } = await import('./lib/module-diagnostics')
|
|
1591
|
+
return runModuleDiagnostics(subcommand, commandArgs)
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1584
1594
|
if (subcommand === 'search' || subcommand === 'info') {
|
|
1585
1595
|
const { runModuleSearch, runModuleInfo } = await import('./lib/module-search')
|
|
1586
1596
|
const { readEnabledModules } = await import('./lib/modules-config')
|
|
@@ -2105,7 +2115,16 @@ export async function run(argv = process.argv) {
|
|
|
2105
2115
|
watchRequest?.logCascade
|
|
2106
2116
|
? (reason) => console.log(`[generate:watch] Cascading; groups=openapi; reason=${reason}`)
|
|
2107
2117
|
: undefined)
|
|
2108
|
-
if (!quiet)
|
|
2118
|
+
if (!quiet) {
|
|
2119
|
+
try {
|
|
2120
|
+
const { buildModuleIndex, inactiveModuleDependencies } = await import('./lib/module-index')
|
|
2121
|
+
const inactive = inactiveModuleDependencies(buildModuleIndex(undefined, false)).length
|
|
2122
|
+
if (inactive > 0) console.log(`[generate] ${inactive} inactive optional module capabilities. Run yarn mercato module doctor.`)
|
|
2123
|
+
} catch {
|
|
2124
|
+
// Module diagnostics are informational and must not make generate fail.
|
|
2125
|
+
}
|
|
2126
|
+
console.log('All generators completed.')
|
|
2127
|
+
}
|
|
2109
2128
|
},
|
|
2110
2129
|
},
|
|
2111
2130
|
{
|