@open-mercato/cli 0.9.1-develop.7573.1.d0ccc51d5b → 0.9.1-develop.7575.1.8480826a9b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -5
- package/dist/agentic/guides/architecture.md +0 -2
- package/dist/agentic/guides/extensions.md +0 -2
- package/dist/agentic/guides/module-facts.json +683 -4227
- package/dist/agentic/guides/module-facts.v2.json +683 -4227
- package/dist/agentic/guides/modules/agent_orchestrator/index.md +1 -1
- package/dist/agentic/guides/modules/ai_assistant/index.md +1 -1
- package/dist/agentic/guides/modules/api_docs/index.md +1 -1
- package/dist/agentic/guides/modules/api_keys/index.md +1 -1
- package/dist/agentic/guides/modules/attachments/index.md +1 -1
- package/dist/agentic/guides/modules/audit_logs/index.md +1 -1
- package/dist/agentic/guides/modules/auth/index.md +1 -1
- package/dist/agentic/guides/modules/availability/index.md +1 -1
- package/dist/agentic/guides/modules/business_rules/index.md +1 -1
- package/dist/agentic/guides/modules/catalog/acl-features.md +1 -3
- package/dist/agentic/guides/modules/catalog/active-extension-bindings.md +3 -3
- package/dist/agentic/guides/modules/catalog/cli-commands.md +0 -1
- package/dist/agentic/guides/modules/catalog/contribution-resolutions.md +0 -2
- package/dist/agentic/guides/modules/catalog/di-registrations-rich.md +4 -5
- package/dist/agentic/guides/modules/catalog/di-service-tokens.md +1 -2
- package/dist/agentic/guides/modules/catalog/entities.md +0 -1
- package/dist/agentic/guides/modules/catalog/exact-override-targets.md +4 -10
- package/dist/agentic/guides/modules/catalog/index.md +5 -5
- package/dist/agentic/guides/modules/catalog/umes-contributions.md +0 -2
- package/dist/agentic/guides/modules/catalog/umes-hosts.md +0 -1
- package/dist/agentic/guides/modules/channel_apns/index.md +1 -1
- package/dist/agentic/guides/modules/channel_discord/index.md +1 -1
- package/dist/agentic/guides/modules/channel_expo/index.md +1 -1
- package/dist/agentic/guides/modules/channel_fcm/index.md +1 -1
- package/dist/agentic/guides/modules/channel_gmail/index.md +1 -1
- package/dist/agentic/guides/modules/channel_imap/index.md +1 -1
- package/dist/agentic/guides/modules/channel_resend/index.md +1 -1
- package/dist/agentic/guides/modules/channel_ses/index.md +1 -1
- package/dist/agentic/guides/modules/checkout/index.md +1 -1
- package/dist/agentic/guides/modules/communication_channels/index.md +1 -1
- package/dist/agentic/guides/modules/configs/index.md +1 -1
- package/dist/agentic/guides/modules/content/index.md +1 -1
- package/dist/agentic/guides/modules/currencies/index.md +1 -1
- package/dist/agentic/guides/modules/customer_accounts/index.md +2 -3
- package/dist/agentic/guides/modules/customer_groups/active-extension-bindings.md +1 -1
- package/dist/agentic/guides/modules/customer_groups/index.md +2 -3
- package/dist/agentic/guides/modules/customers/active-extension-bindings.md +5 -5
- package/dist/agentic/guides/modules/customers/di-registrations-rich.md +3 -5
- package/dist/agentic/guides/modules/customers/exact-override-targets.md +3 -5
- package/dist/agentic/guides/modules/customers/index.md +2 -2
- package/dist/agentic/guides/modules/customers/owned-contract-module-metadata.md +1 -1
- package/dist/agentic/guides/modules/customers/umes-hosts.md +0 -2
- package/dist/agentic/guides/modules/dashboards/index.md +1 -1
- package/dist/agentic/guides/modules/data_sync/di-registrations-rich.md +8 -8
- package/dist/agentic/guides/modules/data_sync/di-service-tokens.md +4 -4
- package/dist/agentic/guides/modules/data_sync/exact-override-targets.md +8 -8
- package/dist/agentic/guides/modules/data_sync/index.md +1 -1
- package/dist/agentic/guides/modules/design_system/index.md +1 -1
- package/dist/agentic/guides/modules/devices/index.md +1 -1
- package/dist/agentic/guides/modules/dictionaries/index.md +1 -1
- package/dist/agentic/guides/modules/directory/index.md +1 -1
- package/dist/agentic/guides/modules/documents/index.md +1 -1
- package/dist/agentic/guides/modules/entities/index.md +1 -1
- package/dist/agentic/guides/modules/eudr/index.md +1 -1
- package/dist/agentic/guides/modules/events/index.md +1 -1
- package/dist/agentic/guides/modules/feature_toggles/index.md +1 -1
- package/dist/agentic/guides/modules/forms/index.md +1 -1
- package/dist/agentic/guides/modules/gateway_stripe/di-registrations-rich.md +1 -1
- package/dist/agentic/guides/modules/gateway_stripe/exact-override-targets.md +1 -1
- package/dist/agentic/guides/modules/gateway_stripe/index.md +1 -1
- package/dist/agentic/guides/modules/generators/index.md +1 -1
- package/dist/agentic/guides/modules/inbox_ops/index.md +1 -1
- package/dist/agentic/guides/modules/integrations/index.md +1 -1
- package/dist/agentic/guides/modules/messages/index.md +1 -1
- package/dist/agentic/guides/modules/notifications/index.md +1 -1
- package/dist/agentic/guides/modules/onboarding/index.md +1 -1
- package/dist/agentic/guides/modules/payment_gateways/index.md +1 -1
- package/dist/agentic/guides/modules/perspectives/index.md +1 -1
- package/dist/agentic/guides/modules/phone_calls/index.md +1 -1
- package/dist/agentic/guides/modules/planner/index.md +1 -1
- package/dist/agentic/guides/modules/portal/index.md +1 -1
- package/dist/agentic/guides/modules/portal/owned-contract-module-metadata.md +1 -1
- package/dist/agentic/guides/modules/progress/index.md +1 -1
- package/dist/agentic/guides/modules/push_notifications/index.md +1 -1
- package/dist/agentic/guides/modules/query_index/index.md +1 -1
- package/dist/agentic/guides/modules/record_locks/index.md +1 -1
- package/dist/agentic/guides/modules/resources/index.md +1 -1
- package/dist/agentic/guides/modules/sales/index.md +1 -1
- package/dist/agentic/guides/modules/scheduler/exact-override-targets.md +1 -1
- package/dist/agentic/guides/modules/scheduler/index.md +1 -1
- package/dist/agentic/guides/modules/scheduler/workers.md +1 -1
- package/dist/agentic/guides/modules/search/index.md +1 -1
- package/dist/agentic/guides/modules/security/index.md +1 -1
- package/dist/agentic/guides/modules/seeds/index.md +1 -1
- package/dist/agentic/guides/modules/shipping_carriers/exact-override-targets.md +1 -1
- package/dist/agentic/guides/modules/shipping_carriers/index.md +1 -1
- package/dist/agentic/guides/modules/shipping_carriers/workers.md +1 -1
- package/dist/agentic/guides/modules/sso/index.md +1 -1
- package/dist/agentic/guides/modules/staff/index.md +1 -1
- package/dist/agentic/guides/modules/storage_s3/index.md +1 -1
- package/dist/agentic/guides/modules/sync_akeneo/index.md +1 -1
- package/dist/agentic/guides/modules/sync_excel/index.md +1 -1
- package/dist/agentic/guides/modules/system_status_overlays/index.md +1 -1
- package/dist/agentic/guides/modules/telemetry/index.md +1 -1
- package/dist/agentic/guides/modules/tillio/index.md +1 -1
- package/dist/agentic/guides/modules/translations/index.md +1 -1
- package/dist/agentic/guides/modules/warranty_claims/index.md +1 -1
- package/dist/agentic/guides/modules/webhooks/exact-override-targets.md +2 -2
- package/dist/agentic/guides/modules/webhooks/index.md +1 -1
- package/dist/agentic/guides/modules/webhooks/workers.md +2 -2
- package/dist/agentic/guides/modules/wms/events.md +1 -2
- package/dist/agentic/guides/modules/wms/index.md +1 -1
- package/dist/agentic/guides/modules/wms/umes-hosts.md +0 -1
- package/dist/agentic/guides/modules/workflows/index.md +1 -1
- package/dist/agentic/guides/modules/workflows/owned-contract-module-metadata.md +1 -1
- package/dist/agentic/guides/reference-module-facts.json +25 -443
- package/dist/agentic/guides/reference-modules/example/active-extension-bindings.md +0 -2
- package/dist/agentic/guides/reference-modules/example/contribution-resolutions.md +4 -9
- package/dist/agentic/guides/reference-modules/example/di-registrations-rich.md +2 -3
- package/dist/agentic/guides/reference-modules/example/di-service-tokens.md +1 -1
- package/dist/agentic/guides/reference-modules/example/exact-override-targets.md +6 -12
- package/dist/agentic/guides/reference-modules/example/index.md +4 -4
- package/dist/agentic/guides/reference-modules/example/umes-contributions.md +5 -10
- package/dist/agentic/guides/reference-modules/example/umes-hosts.md +0 -1
- package/dist/agentic/guides/upstream/AGENTS.md +1 -1
- package/dist/agentic/guides/upstream/BACKWARD_COMPATIBILITY.md +0 -20
- package/dist/agentic/guides/upstream/manifest.json +3 -3
- package/dist/agentic/shared/AGENTS.md.template +0 -1
- package/dist/agentic/shared/ai/harness/README.md +2 -6
- package/dist/agentic/shared/ai/harness/RELEASE.md +4 -4
- package/dist/agentic/shared/ai/harness/cases.json +39 -371
- package/dist/agentic/shared/ai/harness/cases.schema.json +4 -4
- package/dist/agentic/shared/ai/harness/design-system-inventory.json +3 -63
- package/dist/agentic/shared/ai/harness/source-link-inventory.json +8 -316
- package/dist/agentic/shared/ai/harness/validators.json +1 -1
- package/dist/agentic/shared/ai/skills/om-integration-builder/references/provider-families.md +1 -1
- package/dist/agentic/shared/ai/skills/om-module-scaffold/SKILL.md +0 -2
- package/dist/agentic/shared/scripts/evaluate-agent-harness.mjs +9 -78
- package/dist/agentic/shared/scripts/execution-sandbox.mjs +7 -8
- package/dist/bin.js +0 -2
- package/dist/bin.js.map +2 -2
- package/dist/mercato.js +17 -87
- package/dist/mercato.js.map +2 -2
- package/package.json +7 -7
- package/src/__tests__/mercato.test.ts +0 -480
- package/src/bin.ts +0 -5
- package/src/mercato.ts +14 -104
- package/dist/agentic/guides/customers-calendar.md +0 -57
- package/dist/agentic/guides/module-tool.md +0 -35
- package/dist/agentic/guides/modules/customer_accounts/incoming-installed-contributions.md +0 -13
- package/dist/agentic/guides/modules/customer_groups/incoming-installed-contributions.md +0 -11
- package/dist/agentic/guides/modules/ecommerce/acl-features.md +0 -15
- package/dist/agentic/guides/modules/ecommerce/active-extension-bindings.md +0 -12
- package/dist/agentic/guides/modules/ecommerce/backend-pages.md +0 -12
- package/dist/agentic/guides/modules/ecommerce/contribution-resolutions.md +0 -32
- package/dist/agentic/guides/modules/ecommerce/di-registrations-rich.md +0 -11
- package/dist/agentic/guides/modules/ecommerce/di-service-tokens.md +0 -11
- package/dist/agentic/guides/modules/ecommerce/entities.md +0 -13
- package/dist/agentic/guides/modules/ecommerce/events.md +0 -22
- package/dist/agentic/guides/modules/ecommerce/exact-override-targets.md +0 -41
- package/dist/agentic/guides/modules/ecommerce/index.md +0 -26
- package/dist/agentic/guides/modules/ecommerce/notifications.md +0 -12
- package/dist/agentic/guides/modules/ecommerce/owned-contract-module-metadata.md +0 -11
- package/dist/agentic/guides/modules/ecommerce/search-entities.md +0 -11
- package/dist/agentic/guides/modules/ecommerce/setup.md +0 -11
- package/dist/agentic/guides/modules/ecommerce/umes-contributions.md +0 -32
- package/dist/agentic/guides/modules/ecommerce/umes-hosts.md +0 -27
- package/dist/agentic/guides/modules/gateway_tpay/acl-features.md +0 -12
- package/dist/agentic/guides/modules/gateway_tpay/cli-commands.md +0 -12
- package/dist/agentic/guides/modules/gateway_tpay/contribution-resolutions.md +0 -12
- package/dist/agentic/guides/modules/gateway_tpay/di-registrations-rich.md +0 -11
- package/dist/agentic/guides/modules/gateway_tpay/exact-override-targets.md +0 -17
- package/dist/agentic/guides/modules/gateway_tpay/index.md +0 -19
- package/dist/agentic/guides/modules/gateway_tpay/owned-contract-module-metadata.md +0 -11
- package/dist/agentic/guides/modules/gateway_tpay/setup.md +0 -11
- package/dist/agentic/guides/modules/gateway_tpay/umes-contributions.md +0 -12
- package/src/lib/__tests__/bin-next-subpath-hook.test.ts +0 -25
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-mercato/cli",
|
|
3
|
-
"version": "0.9.1-develop.
|
|
3
|
+
"version": "0.9.1-develop.7575.1.8480826a9b",
|
|
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.9.1-develop.
|
|
64
|
-
"@open-mercato/queue": "0.9.1-develop.
|
|
65
|
-
"@open-mercato/shared": "0.9.1-develop.
|
|
66
|
-
"@open-mercato/telemetry": "0.9.1-develop.
|
|
63
|
+
"@open-mercato/events": "0.9.1-develop.7575.1.8480826a9b",
|
|
64
|
+
"@open-mercato/queue": "0.9.1-develop.7575.1.8480826a9b",
|
|
65
|
+
"@open-mercato/shared": "0.9.1-develop.7575.1.8480826a9b",
|
|
66
|
+
"@open-mercato/telemetry": "0.9.1-develop.7575.1.8480826a9b",
|
|
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.9.1-develop.
|
|
77
|
+
"@open-mercato/shared": "0.9.1-develop.7575.1.8480826a9b"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
|
-
"@open-mercato/shared": "0.9.1-develop.
|
|
80
|
+
"@open-mercato/shared": "0.9.1-develop.7575.1.8480826a9b",
|
|
81
81
|
"@types/jest": "^30.0.0",
|
|
82
82
|
"jest": "^30.4.2",
|
|
83
83
|
"ts-jest": "^29.4.12"
|
|
@@ -3,9 +3,7 @@ import {
|
|
|
3
3
|
registerCliModules,
|
|
4
4
|
getCliModules,
|
|
5
5
|
hasCliModules,
|
|
6
|
-
isHelpRequest,
|
|
7
6
|
padByCodePointWidth,
|
|
8
|
-
resolveEnvBootstrapOptions,
|
|
9
7
|
run,
|
|
10
8
|
} from '../mercato'
|
|
11
9
|
import { pathIncludes } from '../lib/__tests__/path-helpers'
|
|
@@ -189,264 +187,6 @@ describe('padByCodePointWidth', () => {
|
|
|
189
187
|
})
|
|
190
188
|
})
|
|
191
189
|
|
|
192
|
-
describe('--help never triggers side effects (issue #5581)', () => {
|
|
193
|
-
beforeEach(() => {
|
|
194
|
-
jest.restoreAllMocks()
|
|
195
|
-
})
|
|
196
|
-
|
|
197
|
-
describe('isHelpRequest', () => {
|
|
198
|
-
it('matches the long and short help flags in any position', () => {
|
|
199
|
-
expect(isHelpRequest(['db', 'generate', '--help'])).toBe(true)
|
|
200
|
-
expect(isHelpRequest(['-h'])).toBe(true)
|
|
201
|
-
})
|
|
202
|
-
|
|
203
|
-
it('does not match arguments that merely contain the flag text', () => {
|
|
204
|
-
expect(isHelpRequest(['db', 'generate'])).toBe(false)
|
|
205
|
-
expect(isHelpRequest(['--help-me'])).toBe(false)
|
|
206
|
-
expect(isHelpRequest(['--no-help'])).toBe(false)
|
|
207
|
-
expect(isHelpRequest([])).toBe(false)
|
|
208
|
-
})
|
|
209
|
-
})
|
|
210
|
-
|
|
211
|
-
describe('resolveEnvBootstrapOptions', () => {
|
|
212
|
-
it('refuses to create .env from .env.example for a help invocation', () => {
|
|
213
|
-
expect(resolveEnvBootstrapOptions(['db', 'generate', '--help'])).toEqual({
|
|
214
|
-
createIfMissing: false,
|
|
215
|
-
quiet: true,
|
|
216
|
-
})
|
|
217
|
-
expect(resolveEnvBootstrapOptions(['-h'])).toEqual({ createIfMissing: false, quiet: true })
|
|
218
|
-
})
|
|
219
|
-
|
|
220
|
-
it('still creates .env for a real command invocation', () => {
|
|
221
|
-
expect(resolveEnvBootstrapOptions(['db', 'generate'])).toEqual({
|
|
222
|
-
createIfMissing: true,
|
|
223
|
-
quiet: false,
|
|
224
|
-
})
|
|
225
|
-
})
|
|
226
|
-
|
|
227
|
-
it('keeps the pre-existing deploy and telemetry opt-outs', () => {
|
|
228
|
-
expect(resolveEnvBootstrapOptions(['deploy', 'railway'])).toEqual({
|
|
229
|
-
createIfMissing: false,
|
|
230
|
-
quiet: true,
|
|
231
|
-
})
|
|
232
|
-
expect(resolveEnvBootstrapOptions(['telemetry', 'init'])).toEqual({
|
|
233
|
-
createIfMissing: false,
|
|
234
|
-
quiet: true,
|
|
235
|
-
})
|
|
236
|
-
})
|
|
237
|
-
})
|
|
238
|
-
|
|
239
|
-
describe('dispatcher help branch', () => {
|
|
240
|
-
it('prints usage instead of running db:generate when --help is passed', async () => {
|
|
241
|
-
const consoleLogSpy = jest.spyOn(console, 'log').mockImplementation()
|
|
242
|
-
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation()
|
|
243
|
-
const dbGenerate = jest.fn()
|
|
244
|
-
|
|
245
|
-
registerCliModules([
|
|
246
|
-
{
|
|
247
|
-
id: 'db',
|
|
248
|
-
cli: [{ command: 'generate', help: 'Writes migrations. Applies nothing.', run: dbGenerate }],
|
|
249
|
-
} as any,
|
|
250
|
-
])
|
|
251
|
-
|
|
252
|
-
const exitCode = await run(['node', 'mercato', 'db', 'generate', '--help'])
|
|
253
|
-
|
|
254
|
-
expect(exitCode).toBe(0)
|
|
255
|
-
expect(dbGenerate).not.toHaveBeenCalled()
|
|
256
|
-
const printed = consoleLogSpy.mock.calls.map((call) => String(call[0])).join('\n')
|
|
257
|
-
expect(printed).toContain('mercato db generate [args]')
|
|
258
|
-
expect(printed).toContain('Writes migrations. Applies nothing.')
|
|
259
|
-
|
|
260
|
-
consoleLogSpy.mockRestore()
|
|
261
|
-
consoleErrorSpy.mockRestore()
|
|
262
|
-
})
|
|
263
|
-
|
|
264
|
-
it('prints usage instead of running db:migrate when -h is passed', async () => {
|
|
265
|
-
const consoleLogSpy = jest.spyOn(console, 'log').mockImplementation()
|
|
266
|
-
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation()
|
|
267
|
-
const dbMigrate = jest.fn()
|
|
268
|
-
|
|
269
|
-
registerCliModules([
|
|
270
|
-
{ id: 'db', cli: [{ command: 'migrate', run: dbMigrate }] } as any,
|
|
271
|
-
])
|
|
272
|
-
|
|
273
|
-
const exitCode = await run(['node', 'mercato', 'db', 'migrate', '-h'])
|
|
274
|
-
|
|
275
|
-
expect(exitCode).toBe(0)
|
|
276
|
-
expect(dbMigrate).not.toHaveBeenCalled()
|
|
277
|
-
|
|
278
|
-
consoleLogSpy.mockRestore()
|
|
279
|
-
consoleErrorSpy.mockRestore()
|
|
280
|
-
})
|
|
281
|
-
|
|
282
|
-
it('prints usage instead of destroying data when greenfield --yes --help is passed', async () => {
|
|
283
|
-
const consoleLogSpy = jest.spyOn(console, 'log').mockImplementation()
|
|
284
|
-
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation()
|
|
285
|
-
const dbGreenfield = jest.fn()
|
|
286
|
-
|
|
287
|
-
registerCliModules([
|
|
288
|
-
{
|
|
289
|
-
id: 'db',
|
|
290
|
-
cli: [{
|
|
291
|
-
command: 'greenfield',
|
|
292
|
-
help: 'Destroys all data.',
|
|
293
|
-
run: dbGreenfield,
|
|
294
|
-
}],
|
|
295
|
-
} as any,
|
|
296
|
-
])
|
|
297
|
-
|
|
298
|
-
// --yes is the flag that skips greenfield's confirmation prompt, so pairing it with
|
|
299
|
-
// --help is the scenario that must never reach `run`, regardless of flag order.
|
|
300
|
-
const exitCode = await run(['node', 'mercato', 'db', 'greenfield', '--yes', '--help'])
|
|
301
|
-
|
|
302
|
-
expect(exitCode).toBe(0)
|
|
303
|
-
expect(dbGreenfield).not.toHaveBeenCalled()
|
|
304
|
-
|
|
305
|
-
consoleLogSpy.mockRestore()
|
|
306
|
-
consoleErrorSpy.mockRestore()
|
|
307
|
-
})
|
|
308
|
-
|
|
309
|
-
it('forwards --help to commands that declare handlesHelp', async () => {
|
|
310
|
-
const consoleLogSpy = jest.spyOn(console, 'log').mockImplementation()
|
|
311
|
-
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation()
|
|
312
|
-
const deploy = jest.fn()
|
|
313
|
-
|
|
314
|
-
registerCliModules([
|
|
315
|
-
{ id: 'deploy', cli: [{ command: 'railway', handlesHelp: true, run: deploy }] } as any,
|
|
316
|
-
])
|
|
317
|
-
|
|
318
|
-
const exitCode = await run(['node', 'mercato', 'deploy', 'railway', '--help'])
|
|
319
|
-
|
|
320
|
-
expect(exitCode).toBe(0)
|
|
321
|
-
expect(deploy).toHaveBeenCalledWith(['--help'])
|
|
322
|
-
|
|
323
|
-
consoleLogSpy.mockRestore()
|
|
324
|
-
consoleErrorSpy.mockRestore()
|
|
325
|
-
})
|
|
326
|
-
|
|
327
|
-
it('lists the module commands when the help flag sits in the command slot', async () => {
|
|
328
|
-
const consoleLogSpy = jest.spyOn(console, 'log').mockImplementation()
|
|
329
|
-
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation()
|
|
330
|
-
const dbGenerate = jest.fn()
|
|
331
|
-
|
|
332
|
-
registerCliModules([
|
|
333
|
-
{
|
|
334
|
-
id: 'db',
|
|
335
|
-
cli: [
|
|
336
|
-
{ command: 'generate', run: dbGenerate },
|
|
337
|
-
{ command: 'migrate', run: jest.fn() },
|
|
338
|
-
],
|
|
339
|
-
} as any,
|
|
340
|
-
])
|
|
341
|
-
|
|
342
|
-
const exitCode = await run(['node', 'mercato', 'db', '--help'])
|
|
343
|
-
|
|
344
|
-
expect(exitCode).toBe(0)
|
|
345
|
-
expect(dbGenerate).not.toHaveBeenCalled()
|
|
346
|
-
expect(consoleErrorSpy).not.toHaveBeenCalled()
|
|
347
|
-
const printed = consoleLogSpy.mock.calls.map((call) => String(call[0])).join('\n')
|
|
348
|
-
expect(printed).toContain('Commands for "db": generate, migrate')
|
|
349
|
-
|
|
350
|
-
consoleLogSpy.mockRestore()
|
|
351
|
-
consoleErrorSpy.mockRestore()
|
|
352
|
-
})
|
|
353
|
-
|
|
354
|
-
it('lets a self-documenting command print its own subcommand help', async () => {
|
|
355
|
-
const consoleLogSpy = jest.spyOn(console, 'log').mockImplementation()
|
|
356
|
-
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation()
|
|
357
|
-
// Mirrors packages/core/src/modules/configs/cli.ts, whose `cache` command routes
|
|
358
|
-
// --help to its own printCacheHelp() rather than to the dispatcher's generic usage.
|
|
359
|
-
const cache = jest.fn((rest: string[]) => {
|
|
360
|
-
if (rest[0] === '--help') console.log('configs cache: stats | purge | structural')
|
|
361
|
-
})
|
|
362
|
-
|
|
363
|
-
registerCliModules([
|
|
364
|
-
{ id: 'configs', cli: [{ command: 'cache', handlesHelp: true, run: cache }] } as any,
|
|
365
|
-
])
|
|
366
|
-
|
|
367
|
-
const exitCode = await run(['node', 'mercato', 'configs', 'cache', '--help'])
|
|
368
|
-
|
|
369
|
-
expect(exitCode).toBe(0)
|
|
370
|
-
expect(cache).toHaveBeenCalledWith(['--help'])
|
|
371
|
-
const printed = consoleLogSpy.mock.calls.map((call) => String(call[0])).join('\n')
|
|
372
|
-
expect(printed).toContain('configs cache: stats | purge | structural')
|
|
373
|
-
expect(printed).not.toContain('Usage: ✨ mercato configs cache [args]')
|
|
374
|
-
|
|
375
|
-
consoleLogSpy.mockRestore()
|
|
376
|
-
consoleErrorSpy.mockRestore()
|
|
377
|
-
})
|
|
378
|
-
|
|
379
|
-
it('still runs the command when no help flag is present', async () => {
|
|
380
|
-
const consoleLogSpy = jest.spyOn(console, 'log').mockImplementation()
|
|
381
|
-
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation()
|
|
382
|
-
const dbGenerate = jest.fn()
|
|
383
|
-
|
|
384
|
-
registerCliModules([
|
|
385
|
-
{ id: 'db', cli: [{ command: 'generate', run: dbGenerate }] } as any,
|
|
386
|
-
])
|
|
387
|
-
|
|
388
|
-
const exitCode = await run(['node', 'mercato', 'db', 'generate'])
|
|
389
|
-
|
|
390
|
-
expect(exitCode).toBe(0)
|
|
391
|
-
expect(dbGenerate).toHaveBeenCalled()
|
|
392
|
-
|
|
393
|
-
consoleLogSpy.mockRestore()
|
|
394
|
-
consoleErrorSpy.mockRestore()
|
|
395
|
-
})
|
|
396
|
-
})
|
|
397
|
-
|
|
398
|
-
describe('top-level command help', () => {
|
|
399
|
-
it('prints usage instead of initializing the app when init --help is passed', async () => {
|
|
400
|
-
const consoleLogSpy = jest.spyOn(console, 'log').mockImplementation()
|
|
401
|
-
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation()
|
|
402
|
-
|
|
403
|
-
const exitCode = await run(['node', 'mercato', 'init', '--help'])
|
|
404
|
-
|
|
405
|
-
expect(exitCode).toBe(0)
|
|
406
|
-
const printed = consoleLogSpy.mock.calls.map((call) => String(call[0])).join('\n')
|
|
407
|
-
expect(printed).toContain('Usage: mercato init')
|
|
408
|
-
|
|
409
|
-
consoleLogSpy.mockRestore()
|
|
410
|
-
consoleErrorSpy.mockRestore()
|
|
411
|
-
})
|
|
412
|
-
|
|
413
|
-
it('prints usage instead of seeding when seed:defaults --help is passed', async () => {
|
|
414
|
-
const consoleLogSpy = jest.spyOn(console, 'log').mockImplementation()
|
|
415
|
-
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation()
|
|
416
|
-
|
|
417
|
-
const exitCode = await run(['node', 'mercato', 'seed:defaults', '--help'])
|
|
418
|
-
|
|
419
|
-
expect(exitCode).toBe(0)
|
|
420
|
-
const printed = consoleLogSpy.mock.calls.map((call) => String(call[0])).join('\n')
|
|
421
|
-
expect(printed).toContain('Usage: mercato seed:defaults')
|
|
422
|
-
|
|
423
|
-
consoleLogSpy.mockRestore()
|
|
424
|
-
consoleErrorSpy.mockRestore()
|
|
425
|
-
})
|
|
426
|
-
|
|
427
|
-
it.each(['constructor', 'toString', 'valueOf', 'hasOwnProperty', '__proto__'])(
|
|
428
|
-
'reports %s as an unknown module instead of matching an inherited prototype key',
|
|
429
|
-
async (inheritedKey) => {
|
|
430
|
-
const consoleLogSpy = jest.spyOn(console, 'log').mockImplementation()
|
|
431
|
-
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation()
|
|
432
|
-
|
|
433
|
-
registerCliModules([
|
|
434
|
-
{ id: 'db', cli: [{ command: 'generate', run: jest.fn() }] } as any,
|
|
435
|
-
])
|
|
436
|
-
|
|
437
|
-
const exitCode = await run(['node', 'mercato', inheritedKey, '--help'])
|
|
438
|
-
|
|
439
|
-
expect(exitCode).toBe(1)
|
|
440
|
-
const errors = consoleErrorSpy.mock.calls.map((call) => String(call[0])).join('\n')
|
|
441
|
-
expect(errors).toContain(`Module not found: "${inheritedKey}"`)
|
|
442
|
-
|
|
443
|
-
consoleLogSpy.mockRestore()
|
|
444
|
-
consoleErrorSpy.mockRestore()
|
|
445
|
-
},
|
|
446
|
-
)
|
|
447
|
-
})
|
|
448
|
-
})
|
|
449
|
-
|
|
450
190
|
describe('db command failure output', () => {
|
|
451
191
|
const originalDatabaseUrl = process.env.DATABASE_URL
|
|
452
192
|
|
|
@@ -573,110 +313,6 @@ describe('db command failure output', () => {
|
|
|
573
313
|
})
|
|
574
314
|
})
|
|
575
315
|
|
|
576
|
-
describe('module command exit signal propagation', () => {
|
|
577
|
-
let consoleErrorSpy: jest.SpyInstance
|
|
578
|
-
let consoleLogSpy: jest.SpyInstance
|
|
579
|
-
|
|
580
|
-
beforeEach(() => {
|
|
581
|
-
jest.restoreAllMocks()
|
|
582
|
-
consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation()
|
|
583
|
-
consoleLogSpy = jest.spyOn(console, 'log').mockImplementation()
|
|
584
|
-
})
|
|
585
|
-
|
|
586
|
-
afterEach(() => {
|
|
587
|
-
consoleErrorSpy.mockRestore()
|
|
588
|
-
consoleLogSpy.mockRestore()
|
|
589
|
-
process.exitCode = undefined
|
|
590
|
-
})
|
|
591
|
-
|
|
592
|
-
it('propagates a non-zero process.exitCode set by a command that does not throw', async () => {
|
|
593
|
-
registerCliModules([
|
|
594
|
-
{
|
|
595
|
-
id: 'reporting',
|
|
596
|
-
cli: [{
|
|
597
|
-
command: 'export',
|
|
598
|
-
run: jest.fn().mockImplementation(async () => {
|
|
599
|
-
process.exitCode = 1
|
|
600
|
-
}),
|
|
601
|
-
}],
|
|
602
|
-
} as any,
|
|
603
|
-
])
|
|
604
|
-
|
|
605
|
-
const exitCode = await run(['node', 'mercato', 'reporting', 'export'])
|
|
606
|
-
|
|
607
|
-
expect(exitCode).toBe(1)
|
|
608
|
-
})
|
|
609
|
-
|
|
610
|
-
it('preserves the exact exit code a command signals rather than collapsing it to 1', async () => {
|
|
611
|
-
registerCliModules([
|
|
612
|
-
{
|
|
613
|
-
id: 'reporting',
|
|
614
|
-
cli: [{
|
|
615
|
-
command: 'export',
|
|
616
|
-
run: jest.fn().mockImplementation(async () => {
|
|
617
|
-
process.exitCode = 42
|
|
618
|
-
}),
|
|
619
|
-
}],
|
|
620
|
-
} as any,
|
|
621
|
-
])
|
|
622
|
-
|
|
623
|
-
const exitCode = await run(['node', 'mercato', 'reporting', 'export'])
|
|
624
|
-
|
|
625
|
-
expect(exitCode).toBe(42)
|
|
626
|
-
})
|
|
627
|
-
|
|
628
|
-
it('returns 0 for a command that completes without signalling a failure', async () => {
|
|
629
|
-
registerCliModules([
|
|
630
|
-
{
|
|
631
|
-
id: 'reporting',
|
|
632
|
-
cli: [{ command: 'export', run: jest.fn().mockResolvedValue(undefined) }],
|
|
633
|
-
} as any,
|
|
634
|
-
])
|
|
635
|
-
|
|
636
|
-
const exitCode = await run(['node', 'mercato', 'reporting', 'export'])
|
|
637
|
-
|
|
638
|
-
expect(exitCode).toBe(0)
|
|
639
|
-
})
|
|
640
|
-
|
|
641
|
-
it('ignores a non-zero process.exitCode inherited from before the command ran', async () => {
|
|
642
|
-
process.exitCode = 7
|
|
643
|
-
|
|
644
|
-
registerCliModules([
|
|
645
|
-
{
|
|
646
|
-
id: 'reporting',
|
|
647
|
-
cli: [{ command: 'export', run: jest.fn().mockResolvedValue(undefined) }],
|
|
648
|
-
} as any,
|
|
649
|
-
])
|
|
650
|
-
|
|
651
|
-
const exitCode = await run(['node', 'mercato', 'reporting', 'export'])
|
|
652
|
-
|
|
653
|
-
expect(exitCode).toBe(0)
|
|
654
|
-
expect(process.exitCode).toBe(7)
|
|
655
|
-
})
|
|
656
|
-
|
|
657
|
-
it('still reports 1 when a command throws, regardless of process.exitCode', async () => {
|
|
658
|
-
process.exitCode = 7
|
|
659
|
-
|
|
660
|
-
registerCliModules([
|
|
661
|
-
{
|
|
662
|
-
id: 'reporting',
|
|
663
|
-
cli: [{
|
|
664
|
-
command: 'export',
|
|
665
|
-
run: jest.fn().mockImplementation(async () => {
|
|
666
|
-
process.exitCode = 3
|
|
667
|
-
throw new Error('export failed')
|
|
668
|
-
}),
|
|
669
|
-
}],
|
|
670
|
-
} as any,
|
|
671
|
-
])
|
|
672
|
-
|
|
673
|
-
const exitCode = await run(['node', 'mercato', 'reporting', 'export'])
|
|
674
|
-
|
|
675
|
-
expect(exitCode).toBe(1)
|
|
676
|
-
expect(process.exitCode).toBe(7)
|
|
677
|
-
})
|
|
678
|
-
})
|
|
679
|
-
|
|
680
316
|
describe('init command failure output', () => {
|
|
681
317
|
const originalDatabaseUrl = process.env.DATABASE_URL
|
|
682
318
|
|
|
@@ -893,122 +529,6 @@ describe('init command failure output', () => {
|
|
|
893
529
|
consoleErrorSpy.mockRestore()
|
|
894
530
|
consoleLogSpy.mockRestore()
|
|
895
531
|
})
|
|
896
|
-
|
|
897
|
-
function mockInitDependencies({
|
|
898
|
-
authSetup,
|
|
899
|
-
}: {
|
|
900
|
-
authSetup: jest.Mock
|
|
901
|
-
}) {
|
|
902
|
-
jest.doMock('child_process', () => ({
|
|
903
|
-
execSync: jest.fn(),
|
|
904
|
-
}))
|
|
905
|
-
jest.doMock('pg', () => ({
|
|
906
|
-
Client: jest.fn().mockImplementation(() => ({
|
|
907
|
-
connect: jest.fn().mockResolvedValue(undefined),
|
|
908
|
-
query: jest.fn().mockResolvedValue({
|
|
909
|
-
rows: [{ org_id: 'org-1', tenant_id: 'tenant-1' }],
|
|
910
|
-
}),
|
|
911
|
-
end: jest.fn().mockResolvedValue(undefined),
|
|
912
|
-
})),
|
|
913
|
-
}))
|
|
914
|
-
jest.doMock('../lib/generators', () => ({
|
|
915
|
-
generateEntityIds: jest.fn().mockResolvedValue(undefined),
|
|
916
|
-
generateModuleRegistries: jest.fn().mockResolvedValue(undefined),
|
|
917
|
-
generateModuleEntities: jest.fn().mockResolvedValue(undefined),
|
|
918
|
-
generateModuleDi: jest.fn().mockResolvedValue(undefined),
|
|
919
|
-
generateModulePackageSources: jest.fn().mockResolvedValue(undefined),
|
|
920
|
-
generateWebResearchAdapters: jest.fn().mockResolvedValue(undefined),
|
|
921
|
-
generateOpenApi: jest.fn().mockResolvedValue(undefined),
|
|
922
|
-
}))
|
|
923
|
-
jest.doMock('../lib/db', () => ({
|
|
924
|
-
dbMigrate: jest.fn().mockResolvedValue(undefined),
|
|
925
|
-
}))
|
|
926
|
-
jest.doMock('../lib/resolver', () => ({
|
|
927
|
-
createResolver: () => ({
|
|
928
|
-
getAppDir: () => '/tmp/test-app',
|
|
929
|
-
}),
|
|
930
|
-
}))
|
|
931
|
-
jest.doMock('@open-mercato/shared/lib/bootstrap/dynamicLoader', () => ({
|
|
932
|
-
bootstrapFromAppRoot: jest.fn().mockResolvedValue({
|
|
933
|
-
modules: [
|
|
934
|
-
{
|
|
935
|
-
id: 'configs',
|
|
936
|
-
cli: [{ command: 'restore-defaults', run: jest.fn().mockResolvedValue(undefined) }],
|
|
937
|
-
},
|
|
938
|
-
{
|
|
939
|
-
id: 'auth',
|
|
940
|
-
cli: [
|
|
941
|
-
{ command: 'setup', run: authSetup },
|
|
942
|
-
{ command: 'seed-roles', run: jest.fn().mockResolvedValue(undefined) },
|
|
943
|
-
],
|
|
944
|
-
},
|
|
945
|
-
{
|
|
946
|
-
id: 'entities',
|
|
947
|
-
cli: [{ command: 'seed-encryption', run: jest.fn().mockResolvedValue(undefined) }],
|
|
948
|
-
},
|
|
949
|
-
{
|
|
950
|
-
id: 'query_index',
|
|
951
|
-
cli: [{ command: 'reindex', run: jest.fn().mockResolvedValue(undefined) }],
|
|
952
|
-
},
|
|
953
|
-
],
|
|
954
|
-
}),
|
|
955
|
-
}))
|
|
956
|
-
jest.doMock('@open-mercato/shared/lib/di/container', () => ({
|
|
957
|
-
createRequestContainer: jest.fn().mockResolvedValue({
|
|
958
|
-
resolve: jest.fn().mockReturnValue({}),
|
|
959
|
-
}),
|
|
960
|
-
}))
|
|
961
|
-
jest.doMock(
|
|
962
|
-
'@open-mercato/core/modules/auth/lib/setup-app',
|
|
963
|
-
() => ({
|
|
964
|
-
ensureCustomRoleAcls: jest.fn().mockResolvedValue(undefined),
|
|
965
|
-
}),
|
|
966
|
-
{ virtual: true },
|
|
967
|
-
)
|
|
968
|
-
}
|
|
969
|
-
|
|
970
|
-
it('passes --include-demo-users to auth setup by default', async () => {
|
|
971
|
-
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation()
|
|
972
|
-
const consoleLogSpy = jest.spyOn(console, 'log').mockImplementation()
|
|
973
|
-
const authSetup = jest.fn().mockResolvedValue(undefined)
|
|
974
|
-
mockInitDependencies({ authSetup })
|
|
975
|
-
|
|
976
|
-
const mercato = await import('../mercato')
|
|
977
|
-
const exitCode = await mercato.run(['node', 'mercato', 'init'])
|
|
978
|
-
|
|
979
|
-
expect(exitCode).toBe(0)
|
|
980
|
-
expect(authSetup).toHaveBeenCalledWith(expect.arrayContaining(['--include-demo-users']))
|
|
981
|
-
expect(consoleLogSpy).toHaveBeenCalledWith('👤 Demo accounts (admin@/employee@): enabled')
|
|
982
|
-
const loggedLines = consoleLogSpy.mock.calls.map((args) => args.join(' '))
|
|
983
|
-
expect(loggedLines.some((line) => line.includes('🧰 Admin:'))).toBe(true)
|
|
984
|
-
expect(loggedLines.some((line) => line.includes('👷 Employee:'))).toBe(true)
|
|
985
|
-
|
|
986
|
-
consoleErrorSpy.mockRestore()
|
|
987
|
-
consoleLogSpy.mockRestore()
|
|
988
|
-
})
|
|
989
|
-
|
|
990
|
-
it('skips --include-demo-users when --no-demo-users is passed', async () => {
|
|
991
|
-
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation()
|
|
992
|
-
const consoleLogSpy = jest.spyOn(console, 'log').mockImplementation()
|
|
993
|
-
const authSetup = jest.fn().mockResolvedValue(undefined)
|
|
994
|
-
mockInitDependencies({ authSetup })
|
|
995
|
-
|
|
996
|
-
const mercato = await import('../mercato')
|
|
997
|
-
const exitCode = await mercato.run(['node', 'mercato', 'init', '--no-demo-users'])
|
|
998
|
-
|
|
999
|
-
expect(exitCode).toBe(0)
|
|
1000
|
-
expect(authSetup).toHaveBeenCalled()
|
|
1001
|
-
expect(authSetup.mock.calls[0][0]).not.toContain('--include-demo-users')
|
|
1002
|
-
expect(consoleLogSpy).toHaveBeenCalledWith(
|
|
1003
|
-
'👤 Demo accounts (admin@/employee@): skipped (--no-demo-users)',
|
|
1004
|
-
)
|
|
1005
|
-
const loggedLines = consoleLogSpy.mock.calls.map((args) => args.join(' '))
|
|
1006
|
-
expect(loggedLines.some((line) => line.includes('🧰 Admin:'))).toBe(false)
|
|
1007
|
-
expect(loggedLines.some((line) => line.includes('👷 Employee:'))).toBe(false)
|
|
1008
|
-
|
|
1009
|
-
consoleErrorSpy.mockRestore()
|
|
1010
|
-
consoleLogSpy.mockRestore()
|
|
1011
|
-
})
|
|
1012
532
|
})
|
|
1013
533
|
|
|
1014
534
|
describe('seed:defaults command', () => {
|
package/src/bin.ts
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
* Uses dynamic app resolution to find generated files at .mercato/generated/
|
|
6
6
|
*/
|
|
7
7
|
import { isTelemetryBackendEnabled } from '@open-mercato/shared/lib/telemetry/runtime'
|
|
8
|
-
import { installNextSubpathResolveHook } from '@open-mercato/shared/lib/bootstrap/next-subpath-resolve-hook'
|
|
9
8
|
import { resolveCliBootstrapMode, type CliBootstrapMode } from './lib/cli-bootstrap-mode.js'
|
|
10
9
|
import { flushBeforeExit } from './lib/flush-before-exit.js'
|
|
11
10
|
// `run` is imported dynamically inside `main()` so telemetry can initialize
|
|
@@ -73,10 +72,6 @@ async function tryBootstrap(mode: Exclude<CliBootstrapMode, 'none'>): Promise<bo
|
|
|
73
72
|
|
|
74
73
|
async function main(): Promise<void> {
|
|
75
74
|
assertNode24Runtime()
|
|
76
|
-
// Commands and workers run in plain Node, where a bare `next/<subpath>` such
|
|
77
|
-
// as `next/dynamic` or `next/link` does not resolve (#7102). Install the
|
|
78
|
-
// retry-with-`.js` hook before any package dist can be imported.
|
|
79
|
-
installNextSubpathResolveHook()
|
|
80
75
|
const bootstrapMode = resolveCliBootstrapMode(process.argv)
|
|
81
76
|
|
|
82
77
|
if (bootstrapMode !== 'none') {
|