@open-mercato/cli 0.6.7-develop.6552.1.5208a19369 → 0.6.7-develop.6565.1.1026d85fff
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 +3 -3
- package/AGENTS.md +1 -0
- package/dist/agentic/guides/module-facts.json +53 -53
- package/dist/agentic/guides/modules/ai_assistant.md +1 -1
- package/dist/agentic/guides/modules/api_docs.md +1 -1
- package/dist/agentic/guides/modules/api_keys.md +1 -1
- package/dist/agentic/guides/modules/attachments.md +1 -1
- package/dist/agentic/guides/modules/audit_logs.md +1 -1
- package/dist/agentic/guides/modules/auth.md +1 -1
- package/dist/agentic/guides/modules/business_rules.md +1 -1
- package/dist/agentic/guides/modules/catalog.md +1 -1
- package/dist/agentic/guides/modules/channel_gmail.md +1 -1
- package/dist/agentic/guides/modules/channel_imap.md +1 -1
- package/dist/agentic/guides/modules/checkout.md +1 -1
- package/dist/agentic/guides/modules/communication_channels.md +1 -1
- package/dist/agentic/guides/modules/configs.md +1 -1
- package/dist/agentic/guides/modules/content.md +1 -1
- package/dist/agentic/guides/modules/currencies.md +1 -1
- package/dist/agentic/guides/modules/customer_accounts.md +1 -1
- package/dist/agentic/guides/modules/customers.md +1 -1
- package/dist/agentic/guides/modules/dashboards.md +1 -1
- package/dist/agentic/guides/modules/data_sync.md +1 -1
- package/dist/agentic/guides/modules/dictionaries.md +1 -1
- package/dist/agentic/guides/modules/directory.md +1 -1
- package/dist/agentic/guides/modules/entities.md +1 -1
- package/dist/agentic/guides/modules/events.md +1 -1
- package/dist/agentic/guides/modules/feature_toggles.md +1 -1
- package/dist/agentic/guides/modules/gateway_stripe.md +1 -1
- package/dist/agentic/guides/modules/generators.md +1 -1
- package/dist/agentic/guides/modules/inbox_ops.md +1 -1
- package/dist/agentic/guides/modules/integrations.md +1 -1
- package/dist/agentic/guides/modules/messages.md +1 -1
- package/dist/agentic/guides/modules/notifications.md +1 -1
- package/dist/agentic/guides/modules/onboarding.md +1 -1
- package/dist/agentic/guides/modules/payment_gateways.md +1 -1
- package/dist/agentic/guides/modules/perspectives.md +1 -1
- package/dist/agentic/guides/modules/planner.md +1 -1
- package/dist/agentic/guides/modules/portal.md +1 -1
- package/dist/agentic/guides/modules/progress.md +1 -1
- package/dist/agentic/guides/modules/query_index.md +1 -1
- package/dist/agentic/guides/modules/record_locks.md +1 -1
- package/dist/agentic/guides/modules/resources.md +1 -1
- package/dist/agentic/guides/modules/sales.md +1 -1
- package/dist/agentic/guides/modules/scheduler.md +1 -1
- package/dist/agentic/guides/modules/search.md +1 -1
- package/dist/agentic/guides/modules/security.md +1 -1
- package/dist/agentic/guides/modules/shipping_carriers.md +1 -1
- package/dist/agentic/guides/modules/sso.md +1 -1
- package/dist/agentic/guides/modules/staff.md +1 -1
- package/dist/agentic/guides/modules/storage_s3.md +1 -1
- package/dist/agentic/guides/modules/sync_akeneo.md +1 -1
- package/dist/agentic/guides/modules/sync_excel.md +1 -1
- package/dist/agentic/guides/modules/system_status_overlays.md +1 -1
- package/dist/agentic/guides/modules/translations.md +1 -1
- package/dist/agentic/guides/modules/webhooks.md +1 -1
- package/dist/agentic/guides/modules/workflows.md +1 -1
- package/dist/agentic/shared/AGENTS.md.template +1 -1
- package/dist/agentic/shared/ai/skills/tiers.schema.json +15 -0
- package/dist/agentic/shared/scripts/install-skills.sh +244 -37
- package/dist/lib/__integration__/TC-INT-008.spec.js +9 -11
- package/dist/lib/__integration__/TC-INT-008.spec.js.map +2 -2
- package/dist/lib/agentic-setup.js +14 -2
- package/dist/lib/agentic-setup.js.map +2 -2
- package/dist/lib/generate-watch-events.js +106 -0
- package/dist/lib/generate-watch-events.js.map +7 -0
- package/dist/lib/generators/entity-ids.js +20 -13
- package/dist/lib/generators/entity-ids.js.map +2 -2
- package/dist/lib/generators/openapi.js +114 -12
- package/dist/lib/generators/openapi.js.map +2 -2
- package/dist/lib/in-process-generate-watcher.js +13 -2
- package/dist/lib/in-process-generate-watcher.js.map +2 -2
- package/dist/mercato.js +68 -23
- package/dist/mercato.js.map +2 -2
- package/package.json +5 -5
- package/src/__tests__/mercato.test.ts +53 -2
- package/src/lib/__integration__/TC-INT-008.spec.ts +15 -15
- package/src/lib/__tests__/generate-watch-events.test.ts +112 -0
- package/src/lib/__tests__/generate-watch-structure.test.ts +20 -0
- package/src/lib/__tests__/in-process-generate-watcher.test.ts +193 -2
- package/src/lib/agentic-setup.ts +23 -4
- package/src/lib/generate-watch-events.ts +125 -0
- package/src/lib/generators/__tests__/entity-ids.test.ts +98 -1
- package/src/lib/generators/__tests__/openapi.test.ts +174 -0
- package/src/lib/generators/entity-ids.ts +33 -13
- package/src/lib/generators/openapi.ts +167 -14
- package/src/lib/in-process-generate-watcher.ts +35 -6
- package/src/mercato.ts +75 -27
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/lib/agentic-setup.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Agentic setup for the CLI `agentic:init` command.\n *\n * Source files live in packages/create-app/agentic/ and are copied\n * to packages/cli/dist/agentic/ during build (see build.mjs).\n * This module reads those files at runtime \u2014 no embedded string constants.\n */\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync, copyFileSync, symlinkSync, lstatSync, unlinkSync, readdirSync } from 'node:fs'\nimport { spawnSync } from 'node:child_process'\nimport { join, dirname, basename } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { Project, SyntaxKind } from 'ts-morph'\n\nconst __dirname = dirname(fileURLToPath(import.meta.url))\n// In the built output (dist/lib/agentic-setup.js), __dirname is dist/lib/.\n// agentic/ is copied to dist/agentic/ by build.mjs.\nconst AGENTIC_DIR = join(__dirname, '..', 'agentic')\nconst GUIDES_DIR = join(AGENTIC_DIR, 'guides')\n\ntype AskFn = (question: string) => Promise<string>\n\ninterface AgenticSetupOptions {\n tool?: string\n force?: boolean\n}\n\ninterface AgenticConfig {\n projectName: string\n targetDir: string\n}\n\n// \u2500\u2500\u2500 Helpers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction resolvePlaceholders(content: string, config: AgenticConfig): string {\n return content.replace(/\\{\\{PROJECT_NAME\\}\\}/g, config.projectName)\n}\n\nfunction ensureDir(filePath: string): void {\n const dir = dirname(filePath)\n if (!existsSync(dir)) mkdirSync(dir, { recursive: true })\n}\n\nfunction writeTemplate(srcDir: string, srcRelative: string, destPath: string, config: AgenticConfig): void {\n const srcPath = join(srcDir, srcRelative)\n const content = readFileSync(srcPath, 'utf-8')\n ensureDir(destPath)\n writeFileSync(destPath, resolvePlaceholders(content, config))\n}\n\nfunction copyFile(srcDir: string, srcRelative: string, destPath: string): void {\n const srcPath = join(srcDir, srcRelative)\n ensureDir(destPath)\n copyFileSync(srcPath, destPath)\n}\n\n// \u2500\u2500\u2500 Module fact-sheet selection (mirrors packages/create-app/src/setup/tools/shared.ts) \u2500\u2500\n\n// AST-parse the static `enabledModules` array literal in the app's src/modules.ts\n// and collect each entry's `id`. Only the static literal is read (conditional\n// .push()/spread entries are intentionally not seen \u2014 see spec D6).\nfunction readEnabledModuleIds(modulesPath: string): string[] {\n if (!existsSync(modulesPath)) return []\n try {\n const project = new Project({ useInMemoryFileSystem: true })\n const sourceFile = project.createSourceFile('modules.ts', readFileSync(modulesPath, 'utf-8'))\n const declaration = sourceFile.getVariableDeclaration('enabledModules')\n const arrayLiteral = declaration?.getInitializerIfKind(SyntaxKind.ArrayLiteralExpression)\n if (!arrayLiteral) return []\n const ids: string[] = []\n for (const element of arrayLiteral.getElements()) {\n const objectLiteral = element.asKind(SyntaxKind.ObjectLiteralExpression)\n if (!objectLiteral) continue\n const idProperty = objectLiteral.getProperty('id')?.asKind(SyntaxKind.PropertyAssignment)\n const idValue = idProperty?.getInitializerIfKind(SyntaxKind.StringLiteral)?.getLiteralValue()\n if (idValue) ids.push(idValue)\n }\n return ids\n } catch {\n return []\n }\n}\n\n// Resolve which per-module fact-sheets to ship: the intersection of the bundled\n// fact-sheets (the D5 allowlist, materialized by build.mjs) with the app's enabled\n// modules. Falls back to the full bundled set when the enabled set cannot be read\n// (R5 \u2014 degraded, never empty).\nfunction selectModuleFactSheets(targetDir: string, modulesSubdir: string): string[] {\n const available = existsSync(modulesSubdir)\n ? readdirSync(modulesSubdir)\n .filter((file) => file.endsWith('.md'))\n .map((file) => file.replace(/\\.md$/, ''))\n : []\n if (available.length === 0) return []\n const enabled = new Set(readEnabledModuleIds(join(targetDir, 'src', 'modules.ts')))\n const selected = available.filter((moduleId) => enabled.has(moduleId))\n return selected.length > 0 ? selected : available\n}\n\nconst MODULE_GUIDES_START = '<!-- om:module-guides:start -->'\nconst MODULE_GUIDES_END = '<!-- om:module-guides:end -->'\n\n// Read each module's guide label from the bundled `module-facts.json` (emitted by\n// build.mjs from the generator's extraction of each module's own `metadata`). The\n// label falls back description \u2192 title \u2192 generic, so the CLI never re-declares\n// specific module names or descriptions. A missing/malformed sidecar degrades to an\n// empty map (generic labels), never a throw.\nfunction readModuleGuideLabels(guidesDir: string): Record<string, string> {\n const factsPath = join(guidesDir, 'module-facts.json')\n if (!existsSync(factsPath)) return {}\n try {\n const parsed = JSON.parse(readFileSync(factsPath, 'utf-8')) as Record<\n string,\n { description?: unknown; title?: unknown }\n >\n const labels: Record<string, string> = {}\n for (const [moduleId, entry] of Object.entries(parsed)) {\n const label =\n (entry && typeof entry.description === 'string' && entry.description) ||\n (entry && typeof entry.title === 'string' && entry.title) ||\n ''\n if (label) labels[moduleId] = label\n }\n return labels\n } catch {\n return {}\n }\n}\n\nfunction renderModuleGuidesBlock(selected: string[], labels: Record<string, string>): string {\n if (selected.length === 0) return '_No module fact-sheets are bundled for this app._'\n const rows = selected.map((moduleId) => {\n const label = labels[moduleId] ?? `Use the ${moduleId} module`\n return `| ${label} | \\`.ai/guides/modules/${moduleId}.md\\` |`\n })\n return ['| Task | Load |', '|---|---|', ...rows].join('\\n')\n}\n\n// Regenerate the marker-delimited Module-Specific Guides block in the written\n// AGENTS.md from the selected module set. Replaces strictly between the markers so\n// surrounding prose is untouched and repeat runs are idempotent.\nfunction injectModuleGuides(\n agentsMdPath: string,\n selected: string[],\n labels: Record<string, string> = {},\n): void {\n if (!existsSync(agentsMdPath)) return\n const content = readFileSync(agentsMdPath, 'utf-8')\n const startIndex = content.indexOf(MODULE_GUIDES_START)\n const endIndex = content.indexOf(MODULE_GUIDES_END)\n if (startIndex === -1 || endIndex === -1 || endIndex < startIndex) {\n console.warn(\n `[agentic] Module-Specific Guides markers (${MODULE_GUIDES_START} \u2026 ${MODULE_GUIDES_END}) not found in ${agentsMdPath}; the per-module guide list was not generated.`,\n )\n return\n }\n const before = content.slice(0, startIndex + MODULE_GUIDES_START.length)\n const after = content.slice(endIndex)\n const next = `${before}\\n${renderModuleGuidesBlock(selected, labels)}\\n${after}`\n if (next !== content) writeFileSync(agentsMdPath, next)\n}\n\n// \u2500\u2500\u2500 Generators \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction generateShared(config: AgenticConfig): void {\n const { targetDir } = config\n const srcDir = join(AGENTIC_DIR, 'shared')\n\n // Resolve which per-module fact-sheets this app gets (enabled \u2229 bundled allowlist).\n const selectedModules = selectModuleFactSheets(targetDir, join(GUIDES_DIR, 'modules'))\n const moduleGuideLabels = readModuleGuideLabels(GUIDES_DIR)\n\n // AGENTS.md\n writeTemplate(srcDir, 'AGENTS.md.template', join(targetDir, 'AGENTS.md'), config)\n injectModuleGuides(join(targetDir, 'AGENTS.md'), selectedModules, moduleGuideLabels)\n\n // .ai/ structure\n writeTemplate(srcDir, 'ai/specs/README.md', join(targetDir, '.ai', 'specs', 'README.md'), config)\n copyFile(srcDir, 'ai/specs/SPEC-000-template.md', join(targetDir, '.ai', 'specs', 'SPEC-000-template.md'))\n copyFile(srcDir, 'ai/lessons.md', join(targetDir, '.ai', 'lessons.md'))\n\n // .ai/skills/ \u2014 the shared skills-mixin manifest + tracker + external installer.\n // Skills owned by the external open-mercato/skills collection (code review, spec\n // writing, integration tests, prepare-issue, the auto-* PR family) are NOT copied\n // here; the user installs them with `yarn install-skills` (npx skills add). Only\n // standalone-only + kept-local skills and repo-local override folders are copied.\n copyFile(srcDir, 'ai/skills/tiers.json', join(targetDir, '.ai', 'skills', 'tiers.json'))\n copyFile(srcDir, 'ai/skills/tiers.schema.json', join(targetDir, '.ai', 'skills', 'tiers.schema.json'))\n copyFile(srcDir, 'ai/agentic.config.json', join(targetDir, '.ai', 'agentic.config.json'))\n copyFile(srcDir, 'ai/trackers/github.md', join(targetDir, '.ai', 'trackers', 'github.md'))\n copyFile(srcDir, 'scripts/install-skills.sh', join(targetDir, 'scripts', 'install-skills.sh'))\n\n copyFile(\n srcDir,\n 'ai/skills/om-backend-ui-design/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-backend-ui-design', 'SKILL.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-backend-ui-design/references/ui-components.md',\n join(targetDir, '.ai', 'skills', 'om-backend-ui-design', 'references', 'ui-components.md'),\n )\n copyFile(srcDir, 'ai/skills/om-integration-builder/SKILL.md', join(targetDir, '.ai', 'skills', 'om-integration-builder', 'SKILL.md'))\n if (existsSync(join(srcDir, 'ai', 'skills', 'om-integration-builder', 'STANDALONE.md'))) {\n copyFile(\n srcDir,\n 'ai/skills/om-integration-builder/STANDALONE.md',\n join(targetDir, '.ai', 'skills', 'om-integration-builder', 'STANDALONE.md'),\n )\n }\n copyFile(\n srcDir,\n 'ai/skills/om-integration-builder/references/adapter-contracts.md',\n join(targetDir, '.ai', 'skills', 'om-integration-builder', 'references', 'adapter-contracts.md'),\n )\n if (existsSync(join(srcDir, 'ai', 'skills', 'om-integration-builder', 'STANDALONE.md'))) {\n copyFile(\n srcDir,\n 'ai/skills/om-integration-builder/STANDALONE.md',\n join(targetDir, '.ai', 'skills', 'om-integration-builder', 'STANDALONE.md'),\n )\n }\n\n copyFile(\n srcDir,\n 'ai/skills/om-system-extension/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-system-extension', 'SKILL.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-system-extension/references/extension-contracts.md',\n join(targetDir, '.ai', 'skills', 'om-system-extension', 'references', 'extension-contracts.md'),\n )\n\n copyFile(\n srcDir,\n 'ai/skills/om-module-scaffold/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-module-scaffold', 'SKILL.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-module-scaffold/references/naming-conventions.md',\n join(targetDir, '.ai', 'skills', 'om-module-scaffold', 'references', 'naming-conventions.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-module-scaffold/references/navigation-patterns.md',\n join(targetDir, '.ai', 'skills', 'om-module-scaffold', 'references', 'navigation-patterns.md'),\n )\n\n copyFile(\n srcDir,\n 'ai/skills/om-troubleshooter/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-troubleshooter', 'SKILL.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-troubleshooter/references/diagnostic-commands.md',\n join(targetDir, '.ai', 'skills', 'om-troubleshooter', 'references', 'diagnostic-commands.md'),\n )\n\n copyFile(\n srcDir,\n 'ai/skills/om-eject-and-customize/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-eject-and-customize', 'SKILL.md'),\n )\n\n copyFile(\n srcDir,\n 'ai/skills/om-data-model-design/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-data-model-design', 'SKILL.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-data-model-design/references/mikro-orm-cheatsheet.md',\n join(targetDir, '.ai', 'skills', 'om-data-model-design', 'references', 'mikro-orm-cheatsheet.md'),\n )\n\n copyFile(\n srcDir,\n 'ai/skills/om-implement-spec/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-implement-spec', 'SKILL.md'),\n )\n\n copyFile(\n srcDir,\n 'ai/skills/om-help/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-help', 'SKILL.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-help/references/skills-catalog.md',\n join(targetDir, '.ai', 'skills', 'om-help', 'references', 'skills-catalog.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-help/references/workflow-sequences.md',\n join(targetDir, '.ai', 'skills', 'om-help', 'references', 'workflow-sequences.md'),\n )\n\n copyFile(\n srcDir,\n 'ai/skills/om-auto-upgrade-0.4.10-to-0.5.0/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-auto-upgrade-0.4.10-to-0.5.0', 'SKILL.md'),\n )\n\n // Slim repo-local OVERRIDE folders (SKILL.md only) for the external auto-* PR\n // family + single autofix skill. The workflow bodies live in open-mercato/skills\n // (installed via `yarn install-skills`); these overrides adjust them for a\n // standalone app and are read on top of the external skill's built-in workflow.\n // om-prepare-test-env's override carries environment knowledge (cross-platform\n // mercato CLI runner commands) rather than tracker adjustments.\n for (const autoSkill of [\n 'om-auto-create-pr',\n 'om-auto-continue-pr',\n 'om-auto-create-pr-loop',\n 'om-auto-continue-pr-loop',\n 'om-auto-review-pr',\n 'om-auto-fix-issue',\n 'om-prepare-test-env',\n ]) {\n if (!existsSync(join(srcDir, 'ai', 'skills', autoSkill, 'SKILL.md'))) {\n continue\n }\n copyFile(\n srcDir,\n `ai/skills/${autoSkill}/SKILL.md`,\n join(targetDir, '.ai', 'skills', autoSkill, 'SKILL.md'),\n )\n }\n\n copyFile(\n srcDir,\n 'ai/skills/om-trim-unused-modules/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-trim-unused-modules', 'SKILL.md'),\n )\n\n copyFile(srcDir, 'ai/qa/tests/playwright.config.ts', join(targetDir, '.ai', 'qa', 'tests', 'playwright.config.ts'))\n\n // Package & conceptual guides are copied wholesale (framework-wide). Per-module\n // fact-sheets (.ai/guides/modules/<module>.md) are filtered to the app's enabled\n // module set; the combined module-facts.json sidecar is copied as-is.\n if (existsSync(GUIDES_DIR)) {\n const guidesDestDir = join(targetDir, '.ai', 'guides')\n for (const file of readdirSync(GUIDES_DIR)) {\n if (!file.endsWith('.md')) continue\n const srcPath = join(GUIDES_DIR, file)\n const destPath = join(guidesDestDir, file)\n ensureDir(destPath)\n copyFileSync(srcPath, destPath)\n }\n\n const moduleFactsPath = join(GUIDES_DIR, 'module-facts.json')\n if (existsSync(moduleFactsPath)) {\n const destPath = join(guidesDestDir, 'module-facts.json')\n ensureDir(destPath)\n copyFileSync(moduleFactsPath, destPath)\n }\n\n const modulesSubdir = join(GUIDES_DIR, 'modules')\n for (const moduleId of selectedModules) {\n const destPath = join(guidesDestDir, 'modules', `${moduleId}.md`)\n ensureDir(destPath)\n copyFileSync(join(modulesSubdir, `${moduleId}.md`), destPath)\n }\n }\n}\n\nfunction generateClaudeCode(config: AgenticConfig): void {\n const { targetDir } = config\n const srcDir = join(AGENTIC_DIR, 'claude-code')\n\n writeTemplate(srcDir, 'CLAUDE.md.template', join(targetDir, 'CLAUDE.md'), config)\n copyFile(srcDir, 'settings.json', join(targetDir, '.claude', 'settings.json'))\n copyFile(srcDir, 'hooks/entity-migration-check.ts', join(targetDir, '.claude', 'hooks', 'entity-migration-check.ts'))\n copyFile(srcDir, 'mcp.json.example', join(targetDir, '.mcp.json.example'))\n\n // Symlink .claude/skills \u2192 ../.ai/skills\n ensureSkillsLink(join(targetDir, '.claude', 'skills'), join('..', '.ai', 'skills'))\n}\n\nfunction generateCodex(config: AgenticConfig): void {\n const { targetDir } = config\n const srcDir = join(AGENTIC_DIR, 'codex')\n\n const agentsPath = join(targetDir, 'AGENTS.md')\n if (existsSync(agentsPath)) {\n const enforcement = readFileSync(join(srcDir, 'enforcement-rules.md'), 'utf-8')\n let agents = readFileSync(agentsPath, 'utf-8')\n const MARKER_START = '<!-- CODEX_ENFORCEMENT_RULES_START -->'\n const MARKER_END = '<!-- CODEX_ENFORCEMENT_RULES_END -->'\n\n if (agents.includes(MARKER_START)) {\n const startIdx = agents.indexOf(MARKER_START)\n const endIdx = agents.indexOf(MARKER_END)\n if (endIdx !== -1) {\n agents = agents.slice(0, startIdx) + enforcement + agents.slice(endIdx + MARKER_END.length)\n }\n } else {\n const firstNewline = agents.indexOf('\\n')\n if (firstNewline !== -1) {\n agents = agents.slice(0, firstNewline + 1) + '\\n' + enforcement + '\\n' + agents.slice(firstNewline + 1)\n } else {\n agents = agents + '\\n\\n' + enforcement\n }\n }\n writeFileSync(agentsPath, agents)\n }\n\n copyFile(srcDir, 'mcp.json.example', join(targetDir, '.codex', 'mcp.json.example'))\n\n // Symlink .codex/skills \u2192 ../.ai/skills\n ensureSkillsLink(join(targetDir, '.codex', 'skills'), join('..', '.ai', 'skills'))\n}\n\nfunction generateCursor(config: AgenticConfig): void {\n const { targetDir } = config\n const srcDir = join(AGENTIC_DIR, 'cursor')\n\n writeTemplate(srcDir, 'rules/open-mercato.mdc', join(targetDir, '.cursor', 'rules', 'open-mercato.mdc'), config)\n copyFile(srcDir, 'rules/entity-guard.mdc', join(targetDir, '.cursor', 'rules', 'entity-guard.mdc'))\n copyFile(srcDir, 'rules/generated-guard.mdc', join(targetDir, '.cursor', 'rules', 'generated-guard.mdc'))\n copyFile(srcDir, 'hooks.json', join(targetDir, '.cursor', 'hooks.json'))\n copyFile(srcDir, 'hooks/entity-migration-check.mjs', join(targetDir, '.cursor', 'hooks', 'entity-migration-check.mjs'))\n copyFile(srcDir, 'mcp.json.example', join(targetDir, '.cursor', 'mcp.json.example'))\n\n // Symlink .cursor/skills \u2192 ../.ai/skills\n ensureSkillsLink(join(targetDir, '.cursor', 'skills'), join('..', '.ai', 'skills'))\n}\n\nfunction ensureSkillsLink(linkPath: string, target: string): void {\n ensureDir(linkPath)\n if (existsSync(linkPath) && !lstatSync(linkPath).isSymbolicLink()) {\n return\n }\n if (lstatSync(linkPath, { throwIfNoEntry: false })?.isSymbolicLink()) {\n unlinkSync(linkPath)\n }\n symlinkSync(target, linkPath)\n}\n\n// \u2500\u2500\u2500 Wizard \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nconst TOOLS = [\n { key: '1', label: 'Claude Code (Anthropic)', id: 'claude-code' },\n { key: '2', label: 'Codex (OpenAI)', id: 'codex' },\n { key: '3', label: 'Cursor (Anysphere)', id: 'cursor' },\n { key: '4', label: 'Multiple tools (select individually)', id: 'multiple' },\n { key: '5', label: 'Skip \u2014 set up manually later', id: 'skip' },\n] as const\n\nconst SELECTABLE = TOOLS.filter((t) => t.id !== 'multiple' && t.id !== 'skip')\n\nasync function promptSelection(ask: AskFn): Promise<string[]> {\n console.log('')\n console.log('\uD83E\uDD16 Agentic workflow setup')\n console.log('')\n console.log(' Which AI coding tool will you use with this project?')\n console.log('')\n for (const tool of TOOLS) {\n console.log(` ${tool.key}. ${tool.label}`)\n }\n console.log('')\n\n const answer = (await ask(' Enter number(s) separated by comma [1]: ')).trim() || '1'\n\n if (answer === '5') return ['skip']\n\n if (answer === '4') {\n const selected: string[] = []\n for (const tool of SELECTABLE) {\n const yn = await ask(` Include ${tool.label}? [y/N]: `)\n if (yn.toLowerCase() === 'y' || yn.toLowerCase() === 'yes') {\n selected.push(tool.id)\n }\n }\n return selected.length > 0 ? selected : ['skip']\n }\n\n const keys = answer.split(',').map((s) => s.trim())\n const ids: string[] = []\n for (const key of keys) {\n const tool = TOOLS.find((t) => t.key === key)\n if (tool && tool.id !== 'multiple' && tool.id !== 'skip') {\n ids.push(tool.id)\n }\n }\n return ids.length > 0 ? ids : ['skip']\n}\n\nexport async function runAgenticSetup(\n targetDir: string,\n ask: AskFn,\n options?: AgenticSetupOptions,\n): Promise<void> {\n let selectedIds: string[]\n\n if (options?.tool) {\n selectedIds = options.tool.split(',').map((t) => t.trim())\n } else {\n selectedIds = await promptSelection(ask)\n }\n\n if (selectedIds.includes('skip')) {\n console.log('')\n console.log(' Skipped agentic setup.')\n console.log('')\n return\n }\n\n const config: AgenticConfig = {\n projectName: basename(targetDir),\n targetDir,\n }\n\n generateShared(config)\n if (selectedIds.includes('claude-code')) generateClaudeCode(config)\n if (selectedIds.includes('codex')) generateCodex(config)\n if (selectedIds.includes('cursor')) generateCursor(config)\n\n installSkills(targetDir)\n\n console.log('')\n console.log(' Agentic setup complete:')\n if (selectedIds.includes('claude-code')) {\n console.log(' \u2713 Claude Code \u2014 CLAUDE.md, .claude/hooks/, .mcp.json.example')\n }\n if (selectedIds.includes('codex')) {\n console.log(' \u2713 Codex \u2014 AGENTS.md enforcement rules, .codex/mcp.json.example')\n }\n if (selectedIds.includes('cursor')) {\n console.log(' \u2713 Cursor \u2014 .cursor/rules/, .cursor/hooks/, .cursor/mcp.json.example')\n }\n console.log('')\n console.log(' .ai/agentic.config.json ships preconfigured (GitHub tracker, labels off);')\n console.log(' run /om-setup-agent-pipeline in your agent CLI to tailor labels, QA gate,')\n console.log(' tracker, or validation commands. Re-run `yarn install-skills` anytime to')\n console.log(' refresh the external open-mercato/skills subset.')\n console.log('')\n}\n\nfunction installSkills(targetDir: string): void {\n const installScript = join(targetDir, 'scripts', 'install-skills.sh')\n if (!existsSync(installScript)) return\n console.log('')\n console.log(' Installing agent skills (local tiers + external open-mercato/skills subset)...')\n const result = spawnSync('sh', [installScript], { cwd: targetDir, stdio: 'inherit' })\n if (result.error || result.status !== 0) {\n console.log(' \u26A0 Skill installation did not complete; run `yarn install-skills` inside the app when online.')\n }\n}\n"],
|
|
5
|
-
"mappings": "AAQA,SAAS,YAAY,WAAW,cAAc,eAAe,cAAc,aAAa,WAAW,YAAY,mBAAmB;AAClI,SAAS,iBAAiB;AAC1B,SAAS,MAAM,SAAS,gBAAgB;AACxC,SAAS,qBAAqB;AAC9B,SAAS,SAAS,kBAAkB;AAEpC,MAAM,YAAY,QAAQ,cAAc,YAAY,GAAG,CAAC;AAGxD,MAAM,cAAc,KAAK,WAAW,MAAM,SAAS;AACnD,MAAM,aAAa,KAAK,aAAa,QAAQ;AAgB7C,SAAS,oBAAoB,SAAiB,QAA+B;AAC3E,SAAO,QAAQ,QAAQ,yBAAyB,OAAO,WAAW;AACpE;AAEA,SAAS,UAAU,UAAwB;AACzC,QAAM,MAAM,QAAQ,QAAQ;AAC5B,MAAI,CAAC,WAAW,GAAG,EAAG,WAAU,KAAK,EAAE,WAAW,KAAK,CAAC;AAC1D;AAEA,SAAS,cAAc,QAAgB,aAAqB,UAAkB,QAA6B;AACzG,QAAM,UAAU,KAAK,QAAQ,WAAW;AACxC,QAAM,UAAU,aAAa,SAAS,OAAO;AAC7C,YAAU,QAAQ;AAClB,gBAAc,UAAU,oBAAoB,SAAS,MAAM,CAAC;AAC9D;AAEA,SAAS,SAAS,QAAgB,aAAqB,UAAwB;AAC7E,QAAM,UAAU,KAAK,QAAQ,WAAW;AACxC,YAAU,QAAQ;AAClB,eAAa,SAAS,QAAQ;AAChC;AAOA,SAAS,qBAAqB,aAA+B;AAC3D,MAAI,CAAC,WAAW,WAAW,EAAG,Q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,UAAQ,IAAI,8EAA8E;AAC1F,UAAQ,IAAI,6EAA6E;AACzF,UAAQ,IAAI,qDAAqD;AACjE,UAAQ,IAAI,EAAE;AAChB;AAEA,SAAS,cAAc,WAAyB;AAC9C,QAAM,gBAAgB,KAAK,WAAW,WAAW,mBAAmB;AACpE,MAAI,CAAC,WAAW,aAAa,EAAG;AAChC,UAAQ,IAAI,EAAE;AACd,UAAQ,IAAI,mFAAmF;AAC/F,QAAM,SAAS,UAAU,MAAM,CAAC,aAAa,GAAG,EAAE,KAAK,WAAW,OAAO,UAAU,CAAC;AACpF,MAAI,OAAO,SAAS,OAAO,WAAW,GAAG;AACvC,YAAQ,IAAI,sGAAiG;AAAA,EAC/G;AACF;",
|
|
4
|
+
"sourcesContent": ["/**\n * Agentic setup for the CLI `agentic:init` command.\n *\n * Source files live in packages/create-app/agentic/ and are copied\n * to packages/cli/dist/agentic/ during build (see build.mjs).\n * This module reads those files at runtime \u2014 no embedded string constants.\n */\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync, copyFileSync, symlinkSync, lstatSync, unlinkSync, readdirSync } from 'node:fs'\nimport { spawnSync } from 'node:child_process'\nimport { join, dirname, basename } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { Project, SyntaxKind } from 'ts-morph'\n\nconst __dirname = dirname(fileURLToPath(import.meta.url))\n// In the built output (dist/lib/agentic-setup.js), __dirname is dist/lib/.\n// agentic/ is copied to dist/agentic/ by build.mjs.\nconst AGENTIC_DIR = join(__dirname, '..', 'agentic')\nconst GUIDES_DIR = join(AGENTIC_DIR, 'guides')\n\ntype AskFn = (question: string) => Promise<string>\n\ninterface AgenticSetupOptions {\n tool?: string\n force?: boolean\n}\n\ninterface AgenticConfig {\n projectName: string\n targetDir: string\n}\n\n// \u2500\u2500\u2500 Helpers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction resolvePlaceholders(content: string, config: AgenticConfig): string {\n return content.replace(/\\{\\{PROJECT_NAME\\}\\}/g, config.projectName)\n}\n\nfunction ensureDir(filePath: string): void {\n const dir = dirname(filePath)\n if (!existsSync(dir)) mkdirSync(dir, { recursive: true })\n}\n\nfunction writeTemplate(srcDir: string, srcRelative: string, destPath: string, config: AgenticConfig): void {\n const srcPath = join(srcDir, srcRelative)\n const content = readFileSync(srcPath, 'utf-8')\n ensureDir(destPath)\n writeFileSync(destPath, resolvePlaceholders(content, config))\n}\n\nfunction copyFile(srcDir: string, srcRelative: string, destPath: string): void {\n const srcPath = join(srcDir, srcRelative)\n ensureDir(destPath)\n copyFileSync(srcPath, destPath)\n}\n\n// \u2500\u2500\u2500 Module fact-sheet selection (mirrors packages/create-app/src/setup/tools/shared.ts) \u2500\u2500\n\n// AST-parse the static `enabledModules` array literal in the app's src/modules.ts\n// and collect each entry's `id`. Only the static literal is read (conditional\n// .push()/spread entries are intentionally not seen \u2014 see spec D6).\nfunction readEnabledModuleIds(modulesPath: string): string[] {\n if (!existsSync(modulesPath)) return []\n try {\n const project = new Project({ useInMemoryFileSystem: true })\n const sourceFile = project.createSourceFile('modules.ts', readFileSync(modulesPath, 'utf-8'))\n const declaration = sourceFile.getVariableDeclaration('enabledModules')\n const arrayLiteral = declaration?.getInitializerIfKind(SyntaxKind.ArrayLiteralExpression)\n if (!arrayLiteral) return []\n const ids: string[] = []\n for (const element of arrayLiteral.getElements()) {\n const objectLiteral = element.asKind(SyntaxKind.ObjectLiteralExpression)\n if (!objectLiteral) continue\n const idProperty = objectLiteral.getProperty('id')?.asKind(SyntaxKind.PropertyAssignment)\n const idValue = idProperty?.getInitializerIfKind(SyntaxKind.StringLiteral)?.getLiteralValue()\n if (idValue) ids.push(idValue)\n }\n return ids\n } catch {\n return []\n }\n}\n\n// Resolve which per-module fact-sheets to ship: the intersection of the bundled\n// fact-sheets (the D5 allowlist, materialized by build.mjs) with the app's enabled\n// modules. Falls back to the full bundled set when the enabled set cannot be read\n// (R5 \u2014 degraded, never empty).\nfunction selectModuleFactSheets(targetDir: string, modulesSubdir: string): string[] {\n const available = existsSync(modulesSubdir)\n ? readdirSync(modulesSubdir)\n .filter((file) => file.endsWith('.md'))\n .map((file) => file.replace(/\\.md$/, ''))\n : []\n if (available.length === 0) return []\n const enabled = new Set(readEnabledModuleIds(join(targetDir, 'src', 'modules.ts')))\n const selected = available.filter((moduleId) => enabled.has(moduleId))\n return selected.length > 0 ? selected : available\n}\n\nconst MODULE_GUIDES_START = '<!-- om:module-guides:start -->'\nconst MODULE_GUIDES_END = '<!-- om:module-guides:end -->'\n\n// Read each module's guide label from the bundled `module-facts.json` (emitted by\n// build.mjs from the generator's extraction of each module's own `metadata`). The\n// label falls back description \u2192 title \u2192 generic, so the CLI never re-declares\n// specific module names or descriptions. A missing/malformed sidecar degrades to an\n// empty map (generic labels), never a throw.\nfunction readModuleGuideLabels(guidesDir: string): Record<string, string> {\n const factsPath = join(guidesDir, 'module-facts.json')\n if (!existsSync(factsPath)) return {}\n try {\n const parsed = JSON.parse(readFileSync(factsPath, 'utf-8')) as Record<\n string,\n { description?: unknown; title?: unknown }\n >\n const labels: Record<string, string> = {}\n for (const [moduleId, entry] of Object.entries(parsed)) {\n const label =\n (entry && typeof entry.description === 'string' && entry.description) ||\n (entry && typeof entry.title === 'string' && entry.title) ||\n ''\n if (label) labels[moduleId] = label\n }\n return labels\n } catch {\n return {}\n }\n}\n\nfunction renderModuleGuidesBlock(selected: string[], labels: Record<string, string>): string {\n if (selected.length === 0) return '_No module fact-sheets are bundled for this app._'\n const rows = selected.map((moduleId) => {\n const label = labels[moduleId] ?? `Use the ${moduleId} module`\n return `| ${label} | \\`.ai/guides/modules/${moduleId}.md\\` |`\n })\n return ['| Task | Load |', '|---|---|', ...rows].join('\\n')\n}\n\n// Regenerate the marker-delimited Module-Specific Guides block in the written\n// AGENTS.md from the selected module set. Replaces strictly between the markers so\n// surrounding prose is untouched and repeat runs are idempotent.\nfunction injectModuleGuides(\n agentsMdPath: string,\n selected: string[],\n labels: Record<string, string> = {},\n): void {\n if (!existsSync(agentsMdPath)) return\n const content = readFileSync(agentsMdPath, 'utf-8')\n const startIndex = content.indexOf(MODULE_GUIDES_START)\n const endIndex = content.indexOf(MODULE_GUIDES_END)\n if (startIndex === -1 || endIndex === -1 || endIndex < startIndex) {\n console.warn(\n `[agentic] Module-Specific Guides markers (${MODULE_GUIDES_START} \u2026 ${MODULE_GUIDES_END}) not found in ${agentsMdPath}; the per-module guide list was not generated.`,\n )\n return\n }\n const before = content.slice(0, startIndex + MODULE_GUIDES_START.length)\n const after = content.slice(endIndex)\n const next = `${before}\\n${renderModuleGuidesBlock(selected, labels)}\\n${after}`\n if (next !== content) writeFileSync(agentsMdPath, next)\n}\n\n// \u2500\u2500\u2500 Generators \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction generateShared(config: AgenticConfig): void {\n const { targetDir } = config\n const srcDir = join(AGENTIC_DIR, 'shared')\n\n // Resolve which per-module fact-sheets this app gets (enabled \u2229 bundled allowlist).\n const selectedModules = selectModuleFactSheets(targetDir, join(GUIDES_DIR, 'modules'))\n const moduleGuideLabels = readModuleGuideLabels(GUIDES_DIR)\n\n // AGENTS.md\n writeTemplate(srcDir, 'AGENTS.md.template', join(targetDir, 'AGENTS.md'), config)\n injectModuleGuides(join(targetDir, 'AGENTS.md'), selectedModules, moduleGuideLabels)\n\n // .ai/ structure\n writeTemplate(srcDir, 'ai/specs/README.md', join(targetDir, '.ai', 'specs', 'README.md'), config)\n copyFile(srcDir, 'ai/specs/SPEC-000-template.md', join(targetDir, '.ai', 'specs', 'SPEC-000-template.md'))\n copyFile(srcDir, 'ai/lessons.md', join(targetDir, '.ai', 'lessons.md'))\n\n // .ai/skills/ \u2014 the shared skills-mixin manifest + tracker + external installer.\n // Skills owned by the external open-mercato/skills collection (code review, spec\n // writing, integration tests, prepare-issue, the auto-* PR family) are NOT copied\n // here; the user installs them with `yarn install-skills` (npx skills add). Only\n // standalone-only + kept-local skills and repo-local override folders are copied.\n copyFile(srcDir, 'ai/skills/tiers.json', join(targetDir, '.ai', 'skills', 'tiers.json'))\n copyFile(srcDir, 'ai/skills/tiers.schema.json', join(targetDir, '.ai', 'skills', 'tiers.schema.json'))\n copyFile(srcDir, 'ai/agentic.config.json', join(targetDir, '.ai', 'agentic.config.json'))\n copyFile(srcDir, 'ai/trackers/github.md', join(targetDir, '.ai', 'trackers', 'github.md'))\n copyFile(srcDir, 'scripts/install-skills.sh', join(targetDir, 'scripts', 'install-skills.sh'))\n\n copyFile(\n srcDir,\n 'ai/skills/om-backend-ui-design/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-backend-ui-design', 'SKILL.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-backend-ui-design/references/ui-components.md',\n join(targetDir, '.ai', 'skills', 'om-backend-ui-design', 'references', 'ui-components.md'),\n )\n copyFile(srcDir, 'ai/skills/om-integration-builder/SKILL.md', join(targetDir, '.ai', 'skills', 'om-integration-builder', 'SKILL.md'))\n if (existsSync(join(srcDir, 'ai', 'skills', 'om-integration-builder', 'STANDALONE.md'))) {\n copyFile(\n srcDir,\n 'ai/skills/om-integration-builder/STANDALONE.md',\n join(targetDir, '.ai', 'skills', 'om-integration-builder', 'STANDALONE.md'),\n )\n }\n copyFile(\n srcDir,\n 'ai/skills/om-integration-builder/references/adapter-contracts.md',\n join(targetDir, '.ai', 'skills', 'om-integration-builder', 'references', 'adapter-contracts.md'),\n )\n if (existsSync(join(srcDir, 'ai', 'skills', 'om-integration-builder', 'STANDALONE.md'))) {\n copyFile(\n srcDir,\n 'ai/skills/om-integration-builder/STANDALONE.md',\n join(targetDir, '.ai', 'skills', 'om-integration-builder', 'STANDALONE.md'),\n )\n }\n\n copyFile(\n srcDir,\n 'ai/skills/om-system-extension/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-system-extension', 'SKILL.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-system-extension/references/extension-contracts.md',\n join(targetDir, '.ai', 'skills', 'om-system-extension', 'references', 'extension-contracts.md'),\n )\n\n copyFile(\n srcDir,\n 'ai/skills/om-module-scaffold/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-module-scaffold', 'SKILL.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-module-scaffold/references/naming-conventions.md',\n join(targetDir, '.ai', 'skills', 'om-module-scaffold', 'references', 'naming-conventions.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-module-scaffold/references/navigation-patterns.md',\n join(targetDir, '.ai', 'skills', 'om-module-scaffold', 'references', 'navigation-patterns.md'),\n )\n\n copyFile(\n srcDir,\n 'ai/skills/om-troubleshooter/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-troubleshooter', 'SKILL.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-troubleshooter/references/diagnostic-commands.md',\n join(targetDir, '.ai', 'skills', 'om-troubleshooter', 'references', 'diagnostic-commands.md'),\n )\n\n copyFile(\n srcDir,\n 'ai/skills/om-eject-and-customize/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-eject-and-customize', 'SKILL.md'),\n )\n\n copyFile(\n srcDir,\n 'ai/skills/om-data-model-design/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-data-model-design', 'SKILL.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-data-model-design/references/mikro-orm-cheatsheet.md',\n join(targetDir, '.ai', 'skills', 'om-data-model-design', 'references', 'mikro-orm-cheatsheet.md'),\n )\n\n copyFile(\n srcDir,\n 'ai/skills/om-implement-spec/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-implement-spec', 'SKILL.md'),\n )\n\n copyFile(\n srcDir,\n 'ai/skills/om-help/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-help', 'SKILL.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-help/references/skills-catalog.md',\n join(targetDir, '.ai', 'skills', 'om-help', 'references', 'skills-catalog.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-help/references/workflow-sequences.md',\n join(targetDir, '.ai', 'skills', 'om-help', 'references', 'workflow-sequences.md'),\n )\n\n copyFile(\n srcDir,\n 'ai/skills/om-auto-upgrade-0.4.10-to-0.5.0/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-auto-upgrade-0.4.10-to-0.5.0', 'SKILL.md'),\n )\n\n // Slim repo-local OVERRIDE folders (SKILL.md only) for the external auto-* PR\n // family + single autofix skill. The workflow bodies live in open-mercato/skills\n // (installed via `yarn install-skills`); these overrides adjust them for a\n // standalone app and are read on top of the external skill's built-in workflow.\n // om-prepare-test-env's override carries environment knowledge (cross-platform\n // mercato CLI runner commands) rather than tracker adjustments.\n for (const autoSkill of [\n 'om-auto-create-pr',\n 'om-auto-continue-pr',\n 'om-auto-create-pr-loop',\n 'om-auto-continue-pr-loop',\n 'om-auto-review-pr',\n 'om-auto-fix-issue',\n 'om-prepare-test-env',\n ]) {\n if (!existsSync(join(srcDir, 'ai', 'skills', autoSkill, 'SKILL.md'))) {\n continue\n }\n copyFile(\n srcDir,\n `ai/skills/${autoSkill}/SKILL.md`,\n join(targetDir, '.ai', 'skills', autoSkill, 'SKILL.md'),\n )\n }\n\n copyFile(\n srcDir,\n 'ai/skills/om-trim-unused-modules/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-trim-unused-modules', 'SKILL.md'),\n )\n\n copyFile(srcDir, 'ai/qa/tests/playwright.config.ts', join(targetDir, '.ai', 'qa', 'tests', 'playwright.config.ts'))\n\n // Package & conceptual guides are copied wholesale (framework-wide). Per-module\n // fact-sheets (.ai/guides/modules/<module>.md) are filtered to the app's enabled\n // module set; the combined module-facts.json sidecar is copied as-is.\n if (existsSync(GUIDES_DIR)) {\n const guidesDestDir = join(targetDir, '.ai', 'guides')\n for (const file of readdirSync(GUIDES_DIR)) {\n if (!file.endsWith('.md')) continue\n const srcPath = join(GUIDES_DIR, file)\n const destPath = join(guidesDestDir, file)\n ensureDir(destPath)\n copyFileSync(srcPath, destPath)\n }\n\n const moduleFactsPath = join(GUIDES_DIR, 'module-facts.json')\n if (existsSync(moduleFactsPath)) {\n const destPath = join(guidesDestDir, 'module-facts.json')\n ensureDir(destPath)\n copyFileSync(moduleFactsPath, destPath)\n }\n\n const modulesSubdir = join(GUIDES_DIR, 'modules')\n for (const moduleId of selectedModules) {\n const destPath = join(guidesDestDir, 'modules', `${moduleId}.md`)\n ensureDir(destPath)\n copyFileSync(join(modulesSubdir, `${moduleId}.md`), destPath)\n }\n }\n}\n\nfunction generateClaudeCode(config: AgenticConfig): void {\n const { targetDir } = config\n const srcDir = join(AGENTIC_DIR, 'claude-code')\n\n writeTemplate(srcDir, 'CLAUDE.md.template', join(targetDir, 'CLAUDE.md'), config)\n copyFile(srcDir, 'settings.json', join(targetDir, '.claude', 'settings.json'))\n copyFile(srcDir, 'hooks/entity-migration-check.ts', join(targetDir, '.claude', 'hooks', 'entity-migration-check.ts'))\n copyFile(srcDir, 'mcp.json.example', join(targetDir, '.mcp.json.example'))\n\n // Symlink .claude/skills \u2192 ../.ai/skills\n ensureSkillsLink(join(targetDir, '.claude', 'skills'), join('..', '.ai', 'skills'))\n}\n\nfunction generateCodex(config: AgenticConfig): void {\n const { targetDir } = config\n const srcDir = join(AGENTIC_DIR, 'codex')\n\n const agentsPath = join(targetDir, 'AGENTS.md')\n if (existsSync(agentsPath)) {\n const enforcement = readFileSync(join(srcDir, 'enforcement-rules.md'), 'utf-8')\n let agents = readFileSync(agentsPath, 'utf-8')\n const MARKER_START = '<!-- CODEX_ENFORCEMENT_RULES_START -->'\n const MARKER_END = '<!-- CODEX_ENFORCEMENT_RULES_END -->'\n\n if (agents.includes(MARKER_START)) {\n const startIdx = agents.indexOf(MARKER_START)\n const endIdx = agents.indexOf(MARKER_END)\n if (endIdx !== -1) {\n agents = agents.slice(0, startIdx) + enforcement + agents.slice(endIdx + MARKER_END.length)\n }\n } else {\n const firstNewline = agents.indexOf('\\n')\n if (firstNewline !== -1) {\n agents = agents.slice(0, firstNewline + 1) + '\\n' + enforcement + '\\n' + agents.slice(firstNewline + 1)\n } else {\n agents = agents + '\\n\\n' + enforcement\n }\n }\n writeFileSync(agentsPath, agents)\n }\n\n copyFile(srcDir, 'mcp.json.example', join(targetDir, '.codex', 'mcp.json.example'))\n\n // No .codex/skills directory: Codex reads the canonical .agents/skills/,\n // which scripts/install-skills.sh populates.\n}\n\nfunction generateCursor(config: AgenticConfig): void {\n const { targetDir } = config\n const srcDir = join(AGENTIC_DIR, 'cursor')\n\n writeTemplate(srcDir, 'rules/open-mercato.mdc', join(targetDir, '.cursor', 'rules', 'open-mercato.mdc'), config)\n copyFile(srcDir, 'rules/entity-guard.mdc', join(targetDir, '.cursor', 'rules', 'entity-guard.mdc'))\n copyFile(srcDir, 'rules/generated-guard.mdc', join(targetDir, '.cursor', 'rules', 'generated-guard.mdc'))\n copyFile(srcDir, 'hooks.json', join(targetDir, '.cursor', 'hooks.json'))\n copyFile(srcDir, 'hooks/entity-migration-check.mjs', join(targetDir, '.cursor', 'hooks', 'entity-migration-check.mjs'))\n copyFile(srcDir, 'mcp.json.example', join(targetDir, '.cursor', 'mcp.json.example'))\n\n // No .cursor/skills directory: Cursor reads the canonical .agents/skills/,\n // which scripts/install-skills.sh populates.\n}\n\nfunction ensureSkillsLink(linkPath: string, target: string): void {\n ensureDir(linkPath)\n if (existsSync(linkPath) && !lstatSync(linkPath).isSymbolicLink()) {\n return\n }\n if (lstatSync(linkPath, { throwIfNoEntry: false })?.isSymbolicLink()) {\n unlinkSync(linkPath)\n }\n symlinkSync(target, linkPath)\n}\n\n// \u2500\u2500\u2500 Wizard \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nconst TOOLS = [\n { key: '1', label: 'Claude Code (Anthropic)', id: 'claude-code' },\n { key: '2', label: 'Codex (OpenAI)', id: 'codex' },\n { key: '3', label: 'Cursor (Anysphere)', id: 'cursor' },\n { key: '4', label: 'Multiple tools (select individually)', id: 'multiple' },\n { key: '5', label: 'Skip \u2014 set up manually later', id: 'skip' },\n] as const\n\nconst SELECTABLE = TOOLS.filter((t) => t.id !== 'multiple' && t.id !== 'skip')\n\nasync function promptSelection(ask: AskFn): Promise<string[]> {\n console.log('')\n console.log('\uD83E\uDD16 Agentic workflow setup')\n console.log('')\n console.log(' Which AI coding tool will you use with this project?')\n console.log('')\n for (const tool of TOOLS) {\n console.log(` ${tool.key}. ${tool.label}`)\n }\n console.log('')\n\n const answer = (await ask(' Enter number(s) separated by comma [1]: ')).trim() || '1'\n\n if (answer === '5') return ['skip']\n\n if (answer === '4') {\n const selected: string[] = []\n for (const tool of SELECTABLE) {\n const yn = await ask(` Include ${tool.label}? [y/N]: `)\n if (yn.toLowerCase() === 'y' || yn.toLowerCase() === 'yes') {\n selected.push(tool.id)\n }\n }\n return selected.length > 0 ? selected : ['skip']\n }\n\n const keys = answer.split(',').map((s) => s.trim())\n const ids: string[] = []\n for (const key of keys) {\n const tool = TOOLS.find((t) => t.key === key)\n if (tool && tool.id !== 'multiple' && tool.id !== 'skip') {\n ids.push(tool.id)\n }\n }\n return ids.length > 0 ? ids : ['skip']\n}\n\nexport async function runAgenticSetup(\n targetDir: string,\n ask: AskFn,\n options?: AgenticSetupOptions,\n): Promise<void> {\n let selectedIds: string[]\n\n if (options?.tool) {\n selectedIds = options.tool.split(',').map((t) => t.trim())\n } else {\n selectedIds = await promptSelection(ask)\n }\n\n if (selectedIds.includes('skip')) {\n console.log('')\n console.log(' Skipped agentic setup.')\n console.log('')\n return\n }\n\n const config: AgenticConfig = {\n projectName: basename(targetDir),\n targetDir,\n }\n\n generateShared(config)\n if (selectedIds.includes('claude-code')) generateClaudeCode(config)\n if (selectedIds.includes('codex')) generateCodex(config)\n if (selectedIds.includes('cursor')) generateCursor(config)\n\n persistAgentSelection(targetDir, selectedIds)\n installSkills(targetDir)\n\n console.log('')\n console.log(' Agentic setup complete:')\n if (selectedIds.includes('claude-code')) {\n console.log(' \u2713 Claude Code \u2014 CLAUDE.md, .claude/hooks/, .mcp.json.example')\n }\n if (selectedIds.includes('codex')) {\n console.log(' \u2713 Codex \u2014 AGENTS.md enforcement rules, .codex/mcp.json.example')\n }\n if (selectedIds.includes('cursor')) {\n console.log(' \u2713 Cursor \u2014 .cursor/rules/, .cursor/hooks/, .cursor/mcp.json.example')\n }\n console.log('')\n console.log(' .ai/agentic.config.json ships preconfigured (GitHub tracker, labels off);')\n console.log(' run /om-setup-agent-pipeline in your agent CLI to tailor labels, QA gate,')\n console.log(' tracker, or validation commands. Re-run `yarn install-skills` anytime to')\n console.log(' refresh the external open-mercato/skills subset.')\n console.log('')\n}\n\n/**\n * Persist the agent selection so later `yarn install-skills` runs keep honoring\n * it: agents the user did not pick go into `agents.ignore` in tiers.json and\n * never get a skills directory of their own.\n */\nfunction persistAgentSelection(targetDir: string, selectedIds: string[]): void {\n const manifestPath = join(targetDir, '.ai', 'skills', 'tiers.json')\n if (!existsSync(manifestPath)) return\n const ignore = SELECTABLE.map((tool) => tool.id).filter((id) => !selectedIds.includes(id))\n const manifest = JSON.parse(readFileSync(manifestPath, 'utf-8')) as Record<string, unknown>\n if (ignore.length > 0) {\n manifest.agents = { ignore }\n } else {\n delete manifest.agents\n }\n writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\\n`)\n}\n\nfunction installSkills(targetDir: string): void {\n const installScript = join(targetDir, 'scripts', 'install-skills.sh')\n if (!existsSync(installScript)) return\n console.log('')\n console.log(' Installing agent skills (local tiers + external open-mercato/skills subset)...')\n const result = spawnSync('sh', [installScript], { cwd: targetDir, stdio: 'inherit' })\n if (result.error || result.status !== 0) {\n console.log(' \u26A0 Skill installation did not complete; run `yarn install-skills` inside the app when online.')\n }\n}\n"],
|
|
5
|
+
"mappings": "AAQA,SAAS,YAAY,WAAW,cAAc,eAAe,cAAc,aAAa,WAAW,YAAY,mBAAmB;AAClI,SAAS,iBAAiB;AAC1B,SAAS,MAAM,SAAS,gBAAgB;AACxC,SAAS,qBAAqB;AAC9B,SAAS,SAAS,kBAAkB;AAEpC,MAAM,YAAY,QAAQ,cAAc,YAAY,GAAG,CAAC;AAGxD,MAAM,cAAc,KAAK,WAAW,MAAM,SAAS;AACnD,MAAM,aAAa,KAAK,aAAa,QAAQ;AAgB7C,SAAS,oBAAoB,SAAiB,QAA+B;AAC3E,SAAO,QAAQ,QAAQ,yBAAyB,OAAO,WAAW;AACpE;AAEA,SAAS,UAAU,UAAwB;AACzC,QAAM,MAAM,QAAQ,QAAQ;AAC5B,MAAI,CAAC,WAAW,GAAG,EAAG,WAAU,KAAK,EAAE,WAAW,KAAK,CAAC;AAC1D;AAEA,SAAS,cAAc,QAAgB,aAAqB,UAAkB,QAA6B;AACzG,QAAM,UAAU,KAAK,QAAQ,WAAW;AACxC,QAAM,UAAU,aAAa,SAAS,OAAO;AAC7C,YAAU,QAAQ;AAClB,gBAAc,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AAQ,GAAG;AAClC,YAAQ,IAAI,kFAAwE;AAAA,EACtF;AACA,UAAQ,IAAI,EAAE;AACd,UAAQ,IAAI,8EAA8E;AAC1F,UAAQ,IAAI,8EAA8E;AAC1F,UAAQ,IAAI,6EAA6E;AACzF,UAAQ,IAAI,qDAAqD;AACjE,UAAQ,IAAI,EAAE;AAChB;AAOA,SAAS,sBAAsB,WAAmB,aAA6B;AAC7E,QAAM,eAAe,KAAK,WAAW,OAAO,UAAU,YAAY;AAClE,MAAI,CAAC,WAAW,YAAY,EAAG;AAC/B,QAAM,SAAS,WAAW,IAAI,CAAC,SAAS,KAAK,EAAE,EAAE,OAAO,CAAC,OAAO,CAAC,YAAY,SAAS,EAAE,CAAC;AACzF,QAAM,WAAW,KAAK,MAAM,aAAa,cAAc,OAAO,CAAC;AAC/D,MAAI,OAAO,SAAS,GAAG;AACrB,aAAS,SAAS,EAAE,OAAO;AAAA,EAC7B,OAAO;AACL,WAAO,SAAS;AAAA,EAClB;AACA,gBAAc,cAAc,GAAG,KAAK,UAAU,UAAU,MAAM,CAAC,CAAC;AAAA,CAAI;AACtE;AAEA,SAAS,cAAc,WAAyB;AAC9C,QAAM,gBAAgB,KAAK,WAAW,WAAW,mBAAmB;AACpE,MAAI,CAAC,WAAW,aAAa,EAAG;AAChC,UAAQ,IAAI,EAAE;AACd,UAAQ,IAAI,mFAAmF;AAC/F,QAAM,SAAS,UAAU,MAAM,CAAC,aAAa,GAAG,EAAE,KAAK,WAAW,OAAO,UAAU,CAAC;AACpF,MAAI,OAAO,SAAS,OAAO,WAAW,GAAG;AACvC,YAAQ,IAAI,sGAAiG;AAAA,EAC/G;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
function targetKey(target) {
|
|
4
|
+
return JSON.stringify([
|
|
5
|
+
path.resolve(target.directory),
|
|
6
|
+
target.recursive,
|
|
7
|
+
target.fileName ?? ""
|
|
8
|
+
]);
|
|
9
|
+
}
|
|
10
|
+
const defaultWatchDirectory = (target, onChange, onError) => {
|
|
11
|
+
const watcher = fs.watch(
|
|
12
|
+
target.directory,
|
|
13
|
+
{ recursive: target.recursive },
|
|
14
|
+
(_eventType, fileName) => {
|
|
15
|
+
const normalizedName = String(fileName ?? "");
|
|
16
|
+
if (target.fileName && normalizedName && normalizedName !== target.fileName) return;
|
|
17
|
+
onChange(normalizedName || void 0);
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
watcher.on("error", onError);
|
|
21
|
+
return watcher;
|
|
22
|
+
};
|
|
23
|
+
function createGenerateWatchChangeSignal(options) {
|
|
24
|
+
const watchDirectory = options.watchDirectory ?? defaultWatchDirectory;
|
|
25
|
+
const watchers = /* @__PURE__ */ new Map();
|
|
26
|
+
let version = 0;
|
|
27
|
+
let pollingFallback = false;
|
|
28
|
+
let closed = false;
|
|
29
|
+
const closeWatchers = () => {
|
|
30
|
+
for (const watcher of watchers.values()) {
|
|
31
|
+
try {
|
|
32
|
+
watcher.close();
|
|
33
|
+
} catch {
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
watchers.clear();
|
|
37
|
+
};
|
|
38
|
+
const enterPollingFallback = () => {
|
|
39
|
+
if (pollingFallback) return;
|
|
40
|
+
pollingFallback = true;
|
|
41
|
+
version += 1;
|
|
42
|
+
closeWatchers();
|
|
43
|
+
};
|
|
44
|
+
return {
|
|
45
|
+
currentVersion: () => version,
|
|
46
|
+
usesPollingFallback: () => pollingFallback,
|
|
47
|
+
refresh: async () => {
|
|
48
|
+
if (closed || pollingFallback) return;
|
|
49
|
+
let targets;
|
|
50
|
+
try {
|
|
51
|
+
targets = await options.getWatchTargets();
|
|
52
|
+
} catch {
|
|
53
|
+
enterPollingFallback();
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const normalizedTargets = /* @__PURE__ */ new Map();
|
|
57
|
+
for (const target of targets) {
|
|
58
|
+
const normalized = {
|
|
59
|
+
...target,
|
|
60
|
+
directory: path.resolve(target.directory)
|
|
61
|
+
};
|
|
62
|
+
normalizedTargets.set(targetKey(normalized), normalized);
|
|
63
|
+
}
|
|
64
|
+
for (const [key, watcher] of watchers) {
|
|
65
|
+
if (normalizedTargets.has(key)) continue;
|
|
66
|
+
try {
|
|
67
|
+
watcher.close();
|
|
68
|
+
} catch {
|
|
69
|
+
}
|
|
70
|
+
watchers.delete(key);
|
|
71
|
+
}
|
|
72
|
+
for (const [key, target] of normalizedTargets) {
|
|
73
|
+
if (watchers.has(key)) continue;
|
|
74
|
+
try {
|
|
75
|
+
const watcher = watchDirectory(
|
|
76
|
+
target,
|
|
77
|
+
() => {
|
|
78
|
+
version += 1;
|
|
79
|
+
},
|
|
80
|
+
enterPollingFallback
|
|
81
|
+
);
|
|
82
|
+
if (closed || pollingFallback) {
|
|
83
|
+
try {
|
|
84
|
+
watcher.close();
|
|
85
|
+
} catch {
|
|
86
|
+
}
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
watchers.set(key, watcher);
|
|
90
|
+
} catch {
|
|
91
|
+
enterPollingFallback();
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
close: () => {
|
|
97
|
+
if (closed) return;
|
|
98
|
+
closed = true;
|
|
99
|
+
closeWatchers();
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
export {
|
|
104
|
+
createGenerateWatchChangeSignal
|
|
105
|
+
};
|
|
106
|
+
//# sourceMappingURL=generate-watch-events.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/lib/generate-watch-events.ts"],
|
|
4
|
+
"sourcesContent": ["import fs from 'node:fs'\nimport path from 'node:path'\nimport type { GenerateWatcherChangeSignal } from './in-process-generate-watcher'\n\nexport type GenerateWatchTarget = {\n directory: string\n recursive: boolean\n fileName?: string\n}\n\ntype WatchHandle = {\n close(): void\n}\n\ntype WatchDirectory = (\n target: GenerateWatchTarget,\n onChange: (fileName?: string) => void,\n onError: () => void,\n) => WatchHandle\n\nexport type GenerateWatchChangeSignalOptions = {\n getWatchTargets: () => Promise<GenerateWatchTarget[]> | GenerateWatchTarget[]\n watchDirectory?: WatchDirectory\n}\n\nfunction targetKey(target: GenerateWatchTarget): string {\n return JSON.stringify([\n path.resolve(target.directory),\n target.recursive,\n target.fileName ?? '',\n ])\n}\n\nconst defaultWatchDirectory: WatchDirectory = (target, onChange, onError) => {\n const watcher = fs.watch(\n target.directory,\n { recursive: target.recursive },\n (_eventType, fileName) => {\n const normalizedName = String(fileName ?? '')\n if (target.fileName && normalizedName && normalizedName !== target.fileName) return\n onChange(normalizedName || undefined)\n },\n )\n watcher.on('error', onError)\n return watcher\n}\n\nexport function createGenerateWatchChangeSignal(\n options: GenerateWatchChangeSignalOptions,\n): GenerateWatcherChangeSignal {\n const watchDirectory = options.watchDirectory ?? defaultWatchDirectory\n const watchers = new Map<string, WatchHandle>()\n let version = 0\n let pollingFallback = false\n let closed = false\n\n const closeWatchers = () => {\n for (const watcher of watchers.values()) {\n try { watcher.close() } catch {}\n }\n watchers.clear()\n }\n\n const enterPollingFallback = () => {\n if (pollingFallback) return\n pollingFallback = true\n version += 1\n closeWatchers()\n }\n\n return {\n currentVersion: () => version,\n usesPollingFallback: () => pollingFallback,\n refresh: async () => {\n if (closed || pollingFallback) return\n\n let targets: GenerateWatchTarget[]\n try {\n targets = await options.getWatchTargets()\n } catch {\n enterPollingFallback()\n return\n }\n\n const normalizedTargets = new Map<string, GenerateWatchTarget>()\n for (const target of targets) {\n const normalized: GenerateWatchTarget = {\n ...target,\n directory: path.resolve(target.directory),\n }\n normalizedTargets.set(targetKey(normalized), normalized)\n }\n\n for (const [key, watcher] of watchers) {\n if (normalizedTargets.has(key)) continue\n try { watcher.close() } catch {}\n watchers.delete(key)\n }\n\n for (const [key, target] of normalizedTargets) {\n if (watchers.has(key)) continue\n try {\n const watcher = watchDirectory(\n target,\n () => { version += 1 },\n enterPollingFallback,\n )\n if (closed || pollingFallback) {\n try { watcher.close() } catch {}\n continue\n }\n watchers.set(key, watcher)\n } catch {\n enterPollingFallback()\n return\n }\n }\n },\n close: () => {\n if (closed) return\n closed = true\n closeWatchers()\n },\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AAwBjB,SAAS,UAAU,QAAqC;AACtD,SAAO,KAAK,UAAU;AAAA,IACpB,KAAK,QAAQ,OAAO,SAAS;AAAA,IAC7B,OAAO;AAAA,IACP,OAAO,YAAY;AAAA,EACrB,CAAC;AACH;AAEA,MAAM,wBAAwC,CAAC,QAAQ,UAAU,YAAY;AAC3E,QAAM,UAAU,GAAG;AAAA,IACjB,OAAO;AAAA,IACP,EAAE,WAAW,OAAO,UAAU;AAAA,IAC9B,CAAC,YAAY,aAAa;AACxB,YAAM,iBAAiB,OAAO,YAAY,EAAE;AAC5C,UAAI,OAAO,YAAY,kBAAkB,mBAAmB,OAAO,SAAU;AAC7E,eAAS,kBAAkB,MAAS;AAAA,IACtC;AAAA,EACF;AACA,UAAQ,GAAG,SAAS,OAAO;AAC3B,SAAO;AACT;AAEO,SAAS,gCACd,SAC6B;AAC7B,QAAM,iBAAiB,QAAQ,kBAAkB;AACjD,QAAM,WAAW,oBAAI,IAAyB;AAC9C,MAAI,UAAU;AACd,MAAI,kBAAkB;AACtB,MAAI,SAAS;AAEb,QAAM,gBAAgB,MAAM;AAC1B,eAAW,WAAW,SAAS,OAAO,GAAG;AACvC,UAAI;AAAE,gBAAQ,MAAM;AAAA,MAAE,QAAQ;AAAA,MAAC;AAAA,IACjC;AACA,aAAS,MAAM;AAAA,EACjB;AAEA,QAAM,uBAAuB,MAAM;AACjC,QAAI,gBAAiB;AACrB,sBAAkB;AAClB,eAAW;AACX,kBAAc;AAAA,EAChB;AAEA,SAAO;AAAA,IAC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
writeIfChanged,
|
|
15
16
|
createGeneratorResult
|
|
16
17
|
} from "../utils.js";
|
|
17
18
|
import { addAutoGeneratedComment, createGeneratedSourceFile, elementAccess, getSourceText, identifier, returnStatement } from "./ast/index.js";
|
|
@@ -170,7 +171,14 @@ function parseEntityFieldsFromFile(filePath, exportedClassNames) {
|
|
|
170
171
|
});
|
|
171
172
|
return result;
|
|
172
173
|
}
|
|
173
|
-
function
|
|
174
|
+
function writeTrackedFile(filePath, content, result) {
|
|
175
|
+
if (writeIfChanged(filePath, content)) {
|
|
176
|
+
result.filesWritten.push(filePath);
|
|
177
|
+
} else {
|
|
178
|
+
result.filesUnchanged.push(filePath);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
function writePerEntityFieldFiles(outRoot, fieldsByEntity, result) {
|
|
174
182
|
fs.mkdirSync(outRoot, { recursive: true });
|
|
175
183
|
const desiredEntities = new Set(Object.keys(fieldsByEntity));
|
|
176
184
|
for (const [entity, fields] of Object.entries(fieldsByEntity)) {
|
|
@@ -189,16 +197,18 @@ function writePerEntityFieldFiles(outRoot, fieldsByEntity) {
|
|
|
189
197
|
]
|
|
190
198
|
});
|
|
191
199
|
}
|
|
192
|
-
|
|
200
|
+
writeTrackedFile(path.join(entDir, "index.ts"), getSourceText(sourceFile), result);
|
|
193
201
|
}
|
|
194
202
|
const existingEntries = fs.existsSync(outRoot) ? fs.readdirSync(outRoot, { withFileTypes: true }) : [];
|
|
195
203
|
for (const entry of existingEntries) {
|
|
196
204
|
if (!entry.isDirectory()) continue;
|
|
197
205
|
if (desiredEntities.has(entry.name)) continue;
|
|
198
|
-
|
|
206
|
+
const staleDirectory = path.join(outRoot, entry.name);
|
|
207
|
+
rimrafDir(staleDirectory);
|
|
208
|
+
result.filesWritten.push(staleDirectory);
|
|
199
209
|
}
|
|
200
210
|
}
|
|
201
|
-
function writeEntityFieldsRegistry(generatedRoot, fieldsByEntity) {
|
|
211
|
+
function writeEntityFieldsRegistry(generatedRoot, fieldsByEntity, result) {
|
|
202
212
|
const entities = Object.keys(fieldsByEntity).sort((a, b) => a.localeCompare(b));
|
|
203
213
|
const registry = {};
|
|
204
214
|
for (const entity of entities) {
|
|
@@ -229,8 +239,7 @@ function writeEntityFieldsRegistry(generatedRoot, fieldsByEntity) {
|
|
|
229
239
|
statements: [returnStatement(elementAccess(identifier("entityFieldsRegistry"), identifier("slug")))]
|
|
230
240
|
});
|
|
231
241
|
const outPath = path.join(generatedRoot, "entity-fields-registry.ts");
|
|
232
|
-
|
|
233
|
-
fs.writeFileSync(outPath, getSourceText(sourceFile));
|
|
242
|
+
writeTrackedFile(outPath, getSourceText(sourceFile), result);
|
|
234
243
|
}
|
|
235
244
|
async function generateEntityIds(options) {
|
|
236
245
|
const { resolver, quiet = false } = options;
|
|
@@ -362,9 +371,7 @@ async function generateEntityIds(options) {
|
|
|
362
371
|
type: "typeof E"
|
|
363
372
|
});
|
|
364
373
|
const src = getSourceText(groupSourceFile);
|
|
365
|
-
|
|
366
|
-
fs.writeFileSync(out, src);
|
|
367
|
-
result.filesWritten.push(out);
|
|
374
|
+
writeTrackedFile(out, src, result);
|
|
368
375
|
const fieldsRoot = path.join(pkgOutputDir, "entities");
|
|
369
376
|
const fieldsByModule = fieldsByGroup[g] || {};
|
|
370
377
|
const combined = {};
|
|
@@ -374,8 +381,8 @@ async function generateEntityIds(options) {
|
|
|
374
381
|
combined[entity] = Array.from(/* @__PURE__ */ new Set([...combined[entity] || [], ...fields]));
|
|
375
382
|
}
|
|
376
383
|
}
|
|
377
|
-
writePerEntityFieldFiles(fieldsRoot, combined);
|
|
378
|
-
writeEntityFieldsRegistry(pkgOutputDir, combined);
|
|
384
|
+
writePerEntityFieldFiles(fieldsRoot, combined, result);
|
|
385
|
+
writeEntityFieldsRegistry(pkgOutputDir, combined, result);
|
|
379
386
|
}
|
|
380
387
|
const combinedAll = {};
|
|
381
388
|
for (const groupFields of Object.values(fieldsByGroup)) {
|
|
@@ -385,8 +392,8 @@ async function generateEntityIds(options) {
|
|
|
385
392
|
}
|
|
386
393
|
}
|
|
387
394
|
}
|
|
388
|
-
writePerEntityFieldFiles(path.join(outputDir, "entities"), combinedAll);
|
|
389
|
-
writeEntityFieldsRegistry(outputDir, combinedAll);
|
|
395
|
+
writePerEntityFieldFiles(path.join(outputDir, "entities"), combinedAll, result);
|
|
396
|
+
writeEntityFieldsRegistry(outputDir, combinedAll, result);
|
|
390
397
|
return result;
|
|
391
398
|
}
|
|
392
399
|
function resolveConventionFile(baseDir, basename) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/generators/entity-ids.ts"],
|
|
4
|
-
"sourcesContent": ["import fs from 'node:fs'\nimport path from 'node:path'\nimport ts from 'typescript'\nimport { VariableDeclarationKind } from 'ts-morph'\nimport type { PackageResolver, ModuleEntry } from '../resolver'\nimport { MODULE_CODE_EXTENSIONS } from './scanner'\nimport {\n calculateChecksum,\n readChecksumRecord,\n writeChecksumRecord,\n ensureDir,\n toVar,\n toSnake,\n rimrafDir,\n logGenerationResult,\n type GeneratorResult,\n createGeneratorResult,\n} from '../utils'\nimport { addAutoGeneratedComment, createGeneratedSourceFile, elementAccess, getSourceText, identifier, returnStatement } from './ast'\n\ntype GroupKey = '@app' | '@open-mercato/core' | string\ntype EntityFieldMap = Record<string, string[]>\n\nexport interface EntityIdsOptions {\n resolver: PackageResolver\n quiet?: boolean\n}\n\n/**\n * Extract exported class names from a TypeScript source file without dynamic import.\n * This is used for @app modules since Node.js can't import TypeScript files directly.\n */\nfunction parseExportedClassNamesFromFile(filePath: string): string[] {\n const src = fs.readFileSync(filePath, 'utf8')\n const sf = ts.createSourceFile(filePath, src, ts.ScriptTarget.ES2020, true, ts.ScriptKind.TS)\n const classNames: string[] = []\n\n sf.forEachChild((node) => {\n // Check for exported class declarations\n if (ts.isClassDeclaration(node) && node.name) {\n const hasExport = node.modifiers?.some(\n (m) => m.kind === ts.SyntaxKind.ExportKeyword\n )\n if (hasExport) {\n classNames.push(node.name.text)\n }\n }\n })\n\n return classNames\n}\n\nfunction unwrapObjectLiteralExpression(\n expression: ts.Expression | undefined,\n): ts.ObjectLiteralExpression | undefined {\n if (!expression) return undefined\n if (ts.isObjectLiteralExpression(expression)) return expression\n if (ts.isAsExpression(expression) || ts.isTypeAssertionExpression(expression)) {\n return unwrapObjectLiteralExpression(expression.expression)\n }\n if (ts.isParenthesizedExpression(expression)) {\n return unwrapObjectLiteralExpression(expression.expression)\n }\n return undefined\n}\n\nfunction readPropertyInitializer(\n objectLiteral: ts.ObjectLiteralExpression,\n propertyName: string,\n): ts.Expression | undefined {\n for (const property of objectLiteral.properties) {\n if (!ts.isPropertyAssignment(property)) continue\n const name = ts.isIdentifier(property.name)\n ? property.name.text\n : ts.isStringLiteralLike(property.name)\n ? property.name.text\n : undefined\n if (name === propertyName) {\n return property.initializer\n }\n }\n return undefined\n}\n\nfunction parseGeneratedModuleEntityNames(filePath: string, moduleId: string): string[] {\n if (!fs.existsSync(filePath)) return []\n\n const source = fs.readFileSync(filePath, 'utf8')\n const scriptKind = filePath.endsWith('.js') ? ts.ScriptKind.JS : ts.ScriptKind.TS\n const sf = ts.createSourceFile(filePath, source, ts.ScriptTarget.ES2020, true, scriptKind)\n\n for (const statement of sf.statements) {\n if (!ts.isVariableStatement(statement)) continue\n const declaration = statement.declarationList.declarations.find((candidate) =>\n ts.isIdentifier(candidate.name) && candidate.name.text === 'E')\n if (!declaration) continue\n\n const eObject = unwrapObjectLiteralExpression(declaration.initializer)\n if (!eObject) continue\n\n const moduleObject = unwrapObjectLiteralExpression(readPropertyInitializer(eObject, moduleId))\n if (!moduleObject) return []\n\n const names: string[] = []\n for (const property of moduleObject.properties) {\n if (!ts.isPropertyAssignment(property)) continue\n const name = ts.isIdentifier(property.name)\n ? property.name.text\n : ts.isStringLiteralLike(property.name)\n ? property.name.text\n : undefined\n if (name) names.push(name)\n }\n return names\n }\n\n return []\n}\n\nfunction parseGeneratedEntityFieldsFile(filePath: string): string[] {\n if (!fs.existsSync(filePath)) return []\n\n const source = fs.readFileSync(filePath, 'utf8')\n const scriptKind = filePath.endsWith('.js') ? ts.ScriptKind.JS : ts.ScriptKind.TS\n const sf = ts.createSourceFile(filePath, source, ts.ScriptTarget.ES2020, true, scriptKind)\n const fields: string[] = []\n\n for (const statement of sf.statements) {\n if (!ts.isVariableStatement(statement)) continue\n for (const declaration of statement.declarationList.declarations) {\n if (!ts.isIdentifier(declaration.name) || !declaration.initializer) continue\n if (!ts.isStringLiteralLike(declaration.initializer)) continue\n fields.push(declaration.initializer.text)\n }\n }\n\n return Array.from(new Set(fields))\n}\n\nfunction resolveExistingFile(candidates: string[]): string | null {\n for (const candidate of candidates) {\n if (fs.existsSync(candidate)) return candidate\n }\n return null\n}\n\nfunction loadStandaloneGeneratedPackageEntities(\n resolver: PackageResolver,\n entry: ModuleEntry,\n): { entityNames: string[]; entityFieldMap: EntityFieldMap } | null {\n if (resolver.isMonorepo() || !entry.from || entry.from === '@app') return null\n\n const packageRoot = resolver.getPackageRoot(entry.from)\n const generatedRoot = fs.existsSync(path.join(packageRoot, 'generated'))\n ? path.join(packageRoot, 'generated')\n : path.join(packageRoot, 'dist', 'generated')\n const idsFile = resolveExistingFile([\n path.join(generatedRoot, 'entities.ids.generated.ts'),\n path.join(generatedRoot, 'entities.ids.generated.js'),\n ])\n if (!idsFile) return null\n const entityNames = parseGeneratedModuleEntityNames(idsFile, entry.id)\n\n if (entityNames.length === 0) return null\n\n const entityFieldMap: EntityFieldMap = {}\n for (const entityName of entityNames) {\n const fieldsFile = resolveExistingFile([\n path.join(generatedRoot, 'entities', entityName, 'index.ts'),\n path.join(generatedRoot, 'entities', entityName, 'index.js'),\n ])\n if (!fieldsFile) continue\n const fields = parseGeneratedEntityFieldsFile(fieldsFile)\n entityFieldMap[entityName] = fields\n }\n\n return { entityNames, entityFieldMap }\n}\n\nfunction parseEntityFieldsFromFile(filePath: string, exportedClassNames: string[]): EntityFieldMap {\n const src = fs.readFileSync(filePath, 'utf8')\n const sf = ts.createSourceFile(filePath, src, ts.ScriptTarget.ES2020, true, ts.ScriptKind.TS)\n\n const exported = new Set(exportedClassNames)\n const result: EntityFieldMap = {}\n\n function getDecoratorArgNameLiteral(dec: ts.Decorator | undefined): string | undefined {\n if (!dec) return undefined\n const expr = dec.expression\n if (!ts.isCallExpression(expr)) return undefined\n if (!expr.arguments.length) return undefined\n const first = expr.arguments[0]\n if (!ts.isObjectLiteralExpression(first)) return undefined\n for (const prop of first.properties) {\n if (ts.isPropertyAssignment(prop) && ts.isIdentifier(prop.name) && prop.name.text === 'name') {\n if (ts.isStringLiteral(prop.initializer)) return prop.initializer.text\n }\n }\n return undefined\n }\n\n function normalizeDbName(propertyName: string, _decoratorName?: string, nameOverride?: string): string {\n if (nameOverride) return nameOverride\n return toSnake(propertyName)\n }\n\n sf.forEachChild((node) => {\n if (!ts.isClassDeclaration(node) || !node.name) return\n const clsName = node.name.text\n if (!exported.has(clsName)) return\n const entityKey = toSnake(clsName)\n const fields: string[] = []\n\n for (const member of node.members) {\n if (!ts.isPropertyDeclaration(member) || !member.name) continue\n const name = ts.isIdentifier(member.name)\n ? member.name.text\n : ts.isStringLiteral(member.name)\n ? member.name.text\n : undefined\n if (!name) continue\n if (member.modifiers?.some((m) => m.kind === ts.SyntaxKind.StaticKeyword)) continue\n const decorators = ts.canHaveDecorators(member)\n ? ts.getDecorators(member) ?? []\n : []\n let dbName: string | undefined\n if (decorators && decorators.length) {\n for (const d of decorators) {\n const nameOverride = getDecoratorArgNameLiteral(d)\n dbName = normalizeDbName(name, undefined, nameOverride)\n if (dbName) break\n }\n }\n if (!dbName) dbName = normalizeDbName(name)\n fields.push(dbName)\n }\n result[entityKey] = Array.from(new Set(fields))\n })\n\n return result\n}\n\nfunction writePerEntityFieldFiles(outRoot: string, fieldsByEntity: EntityFieldMap): void {\n fs.mkdirSync(outRoot, { recursive: true })\n const desiredEntities = new Set(Object.keys(fieldsByEntity))\n for (const [entity, fields] of Object.entries(fieldsByEntity)) {\n const entDir = path.join(outRoot, entity)\n fs.mkdirSync(entDir, { recursive: true })\n const sourceFile = createGeneratedSourceFile(`${entity}/index.ts`)\n for (const field of fields) {\n sourceFile.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n isExported: true,\n declarations: [\n {\n name: toVar(field),\n initializer: JSON.stringify(field),\n },\n ],\n })\n }\n fs.writeFileSync(path.join(entDir, 'index.ts'), getSourceText(sourceFile))\n }\n\n const existingEntries = fs.existsSync(outRoot) ? fs.readdirSync(outRoot, { withFileTypes: true }) : []\n for (const entry of existingEntries) {\n if (!entry.isDirectory()) continue\n if (desiredEntities.has(entry.name)) continue\n rimrafDir(path.join(outRoot, entry.name))\n }\n}\n\nfunction writeEntityFieldsRegistry(generatedRoot: string, fieldsByEntity: EntityFieldMap): void {\n const entities = Object.keys(fieldsByEntity).sort((a, b) => a.localeCompare(b))\n const registry: Record<string, Record<string, string>> = {}\n for (const entity of entities) {\n registry[toVar(entity)] = {}\n for (const field of fieldsByEntity[entity] ?? []) {\n registry[toVar(entity)][toVar(field)] = field\n }\n }\n\n const sourceFile = createGeneratedSourceFile('entity-fields-registry.ts')\n addAutoGeneratedComment(sourceFile, 'entity-ids')\n sourceFile.insertText(sourceFile.getFullText().length, '// Static registry for entity fields - eliminates dynamic imports for Turbopack compatibility\\n')\n sourceFile.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n isExported: true,\n declarations: [\n {\n name: 'entityFieldsRegistry',\n type: 'Record<string, Record<string, string>>',\n initializer: JSON.stringify(registry, null, 2),\n },\n ],\n })\n sourceFile.addFunction({\n name: 'getEntityFields',\n isExported: true,\n parameters: [{ name: 'slug', type: 'string' }],\n returnType: 'Record<string, string> | undefined',\n statements: [returnStatement(elementAccess(identifier('entityFieldsRegistry'), identifier('slug')))],\n })\n const outPath = path.join(generatedRoot, 'entity-fields-registry.ts')\n ensureDir(outPath)\n fs.writeFileSync(outPath, getSourceText(sourceFile))\n}\n\nexport async function generateEntityIds(options: EntityIdsOptions): Promise<GeneratorResult> {\n const { resolver, quiet = false } = options\n const result = createGeneratorResult()\n\n const outputDir = resolver.getOutputDir()\n const outFile = path.join(outputDir, 'entities.ids.generated.ts')\n const checksumFile = path.join(outputDir, 'entities.ids.generated.checksum')\n\n const entries = resolver.loadEnabledModules()\n\n const consolidated: Record<string, Record<string, string>> = {}\n const grouped: Record<GroupKey, Record<string, Record<string, string>>> = {}\n const modulesDict: Record<string, string> = {}\n const groupedModulesDict: Record<GroupKey, Record<string, string>> = {}\n\n const fieldsByGroup: Record<GroupKey, Record<string, EntityFieldMap>> = {}\n\n for (const entry of entries) {\n const modId = entry.id\n const roots = resolver.getModulePaths(entry)\n const imps = resolver.getModuleImportBase(entry)\n const group: GroupKey = (entry.from as GroupKey) || '@open-mercato/core'\n\n const standaloneGeneratedPackageEntities = loadStandaloneGeneratedPackageEntities(resolver, entry)\n\n // Locate entities definition file (prefer app override)\n const appData = path.join(roots.appBase, 'data')\n const pkgData = path.join(roots.pkgBase, 'data')\n const appDb = path.join(roots.appBase, 'db')\n const pkgDb = path.join(roots.pkgBase, 'db')\n const bases = [appData, pkgData, appDb, pkgDb]\n const candidates = ['entities.override', 'entities', 'schema']\n let importPath: string | null = null\n let filePath: string | null = null\n\n for (const base of bases) {\n for (const f of candidates) {\n const p = resolveConventionFile(base, f)\n if (p) {\n const fromApp = base.startsWith(roots.appBase)\n const sub = path.basename(base) // 'data' | 'db'\n importPath = `${fromApp ? imps.appBase : imps.pkgBase}/${sub}/${f}`\n filePath = p\n break\n }\n }\n if (importPath) break\n }\n\n // No entities file found -> still register module id\n if (!filePath && !standaloneGeneratedPackageEntities) {\n modulesDict[modId] = modId\n groupedModulesDict[group] = groupedModulesDict[group] || {}\n groupedModulesDict[group][modId] = modId\n continue\n }\n\n const exportNames = filePath ? parseExportedClassNamesFromFile(filePath) : []\n\n const entityNames = standaloneGeneratedPackageEntities\n ? standaloneGeneratedPackageEntities.entityNames\n : exportNames\n .map((k) => toSnake(k))\n .filter((k, idx, arr) => arr.indexOf(k) === idx)\n\n // Build dictionaries\n modulesDict[modId] = modId\n groupedModulesDict[group] = groupedModulesDict[group] || {}\n groupedModulesDict[group][modId] = modId\n\n consolidated[modId] = consolidated[modId] || {}\n grouped[group] = grouped[group] || {}\n grouped[group][modId] = grouped[group][modId] || {}\n\n for (const en of entityNames) {\n consolidated[modId][en] = `${modId}:${en}`\n grouped[group][modId][en] = `${modId}:${en}`\n }\n\n // Parse entity fields from TypeScript source\n const entityFieldMap = standaloneGeneratedPackageEntities\n ? standaloneGeneratedPackageEntities.entityFieldMap\n : parseEntityFieldsFromFile(filePath!, exportNames)\n fieldsByGroup[group] = fieldsByGroup[group] || {}\n fieldsByGroup[group][modId] = entityFieldMap\n }\n\n // Write consolidated output\n const consolidatedSourceFile = createGeneratedSourceFile('entities.ids.generated.ts')\n addAutoGeneratedComment(consolidatedSourceFile, 'entity-ids')\n consolidatedSourceFile.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n isExported: true,\n declarations: [\n { name: 'M', initializer: `${JSON.stringify(modulesDict, null, 2)} as const` },\n { name: 'E', initializer: `${JSON.stringify(consolidated, null, 2)} as const` },\n ],\n })\n consolidatedSourceFile.addTypeAlias({\n name: 'KnownModuleId',\n isExported: true,\n type: 'keyof typeof M',\n })\n consolidatedSourceFile.addTypeAlias({\n name: 'KnownEntities',\n isExported: true,\n type: 'typeof E',\n })\n const consolidatedSrc = getSourceText(consolidatedSourceFile)\n\n // Check if content has changed\n const newChecksum = calculateChecksum(consolidatedSrc)\n let shouldWrite = true\n\n const existingRecord = readChecksumRecord(checksumFile)\n if (existingRecord && existingRecord.content === newChecksum) {\n shouldWrite = false\n }\n\n if (shouldWrite) {\n ensureDir(outFile)\n fs.writeFileSync(outFile, consolidatedSrc)\n writeChecksumRecord(checksumFile, { content: newChecksum, structure: '' })\n result.filesWritten.push(outFile)\n if (!quiet) {\n logGenerationResult(path.relative(process.cwd(), outFile), true)\n }\n } else {\n result.filesUnchanged.push(outFile)\n }\n\n // Write per-group outputs\n const groups = Object.keys(grouped) as GroupKey[]\n for (const g of groups) {\n if (!resolver.isMonorepo() && g !== '@app') {\n continue\n }\n\n const pkgOutputDir = resolver.getPackageOutputDir(g)\n // Skip @app group since it writes to the same location as the consolidated output\n if (g === '@app' && pkgOutputDir === outputDir) {\n continue\n }\n const out = path.join(pkgOutputDir, 'entities.ids.generated.ts')\n\n const groupSourceFile = createGeneratedSourceFile(`${String(g)}/entities.ids.generated.ts`)\n addAutoGeneratedComment(groupSourceFile, 'entity-ids')\n groupSourceFile.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n isExported: true,\n declarations: [\n { name: 'M', initializer: `${JSON.stringify(groupedModulesDict[g] || {}, null, 2)} as const` },\n { name: 'E', initializer: `${JSON.stringify(grouped[g] || {}, null, 2)} as const` },\n ],\n })\n groupSourceFile.addTypeAlias({\n name: 'KnownModuleId',\n isExported: true,\n type: 'keyof typeof M',\n })\n groupSourceFile.addTypeAlias({\n name: 'KnownEntities',\n isExported: true,\n type: 'typeof E',\n })\n const src = getSourceText(groupSourceFile)\n ensureDir(out)\n fs.writeFileSync(out, src)\n result.filesWritten.push(out)\n\n const fieldsRoot = path.join(pkgOutputDir, 'entities')\n const fieldsByModule = fieldsByGroup[g] || {}\n const combined: EntityFieldMap = {}\n for (const mId of Object.keys(fieldsByModule)) {\n const mMap = fieldsByModule[mId]\n for (const [entity, fields] of Object.entries(mMap)) {\n combined[entity] = Array.from(new Set([...(combined[entity] || []), ...fields]))\n }\n }\n writePerEntityFieldFiles(fieldsRoot, combined)\n\n // Generate static entity fields registry for Turbopack compatibility\n writeEntityFieldsRegistry(pkgOutputDir, combined)\n }\n\n // Write combined entity fields to root generated/ folder\n const combinedAll: EntityFieldMap = {}\n for (const groupFields of Object.values(fieldsByGroup)) {\n for (const mMap of Object.values(groupFields)) {\n for (const [entity, fields] of Object.entries(mMap)) {\n combinedAll[entity] = Array.from(new Set([...(combinedAll[entity] || []), ...fields]))\n }\n }\n }\n writePerEntityFieldFiles(path.join(outputDir, 'entities'), combinedAll)\n writeEntityFieldsRegistry(outputDir, combinedAll)\n\n return result\n}\n\nfunction resolveConventionFile(baseDir: string, basename: string): string | null {\n for (const extension of MODULE_CODE_EXTENSIONS) {\n const candidate = path.join(baseDir, `${basename}${extension}`)\n if (fs.existsSync(candidate)) return candidate\n }\n return null\n}\n"],
|
|
5
|
-
"mappings": "AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,SAAS,+BAA+B;AAExC,SAAS,8BAA8B;AACvC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AACP,SAAS,yBAAyB,2BAA2B,eAAe,eAAe,YAAY,uBAAuB;AAc9H,SAAS,gCAAgC,UAA4B;AACnE,QAAM,MAAM,GAAG,aAAa,UAAU,MAAM;AAC5C,QAAM,KAAK,GAAG,iBAAiB,UAAU,KAAK,GAAG,aAAa,QAAQ,MAAM,GAAG,WAAW,EAAE;AAC5F,QAAM,aAAuB,CAAC;AAE9B,KAAG,aAAa,CAAC,SAAS;AAExB,QAAI,GAAG,mBAAmB,IAAI,KAAK,KAAK,MAAM;AAC5C,YAAM,YAAY,KAAK,WAAW;AAAA,QAChC,CAAC,MAAM,EAAE,SAAS,GAAG,WAAW;AAAA,MAClC;AACA,UAAI,WAAW;AACb,mBAAW,KAAK,KAAK,KAAK,IAAI;AAAA,MAChC;AAAA,IACF;AAAA,EACF,CAAC;AAED,SAAO;AACT;AAEA,SAAS,8BACP,YACwC;AACxC,MAAI,CAAC,WAAY,QAAO;AACxB,MAAI,GAAG,0BAA0B,UAAU,EAAG,QAAO;AACrD,MAAI,GAAG,eAAe,UAAU,KAAK,GAAG,0BAA0B,UAAU,GAAG;AAC7E,WAAO,8BAA8B,WAAW,UAAU;AAAA,EA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AAU;AACrD,UAAM,iBAAiB,cAAc,CAAC,KAAK,CAAC;AAC5C,UAAM,WAA2B,CAAC;AAClC,eAAW,OAAO,OAAO,KAAK,cAAc,GAAG;AAC7C,YAAM,OAAO,eAAe,GAAG;AAC/B,iBAAW,CAAC,QAAQ,MAAM,KAAK,OAAO,QAAQ,IAAI,GAAG;AACnD,iBAAS,MAAM,IAAI,MAAM,KAAK,oBAAI,IAAI,CAAC,GAAI,SAAS,MAAM,KAAK,CAAC,GAAI,GAAG,MAAM,CAAC,CAAC;AAAA,MACjF;AAAA,IACF;AACA,6BAAyB,YAAY,QAAQ;AAG7C,8BAA0B,cAAc,QAAQ;AAAA,EAClD;AAGA,QAAM,cAA8B,CAAC;AACrC,aAAW,eAAe,OAAO,OAAO,aAAa,GAAG;AACtD,eAAW,QAAQ,OAAO,OAAO,WAAW,GAAG;AAC7C,iBAAW,CAAC,QAAQ,MAAM,KAAK,OAAO,QAAQ,IAAI,GAAG;AACnD,oBAAY,MAAM,IAAI,MAAM,KAAK,oBAAI,IAAI,CAAC,GAAI,YAAY,MAAM,KAAK,CAAC,GAAI,GAAG,MAAM,CAAC,CAAC;AAAA,MACvF;AAAA,IACF;AAAA,EACF;AACA,2BAAyB,KAAK,KAAK,WAAW,UAAU,GAAG,WAAW;AACtE,4BAA0B,WAAW,WAAW;AAEhD,SAAO;AACT;AAEA,SAAS,sBAAsB,SAAiB,UAAiC;AAC/E,aAAW,aAAa,wBAAwB;AAC9C,UAAM,YAAY,KAAK,KAAK,SAAS,GAAG,QAAQ,GAAG,SAAS,EAAE;AAC9D,QAAI,GAAG,WAAW,SAAS,EAAG,QAAO;AAAA,EACvC;AACA,SAAO;AACT;",
|
|
4
|
+
"sourcesContent": ["import fs from 'node:fs'\nimport path from 'node:path'\nimport ts from 'typescript'\nimport { VariableDeclarationKind } from 'ts-morph'\nimport type { PackageResolver, ModuleEntry } from '../resolver'\nimport { MODULE_CODE_EXTENSIONS } from './scanner'\nimport {\n calculateChecksum,\n readChecksumRecord,\n writeChecksumRecord,\n ensureDir,\n toVar,\n toSnake,\n rimrafDir,\n logGenerationResult,\n writeIfChanged,\n type GeneratorResult,\n createGeneratorResult,\n} from '../utils'\nimport { addAutoGeneratedComment, createGeneratedSourceFile, elementAccess, getSourceText, identifier, returnStatement } from './ast'\n\ntype GroupKey = '@app' | '@open-mercato/core' | string\ntype EntityFieldMap = Record<string, string[]>\n\nexport interface EntityIdsOptions {\n resolver: PackageResolver\n quiet?: boolean\n}\n\n/**\n * Extract exported class names from a TypeScript source file without dynamic import.\n * This is used for @app modules since Node.js can't import TypeScript files directly.\n */\nfunction parseExportedClassNamesFromFile(filePath: string): string[] {\n const src = fs.readFileSync(filePath, 'utf8')\n const sf = ts.createSourceFile(filePath, src, ts.ScriptTarget.ES2020, true, ts.ScriptKind.TS)\n const classNames: string[] = []\n\n sf.forEachChild((node) => {\n // Check for exported class declarations\n if (ts.isClassDeclaration(node) && node.name) {\n const hasExport = node.modifiers?.some(\n (m) => m.kind === ts.SyntaxKind.ExportKeyword\n )\n if (hasExport) {\n classNames.push(node.name.text)\n }\n }\n })\n\n return classNames\n}\n\nfunction unwrapObjectLiteralExpression(\n expression: ts.Expression | undefined,\n): ts.ObjectLiteralExpression | undefined {\n if (!expression) return undefined\n if (ts.isObjectLiteralExpression(expression)) return expression\n if (ts.isAsExpression(expression) || ts.isTypeAssertionExpression(expression)) {\n return unwrapObjectLiteralExpression(expression.expression)\n }\n if (ts.isParenthesizedExpression(expression)) {\n return unwrapObjectLiteralExpression(expression.expression)\n }\n return undefined\n}\n\nfunction readPropertyInitializer(\n objectLiteral: ts.ObjectLiteralExpression,\n propertyName: string,\n): ts.Expression | undefined {\n for (const property of objectLiteral.properties) {\n if (!ts.isPropertyAssignment(property)) continue\n const name = ts.isIdentifier(property.name)\n ? property.name.text\n : ts.isStringLiteralLike(property.name)\n ? property.name.text\n : undefined\n if (name === propertyName) {\n return property.initializer\n }\n }\n return undefined\n}\n\nfunction parseGeneratedModuleEntityNames(filePath: string, moduleId: string): string[] {\n if (!fs.existsSync(filePath)) return []\n\n const source = fs.readFileSync(filePath, 'utf8')\n const scriptKind = filePath.endsWith('.js') ? ts.ScriptKind.JS : ts.ScriptKind.TS\n const sf = ts.createSourceFile(filePath, source, ts.ScriptTarget.ES2020, true, scriptKind)\n\n for (const statement of sf.statements) {\n if (!ts.isVariableStatement(statement)) continue\n const declaration = statement.declarationList.declarations.find((candidate) =>\n ts.isIdentifier(candidate.name) && candidate.name.text === 'E')\n if (!declaration) continue\n\n const eObject = unwrapObjectLiteralExpression(declaration.initializer)\n if (!eObject) continue\n\n const moduleObject = unwrapObjectLiteralExpression(readPropertyInitializer(eObject, moduleId))\n if (!moduleObject) return []\n\n const names: string[] = []\n for (const property of moduleObject.properties) {\n if (!ts.isPropertyAssignment(property)) continue\n const name = ts.isIdentifier(property.name)\n ? property.name.text\n : ts.isStringLiteralLike(property.name)\n ? property.name.text\n : undefined\n if (name) names.push(name)\n }\n return names\n }\n\n return []\n}\n\nfunction parseGeneratedEntityFieldsFile(filePath: string): string[] {\n if (!fs.existsSync(filePath)) return []\n\n const source = fs.readFileSync(filePath, 'utf8')\n const scriptKind = filePath.endsWith('.js') ? ts.ScriptKind.JS : ts.ScriptKind.TS\n const sf = ts.createSourceFile(filePath, source, ts.ScriptTarget.ES2020, true, scriptKind)\n const fields: string[] = []\n\n for (const statement of sf.statements) {\n if (!ts.isVariableStatement(statement)) continue\n for (const declaration of statement.declarationList.declarations) {\n if (!ts.isIdentifier(declaration.name) || !declaration.initializer) continue\n if (!ts.isStringLiteralLike(declaration.initializer)) continue\n fields.push(declaration.initializer.text)\n }\n }\n\n return Array.from(new Set(fields))\n}\n\nfunction resolveExistingFile(candidates: string[]): string | null {\n for (const candidate of candidates) {\n if (fs.existsSync(candidate)) return candidate\n }\n return null\n}\n\nfunction loadStandaloneGeneratedPackageEntities(\n resolver: PackageResolver,\n entry: ModuleEntry,\n): { entityNames: string[]; entityFieldMap: EntityFieldMap } | null {\n if (resolver.isMonorepo() || !entry.from || entry.from === '@app') return null\n\n const packageRoot = resolver.getPackageRoot(entry.from)\n const generatedRoot = fs.existsSync(path.join(packageRoot, 'generated'))\n ? path.join(packageRoot, 'generated')\n : path.join(packageRoot, 'dist', 'generated')\n const idsFile = resolveExistingFile([\n path.join(generatedRoot, 'entities.ids.generated.ts'),\n path.join(generatedRoot, 'entities.ids.generated.js'),\n ])\n if (!idsFile) return null\n const entityNames = parseGeneratedModuleEntityNames(idsFile, entry.id)\n\n if (entityNames.length === 0) return null\n\n const entityFieldMap: EntityFieldMap = {}\n for (const entityName of entityNames) {\n const fieldsFile = resolveExistingFile([\n path.join(generatedRoot, 'entities', entityName, 'index.ts'),\n path.join(generatedRoot, 'entities', entityName, 'index.js'),\n ])\n if (!fieldsFile) continue\n const fields = parseGeneratedEntityFieldsFile(fieldsFile)\n entityFieldMap[entityName] = fields\n }\n\n return { entityNames, entityFieldMap }\n}\n\nfunction parseEntityFieldsFromFile(filePath: string, exportedClassNames: string[]): EntityFieldMap {\n const src = fs.readFileSync(filePath, 'utf8')\n const sf = ts.createSourceFile(filePath, src, ts.ScriptTarget.ES2020, true, ts.ScriptKind.TS)\n\n const exported = new Set(exportedClassNames)\n const result: EntityFieldMap = {}\n\n function getDecoratorArgNameLiteral(dec: ts.Decorator | undefined): string | undefined {\n if (!dec) return undefined\n const expr = dec.expression\n if (!ts.isCallExpression(expr)) return undefined\n if (!expr.arguments.length) return undefined\n const first = expr.arguments[0]\n if (!ts.isObjectLiteralExpression(first)) return undefined\n for (const prop of first.properties) {\n if (ts.isPropertyAssignment(prop) && ts.isIdentifier(prop.name) && prop.name.text === 'name') {\n if (ts.isStringLiteral(prop.initializer)) return prop.initializer.text\n }\n }\n return undefined\n }\n\n function normalizeDbName(propertyName: string, _decoratorName?: string, nameOverride?: string): string {\n if (nameOverride) return nameOverride\n return toSnake(propertyName)\n }\n\n sf.forEachChild((node) => {\n if (!ts.isClassDeclaration(node) || !node.name) return\n const clsName = node.name.text\n if (!exported.has(clsName)) return\n const entityKey = toSnake(clsName)\n const fields: string[] = []\n\n for (const member of node.members) {\n if (!ts.isPropertyDeclaration(member) || !member.name) continue\n const name = ts.isIdentifier(member.name)\n ? member.name.text\n : ts.isStringLiteral(member.name)\n ? member.name.text\n : undefined\n if (!name) continue\n if (member.modifiers?.some((m) => m.kind === ts.SyntaxKind.StaticKeyword)) continue\n const decorators = ts.canHaveDecorators(member)\n ? ts.getDecorators(member) ?? []\n : []\n let dbName: string | undefined\n if (decorators && decorators.length) {\n for (const d of decorators) {\n const nameOverride = getDecoratorArgNameLiteral(d)\n dbName = normalizeDbName(name, undefined, nameOverride)\n if (dbName) break\n }\n }\n if (!dbName) dbName = normalizeDbName(name)\n fields.push(dbName)\n }\n result[entityKey] = Array.from(new Set(fields))\n })\n\n return result\n}\n\nfunction writeTrackedFile(\n filePath: string,\n content: string,\n result: GeneratorResult,\n): void {\n if (writeIfChanged(filePath, content)) {\n result.filesWritten.push(filePath)\n } else {\n result.filesUnchanged.push(filePath)\n }\n}\n\nfunction writePerEntityFieldFiles(\n outRoot: string,\n fieldsByEntity: EntityFieldMap,\n result: GeneratorResult,\n): void {\n fs.mkdirSync(outRoot, { recursive: true })\n const desiredEntities = new Set(Object.keys(fieldsByEntity))\n for (const [entity, fields] of Object.entries(fieldsByEntity)) {\n const entDir = path.join(outRoot, entity)\n fs.mkdirSync(entDir, { recursive: true })\n const sourceFile = createGeneratedSourceFile(`${entity}/index.ts`)\n for (const field of fields) {\n sourceFile.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n isExported: true,\n declarations: [\n {\n name: toVar(field),\n initializer: JSON.stringify(field),\n },\n ],\n })\n }\n writeTrackedFile(path.join(entDir, 'index.ts'), getSourceText(sourceFile), result)\n }\n\n const existingEntries = fs.existsSync(outRoot) ? fs.readdirSync(outRoot, { withFileTypes: true }) : []\n for (const entry of existingEntries) {\n if (!entry.isDirectory()) continue\n if (desiredEntities.has(entry.name)) continue\n const staleDirectory = path.join(outRoot, entry.name)\n rimrafDir(staleDirectory)\n result.filesWritten.push(staleDirectory)\n }\n}\n\nfunction writeEntityFieldsRegistry(\n generatedRoot: string,\n fieldsByEntity: EntityFieldMap,\n result: GeneratorResult,\n): void {\n const entities = Object.keys(fieldsByEntity).sort((a, b) => a.localeCompare(b))\n const registry: Record<string, Record<string, string>> = {}\n for (const entity of entities) {\n registry[toVar(entity)] = {}\n for (const field of fieldsByEntity[entity] ?? []) {\n registry[toVar(entity)][toVar(field)] = field\n }\n }\n\n const sourceFile = createGeneratedSourceFile('entity-fields-registry.ts')\n addAutoGeneratedComment(sourceFile, 'entity-ids')\n sourceFile.insertText(sourceFile.getFullText().length, '// Static registry for entity fields - eliminates dynamic imports for Turbopack compatibility\\n')\n sourceFile.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n isExported: true,\n declarations: [\n {\n name: 'entityFieldsRegistry',\n type: 'Record<string, Record<string, string>>',\n initializer: JSON.stringify(registry, null, 2),\n },\n ],\n })\n sourceFile.addFunction({\n name: 'getEntityFields',\n isExported: true,\n parameters: [{ name: 'slug', type: 'string' }],\n returnType: 'Record<string, string> | undefined',\n statements: [returnStatement(elementAccess(identifier('entityFieldsRegistry'), identifier('slug')))],\n })\n const outPath = path.join(generatedRoot, 'entity-fields-registry.ts')\n writeTrackedFile(outPath, getSourceText(sourceFile), result)\n}\n\nexport async function generateEntityIds(options: EntityIdsOptions): Promise<GeneratorResult> {\n const { resolver, quiet = false } = options\n const result = createGeneratorResult()\n\n const outputDir = resolver.getOutputDir()\n const outFile = path.join(outputDir, 'entities.ids.generated.ts')\n const checksumFile = path.join(outputDir, 'entities.ids.generated.checksum')\n\n const entries = resolver.loadEnabledModules()\n\n const consolidated: Record<string, Record<string, string>> = {}\n const grouped: Record<GroupKey, Record<string, Record<string, string>>> = {}\n const modulesDict: Record<string, string> = {}\n const groupedModulesDict: Record<GroupKey, Record<string, string>> = {}\n\n const fieldsByGroup: Record<GroupKey, Record<string, EntityFieldMap>> = {}\n\n for (const entry of entries) {\n const modId = entry.id\n const roots = resolver.getModulePaths(entry)\n const imps = resolver.getModuleImportBase(entry)\n const group: GroupKey = (entry.from as GroupKey) || '@open-mercato/core'\n\n const standaloneGeneratedPackageEntities = loadStandaloneGeneratedPackageEntities(resolver, entry)\n\n // Locate entities definition file (prefer app override)\n const appData = path.join(roots.appBase, 'data')\n const pkgData = path.join(roots.pkgBase, 'data')\n const appDb = path.join(roots.appBase, 'db')\n const pkgDb = path.join(roots.pkgBase, 'db')\n const bases = [appData, pkgData, appDb, pkgDb]\n const candidates = ['entities.override', 'entities', 'schema']\n let importPath: string | null = null\n let filePath: string | null = null\n\n for (const base of bases) {\n for (const f of candidates) {\n const p = resolveConventionFile(base, f)\n if (p) {\n const fromApp = base.startsWith(roots.appBase)\n const sub = path.basename(base) // 'data' | 'db'\n importPath = `${fromApp ? imps.appBase : imps.pkgBase}/${sub}/${f}`\n filePath = p\n break\n }\n }\n if (importPath) break\n }\n\n // No entities file found -> still register module id\n if (!filePath && !standaloneGeneratedPackageEntities) {\n modulesDict[modId] = modId\n groupedModulesDict[group] = groupedModulesDict[group] || {}\n groupedModulesDict[group][modId] = modId\n continue\n }\n\n const exportNames = filePath ? parseExportedClassNamesFromFile(filePath) : []\n\n const entityNames = standaloneGeneratedPackageEntities\n ? standaloneGeneratedPackageEntities.entityNames\n : exportNames\n .map((k) => toSnake(k))\n .filter((k, idx, arr) => arr.indexOf(k) === idx)\n\n // Build dictionaries\n modulesDict[modId] = modId\n groupedModulesDict[group] = groupedModulesDict[group] || {}\n groupedModulesDict[group][modId] = modId\n\n consolidated[modId] = consolidated[modId] || {}\n grouped[group] = grouped[group] || {}\n grouped[group][modId] = grouped[group][modId] || {}\n\n for (const en of entityNames) {\n consolidated[modId][en] = `${modId}:${en}`\n grouped[group][modId][en] = `${modId}:${en}`\n }\n\n // Parse entity fields from TypeScript source\n const entityFieldMap = standaloneGeneratedPackageEntities\n ? standaloneGeneratedPackageEntities.entityFieldMap\n : parseEntityFieldsFromFile(filePath!, exportNames)\n fieldsByGroup[group] = fieldsByGroup[group] || {}\n fieldsByGroup[group][modId] = entityFieldMap\n }\n\n // Write consolidated output\n const consolidatedSourceFile = createGeneratedSourceFile('entities.ids.generated.ts')\n addAutoGeneratedComment(consolidatedSourceFile, 'entity-ids')\n consolidatedSourceFile.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n isExported: true,\n declarations: [\n { name: 'M', initializer: `${JSON.stringify(modulesDict, null, 2)} as const` },\n { name: 'E', initializer: `${JSON.stringify(consolidated, null, 2)} as const` },\n ],\n })\n consolidatedSourceFile.addTypeAlias({\n name: 'KnownModuleId',\n isExported: true,\n type: 'keyof typeof M',\n })\n consolidatedSourceFile.addTypeAlias({\n name: 'KnownEntities',\n isExported: true,\n type: 'typeof E',\n })\n const consolidatedSrc = getSourceText(consolidatedSourceFile)\n\n // Check if content has changed\n const newChecksum = calculateChecksum(consolidatedSrc)\n let shouldWrite = true\n\n const existingRecord = readChecksumRecord(checksumFile)\n if (existingRecord && existingRecord.content === newChecksum) {\n shouldWrite = false\n }\n\n if (shouldWrite) {\n ensureDir(outFile)\n fs.writeFileSync(outFile, consolidatedSrc)\n writeChecksumRecord(checksumFile, { content: newChecksum, structure: '' })\n result.filesWritten.push(outFile)\n if (!quiet) {\n logGenerationResult(path.relative(process.cwd(), outFile), true)\n }\n } else {\n result.filesUnchanged.push(outFile)\n }\n\n // Write per-group outputs\n const groups = Object.keys(grouped) as GroupKey[]\n for (const g of groups) {\n if (!resolver.isMonorepo() && g !== '@app') {\n continue\n }\n\n const pkgOutputDir = resolver.getPackageOutputDir(g)\n // Skip @app group since it writes to the same location as the consolidated output\n if (g === '@app' && pkgOutputDir === outputDir) {\n continue\n }\n const out = path.join(pkgOutputDir, 'entities.ids.generated.ts')\n\n const groupSourceFile = createGeneratedSourceFile(`${String(g)}/entities.ids.generated.ts`)\n addAutoGeneratedComment(groupSourceFile, 'entity-ids')\n groupSourceFile.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n isExported: true,\n declarations: [\n { name: 'M', initializer: `${JSON.stringify(groupedModulesDict[g] || {}, null, 2)} as const` },\n { name: 'E', initializer: `${JSON.stringify(grouped[g] || {}, null, 2)} as const` },\n ],\n })\n groupSourceFile.addTypeAlias({\n name: 'KnownModuleId',\n isExported: true,\n type: 'keyof typeof M',\n })\n groupSourceFile.addTypeAlias({\n name: 'KnownEntities',\n isExported: true,\n type: 'typeof E',\n })\n const src = getSourceText(groupSourceFile)\n writeTrackedFile(out, src, result)\n\n const fieldsRoot = path.join(pkgOutputDir, 'entities')\n const fieldsByModule = fieldsByGroup[g] || {}\n const combined: EntityFieldMap = {}\n for (const mId of Object.keys(fieldsByModule)) {\n const mMap = fieldsByModule[mId]\n for (const [entity, fields] of Object.entries(mMap)) {\n combined[entity] = Array.from(new Set([...(combined[entity] || []), ...fields]))\n }\n }\n writePerEntityFieldFiles(fieldsRoot, combined, result)\n\n // Generate static entity fields registry for Turbopack compatibility\n writeEntityFieldsRegistry(pkgOutputDir, combined, result)\n }\n\n // Write combined entity fields to root generated/ folder\n const combinedAll: EntityFieldMap = {}\n for (const groupFields of Object.values(fieldsByGroup)) {\n for (const mMap of Object.values(groupFields)) {\n for (const [entity, fields] of Object.entries(mMap)) {\n combinedAll[entity] = Array.from(new Set([...(combinedAll[entity] || []), ...fields]))\n }\n }\n }\n writePerEntityFieldFiles(path.join(outputDir, 'entities'), combinedAll, result)\n writeEntityFieldsRegistry(outputDir, combinedAll, result)\n\n return result\n}\n\nfunction resolveConventionFile(baseDir: string, basename: string): string | null {\n for (const extension of MODULE_CODE_EXTENSIONS) {\n const candidate = path.join(baseDir, `${basename}${extension}`)\n if (fs.existsSync(candidate)) return candidate\n }\n return null\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,SAAS,+BAA+B;AAExC,SAAS,8BAA8B;AACvC;AAAA,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