@open-mercato/cli 0.10.1-develop.7752.1.fd7c06569b → 0.10.1-develop.7753.1.61290f530d

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.
Files changed (93) hide show
  1. package/dist/agentic/guides/module-facts.json +162 -162
  2. package/dist/agentic/guides/module-facts.v2.json +162 -162
  3. package/dist/agentic/guides/modules/agent_orchestrator/index.md +1 -1
  4. package/dist/agentic/guides/modules/ai_assistant/index.md +1 -1
  5. package/dist/agentic/guides/modules/api_docs/index.md +1 -1
  6. package/dist/agentic/guides/modules/api_keys/index.md +1 -1
  7. package/dist/agentic/guides/modules/attachments/index.md +1 -1
  8. package/dist/agentic/guides/modules/audit_logs/index.md +1 -1
  9. package/dist/agentic/guides/modules/auth/index.md +1 -1
  10. package/dist/agentic/guides/modules/availability/index.md +1 -1
  11. package/dist/agentic/guides/modules/business_rules/index.md +1 -1
  12. package/dist/agentic/guides/modules/carrier_inpost/index.md +1 -1
  13. package/dist/agentic/guides/modules/cart/index.md +1 -1
  14. package/dist/agentic/guides/modules/catalog/index.md +1 -1
  15. package/dist/agentic/guides/modules/channel_apns/index.md +1 -1
  16. package/dist/agentic/guides/modules/channel_discord/index.md +1 -1
  17. package/dist/agentic/guides/modules/channel_expo/index.md +1 -1
  18. package/dist/agentic/guides/modules/channel_fcm/index.md +1 -1
  19. package/dist/agentic/guides/modules/channel_gmail/index.md +1 -1
  20. package/dist/agentic/guides/modules/channel_imap/index.md +1 -1
  21. package/dist/agentic/guides/modules/channel_resend/index.md +1 -1
  22. package/dist/agentic/guides/modules/channel_ses/index.md +1 -1
  23. package/dist/agentic/guides/modules/channel_smtp/index.md +1 -1
  24. package/dist/agentic/guides/modules/checkout/index.md +1 -1
  25. package/dist/agentic/guides/modules/communication_channels/index.md +1 -1
  26. package/dist/agentic/guides/modules/configs/index.md +1 -1
  27. package/dist/agentic/guides/modules/content/index.md +1 -1
  28. package/dist/agentic/guides/modules/currencies/index.md +1 -1
  29. package/dist/agentic/guides/modules/customer_accounts/index.md +1 -1
  30. package/dist/agentic/guides/modules/customer_groups/index.md +1 -1
  31. package/dist/agentic/guides/modules/customers/index.md +1 -1
  32. package/dist/agentic/guides/modules/dashboards/index.md +1 -1
  33. package/dist/agentic/guides/modules/data_sync/index.md +1 -1
  34. package/dist/agentic/guides/modules/design_system/index.md +1 -1
  35. package/dist/agentic/guides/modules/devices/index.md +1 -1
  36. package/dist/agentic/guides/modules/dictionaries/index.md +1 -1
  37. package/dist/agentic/guides/modules/directory/index.md +1 -1
  38. package/dist/agentic/guides/modules/documents/index.md +1 -1
  39. package/dist/agentic/guides/modules/ecommerce/index.md +1 -1
  40. package/dist/agentic/guides/modules/entities/index.md +1 -1
  41. package/dist/agentic/guides/modules/eudr/index.md +1 -1
  42. package/dist/agentic/guides/modules/events/index.md +1 -1
  43. package/dist/agentic/guides/modules/feature_toggles/index.md +1 -1
  44. package/dist/agentic/guides/modules/forms/index.md +1 -1
  45. package/dist/agentic/guides/modules/gateway_autopay/index.md +1 -1
  46. package/dist/agentic/guides/modules/gateway_stripe/index.md +1 -1
  47. package/dist/agentic/guides/modules/gateway_tpay/index.md +1 -1
  48. package/dist/agentic/guides/modules/generators/index.md +1 -1
  49. package/dist/agentic/guides/modules/inbox_ops/index.md +1 -1
  50. package/dist/agentic/guides/modules/integrations/index.md +1 -1
  51. package/dist/agentic/guides/modules/messages/index.md +1 -1
  52. package/dist/agentic/guides/modules/notifications/index.md +1 -1
  53. package/dist/agentic/guides/modules/onboarding/index.md +1 -1
  54. package/dist/agentic/guides/modules/payment_gateways/index.md +1 -1
  55. package/dist/agentic/guides/modules/perspectives/index.md +1 -1
  56. package/dist/agentic/guides/modules/phone_calls/index.md +1 -1
  57. package/dist/agentic/guides/modules/planner/index.md +1 -1
  58. package/dist/agentic/guides/modules/portal/index.md +1 -1
  59. package/dist/agentic/guides/modules/progress/index.md +1 -1
  60. package/dist/agentic/guides/modules/promotions/index.md +1 -1
  61. package/dist/agentic/guides/modules/push_notifications/index.md +1 -1
  62. package/dist/agentic/guides/modules/query_index/index.md +1 -1
  63. package/dist/agentic/guides/modules/record_locks/index.md +1 -1
  64. package/dist/agentic/guides/modules/resources/index.md +1 -1
  65. package/dist/agentic/guides/modules/sales/index.md +1 -1
  66. package/dist/agentic/guides/modules/scheduler/index.md +1 -1
  67. package/dist/agentic/guides/modules/search/index.md +1 -1
  68. package/dist/agentic/guides/modules/security/index.md +1 -1
  69. package/dist/agentic/guides/modules/seeds/index.md +1 -1
  70. package/dist/agentic/guides/modules/shipping_carriers/index.md +1 -1
  71. package/dist/agentic/guides/modules/sso/index.md +1 -1
  72. package/dist/agentic/guides/modules/staff/index.md +1 -1
  73. package/dist/agentic/guides/modules/storage_s3/index.md +1 -1
  74. package/dist/agentic/guides/modules/sync_akeneo/index.md +1 -1
  75. package/dist/agentic/guides/modules/sync_excel/index.md +1 -1
  76. package/dist/agentic/guides/modules/system_status_overlays/index.md +1 -1
  77. package/dist/agentic/guides/modules/telemetry/index.md +1 -1
  78. package/dist/agentic/guides/modules/tillio/index.md +1 -1
  79. package/dist/agentic/guides/modules/translations/index.md +1 -1
  80. package/dist/agentic/guides/modules/warranty_claims/index.md +1 -1
  81. package/dist/agentic/guides/modules/webhooks/index.md +1 -1
  82. package/dist/agentic/guides/modules/wms/index.md +1 -1
  83. package/dist/agentic/guides/modules/workflows/index.md +1 -1
  84. package/dist/agentic/guides/reference-module-facts.json +1 -1
  85. package/dist/agentic/guides/upstream/manifest.json +1 -1
  86. package/dist/lib/__integration__/TC-INT-007.spec.js +17 -2
  87. package/dist/lib/__integration__/TC-INT-007.spec.js.map +2 -2
  88. package/dist/lib/modules-config.js +40 -13
  89. package/dist/lib/modules-config.js.map +2 -2
  90. package/package.json +7 -7
  91. package/src/lib/__integration__/TC-INT-007.spec.ts +18 -2
  92. package/src/lib/__tests__/modules-config.test.ts +125 -0
  93. package/src/lib/modules-config.ts +50 -17
@@ -1,5 +1,5 @@
1
1
  # staff — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/core 0.10.1-develop.7752.1.fd7c06569b; core 0.10.1-develop.7752.1.fd7c06569b — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/core 0.10.1-develop.7753.1.61290f530d; core 0.10.1-develop.7753.1.61290f530d — R1 staleness stamp -->
3
3
  Source root: node_modules/@open-mercato/core/src/modules/staff
4
4
 
5
5
  ## Sections
@@ -1,5 +1,5 @@
1
1
  # storage_s3 — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/storage-s3 0.10.1-develop.7752.1.fd7c06569b; core 0.10.1-develop.7752.1.fd7c06569b — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/storage-s3 0.10.1-develop.7753.1.61290f530d; core 0.10.1-develop.7753.1.61290f530d — R1 staleness stamp -->
3
3
  Source root: node_modules/@open-mercato/storage-s3/src/modules/storage_s3
4
4
 
5
5
  ## Sections
@@ -1,5 +1,5 @@
1
1
  # sync_akeneo — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/sync-akeneo 0.10.1-develop.7752.1.fd7c06569b; core 0.10.1-develop.7752.1.fd7c06569b — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/sync-akeneo 0.10.1-develop.7753.1.61290f530d; core 0.10.1-develop.7753.1.61290f530d — R1 staleness stamp -->
3
3
  Source root: node_modules/@open-mercato/sync-akeneo/src/modules/sync_akeneo
4
4
 
5
5
  ## Sections
@@ -1,5 +1,5 @@
1
1
  # sync_excel — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/core 0.10.1-develop.7752.1.fd7c06569b; core 0.10.1-develop.7752.1.fd7c06569b — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/core 0.10.1-develop.7753.1.61290f530d; core 0.10.1-develop.7753.1.61290f530d — R1 staleness stamp -->
3
3
  Source root: node_modules/@open-mercato/core/src/modules/sync_excel
4
4
 
5
5
  ## Sections
@@ -1,5 +1,5 @@
1
1
  # system_status_overlays — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/enterprise 0.10.1-develop.7752.1.fd7c06569b; core 0.10.1-develop.7752.1.fd7c06569b — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/enterprise 0.10.1-develop.7753.1.61290f530d; core 0.10.1-develop.7753.1.61290f530d — R1 staleness stamp -->
3
3
  Source root: node_modules/@open-mercato/enterprise/src/modules/system_status_overlays
4
4
 
5
5
  ## Sections
@@ -1,5 +1,5 @@
1
1
  # telemetry — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/telemetry 0.10.1-develop.7752.1.fd7c06569b; core 0.10.1-develop.7752.1.fd7c06569b — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/telemetry 0.10.1-develop.7753.1.61290f530d; core 0.10.1-develop.7753.1.61290f530d — R1 staleness stamp -->
3
3
  Source root: node_modules/@open-mercato/telemetry/src/modules/telemetry
4
4
 
5
5
  ## Sections
@@ -1,5 +1,5 @@
1
1
  # tillio — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/tillio 0.10.1-develop.7752.1.fd7c06569b; core 0.10.1-develop.7752.1.fd7c06569b — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/tillio 0.10.1-develop.7753.1.61290f530d; core 0.10.1-develop.7753.1.61290f530d — R1 staleness stamp -->
3
3
  Source root: node_modules/@open-mercato/tillio/src/modules/tillio
