@open-mercato/cli 0.10.1-develop.7983.1.fd91207efe → 0.10.1-develop.7994.1.c9f31972aa

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 (162) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/dist/agentic/guides/module-facts.json +162 -162
  3. package/dist/agentic/guides/module-facts.v2.json +162 -162
  4. package/dist/agentic/guides/module-tool.md +21 -0
  5. package/dist/agentic/guides/modules/agent_orchestrator/index.md +1 -1
  6. package/dist/agentic/guides/modules/ai_assistant/index.md +1 -1
  7. package/dist/agentic/guides/modules/api_docs/index.md +1 -1
  8. package/dist/agentic/guides/modules/api_keys/index.md +1 -1
  9. package/dist/agentic/guides/modules/attachments/index.md +1 -1
  10. package/dist/agentic/guides/modules/audit_logs/index.md +1 -1
  11. package/dist/agentic/guides/modules/auth/index.md +1 -1
  12. package/dist/agentic/guides/modules/availability/index.md +1 -1
  13. package/dist/agentic/guides/modules/business_rules/index.md +1 -1
  14. package/dist/agentic/guides/modules/carrier_inpost/index.md +1 -1
  15. package/dist/agentic/guides/modules/cart/index.md +1 -1
  16. package/dist/agentic/guides/modules/catalog/index.md +1 -1
  17. package/dist/agentic/guides/modules/channel_apns/index.md +1 -1
  18. package/dist/agentic/guides/modules/channel_discord/index.md +1 -1
  19. package/dist/agentic/guides/modules/channel_expo/index.md +1 -1
  20. package/dist/agentic/guides/modules/channel_fcm/index.md +1 -1
  21. package/dist/agentic/guides/modules/channel_gmail/index.md +1 -1
  22. package/dist/agentic/guides/modules/channel_imap/index.md +1 -1
  23. package/dist/agentic/guides/modules/channel_resend/index.md +1 -1
  24. package/dist/agentic/guides/modules/channel_ses/index.md +1 -1
  25. package/dist/agentic/guides/modules/channel_smtp/index.md +1 -1
  26. package/dist/agentic/guides/modules/checkout/index.md +1 -1
  27. package/dist/agentic/guides/modules/communication_channels/index.md +1 -1
  28. package/dist/agentic/guides/modules/configs/index.md +1 -1
  29. package/dist/agentic/guides/modules/content/index.md +1 -1
  30. package/dist/agentic/guides/modules/currencies/index.md +1 -1
  31. package/dist/agentic/guides/modules/customer_accounts/index.md +1 -1
  32. package/dist/agentic/guides/modules/customer_groups/index.md +1 -1
  33. package/dist/agentic/guides/modules/customers/index.md +1 -1
  34. package/dist/agentic/guides/modules/dashboards/index.md +1 -1
  35. package/dist/agentic/guides/modules/data_sync/index.md +1 -1
  36. package/dist/agentic/guides/modules/design_system/index.md +1 -1
  37. package/dist/agentic/guides/modules/devices/index.md +1 -1
  38. package/dist/agentic/guides/modules/dictionaries/index.md +1 -1
  39. package/dist/agentic/guides/modules/directory/index.md +1 -1
  40. package/dist/agentic/guides/modules/documents/index.md +1 -1
  41. package/dist/agentic/guides/modules/ecommerce/index.md +1 -1
  42. package/dist/agentic/guides/modules/entities/index.md +1 -1
  43. package/dist/agentic/guides/modules/eudr/index.md +1 -1
  44. package/dist/agentic/guides/modules/events/index.md +1 -1
  45. package/dist/agentic/guides/modules/feature_toggles/index.md +1 -1
  46. package/dist/agentic/guides/modules/forms/index.md +1 -1
  47. package/dist/agentic/guides/modules/gateway_autopay/index.md +1 -1
  48. package/dist/agentic/guides/modules/gateway_stripe/index.md +1 -1
  49. package/dist/agentic/guides/modules/gateway_tpay/index.md +1 -1
  50. package/dist/agentic/guides/modules/generators/index.md +1 -1
  51. package/dist/agentic/guides/modules/inbox_ops/index.md +1 -1
  52. package/dist/agentic/guides/modules/integrations/index.md +1 -1
  53. package/dist/agentic/guides/modules/messages/index.md +1 -1
  54. package/dist/agentic/guides/modules/notifications/index.md +1 -1
  55. package/dist/agentic/guides/modules/onboarding/index.md +1 -1
  56. package/dist/agentic/guides/modules/payment_gateways/index.md +1 -1
  57. package/dist/agentic/guides/modules/perspectives/index.md +1 -1
  58. package/dist/agentic/guides/modules/phone_calls/index.md +1 -1
  59. package/dist/agentic/guides/modules/planner/index.md +1 -1
  60. package/dist/agentic/guides/modules/portal/index.md +1 -1
  61. package/dist/agentic/guides/modules/progress/index.md +1 -1
  62. package/dist/agentic/guides/modules/promotions/index.md +1 -1
  63. package/dist/agentic/guides/modules/push_notifications/index.md +1 -1
  64. package/dist/agentic/guides/modules/query_index/index.md +1 -1
  65. package/dist/agentic/guides/modules/record_locks/index.md +1 -1
  66. package/dist/agentic/guides/modules/resources/index.md +1 -1
  67. package/dist/agentic/guides/modules/sales/index.md +1 -1
  68. package/dist/agentic/guides/modules/scheduler/index.md +1 -1
  69. package/dist/agentic/guides/modules/search/index.md +1 -1
  70. package/dist/agentic/guides/modules/security/index.md +1 -1
  71. package/dist/agentic/guides/modules/seeds/index.md +1 -1
  72. package/dist/agentic/guides/modules/shipping_carriers/index.md +1 -1
  73. package/dist/agentic/guides/modules/sso/index.md +1 -1
  74. package/dist/agentic/guides/modules/staff/index.md +1 -1
  75. package/dist/agentic/guides/modules/storage_s3/index.md +1 -1
  76. package/dist/agentic/guides/modules/sync_akeneo/index.md +1 -1
  77. package/dist/agentic/guides/modules/sync_excel/index.md +1 -1
  78. package/dist/agentic/guides/modules/system_status_overlays/index.md +1 -1
  79. package/dist/agentic/guides/modules/telemetry/index.md +1 -1
  80. package/dist/agentic/guides/modules/tillio/index.md +1 -1
  81. package/dist/agentic/guides/modules/translations/index.md +1 -1
  82. package/dist/agentic/guides/modules/warranty_claims/index.md +1 -1
  83. package/dist/agentic/guides/modules/webhooks/index.md +1 -1
  84. package/dist/agentic/guides/modules/wms/index.md +1 -1
  85. package/dist/agentic/guides/modules/workflows/index.md +1 -1
  86. package/dist/agentic/guides/reference-module-facts.json +1 -1
  87. package/dist/agentic/guides/upstream/manifest.json +1 -1
  88. package/dist/agentic/shared/ai/harness/cases.json +23 -9
  89. package/dist/agentic/shared/ai/harness/source-link-inventory.json +90 -4
  90. package/dist/lib/__integration__/TC-INT-007.spec.js +207 -19
  91. package/dist/lib/__integration__/TC-INT-007.spec.js.map +2 -2
  92. package/dist/lib/__integration__/TC-INT-009.spec.js +267 -0
  93. package/dist/lib/__integration__/TC-INT-009.spec.js.map +7 -0
  94. package/dist/lib/eject.js +25 -9
  95. package/dist/lib/eject.js.map +2 -2
  96. package/dist/lib/generators/entity-ids.js +2 -0
  97. package/dist/lib/generators/entity-ids.js.map +2 -2
  98. package/dist/lib/generators/module-di.js +2 -0
  99. package/dist/lib/generators/module-di.js.map +2 -2
  100. package/dist/lib/generators/module-entities.js +2 -0
  101. package/dist/lib/generators/module-entities.js.map +2 -2
  102. package/dist/lib/generators/module-package-sources.js +6 -4
  103. package/dist/lib/generators/module-package-sources.js.map +2 -2
  104. package/dist/lib/generators/module-registry.js +32 -86
  105. package/dist/lib/generators/module-registry.js.map +2 -2
  106. package/dist/lib/generators/openapi.js +2 -0
  107. package/dist/lib/generators/openapi.js.map +2 -2
  108. package/dist/lib/generators/source-exports.js +73 -0
  109. package/dist/lib/generators/source-exports.js.map +7 -0
  110. package/dist/lib/init-summary.js +44 -0
  111. package/dist/lib/init-summary.js.map +7 -0
  112. package/dist/lib/module-github.js +98 -0
  113. package/dist/lib/module-github.js.map +7 -0
  114. package/dist/lib/module-identity.js +131 -0
  115. package/dist/lib/module-identity.js.map +7 -0
  116. package/dist/lib/module-inspection.js +124 -0
  117. package/dist/lib/module-inspection.js.map +7 -0
  118. package/dist/lib/module-install.js +150 -21
  119. package/dist/lib/module-install.js.map +3 -3
  120. package/dist/lib/module-package.js +205 -15
  121. package/dist/lib/module-package.js.map +2 -2
  122. package/dist/lib/modules-config.js +69 -30
  123. package/dist/lib/modules-config.js.map +2 -2
  124. package/dist/lib/resolver.js +33 -34
  125. package/dist/lib/resolver.js.map +2 -2
  126. package/dist/mercato.js +14 -23
  127. package/dist/mercato.js.map +2 -2
  128. package/package.json +7 -7
  129. package/src/__tests__/mercato.test.ts +14 -4
  130. package/src/lib/__fixtures__/official-module-package/dist/modules/test_package/widgets/injection/test/widget.js +1 -0
  131. package/src/lib/__integration__/TC-INT-007.spec.ts +219 -19
  132. package/src/lib/__integration__/TC-INT-009.spec.ts +279 -0
  133. package/src/lib/__tests__/eject.test.ts +98 -4
  134. package/src/lib/__tests__/init-summary.test.ts +50 -0
  135. package/src/lib/__tests__/module-github.test.ts +108 -0
  136. package/src/lib/__tests__/module-identity.test.ts +144 -0
  137. package/src/lib/__tests__/module-inspection.test.ts +195 -0
  138. package/src/lib/__tests__/module-install.test.ts +399 -10
  139. package/src/lib/__tests__/module-package.test.ts +154 -0
  140. package/src/lib/__tests__/modules-config.test.ts +55 -0
  141. package/src/lib/__tests__/resolver.packages.test.ts +29 -0
  142. package/src/lib/eject.ts +28 -10
  143. package/src/lib/generators/__tests__/module-id-collisions.test.ts +146 -0
  144. package/src/lib/generators/__tests__/module-package-sources.test.ts +19 -2
  145. package/src/lib/generators/__tests__/module-requirements.test.ts +56 -0
  146. package/src/lib/generators/entity-ids.ts +2 -0
  147. package/src/lib/generators/module-di.ts +2 -0
  148. package/src/lib/generators/module-entities.ts +2 -0
  149. package/src/lib/generators/module-package-sources.ts +7 -5
  150. package/src/lib/generators/module-registry.ts +33 -115
  151. package/src/lib/generators/openapi.ts +3 -0
  152. package/src/lib/generators/source-exports.ts +93 -0
  153. package/src/lib/init-summary.ts +54 -0
  154. package/src/lib/module-github.ts +109 -0
  155. package/src/lib/module-identity.ts +145 -0
  156. package/src/lib/module-inspection.ts +133 -0
  157. package/src/lib/module-install.ts +170 -22
  158. package/src/lib/module-package.ts +243 -16
  159. package/src/lib/modules-config.ts +80 -32
  160. package/src/lib/resolver.ts +35 -39
  161. package/src/mercato.ts +14 -24
  162. package/src/types/cross-spawn.d.ts +2 -2
