@open-mercato/cli 0.11.1-develop.8593.1.50784dae35 → 0.11.1-develop.8687.1.adb16f62b3
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 +6 -2
- package/AGENTS.md +2 -0
- package/dist/agentic/guides/architecture.md +2 -2
- package/dist/agentic/guides/extensions.md +7 -2
- package/dist/agentic/guides/framework-extension-points.md +1 -0
- package/dist/agentic/guides/infrastructure-providers.md +20 -0
- package/dist/agentic/guides/integrations.md +2 -2
- package/dist/agentic/guides/module-facts.json +11067 -7122
- package/dist/agentic/guides/module-facts.v2.json +11055 -7094
- 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/assisted_selling/acl-features.md +16 -0
- package/dist/agentic/guides/modules/assisted_selling/contribution-resolutions.md +21 -0
- package/dist/agentic/guides/modules/assisted_selling/domain-commands.md +11 -0
- package/dist/agentic/guides/modules/assisted_selling/entities.md +11 -0
- package/dist/agentic/guides/modules/assisted_selling/events.md +22 -0
- package/dist/agentic/guides/modules/assisted_selling/exact-override-targets.md +17 -0
- package/dist/agentic/guides/modules/assisted_selling/index.md +21 -0
- package/dist/agentic/guides/modules/assisted_selling/owned-contract-module-metadata.md +11 -0
- package/dist/agentic/guides/modules/assisted_selling/setup.md +11 -0
- package/dist/agentic/guides/modules/assisted_selling/umes-contributions.md +21 -0
- package/dist/agentic/guides/modules/assisted_selling/umes-hosts.md +23 -0
- package/dist/agentic/guides/modules/attachments/exact-override-targets.md +1 -1
- package/dist/agentic/guides/modules/attachments/index.md +1 -1
- package/dist/agentic/guides/modules/attachments/workers.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/backups/di-registrations-rich.md +11 -0
- package/dist/agentic/guides/modules/backups/di-service-tokens.md +11 -0
- package/dist/agentic/guides/modules/backups/exact-override-targets.md +11 -0
- package/dist/agentic/guides/modules/backups/index.md +5 -2
- package/dist/agentic/guides/modules/business_rules/index.md +1 -1
- package/dist/agentic/guides/modules/carrier_inpost/index.md +1 -1
- package/dist/agentic/guides/modules/cart/index.md +1 -1
- package/dist/agentic/guides/modules/catalog/acl-features.md +2 -1
- package/dist/agentic/guides/modules/catalog/active-extension-bindings.md +2 -0
- package/dist/agentic/guides/modules/catalog/backend-pages.md +1 -0
- package/dist/agentic/guides/modules/catalog/contribution-resolutions.md +5 -0
- package/dist/agentic/guides/modules/catalog/di-registrations-rich.md +8 -7
- package/dist/agentic/guides/modules/catalog/di-service-tokens.md +5 -4
- package/dist/agentic/guides/modules/catalog/domain-commands.md +2 -0
- package/dist/agentic/guides/modules/catalog/entities.md +1 -0
- package/dist/agentic/guides/modules/catalog/events.md +4 -1
- package/dist/agentic/guides/modules/catalog/exact-override-targets.md +13 -7
- package/dist/agentic/guides/modules/catalog/index.md +9 -9
- package/dist/agentic/guides/modules/catalog/umes-contributions.md +5 -0
- package/dist/agentic/guides/modules/catalog/umes-hosts.md +4 -0
- package/dist/agentic/guides/modules/catalog/workers.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/channel_smtp/index.md +1 -1
- package/dist/agentic/guides/modules/checkout/index.md +1 -1
- package/dist/agentic/guides/modules/communication_channels/exact-override-targets.md +1 -1
- package/dist/agentic/guides/modules/communication_channels/index.md +1 -1
- package/dist/agentic/guides/modules/communication_channels/workers.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/active-extension-bindings.md +11 -0
- package/dist/agentic/guides/modules/currencies/di-registrations-rich.md +1 -1
- package/dist/agentic/guides/modules/currencies/di-service-tokens.md +1 -1
- package/dist/agentic/guides/modules/currencies/exact-override-targets.md +1 -1
- package/dist/agentic/guides/modules/currencies/index.md +3 -2
- package/dist/agentic/guides/modules/customer_accounts/active-extension-bindings.md +1 -1
- package/dist/agentic/guides/modules/customer_accounts/exact-override-targets.md +2 -0
- package/dist/agentic/guides/modules/customer_accounts/index.md +2 -2
- package/dist/agentic/guides/modules/customer_accounts/workers.md +2 -0
- package/dist/agentic/guides/modules/customer_groups/index.md +1 -1
- package/dist/agentic/guides/modules/customers/active-extension-bindings.md +2 -1
- package/dist/agentic/guides/modules/customers/incoming-installed-contributions.md +1 -0
- package/dist/agentic/guides/modules/customers/index.md +3 -3
- package/dist/agentic/guides/modules/customers/umes-hosts.md +1 -0
- package/dist/agentic/guides/modules/dashboards/active-extension-bindings.md +0 -1
- package/dist/agentic/guides/modules/dashboards/cli-commands.md +1 -0
- package/dist/agentic/guides/modules/dashboards/exact-override-targets.md +1 -0
- package/dist/agentic/guides/modules/dashboards/index.md +2 -3
- 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/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_autopay/index.md +1 -1
- package/dist/agentic/guides/modules/gateway_stripe/index.md +1 -1
- package/dist/agentic/guides/modules/gateway_tpay/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/di-registrations-rich.md +8 -8
- package/dist/agentic/guides/modules/integrations/di-service-tokens.md +4 -4
- package/dist/agentic/guides/modules/integrations/exact-override-targets.md +14 -12
- package/dist/agentic/guides/modules/integrations/index.md +2 -2
- package/dist/agentic/guides/modules/integrations/setup.md +1 -1
- package/dist/agentic/guides/modules/integrations/workers.md +3 -1
- package/dist/agentic/guides/modules/ledger/acl-features.md +16 -0
- package/dist/agentic/guides/modules/ledger/active-extension-bindings.md +11 -0
- package/dist/agentic/guides/modules/ledger/backend-pages.md +21 -0
- package/dist/agentic/guides/modules/ledger/domain-commands.md +22 -0
- package/dist/agentic/guides/modules/ledger/encryption.md +11 -0
- package/dist/agentic/guides/modules/ledger/entities.md +17 -0
- package/dist/agentic/guides/modules/ledger/events.md +19 -0
- package/dist/agentic/guides/modules/ledger/exact-override-targets.md +30 -0
- package/dist/agentic/guides/modules/ledger/index.md +22 -0
- package/dist/agentic/guides/modules/ledger/owned-contract-module-metadata.md +11 -0
- package/dist/agentic/guides/modules/ledger/setup.md +11 -0
- package/dist/agentic/guides/modules/ledger/umes-hosts.md +26 -0
- 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/active-extension-bindings.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/progress/index.md +1 -1
- package/dist/agentic/guides/modules/promotions/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/exact-override-targets.md +3 -3
- package/dist/agentic/guides/modules/resources/index.md +1 -1
- package/dist/agentic/guides/modules/resources/owned-contract-module-metadata.md +1 -1
- package/dist/agentic/guides/modules/resources/setup.md +1 -1
- package/dist/agentic/guides/modules/sales/contribution-resolutions.md +1 -0
- package/dist/agentic/guides/modules/sales/exact-override-targets.md +1 -0
- package/dist/agentic/guides/modules/sales/index.md +3 -3
- package/dist/agentic/guides/modules/sales/umes-contributions.md +1 -0
- package/dist/agentic/guides/modules/scheduler/index.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/index.md +1 -1
- package/dist/agentic/guides/modules/sso/index.md +1 -1
- package/dist/agentic/guides/modules/staff/contribution-resolutions.md +1 -1
- package/dist/agentic/guides/modules/staff/exact-override-targets.md +1 -1
- package/dist/agentic/guides/modules/staff/index.md +1 -1
- package/dist/agentic/guides/modules/staff/workers.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/index.md +1 -1
- package/dist/agentic/guides/modules/wms/index.md +1 -1
- package/dist/agentic/guides/modules/workflows/index.md +1 -1
- package/dist/agentic/guides/reference-module-facts.json +811 -21
- package/dist/agentic/guides/reference-modules/example/active-extension-bindings.md +1 -0
- package/dist/agentic/guides/reference-modules/example/backend-pages.md +2 -0
- package/dist/agentic/guides/reference-modules/example/contribution-resolutions.md +3 -1
- package/dist/agentic/guides/reference-modules/example/di-registrations-rich.md +3 -3
- package/dist/agentic/guides/reference-modules/example/di-service-tokens.md +1 -1
- package/dist/agentic/guides/reference-modules/example/entities.md +2 -0
- package/dist/agentic/guides/reference-modules/example/events.md +2 -1
- package/dist/agentic/guides/reference-modules/example/exact-override-targets.md +25 -8
- package/dist/agentic/guides/reference-modules/example/index.md +7 -7
- package/dist/agentic/guides/reference-modules/example/notifications.md +1 -0
- package/dist/agentic/guides/reference-modules/example/setup.md +1 -1
- package/dist/agentic/guides/reference-modules/example/umes-contributions.md +3 -1
- package/dist/agentic/guides/reference-modules/example/umes-hosts.md +4 -0
- package/dist/agentic/guides/upstream/AGENTS.md +5 -4
- package/dist/agentic/guides/upstream/BACKWARD_COMPATIBILITY.md +37 -20
- package/dist/agentic/guides/upstream/manifest.json +3 -3
- package/dist/agentic/shared/AGENTS.md.template +12 -16
- package/dist/agentic/shared/ai/harness/README.md +4 -2
- package/dist/agentic/shared/ai/harness/RELEASE.md +4 -4
- package/dist/agentic/shared/ai/harness/cases.json +1420 -41
- package/dist/agentic/shared/ai/harness/cases.schema.json +4 -4
- package/dist/agentic/shared/ai/harness/design-system-inventory.json +640 -142
- package/dist/agentic/shared/ai/harness/source-link-inventory.json +223 -16
- package/dist/agentic/shared/ai/harness/validators.json +1 -1
- package/dist/agentic/shared/ai/skills/om-system-extension/SKILL.md +1 -1
- package/dist/agentic/shared/ai/skills/om-system-extension/references/extension-branches.md +25 -0
- package/dist/agentic/shared/ai/skills/om-system-extension/references/mechanism-selector.md +1 -0
- package/dist/agentic/shared/ai/skills/om-system-extension/references/unified-overrides.md +2 -0
- package/dist/agentic/shared/scripts/run-agent-harness-release.mjs +21 -1
- package/dist/lib/cache-provider-manifest.js +9 -0
- package/dist/lib/cache-provider-manifest.js.map +7 -0
- package/dist/lib/generate-watch-plan.js +4 -0
- package/dist/lib/generate-watch-plan.js.map +2 -2
- package/dist/lib/generate-watch-runner.js +1 -0
- package/dist/lib/generate-watch-runner.js.map +2 -2
- package/dist/lib/generate-watch-structure.js +2 -0
- package/dist/lib/generate-watch-structure.js.map +2 -2
- package/dist/lib/generators/ast/writers.js +5 -1
- package/dist/lib/generators/ast/writers.js.map +2 -2
- package/dist/lib/generators/cache-providers.js +80 -0
- package/dist/lib/generators/cache-providers.js.map +7 -0
- package/dist/lib/generators/form-section-ast.js +156 -0
- package/dist/lib/generators/form-section-ast.js.map +7 -0
- package/dist/lib/generators/form-section-extension-compiler.js +568 -0
- package/dist/lib/generators/form-section-extension-compiler.js.map +7 -0
- package/dist/lib/generators/form-section-extension-source.js +245 -0
- package/dist/lib/generators/form-section-extension-source.js.map +7 -0
- package/dist/lib/generators/form-section-runtime-revisions.js +184 -0
- package/dist/lib/generators/form-section-runtime-revisions.js.map +7 -0
- package/dist/lib/generators/form-sections.js +773 -0
- package/dist/lib/generators/form-sections.js.map +7 -0
- package/dist/lib/generators/index.js +2 -0
- package/dist/lib/generators/index.js.map +2 -2
- package/dist/lib/generators/module-entities.js +21 -2
- package/dist/lib/generators/module-entities.js.map +2 -2
- package/dist/lib/generators/module-extension-facts.js +2 -1
- package/dist/lib/generators/module-extension-facts.js.map +2 -2
- package/dist/lib/generators/module-facts.js +30 -1
- package/dist/lib/generators/module-facts.js.map +2 -2
- package/dist/lib/generators/module-override-targets.js +24 -2
- package/dist/lib/generators/module-override-targets.js.map +2 -2
- package/dist/lib/generators/module-registry.js +75 -3
- package/dist/lib/generators/module-registry.js.map +2 -2
- package/dist/lib/generators/openapi.js +27 -17
- package/dist/lib/generators/openapi.js.map +2 -2
- package/dist/lib/post-generate-invalidation.js +20 -1
- package/dist/lib/post-generate-invalidation.js.map +2 -2
- package/dist/lib/resolver.js +195 -1
- package/dist/lib/resolver.js.map +3 -3
- package/dist/lib/scaffold/field-dsl.js +393 -0
- package/dist/lib/scaffold/field-dsl.js.map +7 -0
- package/dist/lib/scaffold/index.js +412 -0
- package/dist/lib/scaffold/index.js.map +7 -0
- package/dist/lib/scaffold/targets.js +42 -0
- package/dist/lib/scaffold/targets.js.map +7 -0
- package/dist/lib/scaffold/templates/create-page.js +52 -0
- package/dist/lib/scaffold/templates/create-page.js.map +7 -0
- package/dist/lib/scaffold/templates/detail-page.js +186 -0
- package/dist/lib/scaffold/templates/detail-page.js.map +7 -0
- package/dist/lib/scaffold/templates/form-config.js +42 -0
- package/dist/lib/scaffold/templates/form-config.js.map +7 -0
- package/dist/lib/scaffold/templates/index.js +27 -0
- package/dist/lib/scaffold/templates/index.js.map +7 -0
- package/dist/lib/scaffold/templates/list-page.js +190 -0
- package/dist/lib/scaffold/templates/list-page.js.map +7 -0
- package/dist/lib/scaffold/templates/metas.js +47 -0
- package/dist/lib/scaffold/templates/metas.js.map +7 -0
- package/dist/lib/scaffold/templates/module-files.js +85 -0
- package/dist/lib/scaffold/templates/module-files.js.map +7 -0
- package/dist/lib/single-instance-strategy-guard.js +26 -3
- package/dist/lib/single-instance-strategy-guard.js.map +2 -2
- package/dist/lib/testing/integration-discovery.js +32 -3
- package/dist/lib/testing/integration-discovery.js.map +2 -2
- package/dist/lib/testing/integration.js +232 -8
- package/dist/lib/testing/integration.js.map +2 -2
- package/dist/mercato.js +40 -7
- package/dist/mercato.js.map +2 -2
- package/jest.config.cjs +2 -0
- package/package.json +7 -7
- package/src/__tests__/mercato.test.ts +18 -0
- package/src/__tests__/rotation-json-output.test.ts +52 -0
- package/src/lib/__tests__/agentic-workflows-ownership.test.ts +79 -0
- package/src/lib/__tests__/cache-provider-manifest.test.ts +76 -0
- package/src/lib/__tests__/generate-watch-plan.test.ts +3 -2
- package/src/lib/__tests__/generate-watch-runner.test.ts +13 -1
- package/src/lib/__tests__/generate-watch-structure.test.ts +34 -0
- package/src/lib/__tests__/post-generate-invalidation.test.ts +108 -0
- package/src/lib/__tests__/resolver.form-section-gates.test.ts +82 -0
- package/src/lib/__tests__/single-instance-strategy-guard.test.ts +129 -0
- package/src/lib/cache-provider-manifest.ts +8 -0
- package/src/lib/generate-watch-plan.ts +6 -3
- package/src/lib/generate-watch-runner.ts +1 -0
- package/src/lib/generate-watch-structure.ts +5 -1
- package/src/lib/generators/__tests__/cache-providers.test.ts +102 -0
- package/src/lib/generators/__tests__/derived-crud-route-collisions.test.ts +85 -0
- package/src/lib/generators/__tests__/form-section-outbox.test.ts +53 -0
- package/src/lib/generators/__tests__/form-sections.test.ts +896 -0
- package/src/lib/generators/__tests__/module-extension-facts.test.ts +1 -0
- package/src/lib/generators/__tests__/module-facts.bc-guard.test.ts +8 -6
- package/src/lib/generators/__tests__/module-facts.example-fact-coverage.test.ts +37 -13
- package/src/lib/generators/__tests__/module-facts.local-reference.test.ts +13 -0
- package/src/lib/generators/__tests__/module-override-targets.test.ts +2 -3
- package/src/lib/generators/__tests__/module-subset.test.ts +1 -1
- package/src/lib/generators/__tests__/openapi.test.ts +60 -13
- package/src/lib/generators/__tests__/structural-contracts.test.ts +2 -2
- package/src/lib/generators/ast/writers.ts +6 -1
- package/src/lib/generators/cache-providers.ts +111 -0
- package/src/lib/generators/form-section-ast.ts +166 -0
- package/src/lib/generators/form-section-extension-compiler.ts +632 -0
- package/src/lib/generators/form-section-extension-source.ts +308 -0
- package/src/lib/generators/form-section-runtime-revisions.ts +211 -0
- package/src/lib/generators/form-sections.ts +896 -0
- package/src/lib/generators/index.ts +1 -0
- package/src/lib/generators/module-entities.ts +22 -4
- package/src/lib/generators/module-extension-facts.ts +1 -0
- package/src/lib/generators/module-facts.ts +40 -0
- package/src/lib/generators/module-override-targets.ts +19 -0
- package/src/lib/generators/module-registry.ts +80 -4
- package/src/lib/generators/openapi.ts +31 -20
- package/src/lib/post-generate-invalidation.ts +28 -1
- package/src/lib/resolver.ts +218 -0
- package/src/lib/scaffold/__tests__/__snapshots__/scaffold-golden.test.ts.snap +1742 -0
- package/src/lib/scaffold/__tests__/helpers.ts +75 -0
- package/src/lib/scaffold/__tests__/scaffold-ds-contract.test.ts +248 -0
- package/src/lib/scaffold/__tests__/scaffold-golden.test.ts +267 -0
- package/src/lib/scaffold/__tests__/scaffold-runtime.test.tsx +193 -0
- package/src/lib/scaffold/field-dsl.ts +491 -0
- package/src/lib/scaffold/index.ts +531 -0
- package/src/lib/scaffold/targets.ts +68 -0
- package/src/lib/scaffold/templates/create-page.ts +52 -0
- package/src/lib/scaffold/templates/detail-page.ts +190 -0
- package/src/lib/scaffold/templates/form-config.ts +42 -0
- package/src/lib/scaffold/templates/index.ts +27 -0
- package/src/lib/scaffold/templates/list-page.ts +190 -0
- package/src/lib/scaffold/templates/metas.ts +48 -0
- package/src/lib/scaffold/templates/module-files.ts +87 -0
- package/src/lib/single-instance-strategy-guard.ts +51 -1
- package/src/lib/testing/__tests__/integration-app-only-playwright.test.ts +225 -0
- package/src/lib/testing/__tests__/integration-app-only.test.ts +320 -0
- package/src/lib/testing/__tests__/integration-discovery.test.ts +45 -1
- package/src/lib/testing/integration-discovery.ts +32 -2
- package/src/lib/testing/integration.ts +293 -11
- package/src/mercato.ts +39 -5
- package/dist/agentic/guides/modules/dashboards/incoming-installed-contributions.md +0 -11
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
import os from 'node:os'
|
|
3
|
+
import path from 'node:path'
|
|
4
|
+
import type { PackageResolver, ModuleEntry } from '../../resolver'
|
|
5
|
+
import { runModuleScaffold } from '../index'
|
|
6
|
+
|
|
7
|
+
export function createTmpRoot(): string {
|
|
8
|
+
// realpath: on macOS os.tmpdir() is a /var → /private/var symlink; tools that
|
|
9
|
+
// realpath their inputs (ESLint base-path checks) would otherwise see every
|
|
10
|
+
// file as outside the unresolved root.
|
|
11
|
+
return fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'scaffold-test-')))
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function createMockResolver(rootDir: string): PackageResolver {
|
|
15
|
+
return {
|
|
16
|
+
isMonorepo: () => true,
|
|
17
|
+
getRootDir: () => rootDir,
|
|
18
|
+
getAppDir: () => path.join(rootDir, 'apps', 'mercato'),
|
|
19
|
+
getOutputDir: () => path.join(rootDir, 'apps', 'mercato', '.mercato', 'generated'),
|
|
20
|
+
getModulesConfigPath: () => path.join(rootDir, 'apps', 'mercato', 'src', 'modules.ts'),
|
|
21
|
+
discoverPackages: () => [],
|
|
22
|
+
loadEnabledModules: () => [],
|
|
23
|
+
getModulePaths: (entry: ModuleEntry) => ({
|
|
24
|
+
appBase: path.join(rootDir, 'apps', 'mercato', 'src', 'modules', entry.id),
|
|
25
|
+
pkgBase: path.join(rootDir, 'packages', 'core', 'src', 'modules', entry.id),
|
|
26
|
+
}),
|
|
27
|
+
getModuleImportBase: (entry: ModuleEntry) => ({
|
|
28
|
+
appBase: `@/modules/${entry.id}`,
|
|
29
|
+
pkgBase: `@open-mercato/core/modules/${entry.id}`,
|
|
30
|
+
}),
|
|
31
|
+
getPackageOutputDir: () => path.join(rootDir, 'apps', 'mercato', '.mercato', 'generated'),
|
|
32
|
+
getPackageRoot: () => path.join(rootDir, 'packages', 'core'),
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type CapturedRun = {
|
|
37
|
+
code: number
|
|
38
|
+
logs: string[]
|
|
39
|
+
errors: string[]
|
|
40
|
+
output: string
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export async function runScaffold(rootDir: string, args: string[]): Promise<CapturedRun> {
|
|
44
|
+
const logs: string[] = []
|
|
45
|
+
const errors: string[] = []
|
|
46
|
+
const code = await runModuleScaffold(args, {
|
|
47
|
+
resolver: createMockResolver(rootDir),
|
|
48
|
+
logger: {
|
|
49
|
+
log: (message: string) => logs.push(message),
|
|
50
|
+
error: (message: string) => errors.push(message),
|
|
51
|
+
},
|
|
52
|
+
})
|
|
53
|
+
return { code, logs, errors, output: [...logs, ...errors].join('\n') }
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Recursively read every file under `dir` into a sorted relPath → contents map. */
|
|
57
|
+
export function readTree(dir: string): Map<string, string> {
|
|
58
|
+
const files = new Map<string, string>()
|
|
59
|
+
if (!fs.existsSync(dir)) return files
|
|
60
|
+
const walk = (current: string) => {
|
|
61
|
+
for (const entry of fs.readdirSync(current, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
62
|
+
const absPath = path.join(current, entry.name)
|
|
63
|
+
if (entry.isDirectory()) walk(absPath)
|
|
64
|
+
else files.set(path.relative(dir, absPath).split(path.sep).join('/'), fs.readFileSync(absPath, 'utf8'))
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
walk(dir)
|
|
68
|
+
return files
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Every field type + both required shapes + status and non-status selects. */
|
|
72
|
+
export const FULL_FIELDS =
|
|
73
|
+
'name:text:required,summary:textarea,quantity:number:required,status:select(open|in_progress|closed),severity:select(low|high):required,archived:checkbox,dueDate:date:required'
|
|
74
|
+
|
|
75
|
+
export const FULL_ARGS = ['inventory_items', '--entity', 'stock_item', '--fields', FULL_FIELDS, '--with-ui']
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DS contract test for `mercato module scaffold` (spec:
|
|
3
|
+
* .ai/specs/2026-07-05-ds-module-ui-scaffold.md §Testing layer 2).
|
|
4
|
+
*
|
|
5
|
+
* Two halves:
|
|
6
|
+
* 1. Programmatic ESLint run with the repo's DS flat config
|
|
7
|
+
* (eslint.ds.config.mjs via fixtures/ds-flat-config.mjs, which only widens
|
|
8
|
+
* the `files` globs to the temp dir) → zero errors AND zero warnings.
|
|
9
|
+
* 2. The guardian ANALYZE checklist markers from
|
|
10
|
+
* .ai/skills/om-ds-guardian/references/page-templates.md §DS Checklist,
|
|
11
|
+
* asserted directly on the generated sources. When the guardian gains a
|
|
12
|
+
* rule, this test fails until the templates comply.
|
|
13
|
+
*/
|
|
14
|
+
import { spawnSync } from 'node:child_process'
|
|
15
|
+
import fs from 'node:fs'
|
|
16
|
+
import path from 'node:path'
|
|
17
|
+
import { pathToFileURL } from 'node:url'
|
|
18
|
+
import { FULL_ARGS, createTmpRoot, readTree, runScaffold } from './helpers'
|
|
19
|
+
|
|
20
|
+
const REPO_ROOT = path.resolve(__dirname, '..', '..', '..', '..', '..', '..')
|
|
21
|
+
|
|
22
|
+
let tmpDir: string
|
|
23
|
+
let moduleDir: string
|
|
24
|
+
let tree: Map<string, string>
|
|
25
|
+
let dsConfigPath: string
|
|
26
|
+
|
|
27
|
+
beforeAll(async () => {
|
|
28
|
+
tmpDir = createTmpRoot()
|
|
29
|
+
const run = await runScaffold(tmpDir, FULL_ARGS)
|
|
30
|
+
expect(run.errors).toEqual([])
|
|
31
|
+
expect(run.code).toBe(0)
|
|
32
|
+
moduleDir = path.join(tmpDir, 'apps', 'mercato', 'src', 'modules', 'inventory_items')
|
|
33
|
+
tree = readTree(moduleDir)
|
|
34
|
+
// ESLint's base path with --config is the CONFIG FILE's directory — a config
|
|
35
|
+
// living in the repo makes every temp-dir file "outside of base path" and
|
|
36
|
+
// silently unlintable. Write the widened config into the temp root itself,
|
|
37
|
+
// importing the repo's DS flat config verbatim by absolute file URL.
|
|
38
|
+
dsConfigPath = path.join(tmpDir, 'ds-flat-config.mjs')
|
|
39
|
+
const repoConfigUrl = pathToFileURL(path.join(REPO_ROOT, 'eslint.ds.config.mjs')).href
|
|
40
|
+
fs.writeFileSync(
|
|
41
|
+
dsConfigPath,
|
|
42
|
+
[
|
|
43
|
+
`import baseConfig from ${JSON.stringify(repoConfigUrl)}`,
|
|
44
|
+
'',
|
|
45
|
+
'export default baseConfig.map((entry) => ({',
|
|
46
|
+
' ...entry,',
|
|
47
|
+
" files: ['**/*.ts', '**/*.tsx'],",
|
|
48
|
+
' ignores: [],',
|
|
49
|
+
'}))',
|
|
50
|
+
'',
|
|
51
|
+
].join('\n'),
|
|
52
|
+
)
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
afterAll(() => {
|
|
56
|
+
fs.rmSync(tmpDir, { recursive: true, force: true })
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
function fileOrThrow(relPath: string): string {
|
|
60
|
+
const contents = tree.get(relPath)
|
|
61
|
+
if (contents === undefined) throw new Error(`expected generated file ${relPath}`)
|
|
62
|
+
return contents
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function pageFiles(): Array<[string, string]> {
|
|
66
|
+
return [...tree.entries()].filter(([relPath]) => relPath.endsWith('.tsx'))
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function codeFiles(): Array<[string, string]> {
|
|
70
|
+
return [...tree.entries()].filter(([relPath]) => relPath.endsWith('.ts') || relPath.endsWith('.tsx'))
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
describe('DS lint gate (repo eslint.ds config, programmatic run)', () => {
|
|
74
|
+
it('generated pages produce zero errors and zero warnings', () => {
|
|
75
|
+
// TS7-native root: eslint's parser needs the JS compiler API, which only
|
|
76
|
+
// the typescript-js alias provides — run through the repo's require hook.
|
|
77
|
+
const eslintJs = path.join(REPO_ROOT, 'node_modules', 'eslint', 'bin', 'eslint.js')
|
|
78
|
+
const requireHook = path.join(REPO_ROOT, 'scripts', 'typescript-js-require-hook.cjs')
|
|
79
|
+
// Explicit absolute file list, not '.': directory-pattern expansion against
|
|
80
|
+
// a temp cwd resolved differently across platforms in CI (the Linux runner
|
|
81
|
+
// matched zero files), while explicitly-passed paths are always linted.
|
|
82
|
+
const lintTargets = [...tree.keys()]
|
|
83
|
+
.filter((relPath) => relPath.endsWith('.ts') || relPath.endsWith('.tsx'))
|
|
84
|
+
.map((relPath) => path.join(moduleDir, relPath))
|
|
85
|
+
const result = spawnSync(
|
|
86
|
+
process.execPath,
|
|
87
|
+
['--require', requireHook, eslintJs, '--no-config-lookup', '--config', dsConfigPath, '--format', 'json', ...lintTargets],
|
|
88
|
+
{
|
|
89
|
+
cwd: moduleDir,
|
|
90
|
+
encoding: 'utf8',
|
|
91
|
+
timeout: 120_000,
|
|
92
|
+
// Minimal, controlled env: the jest/turbo process env (NODE_OPTIONS,
|
|
93
|
+
// NODE_PATH, ts tooling variables) must not leak into the child and
|
|
94
|
+
// change how eslint resolves its parser toolchain.
|
|
95
|
+
env: { PATH: process.env.PATH ?? '', HOME: process.env.HOME ?? '' },
|
|
96
|
+
},
|
|
97
|
+
)
|
|
98
|
+
expect(result.error).toBeUndefined()
|
|
99
|
+
if (result.status !== 0 && result.status !== 1) {
|
|
100
|
+
const toolchain = spawnSync(
|
|
101
|
+
process.execPath,
|
|
102
|
+
['-p', `(() => { const p = require.resolve('typescript', { paths: [${JSON.stringify(path.join(REPO_ROOT, 'node_modules', '@typescript-eslint', 'typescript-estree'))}] }); const ts = require(p); return p + ' v' + ts.version + ' Extension=' + typeof ts.Extension })()`],
|
|
103
|
+
{ encoding: 'utf8', timeout: 30_000 },
|
|
104
|
+
)
|
|
105
|
+
throw new Error(
|
|
106
|
+
`[internal] eslint exited with ${result.status}\nstderr: ${result.stderr}\nstdout: ${result.stdout}\ntoolchain: ${toolchain.stdout || toolchain.stderr}`,
|
|
107
|
+
)
|
|
108
|
+
}
|
|
109
|
+
const reports = JSON.parse(result.stdout || '[]') as Array<{
|
|
110
|
+
filePath: string
|
|
111
|
+
errorCount: number
|
|
112
|
+
warningCount: number
|
|
113
|
+
messages: Array<{ ruleId: string | null; message: string }>
|
|
114
|
+
}>
|
|
115
|
+
// Every generated page (and module file) must have been linted…
|
|
116
|
+
const lintedPages = reports.filter((report) => report.filePath.endsWith('page.tsx'))
|
|
117
|
+
expect(lintedPages).toHaveLength(3)
|
|
118
|
+
// …with zero findings (the plugin runs at warn severity during rollout, so
|
|
119
|
+
// warnings are failures here — the scaffold must be clean, not "tolerated").
|
|
120
|
+
const findings = reports.flatMap((report) =>
|
|
121
|
+
report.messages.map((message) => `${report.filePath}: ${message.ruleId ?? 'fatal'} ${message.message}`),
|
|
122
|
+
)
|
|
123
|
+
expect(findings).toEqual([])
|
|
124
|
+
expect(reports.reduce((sum, report) => sum + report.errorCount + report.warningCount, 0)).toBe(0)
|
|
125
|
+
expect(result.status).toBe(0)
|
|
126
|
+
})
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
describe('guardian checklist markers', () => {
|
|
130
|
+
it('list page renders EmptyState and passes isLoading to DataTable', () => {
|
|
131
|
+
const listPage = fileOrThrow('backend/inventory_items/page.tsx')
|
|
132
|
+
expect(listPage).toContain("import { EmptyState } from '@open-mercato/ui/primitives/empty-state'")
|
|
133
|
+
expect(listPage).toContain('emptyState={(')
|
|
134
|
+
expect(listPage).toContain('isLoading={isLoading}')
|
|
135
|
+
expect(listPage).toContain('<Page>')
|
|
136
|
+
expect(listPage).toContain('<PageBody>')
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
it('detail page uses LoadingMessage / ErrorMessage for the fetch lifecycle', () => {
|
|
140
|
+
const detailPage = fileOrThrow('backend/inventory_items/[id]/page.tsx')
|
|
141
|
+
expect(detailPage).toContain("import { LoadingMessage, ErrorMessage } from '@open-mercato/ui/backend/detail'")
|
|
142
|
+
expect(detailPage).toContain('<LoadingMessage label=')
|
|
143
|
+
expect(detailPage).toContain('<ErrorMessage label=')
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
it('status is rendered through StatusBadge + the shared StatusMap module', () => {
|
|
147
|
+
expect(tree.has('components/statusMap.ts')).toBe(true)
|
|
148
|
+
const statusMap = fileOrThrow('components/statusMap.ts')
|
|
149
|
+
expect(statusMap).toContain("import type { StatusMap } from '@open-mercato/ui/primitives/status-badge'")
|
|
150
|
+
expect(statusMap).toContain("export type StockItemStatus = 'open' | 'in_progress' | 'closed'")
|
|
151
|
+
const listPage = fileOrThrow('backend/inventory_items/page.tsx')
|
|
152
|
+
expect(listPage).toContain('<StatusBadge variant={stockItemStatusMap[status]')
|
|
153
|
+
const detailPage = fileOrThrow('backend/inventory_items/[id]/page.tsx')
|
|
154
|
+
expect(detailPage).toContain('statusBadge={record.status ? (')
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
it('data flows through apiCall/crud helpers — never raw fetch', () => {
|
|
158
|
+
for (const [relPath, contents] of codeFiles()) {
|
|
159
|
+
expect(`${relPath}: ${contents}`).not.toMatch(/\bfetch\s*\(/)
|
|
160
|
+
}
|
|
161
|
+
const listPage = fileOrThrow('backend/inventory_items/page.tsx')
|
|
162
|
+
expect(listPage).toContain("from '@open-mercato/ui/backend/utils/apiCall'")
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
it('metadata guards are present on every page.meta.ts', () => {
|
|
166
|
+
const metas = [...tree.entries()].filter(([relPath]) => relPath.endsWith('page.meta.ts'))
|
|
167
|
+
expect(metas).toHaveLength(3)
|
|
168
|
+
for (const [, contents] of metas) {
|
|
169
|
+
expect(contents).toContain('requireAuth: true')
|
|
170
|
+
expect(contents).toMatch(/requireFeatures: \['inventory_items\.(view|create)'\]/)
|
|
171
|
+
expect(contents).toContain('breadcrumb: [')
|
|
172
|
+
expect(contents).toContain('pageTitleKey:')
|
|
173
|
+
expect(contents).toContain('pageGroupKey:')
|
|
174
|
+
}
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
it('uses semantic tokens only — no inline svg, arbitrary values, palette classes, dark: overrides or pill chips', () => {
|
|
178
|
+
const forbidden: Array<[string, RegExp]> = [
|
|
179
|
+
['inline <svg>', /<svg/],
|
|
180
|
+
['arbitrary text size text-[', /text-\[/],
|
|
181
|
+
['dark: override', /dark:/],
|
|
182
|
+
['full-pill rounded-full', /rounded-full/],
|
|
183
|
+
['raw palette class', /(?:text|bg|border)-(?:red|green|blue|emerald|amber|yellow|sky|rose|lime|orange|slate|gray|zinc|stone)-\d/],
|
|
184
|
+
['hardcoded hex color', /#[0-9a-fA-F]{3,8}\b/],
|
|
185
|
+
]
|
|
186
|
+
const violations: string[] = []
|
|
187
|
+
for (const [relPath, contents] of codeFiles()) {
|
|
188
|
+
for (const [label, pattern] of forbidden) {
|
|
189
|
+
if (pattern.test(contents)) violations.push(`${relPath}: ${label}`)
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
expect(violations).toEqual([])
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
it('routes every user-facing string through t() with i18n keys emitted to every app locale', () => {
|
|
196
|
+
for (const [relPath, contents] of pageFiles()) {
|
|
197
|
+
expect(contents).toContain('useT()')
|
|
198
|
+
// No literal JSX text nodes — all copy is {t('key', 'Fallback')}.
|
|
199
|
+
const literalTextNodes = contents.match(/>\s*[A-Za-z][A-Za-z ,.']*</g) ?? []
|
|
200
|
+
expect(`${relPath}: ${literalTextNodes.join(' | ')}`).toBe(`${relPath}: `)
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const en = JSON.parse(fileOrThrow('i18n/en.json')) as Record<string, string>
|
|
204
|
+
for (const locale of ['pl', 'es', 'de', 'ko']) {
|
|
205
|
+
const dict = JSON.parse(fileOrThrow(`i18n/${locale}.json`)) as Record<string, string>
|
|
206
|
+
expect(Object.keys(dict).sort()).toEqual(Object.keys(en).sort())
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// Every t('<key>', ...) key referenced with a literal is present in en.json.
|
|
210
|
+
// Keys ending with '.' are dynamic prefixes (e.g. status option lookups);
|
|
211
|
+
// their concrete variants are asserted via the option keys below.
|
|
212
|
+
const referenced = new Set<string>()
|
|
213
|
+
for (const [, contents] of codeFiles()) {
|
|
214
|
+
for (const match of contents.matchAll(/t\('([a-zA-Z0-9_.]+)'/g)) {
|
|
215
|
+
if (!match[1].endsWith('.')) referenced.add(match[1])
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
const missing = [...referenced].filter((key) => !(key in en)).sort()
|
|
219
|
+
expect(missing).toEqual([])
|
|
220
|
+
expect(en['inventory_items.fields.status.options.in_progress']).toBe('In progress')
|
|
221
|
+
expect(en['inventory_items.fields.severity.options.high']).toBe('High')
|
|
222
|
+
})
|
|
223
|
+
|
|
224
|
+
it('edit flows through CrudForm with initialValues.updatedAt (optimistic locking default-ON)', () => {
|
|
225
|
+
const detailPage = fileOrThrow('backend/inventory_items/[id]/page.tsx')
|
|
226
|
+
expect(detailPage).toContain('updatedAt: record.updatedAt ?? undefined,')
|
|
227
|
+
expect(detailPage).toContain('<CrudForm<StockItemUpdateInput>')
|
|
228
|
+
expect(detailPage).toContain('initialValues={initialValues}')
|
|
229
|
+
const validators = fileOrThrow('data/validators.ts')
|
|
230
|
+
expect(validators).toContain('`updatedAt`')
|
|
231
|
+
expect(validators).toContain('`updated_at`')
|
|
232
|
+
})
|
|
233
|
+
|
|
234
|
+
it('row actions use stable ids with confirm dialog + flash', () => {
|
|
235
|
+
const listPage = fileOrThrow('backend/inventory_items/page.tsx')
|
|
236
|
+
expect(listPage).toContain("id: 'edit',")
|
|
237
|
+
expect(listPage).toContain("id: 'delete',")
|
|
238
|
+
expect(listPage).toContain('useConfirmDialog()')
|
|
239
|
+
expect(listPage).toContain("flash(t('inventory_items.delete.success'")
|
|
240
|
+
})
|
|
241
|
+
|
|
242
|
+
it('keeps pageSize at or below 100', () => {
|
|
243
|
+
const listPage = fileOrThrow('backend/inventory_items/page.tsx')
|
|
244
|
+
const match = listPage.match(/const PAGE_SIZE = (\d+)/)
|
|
245
|
+
expect(match).not.toBeNull()
|
|
246
|
+
expect(Number(match?.[1])).toBeLessThanOrEqual(100)
|
|
247
|
+
})
|
|
248
|
+
})
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Golden-file tests for `mercato module scaffold` (spec:
|
|
3
|
+
* .ai/specs/2026-07-05-ds-module-ui-scaffold.md §Testing layer 1).
|
|
4
|
+
*
|
|
5
|
+
* Every emitted file is pinned as a jest snapshot — an intentional template
|
|
6
|
+
* change updates snapshots via `--updateSnapshot` and therefore always shows
|
|
7
|
+
* up in review diffs; a template edit can never ship invisibly.
|
|
8
|
+
*
|
|
9
|
+
* To update snapshots after an intentional change:
|
|
10
|
+
* npx jest --updateSnapshot scaffold-golden
|
|
11
|
+
*/
|
|
12
|
+
import fs from 'node:fs'
|
|
13
|
+
import path from 'node:path'
|
|
14
|
+
import { FieldDslError, parseFieldsSpec } from '../field-dsl'
|
|
15
|
+
import { FULL_ARGS, createTmpRoot, readTree, runScaffold } from './helpers'
|
|
16
|
+
|
|
17
|
+
const tmpRoots: string[] = []
|
|
18
|
+
|
|
19
|
+
function tmpRoot(): string {
|
|
20
|
+
const root = createTmpRoot()
|
|
21
|
+
tmpRoots.push(root)
|
|
22
|
+
return root
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
afterAll(() => {
|
|
26
|
+
for (const root of tmpRoots) fs.rmSync(root, { recursive: true, force: true })
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
const APP_MODULE_DIR = ['apps', 'mercato', 'src', 'modules', 'inventory_items']
|
|
30
|
+
const CORE_MODULE_DIR = ['packages', 'core', 'src', 'modules', 'inventory_items']
|
|
31
|
+
|
|
32
|
+
describe('scaffold golden files', () => {
|
|
33
|
+
it('emits the full DS-compliant UI slice for every field type (app target)', async () => {
|
|
34
|
+
const root = tmpRoot()
|
|
35
|
+
const run = await runScaffold(root, FULL_ARGS)
|
|
36
|
+
expect(run.errors).toEqual([])
|
|
37
|
+
expect(run.code).toBe(0)
|
|
38
|
+
|
|
39
|
+
const tree = readTree(path.join(root, ...APP_MODULE_DIR))
|
|
40
|
+
expect([...tree.keys()].sort()).toEqual([
|
|
41
|
+
'acl.ts',
|
|
42
|
+
'backend/inventory_items/[id]/page.meta.ts',
|
|
43
|
+
'backend/inventory_items/[id]/page.tsx',
|
|
44
|
+
'backend/inventory_items/create/page.meta.ts',
|
|
45
|
+
'backend/inventory_items/create/page.tsx',
|
|
46
|
+
'backend/inventory_items/page.meta.ts',
|
|
47
|
+
'backend/inventory_items/page.tsx',
|
|
48
|
+
'components/formConfig.ts',
|
|
49
|
+
'components/statusMap.ts',
|
|
50
|
+
'data/validators.ts',
|
|
51
|
+
'i18n/de.json',
|
|
52
|
+
'i18n/en.json',
|
|
53
|
+
'i18n/es.json',
|
|
54
|
+
'i18n/ko.json',
|
|
55
|
+
'i18n/pl.json',
|
|
56
|
+
'index.ts',
|
|
57
|
+
'setup.ts',
|
|
58
|
+
])
|
|
59
|
+
|
|
60
|
+
for (const [relPath, contents] of [...tree.entries()].sort(([a], [b]) => a.localeCompare(b))) {
|
|
61
|
+
expect(contents).toMatchSnapshot(relPath)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Non-English locales carry the identical key set with English values and
|
|
65
|
+
// are flagged as "needs translation" in the summary.
|
|
66
|
+
expect(tree.get('i18n/pl.json')).toBe(tree.get('i18n/en.json'))
|
|
67
|
+
expect(tree.get('i18n/es.json')).toBe(tree.get('i18n/en.json'))
|
|
68
|
+
expect(tree.get('i18n/de.json')).toBe(tree.get('i18n/en.json'))
|
|
69
|
+
expect(tree.get('i18n/ko.json')).toBe(tree.get('i18n/en.json'))
|
|
70
|
+
expect(run.output).toContain('needs translation')
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
it('scaffolds identical contents into the packages/core target shape', async () => {
|
|
74
|
+
const appRoot = tmpRoot()
|
|
75
|
+
const coreRoot = tmpRoot()
|
|
76
|
+
const appRun = await runScaffold(appRoot, FULL_ARGS)
|
|
77
|
+
const coreRun = await runScaffold(coreRoot, [...FULL_ARGS, '--target', 'packages/core'])
|
|
78
|
+
expect(appRun.code).toBe(0)
|
|
79
|
+
expect(coreRun.code).toBe(0)
|
|
80
|
+
|
|
81
|
+
expect(fs.existsSync(path.join(appRoot, ...APP_MODULE_DIR, 'backend', 'inventory_items', 'page.tsx'))).toBe(true)
|
|
82
|
+
expect(fs.existsSync(path.join(coreRoot, ...CORE_MODULE_DIR, 'backend', 'inventory_items', 'page.tsx'))).toBe(true)
|
|
83
|
+
|
|
84
|
+
// Only the location differs between targets — file-by-file bytes are identical.
|
|
85
|
+
const appTree = readTree(path.join(appRoot, ...APP_MODULE_DIR))
|
|
86
|
+
const coreTree = readTree(path.join(coreRoot, ...CORE_MODULE_DIR))
|
|
87
|
+
expect([...coreTree.entries()]).toEqual([...appTree.entries()])
|
|
88
|
+
|
|
89
|
+
// The next-steps registration hint follows the target.
|
|
90
|
+
expect(appRun.output).toContain("from: '@app'")
|
|
91
|
+
expect(coreRun.output).toContain("from: '@open-mercato/core'")
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
it('omits statusMap and StatusBadge when no select field is named status', async () => {
|
|
95
|
+
const root = tmpRoot()
|
|
96
|
+
const run = await runScaffold(root, [
|
|
97
|
+
'notes',
|
|
98
|
+
'--entity',
|
|
99
|
+
'note',
|
|
100
|
+
'--fields',
|
|
101
|
+
'title:text:required,body:textarea',
|
|
102
|
+
])
|
|
103
|
+
expect(run.code).toBe(0)
|
|
104
|
+
const tree = readTree(path.join(root, 'apps', 'mercato', 'src', 'modules', 'notes'))
|
|
105
|
+
expect(tree.has('components/statusMap.ts')).toBe(false)
|
|
106
|
+
const listPage = tree.get('backend/notes/page.tsx') ?? ''
|
|
107
|
+
expect(listPage).not.toContain('StatusBadge')
|
|
108
|
+
expect(listPage).not.toContain('statusMap')
|
|
109
|
+
// No select fields → no quick-filter surface either.
|
|
110
|
+
expect(listPage).not.toContain('FilterDef')
|
|
111
|
+
expect(tree.get('backend/notes/[id]/page.tsx') ?? '').not.toContain('StatusBadge')
|
|
112
|
+
for (const [relPath, contents] of [...tree.entries()].sort(([a], [b]) => a.localeCompare(b))) {
|
|
113
|
+
expect(contents).toMatchSnapshot(`no-status ${relPath}`)
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
it('generates acl/setup/index only when absent and reports expected features', async () => {
|
|
118
|
+
const root = tmpRoot()
|
|
119
|
+
const moduleDir = path.join(root, ...APP_MODULE_DIR)
|
|
120
|
+
fs.mkdirSync(moduleDir, { recursive: true })
|
|
121
|
+
const preexisting = {
|
|
122
|
+
'acl.ts': '// user acl\n',
|
|
123
|
+
'setup.ts': '// user setup\n',
|
|
124
|
+
'index.ts': '// user index\n',
|
|
125
|
+
}
|
|
126
|
+
for (const [name, contents] of Object.entries(preexisting)) {
|
|
127
|
+
fs.writeFileSync(path.join(moduleDir, name), contents)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const run = await runScaffold(root, FULL_ARGS)
|
|
131
|
+
expect(run.code).toBe(0)
|
|
132
|
+
for (const [name, contents] of Object.entries(preexisting)) {
|
|
133
|
+
expect(fs.readFileSync(path.join(moduleDir, name), 'utf8')).toBe(contents)
|
|
134
|
+
}
|
|
135
|
+
expect(run.output).toContain('Skipped (already present, left untouched):')
|
|
136
|
+
expect(run.output).toContain(
|
|
137
|
+
'pages expect features: inventory_items.view, inventory_items.create, inventory_items.edit, inventory_items.delete',
|
|
138
|
+
)
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
it('never overwrites — re-running onto existing files aborts with the conflict list', async () => {
|
|
142
|
+
const root = tmpRoot()
|
|
143
|
+
const first = await runScaffold(root, FULL_ARGS)
|
|
144
|
+
expect(first.code).toBe(0)
|
|
145
|
+
const before = readTree(path.join(root, ...APP_MODULE_DIR))
|
|
146
|
+
|
|
147
|
+
const second = await runScaffold(root, FULL_ARGS)
|
|
148
|
+
expect(second.code).toBe(1)
|
|
149
|
+
expect(second.output).toContain('Scaffold aborted')
|
|
150
|
+
expect(second.output).toContain('backend/inventory_items/page.tsx')
|
|
151
|
+
expect(second.output).toContain('No files were written.')
|
|
152
|
+
|
|
153
|
+
const after = readTree(path.join(root, ...APP_MODULE_DIR))
|
|
154
|
+
expect([...after.entries()]).toEqual([...before.entries()])
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
it('honors --features-prefix in metas, acl and setup', async () => {
|
|
158
|
+
const root = tmpRoot()
|
|
159
|
+
const run = await runScaffold(root, [...FULL_ARGS, '--features-prefix', 'inventory_items.stock'])
|
|
160
|
+
expect(run.code).toBe(0)
|
|
161
|
+
const tree = readTree(path.join(root, ...APP_MODULE_DIR))
|
|
162
|
+
expect(tree.get('backend/inventory_items/page.meta.ts')).toContain("requireFeatures: ['inventory_items.stock.view']")
|
|
163
|
+
expect(tree.get('backend/inventory_items/create/page.meta.ts')).toContain(
|
|
164
|
+
"requireFeatures: ['inventory_items.stock.create']",
|
|
165
|
+
)
|
|
166
|
+
expect(tree.get('acl.ts')).toContain("id: 'inventory_items.stock.edit'")
|
|
167
|
+
expect(tree.get('setup.ts')).toContain("superadmin: ['inventory_items.stock.*']")
|
|
168
|
+
})
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
describe('scaffold determinism', () => {
|
|
172
|
+
it('produces byte-identical output for identical inputs', async () => {
|
|
173
|
+
const rootA = tmpRoot()
|
|
174
|
+
const rootB = tmpRoot()
|
|
175
|
+
const runA = await runScaffold(rootA, FULL_ARGS)
|
|
176
|
+
const runB = await runScaffold(rootB, FULL_ARGS)
|
|
177
|
+
expect(runA.code).toBe(0)
|
|
178
|
+
expect(runB.code).toBe(0)
|
|
179
|
+
expect([...readTree(path.join(rootB, ...APP_MODULE_DIR)).entries()]).toEqual(
|
|
180
|
+
[...readTree(path.join(rootA, ...APP_MODULE_DIR)).entries()],
|
|
181
|
+
)
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
it('prints an identical --dry-run plan on re-run and writes nothing', async () => {
|
|
185
|
+
const root = tmpRoot()
|
|
186
|
+
const first = await runScaffold(root, [...FULL_ARGS, '--dry-run'])
|
|
187
|
+
const second = await runScaffold(root, [...FULL_ARGS, '--dry-run'])
|
|
188
|
+
expect(first.code).toBe(0)
|
|
189
|
+
expect(second.code).toBe(0)
|
|
190
|
+
expect(first.output).toBe(second.output)
|
|
191
|
+
expect(first.output).toContain('+ backend/inventory_items/page.tsx')
|
|
192
|
+
expect(fs.existsSync(path.join(root, ...APP_MODULE_DIR))).toBe(false)
|
|
193
|
+
})
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
describe('scaffold hostile inputs', () => {
|
|
197
|
+
const base = (fields: string) => ['tickets', '--entity', 'ticket', '--fields', fields]
|
|
198
|
+
|
|
199
|
+
it.each([
|
|
200
|
+
['reserved field name', 'id:text', 'reserved'],
|
|
201
|
+
['reserved platform column', 'updatedAt:date', 'reserved'],
|
|
202
|
+
['reserved list-API query param (export hijack)', 'format:select(csv|json)', 'reserved'],
|
|
203
|
+
['reserved pagination param', 'pageSize:number', 'reserved'],
|
|
204
|
+
['reserved search param', 'search:text', 'reserved'],
|
|
205
|
+
['reserved prototype member', 'constructor:text', 'reserved'],
|
|
206
|
+
['non-camelCase name', 'Name:text', 'Invalid field name'],
|
|
207
|
+
['kebab name', 'foo-bar:text', 'Invalid field name'],
|
|
208
|
+
['unknown type', 'foo:magic', 'Unknown field type "magic"'],
|
|
209
|
+
['select without options', 'status:select', 'needs options'],
|
|
210
|
+
['select with empty options', 'status:select()', 'needs options'],
|
|
211
|
+
['malformed select', 'status:select(', 'Malformed type'],
|
|
212
|
+
['invalid option charset', 'status:select(Open|closed)', 'Invalid option "Open"'],
|
|
213
|
+
['duplicate options', 'status:select(open|open)', 'Duplicate option "open"'],
|
|
214
|
+
['duplicate fields', 'name:text,name:text', 'Duplicate field name "name"'],
|
|
215
|
+
['unknown modifier', 'name:text:optional', 'Unknown field modifier'],
|
|
216
|
+
['options on non-select', 'name:text(a|b)', 'does not take options'],
|
|
217
|
+
['empty declaration', 'name:text,,notes:textarea', 'Empty field declaration'],
|
|
218
|
+
])('rejects %s and prints the grammar', async (_label, fields, expectedMessage) => {
|
|
219
|
+
const root = tmpRoot()
|
|
220
|
+
const run = await runScaffold(root, base(fields))
|
|
221
|
+
expect(run.code).toBe(1)
|
|
222
|
+
expect(run.output).toContain(expectedMessage)
|
|
223
|
+
expect(run.output).toContain('--fields grammar:')
|
|
224
|
+
expect(fs.existsSync(path.join(root, 'apps', 'mercato', 'src', 'modules', 'tickets'))).toBe(false)
|
|
225
|
+
})
|
|
226
|
+
|
|
227
|
+
it('rejects invalid module ids, entities, targets and reserved --no-ui', async () => {
|
|
228
|
+
const root = tmpRoot()
|
|
229
|
+
|
|
230
|
+
const badModule = await runScaffold(root, ['Tickets', '--entity', 'ticket', '--fields', 'name:text'])
|
|
231
|
+
expect(badModule.code).toBe(1)
|
|
232
|
+
expect(badModule.output).toContain('Invalid module id')
|
|
233
|
+
|
|
234
|
+
const badEntity = await runScaffold(root, ['tickets', '--entity', 'Ticket', '--fields', 'name:text'])
|
|
235
|
+
expect(badEntity.code).toBe(1)
|
|
236
|
+
expect(badEntity.output).toContain('Invalid entity name')
|
|
237
|
+
|
|
238
|
+
const missingEntity = await runScaffold(root, ['tickets', '--fields', 'name:text'])
|
|
239
|
+
expect(missingEntity.code).toBe(1)
|
|
240
|
+
expect(missingEntity.output).toContain('Missing --entity')
|
|
241
|
+
|
|
242
|
+
const missingFields = await runScaffold(root, ['tickets', '--entity', 'ticket'])
|
|
243
|
+
expect(missingFields.code).toBe(1)
|
|
244
|
+
expect(missingFields.output).toContain('Missing --fields')
|
|
245
|
+
|
|
246
|
+
const badTarget = await runScaffold(root, [
|
|
247
|
+
'tickets', '--entity', 'ticket', '--fields', 'name:text', '--target', 'packages/ui',
|
|
248
|
+
])
|
|
249
|
+
expect(badTarget.code).toBe(1)
|
|
250
|
+
expect(badTarget.output).toContain('Unknown --target')
|
|
251
|
+
|
|
252
|
+
const noUi = await runScaffold(root, ['tickets', '--entity', 'ticket', '--fields', 'name:text', '--no-ui'])
|
|
253
|
+
expect(noUi.code).toBe(1)
|
|
254
|
+
expect(noUi.output).toContain('reserved')
|
|
255
|
+
})
|
|
256
|
+
|
|
257
|
+
it('parseFieldsSpec throws FieldDslError with actionable messages', () => {
|
|
258
|
+
expect(() => parseFieldsSpec('')).toThrow(FieldDslError)
|
|
259
|
+
expect(() => parseFieldsSpec('tenantId:text')).toThrow(/reserved/)
|
|
260
|
+
expect(() => parseFieldsSpec('a:select(x|)')).toThrow(/Invalid option/)
|
|
261
|
+
expect(parseFieldsSpec('subject:text:required,status:select(open|closed),notes:textarea')).toEqual([
|
|
262
|
+
{ name: 'subject', type: 'text', required: true },
|
|
263
|
+
{ name: 'status', type: 'select', required: false, options: ['open', 'closed'] },
|
|
264
|
+
{ name: 'notes', type: 'textarea', required: false },
|
|
265
|
+
])
|
|
266
|
+
})
|
|
267
|
+
})
|