4
4
 
5
5
  ## Sections
@@ -1,5 +1,5 @@
1
1
  # translations — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/core 0.10.1-develop.7752.1.fd7c06569b; core 0.10.1-develop.7752.1.fd7c06569b — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/core 0.10.1-develop.7753.1.61290f530d; core 0.10.1-develop.7753.1.61290f530d — R1 staleness stamp -->
3
3
  Source root: node_modules/@open-mercato/core/src/modules/translations
4
4
 
5
5
  ## Sections
@@ -1,5 +1,5 @@
1
1
  # warranty_claims — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/core 0.10.1-develop.7752.1.fd7c06569b; core 0.10.1-develop.7752.1.fd7c06569b — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/core 0.10.1-develop.7753.1.61290f530d; core 0.10.1-develop.7753.1.61290f530d — R1 staleness stamp -->
3
3
  Source root: node_modules/@open-mercato/core/src/modules/warranty_claims
4
4
 
5
5
  ## Sections
@@ -1,5 +1,5 @@
1
1
  # webhooks — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/webhooks 0.10.1-develop.7752.1.fd7c06569b; core 0.10.1-develop.7752.1.fd7c06569b — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/webhooks 0.10.1-develop.7753.1.61290f530d; core 0.10.1-develop.7753.1.61290f530d — R1 staleness stamp -->
3
3
  Source root: node_modules/@open-mercato/webhooks/src/modules/webhooks
4
4
 
5
5
  ## Sections
@@ -1,5 +1,5 @@
1
1
  # wms — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/core 0.10.1-develop.7752.1.fd7c06569b; core 0.10.1-develop.7752.1.fd7c06569b — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/core 0.10.1-develop.7753.1.61290f530d; core 0.10.1-develop.7753.1.61290f530d — R1 staleness stamp -->
3
3
  Source root: node_modules/@open-mercato/core/src/modules/wms
4
4
 
5
5
  ## Sections
@@ -1,5 +1,5 @@
1
1
  # workflows — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/core 0.10.1-develop.7752.1.fd7c06569b; core 0.10.1-develop.7752.1.fd7c06569b — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/core 0.10.1-develop.7753.1.61290f530d; core 0.10.1-develop.7753.1.61290f530d — R1 staleness stamp -->
3
3
  Source root: node_modules/@open-mercato/core/src/modules/workflows
4
4
 
5
5
  ## Sections