@@ -2,6 +2,7 @@ import path from 'node:path'
2
2
  import fs from 'node:fs'
3
3
  import ts from 'typescript-js'
4
4
  import { parseBooleanWithDefault } from '@open-mercato/shared/lib/boolean'
5
+ import { resolveInstalledPackageRootWithRequire } from './module-package'
5
6
 
6
7
  /**
7
8
  * Resolved execution environment for the CLI.
@@ -25,6 +26,8 @@ export type CliEnvironment = {
25
26
  export type ModuleEntry = {
26
27
  id: string
27
28
  from?: '@open-mercato/core' | '@app' | string
29
+ locator?: string
30
+ packageName?: string
28
31
  devSupervisorRequiresFullBootstrap?: boolean
29
32
  }
30
33
 
@@ -49,47 +52,33 @@ export interface PackageResolver {
49
52
  getPackageRoot(from?: string): string
50
53
  }
51
54
 
52
- function pkgDirFor(rootDir: string, from?: string, isMonorepo = true): string {
53
- if (!isMonorepo) {
54
- const pkgName = from || '@open-mercato/core'
55
- const pkgRoot = path.join(rootDir, 'node_modules', pkgName)
56
- const distModules = path.join(pkgRoot, 'dist', 'modules')
57
- if (fs.existsSync(distModules)) return distModules
58
- return path.join(pkgRoot, 'src', 'modules')
59
- }
60
-
61
- // Monorepo mode - read from src/modules (TypeScript source)
62
- if (!from || from === '@open-mercato/core') {
63
- return path.resolve(rootDir, 'packages/core/src/modules')
64
- }
65
- // Support other local packages like '@open-mercato/onboarding' => packages/onboarding/src/modules
66
- const m = from.match(/^@open-mercato\/(.+)$/)
67
- if (m) {
68
- return path.resolve(rootDir, `packages/${m[1]}/src/modules`)
69
- }
70
- // Fallback to core modules path
71
- return path.resolve(rootDir, 'packages/core/src/modules')
55
+ function pkgDirFor(rootDir: string, from?: string, isMonorepo = true, appDir = rootDir): string {
56
+ const packageRoot = pkgRootFor(rootDir, from, isMonorepo, appDir)
57
+ const sourceModules = path.join(packageRoot, 'src', 'modules')
58
+ const distModules = path.join(packageRoot, 'dist', 'modules')
59
+ const workspacePackage = isMonorepo && packageRoot.startsWith(path.join(rootDir, 'packages') + path.sep)
60
+ if (workspacePackage && fs.existsSync(sourceModules)) return sourceModules
61
+ if (fs.existsSync(distModules)) return distModules
62
+ return sourceModules
72
63
  }
73
64
 
74
- function pkgRootFor(rootDir: string, from?: string, isMonorepo = true): string {
75
- if (!isMonorepo) {
76
- const pkgName = from || '@open-mercato/core'
77
- return path.join(rootDir, 'node_modules', pkgName)
78
- }
79
-
80
- if (!from || from === '@open-mercato/core') {
81
- return path.resolve(rootDir, 'packages/core')
82
- }
83
- const m = from.match(/^@open-mercato\/(.+)$/)
84
- if (m) {
85
- return path.resolve(rootDir, `packages/${m[1]}`)
65
+ function pkgRootFor(rootDir: string, from?: string, isMonorepo = true, appDir = rootDir): string {
66
+ const packageName = from || '@open-mercato/core'
67
+ if (isMonorepo) {
68
+ const workspaceMatch = packageName.match(/^@open-mercato\/(.+)$/)
69
+ if (workspaceMatch) {
70
+ const workspaceRoot = path.join(rootDir, 'packages', workspaceMatch[1])
71
+ if (fs.existsSync(workspaceRoot)) return workspaceRoot
72
+ }
86
73
  }
87
- return path.resolve(rootDir, 'packages/core')
74
+ return resolveInstalledPackageRootWithRequire(packageName, appDir) ?? path.join(rootDir, 'node_modules', packageName)
88
75
  }
89
76
 
90
77
  function parseModuleEntryFromObjectLiteral(node: ts.ObjectLiteralExpression): ModuleEntry | null {
91
78
  let id: string | null = null
92
79
  let from: string | null = null
80
+ let locator: string | undefined
81
+ let packageName: string | undefined
93
82
  let devSupervisorRequiresFullBootstrap = false
94
83
  for (const property of node.properties) {
95
84
  if (!ts.isPropertyAssignment(property)) continue
@@ -102,6 +91,12 @@ function parseModuleEntryFromObjectLiteral(node: ts.ObjectLiteralExpression): Mo
102
91
  if (key === 'from' && ts.isStringLiteralLike(property.initializer)) {
103
92
  from = property.initializer.text
104
93
  }
94
+ if (key === 'packageName' && ts.isStringLiteralLike(property.initializer)) {
95
+ packageName = property.initializer.text
96
+ }
97
+ if (key === 'locator' && ts.isStringLiteralLike(property.initializer)) {
98
+ locator = property.initializer.text
99
+ }
105
100
  if (key === 'overrides') {
106
101
  if (!ts.isObjectLiteralExpression(property.initializer)) {
107
102
  devSupervisorRequiresFullBootstrap = true
@@ -127,6 +122,8 @@ function parseModuleEntryFromObjectLiteral(node: ts.ObjectLiteralExpression): Mo
127
122
  return {
128
123
  id,
129
124
  from: from ?? '@open-mercato/core',
125
+ ...(locator ? { locator } : {}),
126
+ ...(packageName ? { packageName } : {}),
130
127
  ...(devSupervisorRequiresFullBootstrap ? { devSupervisorRequiresFullBootstrap: true } : {}),
131
128
  }
132
129
  }
@@ -365,8 +362,7 @@ function loadEnabledModulesFromConfig(appDir: string): ModuleEntry[] {
365
362
  const cfgPath = path.resolve(appDir, 'src/modules.ts')
366
363
  if (fs.existsSync(cfgPath)) {
367
364
  try {
368
- const loadedModules = readEnabledModulesFromConfig(cfgPath)
369
- if (loadedModules.length > 0) return loadedModules
365
+ return readEnabledModulesFromConfig(cfgPath)
370
366
  } catch (error) {
371
367
  console.warn(
372
368
  '[resolver] Failed to read enabled modules from src/modules.ts, falling back to src/modules scan:',
@@ -582,7 +578,7 @@ export function createResolver(cwd: string = process.cwd()): PackageResolver {
582
578
 
583
579
  getModulePaths: (entry: ModuleEntry) => {
584
580
  const appBase = path.resolve(appDir, 'src/modules', entry.id)
585
- const pkgModulesRoot = pkgDirFor(rootDir, entry.from, _isMonorepo)
581
+ const pkgModulesRoot = pkgDirFor(rootDir, entry.from, _isMonorepo, appDir)
586
582
  const pkgBase = path.join(pkgModulesRoot, entry.id)
587
583
  return { appBase, pkgBase }
588
584
  },
@@ -601,12 +597,12 @@ export function createResolver(cwd: string = process.cwd()): PackageResolver {
601
597
  // App output goes to .mercato/generated
602
598
  return path.join(appDir, '.mercato', 'generated')
603
599
  }
604
- const pkgRoot = pkgRootFor(rootDir, packageName, _isMonorepo)
600
+ const pkgRoot = pkgRootFor(rootDir, packageName, _isMonorepo, appDir)
605
601
  return path.join(pkgRoot, 'generated')
606
602
  },
607
603
 
608
604
  getPackageRoot: (from?: string) => {
609
- return pkgRootFor(rootDir, from, _isMonorepo)
605
+ return pkgRootFor(rootDir, from, _isMonorepo, appDir)
610
606
  },
611
607
  }
612
608
  }
@@ -624,6 +620,6 @@ export function resolveEnvironment(cwd: string = process.cwd()): CliEnvironment
624
620
  mode: _isMonorepo ? 'monorepo' : 'standalone',
625
621
  rootDir,
626
622
  appDir,
627
- packageRoot: (packageName: string) => pkgRootFor(rootDir, packageName, _isMonorepo),
623
+ packageRoot: (packageName: string) => pkgRootFor(rootDir, packageName, _isMonorepo, appDir),
628
624
  }
629
625
  }
package/src/mercato.ts CHANGED
@@ -9,6 +9,7 @@ export { getCliModules, hasCliModules, registerCliModules }
9
9
  import { parseBooleanToken } from '@open-mercato/shared/lib/boolean'
10
10
  import { getSslConfig } from '@open-mercato/shared/lib/db/ssl'
11
11
  import { getRedisUrl, getRedisUrlOrThrow, parseRedisUrl } from '@open-mercato/shared/lib/redis/connection'
12
+ import { formatInitSummary } from './lib/init-summary'
12
13
  import { resolveInitDerivedSecrets } from './lib/init-secrets'
13
14
  import { decideExistingDatabase, formatSkipIfInitializedMessage } from './lib/init-existing-database'
14
15
  import {
@@ -1482,29 +1483,18 @@ export async function run(argv = process.argv) {
1482
1483
  pushUser('Admin', '🧰', adminEmailDerived, adminPasswordOverride ?? password)
1483
1484
  pushUser('Employee', '👷', employeeEmailDerived, employeePasswordOverride ?? password)
1484
1485
  }
1485
- // Simplified success message: we know which users were created
1486
- console.log('🎉 App initialization complete!\n')
1487
- console.log('╔══════════════════════════════════════════════════════════════╗')
1488
- console.log('║ 🚀 You\'re now ready to start development! ║')
1489
- console.log('║ ║')
1490
- if (parseBooleanToken(process.env.OM_INIT_DEV_AUTOSTART) === true) {
1491
- console.log('║ The dev server is starting now (next time run: yarn dev). ║')
1492
- } else {
1493
- console.log('║ Start the dev server: ║')
1494
- console.log('║ yarn dev ║')
1495
- }
1496
- console.log('║ ║')
1497
- console.log('║ Users created: ║')
1498
- for (const entry of createdUsers) {
1499
- const label = `${entry.icon} ${entry.label}:`
1500
- const labelPad = padByCodePointWidth(label, 13)
1501
- const entryPassword = createdPasswords.get(entry.email.toLowerCase()) ?? password
1502
- console.log(`║ ${labelPad}${entry.email.padEnd(42)} ║`)
1503
- console.log(`║ Password: ${entryPassword.padEnd(44)} ║`)
1504
- }
1505
- console.log('║ ║')
1506
- console.log('║ Happy coding! ║')
1507
- console.log('╚══════════════════════════════════════════════════════════════╝')
1486
+ const summaryColor = parseBooleanToken(process.env.OM_INIT_SUMMARY_COLOR)
1487
+ const summaryColumns = Number(process.env.OM_INIT_SUMMARY_COLUMNS ?? process.stdout.columns)
1488
+ const summary = formatInitSummary({
1489
+ users: createdUsers.map((entry) => ({
1490
+ ...entry,
1491
+ password: createdPasswords.get(entry.email.toLowerCase()) ?? password,
1492
+ })),
1493
+ autoStart: parseBooleanToken(process.env.OM_INIT_DEV_AUTOSTART) === true,
1494
+ columns: summaryColumns,
1495
+ color: process.env.NO_COLOR === undefined && (summaryColor ?? (Boolean(process.stdout.isTTY) || parseBooleanToken(process.env.FORCE_COLOR) === true)),
1496
+ })
1497
+ for (const line of summary) console.log(line)
1508
1498
 
1509
1499
  return 0
1510
1500
  } catch (error: unknown) {
@@ -2333,7 +2323,7 @@ export async function run(argv = process.argv) {
2333
2323
  )
2334
2324
  const nextProcess = spawn('node', nextDevCommand.args, {
2335
2325
  stdio: ['inherit', 'pipe', 'pipe'],
2336
- env: runtimeEnv,
2326
+ env: { ...runtimeEnv, NODE_ENV: 'development' },
2337
2327
  cwd: appDir,
2338
2328
  })
2339
2329
  processes.push(nextProcess)
@@ -1,7 +1,7 @@
1
1
  declare module 'cross-spawn' {
2
- import type { spawn as spawnFunction } from 'node:child_process'
2
+ import type { spawn as spawnFunction, spawnSync } from 'node:child_process'
3
3
 
4
- const spawn: typeof spawnFunction
4
+ const spawn: typeof spawnFunction & { sync: typeof spawnSync }
5
5
 
6
6
  export default spawn
7
7
  }