@open-mercato/cli 0.10.1-develop.7576.1.21d5b50435 → 0.10.1-develop.7578.1.677eeb8343
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 +5 -1
- package/dist/agentic/guides/architecture.md +2 -0
- package/dist/agentic/guides/customers-calendar.md +57 -0
- package/dist/agentic/guides/extensions.md +2 -0
- package/dist/agentic/guides/module-facts.json +4287 -699
- package/dist/agentic/guides/module-facts.v2.json +4287 -699
- package/dist/agentic/guides/module-tool.md +35 -0
- 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 +3 -1
- package/dist/agentic/guides/modules/catalog/active-extension-bindings.md +3 -3
- package/dist/agentic/guides/modules/catalog/cli-commands.md +1 -0
- package/dist/agentic/guides/modules/catalog/contribution-resolutions.md +2 -0
- package/dist/agentic/guides/modules/catalog/di-registrations-rich.md +5 -4
- package/dist/agentic/guides/modules/catalog/di-service-tokens.md +2 -1
- package/dist/agentic/guides/modules/catalog/entities.md +1 -0
- package/dist/agentic/guides/modules/catalog/exact-override-targets.md +10 -4
- package/dist/agentic/guides/modules/catalog/index.md +5 -5
- package/dist/agentic/guides/modules/catalog/umes-contributions.md +2 -0
- package/dist/agentic/guides/modules/catalog/umes-hosts.md +1 -0
- package/dist/agentic/guides/modules/channel_apns/index.md +1 -1
- package/dist/agentic/guides/modules/channel_discord/index.md +1 -1
- package/dist/agentic/guides/modules/channel_expo/index.md +1 -1
- package/dist/agentic/guides/modules/channel_fcm/index.md +1 -1
- package/dist/agentic/guides/modules/channel_gmail/index.md +1 -1
- package/dist/agentic/guides/modules/channel_imap/index.md +1 -1
- package/dist/agentic/guides/modules/channel_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/incoming-installed-contributions.md +13 -0
- package/dist/agentic/guides/modules/customer_accounts/index.md +3 -2
- package/dist/agentic/guides/modules/customer_groups/active-extension-bindings.md +1 -1
- package/dist/agentic/guides/modules/customer_groups/incoming-installed-contributions.md +11 -0
- package/dist/agentic/guides/modules/customer_groups/index.md +3 -2
- package/dist/agentic/guides/modules/customers/active-extension-bindings.md +5 -5
- package/dist/agentic/guides/modules/customers/di-registrations-rich.md +5 -3
- package/dist/agentic/guides/modules/customers/exact-override-targets.md +5 -3
- 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 +2 -0
- 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/ecommerce/acl-features.md +15 -0
- package/dist/agentic/guides/modules/ecommerce/active-extension-bindings.md +12 -0
- package/dist/agentic/guides/modules/ecommerce/backend-pages.md +12 -0
- package/dist/agentic/guides/modules/ecommerce/contribution-resolutions.md +32 -0
- package/dist/agentic/guides/modules/ecommerce/di-registrations-rich.md +11 -0
- package/dist/agentic/guides/modules/ecommerce/di-service-tokens.md +11 -0
- package/dist/agentic/guides/modules/ecommerce/entities.md +13 -0
- package/dist/agentic/guides/modules/ecommerce/events.md +22 -0
- package/dist/agentic/guides/modules/ecommerce/exact-override-targets.md +41 -0
- package/dist/agentic/guides/modules/ecommerce/index.md +26 -0
- package/dist/agentic/guides/modules/ecommerce/notifications.md +12 -0
- package/dist/agentic/guides/modules/ecommerce/owned-contract-module-metadata.md +11 -0
- package/dist/agentic/guides/modules/ecommerce/search-entities.md +11 -0
- package/dist/agentic/guides/modules/ecommerce/setup.md +11 -0
- package/dist/agentic/guides/modules/ecommerce/umes-contributions.md +32 -0
- package/dist/agentic/guides/modules/ecommerce/umes-hosts.md +27 -0
- 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/gateway_tpay/acl-features.md +12 -0
- package/dist/agentic/guides/modules/gateway_tpay/cli-commands.md +12 -0
- package/dist/agentic/guides/modules/gateway_tpay/contribution-resolutions.md +12 -0
- package/dist/agentic/guides/modules/gateway_tpay/di-registrations-rich.md +11 -0
- package/dist/agentic/guides/modules/gateway_tpay/exact-override-targets.md +17 -0
- package/dist/agentic/guides/modules/gateway_tpay/index.md +19 -0
- package/dist/agentic/guides/modules/gateway_tpay/owned-contract-module-metadata.md +11 -0
- package/dist/agentic/guides/modules/gateway_tpay/setup.md +11 -0
- package/dist/agentic/guides/modules/gateway_tpay/umes-contributions.md +12 -0
- 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/di-registrations-rich.md +9 -8
- package/dist/agentic/guides/modules/integrations/di-service-tokens.md +5 -4
- package/dist/agentic/guides/modules/integrations/exact-override-targets.md +9 -8
- 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 +2 -1
- package/dist/agentic/guides/modules/wms/index.md +1 -1
- package/dist/agentic/guides/modules/wms/umes-hosts.md +1 -0
- 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 +443 -25
- package/dist/agentic/guides/reference-modules/example/active-extension-bindings.md +2 -0
- package/dist/agentic/guides/reference-modules/example/contribution-resolutions.md +9 -4
- package/dist/agentic/guides/reference-modules/example/di-registrations-rich.md +3 -2
- package/dist/agentic/guides/reference-modules/example/di-service-tokens.md +1 -1
- package/dist/agentic/guides/reference-modules/example/exact-override-targets.md +12 -6
- package/dist/agentic/guides/reference-modules/example/index.md +4 -4
- package/dist/agentic/guides/reference-modules/example/umes-contributions.md +10 -5
- package/dist/agentic/guides/reference-modules/example/umes-hosts.md +1 -0
- package/dist/agentic/guides/upstream/BACKWARD_COMPATIBILITY.md +46 -0
- package/dist/agentic/guides/upstream/manifest.json +2 -2
- package/dist/agentic/shared/AGENTS.md.template +1 -0
- package/dist/agentic/shared/ai/harness/README.md +6 -2
- package/dist/agentic/shared/ai/harness/RELEASE.md +4 -4
- package/dist/agentic/shared/ai/harness/cases.json +371 -39
- package/dist/agentic/shared/ai/harness/cases.schema.json +4 -4
- package/dist/agentic/shared/ai/harness/design-system-inventory.json +63 -3
- package/dist/agentic/shared/ai/harness/source-link-inventory.json +316 -8
- 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 +2 -0
- package/dist/agentic/shared/scripts/evaluate-agent-harness.mjs +78 -9
- package/dist/agentic/shared/scripts/execution-sandbox.mjs +8 -7
- package/dist/bin.js +2 -0
- package/dist/bin.js.map +2 -2
- package/dist/lib/testing/integration.js +2 -0
- package/dist/lib/testing/integration.js.map +2 -2
- package/dist/mercato.js +87 -17
- package/dist/mercato.js.map +2 -2
- package/package.json +7 -7
- package/src/__tests__/mercato.test.ts +480 -0
- package/src/bin.ts +5 -0
- package/src/lib/__tests__/bin-next-subpath-hook.test.ts +25 -0
- package/src/lib/testing/integration.ts +2 -0
- package/src/mercato.ts +104 -14
package/src/mercato.ts
CHANGED
|
@@ -327,7 +327,11 @@ async function ensureEnvLoaded(options: { createIfMissing?: boolean; quiet?: boo
|
|
|
327
327
|
const examplePath = path.join(appDir, '.env.example')
|
|
328
328
|
if (fs.existsSync(examplePath)) {
|
|
329
329
|
fs.copyFileSync(examplePath, envPath)
|
|
330
|
-
console.log(
|
|
330
|
+
console.log('')
|
|
331
|
+
console.log('⚠️ No .env was found, so one was created from .env.example.')
|
|
332
|
+
console.log(` ${envPath}`)
|
|
333
|
+
console.log(' It carries the example placeholders — review DATABASE_URL and secrets before continuing.')
|
|
334
|
+
console.log('')
|
|
331
335
|
}
|
|
332
336
|
}
|
|
333
337
|
if (fs.existsSync(envPath)) {
|
|
@@ -894,14 +898,67 @@ async function buildAllModules(): Promise<Module[]> {
|
|
|
894
898
|
return all
|
|
895
899
|
}
|
|
896
900
|
|
|
901
|
+
export function isHelpRequest(args: string[]): boolean {
|
|
902
|
+
return args.some((arg) => arg === '--help' || arg === '-h')
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
// Top-level commands that return before the module dispatcher and therefore never reach its
|
|
906
|
+
// generic help branch. Without an entry here, `mercato init --help` runs a full install.
|
|
907
|
+
const TOP_LEVEL_COMMAND_HELP: Record<string, string[]> = {
|
|
908
|
+
init: [
|
|
909
|
+
'Usage: mercato init [--reinstall|-r] [--no-examples] [--no-demo-users] [--stresstest [--lite] [--count=<n>]]',
|
|
910
|
+
'Initializes this app: installs dependencies, runs generators, applies migrations and seeds data.',
|
|
911
|
+
],
|
|
912
|
+
'agentic:init': [
|
|
913
|
+
'Usage: mercato agentic:init [--force]',
|
|
914
|
+
'Scaffolds the agentic harness (AGENTS.md, .ai/ config and skills) into this app.',
|
|
915
|
+
],
|
|
916
|
+
'seed:defaults': [
|
|
917
|
+
'Usage: mercato seed:defaults [--module <moduleId>]',
|
|
918
|
+
'Runs every enabled module\'s seedDefaults hook, or only the named module\'s.',
|
|
919
|
+
],
|
|
920
|
+
'umes:list': [
|
|
921
|
+
'Usage: mercato umes:list',
|
|
922
|
+
'Lists the extension points every enabled module declares.',
|
|
923
|
+
],
|
|
924
|
+
'umes:inspect': [
|
|
925
|
+
'Usage: mercato umes:inspect --module <moduleId>',
|
|
926
|
+
'Prints the extension surface a single module declares.',
|
|
927
|
+
],
|
|
928
|
+
'umes:check': [
|
|
929
|
+
'Usage: mercato umes:check',
|
|
930
|
+
'Validates declared extension points against the modules that implement them.',
|
|
931
|
+
],
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
// A help invocation must never materialize .env from .env.example — asking what the flags are
|
|
935
|
+
// should not mutate the working tree, least of all with the example's placeholder DATABASE_URL.
|
|
936
|
+
export function resolveEnvBootstrapOptions(parts: string[]): { createIfMissing: boolean; quiet: boolean } {
|
|
937
|
+
const first = parts[0]
|
|
938
|
+
const opaqueEnvCommand = first === 'deploy' || first === 'telemetry'
|
|
939
|
+
const helpRequested = isHelpRequest(parts)
|
|
940
|
+
return {
|
|
941
|
+
createIfMissing: !helpRequested && !opaqueEnvCommand,
|
|
942
|
+
quiet: helpRequested || opaqueEnvCommand,
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
|
|
897
946
|
export async function run(argv = process.argv) {
|
|
898
947
|
const [, , ...parts] = argv
|
|
899
948
|
const [first, second, ...remaining] = parts
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
949
|
+
// Help must never have side effects: it must not create .env, and must not fall through
|
|
950
|
+
// to the command it is asking about.
|
|
951
|
+
const helpRequested = isHelpRequest(parts)
|
|
952
|
+
await ensureEnvLoaded(resolveEnvBootstrapOptions(parts))
|
|
953
|
+
|
|
954
|
+
// Object.hasOwn, not a truthiness check: the map is indexed with raw user input, and an
|
|
955
|
+
// inherited Object.prototype member (`constructor`, `toString`, …) would otherwise pass the
|
|
956
|
+
// guard and then fail to iterate instead of reporting the module as not found.
|
|
957
|
+
if (helpRequested && first && Object.hasOwn(TOP_LEVEL_COMMAND_HELP, first)) {
|
|
958
|
+
for (const line of TOP_LEVEL_COMMAND_HELP[first]) console.log(` ${line}`)
|
|
959
|
+
return 0
|
|
960
|
+
}
|
|
961
|
+
|
|
905
962
|
// Handle init command directly
|
|
906
963
|
if (first === 'init') {
|
|
907
964
|
const { execSync } = await import('child_process')
|
|
@@ -918,6 +975,7 @@ export async function run(argv = process.argv) {
|
|
|
918
975
|
delete process.env.OM_INIT_REINSTALL
|
|
919
976
|
}
|
|
920
977
|
const skipExamples = initArgs.includes('--no-examples')
|
|
978
|
+
const skipDemoUsers = initArgs.includes('--no-demo-users')
|
|
921
979
|
const stressTestEnabled =
|
|
922
980
|
initArgs.includes('--stresstest') || initArgs.includes('--stress-test')
|
|
923
981
|
const stressTestLite =
|
|
@@ -958,6 +1016,7 @@ export async function run(argv = process.argv) {
|
|
|
958
1016
|
}
|
|
959
1017
|
console.log(`🔄 Reinstall mode: ${reinstall ? 'enabled' : 'disabled'}`)
|
|
960
1018
|
console.log(`🎨 Example content: ${skipExamples ? 'skipped (--no-examples)' : 'enabled'}`)
|
|
1019
|
+
console.log(`👤 Demo accounts (admin@/employee@): ${skipDemoUsers ? 'skipped (--no-demo-users)' : 'enabled'}`)
|
|
961
1020
|
console.log(
|
|
962
1021
|
`🏋️ Stress test dataset: ${
|
|
963
1022
|
stressTestEnabled
|
|
@@ -1148,10 +1207,10 @@ export async function run(argv = process.argv) {
|
|
|
1148
1207
|
const derivedSecrets = resolveInitDerivedSecrets({ email, env: process.env })
|
|
1149
1208
|
const adminEmailDerived = derivedSecrets.adminEmail
|
|
1150
1209
|
const employeeEmailDerived = derivedSecrets.employeeEmail
|
|
1151
|
-
if (adminEmailDerived && derivedSecrets.adminPassword) {
|
|
1210
|
+
if (!skipDemoUsers && adminEmailDerived && derivedSecrets.adminPassword) {
|
|
1152
1211
|
process.env.OM_INIT_ADMIN_PASSWORD = derivedSecrets.adminPassword
|
|
1153
1212
|
}
|
|
1154
|
-
if (employeeEmailDerived && derivedSecrets.employeePassword) {
|
|
1213
|
+
if (!skipDemoUsers && employeeEmailDerived && derivedSecrets.employeePassword) {
|
|
1155
1214
|
process.env.OM_INIT_EMPLOYEE_PASSWORD = derivedSecrets.employeePassword
|
|
1156
1215
|
}
|
|
1157
1216
|
const roles = findArgValue(['--roles='], 'superadmin,admin,employee')
|
|
@@ -1172,12 +1231,15 @@ export async function run(argv = process.argv) {
|
|
|
1172
1231
|
'--email', email,
|
|
1173
1232
|
'--password', password,
|
|
1174
1233
|
'--roles', roles,
|
|
1234
|
+
]
|
|
1235
|
+
if (!skipDemoUsers) {
|
|
1175
1236
|
// `mercato init` is the dev/demo bootstrap flow — it explicitly wants
|
|
1176
1237
|
// the derived admin@/employee@ demo accounts. Standalone callers of
|
|
1177
1238
|
// `mercato auth setup` must opt in themselves; without this flag the
|
|
1178
1239
|
// setup command no longer seeds those accounts by default.
|
|
1179
|
-
|
|
1180
|
-
|
|
1240
|
+
// `--no-demo-users` opts a caller (e.g. a production `init`) out of them.
|
|
1241
|
+
setupArgs.push('--include-demo-users')
|
|
1242
|
+
}
|
|
1181
1243
|
if (skipPasswordPolicy) {
|
|
1182
1244
|
setupArgs.push('--skip-password-policy')
|
|
1183
1245
|
}
|
|
@@ -1331,8 +1393,10 @@ export async function run(argv = process.argv) {
|
|
|
1331
1393
|
createdPasswords.set(value.toLowerCase(), passwordValue)
|
|
1332
1394
|
}
|
|
1333
1395
|
pushUser('Superadmin', '👑', email, password)
|
|
1334
|
-
|
|
1335
|
-
|
|
1396
|
+
if (!skipDemoUsers) {
|
|
1397
|
+
pushUser('Admin', '🧰', adminEmailDerived, adminPasswordOverride ?? password)
|
|
1398
|
+
pushUser('Employee', '👷', employeeEmailDerived, employeePasswordOverride ?? password)
|
|
1399
|
+
}
|
|
1336
1400
|
// Simplified success message: we know which users were created
|
|
1337
1401
|
console.log('🎉 App initialization complete!\n')
|
|
1338
1402
|
console.log('╔══════════════════════════════════════════════════════════════╗')
|
|
@@ -1633,6 +1697,8 @@ export async function run(argv = process.argv) {
|
|
|
1633
1697
|
cli: [
|
|
1634
1698
|
{
|
|
1635
1699
|
command: 'railway',
|
|
1700
|
+
// Parses --help/-h itself and prints railwayDeployHelp() without deploying.
|
|
1701
|
+
handlesHelp: true,
|
|
1636
1702
|
run: async (args: string[]) => {
|
|
1637
1703
|
const { runRailwayDeploy } = await import('./lib/deploy/railway/index')
|
|
1638
1704
|
await runRailwayDeploy(args)
|
|
@@ -2001,6 +2067,7 @@ export async function run(argv = process.argv) {
|
|
|
2001
2067
|
cli: [
|
|
2002
2068
|
{
|
|
2003
2069
|
command: 'generate',
|
|
2070
|
+
help: 'Generates a migration per module from the current ORM entities and refreshes each\nmodule\'s .snapshot-open-mercato.json. Writes files only — nothing is applied.',
|
|
2004
2071
|
run: async () => {
|
|
2005
2072
|
const { createResolver } = await import('./lib/resolver')
|
|
2006
2073
|
const { dbGenerate } = await import('./lib/db')
|
|
@@ -2010,6 +2077,7 @@ export async function run(argv = process.argv) {
|
|
|
2010
2077
|
},
|
|
2011
2078
|
{
|
|
2012
2079
|
command: 'migrate',
|
|
2080
|
+
help: 'Applies every pending migration to the database DATABASE_URL points at.\nThis mutates the database — check .env before running it.',
|
|
2013
2081
|
run: async () => {
|
|
2014
2082
|
const { createResolver } = await import('./lib/resolver')
|
|
2015
2083
|
const { dbMigrate } = await import('./lib/db')
|
|
@@ -2019,6 +2087,7 @@ export async function run(argv = process.argv) {
|
|
|
2019
2087
|
},
|
|
2020
2088
|
{
|
|
2021
2089
|
command: 'greenfield',
|
|
2090
|
+
help: 'Drops and recreates the schema from scratch, then re-applies every migration.\nDestroys all data. Pass --yes (-y) to skip the confirmation prompt.',
|
|
2022
2091
|
run: async (args: string[]) => {
|
|
2023
2092
|
const { createResolver } = await import('./lib/resolver')
|
|
2024
2093
|
const { dbGreenfield } = await import('./lib/db')
|
|
@@ -2689,12 +2758,31 @@ export async function run(argv = process.argv) {
|
|
|
2689
2758
|
console.log(pad(`Commands for "${modName}": ${mod.cli.map((c) => c.command).join(', ')}`))
|
|
2690
2759
|
return 1
|
|
2691
2760
|
}
|
|
2761
|
+
// A help flag in the command slot (`mercato db --help`) asks what this module offers.
|
|
2762
|
+
if (isHelpRequest([cmdName])) {
|
|
2763
|
+
console.log(pad(`Usage: ✨ mercato ${modName} <command> [args]`))
|
|
2764
|
+
console.log(pad(`Commands for "${modName}": ${mod.cli.map((c) => c.command).join(', ')}`))
|
|
2765
|
+
return 0
|
|
2766
|
+
}
|
|
2692
2767
|
const cmd = mod.cli.find((c) => c.command === cmdName)
|
|
2693
2768
|
if (!cmd) {
|
|
2694
2769
|
console.error(`🤔 Unknown command "${cmdName}". Available: ${mod.cli.map((c) => c.command).join(', ')}`)
|
|
2695
2770
|
return 1
|
|
2696
2771
|
}
|
|
2697
2772
|
|
|
2773
|
+
// `--help` must describe the command, never run it. Commands that parse the flag themselves
|
|
2774
|
+
// opt out via `handlesHelp` so their own richer usage text still wins.
|
|
2775
|
+
if (isHelpRequest(rest) && !cmd.handlesHelp) {
|
|
2776
|
+
console.log(pad(`Usage: ✨ mercato ${modName} ${cmdName} [args]`))
|
|
2777
|
+
if (cmd.help) {
|
|
2778
|
+
console.log('')
|
|
2779
|
+
for (const line of cmd.help.split('\n')) console.log(pad(line))
|
|
2780
|
+
}
|
|
2781
|
+
console.log('')
|
|
2782
|
+
console.log(pad(`Commands for "${modName}": ${mod.cli.map((c) => c.command).join(', ')}`))
|
|
2783
|
+
return 0
|
|
2784
|
+
}
|
|
2785
|
+
|
|
2698
2786
|
console.log('')
|
|
2699
2787
|
const started = Date.now()
|
|
2700
2788
|
const loggedArgs = modName === 'deploy' && cmdName === 'railway'
|
|
@@ -2702,12 +2790,14 @@ export async function run(argv = process.argv) {
|
|
|
2702
2790
|
: rest
|
|
2703
2791
|
console.log(`🚀 Running ${modName}:${cmdName} ${loggedArgs.join(' ')}`)
|
|
2704
2792
|
try {
|
|
2705
|
-
await
|
|
2793
|
+
const commandExitCode = await runWithCapturedExitCode(async () => {
|
|
2794
|
+
await cmd.run(rest)
|
|
2795
|
+
})
|
|
2706
2796
|
if (modName !== 'deploy' || cmdName !== 'railway') {
|
|
2707
2797
|
const ms = Date.now() - started
|
|
2708
2798
|
console.log(`⏱️ Done in ${ms}ms`)
|
|
2709
2799
|
}
|
|
2710
|
-
return
|
|
2800
|
+
return commandExitCode
|
|
2711
2801
|
} catch (e: any) {
|
|
2712
2802
|
console.error(`💥 Failed: ${formatCliFailureMessage(modName, cmdName, e)}`)
|
|
2713
2803
|
return 1
|