@@ -1185,7 +1185,7 @@
1185
1185
  "facts": {
1186
1186
  "title": "Example Module",
1187
1187
  "description": "Demonstrates pages, APIs, entities and DI.",
1188
- "coreVersion": "0.10.1-develop.7752.1.fd7c06569b",
1188
+ "coreVersion": "0.10.1-develop.7753.1.61290f530d",
1189
1189
  "sourcePackage": null,
1190
1190
  "sourceVersion": null,
1191
1191
  "sourceRoot": "src/modules/example",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 1,
3
- "generator": "@open-mercato/cli@0.10.1-develop.7752.1.fd7c06569b",
3
+ "generator": "@open-mercato/cli@0.10.1-develop.7753.1.61290f530d",
4
4
  "files": {
5
5
  "AGENTS.md": "b27342ee5f61e805ba52703fdb7ec822b030490f734b4d80f48dfd1e05fa4cf5",
6
6
  "BACKWARD_COMPATIBILITY.md": "bac9a78af24b35909285d6d52f411d72aa5469204d9f434e9d5b5590ba7edfec"
@@ -58,6 +58,16 @@ function createCoreWorkspacePackage(rootDir, relativeDir) {
58
58
  );
59
59
  return coreDir;
60
60
  }
61
+ const commentedModulesSource = [
62
+ "// Central place to enable modules.",
63
+ "export const enabledModules = [",
64
+ " // customer_groups stays disabled by default.",
65
+ " // { id: 'customer_groups', from: '@open-mercato/core' },",
66
+ "",
67
+ " /* Block comment kept by module add. */",
68
+ "]",
69
+ ""
70
+ ].join("\n");
61
71
  function createMonorepoFixture(rootDir) {
62
72
  writeFile(
63
73
  path.join(rootDir, "package.json"),
@@ -89,7 +99,7 @@ function createMonorepoFixture(rootDir) {
89
99
  2
90
100
  )
91
101
  );
92
- writeFile(path.join(appDir, "src", "modules.ts"), "export const enabledModules = []\n");
102
+ writeFile(path.join(appDir, "src", "modules.ts"), commentedModulesSource);
93
103
  return appDir;
94
104
  }
95
105
  function createStandaloneFixture(rootDir) {
@@ -135,7 +145,12 @@ test.describe("TC-INT-007: CLI official module install and eject flows", () => {
135
145
  const modulesSource = readFile(path.join(appDir, "src", "modules.ts"));
136
146
  const cssSource = readFile(path.join(appDir, ".mercato", "generated", "module-package-sources.css"));
137
147
  const appPackageJson = JSON.parse(readFile(path.join(appDir, "package.json")));
138
- expect(modulesSource).toContain("{ id: 'test_package', from: '@open-mercato/test-package' }");
148
+ expect(modulesSource).toBe(
149
+ commentedModulesSource.replace(
150
+ " /* Block comment kept by module add. */\n",
151
+ " /* Block comment kept by module add. */\n { id: 'test_package', from: '@open-mercato/test-package' },\n"
152
+ )
153
+ );
139
154
  expect(cssSource).toContain("node_modules/@open-mercato/test-package/src/**/*.{ts,tsx}");
140
155
  expect(appPackageJson.dependencies?.["@open-mercato/test-package"]).toBeTruthy();
141
156
  } finally {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/lib/__integration__/TC-INT-007.spec.ts"],
4
- "sourcesContent": ["import { expect, test } from '@playwright/test'\nimport { execFileSync } from 'node:child_process'\nimport fs from 'node:fs'\nimport os from 'node:os'\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url))\nconst repoRoot = path.resolve(__dirname, '..', '..', '..', '..', '..')\nconst cliBin = path.join(repoRoot, 'packages', 'cli', 'dist', 'bin.js')\nconst fixtureModulePackage = path.join(\n repoRoot,\n 'packages',\n 'cli',\n 'src',\n 'lib',\n '__fixtures__',\n 'official-module-package',\n)\n\nfunction yarnBinary(): string {\n return process.platform === 'win32' ? 'yarn.cmd' : 'yarn'\n}\n\nfunction runCommand(command: string, args: string[], cwd: string): string {\n const yarnCacheFolder = path.join(cwd, '.yarn', 'cache')\n return execFileSync(command, args, {\n cwd,\n encoding: 'utf8',\n env: {\n ...process.env,\n FORCE_COLOR: '0',\n NODE_NO_WARNINGS: '1',\n YARN_CACHE_FOLDER: yarnCacheFolder,\n YARN_ENABLE_GLOBAL_CACHE: '0',\n YARN_ENABLE_IMMUTABLE_INSTALLS: '0',\n YARN_NODE_LINKER: 'node-modules',\n },\n })\n}\n\nfunction runMercato(args: string[], cwd: string): string {\n return runCommand(process.execPath, [cliBin, ...args], cwd)\n}\n\nfunction writeFile(filePath: string, content: string): void {\n fs.mkdirSync(path.dirname(filePath), { recursive: true })\n fs.writeFileSync(filePath, content)\n}\n\nfunction createCoreWorkspacePackage(rootDir: string, relativeDir: string): string {\n const coreDir = path.join(rootDir, relativeDir)\n writeFile(\n path.join(coreDir, 'package.json'),\n JSON.stringify(\n {\n name: '@open-mercato/core',\n version: '0.4.7',\n type: 'module',\n },\n null,\n 2,\n ),\n )\n return coreDir\n}\n\nfunction createMonorepoFixture(rootDir: string): string {\n writeFile(\n path.join(rootDir, 'package.json'),\n JSON.stringify(\n {\n name: 'cli-module-monorepo-fixture',\n private: true,\n workspaces: ['apps/*', 'packages/*'],\n },\n null,\n 2,\n ),\n )\n writeFile(\n path.join(rootDir, '.yarnrc.yml'),\n ['nodeLinker: node-modules', 'enableGlobalCache: false', 'cacheFolder: ./.yarn/cache', ''].join('\\n'),\n )\n createCoreWorkspacePackage(rootDir, path.join('packages', 'core'))\n\n const appDir = path.join(rootDir, 'apps', 'mercato')\n writeFile(\n path.join(appDir, 'package.json'),\n JSON.stringify(\n {\n name: '@open-mercato/app',\n version: '0.0.0',\n private: true,\n },\n null,\n 2,\n ),\n )\n writeFile(path.join(appDir, 'src', 'modules.ts'), 'export const enabledModules = []\\n')\n return appDir\n}\n\nfunction createStandaloneFixture(rootDir: string): string {\n writeFile(\n path.join(rootDir, '.yarnrc.yml'),\n ['nodeLinker: node-modules', 'enableGlobalCache: false', 'cacheFolder: ./.yarn/cache', ''].join('\\n'),\n )\n createCoreWorkspacePackage(rootDir, path.join('vendor', 'core'))\n writeFile(\n path.join(rootDir, 'package.json'),\n JSON.stringify(\n {\n name: 'cli-module-standalone-fixture',\n private: true,\n dependencies: {\n '@open-mercato/core': 'file:./vendor/core',\n },\n },\n null,\n 2,\n ),\n )\n writeFile(path.join(rootDir, 'src', 'modules.ts'), 'export const enabledModules = []\\n')\n return rootDir\n}\n\nfunction readFile(filePath: string): string {\n return fs.readFileSync(filePath, 'utf8')\n}\n\ntest.describe('TC-INT-007: CLI official module install and eject flows', () => {\n test('module add installs and registers a package-backed module in a monorepo app', () => {\n const rootDir = fs.mkdtempSync(path.join(os.tmpdir(), 'mercato-cli-monorepo-'))\n\n try {\n const appDir = createMonorepoFixture(rootDir)\n runCommand(yarnBinary(), ['install'], rootDir)\n\n runMercato(\n [\n 'module',\n 'add',\n `@open-mercato/test-package@file:${fixtureModulePackage}`,\n ],\n rootDir,\n )\n\n const modulesSource = readFile(path.join(appDir, 'src', 'modules.ts'))\n const cssSource = readFile(path.join(appDir, '.mercato', 'generated', 'module-package-sources.css'))\n const appPackageJson = JSON.parse(readFile(path.join(appDir, 'package.json'))) as {\n dependencies?: Record<string, string>\n }\n\n expect(modulesSource).toContain(\"{ id: 'test_package', from: '@open-mercato/test-package' }\")\n expect(cssSource).toContain('node_modules/@open-mercato/test-package/src/**/*.{ts,tsx}')\n expect(appPackageJson.dependencies?.['@open-mercato/test-package']).toBeTruthy()\n } finally {\n fs.rmSync(rootDir, { recursive: true, force: true })\n }\n })\n\n test('module add --eject copies module source and omits package CSS entries', () => {\n const appDir = fs.mkdtempSync(path.join(os.tmpdir(), 'mercato-cli-standalone-source-'))\n\n try {\n createStandaloneFixture(appDir)\n runCommand(yarnBinary(), ['install'], appDir)\n\n runMercato(\n [\n 'module',\n 'add',\n `@open-mercato/test-package@file:${fixtureModulePackage}`,\n '--eject',\n ],\n appDir,\n )\n\n const modulesSource = readFile(path.join(appDir, 'src', 'modules.ts'))\n const cssSource = readFile(path.join(appDir, '.mercato', 'generated', 'module-package-sources.css'))\n\n expect(modulesSource).toContain(\"{ id: 'test_package', from: '@app' }\")\n expect(fs.existsSync(path.join(appDir, 'src', 'modules', 'test_package', 'index.ts'))).toBe(true)\n expect(cssSource).toBe('')\n } finally {\n fs.rmSync(appDir, { recursive: true, force: true })\n }\n })\n\n test('module enable supports package-backed and ejected flows plus both eject entrypoints', () => {\n const appDir = fs.mkdtempSync(path.join(os.tmpdir(), 'mercato-cli-standalone-eject-'))\n\n try {\n createStandaloneFixture(appDir)\n runCommand(yarnBinary(), ['install'], appDir)\n runCommand(\n yarnBinary(),\n ['add', `@open-mercato/test-package@file:${fixtureModulePackage}`],\n appDir,\n )\n\n runMercato(['module', 'enable', '@open-mercato/test-package'], appDir)\n expect(readFile(path.join(appDir, 'src', 'modules.ts'))).toContain(\n \"{ id: 'test_package', from: '@open-mercato/test-package' }\",\n )\n\n writeFile(path.join(appDir, 'src', 'modules.ts'), 'export const enabledModules = []\\n')\n fs.rmSync(path.join(appDir, 'src', 'modules', 'test_package'), { recursive: true, force: true })\n runMercato(['module', 'enable', '@open-mercato/test-package', '--eject'], appDir)\n expect(readFile(path.join(appDir, 'src', 'modules.ts'))).toContain(\"{ id: 'test_package', from: '@app' }\")\n expect(fs.existsSync(path.join(appDir, 'src', 'modules', 'test_package', 'index.ts'))).toBe(true)\n expect(readFile(path.join(appDir, '.mercato', 'generated', 'module-package-sources.css'))).toBe('')\n\n writeFile(path.join(appDir, 'src', 'modules.ts'), \"export const enabledModules = [{ id: 'test_package', from: '@open-mercato/test-package' }]\\n\")\n fs.rmSync(path.join(appDir, 'src', 'modules', 'test_package'), { recursive: true, force: true })\n runMercato(['module', 'eject', 'test_package'], appDir)\n expect(readFile(path.join(appDir, 'src', 'modules.ts'))).toContain(\"{ id: 'test_package', from: '@app' }\")\n\n writeFile(path.join(appDir, 'src', 'modules.ts'), \"export const enabledModules = [{ id: 'test_package', from: '@open-mercato/test-package' }]\\n\")\n fs.rmSync(path.join(appDir, 'src', 'modules', 'test_package'), { recursive: true, force: true })\n runMercato(['eject', 'test_package'], appDir)\n expect(readFile(path.join(appDir, 'src', 'modules.ts'))).toContain(\"{ id: 'test_package', from: '@app' }\")\n } finally {\n fs.rmSync(appDir, { recursive: true, force: true })\n }\n })\n})\n"],
5
- "mappings": "AAAA,SAAS,QAAQ,YAAY;AAC7B,SAAS,oBAAoB;AAC7B,OAAO,QAAQ;AACf,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAE9B,MAAM,YAAY,KAAK,QAAQ,cAAc,YAAY,GAAG,CAAC;AAC7D,MAAM,WAAW,KAAK,QAAQ,WAAW,MAAM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AAS,cAAc,GAAG,MAAM;AACtD,aAAO,SAAS,KAAK,KAAK,QAAQ,OAAO,YAAY,CAAC,CAAC,EAAE,UAAU,sCAAsC;AAEzG,gBAAU,KAAK,KAAK,QAAQ,OAAO,YAAY,GAAG,8FAA8F;AAChJ,SAAG,OAAO,KAAK,KAAK,QAAQ,OAAO,WAAW,cAAc,GAAG,EAAE,WAAW,MAAM,OAAO,KAAK,CAAC;AAC/F,iBAAW,CAAC,SAAS,cAAc,GAAG,MAAM;AAC5C,aAAO,SAAS,KAAK,KAAK,QAAQ,OAAO,YAAY,CAAC,CAAC,EAAE,UAAU,sCAAsC;AAAA,IAC3G,UAAE;AACA,SAAG,OAAO,QAAQ,EAAE,WAAW,MAAM,OAAO,KAAK,CAAC;AAAA,IACpD;AAAA,EACF,CAAC;AACH,CAAC;",
4
+ "sourcesContent": ["import { expect, test } from '@playwright/test'\nimport { execFileSync } from 'node:child_process'\nimport fs from 'node:fs'\nimport os from 'node:os'\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url))\nconst repoRoot = path.resolve(__dirname, '..', '..', '..', '..', '..')\nconst cliBin = path.join(repoRoot, 'packages', 'cli', 'dist', 'bin.js')\nconst fixtureModulePackage = path.join(\n repoRoot,\n 'packages',\n 'cli',\n 'src',\n 'lib',\n '__fixtures__',\n 'official-module-package',\n)\n\nfunction yarnBinary(): string {\n return process.platform === 'win32' ? 'yarn.cmd' : 'yarn'\n}\n\nfunction runCommand(command: string, args: string[], cwd: string): string {\n const yarnCacheFolder = path.join(cwd, '.yarn', 'cache')\n return execFileSync(command, args, {\n cwd,\n encoding: 'utf8',\n env: {\n ...process.env,\n FORCE_COLOR: '0',\n NODE_NO_WARNINGS: '1',\n YARN_CACHE_FOLDER: yarnCacheFolder,\n YARN_ENABLE_GLOBAL_CACHE: '0',\n YARN_ENABLE_IMMUTABLE_INSTALLS: '0',\n YARN_NODE_LINKER: 'node-modules',\n },\n })\n}\n\nfunction runMercato(args: string[], cwd: string): string {\n return runCommand(process.execPath, [cliBin, ...args], cwd)\n}\n\nfunction writeFile(filePath: string, content: string): void {\n fs.mkdirSync(path.dirname(filePath), { recursive: true })\n fs.writeFileSync(filePath, content)\n}\n\nfunction createCoreWorkspacePackage(rootDir: string, relativeDir: string): string {\n const coreDir = path.join(rootDir, relativeDir)\n writeFile(\n path.join(coreDir, 'package.json'),\n JSON.stringify(\n {\n name: '@open-mercato/core',\n version: '0.4.7',\n type: 'module',\n },\n null,\n 2,\n ),\n )\n return coreDir\n}\n\nconst commentedModulesSource = [\n '// Central place to enable modules.',\n 'export const enabledModules = [',\n ' // customer_groups stays disabled by default.',\n \" // { id: 'customer_groups', from: '@open-mercato/core' },\",\n '',\n ' /* Block comment kept by module add. */',\n ']',\n '',\n].join('\\n')\n\nfunction createMonorepoFixture(rootDir: string): string {\n writeFile(\n path.join(rootDir, 'package.json'),\n JSON.stringify(\n {\n name: 'cli-module-monorepo-fixture',\n private: true,\n workspaces: ['apps/*', 'packages/*'],\n },\n null,\n 2,\n ),\n )\n writeFile(\n path.join(rootDir, '.yarnrc.yml'),\n ['nodeLinker: node-modules', 'enableGlobalCache: false', 'cacheFolder: ./.yarn/cache', ''].join('\\n'),\n )\n createCoreWorkspacePackage(rootDir, path.join('packages', 'core'))\n\n const appDir = path.join(rootDir, 'apps', 'mercato')\n writeFile(\n path.join(appDir, 'package.json'),\n JSON.stringify(\n {\n name: '@open-mercato/app',\n version: '0.0.0',\n private: true,\n },\n null,\n 2,\n ),\n )\n writeFile(path.join(appDir, 'src', 'modules.ts'), commentedModulesSource)\n return appDir\n}\n\nfunction createStandaloneFixture(rootDir: string): string {\n writeFile(\n path.join(rootDir, '.yarnrc.yml'),\n ['nodeLinker: node-modules', 'enableGlobalCache: false', 'cacheFolder: ./.yarn/cache', ''].join('\\n'),\n )\n createCoreWorkspacePackage(rootDir, path.join('vendor', 'core'))\n writeFile(\n path.join(rootDir, 'package.json'),\n JSON.stringify(\n {\n name: 'cli-module-standalone-fixture',\n private: true,\n dependencies: {\n '@open-mercato/core': 'file:./vendor/core',\n },\n },\n null,\n 2,\n ),\n )\n writeFile(path.join(rootDir, 'src', 'modules.ts'), 'export const enabledModules = []\\n')\n return rootDir\n}\n\nfunction readFile(filePath: string): string {\n return fs.readFileSync(filePath, 'utf8')\n}\n\ntest.describe('TC-INT-007: CLI official module install and eject flows', () => {\n test('module add installs and registers a package-backed module in a monorepo app', () => {\n const rootDir = fs.mkdtempSync(path.join(os.tmpdir(), 'mercato-cli-monorepo-'))\n\n try {\n const appDir = createMonorepoFixture(rootDir)\n runCommand(yarnBinary(), ['install'], rootDir)\n\n runMercato(\n [\n 'module',\n 'add',\n `@open-mercato/test-package@file:${fixtureModulePackage}`,\n ],\n rootDir,\n )\n\n const modulesSource = readFile(path.join(appDir, 'src', 'modules.ts'))\n const cssSource = readFile(path.join(appDir, '.mercato', 'generated', 'module-package-sources.css'))\n const appPackageJson = JSON.parse(readFile(path.join(appDir, 'package.json'))) as {\n dependencies?: Record<string, string>\n }\n\n expect(modulesSource).toBe(\n commentedModulesSource.replace(\n ' /* Block comment kept by module add. */\\n',\n \" /* Block comment kept by module add. */\\n { id: 'test_package', from: '@open-mercato/test-package' },\\n\",\n ),\n )\n expect(cssSource).toContain('node_modules/@open-mercato/test-package/src/**/*.{ts,tsx}')\n expect(appPackageJson.dependencies?.['@open-mercato/test-package']).toBeTruthy()\n } finally {\n fs.rmSync(rootDir, { recursive: true, force: true })\n }\n })\n\n test('module add --eject copies module source and omits package CSS entries', () => {\n const appDir = fs.mkdtempSync(path.join(os.tmpdir(), 'mercato-cli-standalone-source-'))\n\n try {\n createStandaloneFixture(appDir)\n runCommand(yarnBinary(), ['install'], appDir)\n\n runMercato(\n [\n 'module',\n 'add',\n `@open-mercato/test-package@file:${fixtureModulePackage}`,\n '--eject',\n ],\n appDir,\n )\n\n const modulesSource = readFile(path.join(appDir, 'src', 'modules.ts'))\n const cssSource = readFile(path.join(appDir, '.mercato', 'generated', 'module-package-sources.css'))\n\n expect(modulesSource).toContain(\"{ id: 'test_package', from: '@app' }\")\n expect(fs.existsSync(path.join(appDir, 'src', 'modules', 'test_package', 'index.ts'))).toBe(true)\n expect(cssSource).toBe('')\n } finally {\n fs.rmSync(appDir, { recursive: true, force: true })\n }\n })\n\n test('module enable supports package-backed and ejected flows plus both eject entrypoints', () => {\n const appDir = fs.mkdtempSync(path.join(os.tmpdir(), 'mercato-cli-standalone-eject-'))\n\n try {\n createStandaloneFixture(appDir)\n runCommand(yarnBinary(), ['install'], appDir)\n runCommand(\n yarnBinary(),\n ['add', `@open-mercato/test-package@file:${fixtureModulePackage}`],\n appDir,\n )\n\n runMercato(['module', 'enable', '@open-mercato/test-package'], appDir)\n expect(readFile(path.join(appDir, 'src', 'modules.ts'))).toContain(\n \"{ id: 'test_package', from: '@open-mercato/test-package' }\",\n )\n\n writeFile(path.join(appDir, 'src', 'modules.ts'), 'export const enabledModules = []\\n')\n fs.rmSync(path.join(appDir, 'src', 'modules', 'test_package'), { recursive: true, force: true })\n runMercato(['module', 'enable', '@open-mercato/test-package', '--eject'], appDir)\n expect(readFile(path.join(appDir, 'src', 'modules.ts'))).toContain(\"{ id: 'test_package', from: '@app' }\")\n expect(fs.existsSync(path.join(appDir, 'src', 'modules', 'test_package', 'index.ts'))).toBe(true)\n expect(readFile(path.join(appDir, '.mercato', 'generated', 'module-package-sources.css'))).toBe('')\n\n writeFile(path.join(appDir, 'src', 'modules.ts'), \"export const enabledModules = [{ id: 'test_package', from: '@open-mercato/test-package' }]\\n\")\n fs.rmSync(path.join(appDir, 'src', 'modules', 'test_package'), { recursive: true, force: true })\n runMercato(['module', 'eject', 'test_package'], appDir)\n expect(readFile(path.join(appDir, 'src', 'modules.ts'))).toContain(\"{ id: 'test_package', from: '@app' }\")\n\n writeFile(path.join(appDir, 'src', 'modules.ts'), \"export const enabledModules = [{ id: 'test_package', from: '@open-mercato/test-package' }]\\n\")\n fs.rmSync(path.join(appDir, 'src', 'modules', 'test_package'), { recursive: true, force: true })\n runMercato(['eject', 'test_package'], appDir)\n expect(readFile(path.join(appDir, 'src', 'modules.ts'))).toContain(\"{ id: 'test_package', from: '@app' }\")\n } finally {\n fs.rmSync(appDir, { recursive: true, force: true })\n }\n })\n})\n"],
5
+ "mappings": "AAAA,SAAS,QAAQ,YAAY;AAC7B,SAAS,oBAAoB;AAC7B,OAAO,QAAQ;AACf,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAE9B,MAAM,YAAY,KAAK,QAAQ,cAAc,YAAY,GAAG,CAAC;AAC7D,MAAM,WAAW,KAAK,QAAQ,WAAW,MAAM,MAAM,MAAM,MAAM,IAAI;AACrE,MAAM,SAAS,KAAK,KAAK,UAAU,YAAY,OAAO,QAAQ,QAAQ;AACtE,MAAM,uBAAuB,KAAK;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,SAAS,aAAqB;AAC5B,SAAO,QAAQ,aAAa,UAAU,aAAa;AACrD;AAEA,SAAS,WAAW,SAAiB,MAAgB,KAAqB;AACxE,QAAM,kBAAkB,KAAK,KAAK,KAAK,SAAS,OAAO;AACvD,SAAO,aAAa,SAAS,MAAM;AAAA,IACjC;AAAA,IACA,UAAU;AAAA,IACV,KAAK;AAAA,MACH,GAAG,QAAQ;AAAA,MACX,aAAa;AAAA,MACb,kBAAkB;AAAA,MAClB,mBAAmB;AAAA,MACnB,0BAA0B;AAAA,MAC1B,gCAAgC;AAAA,MAChC,kBAAkB;AAAA,IACpB;AAAA,EACF,CAAC;AACH;AAEA,SAAS,WAAW,MAAgB,KAAqB;AACvD,SAAO,WAAW,QAAQ,UAAU,CAAC,QAAQ,GAAG,IAAI,GAAG,GAAG;AAC5D;AAEA,SAAS,UAAU,UAAkB,SAAuB;AAC1D,KAAG,UAAU,KAAK,QAAQ,QAAQ,GAAG,EAAE,WAAW,KAAK,CA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
213
- function replaceArrayLiteral(source, arrayNode, entry, sourceFile) {
214
- const existingElements = arrayNode.elements.map(
215
- (element) => source.slice(element.getStart(sourceFile), element.end).trim()
216
- );
217
- const closingIndent = lineIndentAt(source, arrayNode.end - 1);
218
- const elementIndent = arrayNode.elements.length > 0 ? lineIndentAt(source, arrayNode.elements[0].getStart(sourceFile)) : `${closingIndent} `;
219
- const updatedArray = [
220
- "[",
221
- ...[...existingElements, buildModuleEntryLiteral(entry)].map((value) => `${elementIndent}${value},`),
222
- `${closingIndent}]`
223
- ].join("\n");
224
- return source.slice(0, arrayNode.getStart(sourceFile)) + updatedArray + source.slice(arrayNode.end);
213
+ function nextTokenEnd(source, position) {
214
+ const scanner = ts.createScanner(ts.ScriptTarget.Latest, true, ts.LanguageVariant.Standard, source);
215
+ scanner.resetTokenState(position);
216
+ scanner.scan();
217
+ return scanner.getTokenEnd();
218
+ }
219
+ function trailingCommentsEnd(source, position) {
220
+ const ranges = ts.getTrailingCommentRanges(source, position) ?? [];
221
+ return ranges.length > 0 ? ranges[ranges.length - 1].end : position;
222
+ }
223
+ function insertArrayElement(source, arrayNode, entry, sourceFile) {
224
+ const newline = source.includes("\r\n") ? "\r\n" : "\n";
225
+ const entryLiteral = buildModuleEntryLiteral(entry);
226
+ const openingBracket = arrayNode.getStart(sourceFile);
227
+ const closingBracket = arrayNode.end - 1;
228
+ const openingIndent = lineIndentAt(source, openingBracket);
229
+ const lastElement = arrayNode.elements[arrayNode.elements.length - 1];
230
+ let head;
231
+ let insertAt;
232
+ let insertion;
233
+ if (!lastElement) {
234
+ const innerContent = source.slice(openingBracket + 1, closingBracket).trimEnd();
235
+ insertAt = openingBracket + 1 + innerContent.length;
236
+ head = source.slice(0, insertAt);
237
+ insertion = `${newline}${openingIndent} ${entryLiteral},`;
238
+ } else {
239
+ const hasTrailingComma = arrayNode.elements.hasTrailingComma;
240
+ const anchor = hasTrailingComma ? nextTokenEnd(source, lastElement.end) : lastElement.end;
241
+ insertAt = trailingCommentsEnd(source, anchor);
242
+ head = hasTrailingComma ? source.slice(0, insertAt) : `${source.slice(0, anchor)},${source.slice(anchor, insertAt)}`;
243
+ const lastElementStart = lastElement.getStart(sourceFile);
244
+ const startsOnOpeningLine = !source.slice(openingBracket, lastElementStart).includes("\n");
245
+ const elementIndent = startsOnOpeningLine ? `${openingIndent} ` : lineIndentAt(source, lastElementStart);
246
+ insertion = `${newline}${elementIndent}${entryLiteral}${hasTrailingComma ? "," : ""}`;
247
+ }
248
+ const closesOnSameLine = !source.slice(insertAt, closingBracket).includes("\n");
249
+ const closingLine = closesOnSameLine ? `${newline}${openingIndent}` : "";
250
+ const tail = closesOnSameLine ? source.slice(closingBracket) : source.slice(insertAt);
251
+ return head + insertion + closingLine + tail;
225
252
  }
226
253
  function upsertModuleSource(objectLiteral, from) {
227
254
  if (/from\s*:\s*'[^']*'/.test(objectLiteral)) {
@@ -255,7 +282,7 @@ function ensureModuleRegistration(modulesPath, entry) {
255
282
  `Module "${normalized.id}" is already registered from "${existing.from}". Remove or eject the existing registration first.`
256
283
  );
257
284
  }
258
- const updated = replaceArrayLiteral(source, config.arrayNode, normalized, sourceFile);
285
+ const updated = insertArrayElement(source, config.arrayNode, normalized, sourceFile);
259
286
  fs.writeFileSync(modulesPath, updated);
260
287
  return { changed: true, registeredAs: normalized.from ?? "@open-mercato/core" };
261
288
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/lib/modules-config.ts"],
4
- "sourcesContent": ["import fs from 'node:fs'\nimport ts from 'typescript-js'\nimport { parseBooleanWithDefault } from '@open-mercato/shared/lib/boolean'\n\nexport type ModuleEntry = {\n id: string\n from?: '@open-mercato/core' | '@app' | string\n}\n\ntype ModuleOccurrence = {\n entry: ModuleEntry\n node: ts.ObjectLiteralExpression\n}\n\ntype ModuleConfigShape = {\n arrayNode: ts.ArrayLiteralExpression\n occurrences: ModuleOccurrence[]\n}\n\nfunction parseModuleEntryFromObjectLiteral(node: ts.ObjectLiteralExpression): ModuleEntry | null {\n let id: string | null = null\n let from: string | null = null\n\n for (const property of node.properties) {\n if (!ts.isPropertyAssignment(property) || !ts.isIdentifier(property.name)) continue\n\n if (property.name.text === 'id' && ts.isStringLiteralLike(property.initializer)) {\n id = property.initializer.text\n }\n\n if (property.name.text === 'from' && ts.isStringLiteralLike(property.initializer)) {\n from = property.initializer.text\n }\n }\n\n if (!id) return null\n\n return {\n id,\n from: from ?? '@open-mercato/core',\n }\n}\n\nfunction parseProcessEnvAccess(\n node: ts.Expression,\n env: NodeJS.ProcessEnv,\n): { matched: boolean; value: string | undefined } {\n if (ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.name)) {\n const target = node.expression\n if (\n ts.isPropertyAccessExpression(target)\n && ts.isIdentifier(target.expression)\n && target.expression.text === 'process'\n && target.name.text === 'env'\n ) {\n return { matched: true, value: env[node.name.text] }\n }\n }\n\n if (\n ts.isElementAccessExpression(node)\n && ts.isPropertyAccessExpression(node.expression)\n && ts.isIdentifier(node.expression.expression)\n && node.expression.expression.text === 'process'\n && node.expression.name.text === 'env'\n && ts.isStringLiteralLike(node.argumentExpression)\n ) {\n return { matched: true, value: env[node.argumentExpression.text] }\n }\n\n return { matched: false, value: undefined }\n}\n\nfunction evaluateStaticExpressionWithScope(\n node: ts.Expression,\n env: NodeJS.ProcessEnv,\n scope: Map<string, unknown>,\n): unknown {\n if (ts.isParenthesizedExpression(node)) {\n return evaluateStaticExpressionWithScope(node.expression, env, scope)\n }\n\n if (ts.isIdentifier(node)) {\n return scope.get(node.text)\n }\n\n if (ts.isStringLiteralLike(node) || ts.isNoSubstitutionTemplateLiteral(node)) {\n return node.text\n }\n\n if (ts.isNumericLiteral(node)) {\n return Number(node.text)\n }\n\n if (node.kind === ts.SyntaxKind.TrueKeyword) return true\n if (node.kind === ts.SyntaxKind.FalseKeyword) return false\n if (node.kind === ts.SyntaxKind.NullKeyword) return null\n\n const envAccess = parseProcessEnvAccess(node, env)\n if (envAccess.matched) {\n return envAccess.value\n }\n\n if (ts.isPropertyAccessExpression(node)) {\n const target = evaluateStaticExpressionWithScope(node.expression, env, scope)\n if (target && typeof target === 'object' && node.name.text in target) {\n return (target as Record<string, unknown>)[node.name.text]\n }\n return undefined\n }\n\n if (ts.isPrefixUnaryExpression(node) && node.operator === ts.SyntaxKind.ExclamationToken) {\n return !Boolean(evaluateStaticExpressionWithScope(node.operand, env, scope))\n }\n\n if (ts.isBinaryExpression(node)) {\n if (node.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken) {\n return Boolean(evaluateStaticExpressionWithScope(node.left, env, scope))\n && Boolean(evaluateStaticExpressionWithScope(node.right, env, scope))\n }\n\n if (node.operatorToken.kind === ts.SyntaxKind.BarBarToken) {\n return Boolean(evaluateStaticExpressionWithScope(node.left, env, scope))\n || Boolean(evaluateStaticExpressionWithScope(node.right, env, scope))\n }\n\n if (node.operatorToken.kind === ts.SyntaxKind.EqualsEqualsEqualsToken) {\n return evaluateStaticExpressionWithScope(node.left, env, scope)\n === evaluateStaticExpressionWithScope(node.right, env, scope)\n }\n\n if (node.operatorToken.kind === ts.SyntaxKind.ExclamationEqualsEqualsToken) {\n return evaluateStaticExpressionWithScope(node.left, env, scope)\n !== evaluateStaticExpressionWithScope(node.right, env, scope)\n }\n }\n\n if (\n ts.isCallExpression(node)\n && ts.isIdentifier(node.expression)\n && node.expression.text === 'parseBooleanWithDefault'\n ) {\n const rawValueNode = node.arguments[0]\n const fallbackNode = node.arguments[1]\n const rawValue = rawValueNode\n ? evaluateStaticExpressionWithScope(rawValueNode, env, scope)\n : undefined\n const fallbackValue = fallbackNode\n ? evaluateStaticExpressionWithScope(fallbackNode, env, scope)\n : false\n\n return parseBooleanWithDefault(\n typeof rawValue === 'string' ? rawValue : undefined,\n Boolean(fallbackValue),\n )\n }\n\n if (\n ts.isCallExpression(node)\n && ts.isPropertyAccessExpression(node.expression)\n && node.expression.name.text === 'some'\n ) {\n const target = evaluateStaticExpressionWithScope(node.expression.expression, env, scope)\n const predicate = node.arguments[0]\n if (!Array.isArray(target) || !predicate) {\n return undefined\n }\n\n return target.some((entry) => {\n if (!ts.isArrowFunction(predicate) && !ts.isFunctionExpression(predicate)) {\n return false\n }\n\n const localScope = new Map(scope)\n const parameter = predicate.parameters[0]\n if (parameter && ts.isIdentifier(parameter.name)) {\n localScope.set(parameter.name.text, entry)\n }\n\n if (ts.isBlock(predicate.body)) {\n const returnStatement = predicate.body.statements.find((statement): statement is ts.ReturnStatement =>\n ts.isReturnStatement(statement),\n )\n if (!returnStatement?.expression) {\n return false\n }\n return Boolean(evaluateStaticExpressionWithScope(returnStatement.expression, env, localScope))\n }\n\n return Boolean(evaluateStaticExpressionWithScope(predicate.body, env, localScope))\n })\n }\n\n return undefined\n}\n\nfunction evaluateStaticCondition(\n node: ts.Expression,\n env: NodeJS.ProcessEnv,\n scope: Map<string, unknown>,\n): boolean {\n return Boolean(evaluateStaticExpressionWithScope(node, env, scope))\n}\n\nfunction collectPushEntriesFromStatement(\n statement: ts.Statement,\n env: NodeJS.ProcessEnv,\n targetVariableName: string,\n scope: Map<string, unknown>,\n): ModuleOccurrence[] {\n if (ts.isBlock(statement)) {\n return statement.statements.flatMap((child) =>\n collectPushEntriesFromStatement(child, env, targetVariableName, scope),\n )\n }\n\n if (ts.isIfStatement(statement)) {\n if (evaluateStaticCondition(statement.expression, env, scope)) {\n return collectPushEntriesFromStatement(statement.thenStatement, env, targetVariableName, scope)\n }\n\n if (statement.elseStatement) {\n return collectPushEntriesFromStatement(statement.elseStatement, env, targetVariableName, scope)\n }\n\n return []\n }\n\n if (!ts.isExpressionStatement(statement)) return []\n\n const expression = statement.expression\n if (!ts.isCallExpression(expression) || !ts.isPropertyAccessExpression(expression.expression)) {\n return []\n }\n\n const pushTarget = expression.expression.expression\n const pushMethod = expression.expression.name\n\n if (!ts.isIdentifier(pushTarget) || pushTarget.text !== targetVariableName || pushMethod.text !== 'push') {\n return []\n }\n\n return expression.arguments.flatMap((argument) => {\n if (!ts.isObjectLiteralExpression(argument)) return []\n const entry = parseModuleEntryFromObjectLiteral(argument)\n return entry ? [{ entry, node: argument }] : []\n })\n}\n\nfunction parseModuleConfigShape(\n source: string,\n env: NodeJS.ProcessEnv = process.env,\n): ModuleConfigShape {\n const sourceFile = ts.createSourceFile('modules.ts', source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS)\n const variableName = 'enabledModules'\n const occurrences: ModuleOccurrence[] = []\n const scope = new Map<string, unknown>()\n let arrayNode: ts.ArrayLiteralExpression | null = null\n let foundDeclaration = false\n\n for (const statement of sourceFile.statements) {\n if (ts.isVariableStatement(statement)) {\n for (const declaration of statement.declarationList.declarations) {\n if (!ts.isIdentifier(declaration.name)) continue\n\n if (declaration.name.text === variableName) {\n if (!declaration.initializer || !ts.isArrayLiteralExpression(declaration.initializer)) continue\n\n arrayNode = declaration.initializer\n occurrences.push(...declaration.initializer.elements.flatMap((element) => {\n if (!ts.isObjectLiteralExpression(element)) return []\n const entry = parseModuleEntryFromObjectLiteral(element)\n return entry ? [{ entry, node: element }] : []\n }))\n scope.set(variableName, occurrences.map((occurrence) => occurrence.entry))\n foundDeclaration = true\n continue\n }\n\n if (!declaration.initializer) continue\n\n scope.set(\n declaration.name.text,\n evaluateStaticExpressionWithScope(declaration.initializer, env, scope),\n )\n }\n continue\n }\n\n if (!foundDeclaration) continue\n\n const pushedOccurrences = collectPushEntriesFromStatement(statement, env, variableName, scope)\n if (pushedOccurrences.length > 0) {\n occurrences.push(...pushedOccurrences)\n scope.set(variableName, occurrences.map((occurrence) => occurrence.entry))\n }\n }\n\n if (!arrayNode) {\n throw new Error('Could not find enabledModules array declaration in src/modules.ts')\n }\n\n return { arrayNode, occurrences }\n}\n\nfunction normalizeModuleEntry(entry: ModuleEntry): ModuleEntry {\n return {\n id: entry.id,\n from: entry.from ?? '@open-mercato/core',\n }\n}\n\nfunction escapeSingleQuotedString(value: string): string {\n return value.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\")\n}\n\nfunction buildModuleEntryLiteral(entry: ModuleEntry): string {\n const normalized = normalizeModuleEntry(entry)\n return `{ id: '${escapeSingleQuotedString(normalized.id)}', from: '${escapeSingleQuotedString(normalized.from ?? '@open-mercato/core')}' }`\n}\n\nfunction lineIndentAt(source: string, position: number): string {\n const lineStart = source.lastIndexOf('\\n', Math.max(0, position - 1)) + 1\n const lineToPosition = source.slice(lineStart, position)\n const match = lineToPosition.match(/^\\s*/)\n return match?.[0] ?? ''\n}\n\nfunction replaceArrayLiteral(\n source: string,\n arrayNode: ts.ArrayLiteralExpression,\n entry: ModuleEntry,\n sourceFile: ts.SourceFile,\n): string {\n const existingElements = arrayNode.elements.map((element) =>\n source.slice(element.getStart(sourceFile), element.end).trim(),\n )\n const closingIndent = lineIndentAt(source, arrayNode.end - 1)\n const elementIndent =\n arrayNode.elements.length > 0\n ? lineIndentAt(source, arrayNode.elements[0].getStart(sourceFile))\n : `${closingIndent} `\n const updatedArray = [\n '[',\n ...[...existingElements, buildModuleEntryLiteral(entry)].map((value) => `${elementIndent}${value},`),\n `${closingIndent}]`,\n ].join('\\n')\n\n return source.slice(0, arrayNode.getStart(sourceFile)) + updatedArray + source.slice(arrayNode.end)\n}\n\nfunction upsertModuleSource(objectLiteral: string, from: string): string {\n if (/from\\s*:\\s*'[^']*'/.test(objectLiteral)) {\n return objectLiteral.replace(/from\\s*:\\s*'[^']*'/, `from: '${escapeSingleQuotedString(from)}'`)\n }\n\n if (/from\\s*:\\s*\"[^\"]*\"/.test(objectLiteral)) {\n return objectLiteral.replace(/from\\s*:\\s*\"[^\"]*\"/, `from: \"${from.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"')}\"`)\n }\n\n return objectLiteral.replace(/\\}\\s*$/, `, from: '${escapeSingleQuotedString(from)}' }`)\n}\n\nexport function ensureModuleRegistration(\n modulesPath: string,\n entry: ModuleEntry,\n): { changed: boolean; registeredAs: string } {\n if (!fs.existsSync(modulesPath)) {\n throw new Error(`modules.ts not found at ${modulesPath}`)\n }\n\n const source = fs.readFileSync(modulesPath, 'utf8')\n const sourceFile = ts.createSourceFile('modules.ts', source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS)\n const config = parseModuleConfigShape(source)\n const normalized = normalizeModuleEntry(entry)\n const matches = config.occurrences.filter((occurrence) => occurrence.entry.id === normalized.id)\n\n if (matches.length > 1) {\n throw new Error(\n `Module \"${normalized.id}\" is registered multiple times in ${modulesPath}. Resolve duplicates manually before running this command.`,\n )\n }\n\n if (matches.length === 1) {\n const existing = normalizeModuleEntry(matches[0].entry)\n if (existing.from === normalized.from) {\n return { changed: false, registeredAs: normalized.from ?? '@open-mercato/core' }\n }\n\n throw new Error(\n `Module \"${normalized.id}\" is already registered from \"${existing.from}\". Remove or eject the existing registration first.`,\n )\n }\n\n const updated = replaceArrayLiteral(source, config.arrayNode, normalized, sourceFile)\n fs.writeFileSync(modulesPath, updated)\n\n return { changed: true, registeredAs: normalized.from ?? '@open-mercato/core' }\n}\n\nexport function setModuleRegistrationSource(\n modulesPath: string,\n moduleId: string,\n from: string,\n): { changed: boolean } {\n if (!fs.existsSync(modulesPath)) {\n throw new Error(`modules.ts not found at ${modulesPath}`)\n }\n\n const source = fs.readFileSync(modulesPath, 'utf8')\n const config = parseModuleConfigShape(source)\n const matches = config.occurrences.filter((occurrence) => occurrence.entry.id === moduleId)\n\n if (matches.length === 0) {\n throw new Error(\n `Could not find module entry for \"${moduleId}\" in ${modulesPath}. Expected a pattern like: { id: '${moduleId}', from: '...' } or { id: '${moduleId}' }`,\n )\n }\n\n if (matches.length > 1) {\n throw new Error(\n `Module \"${moduleId}\" is registered multiple times in ${modulesPath}. Resolve duplicates manually before running this command.`,\n )\n }\n\n const match = matches[0]\n const current = normalizeModuleEntry(match.entry)\n if (current.from === from) {\n return { changed: false }\n }\n\n const objectLiteral = source.slice(match.node.getStart(), match.node.end)\n const updatedObjectLiteral = upsertModuleSource(objectLiteral, from)\n const updated =\n source.slice(0, match.node.getStart()) +\n updatedObjectLiteral +\n source.slice(match.node.end)\n\n fs.writeFileSync(modulesPath, updated)\n\n return { changed: true }\n}\n"],
5
- "mappings": "AAAA,OAAO,QAAQ;AACf,OAAO,QAAQ;AACf,SAAS,+BAA+B;AAiBxC,SAAS,kCAAkC,MAAsD;AAC/F,MAAI,KAAoB;AACxB,MAAI,OAAsB;AAE1B,aAAW,YAAY,KAAK,YAAY;AACtC,QAAI,CAAC,GAAG,qBAAqB,QAAQ,KAAK,CAAC,GAAG,aAAa,SAAS,IAAI,EAAG;AAE3E,QAAI,SAAS,KAAK,SAAS,QAAQ,GAAG,oBAAoB,SAAS,WAAW,GAAG;AAC/E,WAAK,SAAS,YAAY;AAAA,IAC5B;AAEA,QAAI,SAAS,KAAK,SAAS,UAAU,GAAG,oBAAoB,SAAS,WAAW,GAAG;AACjF,aAAO,SAAS,YAAY;AAAA,IAC9B;AAAA,EACF;AAEA,MAAI,CAAC,GAAI,QAAO;AAEhB,SAAO;AAAA,IACL;AAAA,IACA,MAAM,QAAQ;AAAA,EAChB;AACF;AAEA,SAAS,sBACP,MACA,KACiD;AACjD,MAAI,GAAG,2BAA2B,IAAI,KAAK,GAAG,aAAa,KAAK,IAAI,GAAG;AACrE,UAAM,SAAS,KAAK;AACpB,QACE,GAAG,2BAA2B,MAAM,KACjC,GAAG,aAAa,OAAO,UAAU,KACjC,OAAO,WAAW,SAAS,aAC3B,OAAO,KAAK,SAAS,OACxB;AACA,aAAO,EAAE,SAAS,MAAM,OAAO,IAAI,KAAK,KAAK,IAAI,EAAE;AAAA,IACrD;AAAA,EACF;AAEA,MACE,GAAG,0BAA0B,IAAI,KAC9B,GAAG,2BAA2B,KAAK,UAAU,KAC7C,GAAG,aAAa,KAAK,WAAW,UAAU,KAC1C,KAAK,WAAW,WAAW,SAAS,aACpC,KAAK,WAAW,KAAK,SAAS,SAC9B,GAAG,oBAAoB,KAAK,kBAAkB,GACjD;AACA,WAAO,EAAE,SAAS,MAAM,OAAO,IAAI,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I,QAAQ,SAAS,GAAG;AACtB,UAAM,IAAI;AAAA,MACR,WAAW,QAAQ,qCAAqC,WAAW;AAAA,IACrE;AAAA,EACF;AAEA,QAAM,QAAQ,QAAQ,CAAC;AACvB,QAAM,UAAU,qBAAqB,MAAM,KAAK;AAChD,MAAI,QAAQ,SAAS,MAAM;AACzB,WAAO,EAAE,SAAS,MAAM;AAAA,EAC1B;AAEA,QAAM,gBAAgB,OAAO,MAAM,MAAM,KAAK,SAAS,GAAG,MAAM,KAAK,GAAG;AACxE,QAAM,uBAAuB,mBAAmB,eAAe,IAAI;AACnE,QAAM,UACJ,OAAO,MAAM,GAAG,MAAM,KAAK,SAAS,CAAC,IACrC,uBACA,OAAO,MAAM,MAAM,KAAK,GAAG;AAE7B,KAAG,cAAc,aAAa,OAAO;AAErC,SAAO,EAAE,SAAS,KAAK;AACzB;",
4
+ "sourcesContent": ["import fs from 'node:fs'\nimport ts from 'typescript-js'\nimport { parseBooleanWithDefault } from '@open-mercato/shared/lib/boolean'\n\nexport type ModuleEntry = {\n id: string\n from?: '@open-mercato/core' | '@app' | string\n}\n\ntype ModuleOccurrence = {\n entry: ModuleEntry\n node: ts.ObjectLiteralExpression\n}\n\ntype ModuleConfigShape = {\n arrayNode: ts.ArrayLiteralExpression\n occurrences: ModuleOccurrence[]\n}\n\nfunction parseModuleEntryFromObjectLiteral(node: ts.ObjectLiteralExpression): ModuleEntry | null {\n let id: string | null = null\n let from: string | null = null\n\n for (const property of node.properties) {\n if (!ts.isPropertyAssignment(property) || !ts.isIdentifier(property.name)) continue\n\n if (property.name.text === 'id' && ts.isStringLiteralLike(property.initializer)) {\n id = property.initializer.text\n }\n\n if (property.name.text === 'from' && ts.isStringLiteralLike(property.initializer)) {\n from = property.initializer.text\n }\n }\n\n if (!id) return null\n\n return {\n id,\n from: from ?? '@open-mercato/core',\n }\n}\n\nfunction parseProcessEnvAccess(\n node: ts.Expression,\n env: NodeJS.ProcessEnv,\n): { matched: boolean; value: string | undefined } {\n if (ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.name)) {\n const target = node.expression\n if (\n ts.isPropertyAccessExpression(target)\n && ts.isIdentifier(target.expression)\n && target.expression.text === 'process'\n && target.name.text === 'env'\n ) {\n return { matched: true, value: env[node.name.text] }\n }\n }\n\n if (\n ts.isElementAccessExpression(node)\n && ts.isPropertyAccessExpression(node.expression)\n && ts.isIdentifier(node.expression.expression)\n && node.expression.expression.text === 'process'\n && node.expression.name.text === 'env'\n && ts.isStringLiteralLike(node.argumentExpression)\n ) {\n return { matched: true, value: env[node.argumentExpression.text] }\n }\n\n return { matched: false, value: undefined }\n}\n\nfunction evaluateStaticExpressionWithScope(\n node: ts.Expression,\n env: NodeJS.ProcessEnv,\n scope: Map<string, unknown>,\n): unknown {\n if (ts.isParenthesizedExpression(node)) {\n return evaluateStaticExpressionWithScope(node.expression, env, scope)\n }\n\n if (ts.isIdentifier(node)) {\n return scope.get(node.text)\n }\n\n if (ts.isStringLiteralLike(node) || ts.isNoSubstitutionTemplateLiteral(node)) {\n return node.text\n }\n\n if (ts.isNumericLiteral(node)) {\n return Number(node.text)\n }\n\n if (node.kind === ts.SyntaxKind.TrueKeyword) return true\n if (node.kind === ts.SyntaxKind.FalseKeyword) return false\n if (node.kind === ts.SyntaxKind.NullKeyword) return null\n\n const envAccess = parseProcessEnvAccess(node, env)\n if (envAccess.matched) {\n return envAccess.value\n }\n\n if (ts.isPropertyAccessExpression(node)) {\n const target = evaluateStaticExpressionWithScope(node.expression, env, scope)\n if (target && typeof target === 'object' && node.name.text in target) {\n return (target as Record<string, unknown>)[node.name.text]\n }\n return undefined\n }\n\n if (ts.isPrefixUnaryExpression(node) && node.operator === ts.SyntaxKind.ExclamationToken) {\n return !Boolean(evaluateStaticExpressionWithScope(node.operand, env, scope))\n }\n\n if (ts.isBinaryExpression(node)) {\n if (node.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken) {\n return Boolean(evaluateStaticExpressionWithScope(node.left, env, scope))\n && Boolean(evaluateStaticExpressionWithScope(node.right, env, scope))\n }\n\n if (node.operatorToken.kind === ts.SyntaxKind.BarBarToken) {\n return Boolean(evaluateStaticExpressionWithScope(node.left, env, scope))\n || Boolean(evaluateStaticExpressionWithScope(node.right, env, scope))\n }\n\n if (node.operatorToken.kind === ts.SyntaxKind.EqualsEqualsEqualsToken) {\n return evaluateStaticExpressionWithScope(node.left, env, scope)\n === evaluateStaticExpressionWithScope(node.right, env, scope)\n }\n\n if (node.operatorToken.kind === ts.SyntaxKind.ExclamationEqualsEqualsToken) {\n return evaluateStaticExpressionWithScope(node.left, env, scope)\n !== evaluateStaticExpressionWithScope(node.right, env, scope)\n }\n }\n\n if (\n ts.isCallExpression(node)\n && ts.isIdentifier(node.expression)\n && node.expression.text === 'parseBooleanWithDefault'\n ) {\n const rawValueNode = node.arguments[0]\n const fallbackNode = node.arguments[1]\n const rawValue = rawValueNode\n ? evaluateStaticExpressionWithScope(rawValueNode, env, scope)\n : undefined\n const fallbackValue = fallbackNode\n ? evaluateStaticExpressionWithScope(fallbackNode, env, scope)\n : false\n\n return parseBooleanWithDefault(\n typeof rawValue === 'string' ? rawValue : undefined,\n Boolean(fallbackValue),\n )\n }\n\n if (\n ts.isCallExpression(node)\n && ts.isPropertyAccessExpression(node.expression)\n && node.expression.name.text === 'some'\n ) {\n const target = evaluateStaticExpressionWithScope(node.expression.expression, env, scope)\n const predicate = node.arguments[0]\n if (!Array.isArray(target) || !predicate) {\n return undefined\n }\n\n return target.some((entry) => {\n if (!ts.isArrowFunction(predicate) && !ts.isFunctionExpression(predicate)) {\n return false\n }\n\n const localScope = new Map(scope)\n const parameter = predicate.parameters[0]\n if (parameter && ts.isIdentifier(parameter.name)) {\n localScope.set(parameter.name.text, entry)\n }\n\n if (ts.isBlock(predicate.body)) {\n const returnStatement = predicate.body.statements.find((statement): statement is ts.ReturnStatement =>\n ts.isReturnStatement(statement),\n )\n if (!returnStatement?.expression) {\n return false\n }\n return Boolean(evaluateStaticExpressionWithScope(returnStatement.expression, env, localScope))\n }\n\n return Boolean(evaluateStaticExpressionWithScope(predicate.body, env, localScope))\n })\n }\n\n return undefined\n}\n\nfunction evaluateStaticCondition(\n node: ts.Expression,\n env: NodeJS.ProcessEnv,\n scope: Map<string, unknown>,\n): boolean {\n return Boolean(evaluateStaticExpressionWithScope(node, env, scope))\n}\n\nfunction collectPushEntriesFromStatement(\n statement: ts.Statement,\n env: NodeJS.ProcessEnv,\n targetVariableName: string,\n scope: Map<string, unknown>,\n): ModuleOccurrence[] {\n if (ts.isBlock(statement)) {\n return statement.statements.flatMap((child) =>\n collectPushEntriesFromStatement(child, env, targetVariableName, scope),\n )\n }\n\n if (ts.isIfStatement(statement)) {\n if (evaluateStaticCondition(statement.expression, env, scope)) {\n return collectPushEntriesFromStatement(statement.thenStatement, env, targetVariableName, scope)\n }\n\n if (statement.elseStatement) {\n return collectPushEntriesFromStatement(statement.elseStatement, env, targetVariableName, scope)\n }\n\n return []\n }\n\n if (!ts.isExpressionStatement(statement)) return []\n\n const expression = statement.expression\n if (!ts.isCallExpression(expression) || !ts.isPropertyAccessExpression(expression.expression)) {\n return []\n }\n\n const pushTarget = expression.expression.expression\n const pushMethod = expression.expression.name\n\n if (!ts.isIdentifier(pushTarget) || pushTarget.text !== targetVariableName || pushMethod.text !== 'push') {\n return []\n }\n\n return expression.arguments.flatMap((argument) => {\n if (!ts.isObjectLiteralExpression(argument)) return []\n const entry = parseModuleEntryFromObjectLiteral(argument)\n return entry ? [{ entry, node: argument }] : []\n })\n}\n\nfunction parseModuleConfigShape(\n source: string,\n env: NodeJS.ProcessEnv = process.env,\n): ModuleConfigShape {\n const sourceFile = ts.createSourceFile('modules.ts', source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS)\n const variableName = 'enabledModules'\n const occurrences: ModuleOccurrence[] = []\n const scope = new Map<string, unknown>()\n let arrayNode: ts.ArrayLiteralExpression | null = null\n let foundDeclaration = false\n\n for (const statement of sourceFile.statements) {\n if (ts.isVariableStatement(statement)) {\n for (const declaration of statement.declarationList.declarations) {\n if (!ts.isIdentifier(declaration.name)) continue\n\n if (declaration.name.text === variableName) {\n if (!declaration.initializer || !ts.isArrayLiteralExpression(declaration.initializer)) continue\n\n arrayNode = declaration.initializer\n occurrences.push(...declaration.initializer.elements.flatMap((element) => {\n if (!ts.isObjectLiteralExpression(element)) return []\n const entry = parseModuleEntryFromObjectLiteral(element)\n return entry ? [{ entry, node: element }] : []\n }))\n scope.set(variableName, occurrences.map((occurrence) => occurrence.entry))\n foundDeclaration = true\n continue\n }\n\n if (!declaration.initializer) continue\n\n scope.set(\n declaration.name.text,\n evaluateStaticExpressionWithScope(declaration.initializer, env, scope),\n )\n }\n continue\n }\n\n if (!foundDeclaration) continue\n\n const pushedOccurrences = collectPushEntriesFromStatement(statement, env, variableName, scope)\n if (pushedOccurrences.length > 0) {\n occurrences.push(...pushedOccurrences)\n scope.set(variableName, occurrences.map((occurrence) => occurrence.entry))\n }\n }\n\n if (!arrayNode) {\n throw new Error('Could not find enabledModules array declaration in src/modules.ts')\n }\n\n return { arrayNode, occurrences }\n}\n\nfunction normalizeModuleEntry(entry: ModuleEntry): ModuleEntry {\n return {\n id: entry.id,\n from: entry.from ?? '@open-mercato/core',\n }\n}\n\nfunction escapeSingleQuotedString(value: string): string {\n return value.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\")\n}\n\nfunction buildModuleEntryLiteral(entry: ModuleEntry): string {\n const normalized = normalizeModuleEntry(entry)\n return `{ id: '${escapeSingleQuotedString(normalized.id)}', from: '${escapeSingleQuotedString(normalized.from ?? '@open-mercato/core')}' }`\n}\n\nfunction lineIndentAt(source: string, position: number): string {\n const lineStart = source.lastIndexOf('\\n', Math.max(0, position - 1)) + 1\n const lineToPosition = source.slice(lineStart, position)\n const match = lineToPosition.match(/^\\s*/)\n return match?.[0] ?? ''\n}\n\nfunction nextTokenEnd(source: string, position: number): number {\n const scanner = ts.createScanner(ts.ScriptTarget.Latest, true, ts.LanguageVariant.Standard, source)\n scanner.resetTokenState(position)\n scanner.scan()\n return scanner.getTokenEnd()\n}\n\nfunction trailingCommentsEnd(source: string, position: number): number {\n const ranges = ts.getTrailingCommentRanges(source, position) ?? []\n return ranges.length > 0 ? ranges[ranges.length - 1].end : position\n}\n\nfunction insertArrayElement(\n source: string,\n arrayNode: ts.ArrayLiteralExpression,\n entry: ModuleEntry,\n sourceFile: ts.SourceFile,\n): string {\n const newline = source.includes('\\r\\n') ? '\\r\\n' : '\\n'\n const entryLiteral = buildModuleEntryLiteral(entry)\n const openingBracket = arrayNode.getStart(sourceFile)\n const closingBracket = arrayNode.end - 1\n const openingIndent = lineIndentAt(source, openingBracket)\n const lastElement = arrayNode.elements[arrayNode.elements.length - 1]\n\n let head: string\n let insertAt: number\n let insertion: string\n\n if (!lastElement) {\n const innerContent = source.slice(openingBracket + 1, closingBracket).trimEnd()\n insertAt = openingBracket + 1 + innerContent.length\n head = source.slice(0, insertAt)\n insertion = `${newline}${openingIndent} ${entryLiteral},`\n } else {\n const hasTrailingComma = arrayNode.elements.hasTrailingComma\n const anchor = hasTrailingComma ? nextTokenEnd(source, lastElement.end) : lastElement.end\n insertAt = trailingCommentsEnd(source, anchor)\n head = hasTrailingComma\n ? source.slice(0, insertAt)\n : `${source.slice(0, anchor)},${source.slice(anchor, insertAt)}`\n const lastElementStart = lastElement.getStart(sourceFile)\n const startsOnOpeningLine = !source.slice(openingBracket, lastElementStart).includes('\\n')\n const elementIndent = startsOnOpeningLine\n ? `${openingIndent} `\n : lineIndentAt(source, lastElementStart)\n insertion = `${newline}${elementIndent}${entryLiteral}${hasTrailingComma ? ',' : ''}`\n }\n\n const closesOnSameLine = !source.slice(insertAt, closingBracket).includes('\\n')\n const closingLine = closesOnSameLine ? `${newline}${openingIndent}` : ''\n const tail = closesOnSameLine ? source.slice(closingBracket) : source.slice(insertAt)\n\n return head + insertion + closingLine + tail\n}\n\nfunction upsertModuleSource(objectLiteral: string, from: string): string {\n if (/from\\s*:\\s*'[^']*'/.test(objectLiteral)) {\n return objectLiteral.replace(/from\\s*:\\s*'[^']*'/, `from: '${escapeSingleQuotedString(from)}'`)\n }\n\n if (/from\\s*:\\s*\"[^\"]*\"/.test(objectLiteral)) {\n return objectLiteral.replace(/from\\s*:\\s*\"[^\"]*\"/, `from: \"${from.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"')}\"`)\n }\n\n return objectLiteral.replace(/\\}\\s*$/, `, from: '${escapeSingleQuotedString(from)}' }`)\n}\n\nexport function ensureModuleRegistration(\n modulesPath: string,\n entry: ModuleEntry,\n): { changed: boolean; registeredAs: string } {\n if (!fs.existsSync(modulesPath)) {\n throw new Error(`modules.ts not found at ${modulesPath}`)\n }\n\n const source = fs.readFileSync(modulesPath, 'utf8')\n const sourceFile = ts.createSourceFile('modules.ts', source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS)\n const config = parseModuleConfigShape(source)\n const normalized = normalizeModuleEntry(entry)\n const matches = config.occurrences.filter((occurrence) => occurrence.entry.id === normalized.id)\n\n if (matches.length > 1) {\n throw new Error(\n `Module \"${normalized.id}\" is registered multiple times in ${modulesPath}. Resolve duplicates manually before running this command.`,\n )\n }\n\n if (matches.length === 1) {\n const existing = normalizeModuleEntry(matches[0].entry)\n if (existing.from === normalized.from) {\n return { changed: false, registeredAs: normalized.from ?? '@open-mercato/core' }\n }\n\n throw new Error(\n `Module \"${normalized.id}\" is already registered from \"${existing.from}\". Remove or eject the existing registration first.`,\n )\n }\n\n const updated = insertArrayElement(source, config.arrayNode, normalized, sourceFile)\n fs.writeFileSync(modulesPath, updated)\n\n return { changed: true, registeredAs: normalized.from ?? '@open-mercato/core' }\n}\n\nexport function setModuleRegistrationSource(\n modulesPath: string,\n moduleId: string,\n from: string,\n): { changed: boolean } {\n if (!fs.existsSync(modulesPath)) {\n throw new Error(`modules.ts not found at ${modulesPath}`)\n }\n\n const source = fs.readFileSync(modulesPath, 'utf8')\n const config = parseModuleConfigShape(source)\n const matches = config.occurrences.filter((occurrence) => occurrence.entry.id === moduleId)\n\n if (matches.length === 0) {\n throw new Error(\n `Could not find module entry for \"${moduleId}\" in ${modulesPath}. Expected a pattern like: { id: '${moduleId}', from: '...' } or { id: '${moduleId}' }`,\n )\n }\n\n if (matches.length > 1) {\n throw new Error(\n `Module \"${moduleId}\" is registered multiple times in ${modulesPath}. Resolve duplicates manually before running this command.`,\n )\n }\n\n const match = matches[0]\n const current = normalizeModuleEntry(match.entry)\n if (current.from === from) {\n return { changed: false }\n }\n\n const objectLiteral = source.slice(match.node.getStart(), match.node.end)\n const updatedObjectLiteral = upsertModuleSource(objectLiteral, from)\n const updated =\n source.slice(0, match.node.getStart()) +\n updatedObjectLiteral +\n source.slice(match.node.end)\n\n fs.writeFileSync(modulesPath, updated)\n\n return { changed: true }\n}\n"],
5
+ "mappings": "AAAA,OAAO,QAAQ;AACf,OAAO,QAAQ;AACf,SAAS,+BAA+B;AAiBxC,SAAS,kCAAkC,MAAsD;AAC/F,MAAI,KAAoB;AACxB,MAAI,OAAsB;AAE1B,aAAW,YAAY,KAAK,YAAY;AACtC,QAAI,CAAC,GAAG,qBAAqB,QAAQ,KAAK,CAAC,GAAG,aAAa,SAAS,IAAI,EAAG;AAE3E,QAAI,SAAS,KAAK,SAAS,QAAQ,GAAG,oBAAoB,SAAS,WAAW,GAAG;AAC/E,WAAK,SAAS,YAAY;AAAA,IAC5B;AAEA,QAAI,SAAS,KAAK,SAAS,UAAU,GAAG,oBAAoB,SAAS,WAAW,GAAG;AACjF,aAAO,SAAS,YAAY;AAAA,IAC9B;AAAA,EACF;AAEA,MAAI,CAAC,GAAI,QAAO;AAEhB,SAAO;AAAA,IACL;AAAA,IACA,MAAM,QAAQ;AAAA,EAChB;AACF;AAEA,SAAS,sBACP,MACA,KACiD;AACjD,MAAI,GAAG,2BAA2B,IAAI,KAAK,GAAG,aAAa,KAAK,IAAI,GAAG;AACrE,UAAM,SAAS,KAAK;AACpB,QACE,GAAG,2BAA2B,M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AC5C,QAAM,UAAU,OAAO,YAAY,OAAO,CAAC,eAAe,WAAW,MAAM,OAAO,QAAQ;AAE1F,MAAI,QAAQ,WAAW,GAAG;AACxB,UAAM,IAAI;AAAA,MACR,oCAAoC,QAAQ,QAAQ,WAAW,qCAAqC,QAAQ,8BAA8B,QAAQ;AAAA,IACpJ;AAAA,EACF;AAEA,MAAI,QAAQ,SAAS,GAAG;AACtB,UAAM,IAAI;AAAA,MACR,WAAW,QAAQ,qCAAqC,WAAW;AAAA,IACrE;AAAA,EACF;AAEA,QAAM,QAAQ,QAAQ,CAAC;AACvB,QAAM,UAAU,qBAAqB,MAAM,KAAK;AAChD,MAAI,QAAQ,SAAS,MAAM;AACzB,WAAO,EAAE,SAAS,MAAM;AAAA,EAC1B;AAEA,QAAM,gBAAgB,OAAO,MAAM,MAAM,KAAK,SAAS,GAAG,MAAM,KAAK,GAAG;AACxE,QAAM,uBAAuB,mBAAmB,eAAe,IAAI;AACnE,QAAM,UACJ,OAAO,MAAM,GAAG,MAAM,KAAK,SAAS,CAAC,IACrC,uBACA,OAAO,MAAM,MAAM,KAAK,GAAG;AAE7B,KAAG,cAAc,aAAa,OAAO;AAErC,SAAO,EAAE,SAAS,KAAK;AACzB;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-mercato/cli",
3
- "version": "0.10.1-develop.7752.1.fd7c06569b",
3
+ "version": "0.10.1-develop.7753.1.61290f530d",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -60,10 +60,10 @@
60
60
  "@mikro-orm/decorators": "^7.1.14",
61
61
  "@mikro-orm/migrations": "^7.1.14",
62
62
  "@mikro-orm/postgresql": "^7.1.14",
63
- "@open-mercato/events": "0.10.1-develop.7752.1.fd7c06569b",
64
- "@open-mercato/queue": "0.10.1-develop.7752.1.fd7c06569b",
65
- "@open-mercato/shared": "0.10.1-develop.7752.1.fd7c06569b",
66
- "@open-mercato/telemetry": "0.10.1-develop.7752.1.fd7c06569b",
63
+ "@open-mercato/events": "0.10.1-develop.7753.1.61290f530d",
64
+ "@open-mercato/queue": "0.10.1-develop.7753.1.61290f530d",
65
+ "@open-mercato/shared": "0.10.1-develop.7753.1.61290f530d",
66
+ "@open-mercato/telemetry": "0.10.1-develop.7753.1.61290f530d",
67
67
  "cross-spawn": "^7.0.6",
68
68
  "pg": "8.23.0",
69
69
  "semver": "^7.8.5",
@@ -74,10 +74,10 @@
74
74
  "typescript-js": "npm:typescript@6.0.3"
75
75
  },
76
76
  "peerDependencies": {
77
- "@open-mercato/shared": "0.10.1-develop.7752.1.fd7c06569b"
77
+ "@open-mercato/shared": "0.10.1-develop.7753.1.61290f530d"
78
78
  },
79
79
  "devDependencies": {
80
- "@open-mercato/shared": "0.10.1-develop.7752.1.fd7c06569b",
80
+ "@open-mercato/shared": "0.10.1-develop.7753.1.61290f530d",
81
81
  "@types/jest": "^30.0.0",
82
82
  "jest": "^30.4.2",
83
83
  "ts-jest": "^29.4.12"
@@ -65,6 +65,17 @@ function createCoreWorkspacePackage(rootDir: string, relativeDir: string): strin
65
65
  return coreDir
66
66
  }
67
67
 
68
+ const commentedModulesSource = [
69
+ '// Central place to enable modules.',
70
+ 'export const enabledModules = [',
71
+ ' // customer_groups stays disabled by default.',
72
+ " // { id: 'customer_groups', from: '@open-mercato/core' },",
73
+ '',
74
+ ' /* Block comment kept by module add. */',
75
+ ']',
76
+ '',
77
+ ].join('\n')
78
+
68
79
  function createMonorepoFixture(rootDir: string): string {
69
80
  writeFile(
70
81
  path.join(rootDir, 'package.json'),
@@ -97,7 +108,7 @@ function createMonorepoFixture(rootDir: string): string {
97
108
  2,
98
109
  ),
99
110
  )
100
- writeFile(path.join(appDir, 'src', 'modules.ts'), 'export const enabledModules = []\n')
111
+ writeFile(path.join(appDir, 'src', 'modules.ts'), commentedModulesSource)
101
112
  return appDir
102
113
  }
103
114
 
@@ -152,7 +163,12 @@ test.describe('TC-INT-007: CLI official module install and eject flows', () => {
152
163
  dependencies?: Record<string, string>
153
164
  }
154
165
 
155
- expect(modulesSource).toContain("{ id: 'test_package', from: '@open-mercato/test-package' }")
166
+ expect(modulesSource).toBe(
167
+ commentedModulesSource.replace(
168
+ ' /* Block comment kept by module add. */\n',
169
+ " /* Block comment kept by module add. */\n { id: 'test_package', from: '@open-mercato/test-package' },\n",
170
+ ),
171
+ )
156
172
  expect(cssSource).toContain('node_modules/@open-mercato/test-package/src/**/*.{ts,tsx}')
157
173
  expect(appPackageJson.dependencies?.['@open-mercato/test-package']).toBeTruthy()
158
174
  } finally {