@open-mercato/cli 0.11.1-develop.8882.1.4664687cf8 → 0.11.1-develop.8910.1.d07a49d70a
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 +7 -1
- package/dist/agentic/guides/integrations.md +1 -1
- package/dist/agentic/guides/module-facts.json +2117 -178
- package/dist/agentic/guides/module-facts.v2.json +2117 -178
- 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/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/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/acl-features.md +3 -1
- package/dist/agentic/guides/modules/catalog/backend-pages.md +3 -0
- package/dist/agentic/guides/modules/catalog/contribution-resolutions.md +4 -0
- package/dist/agentic/guides/modules/catalog/custom-entities.md +1 -0
- package/dist/agentic/guides/modules/catalog/domain-commands.md +3 -0
- package/dist/agentic/guides/modules/catalog/entities.md +3 -0
- package/dist/agentic/guides/modules/catalog/events.md +4 -1
- package/dist/agentic/guides/modules/catalog/exact-override-targets.md +5 -0
- package/dist/agentic/guides/modules/catalog/host-extension-points.md +1 -1
- package/dist/agentic/guides/modules/catalog/index.md +6 -6
- package/dist/agentic/guides/modules/catalog/search-entities.md +1 -0
- package/dist/agentic/guides/modules/catalog/umes-contributions.md +4 -0
- package/dist/agentic/guides/modules/catalog/umes-hosts.md +8 -0
- 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_ms365/acl-features.md +12 -0
- package/dist/agentic/guides/modules/channel_ms365/contribution-resolutions.md +12 -0
- package/dist/agentic/guides/modules/channel_ms365/di-registrations-rich.md +12 -0
- package/dist/agentic/guides/modules/channel_ms365/exact-override-targets.md +17 -0
- package/dist/agentic/guides/modules/channel_ms365/index.md +18 -0
- package/dist/agentic/guides/modules/channel_ms365/owned-contract-module-metadata.md +11 -0
- package/dist/agentic/guides/modules/channel_ms365/setup.md +11 -0
- package/dist/agentic/guides/modules/channel_ms365/umes-contributions.md +12 -0
- 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/exact-override-targets.md +1 -1
- package/dist/agentic/guides/modules/checkout/index.md +1 -1
- package/dist/agentic/guides/modules/checkout/workers.md +1 -1
- package/dist/agentic/guides/modules/communication_channels/incoming-installed-contributions.md +1 -0
- package/dist/agentic/guides/modules/communication_channels/index.md +2 -2
- package/dist/agentic/guides/modules/configs/acl-features.md +3 -1
- package/dist/agentic/guides/modules/configs/backend-pages.md +1 -0
- package/dist/agentic/guides/modules/configs/exact-override-targets.md +3 -0
- package/dist/agentic/guides/modules/configs/index.md +3 -3
- package/dist/agentic/guides/modules/configs/owned-contract-module-metadata.md +1 -1
- package/dist/agentic/guides/modules/configs/umes-hosts.md +1 -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/incoming-installed-contributions.md +1 -0
- 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/gus_regon/acl-features.md +11 -0
- package/dist/agentic/guides/modules/gus_regon/cli-commands.md +12 -0
- package/dist/agentic/guides/modules/gus_regon/contribution-resolutions.md +11 -0
- package/dist/agentic/guides/modules/gus_regon/di-registrations-rich.md +11 -0
- package/dist/agentic/guides/modules/gus_regon/exact-override-targets.md +17 -0
- package/dist/agentic/guides/modules/gus_regon/index.md +19 -0
- package/dist/agentic/guides/modules/gus_regon/owned-contract-module-metadata.md +11 -0
- package/dist/agentic/guides/modules/gus_regon/setup.md +11 -0
- package/dist/agentic/guides/modules/gus_regon/umes-contributions.md +11 -0
- 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/ledger/index.md +1 -1
- package/dist/agentic/guides/modules/maintenance/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/sales_invoices_gl_posting/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/sync_shopify/acl-features.md +12 -0
- package/dist/agentic/guides/modules/sync_shopify/cli-commands.md +12 -0
- package/dist/agentic/guides/modules/sync_shopify/contribution-resolutions.md +11 -0
- package/dist/agentic/guides/modules/sync_shopify/di-registrations-rich.md +11 -0
- package/dist/agentic/guides/modules/sync_shopify/exact-override-targets.md +17 -0
- package/dist/agentic/guides/modules/sync_shopify/index.md +19 -0
- package/dist/agentic/guides/modules/sync_shopify/owned-contract-module-metadata.md +11 -0
- package/dist/agentic/guides/modules/sync_shopify/setup.md +11 -0
- package/dist/agentic/guides/modules/sync_shopify/umes-contributions.md +11 -0
- 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/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 +2 -2
- package/dist/agentic/guides/reference-modules/example/index.md +1 -1
- package/dist/agentic/guides/upstream/BACKWARD_COMPATIBILITY.md +18 -0
- package/dist/agentic/guides/upstream/manifest.json +2 -2
- package/dist/agentic/shared/ai/harness/cases.json +4 -3
- package/dist/agentic/shared/ai/skills/om-integration-builder/references/provider-families.md +1 -1
- package/dist/lib/init-secrets.js +1 -1
- package/dist/lib/init-secrets.js.map +2 -2
- package/dist/lib/testing/integration-discovery.js +13 -0
- package/dist/lib/testing/integration-discovery.js.map +2 -2
- package/dist/lib/testing/integration.js +286 -26
- package/dist/lib/testing/integration.js.map +2 -2
- package/dist/mercato.js +9 -2
- package/dist/mercato.js.map +2 -2
- package/package.json +7 -7
- package/src/__tests__/mercato.test.ts +68 -0
- package/src/lib/__tests__/init-secrets.test.ts +11 -2
- package/src/lib/generators/__tests__/module-facts.extension-hosts.test.ts +2 -0
- package/src/lib/init-secrets.ts +1 -1
- package/src/lib/testing/__tests__/integration-prebuilt-artifacts.test.ts +486 -0
- package/src/lib/testing/__tests__/integration.test.ts +27 -0
- package/src/lib/testing/integration-discovery.ts +16 -0
- package/src/lib/testing/integration.ts +366 -27
- package/src/mercato.ts +9 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/testing/integration-discovery.ts"],
|
|
4
|
-
"sourcesContent": ["import { existsSync, readFileSync, readdirSync, writeFileSync } from 'node:fs'\nimport path from 'node:path'\nimport ts from 'typescript-js'\n\nexport type IntegrationSpecDiscoveryItem = {\n path: string\n moduleName: string | null\n isOverlay: boolean\n requiredModules: string[]\n requiredEnvVars: string[]\n requiredAnyEnvVars: string[]\n}\n\nconst MODULE_INTEGRATION_DIRECTORY_NAME = '__integration__'\nconst DISCOVERY_IGNORED_DIRS = new Set([\n 'node_modules',\n '.git',\n '.next',\n 'dist',\n '.turbo',\n 'coverage',\n 'test-results',\n '.yarn',\n '.cache',\n 'tmp',\n 'temp',\n '.claude',\n '.codex',\n])\nconst INTEGRATION_META_FILE_NAMES = ['meta.ts', 'index.ts'] as const\nconst INTEGRATION_META_DEPENDENCY_KEYS = ['dependsOnModules', 'requiredModules', 'requiresModules'] as const\nconst INTEGRATION_META_ALL_DEPENDENCY_KEYS = [...INTEGRATION_META_DEPENDENCY_KEYS, 'optionalModules'] as const\nconst INTEGRATION_META_REQUIRED_ENV_KEYS = ['requiredEnvVars', 'requiresEnvVars'] as const\nconst INTEGRATION_META_REQUIRED_ANY_ENV_KEYS = ['requiredAnyEnvVars', 'requiresAnyEnvVars'] as const\nconst DEFAULT_OVERLAY_ROOT = 'packages/enterprise'\nexport const APP_ONLY_INTEGRATION_ENV_VAR = 'OM_INTEGRATION_APP_ONLY'\nexport const SKIP_METADATA_FILTERS_INTEGRATION_ENV_VAR = 'OM_INTEGRATION_SKIP_METADATA_FILTERS'\nexport const DISCOVERY_SELECTION_REPORT_INTEGRATION_ENV_VAR = 'OM_INTEGRATION_DISCOVERY_SELECTION_REPORT'\n\nexport function normalizePath(filePath: string): string {\n return filePath.split(path.sep).join('/')\n}\n\nfunction normalizeModuleId(moduleId: string): string {\n return moduleId.trim().toLowerCase()\n}\n\nfunction isEnterpriseModulesEnabled(): boolean {\n const rawValue = process.env.OM_ENABLE_ENTERPRISE_MODULES?.trim().toLowerCase()\n return rawValue === 'true' || rawValue === '1' || rawValue === 'yes' || rawValue === 'on'\n}\n\nfunction isAppOnlyDiscoveryEnabled(): boolean {\n const rawValue = process.env[APP_ONLY_INTEGRATION_ENV_VAR]?.trim().toLowerCase()\n return rawValue === 'true' || rawValue === '1' || rawValue === 'yes' || rawValue === 'on'\n}\n\nfunction isMetadataFilteringDisabled(): boolean {\n const rawValue = process.env[SKIP_METADATA_FILTERS_INTEGRATION_ENV_VAR]?.trim().toLowerCase()\n return rawValue === 'true' || rawValue === '1' || rawValue === 'yes' || rawValue === 'on'\n}\n\nexport function isAppOwnedIntegrationSpecPath(relativePath: string): boolean {\n return !normalizePath(relativePath).split('/').includes('node_modules')\n}\n\nfunction writeDiscoverySelectionReport(projectRoot: string, files: readonly IntegrationSpecDiscoveryItem[]): void {\n const reportFile = process.env[DISCOVERY_SELECTION_REPORT_INTEGRATION_ENV_VAR]?.trim()\n if (!reportFile) return\n writeFileSync(reportFile, JSON.stringify({ projectRoot, paths: files.map((file) => file.path) }))\n}\n\nfunction collectNamedDirectories(rootPath: string, directoryName: string): string[] {\n let entries\n try {\n entries = readdirSync(rootPath, { withFileTypes: true, encoding: 'utf8' })\n } catch {\n return []\n }\n\n const collected: string[] = []\n for (const entry of entries) {\n if (!entry.isDirectory()) continue\n if (DISCOVERY_IGNORED_DIRS.has(entry.name)) continue\n const absolutePath = path.join(rootPath, entry.name)\n if (entry.name === directoryName) {\n collected.push(absolutePath)\n }\n collected.push(...collectNamedDirectories(absolutePath, directoryName))\n }\n return collected\n}\n\nfunction collectSpecFilesFromDirectory(directoryPath: string): string[] {\n let entries\n try {\n entries = readdirSync(directoryPath, { withFileTypes: true, encoding: 'utf8' })\n } catch {\n return []\n }\n\n const collected: string[] = []\n for (const entry of entries) {\n const absolutePath = path.join(directoryPath, entry.name)\n if (entry.isDirectory()) {\n collected.push(...collectSpecFilesFromDirectory(absolutePath))\n continue\n }\n if (entry.isFile() && entry.name.endsWith('.spec.ts')) {\n collected.push(absolutePath)\n }\n }\n return collected\n}\n\nfunction collectDirectDirectoryNames(directoryPath: string): string[] {\n let entries\n try {\n entries = readdirSync(directoryPath, { withFileTypes: true, encoding: 'utf8' })\n } catch {\n return []\n }\n return entries\n .filter((entry) => entry.isDirectory() && !entry.name.startsWith('.'))\n .map((entry) => entry.name)\n}\n\nfunction collectModuleIdsFromModulesRoot(modulesRoot: string, enabledModules: Set<string>): void {\n for (const moduleName of collectDirectDirectoryNames(modulesRoot)) {\n enabledModules.add(normalizeModuleId(moduleName))\n }\n}\n\nfunction readModuleEntryId(element: ts.Expression): string[] {\n if (!ts.isObjectLiteralExpression(element)) return []\n const idProperty = element.properties.find((property): property is ts.PropertyAssignment =>\n ts.isPropertyAssignment(property)\n && (\n (ts.isIdentifier(property.name) && property.name.text === 'id')\n || (ts.isStringLiteralLike(property.name) && property.name.text === 'id')\n ),\n )\n return idProperty && ts.isStringLiteralLike(idProperty.initializer)\n ? [idProperty.initializer.text]\n : []\n}\n\nfunction isPushOntoVariable(node: ts.Node, variableName: string): node is ts.CallExpression {\n return ts.isCallExpression(node)\n && ts.isPropertyAccessExpression(node.expression)\n && node.expression.name.text === 'push'\n && ts.isIdentifier(node.expression.expression)\n && node.expression.expression.text === variableName\n}\n\n/**\n * Module ids a registry file declares for `variableName`: the entries of its array\n * literal initializer and, with `includePushes`, every `variableName.push({ id })` call.\n * Pushes are usually conditional (enterprise or env-gated modules), so including them\n * yields an upper bound of what the app can register, never narrower than the runtime set.\n */\nfunction readDeclaredModuleIdsFromConfig(\n registryPath: string,\n options: { variableName?: string; includePushes?: boolean; optional?: boolean } = {},\n): string[] {\n const variableName = options.variableName ?? 'enabledModules'\n if (options.optional && !existsSync(registryPath)) return []\n const source = readFileSync(registryPath, 'utf8')\n const sourceFile = ts.createSourceFile(\n registryPath,\n source,\n ts.ScriptTarget.Latest,\n true,\n ts.ScriptKind.TS,\n )\n\n const declared: string[] = []\n const visit = (node: ts.Node): void => {\n if (\n ts.isVariableDeclaration(node)\n && ts.isVariableStatement(node.parent.parent)\n && node.parent.parent.parent === sourceFile\n && ts.isIdentifier(node.name)\n && node.name.text === variableName\n && node.initializer\n && ts.isArrayLiteralExpression(node.initializer)\n ) {\n declared.push(...node.initializer.elements.flatMap(readModuleEntryId))\n }\n if (options.includePushes && isPushOntoVariable(node, variableName)) {\n declared.push(...node.arguments.flatMap(readModuleEntryId))\n }\n ts.forEachChild(node, visit)\n }\n visit(sourceFile)\n return declared\n}\n\nfunction resolveTestAppRoot(): string | null {\n const configuredTestAppRoot = process.env.OM_TEST_APP_ROOT?.trim()\n return configuredTestAppRoot ? path.resolve(configuredTestAppRoot) : null\n}\n\n/**\n * Every module a standalone test app may register: its `enabledModules` literal, its\n * conditional `enabledModules.push(...)` entries, and its official-module activations.\n * Used to skip specs whose owning module the app does not ship at all.\n */\nfunction resolvePossiblyEnabledTestAppModuleIds(testAppRoot: string): Set<string> {\n return new Set(\n [\n ...readDeclaredModuleIdsFromConfig(path.join(testAppRoot, 'src', 'modules.ts'), { includePushes: true }),\n ...readDeclaredModuleIdsFromConfig(\n path.join(testAppRoot, 'src', 'official-modules.generated.ts'),\n { variableName: 'officialModuleEntries', includePushes: true, optional: true },\n ),\n ].map(normalizeModuleId),\n )\n}\n\nfunction resolveEnabledModuleIds(projectRoot: string): Set<string> {\n const testAppRoot = resolveTestAppRoot()\n if (testAppRoot) {\n return new Set(\n readDeclaredModuleIdsFromConfig(path.join(testAppRoot, 'src', 'modules.ts')).map(normalizeModuleId),\n )\n }\n\n const enabledModules = new Set<string>()\n const appModulesRoot = path.join(projectRoot, 'src', 'modules')\n const appsRoot = path.join(projectRoot, 'apps')\n const packagesRoot = path.join(projectRoot, 'packages')\n const installedPackagesRoot = path.join(projectRoot, 'node_modules', '@open-mercato')\n const enterpriseEnabled = isEnterpriseModulesEnabled()\n\n // Standalone app: src/modules at project root\n collectModuleIdsFromModulesRoot(appModulesRoot, enabledModules)\n\n for (const appName of collectDirectDirectoryNames(appsRoot)) {\n const moduleRoot = path.join(appsRoot, appName, 'src', 'modules')\n collectModuleIdsFromModulesRoot(moduleRoot, enabledModules)\n }\n for (const packageName of collectDirectDirectoryNames(packagesRoot)) {\n if (packageName === 'enterprise' && !enterpriseEnabled) {\n continue\n }\n const moduleRoot = path.join(packagesRoot, packageName, 'src', 'modules')\n collectModuleIdsFromModulesRoot(moduleRoot, enabledModules)\n }\n // Standalone app: installed @open-mercato packages in node_modules\n for (const packageName of collectDirectDirectoryNames(installedPackagesRoot)) {\n if (packageName === 'enterprise' && !enterpriseEnabled) {\n continue\n }\n const moduleRoot = path.join(installedPackagesRoot, packageName, 'src', 'modules')\n collectModuleIdsFromModulesRoot(moduleRoot, enabledModules)\n }\n const createAppTemplateModulesRoot = path.join(projectRoot, 'packages', 'create-app', 'template', 'src', 'modules')\n collectModuleIdsFromModulesRoot(createAppTemplateModulesRoot, enabledModules)\n\n return enabledModules\n}\n\nfunction extractModuleNameFromIntegrationPath(relativePath: string): string | null {\n const segments = normalizePath(relativePath).split('/')\n const integrationDirectoryIndex = segments.indexOf(MODULE_INTEGRATION_DIRECTORY_NAME)\n if (integrationDirectoryIndex <= 0) {\n return null\n }\n const moduleSegment = segments[integrationDirectoryIndex - 1]\n return moduleSegment && moduleSegment.length > 0 ? moduleSegment : null\n}\n\n/**\n * The module a spec belongs to: the directory directly under the closest `modules/`\n * ancestor of `__integration__`, provided that directory is a real module (it ships an\n * `index.ts`/`index.js`). Returns null for specs outside a module, e.g. `packages/ui`.\n */\nfunction resolveOwningModuleId(projectRoot: string, relativeSpecPath: string): string | null {\n const segments = normalizePath(relativeSpecPath).split('/')\n const integrationDirectoryIndex = segments.indexOf(MODULE_INTEGRATION_DIRECTORY_NAME)\n if (integrationDirectoryIndex <= 0) return null\n const modulesSegmentIndex = segments.lastIndexOf('modules', integrationDirectoryIndex - 1)\n if (modulesSegmentIndex === -1 || modulesSegmentIndex + 1 >= integrationDirectoryIndex) return null\n const moduleRoot = path.join(projectRoot, ...segments.slice(0, modulesSegmentIndex + 2))\n const isRealModule = ['index.ts', 'index.js'].some((fileName) => existsSync(path.join(moduleRoot, fileName)))\n return isRealModule ? normalizeModuleId(segments[modulesSegmentIndex + 1]) : null\n}\n\nfunction resolveOverlayRootPath(): string {\n const configured = process.env.OM_INTEGRATION_OVERLAY_ROOT?.trim()\n if (!configured) {\n return DEFAULT_OVERLAY_ROOT\n }\n return configured.replace(/\\/+$/, '')\n}\n\nfunction isOverlayIntegrationPath(relativePath: string, overlayRoot: string): boolean {\n return normalizePath(relativePath).startsWith(`${normalizePath(overlayRoot)}/`)\n}\n\nfunction extractStringArrayFromSource(source: string, keys: readonly string[]): string[] {\n const collected = new Set<string>()\n for (const key of keys) {\n const keyPattern = new RegExp(`${key}\\\\s*:\\\\s*\\\\[([\\\\s\\\\S]*?)\\\\]`, 'm')\n const keyMatch = source.match(keyPattern)\n if (!keyMatch?.[1]) continue\n const valuesPattern = /['\"`]([a-zA-Z0-9_.-]+)['\"`]/g\n for (const valueMatch of keyMatch[1].matchAll(valuesPattern)) {\n const value = String(valueMatch[1] ?? '').trim()\n if (value) {\n collected.add(value)\n }\n }\n }\n return Array.from(collected)\n}\n\nfunction extractDependencyListFromSource(source: string, includeOptional: boolean): string[] {\n const keys = includeOptional ? INTEGRATION_META_ALL_DEPENDENCY_KEYS : INTEGRATION_META_DEPENDENCY_KEYS\n return extractStringArrayFromSource(source, keys).map(normalizeModuleId)\n}\n\nfunction extractRequiredEnvVarsFromSource(source: string): string[] {\n return extractStringArrayFromSource(source, INTEGRATION_META_REQUIRED_ENV_KEYS)\n}\n\nfunction extractRequiredAnyEnvVarsFromSource(source: string): string[] {\n return extractStringArrayFromSource(source, INTEGRATION_META_REQUIRED_ANY_ENV_KEYS)\n}\n\nfunction readDependenciesFromMetadataFile(absolutePath: string, includeOptional: boolean): string[] {\n try {\n return extractDependencyListFromSource(readFileSync(absolutePath, 'utf8'), includeOptional)\n } catch {\n return []\n }\n}\n\nfunction readRequiredEnvVarsFromMetadataFile(absolutePath: string): string[] {\n try {\n return extractRequiredEnvVarsFromSource(readFileSync(absolutePath, 'utf8'))\n } catch {\n return []\n }\n}\n\nfunction readRequiredAnyEnvVarsFromMetadataFile(absolutePath: string): string[] {\n try {\n return extractRequiredAnyEnvVarsFromSource(readFileSync(absolutePath, 'utf8'))\n } catch {\n return []\n }\n}\n\nfunction resolveIntegrationRootDirectory(relativeSpecPath: string): string | null {\n const segments = normalizePath(relativeSpecPath).split('/')\n const integrationDirectoryIndex = segments.indexOf(MODULE_INTEGRATION_DIRECTORY_NAME)\n if (integrationDirectoryIndex === -1) {\n return null\n }\n return segments.slice(0, integrationDirectoryIndex + 1).join('/')\n}\n\nexport function resolveModuleDependenciesForSpec(\n projectRoot: string,\n relativeSpecPath: string,\n { includeOptional = false }: { includeOptional?: boolean } = {},\n): string[] {\n const requiredModules = new Set<string>()\n const normalizedSpecPath = normalizePath(relativeSpecPath)\n const absoluteSpecPath = path.join(projectRoot, normalizedSpecPath)\n const integrationRoot = resolveIntegrationRootDirectory(normalizedSpecPath)\n\n if (integrationRoot) {\n const relativeDirectory = normalizePath(path.dirname(normalizedSpecPath))\n const integrationRootAbsolute = path.join(projectRoot, integrationRoot)\n const directoryAbsolute = path.join(projectRoot, relativeDirectory)\n const relativeFromIntegrationRoot = normalizePath(path.relative(integrationRootAbsolute, directoryAbsolute))\n const pathSegments = relativeFromIntegrationRoot === '.'\n ? []\n : relativeFromIntegrationRoot.split('/').filter(Boolean)\n\n let currentDirectory = integrationRootAbsolute\n const traversal = [currentDirectory, ...pathSegments.map((segment) => {\n currentDirectory = path.join(currentDirectory, segment)\n return currentDirectory\n })]\n\n for (const directoryPath of traversal) {\n for (const metadataFileName of INTEGRATION_META_FILE_NAMES) {\n const metadataPath = path.join(directoryPath, metadataFileName)\n readDependenciesFromMetadataFile(metadataPath, includeOptional).forEach((dependency) => requiredModules.add(dependency))\n }\n }\n }\n\n readDependenciesFromMetadataFile(absoluteSpecPath, includeOptional).forEach((dependency) => requiredModules.add(dependency))\n const specFileName = path.basename(normalizedSpecPath, '.spec.ts')\n const perTestMetadataPath = path.join(path.dirname(absoluteSpecPath), `${specFileName}.meta.ts`)\n readDependenciesFromMetadataFile(perTestMetadataPath, includeOptional).forEach((dependency) => requiredModules.add(dependency))\n\n return Array.from(requiredModules)\n}\n\nfunction resolveRequiredEnvVarsForSpec(projectRoot: string, relativeSpecPath: string): string[] {\n const requiredEnvVars = new Set<string>()\n const normalizedSpecPath = normalizePath(relativeSpecPath)\n const absoluteSpecPath = path.join(projectRoot, normalizedSpecPath)\n const integrationRoot = resolveIntegrationRootDirectory(normalizedSpecPath)\n\n if (integrationRoot) {\n const relativeDirectory = normalizePath(path.dirname(normalizedSpecPath))\n const integrationRootAbsolute = path.join(projectRoot, integrationRoot)\n const directoryAbsolute = path.join(projectRoot, relativeDirectory)\n const relativeFromIntegrationRoot = normalizePath(path.relative(integrationRootAbsolute, directoryAbsolute))\n const pathSegments = relativeFromIntegrationRoot === '.'\n ? []\n : relativeFromIntegrationRoot.split('/').filter(Boolean)\n\n let currentDirectory = integrationRootAbsolute\n const traversal = [currentDirectory, ...pathSegments.map((segment) => {\n currentDirectory = path.join(currentDirectory, segment)\n return currentDirectory\n })]\n\n for (const directoryPath of traversal) {\n for (const metadataFileName of INTEGRATION_META_FILE_NAMES) {\n const metadataPath = path.join(directoryPath, metadataFileName)\n readRequiredEnvVarsFromMetadataFile(metadataPath).forEach((envVar) => requiredEnvVars.add(envVar))\n }\n }\n }\n\n readRequiredEnvVarsFromMetadataFile(absoluteSpecPath).forEach((envVar) => requiredEnvVars.add(envVar))\n const specFileName = path.basename(normalizedSpecPath, '.spec.ts')\n const perTestMetadataPath = path.join(path.dirname(absoluteSpecPath), `${specFileName}.meta.ts`)\n readRequiredEnvVarsFromMetadataFile(perTestMetadataPath).forEach((envVar) => requiredEnvVars.add(envVar))\n\n return Array.from(requiredEnvVars)\n}\n\nfunction resolveRequiredAnyEnvVarsForSpec(projectRoot: string, relativeSpecPath: string): string[] {\n const requiredAnyEnvVars = new Set<string>()\n const normalizedSpecPath = normalizePath(relativeSpecPath)\n const absoluteSpecPath = path.join(projectRoot, normalizedSpecPath)\n const integrationRoot = resolveIntegrationRootDirectory(normalizedSpecPath)\n\n if (integrationRoot) {\n const relativeDirectory = normalizePath(path.dirname(normalizedSpecPath))\n const integrationRootAbsolute = path.join(projectRoot, integrationRoot)\n const directoryAbsolute = path.join(projectRoot, relativeDirectory)\n const relativeFromIntegrationRoot = normalizePath(path.relative(integrationRootAbsolute, directoryAbsolute))\n const pathSegments = relativeFromIntegrationRoot === '.'\n ? []\n : relativeFromIntegrationRoot.split('/').filter(Boolean)\n\n let currentDirectory = integrationRootAbsolute\n const traversal = [currentDirectory, ...pathSegments.map((segment) => {\n currentDirectory = path.join(currentDirectory, segment)\n return currentDirectory\n })]\n\n for (const directoryPath of traversal) {\n for (const metadataFileName of INTEGRATION_META_FILE_NAMES) {\n const metadataPath = path.join(directoryPath, metadataFileName)\n readRequiredAnyEnvVarsFromMetadataFile(metadataPath).forEach((envVar) => requiredAnyEnvVars.add(envVar))\n }\n }\n }\n\n readRequiredAnyEnvVarsFromMetadataFile(absoluteSpecPath).forEach((envVar) => requiredAnyEnvVars.add(envVar))\n const specFileName = path.basename(normalizedSpecPath, '.spec.ts')\n const perTestMetadataPath = path.join(path.dirname(absoluteSpecPath), `${specFileName}.meta.ts`)\n readRequiredAnyEnvVarsFromMetadataFile(perTestMetadataPath).forEach((envVar) => requiredAnyEnvVars.add(envVar))\n\n return Array.from(requiredAnyEnvVars)\n}\n\nfunction isEnvironmentVariableConfigured(name: string): boolean {\n const value = process.env[name]\n return typeof value === 'string' && value.trim().length > 0\n}\n\nexport function discoverIntegrationSpecFiles(projectRoot: string, legacyIntegrationRoot: string): IntegrationSpecDiscoveryItem[] {\n const discoveredByPath = new Map<string, IntegrationSpecDiscoveryItem>()\n const overlayRoot = resolveOverlayRootPath()\n const enterpriseEnabled = isEnterpriseModulesEnabled()\n const appOnly = isAppOnlyDiscoveryEnabled()\n const discoveryRoots = [\n path.join(projectRoot, 'src', 'modules'),\n path.join(projectRoot, 'apps'),\n path.join(projectRoot, 'packages'),\n ...(appOnly ? [] : [path.join(projectRoot, 'node_modules', '@open-mercato')]),\n ]\n\n for (const specFile of collectSpecFilesFromDirectory(legacyIntegrationRoot)) {\n const relativePath = normalizePath(path.relative(projectRoot, specFile))\n discoveredByPath.set(relativePath, {\n path: relativePath,\n moduleName: extractModuleNameFromIntegrationPath(relativePath),\n isOverlay: isOverlayIntegrationPath(relativePath, overlayRoot),\n requiredModules: resolveModuleDependenciesForSpec(projectRoot, relativePath),\n requiredEnvVars: resolveRequiredEnvVarsForSpec(projectRoot, relativePath),\n requiredAnyEnvVars: resolveRequiredAnyEnvVarsForSpec(projectRoot, relativePath),\n })\n }\n\n for (const root of discoveryRoots) {\n for (const integrationDirectory of collectNamedDirectories(root, MODULE_INTEGRATION_DIRECTORY_NAME)) {\n for (const specFile of collectSpecFilesFromDirectory(integrationDirectory)) {\n const relativePath = normalizePath(path.relative(projectRoot, specFile))\n discoveredByPath.set(relativePath, {\n path: relativePath,\n moduleName: extractModuleNameFromIntegrationPath(relativePath),\n isOverlay: isOverlayIntegrationPath(relativePath, overlayRoot),\n requiredModules: resolveModuleDependenciesForSpec(projectRoot, relativePath),\n requiredEnvVars: resolveRequiredEnvVarsForSpec(projectRoot, relativePath),\n requiredAnyEnvVars: resolveRequiredAnyEnvVarsForSpec(projectRoot, relativePath),\n })\n }\n }\n }\n\n const discovered = Array.from(discoveredByPath.values())\n .filter((file) => !appOnly || isAppOwnedIntegrationSpecPath(file.path))\n if (isMetadataFilteringDisabled()) {\n const selected = discovered.sort((left, right) => left.path.localeCompare(right.path))\n writeDiscoverySelectionReport(projectRoot, selected)\n return selected\n }\n const enabledModules = resolveEnabledModuleIds(projectRoot)\n const testAppRoot = resolveTestAppRoot()\n const testAppModules = testAppRoot ? resolvePossiblyEnabledTestAppModuleIds(testAppRoot) : null\n const enabledModuleNames = new Set<string>()\n for (const file of discovered) {\n if (!file.isOverlay && file.moduleName) {\n enabledModuleNames.add(file.moduleName)\n }\n }\n\n const selected = discovered\n .filter((file) => {\n if (file.requiredModules.some((moduleId) => !enabledModules.has(normalizeModuleId(moduleId)))) {\n return false\n }\n if (testAppModules && !file.isOverlay) {\n const owningModuleId = resolveOwningModuleId(projectRoot, file.path)\n if (owningModuleId && !testAppModules.has(owningModuleId)) {\n return false\n }\n }\n if (file.requiredEnvVars.some((envVar) => !isEnvironmentVariableConfigured(envVar))) {\n return false\n }\n if (\n file.requiredAnyEnvVars.length > 0 &&\n !file.requiredAnyEnvVars.some((envVar) => isEnvironmentVariableConfigured(envVar))\n ) {\n return false\n }\n if (!file.isOverlay) {\n return true\n }\n if (!enterpriseEnabled) {\n return false\n }\n if (!file.moduleName) {\n return true\n }\n if (enabledModuleNames.has(file.moduleName)) {\n return true\n }\n return enabledModules.has(normalizeModuleId(file.moduleName))\n })\n .sort((left, right) => left.path.localeCompare(right.path))\n writeDiscoverySelectionReport(projectRoot, selected)\n return selected\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,YAAY,cAAc,aAAa,qBAAqB;AACrE,OAAO,UAAU;AACjB,OAAO,QAAQ;AAWf,MAAM,oCAAoC;AAC1C,MAAM,yBAAyB,oBAAI,IAAI;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AACD,MAAM,8BAA8B,CAAC,WAAW,UAAU;AAC1D,MAAM,mCAAmC,CAAC,oBAAoB,mBAAmB,iBAAiB;AAClG,MAAM,uCAAuC,CAAC,GAAG,kCAAkC,iBAAiB;AACpG,MAAM,qCAAqC,CAAC,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AAC,KAAK,WAAW;AACrC,YAAM,iBAAiB,sBAAsB,aAAa,KAAK,IAAI;AACnE,UAAI,kBAAkB,CAAC,eAAe,IAAI,cAAc,GAAG;AACzD,eAAO;AAAA,MACT;AAAA,IACF;AACA,QAAI,KAAK,gBAAgB,KAAK,CAAC,WAAW,CAAC,gCAAgC,MAAM,CAAC,GAAG;AACnF,aAAO;AAAA,IACT;AACA,QACE,KAAK,mBAAmB,SAAS,KACjC,CAAC,KAAK,mBAAmB,KAAK,CAAC,WAAW,gCAAgC,MAAM,CAAC,GACjF;AACA,aAAO;AAAA,IACT;AACA,QAAI,CAAC,KAAK,WAAW;AACnB,aAAO;AAAA,IACT;AACA,QAAI,CAAC,mBAAmB;AACtB,aAAO;AAAA,IACT;AACA,QAAI,CAAC,KAAK,YAAY;AACpB,aAAO;AAAA,IACT;AACA,QAAI,mBAAmB,IAAI,KAAK,UAAU,GAAG;AAC3C,aAAO;AAAA,IACT;AACA,WAAO,eAAe,IAAI,kBAAkB,KAAK,UAAU,CAAC;AAAA,EAC9D,CAAC,EACA,KAAK,CAAC,MAAM,UAAU,KAAK,KAAK,cAAc,MAAM,IAAI,CAAC;AAC5D,gCAA8B,aAAa,QAAQ;AACnD,SAAO;AACT;",
|
|
4
|
+
"sourcesContent": ["import { existsSync, readFileSync, readdirSync, writeFileSync } from 'node:fs'\nimport path from 'node:path'\nimport ts from 'typescript-js'\n\nexport type IntegrationSpecDiscoveryItem = {\n path: string\n moduleName: string | null\n isOverlay: boolean\n requiredModules: string[]\n requiredEnvVars: string[]\n requiredAnyEnvVars: string[]\n}\n\nconst MODULE_INTEGRATION_DIRECTORY_NAME = '__integration__'\nconst DISCOVERY_IGNORED_DIRS = new Set([\n 'node_modules',\n '.git',\n '.next',\n 'dist',\n '.turbo',\n 'coverage',\n 'test-results',\n '.yarn',\n '.cache',\n 'tmp',\n 'temp',\n '.claude',\n '.codex',\n])\nconst INTEGRATION_META_FILE_NAMES = ['meta.ts', 'index.ts'] as const\nconst INTEGRATION_META_DEPENDENCY_KEYS = ['dependsOnModules', 'requiredModules', 'requiresModules'] as const\nconst INTEGRATION_META_ALL_DEPENDENCY_KEYS = [...INTEGRATION_META_DEPENDENCY_KEYS, 'optionalModules'] as const\nconst INTEGRATION_META_REQUIRED_ENV_KEYS = ['requiredEnvVars', 'requiresEnvVars'] as const\nconst INTEGRATION_META_REQUIRED_ANY_ENV_KEYS = ['requiredAnyEnvVars', 'requiresAnyEnvVars'] as const\nconst DEFAULT_OVERLAY_ROOT = 'packages/enterprise'\nexport const APP_ONLY_INTEGRATION_ENV_VAR = 'OM_INTEGRATION_APP_ONLY'\nexport const SKIP_METADATA_FILTERS_INTEGRATION_ENV_VAR = 'OM_INTEGRATION_SKIP_METADATA_FILTERS'\nexport const DISCOVERY_SELECTION_REPORT_INTEGRATION_ENV_VAR = 'OM_INTEGRATION_DISCOVERY_SELECTION_REPORT'\n\nexport function normalizePath(filePath: string): string {\n return filePath.split(path.sep).join('/')\n}\n\nfunction normalizeModuleId(moduleId: string): string {\n return moduleId.trim().toLowerCase()\n}\n\nexport function parseIntegrationModuleList(value: string | undefined): Set<string> {\n return new Set((value ?? '').split(',').map(normalizeModuleId).filter(Boolean))\n}\n\nexport function filterIntegrationSpecsForModules<T extends Pick<IntegrationSpecDiscoveryItem, 'moduleName' | 'requiredModules'>>(\n specs: T[],\n modules: Set<string>,\n): T[] {\n if (modules.size === 0) return specs\n return specs.filter((spec) => {\n if (spec.moduleName === null) return true\n if (modules.has(normalizeModuleId(spec.moduleName))) return true\n return spec.requiredModules.some((moduleId) => modules.has(normalizeModuleId(moduleId)))\n })\n}\n\nfunction isEnterpriseModulesEnabled(): boolean {\n const rawValue = process.env.OM_ENABLE_ENTERPRISE_MODULES?.trim().toLowerCase()\n return rawValue === 'true' || rawValue === '1' || rawValue === 'yes' || rawValue === 'on'\n}\n\nfunction isAppOnlyDiscoveryEnabled(): boolean {\n const rawValue = process.env[APP_ONLY_INTEGRATION_ENV_VAR]?.trim().toLowerCase()\n return rawValue === 'true' || rawValue === '1' || rawValue === 'yes' || rawValue === 'on'\n}\n\nfunction isMetadataFilteringDisabled(): boolean {\n const rawValue = process.env[SKIP_METADATA_FILTERS_INTEGRATION_ENV_VAR]?.trim().toLowerCase()\n return rawValue === 'true' || rawValue === '1' || rawValue === 'yes' || rawValue === 'on'\n}\n\nexport function isAppOwnedIntegrationSpecPath(relativePath: string): boolean {\n return !normalizePath(relativePath).split('/').includes('node_modules')\n}\n\nfunction writeDiscoverySelectionReport(projectRoot: string, files: readonly IntegrationSpecDiscoveryItem[]): void {\n const reportFile = process.env[DISCOVERY_SELECTION_REPORT_INTEGRATION_ENV_VAR]?.trim()\n if (!reportFile) return\n writeFileSync(reportFile, JSON.stringify({ projectRoot, paths: files.map((file) => file.path) }))\n}\n\nfunction collectNamedDirectories(rootPath: string, directoryName: string): string[] {\n let entries\n try {\n entries = readdirSync(rootPath, { withFileTypes: true, encoding: 'utf8' })\n } catch {\n return []\n }\n\n const collected: string[] = []\n for (const entry of entries) {\n if (!entry.isDirectory()) continue\n if (DISCOVERY_IGNORED_DIRS.has(entry.name)) continue\n const absolutePath = path.join(rootPath, entry.name)\n if (entry.name === directoryName) {\n collected.push(absolutePath)\n }\n collected.push(...collectNamedDirectories(absolutePath, directoryName))\n }\n return collected\n}\n\nfunction collectSpecFilesFromDirectory(directoryPath: string): string[] {\n let entries\n try {\n entries = readdirSync(directoryPath, { withFileTypes: true, encoding: 'utf8' })\n } catch {\n return []\n }\n\n const collected: string[] = []\n for (const entry of entries) {\n const absolutePath = path.join(directoryPath, entry.name)\n if (entry.isDirectory()) {\n collected.push(...collectSpecFilesFromDirectory(absolutePath))\n continue\n }\n if (entry.isFile() && entry.name.endsWith('.spec.ts')) {\n collected.push(absolutePath)\n }\n }\n return collected\n}\n\nfunction collectDirectDirectoryNames(directoryPath: string): string[] {\n let entries\n try {\n entries = readdirSync(directoryPath, { withFileTypes: true, encoding: 'utf8' })\n } catch {\n return []\n }\n return entries\n .filter((entry) => entry.isDirectory() && !entry.name.startsWith('.'))\n .map((entry) => entry.name)\n}\n\nfunction collectModuleIdsFromModulesRoot(modulesRoot: string, enabledModules: Set<string>): void {\n for (const moduleName of collectDirectDirectoryNames(modulesRoot)) {\n enabledModules.add(normalizeModuleId(moduleName))\n }\n}\n\nfunction readModuleEntryId(element: ts.Expression): string[] {\n if (!ts.isObjectLiteralExpression(element)) return []\n const idProperty = element.properties.find((property): property is ts.PropertyAssignment =>\n ts.isPropertyAssignment(property)\n && (\n (ts.isIdentifier(property.name) && property.name.text === 'id')\n || (ts.isStringLiteralLike(property.name) && property.name.text === 'id')\n ),\n )\n return idProperty && ts.isStringLiteralLike(idProperty.initializer)\n ? [idProperty.initializer.text]\n : []\n}\n\nfunction isPushOntoVariable(node: ts.Node, variableName: string): node is ts.CallExpression {\n return ts.isCallExpression(node)\n && ts.isPropertyAccessExpression(node.expression)\n && node.expression.name.text === 'push'\n && ts.isIdentifier(node.expression.expression)\n && node.expression.expression.text === variableName\n}\n\n/**\n * Module ids a registry file declares for `variableName`: the entries of its array\n * literal initializer and, with `includePushes`, every `variableName.push({ id })` call.\n * Pushes are usually conditional (enterprise or env-gated modules), so including them\n * yields an upper bound of what the app can register, never narrower than the runtime set.\n */\nfunction readDeclaredModuleIdsFromConfig(\n registryPath: string,\n options: { variableName?: string; includePushes?: boolean; optional?: boolean } = {},\n): string[] {\n const variableName = options.variableName ?? 'enabledModules'\n if (options.optional && !existsSync(registryPath)) return []\n const source = readFileSync(registryPath, 'utf8')\n const sourceFile = ts.createSourceFile(\n registryPath,\n source,\n ts.ScriptTarget.Latest,\n true,\n ts.ScriptKind.TS,\n )\n\n const declared: string[] = []\n const visit = (node: ts.Node): void => {\n if (\n ts.isVariableDeclaration(node)\n && ts.isVariableStatement(node.parent.parent)\n && node.parent.parent.parent === sourceFile\n && ts.isIdentifier(node.name)\n && node.name.text === variableName\n && node.initializer\n && ts.isArrayLiteralExpression(node.initializer)\n ) {\n declared.push(...node.initializer.elements.flatMap(readModuleEntryId))\n }\n if (options.includePushes && isPushOntoVariable(node, variableName)) {\n declared.push(...node.arguments.flatMap(readModuleEntryId))\n }\n ts.forEachChild(node, visit)\n }\n visit(sourceFile)\n return declared\n}\n\nfunction resolveTestAppRoot(): string | null {\n const configuredTestAppRoot = process.env.OM_TEST_APP_ROOT?.trim()\n return configuredTestAppRoot ? path.resolve(configuredTestAppRoot) : null\n}\n\n/**\n * Every module a standalone test app may register: its `enabledModules` literal, its\n * conditional `enabledModules.push(...)` entries, and its official-module activations.\n * Used to skip specs whose owning module the app does not ship at all.\n */\nfunction resolvePossiblyEnabledTestAppModuleIds(testAppRoot: string): Set<string> {\n return new Set(\n [\n ...readDeclaredModuleIdsFromConfig(path.join(testAppRoot, 'src', 'modules.ts'), { includePushes: true }),\n ...readDeclaredModuleIdsFromConfig(\n path.join(testAppRoot, 'src', 'official-modules.generated.ts'),\n { variableName: 'officialModuleEntries', includePushes: true, optional: true },\n ),\n ].map(normalizeModuleId),\n )\n}\n\nfunction resolveEnabledModuleIds(projectRoot: string): Set<string> {\n const testAppRoot = resolveTestAppRoot()\n if (testAppRoot) {\n return new Set(\n readDeclaredModuleIdsFromConfig(path.join(testAppRoot, 'src', 'modules.ts')).map(normalizeModuleId),\n )\n }\n\n const enabledModules = new Set<string>()\n const appModulesRoot = path.join(projectRoot, 'src', 'modules')\n const appsRoot = path.join(projectRoot, 'apps')\n const packagesRoot = path.join(projectRoot, 'packages')\n const installedPackagesRoot = path.join(projectRoot, 'node_modules', '@open-mercato')\n const enterpriseEnabled = isEnterpriseModulesEnabled()\n\n // Standalone app: src/modules at project root\n collectModuleIdsFromModulesRoot(appModulesRoot, enabledModules)\n\n for (const appName of collectDirectDirectoryNames(appsRoot)) {\n const moduleRoot = path.join(appsRoot, appName, 'src', 'modules')\n collectModuleIdsFromModulesRoot(moduleRoot, enabledModules)\n }\n for (const packageName of collectDirectDirectoryNames(packagesRoot)) {\n if (packageName === 'enterprise' && !enterpriseEnabled) {\n continue\n }\n const moduleRoot = path.join(packagesRoot, packageName, 'src', 'modules')\n collectModuleIdsFromModulesRoot(moduleRoot, enabledModules)\n }\n // Standalone app: installed @open-mercato packages in node_modules\n for (const packageName of collectDirectDirectoryNames(installedPackagesRoot)) {\n if (packageName === 'enterprise' && !enterpriseEnabled) {\n continue\n }\n const moduleRoot = path.join(installedPackagesRoot, packageName, 'src', 'modules')\n collectModuleIdsFromModulesRoot(moduleRoot, enabledModules)\n }\n const createAppTemplateModulesRoot = path.join(projectRoot, 'packages', 'create-app', 'template', 'src', 'modules')\n collectModuleIdsFromModulesRoot(createAppTemplateModulesRoot, enabledModules)\n\n return enabledModules\n}\n\nfunction extractModuleNameFromIntegrationPath(relativePath: string): string | null {\n const segments = normalizePath(relativePath).split('/')\n const integrationDirectoryIndex = segments.indexOf(MODULE_INTEGRATION_DIRECTORY_NAME)\n if (integrationDirectoryIndex <= 0) {\n return null\n }\n const moduleSegment = segments[integrationDirectoryIndex - 1]\n return moduleSegment && moduleSegment.length > 0 ? moduleSegment : null\n}\n\n/**\n * The module a spec belongs to: the directory directly under the closest `modules/`\n * ancestor of `__integration__`, provided that directory is a real module (it ships an\n * `index.ts`/`index.js`). Returns null for specs outside a module, e.g. `packages/ui`.\n */\nfunction resolveOwningModuleId(projectRoot: string, relativeSpecPath: string): string | null {\n const segments = normalizePath(relativeSpecPath).split('/')\n const integrationDirectoryIndex = segments.indexOf(MODULE_INTEGRATION_DIRECTORY_NAME)\n if (integrationDirectoryIndex <= 0) return null\n const modulesSegmentIndex = segments.lastIndexOf('modules', integrationDirectoryIndex - 1)\n if (modulesSegmentIndex === -1 || modulesSegmentIndex + 1 >= integrationDirectoryIndex) return null\n const moduleRoot = path.join(projectRoot, ...segments.slice(0, modulesSegmentIndex + 2))\n const isRealModule = ['index.ts', 'index.js'].some((fileName) => existsSync(path.join(moduleRoot, fileName)))\n return isRealModule ? normalizeModuleId(segments[modulesSegmentIndex + 1]) : null\n}\n\nfunction resolveOverlayRootPath(): string {\n const configured = process.env.OM_INTEGRATION_OVERLAY_ROOT?.trim()\n if (!configured) {\n return DEFAULT_OVERLAY_ROOT\n }\n return configured.replace(/\\/+$/, '')\n}\n\nfunction isOverlayIntegrationPath(relativePath: string, overlayRoot: string): boolean {\n return normalizePath(relativePath).startsWith(`${normalizePath(overlayRoot)}/`)\n}\n\nfunction extractStringArrayFromSource(source: string, keys: readonly string[]): string[] {\n const collected = new Set<string>()\n for (const key of keys) {\n const keyPattern = new RegExp(`${key}\\\\s*:\\\\s*\\\\[([\\\\s\\\\S]*?)\\\\]`, 'm')\n const keyMatch = source.match(keyPattern)\n if (!keyMatch?.[1]) continue\n const valuesPattern = /['\"`]([a-zA-Z0-9_.-]+)['\"`]/g\n for (const valueMatch of keyMatch[1].matchAll(valuesPattern)) {\n const value = String(valueMatch[1] ?? '').trim()\n if (value) {\n collected.add(value)\n }\n }\n }\n return Array.from(collected)\n}\n\nfunction extractDependencyListFromSource(source: string, includeOptional: boolean): string[] {\n const keys = includeOptional ? INTEGRATION_META_ALL_DEPENDENCY_KEYS : INTEGRATION_META_DEPENDENCY_KEYS\n return extractStringArrayFromSource(source, keys).map(normalizeModuleId)\n}\n\nfunction extractRequiredEnvVarsFromSource(source: string): string[] {\n return extractStringArrayFromSource(source, INTEGRATION_META_REQUIRED_ENV_KEYS)\n}\n\nfunction extractRequiredAnyEnvVarsFromSource(source: string): string[] {\n return extractStringArrayFromSource(source, INTEGRATION_META_REQUIRED_ANY_ENV_KEYS)\n}\n\nfunction readDependenciesFromMetadataFile(absolutePath: string, includeOptional: boolean): string[] {\n try {\n return extractDependencyListFromSource(readFileSync(absolutePath, 'utf8'), includeOptional)\n } catch {\n return []\n }\n}\n\nfunction readRequiredEnvVarsFromMetadataFile(absolutePath: string): string[] {\n try {\n return extractRequiredEnvVarsFromSource(readFileSync(absolutePath, 'utf8'))\n } catch {\n return []\n }\n}\n\nfunction readRequiredAnyEnvVarsFromMetadataFile(absolutePath: string): string[] {\n try {\n return extractRequiredAnyEnvVarsFromSource(readFileSync(absolutePath, 'utf8'))\n } catch {\n return []\n }\n}\n\nfunction resolveIntegrationRootDirectory(relativeSpecPath: string): string | null {\n const segments = normalizePath(relativeSpecPath).split('/')\n const integrationDirectoryIndex = segments.indexOf(MODULE_INTEGRATION_DIRECTORY_NAME)\n if (integrationDirectoryIndex === -1) {\n return null\n }\n return segments.slice(0, integrationDirectoryIndex + 1).join('/')\n}\n\nexport function resolveModuleDependenciesForSpec(\n projectRoot: string,\n relativeSpecPath: string,\n { includeOptional = false }: { includeOptional?: boolean } = {},\n): string[] {\n const requiredModules = new Set<string>()\n const normalizedSpecPath = normalizePath(relativeSpecPath)\n const absoluteSpecPath = path.join(projectRoot, normalizedSpecPath)\n const integrationRoot = resolveIntegrationRootDirectory(normalizedSpecPath)\n\n if (integrationRoot) {\n const relativeDirectory = normalizePath(path.dirname(normalizedSpecPath))\n const integrationRootAbsolute = path.join(projectRoot, integrationRoot)\n const directoryAbsolute = path.join(projectRoot, relativeDirectory)\n const relativeFromIntegrationRoot = normalizePath(path.relative(integrationRootAbsolute, directoryAbsolute))\n const pathSegments = relativeFromIntegrationRoot === '.'\n ? []\n : relativeFromIntegrationRoot.split('/').filter(Boolean)\n\n let currentDirectory = integrationRootAbsolute\n const traversal = [currentDirectory, ...pathSegments.map((segment) => {\n currentDirectory = path.join(currentDirectory, segment)\n return currentDirectory\n })]\n\n for (const directoryPath of traversal) {\n for (const metadataFileName of INTEGRATION_META_FILE_NAMES) {\n const metadataPath = path.join(directoryPath, metadataFileName)\n readDependenciesFromMetadataFile(metadataPath, includeOptional).forEach((dependency) => requiredModules.add(dependency))\n }\n }\n }\n\n readDependenciesFromMetadataFile(absoluteSpecPath, includeOptional).forEach((dependency) => requiredModules.add(dependency))\n const specFileName = path.basename(normalizedSpecPath, '.spec.ts')\n const perTestMetadataPath = path.join(path.dirname(absoluteSpecPath), `${specFileName}.meta.ts`)\n readDependenciesFromMetadataFile(perTestMetadataPath, includeOptional).forEach((dependency) => requiredModules.add(dependency))\n\n return Array.from(requiredModules)\n}\n\nfunction resolveRequiredEnvVarsForSpec(projectRoot: string, relativeSpecPath: string): string[] {\n const requiredEnvVars = new Set<string>()\n const normalizedSpecPath = normalizePath(relativeSpecPath)\n const absoluteSpecPath = path.join(projectRoot, normalizedSpecPath)\n const integrationRoot = resolveIntegrationRootDirectory(normalizedSpecPath)\n\n if (integrationRoot) {\n const relativeDirectory = normalizePath(path.dirname(normalizedSpecPath))\n const integrationRootAbsolute = path.join(projectRoot, integrationRoot)\n const directoryAbsolute = path.join(projectRoot, relativeDirectory)\n const relativeFromIntegrationRoot = normalizePath(path.relative(integrationRootAbsolute, directoryAbsolute))\n const pathSegments = relativeFromIntegrationRoot === '.'\n ? []\n : relativeFromIntegrationRoot.split('/').filter(Boolean)\n\n let currentDirectory = integrationRootAbsolute\n const traversal = [currentDirectory, ...pathSegments.map((segment) => {\n currentDirectory = path.join(currentDirectory, segment)\n return currentDirectory\n })]\n\n for (const directoryPath of traversal) {\n for (const metadataFileName of INTEGRATION_META_FILE_NAMES) {\n const metadataPath = path.join(directoryPath, metadataFileName)\n readRequiredEnvVarsFromMetadataFile(metadataPath).forEach((envVar) => requiredEnvVars.add(envVar))\n }\n }\n }\n\n readRequiredEnvVarsFromMetadataFile(absoluteSpecPath).forEach((envVar) => requiredEnvVars.add(envVar))\n const specFileName = path.basename(normalizedSpecPath, '.spec.ts')\n const perTestMetadataPath = path.join(path.dirname(absoluteSpecPath), `${specFileName}.meta.ts`)\n readRequiredEnvVarsFromMetadataFile(perTestMetadataPath).forEach((envVar) => requiredEnvVars.add(envVar))\n\n return Array.from(requiredEnvVars)\n}\n\nfunction resolveRequiredAnyEnvVarsForSpec(projectRoot: string, relativeSpecPath: string): string[] {\n const requiredAnyEnvVars = new Set<string>()\n const normalizedSpecPath = normalizePath(relativeSpecPath)\n const absoluteSpecPath = path.join(projectRoot, normalizedSpecPath)\n const integrationRoot = resolveIntegrationRootDirectory(normalizedSpecPath)\n\n if (integrationRoot) {\n const relativeDirectory = normalizePath(path.dirname(normalizedSpecPath))\n const integrationRootAbsolute = path.join(projectRoot, integrationRoot)\n const directoryAbsolute = path.join(projectRoot, relativeDirectory)\n const relativeFromIntegrationRoot = normalizePath(path.relative(integrationRootAbsolute, directoryAbsolute))\n const pathSegments = relativeFromIntegrationRoot === '.'\n ? []\n : relativeFromIntegrationRoot.split('/').filter(Boolean)\n\n let currentDirectory = integrationRootAbsolute\n const traversal = [currentDirectory, ...pathSegments.map((segment) => {\n currentDirectory = path.join(currentDirectory, segment)\n return currentDirectory\n })]\n\n for (const directoryPath of traversal) {\n for (const metadataFileName of INTEGRATION_META_FILE_NAMES) {\n const metadataPath = path.join(directoryPath, metadataFileName)\n readRequiredAnyEnvVarsFromMetadataFile(metadataPath).forEach((envVar) => requiredAnyEnvVars.add(envVar))\n }\n }\n }\n\n readRequiredAnyEnvVarsFromMetadataFile(absoluteSpecPath).forEach((envVar) => requiredAnyEnvVars.add(envVar))\n const specFileName = path.basename(normalizedSpecPath, '.spec.ts')\n const perTestMetadataPath = path.join(path.dirname(absoluteSpecPath), `${specFileName}.meta.ts`)\n readRequiredAnyEnvVarsFromMetadataFile(perTestMetadataPath).forEach((envVar) => requiredAnyEnvVars.add(envVar))\n\n return Array.from(requiredAnyEnvVars)\n}\n\nfunction isEnvironmentVariableConfigured(name: string): boolean {\n const value = process.env[name]\n return typeof value === 'string' && value.trim().length > 0\n}\n\nexport function discoverIntegrationSpecFiles(projectRoot: string, legacyIntegrationRoot: string): IntegrationSpecDiscoveryItem[] {\n const discoveredByPath = new Map<string, IntegrationSpecDiscoveryItem>()\n const overlayRoot = resolveOverlayRootPath()\n const enterpriseEnabled = isEnterpriseModulesEnabled()\n const appOnly = isAppOnlyDiscoveryEnabled()\n const discoveryRoots = [\n path.join(projectRoot, 'src', 'modules'),\n path.join(projectRoot, 'apps'),\n path.join(projectRoot, 'packages'),\n ...(appOnly ? [] : [path.join(projectRoot, 'node_modules', '@open-mercato')]),\n ]\n\n for (const specFile of collectSpecFilesFromDirectory(legacyIntegrationRoot)) {\n const relativePath = normalizePath(path.relative(projectRoot, specFile))\n discoveredByPath.set(relativePath, {\n path: relativePath,\n moduleName: extractModuleNameFromIntegrationPath(relativePath),\n isOverlay: isOverlayIntegrationPath(relativePath, overlayRoot),\n requiredModules: resolveModuleDependenciesForSpec(projectRoot, relativePath),\n requiredEnvVars: resolveRequiredEnvVarsForSpec(projectRoot, relativePath),\n requiredAnyEnvVars: resolveRequiredAnyEnvVarsForSpec(projectRoot, relativePath),\n })\n }\n\n for (const root of discoveryRoots) {\n for (const integrationDirectory of collectNamedDirectories(root, MODULE_INTEGRATION_DIRECTORY_NAME)) {\n for (const specFile of collectSpecFilesFromDirectory(integrationDirectory)) {\n const relativePath = normalizePath(path.relative(projectRoot, specFile))\n discoveredByPath.set(relativePath, {\n path: relativePath,\n moduleName: extractModuleNameFromIntegrationPath(relativePath),\n isOverlay: isOverlayIntegrationPath(relativePath, overlayRoot),\n requiredModules: resolveModuleDependenciesForSpec(projectRoot, relativePath),\n requiredEnvVars: resolveRequiredEnvVarsForSpec(projectRoot, relativePath),\n requiredAnyEnvVars: resolveRequiredAnyEnvVarsForSpec(projectRoot, relativePath),\n })\n }\n }\n }\n\n const discovered = Array.from(discoveredByPath.values())\n .filter((file) => !appOnly || isAppOwnedIntegrationSpecPath(file.path))\n if (isMetadataFilteringDisabled()) {\n const selected = discovered.sort((left, right) => left.path.localeCompare(right.path))\n writeDiscoverySelectionReport(projectRoot, selected)\n return selected\n }\n const enabledModules = resolveEnabledModuleIds(projectRoot)\n const testAppRoot = resolveTestAppRoot()\n const testAppModules = testAppRoot ? resolvePossiblyEnabledTestAppModuleIds(testAppRoot) : null\n const enabledModuleNames = new Set<string>()\n for (const file of discovered) {\n if (!file.isOverlay && file.moduleName) {\n enabledModuleNames.add(file.moduleName)\n }\n }\n\n const selected = discovered\n .filter((file) => {\n if (file.requiredModules.some((moduleId) => !enabledModules.has(normalizeModuleId(moduleId)))) {\n return false\n }\n if (testAppModules && !file.isOverlay) {\n const owningModuleId = resolveOwningModuleId(projectRoot, file.path)\n if (owningModuleId && !testAppModules.has(owningModuleId)) {\n return false\n }\n }\n if (file.requiredEnvVars.some((envVar) => !isEnvironmentVariableConfigured(envVar))) {\n return false\n }\n if (\n file.requiredAnyEnvVars.length > 0 &&\n !file.requiredAnyEnvVars.some((envVar) => isEnvironmentVariableConfigured(envVar))\n ) {\n return false\n }\n if (!file.isOverlay) {\n return true\n }\n if (!enterpriseEnabled) {\n return false\n }\n if (!file.moduleName) {\n return true\n }\n if (enabledModuleNames.has(file.moduleName)) {\n return true\n }\n return enabledModules.has(normalizeModuleId(file.moduleName))\n })\n .sort((left, right) => left.path.localeCompare(right.path))\n writeDiscoverySelectionReport(projectRoot, selected)\n return selected\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,YAAY,cAAc,aAAa,qBAAqB;AACrE,OAAO,UAAU;AACjB,OAAO,QAAQ;AAWf,MAAM,oCAAoC;AAC1C,MAAM,yBAAyB,oBAAI,IAAI;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AACD,MAAM,8BAA8B,CAAC,WAAW,UAAU;AAC1D,MAAM,mCAAmC,CAAC,oBAAoB,mBAAmB,iBAAiB;AAClG,MAAM,uCAAuC,CAAC,GAAG,kCAAkC,iBAAiB;AACpG,MAAM,qCAAqC,CAAC,mBAAmB,iBAAiB;AAChF,MAAM,yCAAyC,CAAC,sBAAsB,oBAAoB;AAC1F,MAAM,uBAAuB;AACtB,MAAM,+BAA+B;AACrC,MAAM,4CAA4C;AAClD,MAAM,iDAAiD;AAEvD,SAAS,cAAc,UAA0B;AACtD,SAAO,SAAS,MAAM,KAAK,GAAG,EAAE,KAAK,GAAG;AAC1C;AAE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AAA,IACxC;AAAA,EACF;AAEA,QAAM,WAAW,WACd,OAAO,CAAC,SAAS;AAChB,QAAI,KAAK,gBAAgB,KAAK,CAAC,aAAa,CAAC,eAAe,IAAI,kBAAkB,QAAQ,CAAC,CAAC,GAAG;AAC7F,aAAO;AAAA,IACT;AACA,QAAI,kBAAkB,CAAC,KAAK,WAAW;AACrC,YAAM,iBAAiB,sBAAsB,aAAa,KAAK,IAAI;AACnE,UAAI,kBAAkB,CAAC,eAAe,IAAI,cAAc,GAAG;AACzD,eAAO;AAAA,MACT;AAAA,IACF;AACA,QAAI,KAAK,gBAAgB,KAAK,CAAC,WAAW,CAAC,gCAAgC,MAAM,CAAC,GAAG;AACnF,aAAO;AAAA,IACT;AACA,QACE,KAAK,mBAAmB,SAAS,KACjC,CAAC,KAAK,mBAAmB,KAAK,CAAC,WAAW,gCAAgC,MAAM,CAAC,GACjF;AACA,aAAO;AAAA,IACT;AACA,QAAI,CAAC,KAAK,WAAW;AACnB,aAAO;AAAA,IACT;AACA,QAAI,CAAC,mBAAmB;AACtB,aAAO;AAAA,IACT;AACA,QAAI,CAAC,KAAK,YAAY;AACpB,aAAO;AAAA,IACT;AACA,QAAI,mBAAmB,IAAI,KAAK,UAAU,GAAG;AAC3C,aAAO;AAAA,IACT;AACA,WAAO,eAAe,IAAI,kBAAkB,KAAK,UAAU,CAAC;AAAA,EAC9D,CAAC,EACA,KAAK,CAAC,MAAM,UAAU,KAAK,KAAK,cAAc,MAAM,IAAI,CAAC;AAC5D,gCAA8B,aAAa,QAAQ;AACnD,SAAO;AACT;",
|
|
6
6
|
"names": ["selected"]
|
|
7
7
|
}
|
|
@@ -10,6 +10,7 @@ import { stdin as input, stdout as output } from "node:process";
|
|
|
10
10
|
import spawn from "cross-spawn";
|
|
11
11
|
import { fetchWithTimeout } from "@open-mercato/shared/lib/http/fetchWithTimeout";
|
|
12
12
|
import { isUnsafeJwtSecret } from "@open-mercato/shared/lib/auth/jwt";
|
|
13
|
+
import { parseBooleanToken, parseBooleanWithDefault } from "@open-mercato/shared/lib/boolean";
|
|
13
14
|
import { resolveEnvironment } from "../resolver.js";
|
|
14
15
|
import { resolveInitSuperadminCredentials } from "../init-secrets.js";
|
|
15
16
|
import { resolveSpawnCommand } from "../spawn.js";
|
|
@@ -54,6 +55,7 @@ const EPHEMERAL_ENV_LOCK_POLL_MS = 500;
|
|
|
54
55
|
const DEFAULT_BUILD_CACHE_TTL_SECONDS = 600;
|
|
55
56
|
const APP_READY_TIMEOUT_ENV_VAR = "OM_INTEGRATION_APP_READY_TIMEOUT_SECONDS";
|
|
56
57
|
const BUILD_CACHE_TTL_ENV_VAR = "OM_INTEGRATION_BUILD_CACHE_TTL_SECONDS";
|
|
58
|
+
const PREBUILT_ARTIFACTS_ENV_VAR = "OM_INTEGRATION_PREBUILT_ARTIFACTS";
|
|
57
59
|
const EPHEMERAL_POSTGRES_IMAGE_ENV_VAR = "OM_INTEGRATION_POSTGRES_IMAGE";
|
|
58
60
|
const DEFAULT_EPHEMERAL_POSTGRES_IMAGE = "pgvector/pgvector:pg16";
|
|
59
61
|
const EPHEMERAL_POSTGRES_INIT_SQL = `CREATE EXTENSION IF NOT EXISTS vector;
|
|
@@ -69,6 +71,15 @@ function resolveEphemeralPostgresImage(env2 = process.env) {
|
|
|
69
71
|
function ephemeralPostgresInitSql() {
|
|
70
72
|
return EPHEMERAL_POSTGRES_INIT_SQL;
|
|
71
73
|
}
|
|
74
|
+
function buildEphemeralInitializationEnvironment(environment) {
|
|
75
|
+
return {
|
|
76
|
+
...environment,
|
|
77
|
+
OM_PASSWORD_MIN_LENGTH: "6",
|
|
78
|
+
OM_PASSWORD_REQUIRE_DIGIT: "false",
|
|
79
|
+
OM_PASSWORD_REQUIRE_UPPERCASE: "false",
|
|
80
|
+
OM_PASSWORD_REQUIRE_SPECIAL: "false"
|
|
81
|
+
};
|
|
82
|
+
}
|
|
72
83
|
const DEFAULT_EPHEMERAL_JWT_SECRET = "om-ephemeral-integration-jwt-secret";
|
|
73
84
|
function resolveEphemeralJwtSecret(env2 = process.env) {
|
|
74
85
|
const inherited = env2.JWT_SECRET;
|
|
@@ -228,12 +239,17 @@ const FOLDER_TO_CATEGORY_CODE = {
|
|
|
228
239
|
const BACKEND_BROWSER_AUTH_REDIRECT_LIMIT = 6;
|
|
229
240
|
const AUTHENTICATED_API_PROBE_PATH = "/api/auth/profile";
|
|
230
241
|
const BUILD_CACHE_STATE_VERSION = 2;
|
|
231
|
-
const
|
|
232
|
-
"NODE_ENV",
|
|
242
|
+
const BUILD_SHAPING_ENV_KEYS = [
|
|
233
243
|
"OM_ENABLE_ENTERPRISE_MODULES",
|
|
234
244
|
"OM_ENABLE_ENTERPRISE_MODULES_SSO",
|
|
235
|
-
"OM_ENABLE_ENTERPRISE_MODULES_SECURITY"
|
|
245
|
+
"OM_ENABLE_ENTERPRISE_MODULES_SECURITY",
|
|
246
|
+
"OM_ENABLE_ENTERPRISE_MODULES_AGENTS",
|
|
247
|
+
"OM_ENABLE_ENTERPRISE_MODULES_BACKUPS",
|
|
248
|
+
"OM_ENABLE_STORAGE_S3",
|
|
249
|
+
"OM_INTEGRATION_TEST",
|
|
250
|
+
"SELF_SERVICE_ONBOARDING_ENABLED"
|
|
236
251
|
];
|
|
252
|
+
const BUILD_CACHE_ENV_KEYS = ["NODE_ENV", ...BUILD_SHAPING_ENV_KEYS];
|
|
237
253
|
const IGNORED_EPHEMERAL_BUILD_CACHE_DIRS = /* @__PURE__ */ new Set([
|
|
238
254
|
"node_modules",
|
|
239
255
|
".next",
|
|
@@ -887,6 +903,232 @@ async function shouldReuseBuildArtifacts(ttlSeconds, logPrefix, options = {}) {
|
|
|
887
903
|
async function shouldRebuildBuildArtifacts(ttlSeconds, logPrefix, options = {}) {
|
|
888
904
|
return !await shouldReuseBuildArtifacts(ttlSeconds, logPrefix, options);
|
|
889
905
|
}
|
|
906
|
+
const PREBUILT_BUILD_ENV_RECORD_FILE = "om-integration-build-env.json";
|
|
907
|
+
const PREBUILT_BUILD_ENV_RECORD_VERSION = 2;
|
|
908
|
+
const PREBUILT_RUNTIME_ONLY_PUBLIC_KEYS = /* @__PURE__ */ new Set(["NEXT_PUBLIC_APP_URL"]);
|
|
909
|
+
const PREBUILT_CHANGED_FILES_PREVIEW_LIMIT = 10;
|
|
910
|
+
function resolvePrebuiltArtifactsMode(env2 = process.env) {
|
|
911
|
+
return parseBooleanWithDefault(env2[PREBUILT_ARTIFACTS_ENV_VAR], false);
|
|
912
|
+
}
|
|
913
|
+
function resolvePrebuiltArtifactRequirements() {
|
|
914
|
+
const requirements = [
|
|
915
|
+
{
|
|
916
|
+
label: "Next.js build output (BUILD_ID)",
|
|
917
|
+
anyOf: NEXT_BUILD_OUTPUT_DIRECTORIES.map((directory) => path.join(directory, "BUILD_ID"))
|
|
918
|
+
},
|
|
919
|
+
{
|
|
920
|
+
label: "generated module registry",
|
|
921
|
+
anyOf: [path.join(appDirectory, ".mercato", "generated", "modules.generated.ts")]
|
|
922
|
+
}
|
|
923
|
+
];
|
|
924
|
+
if (PROJECT_SUPPORTS_PACKAGE_BUILDS) {
|
|
925
|
+
requirements.push(
|
|
926
|
+
{ label: "core package dist", anyOf: [path.join(corePackageRootDirectory, "dist", "index.js")] },
|
|
927
|
+
{ label: "ui package dist", anyOf: [path.join(uiPackageRootDirectory, "dist", "index.js")] }
|
|
928
|
+
);
|
|
929
|
+
}
|
|
930
|
+
return requirements;
|
|
931
|
+
}
|
|
932
|
+
async function findMissingPrebuiltArtifacts(requirements) {
|
|
933
|
+
const missing = [];
|
|
934
|
+
for (const requirement of requirements) {
|
|
935
|
+
let found = false;
|
|
936
|
+
for (const candidate of requirement.anyOf) {
|
|
937
|
+
if (!await isBuildArtifactMissing(candidate)) {
|
|
938
|
+
found = true;
|
|
939
|
+
break;
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
if (!found) missing.push(requirement);
|
|
943
|
+
}
|
|
944
|
+
return missing;
|
|
945
|
+
}
|
|
946
|
+
function isBuildShapingEnvKey(key) {
|
|
947
|
+
return BUILD_SHAPING_ENV_KEYS.includes(key) || key.startsWith("NEXT_PUBLIC_");
|
|
948
|
+
}
|
|
949
|
+
function isComparedBuildShapingEnvKey(key) {
|
|
950
|
+
return isBuildShapingEnvKey(key) && !PREBUILT_RUNTIME_ONLY_PUBLIC_KEYS.has(key);
|
|
951
|
+
}
|
|
952
|
+
function pickBuildShapingEnvironment(environment) {
|
|
953
|
+
const picked = {};
|
|
954
|
+
for (const key of Object.keys(environment).sort((left, right) => left.localeCompare(right))) {
|
|
955
|
+
const value = environment[key];
|
|
956
|
+
if (value !== void 0 && isBuildShapingEnvKey(key)) picked[key] = value;
|
|
957
|
+
}
|
|
958
|
+
return picked;
|
|
959
|
+
}
|
|
960
|
+
function findPrebuiltBuildEnvironmentMismatches(builtEnvironment, runtimeEnvironment) {
|
|
961
|
+
const publicKeys = [...Object.keys(builtEnvironment), ...Object.keys(runtimeEnvironment)].filter((key) => key.startsWith("NEXT_PUBLIC_") && isComparedBuildShapingEnvKey(key));
|
|
962
|
+
const keys = Array.from(/* @__PURE__ */ new Set([...BUILD_SHAPING_ENV_KEYS, ...publicKeys])).sort((left, right) => left.localeCompare(right));
|
|
963
|
+
return keys.filter((key) => normalizePrebuiltEnvValue(key, builtEnvironment[key]) !== normalizePrebuiltEnvValue(key, runtimeEnvironment[key]));
|
|
964
|
+
}
|
|
965
|
+
function normalizePrebuiltEnvValue(key, raw) {
|
|
966
|
+
if (key.startsWith("NEXT_PUBLIC_") || key === "SELF_SERVICE_ONBOARDING_ENABLED") return raw;
|
|
967
|
+
const trimmed = raw?.trim() ?? "";
|
|
968
|
+
if (!trimmed) return "false";
|
|
969
|
+
const parsed = parseBooleanToken(trimmed);
|
|
970
|
+
return parsed === null ? trimmed : String(parsed);
|
|
971
|
+
}
|
|
972
|
+
function resolvePrebuiltSourceRevision(cwd = projectRootDirectory) {
|
|
973
|
+
const head = spawnSync("git", ["rev-parse", "HEAD"], { cwd, encoding: "utf8" });
|
|
974
|
+
const commit = head.status === 0 ? head.stdout.trim() : "";
|
|
975
|
+
if (!commit) return null;
|
|
976
|
+
const diff = spawnSync("git", ["diff", "HEAD", "--name-only", "-z", "--no-ext-diff"], { cwd, encoding: "utf8" });
|
|
977
|
+
if (diff.status !== 0) return null;
|
|
978
|
+
const changedFiles = diff.stdout.split("\0").filter((file) => file.length > 0).sort((left, right) => left.localeCompare(right));
|
|
979
|
+
return { commit, changedFiles };
|
|
980
|
+
}
|
|
981
|
+
function describeChangedFiles(changedFiles) {
|
|
982
|
+
const preview = changedFiles.slice(0, PREBUILT_CHANGED_FILES_PREVIEW_LIMIT).join(", ");
|
|
983
|
+
const remaining = changedFiles.length - PREBUILT_CHANGED_FILES_PREVIEW_LIMIT;
|
|
984
|
+
return remaining > 0 ? `${preview} and ${remaining} more` : preview;
|
|
985
|
+
}
|
|
986
|
+
async function findNextBuildOutputDirectory(directories) {
|
|
987
|
+
for (const directory of directories) {
|
|
988
|
+
if (!await isBuildArtifactMissing(path.join(directory, "BUILD_ID"))) return directory;
|
|
989
|
+
}
|
|
990
|
+
return null;
|
|
991
|
+
}
|
|
992
|
+
async function writePrebuiltBuildEnvironmentRecord(options = {}) {
|
|
993
|
+
const directories = options.buildOutputDirectories ?? NEXT_BUILD_OUTPUT_DIRECTORIES;
|
|
994
|
+
const directory = await findNextBuildOutputDirectory(directories);
|
|
995
|
+
if (!directory) {
|
|
996
|
+
throw new Error(
|
|
997
|
+
`[internal] No Next.js build output (BUILD_ID) found in ${directories.join(" or ")}. Build the app first (yarn build:app), then record its environment.`
|
|
998
|
+
);
|
|
999
|
+
}
|
|
1000
|
+
const source = (options.resolveSourceRevision ?? (() => resolvePrebuiltSourceRevision()))();
|
|
1001
|
+
if (!source) {
|
|
1002
|
+
throw new Error(
|
|
1003
|
+
"[internal] Cannot determine the source revision of the build (git rev-parse HEAD / git diff HEAD failed). Record the build environment from inside the git checkout the app was built from."
|
|
1004
|
+
);
|
|
1005
|
+
}
|
|
1006
|
+
if (source.changedFiles.length > 0) {
|
|
1007
|
+
throw new Error(
|
|
1008
|
+
`[internal] Cannot record a build made from uncommitted changes (${describeChangedFiles(source.changedFiles)}): the prebuilt app could not be matched to a commit. Commit or stash them, rebuild, then record.`
|
|
1009
|
+
);
|
|
1010
|
+
}
|
|
1011
|
+
const environment = pickBuildShapingEnvironment(options.environment ?? process.env);
|
|
1012
|
+
const recordPath = path.join(directory, PREBUILT_BUILD_ENV_RECORD_FILE);
|
|
1013
|
+
const contents = { version: PREBUILT_BUILD_ENV_RECORD_VERSION, environment, source: { commit: source.commit } };
|
|
1014
|
+
await writeFile(recordPath, `${JSON.stringify(contents, null, 2)}
|
|
1015
|
+
`, "utf8");
|
|
1016
|
+
return { recordPath, environment, source: { commit: source.commit } };
|
|
1017
|
+
}
|
|
1018
|
+
function parsePrebuiltBuildEnvironmentRecord(raw, recordPath) {
|
|
1019
|
+
const invalid = new Error(`[internal] ${recordPath} is not a valid build environment record. Record it again after the app build.`);
|
|
1020
|
+
let parsed;
|
|
1021
|
+
try {
|
|
1022
|
+
parsed = JSON.parse(raw);
|
|
1023
|
+
} catch {
|
|
1024
|
+
throw invalid;
|
|
1025
|
+
}
|
|
1026
|
+
if (!parsed || typeof parsed !== "object") throw invalid;
|
|
1027
|
+
const { version, environment, source } = parsed;
|
|
1028
|
+
if (version !== PREBUILT_BUILD_ENV_RECORD_VERSION || !environment || typeof environment !== "object") throw invalid;
|
|
1029
|
+
const entries = Object.entries(environment);
|
|
1030
|
+
if (entries.some(([, value]) => typeof value !== "string")) throw invalid;
|
|
1031
|
+
if (!source || typeof source !== "object") throw invalid;
|
|
1032
|
+
const { commit } = source;
|
|
1033
|
+
if (typeof commit !== "string" || !commit) throw invalid;
|
|
1034
|
+
return {
|
|
1035
|
+
environment: Object.fromEntries(entries),
|
|
1036
|
+
source: { commit }
|
|
1037
|
+
};
|
|
1038
|
+
}
|
|
1039
|
+
async function readPrebuiltBuildEnvironmentRecord(buildOutputDirectories = NEXT_BUILD_OUTPUT_DIRECTORIES) {
|
|
1040
|
+
const directory = await findNextBuildOutputDirectory(buildOutputDirectories);
|
|
1041
|
+
if (!directory) return null;
|
|
1042
|
+
const recordPath = path.join(directory, PREBUILT_BUILD_ENV_RECORD_FILE);
|
|
1043
|
+
let raw;
|
|
1044
|
+
try {
|
|
1045
|
+
raw = await readFile(recordPath, "utf8");
|
|
1046
|
+
} catch (error) {
|
|
1047
|
+
if (error.code === "ENOENT") return null;
|
|
1048
|
+
throw error;
|
|
1049
|
+
}
|
|
1050
|
+
return { recordPath, ...parsePrebuiltBuildEnvironmentRecord(raw, recordPath) };
|
|
1051
|
+
}
|
|
1052
|
+
async function assertPrebuiltArtifactsUsable(options) {
|
|
1053
|
+
const missing = await findMissingPrebuiltArtifacts(options.requirements ?? resolvePrebuiltArtifactRequirements());
|
|
1054
|
+
if (missing.length > 0) {
|
|
1055
|
+
const details = missing.map((requirement) => `${requirement.label} (${requirement.anyOf.join(" or ")})`).join("; ");
|
|
1056
|
+
throw new Error(
|
|
1057
|
+
`[internal] ${PREBUILT_ARTIFACTS_ENV_VAR} is set but prebuilt artifacts are missing: ${details}. Build them first (yarn build:packages && yarn generate && yarn build:packages && yarn build:app && yarn mercato test record-build-env) or unset ${PREBUILT_ARTIFACTS_ENV_VAR}.`
|
|
1058
|
+
);
|
|
1059
|
+
}
|
|
1060
|
+
const record = await readPrebuiltBuildEnvironmentRecord(options.buildOutputDirectories);
|
|
1061
|
+
if (!record) {
|
|
1062
|
+
throw new Error(
|
|
1063
|
+
`[internal] ${PREBUILT_ARTIFACTS_ENV_VAR} is set but the prebuilt app has no ${PREBUILT_BUILD_ENV_RECORD_FILE} next to its BUILD_ID. Run "yarn mercato test record-build-env" right after the app build, with the same environment, or unset ${PREBUILT_ARTIFACTS_ENV_VAR}.`
|
|
1064
|
+
);
|
|
1065
|
+
}
|
|
1066
|
+
const currentSource = (options.resolveSourceRevision ?? (() => resolvePrebuiltSourceRevision()))();
|
|
1067
|
+
if (!currentSource) {
|
|
1068
|
+
throw new Error(
|
|
1069
|
+
`[internal] ${PREBUILT_ARTIFACTS_ENV_VAR} is set but the current source revision cannot be determined (git rev-parse HEAD / git diff HEAD failed), so the prebuilt app cannot be matched to it. Run from the git checkout or unset ${PREBUILT_ARTIFACTS_ENV_VAR}.`
|
|
1070
|
+
);
|
|
1071
|
+
}
|
|
1072
|
+
if (currentSource.commit !== record.source.commit) {
|
|
1073
|
+
throw new Error(
|
|
1074
|
+
`[internal] ${PREBUILT_ARTIFACTS_ENV_VAR} is set but the prebuilt app was built from commit ${record.source.commit} and the checkout is at ${currentSource.commit}. Rebuild the artifacts from the current checkout or unset ${PREBUILT_ARTIFACTS_ENV_VAR}.`
|
|
1075
|
+
);
|
|
1076
|
+
}
|
|
1077
|
+
if (currentSource.changedFiles.length > 0) {
|
|
1078
|
+
console.warn(
|
|
1079
|
+
`[integration] ${PREBUILT_ARTIFACTS_ENV_VAR}: the checkout has uncommitted changes the prebuilt app does not include: ${describeChangedFiles(currentSource.changedFiles)}.`
|
|
1080
|
+
);
|
|
1081
|
+
}
|
|
1082
|
+
const bakedAppUrl = Array.from(PREBUILT_RUNTIME_ONLY_PUBLIC_KEYS).filter((key) => (record.environment[key] ?? "").length > 0);
|
|
1083
|
+
if (bakedAppUrl.length > 0) {
|
|
1084
|
+
const details = bakedAppUrl.map((key) => `${key} (built "${record.environment[key]}")`).join("; ");
|
|
1085
|
+
throw new Error(
|
|
1086
|
+
`[internal] ${PREBUILT_ARTIFACTS_ENV_VAR} is set but the prebuilt app inlined a fixed app URL: ${details}. The runner serves the app on a per-run port, so rebuild with it unset or unset ${PREBUILT_ARTIFACTS_ENV_VAR}.`
|
|
1087
|
+
);
|
|
1088
|
+
}
|
|
1089
|
+
const mismatches = findPrebuiltBuildEnvironmentMismatches(record.environment, options.runtimeEnvironment);
|
|
1090
|
+
if (mismatches.length > 0) {
|
|
1091
|
+
const details = mismatches.map((key) => `${key} (built "${record.environment[key] ?? ""}", runner "${options.runtimeEnvironment[key] ?? ""}")`).join("; ");
|
|
1092
|
+
throw new Error(
|
|
1093
|
+
`[internal] ${PREBUILT_ARTIFACTS_ENV_VAR} is set but the prebuilt app was built with different build-shaping environment than the integration runner uses: ${details}. Rebuild the artifacts with the runner values or unset ${PREBUILT_ARTIFACTS_ENV_VAR}.`
|
|
1094
|
+
);
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
async function resolveEphemeralBuildDecision(options, dependencies = {}) {
|
|
1098
|
+
if (options.prebuiltArtifactsRequested && options.forceRebuild) {
|
|
1099
|
+
console.log(`[${options.logPrefix}] --force-rebuild overrides ${PREBUILT_ARTIFACTS_ENV_VAR}.`);
|
|
1100
|
+
}
|
|
1101
|
+
if (options.prebuiltArtifactsRequested && !options.forceRebuild) {
|
|
1102
|
+
await (dependencies.assertPrebuiltArtifactsUsable ?? assertPrebuiltArtifactsUsable)({
|
|
1103
|
+
runtimeEnvironment: options.buildToolEnvironment
|
|
1104
|
+
});
|
|
1105
|
+
return { mode: "prebuilt", sourceFingerprint: null, shouldPersistBuildCache: false };
|
|
1106
|
+
}
|
|
1107
|
+
try {
|
|
1108
|
+
const sourceFingerprint = await (dependencies.buildSourceFingerprint ?? (() => buildSourceFingerprint()))();
|
|
1109
|
+
const needsBuild = options.forceRebuild ? true : await (dependencies.shouldRebuildBuildArtifacts ?? shouldRebuildBuildArtifacts)(
|
|
1110
|
+
options.buildCacheTtlSeconds,
|
|
1111
|
+
options.logPrefix,
|
|
1112
|
+
{
|
|
1113
|
+
environmentFingerprint: options.environmentFingerprint,
|
|
1114
|
+
precomputedSourceFingerprint: sourceFingerprint ?? void 0
|
|
1115
|
+
}
|
|
1116
|
+
);
|
|
1117
|
+
return { mode: needsBuild ? "rebuild" : "cached", sourceFingerprint, shouldPersistBuildCache: true };
|
|
1118
|
+
} catch (error) {
|
|
1119
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1120
|
+
console.warn(`[${options.logPrefix}] Build cache check failed (${message}). Rebuilding with cache bypass.`);
|
|
1121
|
+
return { mode: "rebuild", sourceFingerprint: null, shouldPersistBuildCache: false };
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
async function runRecordPrebuiltBuildEnvironment(args = []) {
|
|
1125
|
+
if (args.length > 0) {
|
|
1126
|
+
throw new Error(`[internal] record-build-env takes no arguments (received: ${args.join(" ")}).`);
|
|
1127
|
+
}
|
|
1128
|
+
const { recordPath, environment, source } = await writePrebuiltBuildEnvironmentRecord();
|
|
1129
|
+
const keys = Object.keys(environment);
|
|
1130
|
+
console.log(`[integration] Recorded the build environment in ${recordPath} (${keys.length > 0 ? keys.join(", ") : "no build-shaping values set"}; source ${source.commit}).`);
|
|
1131
|
+
}
|
|
890
1132
|
async function getFreePort() {
|
|
891
1133
|
const tryListen = (host) => new Promise((resolve, reject) => {
|
|
892
1134
|
const server = createServer();
|
|
@@ -1681,6 +1923,8 @@ function buildReusableEnvironment(baseUrl, databaseUrl, queueBaseDir, captureScr
|
|
|
1681
1923
|
// adapters run end-to-end. Unlike `push_stub` (which replaces the whole adapter),
|
|
1682
1924
|
// this replaces only each SDK client. Mirrors the fresh-environment env below.
|
|
1683
1925
|
OM_PUSH_FAKE_PROVIDERS: process.env.OM_PUSH_FAKE_PROVIDERS ?? "1",
|
|
1926
|
+
// Network-free Shopify Admin API fake for sync_shopify import integration tests.
|
|
1927
|
+
OM_SYNC_SHOPIFY_FAKE_API: process.env.OM_SYNC_SHOPIFY_FAKE_API ?? "1",
|
|
1684
1928
|
// Expo's receipt reaper ignores rows younger than 15 minutes by default, which no
|
|
1685
1929
|
// integration test can wait out. Poll immediately instead.
|
|
1686
1930
|
OM_PUSH_RECEIPT_MIN_AGE_MINUTES: process.env.OM_PUSH_RECEIPT_MIN_AGE_MINUTES ?? "0",
|
|
@@ -3081,6 +3325,8 @@ async function startEphemeralEnvironment(options) {
|
|
|
3081
3325
|
// registered only under this flag. Applies to the app server, the Playwright process, and any
|
|
3082
3326
|
// drain/worker child that inherits this environment.
|
|
3083
3327
|
OM_PUSH_FAKE_PROVIDERS: process.env.OM_PUSH_FAKE_PROVIDERS ?? "1",
|
|
3328
|
+
// Network-free Shopify Admin API fake for sync_shopify import integration tests.
|
|
3329
|
+
OM_SYNC_SHOPIFY_FAKE_API: process.env.OM_SYNC_SHOPIFY_FAKE_API ?? "1",
|
|
3084
3330
|
// Expo's receipt reaper ignores rows younger than 15 minutes by default (it polls a real
|
|
3085
3331
|
// provider's async receipts). No integration test can wait that out — poll immediately.
|
|
3086
3332
|
OM_PUSH_RECEIPT_MIN_AGE_MINUTES: process.env.OM_PUSH_RECEIPT_MIN_AGE_MINUTES ?? "0",
|
|
@@ -3103,6 +3349,12 @@ async function startEphemeralEnvironment(options) {
|
|
|
3103
3349
|
// var at the workflow level, masking the gap). Keep in sync with the
|
|
3104
3350
|
// Playwright-process env block above.
|
|
3105
3351
|
MOCK_INBOUND_WEBHOOK_SECRET: "open-mercato-mock-dev-inbound-webhook-secret",
|
|
3352
|
+
// The communication_channels hub fails closed under NODE_ENV=production
|
|
3353
|
+
// instead of deriving the OAuth state-cookie key from JWT_SECRET
|
|
3354
|
+
// (lib/oauth-state.ts), so without a dedicated key every provider's
|
|
3355
|
+
// happy-path `/oauth/<provider>/initiate` 500s in this runtime. Test-only
|
|
3356
|
+
// value; real deployments set OM_HUB_OAUTH_STATE_KEY or KMS_MASTER_KEY.
|
|
3357
|
+
OM_HUB_OAUTH_STATE_KEY: process.env.OM_HUB_OAUTH_STATE_KEY ?? "om-ephemeral-integration-oauth-state-key",
|
|
3106
3358
|
NEXT_PUBLIC_UMES_DEVTOOLS: "true",
|
|
3107
3359
|
CI: "true",
|
|
3108
3360
|
TENANT_DATA_ENCRYPTION_FALLBACK_KEY: process.env.TENANT_DATA_ENCRYPTION_FALLBACK_KEY ?? "om-ephemeral-integration-fallback-key",
|
|
@@ -3185,30 +3437,24 @@ async function startEphemeralEnvironment(options) {
|
|
|
3185
3437
|
const buildCacheTtlSeconds = resolveBuildCacheTtlSeconds(options.logPrefix);
|
|
3186
3438
|
const environmentFingerprint = buildEnvironmentFingerprint(commandEnvironment);
|
|
3187
3439
|
const buildToolEnvironment = withoutCoverageEnvironment(commandEnvironment);
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
});
|
|
3197
|
-
} catch (error) {
|
|
3198
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
3199
|
-
shouldPersistBuildCache = false;
|
|
3200
|
-
needsBuild = true;
|
|
3201
|
-
sourceFingerprintValue = null;
|
|
3202
|
-
console.warn(
|
|
3203
|
-
`[${options.logPrefix}] Build cache check failed (${message}). Rebuilding with cache bypass.`
|
|
3204
|
-
);
|
|
3205
|
-
}
|
|
3440
|
+
const buildDecision = await resolveEphemeralBuildDecision({
|
|
3441
|
+
logPrefix: options.logPrefix,
|
|
3442
|
+
forceRebuild: options.forceRebuild === true,
|
|
3443
|
+
buildCacheTtlSeconds,
|
|
3444
|
+
environmentFingerprint,
|
|
3445
|
+
buildToolEnvironment,
|
|
3446
|
+
prebuiltArtifactsRequested: resolvePrebuiltArtifactsMode()
|
|
3447
|
+
});
|
|
3206
3448
|
console.log(`[${options.logPrefix}] Ephemeral database ready at ${databaseHost}:${databasePort}`);
|
|
3207
3449
|
console.log(`[${options.logPrefix}] Initializing application data (includes migrations)...`);
|
|
3208
|
-
await runTimedStep(options.logPrefix, "Initializing application data", { expectedSeconds: 45 }, async () => runYarnCommand(["initialize"], commandEnvironment, {
|
|
3450
|
+
await runTimedStep(options.logPrefix, "Initializing application data", { expectedSeconds: 45 }, async () => runYarnCommand(["initialize"], buildEphemeralInitializationEnvironment(commandEnvironment), {
|
|
3209
3451
|
silent: !options.verbose
|
|
3210
3452
|
}, appDirectory));
|
|
3211
|
-
if (
|
|
3453
|
+
if (buildDecision.mode === "prebuilt") {
|
|
3454
|
+
console.log(
|
|
3455
|
+
`[${options.logPrefix}] ${PREBUILT_ARTIFACTS_ENV_VAR} is set. Skipping build pipeline and using the prebuilt artifacts.`
|
|
3456
|
+
);
|
|
3457
|
+
} else if (buildDecision.mode === "cached") {
|
|
3212
3458
|
console.log(
|
|
3213
3459
|
`[${options.logPrefix}] Build cache valid (within ${BUILD_CACHE_TTL_ENV_VAR}=${buildCacheTtlSeconds}s). Skipping build pipeline.`
|
|
3214
3460
|
);
|
|
@@ -3245,8 +3491,8 @@ async function startEphemeralEnvironment(options) {
|
|
|
3245
3491
|
silent: !options.verbose
|
|
3246
3492
|
}, appDirectory));
|
|
3247
3493
|
}
|
|
3248
|
-
if (shouldPersistBuildCache &&
|
|
3249
|
-
await writeBuildCacheState(
|
|
3494
|
+
if (buildDecision.shouldPersistBuildCache && buildDecision.sourceFingerprint) {
|
|
3495
|
+
await writeBuildCacheState(buildDecision.sourceFingerprint, { environmentFingerprint });
|
|
3250
3496
|
}
|
|
3251
3497
|
console.log(`[${options.logPrefix}] Starting application on ${applicationBaseUrl}...`);
|
|
3252
3498
|
const startedAppProcess = startYarnCommand(["start"], commandEnvironment, {
|
|
@@ -3529,12 +3775,18 @@ export {
|
|
|
3529
3775
|
INTEGRATION_TEST_USAGE,
|
|
3530
3776
|
NO_APP_OWNED_INTEGRATION_SPECS_MESSAGE,
|
|
3531
3777
|
NO_RUNNABLE_APP_OWNED_INTEGRATION_SPECS_MESSAGE,
|
|
3778
|
+
PREBUILT_ARTIFACTS_ENV_VAR,
|
|
3779
|
+
PREBUILT_BUILD_ENV_RECORD_FILE,
|
|
3532
3780
|
UNREPORTED_APP_OWNED_INTEGRATION_SPECS_MESSAGE,
|
|
3533
3781
|
acquireEphemeralRuntimeLock,
|
|
3782
|
+
assertPrebuiltArtifactsUsable,
|
|
3534
3783
|
buildAppOnlyPlaywrightFileFilters,
|
|
3784
|
+
buildEphemeralInitializationEnvironment,
|
|
3535
3785
|
clearEphemeralEnvironmentState,
|
|
3536
3786
|
createBoundedOutputBuffer,
|
|
3537
3787
|
ephemeralPostgresInitSql,
|
|
3788
|
+
findMissingPrebuiltArtifacts,
|
|
3789
|
+
findPrebuiltBuildEnvironmentMismatches,
|
|
3538
3790
|
formatCapturedOutput,
|
|
3539
3791
|
killProcessTree,
|
|
3540
3792
|
listAppOwnedIntegrationSpecCandidates,
|
|
@@ -3546,20 +3798,27 @@ export {
|
|
|
3546
3798
|
parseInteractiveIntegrationOptions,
|
|
3547
3799
|
parseOptions,
|
|
3548
3800
|
parsePlaywrightListedSpecPaths,
|
|
3801
|
+
pickBuildShapingEnvironment,
|
|
3549
3802
|
readEphemeralEnvironmentState,
|
|
3803
|
+
readPrebuiltBuildEnvironmentRecord,
|
|
3550
3804
|
registerEphemeralShutdownHandlers,
|
|
3551
3805
|
resolveAppOnlySuiteRun,
|
|
3552
3806
|
resolveAppOwnedIntegrationSpecPaths,
|
|
3553
3807
|
resolveAppReadyTimeoutMs,
|
|
3554
3808
|
resolveBuildCacheTtlSeconds,
|
|
3809
|
+
resolveEphemeralBuildDecision,
|
|
3555
3810
|
resolveEphemeralJwtSecret,
|
|
3556
3811
|
resolveEphemeralPostgresImage,
|
|
3557
3812
|
resolveEphemeralSuperadminPassword,
|
|
3813
|
+
resolvePrebuiltArtifactRequirements,
|
|
3814
|
+
resolvePrebuiltArtifactsMode,
|
|
3815
|
+
resolvePrebuiltSourceRevision,
|
|
3558
3816
|
runEphemeralAppForQa,
|
|
3559
3817
|
runIntegrationCoverageReport,
|
|
3560
3818
|
runIntegrationSpecCoverageReport,
|
|
3561
3819
|
runIntegrationTestsInEphemeralEnvironment,
|
|
3562
3820
|
runInteractiveIntegrationInEphemeralEnvironment,
|
|
3821
|
+
runRecordPrebuiltBuildEnvironment,
|
|
3563
3822
|
shouldRebuildBuildArtifacts,
|
|
3564
3823
|
shouldReuseBuildArtifacts,
|
|
3565
3824
|
shouldUseIsolatedPortForFreshEnvironment,
|
|
@@ -3568,6 +3827,7 @@ export {
|
|
|
3568
3827
|
tryReuseExistingEnvironment,
|
|
3569
3828
|
waitForApplicationReadiness,
|
|
3570
3829
|
withoutCoverageEnvironment,
|
|
3571
|
-
writeEphemeralEnvironmentState
|
|
3830
|
+
writeEphemeralEnvironmentState,
|
|
3831
|
+
writePrebuiltBuildEnvironmentRecord
|
|
3572
3832
|
};
|
|
3573
3833
|
//# sourceMappingURL=integration.js.map
|