@decocms/blocks 8.9.1 → 8.11.0
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/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/protocol/channel.d.ts +98 -0
- package/dist/protocol/channel.d.ts.map +1 -0
- package/dist/protocol/channel.js +58 -0
- package/dist/protocol/channel.js.map +1 -0
- package/dist/protocol/client.js +2 -2
- package/dist/protocol/client.js.map +1 -1
- package/dist/protocol/conformance/blockMetaVectors.json +214 -0
- package/dist/protocol/conformance/contentHashFixtures.d.ts +22 -0
- package/dist/protocol/conformance/contentHashFixtures.d.ts.map +1 -1
- package/dist/protocol/conformance/contentHashFixtures.js +55 -0
- package/dist/protocol/conformance/contentHashFixtures.js.map +1 -1
- package/dist/protocol/conformance/index.d.ts +2 -1
- package/dist/protocol/conformance/index.d.ts.map +1 -1
- package/dist/protocol/conformance/index.js +2 -1
- package/dist/protocol/conformance/index.js.map +1 -1
- package/dist/protocol/conformance/vectors.d.ts +33 -0
- package/dist/protocol/conformance/vectors.d.ts.map +1 -0
- package/dist/protocol/conformance/vectors.js +3 -0
- package/dist/protocol/conformance/vectors.js.map +1 -0
- package/dist/protocol/index.d.ts +11 -1
- package/dist/protocol/index.d.ts.map +1 -1
- package/dist/protocol/index.js +11 -1
- package/dist/protocol/index.js.map +1 -1
- package/dist/protocol/keys.d.ts +1 -1
- package/dist/protocol/keys.js +1 -1
- package/dist/v8/background.d.ts +13 -0
- package/dist/v8/background.d.ts.map +1 -1
- package/dist/v8/background.js +41 -0
- package/dist/v8/background.js.map +1 -1
- package/dist/v8/blockMeta.d.ts +27 -0
- package/dist/v8/blockMeta.d.ts.map +1 -0
- package/dist/v8/blockMeta.js +75 -0
- package/dist/v8/blockMeta.js.map +1 -0
- package/dist/v8/blockStore.d.ts +43 -0
- package/dist/v8/blockStore.d.ts.map +1 -0
- package/dist/v8/blockStore.js +95 -0
- package/dist/v8/blockStore.js.map +1 -0
- package/dist/v8/boundedJson.d.ts +5 -0
- package/dist/v8/boundedJson.d.ts.map +1 -1
- package/dist/v8/boundedJson.js +10 -2
- package/dist/v8/boundedJson.js.map +1 -1
- package/dist/v8/boundedMap.d.ts +19 -0
- package/dist/v8/boundedMap.d.ts.map +1 -0
- package/dist/v8/boundedMap.js +52 -0
- package/dist/v8/boundedMap.js.map +1 -0
- package/dist/v8/builtins/data.d.ts +18 -2
- package/dist/v8/builtins/data.d.ts.map +1 -1
- package/dist/v8/builtins/data.js +17 -1
- package/dist/v8/builtins/data.js.map +1 -1
- package/dist/v8/builtins/index.d.ts.map +1 -1
- package/dist/v8/builtins/index.js +2 -1
- package/dist/v8/builtins/index.js.map +1 -1
- package/dist/v8/builtins/legacy.d.ts +6 -3
- package/dist/v8/builtins/legacy.d.ts.map +1 -1
- package/dist/v8/builtins/legacy.js +6 -3
- package/dist/v8/builtins/legacy.js.map +1 -1
- package/dist/v8/canonical.d.ts +8 -0
- package/dist/v8/canonical.d.ts.map +1 -1
- package/dist/v8/canonical.js +15 -0
- package/dist/v8/canonical.js.map +1 -1
- package/dist/v8/cli/builtins.d.ts.map +1 -1
- package/dist/v8/cli/builtins.js +1 -0
- package/dist/v8/cli/builtins.js.map +1 -1
- package/dist/v8/cli/check/index.d.ts +10 -0
- package/dist/v8/cli/check/index.d.ts.map +1 -1
- package/dist/v8/cli/check/index.js +91 -7
- package/dist/v8/cli/check/index.js.map +1 -1
- package/dist/v8/cli/content.d.ts +12 -25
- package/dist/v8/cli/content.d.ts.map +1 -1
- package/dist/v8/cli/content.js +46 -75
- package/dist/v8/cli/content.js.map +1 -1
- package/dist/v8/cli/index.d.ts +2 -2
- package/dist/v8/cli/index.d.ts.map +1 -1
- package/dist/v8/cli/index.js +2 -2
- package/dist/v8/cli/index.js.map +1 -1
- package/dist/v8/cli/remote/commands.d.ts +71 -0
- package/dist/v8/cli/remote/commands.d.ts.map +1 -0
- package/dist/v8/cli/remote/commands.js +644 -0
- package/dist/v8/cli/remote/commands.js.map +1 -0
- package/dist/v8/cli/remote/diff.d.ts +15 -0
- package/dist/v8/cli/remote/diff.d.ts.map +1 -0
- package/dist/v8/cli/remote/diff.js +102 -0
- package/dist/v8/cli/remote/diff.js.map +1 -0
- package/dist/v8/cli/remote/env.d.ts +35 -0
- package/dist/v8/cli/remote/env.d.ts.map +1 -0
- package/dist/v8/cli/remote/env.js +84 -0
- package/dist/v8/cli/remote/env.js.map +1 -0
- package/dist/v8/cli/remote/http.d.ts +149 -0
- package/dist/v8/cli/remote/http.d.ts.map +1 -0
- package/dist/v8/cli/remote/http.js +381 -0
- package/dist/v8/cli/remote/http.js.map +1 -0
- package/dist/v8/cli/remote/local.d.ts +90 -0
- package/dist/v8/cli/remote/local.d.ts.map +1 -0
- package/dist/v8/cli/remote/local.js +309 -0
- package/dist/v8/cli/remote/local.js.map +1 -0
- package/dist/v8/cli/root.d.ts +29 -0
- package/dist/v8/cli/root.d.ts.map +1 -1
- package/dist/v8/cli/root.js +28 -0
- package/dist/v8/cli/root.js.map +1 -1
- package/dist/v8/cli/run.d.ts +13 -1
- package/dist/v8/cli/run.d.ts.map +1 -1
- package/dist/v8/cli/run.js +310 -124
- package/dist/v8/cli/run.js.map +1 -1
- package/dist/v8/cli/schema/builtinSchemas.d.ts.map +1 -1
- package/dist/v8/cli/schema/builtinSchemas.js +28 -10
- package/dist/v8/cli/schema/builtinSchemas.js.map +1 -1
- package/dist/v8/cli/schema/generate.js +1 -1
- package/dist/v8/cli/schema/generate.js.map +1 -1
- package/dist/v8/cli/skills.d.ts +25 -0
- package/dist/v8/cli/skills.d.ts.map +1 -0
- package/dist/v8/cli/skills.js +70 -0
- package/dist/v8/cli/skills.js.map +1 -0
- package/dist/v8/client.d.ts +9 -9
- package/dist/v8/client.d.ts.map +1 -1
- package/dist/v8/client.js +138 -50
- package/dist/v8/client.js.map +1 -1
- package/dist/v8/cms.d.ts +2 -1
- package/dist/v8/cms.d.ts.map +1 -1
- package/dist/v8/cms.js +55 -46
- package/dist/v8/cms.js.map +1 -1
- package/dist/v8/content.d.ts +39 -78
- package/dist/v8/content.d.ts.map +1 -1
- package/dist/v8/content.js +155 -195
- package/dist/v8/content.js.map +1 -1
- package/dist/v8/contentIndex.d.ts +71 -0
- package/dist/v8/contentIndex.d.ts.map +1 -0
- package/dist/v8/contentIndex.js +137 -0
- package/dist/v8/contentIndex.js.map +1 -0
- package/dist/v8/draft.d.ts +7 -7
- package/dist/v8/draft.d.ts.map +1 -1
- package/dist/v8/draft.js +10 -9
- package/dist/v8/draft.js.map +1 -1
- package/dist/v8/draftChanges.d.ts +59 -32
- package/dist/v8/draftChanges.d.ts.map +1 -1
- package/dist/v8/draftChanges.js +139 -75
- package/dist/v8/draftChanges.js.map +1 -1
- package/dist/v8/errors.d.ts +21 -0
- package/dist/v8/errors.d.ts.map +1 -1
- package/dist/v8/errors.js +22 -0
- package/dist/v8/errors.js.map +1 -1
- package/dist/v8/hostedSource.d.ts +57 -0
- package/dist/v8/hostedSource.d.ts.map +1 -0
- package/dist/v8/hostedSource.js +18 -0
- package/dist/v8/hostedSource.js.map +1 -0
- package/dist/v8/identity.d.ts +1 -1
- package/dist/v8/identity.js +1 -1
- package/dist/v8/index.d.ts +1 -0
- package/dist/v8/index.d.ts.map +1 -1
- package/dist/v8/index.js +1 -0
- package/dist/v8/index.js.map +1 -1
- package/dist/v8/matchRoute.js +7 -4
- package/dist/v8/matchRoute.js.map +1 -1
- package/dist/v8/pin.d.ts +34 -0
- package/dist/v8/pin.d.ts.map +1 -0
- package/dist/v8/pin.js +156 -0
- package/dist/v8/pin.js.map +1 -0
- package/dist/v8/preview/StudioBridge.d.ts +8 -8
- package/dist/v8/preview/StudioBridge.d.ts.map +1 -1
- package/dist/v8/preview/StudioBridge.js +8 -10
- package/dist/v8/preview/StudioBridge.js.map +1 -1
- package/dist/v8/preview/StudioChannel.d.ts +51 -0
- package/dist/v8/preview/StudioChannel.d.ts.map +1 -0
- package/dist/v8/preview/StudioChannel.js +104 -0
- package/dist/v8/preview/StudioChannel.js.map +1 -0
- package/dist/v8/preview/index.d.ts +3 -0
- package/dist/v8/preview/index.d.ts.map +1 -1
- package/dist/v8/preview/index.js +3 -0
- package/dist/v8/preview/index.js.map +1 -1
- package/dist/v8/remoteLoader.d.ts +42 -5
- package/dist/v8/remoteLoader.d.ts.map +1 -1
- package/dist/v8/remoteLoader.js +317 -259
- package/dist/v8/remoteLoader.js.map +1 -1
- package/dist/v8/resolver.d.ts +22 -8
- package/dist/v8/resolver.d.ts.map +1 -1
- package/dist/v8/resolver.js +37 -32
- package/dist/v8/resolver.js.map +1 -1
- package/dist/v8/revisionId.d.ts +11 -0
- package/dist/v8/revisionId.d.ts.map +1 -0
- package/dist/v8/revisionId.js +13 -0
- package/dist/v8/revisionId.js.map +1 -0
- package/dist/v8/settings.d.ts +6 -6
- package/dist/v8/settings.d.ts.map +1 -1
- package/dist/v8/settings.js +8 -7
- package/dist/v8/settings.js.map +1 -1
- package/dist/v8/telemetry.d.ts +4 -2
- package/dist/v8/telemetry.d.ts.map +1 -1
- package/dist/v8/telemetry.js +2 -2
- package/dist/v8/telemetry.js.map +1 -1
- package/dist/v8/types.d.ts +52 -40
- package/dist/v8/types.d.ts.map +1 -1
- package/dist/v8/variants.d.ts +7 -2
- package/dist/v8/variants.d.ts.map +1 -1
- package/dist/v8/variants.js +21 -24
- package/dist/v8/variants.js.map +1 -1
- package/dist/v8/vite/index.d.ts +2 -2
- package/dist/v8/vite/index.js +1 -1
- package/dist/v8/vite/index.js.map +1 -1
- package/package.json +3 -2
- package/skills/deco-apps/SKILL.md +82 -0
- package/skills/deco-apps/references/algolia.md +51 -0
- package/skills/deco-apps/references/commerce-types.md +132 -0
- package/skills/deco-apps/references/instrumented-fetch.md +144 -0
- package/skills/deco-apps/references/magento.md +55 -0
- package/skills/deco-apps/references/messaging.md +76 -0
- package/skills/deco-apps/references/shopify.md +69 -0
- package/skills/deco-apps/references/vendored-loaders.md +135 -0
- package/skills/deco-apps/references/vtex-cookies-auth.md +146 -0
- package/skills/deco-apps/references/vtex.md +150 -0
- package/skills/deco-apps/references/wake.md +75 -0
- package/skills/deco-cms-schema/SKILL.md +80 -0
- package/skills/deco-cms-schema/references/annotations.md +147 -0
- package/skills/deco-cms-schema/references/content-hygiene.md +91 -0
- package/skills/deco-cms-schema/references/formats-and-widgets.md +112 -0
- package/skills/deco-cms-schema/references/shapes-that-break-the-form.md +165 -0
- package/skills/deco-cms-schema/references/types-to-fields.md +112 -0
- package/skills/deco-go-live/SKILL.md +127 -0
- package/skills/deco-go-live/references/content-releases.md +90 -0
- package/skills/deco-go-live/references/process.md +106 -0
- package/skills/deco-go-live/references/proxy-headers-checkout.md +139 -0
- package/skills/deco-go-live/references/qa-checklist-template.md +150 -0
- package/skills/deco-go-live/references/qa-inventory.md +120 -0
- package/skills/deco-go-live/references/react-spa.md +183 -0
- package/skills/deco-go-live/references/seo-analytics.md +114 -0
- package/skills/deco-go-live/references/traffic-ramp.md +87 -0
- package/skills/deco-go-live/references/worker-runtime.md +93 -0
- package/skills/deco-go-live/scripts/preflight.sh +221 -0
- package/skills/deco-images-media/SKILL.md +64 -0
- package/skills/deco-images-media/references/asset-upload.md +191 -0
- package/skills/deco-images-media/references/components-per-binding.md +167 -0
- package/skills/deco-images-media/references/providers-and-cdn.md +145 -0
- package/skills/deco-images-media/references/quality-and-lcp.md +93 -0
- package/skills/deco-images-media/references/troubleshooting.md +147 -0
- package/skills/deco-images-media/references/video.md +122 -0
- package/skills/deco-make-editable/SKILL.md +94 -0
- package/skills/deco-make-editable/references/a11y-and-e2e.md +104 -0
- package/skills/deco-make-editable/references/content-shapes.md +198 -0
- package/skills/deco-make-editable/references/from-figma.md +110 -0
- package/skills/deco-make-editable/references/i18n-fields.md +112 -0
- package/skills/deco-make-editable/references/inventory.md +79 -0
- package/skills/deco-make-editable/references/pixel-parity.md +175 -0
- package/skills/deco-make-editable/references/seeding-content.md +119 -0
- package/skills/deco-nextjs-site/SKILL.md +74 -0
- package/skills/deco-nextjs-site/references/caching.md +116 -0
- package/skills/deco-nextjs-site/references/metadata-seo.md +100 -0
- package/skills/deco-nextjs-site/references/proxy-and-drafts.md +177 -0
- package/skills/deco-nextjs-site/references/rendering.md +171 -0
- package/skills/deco-nextjs-site/references/setup.md +190 -0
- package/skills/deco-nextjs-site/references/studio-bridge.md +130 -0
- package/skills/deco-site-authoring/SKILL.md +75 -0
- package/skills/deco-site-authoring/references/lazy-blocks.md +155 -0
- package/skills/deco-site-authoring/references/loaders.md +192 -0
- package/skills/deco-site-authoring/references/pages.md +156 -0
- package/skills/deco-site-authoring/references/review-before-publish.md +95 -0
- package/skills/deco-site-authoring/references/sections.md +158 -0
- package/skills/deco-site-authoring/references/seo.md +116 -0
- package/skills/deco-site-workflow/SKILL.md +92 -0
- package/skills/deco-site-workflow/references/check.md +116 -0
- package/skills/deco-site-workflow/references/cli-reference.md +104 -0
- package/skills/deco-site-workflow/references/content-layout.md +93 -0
- package/skills/deco-site-workflow/references/content-sync.md +146 -0
- package/skills/deco-site-workflow/references/delivery.md +51 -0
- package/skills/deco-site-workflow/references/deploy.md +87 -0
- package/skills/deco-site-workflow/references/schema.md +173 -0
- package/skills/deco-site-workflow/references/serve-and-studio.md +138 -0
- package/skills/deco-storefront-caching/SKILL.md +67 -0
- package/skills/deco-storefront-caching/references/cache-keys.md +129 -0
- package/skills/deco-storefront-caching/references/case-study.md +82 -0
- package/skills/deco-storefront-caching/references/egress-traps.md +153 -0
- package/skills/deco-storefront-caching/references/nextjs.md +60 -0
- package/skills/deco-storefront-caching/references/perf-guardrails-e2e.md +123 -0
- package/skills/deco-storefront-caching/references/verification.md +136 -0
- package/skills/deco-storefront-caching/references/worker-page-cache.md +160 -0
- package/skills/deco-storefront-caching/scripts/html-anatomy.mjs +97 -0
- package/skills/deco-storefront-performance/SKILL.md +81 -0
- package/skills/deco-storefront-performance/references/cls-third-party.md +90 -0
- package/skills/deco-storefront-performance/references/hydration.md +116 -0
- package/skills/deco-storefront-performance/references/loaders-n-plus-1.md +107 -0
- package/skills/deco-storefront-performance/references/navigation-ux.md +130 -0
- package/skills/deco-storefront-performance/references/payload-trim.md +163 -0
- package/skills/deco-storefront-performance/references/render-location.md +152 -0
- package/skills/deco-storefront-performance/references/request-dedupe.md +147 -0
- package/skills/deco-storefront-performance/references/trace-reading.md +79 -0
- package/skills/deco-storefront-performance/references/worker-memory.md +176 -0
- package/skills/deco-tanstack-site/SKILL.md +68 -0
- package/skills/deco-tanstack-site/references/document-and-security.md +155 -0
- package/skills/deco-tanstack-site/references/router-and-navigation.md +137 -0
- package/skills/deco-tanstack-site/references/routes-and-pages.md +183 -0
- package/skills/deco-tanstack-site/references/server-functions.md +123 -0
- package/skills/deco-tanstack-site/references/setup.md +153 -0
- package/skills/deco-tanstack-site/references/worker-entry.md +152 -0
- package/skills/deco-v7-to-v8-migration/SKILL.md +122 -0
- package/skills/deco-v7-to-v8-migration/references/caching-and-privacy.md +10 -0
- package/skills/deco-v7-to-v8-migration/references/content.md +25 -0
- package/skills/deco-v7-to-v8-migration/references/editor-forms.md +27 -0
- package/skills/deco-v7-to-v8-migration/references/faststore.md +40 -0
- package/skills/deco-v7-to-v8-migration/references/framework-code.md +53 -0
- package/skills/deco-v7-to-v8-migration/references/hosted-releases.md +16 -0
- package/skills/deco-v7-to-v8-migration/references/import-map.md +81 -0
- package/skills/deco-v7-to-v8-migration/references/legacy-names.md +33 -0
- package/skills/deco-v7-to-v8-migration/references/manual-steps.md +10 -0
- package/skills/deco-v7-to-v8-migration/references/native-apps.md +43 -0
- package/skills/deco-v7-to-v8-migration/references/nextjs.md +19 -0
- package/skills/deco-v7-to-v8-migration/references/parity.md +66 -0
- package/skills/deco-v7-to-v8-migration/references/rendering.md +13 -0
- package/skills/deco-v7-to-v8-migration/references/running-the-script.md +29 -0
- package/skills/deco-v7-to-v8-migration/references/script-steps.md +13 -0
- package/skills/deco-v7-to-v8-migration/references/server-functions.md +15 -0
- package/skills/deco-v7-to-v8-migration/references/sibling-port.md +11 -0
- package/skills/deco-v7-to-v8-migration/references/site-code.md +15 -0
- package/skills/deco-v7-to-v8-migration/references/telemetry.md +10 -0
- package/skills/deco-v7-to-v8-migration/references/verify.md +20 -0
- package/skills/deco-v7-to-v8-migration/scripts/apps.ts +297 -0
- package/skills/deco-v7-to-v8-migration/scripts/asyncRendering.ts +73 -0
- package/skills/deco-v7-to-v8-migration/scripts/blockMap.ts +584 -0
- package/skills/deco-v7-to-v8-migration/scripts/ciSchemaCheck.ts +145 -0
- package/skills/deco-v7-to-v8-migration/scripts/compat.ts +357 -0
- package/skills/deco-v7-to-v8-migration/scripts/content.ts +121 -0
- package/skills/deco-v7-to-v8-migration/scripts/experiments.ts +81 -0
- package/skills/deco-v7-to-v8-migration/scripts/framework.ts +61 -0
- package/skills/deco-v7-to-v8-migration/scripts/imageCopy.ts +276 -0
- package/skills/deco-v7-to-v8-migration/scripts/imageModule.ts +285 -0
- package/skills/deco-v7-to-v8-migration/scripts/imports.ts +942 -0
- package/skills/deco-v7-to-v8-migration/scripts/invoke.ts +624 -0
- package/skills/deco-v7-to-v8-migration/scripts/legacyNames.ts +45 -0
- package/skills/deco-v7-to-v8-migration/scripts/main.ts +59 -0
- package/skills/deco-v7-to-v8-migration/scripts/matchers.ts +41 -0
- package/skills/deco-v7-to-v8-migration/scripts/migrate.ts +176 -0
- package/skills/deco-v7-to-v8-migration/scripts/redirects.ts +455 -0
- package/skills/deco-v7-to-v8-migration/scripts/report.ts +50 -0
- package/skills/deco-v7-to-v8-migration/scripts/scaffold.ts +1119 -0
- package/skills/deco-v7-to-v8-migration/scripts/secrets.ts +35 -0
- package/skills/deco-v7-to-v8-migration/scripts/sectionLoaders.ts +216 -0
- package/skills/deco-v7-to-v8-migration/scripts/siteSettings.ts +261 -0
- package/skills/deco-v7-to-v8-migration/scripts/stubs.ts +388 -0
- package/skills/deco-v7-to-v8-migration/scripts/tsconfig.json +7 -0
- package/skills/deco-v7-to-v8-migration/scripts/vendor.ts +249 -0
- package/skills/deco-v7-to-v8-migration/scripts/vtexInvoke.ts +240 -0
- package/skills/deco-v7-to-v8-migration/scripts/walk.ts +30 -0
- package/skills/deco-variants/SKILL.md +57 -0
- package/skills/deco-variants/references/caching-variants.md +63 -0
- package/skills/deco-variants/references/custom-matchers.md +83 -0
- package/skills/deco-variants/references/draft-preview.md +59 -0
- package/skills/deco-variants/references/experiments-and-campaigns.md +104 -0
- package/skills/deco-variants/references/multivariate.md +85 -0
- package/skills/deco-variants/references/v7-matchers.md +71 -0
- package/src/index.ts +2 -0
- package/src/protocol/channel.ts +127 -0
- package/src/protocol/client.ts +2 -2
- package/src/protocol/conformance/blockMetaVectors.json +214 -0
- package/src/protocol/conformance/contentHashFixtures.ts +74 -0
- package/src/protocol/conformance/index.ts +9 -1
- package/src/protocol/conformance/vectors.ts +36 -0
- package/src/protocol/index.ts +32 -0
- package/src/protocol/keys.ts +1 -1
- package/src/v8/background.ts +42 -0
- package/src/v8/blockMeta.ts +100 -0
- package/src/v8/blockStore.ts +124 -0
- package/src/v8/boundedJson.ts +20 -2
- package/src/v8/boundedMap.ts +53 -0
- package/src/v8/builtins/data.ts +26 -2
- package/src/v8/builtins/index.ts +2 -1
- package/src/v8/builtins/legacy.ts +6 -3
- package/src/v8/canonical.ts +15 -0
- package/src/v8/cli/builtins.ts +1 -0
- package/src/v8/cli/check/index.ts +97 -7
- package/src/v8/cli/content.ts +49 -91
- package/src/v8/cli/index.ts +2 -2
- package/src/v8/cli/remote/commands.ts +834 -0
- package/src/v8/cli/remote/diff.ts +100 -0
- package/src/v8/cli/remote/env.ts +107 -0
- package/src/v8/cli/remote/http.ts +484 -0
- package/src/v8/cli/remote/local.ts +343 -0
- package/src/v8/cli/root.ts +40 -0
- package/src/v8/cli/run.ts +366 -135
- package/src/v8/cli/schema/builtinSchemas.ts +29 -10
- package/src/v8/cli/schema/generate.ts +1 -1
- package/src/v8/cli/skills.ts +91 -0
- package/src/v8/client.ts +162 -60
- package/src/v8/cms.ts +62 -53
- package/src/v8/content.ts +179 -229
- package/src/v8/contentIndex.ts +183 -0
- package/src/v8/draft.ts +15 -14
- package/src/v8/draftChanges.ts +151 -85
- package/src/v8/errors.ts +37 -0
- package/src/v8/hostedSource.ts +67 -0
- package/src/v8/identity.ts +1 -1
- package/src/v8/index.ts +1 -0
- package/src/v8/matchRoute.ts +7 -4
- package/src/v8/pin.ts +176 -0
- package/src/v8/preview/StudioBridge.ts +8 -10
- package/src/v8/preview/StudioChannel.ts +116 -0
- package/src/v8/preview/index.ts +3 -0
- package/src/v8/remoteLoader.ts +350 -286
- package/src/v8/resolver.ts +56 -33
- package/src/v8/revisionId.ts +14 -0
- package/src/v8/settings.ts +10 -9
- package/src/v8/telemetry.ts +3 -3
- package/src/v8/types.ts +52 -40
- package/src/v8/variants.ts +30 -26
- package/src/v8/vite/index.ts +3 -3
- package/dist/v8/cli/serve/server.d.ts +0 -29
- package/dist/v8/cli/serve/server.d.ts.map +0 -1
- package/dist/v8/cli/serve/server.js +0 -296
- package/dist/v8/cli/serve/server.js.map +0 -1
- package/src/v8/cli/serve/server.ts +0 -348
package/src/v8/cli/run.ts
CHANGED
|
@@ -1,67 +1,139 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `deco` command line:
|
|
3
|
-
* (spec: cli
|
|
2
|
+
* The `deco` command line (spec: cli). Parses flags, runs one command and
|
|
3
|
+
* returns its exit code (spec: cli › Exit codes): 0 ok, 1 check failed (or
|
|
4
|
+
* any other failure), 2 conflict, 3 auth, 4 network, 5 busy (run again), 64
|
|
5
|
+
* usage. Every command takes `--json`: stdout then carries exactly one JSON
|
|
6
|
+
* object, and what a person reads goes to stderr.
|
|
4
7
|
*/
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
import { readSchemaFile, reportCheck } from "./check/index.ts";
|
|
10
|
+
import { content, readSavedBlocks, savedBlocksFromMap, writeContent } from "./content.ts";
|
|
7
11
|
import { consoleReporter, type Reporter, withColor } from "./log.ts";
|
|
8
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
diff,
|
|
14
|
+
drafts,
|
|
15
|
+
login,
|
|
16
|
+
type Outcome,
|
|
17
|
+
publish,
|
|
18
|
+
pull,
|
|
19
|
+
push,
|
|
20
|
+
type RemoteContext,
|
|
21
|
+
releases,
|
|
22
|
+
remoteBlocks,
|
|
23
|
+
schemaPush,
|
|
24
|
+
} from "./remote/commands.ts";
|
|
25
|
+
import type { CommandRunner, Env } from "./remote/env.ts";
|
|
26
|
+
import type { Fetch } from "./remote/http.ts";
|
|
27
|
+
import { checkDraftName, findSite, requireDraftName } from "./remote/local.ts";
|
|
28
|
+
import { CliError, decoPaths, EXIT, findDecoRoot, packageVersion, usageError } from "./root.ts";
|
|
9
29
|
import { reportSchema, schema, writeSchema } from "./schema/index.ts";
|
|
10
|
-
import {
|
|
30
|
+
import { installSkills } from "./skills.ts";
|
|
11
31
|
import { watchFiles, watchTree } from "./watch.ts";
|
|
12
32
|
|
|
13
33
|
type FlagKind = "string" | "boolean";
|
|
14
34
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
35
|
+
interface CommandSpec {
|
|
36
|
+
usage: string;
|
|
37
|
+
flags: Record<string, FlagKind>;
|
|
38
|
+
/** How many positional arguments it takes, at most. */
|
|
39
|
+
positionals?: number;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const DRAFT = { draft: "string" } as const;
|
|
43
|
+
|
|
44
|
+
const COMMANDS: Record<string, CommandSpec> = {
|
|
45
|
+
login: { usage: "deco login", flags: {} },
|
|
46
|
+
pull: {
|
|
47
|
+
usage: "deco pull [--draft=<name>] [--force]",
|
|
48
|
+
flags: { ...DRAFT, force: "boolean" },
|
|
49
|
+
},
|
|
50
|
+
diff: { usage: "deco diff [--draft=<name>]", flags: { ...DRAFT } },
|
|
51
|
+
push: {
|
|
52
|
+
usage: "deco push --draft=<name> [--ours | --theirs] [--prune]",
|
|
53
|
+
flags: { ...DRAFT, ours: "boolean", theirs: "boolean", prune: "boolean" },
|
|
54
|
+
},
|
|
55
|
+
publish: {
|
|
56
|
+
usage: "deco publish --draft=<name> [--message=<text>]",
|
|
57
|
+
flags: { ...DRAFT, message: "string" },
|
|
58
|
+
},
|
|
59
|
+
drafts: {
|
|
60
|
+
usage: "deco drafts list | new <name> | discard <name> | url <name>",
|
|
61
|
+
flags: {},
|
|
62
|
+
positionals: 2,
|
|
63
|
+
},
|
|
64
|
+
releases: { usage: "deco releases [--cursor=<cursor>]", flags: { cursor: "string" } },
|
|
65
|
+
check: {
|
|
66
|
+
usage: "deco check [--draft=<name> | --revision=<id>]",
|
|
67
|
+
flags: { ...DRAFT, revision: "string" },
|
|
19
68
|
},
|
|
20
69
|
content: {
|
|
21
|
-
usage: "deco content
|
|
22
|
-
flags: {
|
|
70
|
+
usage: "deco content [--watch]",
|
|
71
|
+
flags: { watch: "boolean" },
|
|
23
72
|
},
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
assets: "string",
|
|
34
|
-
"read-only": "boolean",
|
|
35
|
-
},
|
|
73
|
+
schema: {
|
|
74
|
+
usage: "deco schema [--watch | --check]\n deco schema push",
|
|
75
|
+
flags: { watch: "boolean", check: "boolean" },
|
|
76
|
+
positionals: 1,
|
|
77
|
+
},
|
|
78
|
+
skills: {
|
|
79
|
+
usage: "deco skills install [--dir=<path>]",
|
|
80
|
+
flags: { dir: "string" },
|
|
81
|
+
positionals: 1,
|
|
36
82
|
},
|
|
37
83
|
};
|
|
38
84
|
|
|
85
|
+
/** Flags every command takes. */
|
|
86
|
+
const COMMON_FLAGS: Record<string, FlagKind> = { root: "string", json: "boolean" };
|
|
87
|
+
|
|
39
88
|
export const USAGE = `Usage: deco <command> [flags]
|
|
40
89
|
|
|
41
90
|
Commands:
|
|
91
|
+
login print how to log in (the session is Studio CLI's: npx decocms auth login)
|
|
92
|
+
pull write production, or a draft, into .deco/blocks
|
|
93
|
+
diff show what .deco/blocks changes against what was pulled, or against a draft
|
|
94
|
+
push save the blocks changed since the pull into a draft as one change (deletes with
|
|
95
|
+
--prune); prints its preview link
|
|
96
|
+
publish make a draft live (prints its changes first)
|
|
97
|
+
drafts list, create, discard a draft, or print its preview link
|
|
98
|
+
releases list the published revisions, newest first, 50 a page
|
|
99
|
+
check check that the content fits the schema (production; or a draft, or a revision;
|
|
100
|
+
with no DECO_SITE set anywhere, the saved blocks in .deco/blocks)
|
|
101
|
+
content turn .deco/blocks into the content module, .deco/blocks.gen.ts (content without
|
|
102
|
+
a site: createCMS({ blocks, content }))
|
|
42
103
|
schema turn the types in .deco/index.ts into .deco/schema.gen.json
|
|
43
104
|
(--check: write nothing, fail when the file is out of date; for CI)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
105
|
+
schema push: upload it so Studio can draw forms (CI, on production deploys)
|
|
106
|
+
skills skills install: copy the agent skills of this @decocms/blocks into the site,
|
|
107
|
+
one folder per skill in .claude/skills (or --dir, relative to the folder that
|
|
108
|
+
contains .deco/); replaces those folders, leaves other skills alone; offline
|
|
48
109
|
|
|
49
110
|
${Object.values(COMMANDS)
|
|
50
111
|
.map((c) => ` ${c.usage}`)
|
|
51
112
|
.join("\n")}
|
|
52
113
|
|
|
53
114
|
Every command finds .deco/ by walking up from the current folder, or takes --root.
|
|
54
|
-
Every command takes --
|
|
115
|
+
Every command takes --json (one JSON object on stdout) and --color or --no-color.
|
|
116
|
+
Site: DECO_SITE, from the environment, else .env, .dev.vars, then vars.DECO_SITE in
|
|
117
|
+
wrangler.jsonc, wrangler.json or wrangler.toml (in the folder that contains .deco/).
|
|
118
|
+
Studio: DECO_STUDIO_URL (default https://studio.decocms.com); token: DECO_TOKEN, else
|
|
119
|
+
npx decocms auth token. Exit codes: 0 ok, 1 failed, 2 conflict, 3 auth, 4 network,
|
|
120
|
+
5 busy (run again), 64 usage.`;
|
|
55
121
|
|
|
56
122
|
export type ParsedFlags = Record<string, string | boolean | string[]>;
|
|
57
123
|
|
|
58
124
|
export function parseFlags(command: string, args: string[]): ParsedFlags {
|
|
59
|
-
const
|
|
125
|
+
const command_ = COMMANDS[command]!;
|
|
126
|
+
const spec = { ...COMMON_FLAGS, ...command_.flags };
|
|
60
127
|
const flags: ParsedFlags = {};
|
|
128
|
+
const positionals: string[] = [];
|
|
61
129
|
for (let i = 0; i < args.length; i++) {
|
|
62
|
-
const arg = args[i]
|
|
63
|
-
if (!arg.startsWith("--"))
|
|
64
|
-
|
|
130
|
+
const arg = args[i]!;
|
|
131
|
+
if (!arg.startsWith("--")) {
|
|
132
|
+
if (positionals.length >= (command_.positionals ?? 0))
|
|
133
|
+
throw usageError(`unexpected argument "${arg}"\n${command_.usage}`);
|
|
134
|
+
positionals.push(arg);
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
65
137
|
// Every command's: `color` is true, false or absent; the last one given wins.
|
|
66
138
|
if (arg === "--color" || arg === "--no-color") {
|
|
67
139
|
flags.color = arg === "--color";
|
|
@@ -69,11 +141,11 @@ export function parseFlags(command: string, args: string[]): ParsedFlags {
|
|
|
69
141
|
}
|
|
70
142
|
const eq = arg.indexOf("=");
|
|
71
143
|
const name = arg.slice(2, eq === -1 ? undefined : eq);
|
|
72
|
-
if (name === "color" || name === "no-color") throw
|
|
144
|
+
if (name === "color" || name === "no-color") throw usageError(`--${name} takes no value`);
|
|
73
145
|
const kind = Object.hasOwn(spec, name) ? spec[name] : undefined;
|
|
74
|
-
if (!kind) throw
|
|
146
|
+
if (!kind) throw usageError(`unknown flag --${name}\n${command_.usage}`);
|
|
75
147
|
if (kind === "boolean") {
|
|
76
|
-
if (eq !== -1) throw
|
|
148
|
+
if (eq !== -1) throw usageError(`--${name} takes no value`);
|
|
77
149
|
flags[name] = true;
|
|
78
150
|
continue;
|
|
79
151
|
}
|
|
@@ -82,11 +154,12 @@ export function parseFlags(command: string, args: string[]): ParsedFlags {
|
|
|
82
154
|
else {
|
|
83
155
|
value = args[i + 1];
|
|
84
156
|
if (value === undefined || value.startsWith("--"))
|
|
85
|
-
throw
|
|
157
|
+
throw usageError(`--${name} needs a value`);
|
|
86
158
|
i++;
|
|
87
159
|
}
|
|
88
160
|
flags[name] = value;
|
|
89
161
|
}
|
|
162
|
+
if (positionals.length > 0) flags._ = positionals;
|
|
90
163
|
return flags;
|
|
91
164
|
}
|
|
92
165
|
|
|
@@ -94,8 +167,18 @@ export interface RunOptions {
|
|
|
94
167
|
cwd?: string;
|
|
95
168
|
/** Defaults to the console, coloured when stdout and stderr are both terminals. */
|
|
96
169
|
reporter?: Reporter;
|
|
97
|
-
/** Resolves when a `--watch`
|
|
170
|
+
/** Resolves when a `--watch` run should stop (tests); defaults to SIGINT/SIGTERM. */
|
|
98
171
|
until?: Promise<void>;
|
|
172
|
+
/** The environment (`DECO_STUDIO_URL`, `DECO_TOKEN`); defaults to the process's. */
|
|
173
|
+
env?: Env;
|
|
174
|
+
/** Defaults to the global `fetch`. */
|
|
175
|
+
fetch?: Fetch;
|
|
176
|
+
/** Runs `npx decocms auth token` (tests replace it). */
|
|
177
|
+
runCommand?: CommandRunner;
|
|
178
|
+
/** Where `--json` writes its object; defaults to stdout. */
|
|
179
|
+
stdout?: (text: string) => void;
|
|
180
|
+
/** The skills `deco skills install` copies; defaults to the package's `skills/` (tests replace it). */
|
|
181
|
+
skillsDir?: string;
|
|
99
182
|
}
|
|
100
183
|
|
|
101
184
|
function stopSignal(): Promise<void> {
|
|
@@ -128,124 +211,272 @@ async function watchLoop(
|
|
|
128
211
|
await running;
|
|
129
212
|
}
|
|
130
213
|
|
|
131
|
-
/**
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
214
|
+
/** Everything a person reads goes to stderr, so `--json`'s stdout is one object. */
|
|
215
|
+
const stderrReporter: Reporter = {
|
|
216
|
+
info: (message) => console.error(message),
|
|
217
|
+
warn: (message) => console.error(message),
|
|
218
|
+
error: (message) => console.error(message),
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
function stringFlag(flags: ParsedFlags, name: string): string | null {
|
|
222
|
+
const value = flags[name];
|
|
223
|
+
return typeof value === "string" ? value : null;
|
|
224
|
+
}
|
|
138
225
|
|
|
139
226
|
/** Run one `deco` invocation; returns the exit code. */
|
|
140
227
|
export async function runCli(argv: string[], options: RunOptions = {}): Promise<number> {
|
|
141
228
|
let reporter = options.reporter ?? consoleReporter;
|
|
229
|
+
const stdout = options.stdout ?? ((text: string) => process.stdout.write(`${text}\n`));
|
|
142
230
|
const [command, ...rest] = argv;
|
|
143
231
|
if (!command || command === "help" || command === "--help" || command === "-h") {
|
|
144
232
|
reporter.info(USAGE);
|
|
145
|
-
return command ?
|
|
146
|
-
}
|
|
147
|
-
if (command === "publish") {
|
|
148
|
-
// Not a command: a signpost for agents that look for one (design-decisions).
|
|
149
|
-
reporter.error(PUBLISH_SIGNPOST);
|
|
150
|
-
return 1;
|
|
151
|
-
}
|
|
152
|
-
if (!Object.hasOwn(COMMANDS, command)) {
|
|
153
|
-
reporter.error(`unknown command "${command}"\n\n${USAGE}`);
|
|
154
|
-
return 1;
|
|
233
|
+
return command ? EXIT.ok : EXIT.usage;
|
|
155
234
|
}
|
|
235
|
+
const json = rest.includes("--json");
|
|
236
|
+
if (json && !options.reporter) reporter = stderrReporter;
|
|
237
|
+
let outcome: Outcome;
|
|
156
238
|
try {
|
|
239
|
+
if (!Object.hasOwn(COMMANDS, command))
|
|
240
|
+
throw usageError(`unknown command "${command}"\n\n${USAGE}`);
|
|
157
241
|
const flags = parseFlags(command, rest);
|
|
158
242
|
const color =
|
|
159
243
|
typeof flags.color === "boolean"
|
|
160
244
|
? flags.color
|
|
161
245
|
: options.reporter
|
|
162
246
|
? Boolean(options.reporter.color)
|
|
163
|
-
: Boolean(process.stdout.isTTY && process.stderr.isTTY);
|
|
247
|
+
: !json && Boolean(process.stdout.isTTY && process.stderr.isTTY);
|
|
164
248
|
reporter = withColor(reporter, color);
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
249
|
+
const env = options.env ?? process.env;
|
|
250
|
+
outcome = await runCommand(command, flags, { ...options, env, reporter });
|
|
251
|
+
} catch (error) {
|
|
252
|
+
if (!(error instanceof CliError)) throw error;
|
|
253
|
+
reporter.error(error.message);
|
|
254
|
+
if (json) {
|
|
255
|
+
stdout(
|
|
256
|
+
JSON.stringify({
|
|
257
|
+
ok: false,
|
|
258
|
+
exitCode: error.exitCode,
|
|
259
|
+
error: { code: error.code, message: error.message },
|
|
260
|
+
...error.details,
|
|
261
|
+
}),
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
return error.exitCode;
|
|
265
|
+
}
|
|
266
|
+
if (json) {
|
|
267
|
+
stdout(
|
|
268
|
+
JSON.stringify(
|
|
269
|
+
outcome.exitCode === EXIT.ok
|
|
270
|
+
? { ok: true, ...outcome.result }
|
|
271
|
+
: { ok: false, exitCode: outcome.exitCode, ...outcome.result },
|
|
272
|
+
),
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
return outcome.exitCode;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* The root of a remote command. With no `.deco/` at all a remote command has
|
|
280
|
+
* no folder to work in nor to read `DECO_SITE` from, a usage error (64), as a
|
|
281
|
+
* missing `DECO_SITE` is (contract §7.4); local commands keep exit 1. The
|
|
282
|
+
* message stays the documented one (cli-09).
|
|
283
|
+
*/
|
|
284
|
+
function remoteRoot(options: { root?: string; cwd?: string }): string {
|
|
285
|
+
try {
|
|
286
|
+
return findDecoRoot(options);
|
|
287
|
+
} catch (error) {
|
|
288
|
+
if (error instanceof CliError && error.exitCode !== EXIT.usage) {
|
|
289
|
+
throw usageError(error.message);
|
|
290
|
+
}
|
|
291
|
+
throw error;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
async function runCommand(
|
|
296
|
+
command: string,
|
|
297
|
+
flags: ParsedFlags,
|
|
298
|
+
options: RunOptions & { env: Env; reporter: Reporter },
|
|
299
|
+
): Promise<Outcome> {
|
|
300
|
+
const { reporter } = options;
|
|
301
|
+
const positionals = (flags._ as string[] | undefined) ?? [];
|
|
302
|
+
const root = flags.root as string | undefined;
|
|
303
|
+
const base = { root, cwd: options.cwd, reporter };
|
|
304
|
+
const remote = (): RemoteContext => ({
|
|
305
|
+
paths: decoPaths(remoteRoot(base)),
|
|
306
|
+
reporter,
|
|
307
|
+
env: options.env,
|
|
308
|
+
fetch: options.fetch ?? fetch,
|
|
309
|
+
runCommand: options.runCommand,
|
|
310
|
+
});
|
|
311
|
+
const legacy = (exitCode: number, result: Record<string, unknown> = {}): Outcome =>
|
|
312
|
+
exitCode === EXIT.ok
|
|
313
|
+
? { exitCode, result }
|
|
314
|
+
: {
|
|
315
|
+
exitCode,
|
|
316
|
+
result: { error: { code: "failed", message: `deco ${command} failed` }, ...result },
|
|
186
317
|
};
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
318
|
+
switch (command) {
|
|
319
|
+
case "login":
|
|
320
|
+
return login({ env: options.env, reporter });
|
|
321
|
+
case "pull": {
|
|
322
|
+
const draft = stringFlag(flags, "draft");
|
|
323
|
+
return pull(remote(), {
|
|
324
|
+
draft: draft === null ? null : checkDraftName(draft),
|
|
325
|
+
force: flags.force === true,
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
case "diff": {
|
|
329
|
+
const draft = stringFlag(flags, "draft");
|
|
330
|
+
return diff(remote(), { draft: draft === null ? null : checkDraftName(draft) });
|
|
331
|
+
}
|
|
332
|
+
case "push": {
|
|
333
|
+
const draft = requireDraftName(flags.draft, "push");
|
|
334
|
+
if (flags.ours && flags.theirs) throw usageError("--ours and --theirs can't be combined");
|
|
335
|
+
return push(remote(), {
|
|
336
|
+
draft,
|
|
337
|
+
side: flags.ours ? "ours" : flags.theirs ? "theirs" : null,
|
|
338
|
+
prune: flags.prune === true,
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
case "publish":
|
|
342
|
+
return publish(remote(), {
|
|
343
|
+
draft: requireDraftName(flags.draft, "publish"),
|
|
344
|
+
message: stringFlag(flags, "message") ?? undefined,
|
|
345
|
+
});
|
|
346
|
+
case "drafts": {
|
|
347
|
+
const name = positionals[1] ?? null;
|
|
348
|
+
return drafts(remote(), {
|
|
349
|
+
action: positionals[0],
|
|
350
|
+
name: name === null ? null : checkDraftName(name),
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
case "releases":
|
|
354
|
+
return releases(remote(), { cursor: stringFlag(flags, "cursor") ?? undefined });
|
|
355
|
+
case "check": {
|
|
356
|
+
const draft = stringFlag(flags, "draft");
|
|
357
|
+
const revision = stringFlag(flags, "revision");
|
|
358
|
+
if (draft !== null && revision !== null)
|
|
359
|
+
throw usageError("--draft and --revision can't be combined");
|
|
360
|
+
// No flag: production (latest.json, then each block by hash, from the
|
|
361
|
+
// CDN), always, even when .deco/blocks exists. No .deco/ at all stays
|
|
362
|
+
// exit 1 for check, as before.
|
|
363
|
+
const paths = decoPaths(findDecoRoot(base));
|
|
364
|
+
if (draft === null && revision === null && findSite(paths, options.env) === null) {
|
|
365
|
+
// No Studio site: the content is the git-backed .deco/blocks (a site
|
|
366
|
+
// on createCMS({ blocks, content }), a v7 site being migrated), checked
|
|
367
|
+
// as deco check always did.
|
|
368
|
+
const meta = readSchemaFile(paths.schema);
|
|
369
|
+
return checkOutcome(reportCheck(meta, readSavedBlocks(paths.blocks), reporter));
|
|
204
370
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
);
|
|
220
|
-
|
|
371
|
+
const ctx = remote();
|
|
372
|
+
const meta = readSchemaFile(ctx.paths.schema);
|
|
373
|
+
const source = await remoteBlocks(ctx, {
|
|
374
|
+
draft: draft === null ? null : checkDraftName(draft),
|
|
375
|
+
revision,
|
|
376
|
+
});
|
|
377
|
+
reporter.info(`checking ${source.label}`);
|
|
378
|
+
return checkOutcome(reportCheck(meta, savedBlocksFromMap(source.blocks), reporter));
|
|
379
|
+
}
|
|
380
|
+
case "content": {
|
|
381
|
+
if (!flags.watch) return legacy(await content(base));
|
|
382
|
+
const paths = decoPaths(findDecoRoot(base));
|
|
383
|
+
const once = async () => {
|
|
384
|
+
const result = await writeContent(paths);
|
|
385
|
+
if (result.changed) reporter.info(`wrote .deco/blocks.gen.ts (${result.count} blocks)`);
|
|
386
|
+
};
|
|
387
|
+
await content({ ...base, watching: true });
|
|
388
|
+
await watchLoop(
|
|
389
|
+
paths.blocks,
|
|
390
|
+
(rel) => rel.endsWith(".json"),
|
|
391
|
+
once,
|
|
392
|
+
options.until ?? stopSignal(),
|
|
393
|
+
reporter,
|
|
394
|
+
);
|
|
395
|
+
return { exitCode: EXIT.ok, result: {} };
|
|
396
|
+
}
|
|
397
|
+
case "schema": {
|
|
398
|
+
if (positionals.length > 0) {
|
|
399
|
+
if (positionals[0] !== "push")
|
|
400
|
+
throw usageError(`unexpected argument "${positionals[0]}"\n${COMMANDS.schema!.usage}`);
|
|
401
|
+
if (flags.watch || flags.check)
|
|
402
|
+
throw usageError("deco schema push takes no --watch or --check");
|
|
403
|
+
return schemaPush(remote());
|
|
221
404
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
case "serve": {
|
|
225
|
-
const port = flags.port === undefined ? undefined : Number(flags.port);
|
|
226
|
-
if (port !== undefined && !Number.isInteger(port))
|
|
227
|
-
throw new CliError(`--port must be a number, got ${flags.port}`);
|
|
228
|
-
const serveOptions = {
|
|
229
|
-
...base,
|
|
230
|
-
port,
|
|
231
|
-
host: flags.host as string | undefined,
|
|
232
|
-
preview: flags.preview as string | undefined,
|
|
233
|
-
assets: flags.assets as string | undefined,
|
|
234
|
-
readOnly: Boolean(flags["read-only"]),
|
|
235
|
-
};
|
|
236
|
-
if (!options.until) return await serve(serveOptions);
|
|
237
|
-
const running = await startServer(serveOptions);
|
|
238
|
-
await options.until;
|
|
239
|
-
await running.close();
|
|
240
|
-
return 0;
|
|
405
|
+
if (flags.watch && flags.check) {
|
|
406
|
+
throw usageError(`--watch and --check can't be combined\n${COMMANDS.schema!.usage}`);
|
|
241
407
|
}
|
|
408
|
+
if (!flags.watch) return legacy(await schema({ ...base, check: flags.check === true }));
|
|
409
|
+
const paths = decoPaths(findDecoRoot(base));
|
|
410
|
+
// Monorepo packages the block map imports live outside the root:
|
|
411
|
+
// watch the files the last run read there, too.
|
|
412
|
+
const external = watchFiles(() => void once());
|
|
413
|
+
let running = Promise.resolve();
|
|
414
|
+
const run = async () => {
|
|
415
|
+
const result = await writeSchema(paths);
|
|
416
|
+
external.update(result.externalSources);
|
|
417
|
+
reportSchema(result, reporter);
|
|
418
|
+
};
|
|
419
|
+
const once = () => {
|
|
420
|
+
running = running.then(run).catch((error) => reporter.error((error as Error).message));
|
|
421
|
+
return running;
|
|
422
|
+
};
|
|
423
|
+
await run();
|
|
424
|
+
// Regenerate when any source file changes; the schema only depends on code.
|
|
425
|
+
await watchLoop(
|
|
426
|
+
paths.root,
|
|
427
|
+
(rel) =>
|
|
428
|
+
/\.(ts|tsx|mts|cts)$/.test(rel) &&
|
|
429
|
+
!rel
|
|
430
|
+
.split("/")
|
|
431
|
+
.some((s) => s === "node_modules" || s.startsWith(".git") || s === "dist") &&
|
|
432
|
+
!rel.endsWith(".gen.ts"),
|
|
433
|
+
once,
|
|
434
|
+
options.until ?? stopSignal(),
|
|
435
|
+
reporter,
|
|
436
|
+
);
|
|
437
|
+
external.close();
|
|
438
|
+
await running;
|
|
439
|
+
return { exitCode: EXIT.ok, result: {} };
|
|
242
440
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
441
|
+
case "skills": {
|
|
442
|
+
if (positionals[0] !== "install") {
|
|
443
|
+
throw usageError(
|
|
444
|
+
positionals.length === 0
|
|
445
|
+
? `deco skills needs a subcommand\n${COMMANDS.skills!.usage}`
|
|
446
|
+
: `unexpected argument "${positionals[0]}"\n${COMMANDS.skills!.usage}`,
|
|
447
|
+
);
|
|
448
|
+
}
|
|
449
|
+
const dir = stringFlag(flags, "dir") ?? undefined;
|
|
450
|
+
const paths = decoPaths(findDecoRoot(base));
|
|
451
|
+
const installed = installSkills({ root: paths.root, dir, from: options.skillsDir });
|
|
452
|
+
const shown = path.relative(paths.root, installed.dir) || ".";
|
|
453
|
+
const where = shown.startsWith("..") || path.isAbsolute(shown) ? installed.dir : shown;
|
|
454
|
+
for (const name of installed.skills) reporter.info(`installed ${path.join(where, name)}/`);
|
|
455
|
+
reporter.info(
|
|
456
|
+
`${installed.skills.length} skill(s) from @decocms/blocks ${packageVersion()} in ${where}`,
|
|
457
|
+
);
|
|
458
|
+
return {
|
|
459
|
+
exitCode: EXIT.ok,
|
|
460
|
+
result: { dir: installed.dir, version: packageVersion(), skills: installed.skills },
|
|
461
|
+
};
|
|
248
462
|
}
|
|
249
|
-
throw error;
|
|
250
463
|
}
|
|
464
|
+
throw usageError(`unknown command "${command}"`);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
function checkOutcome(report: ReturnType<typeof reportCheck>): Outcome {
|
|
468
|
+
const result = {
|
|
469
|
+
blocks: report.count,
|
|
470
|
+
errors: report.errors,
|
|
471
|
+
warnings: report.warnings,
|
|
472
|
+
problems: report.problems,
|
|
473
|
+
};
|
|
474
|
+
if (report.exitCode === EXIT.ok) return { exitCode: EXIT.ok, result };
|
|
475
|
+
return {
|
|
476
|
+
exitCode: report.exitCode,
|
|
477
|
+
result: {
|
|
478
|
+
error: { code: "check_failed", message: `${report.errors} errors` },
|
|
479
|
+
...result,
|
|
480
|
+
},
|
|
481
|
+
};
|
|
251
482
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The forms of the
|
|
2
|
+
* The forms of the thirteen built-in blocks (spec: built-in-blocks, and the types
|
|
3
3
|
* in api-reference › Types). They're always in the schema, unless the block
|
|
4
4
|
* map declares the same key, which replaces the built-in.
|
|
5
5
|
*/
|
|
@@ -16,6 +16,7 @@ export const BUILT_IN_GROUPS: Record<string, ManifestGroup> = {
|
|
|
16
16
|
campaign: "matchers",
|
|
17
17
|
page: "pages",
|
|
18
18
|
redirect: "redirects",
|
|
19
|
+
redirects: "redirects",
|
|
19
20
|
"cms-settings": "content",
|
|
20
21
|
"split-traffic": "content",
|
|
21
22
|
calendar: "content",
|
|
@@ -42,6 +43,10 @@ const BUILT_IN_DOCS: Record<string, { title: string; description: string; icon?:
|
|
|
42
43
|
},
|
|
43
44
|
page: { title: "Page", description: "A page at a URL" },
|
|
44
45
|
redirect: { title: "Redirect", description: "Sends one URL to another" },
|
|
46
|
+
redirects: {
|
|
47
|
+
title: "Redirects",
|
|
48
|
+
description: "The site's redirects: every rule in one block (the saved block Redirects)",
|
|
49
|
+
},
|
|
45
50
|
"cms-settings": {
|
|
46
51
|
title: "CMS settings",
|
|
47
52
|
description: "Telemetry and analytics: the saved block named CMS",
|
|
@@ -61,6 +66,23 @@ const BUILT_IN_DOCS: Record<string, { title: string; description: string; icon?:
|
|
|
61
66
|
},
|
|
62
67
|
};
|
|
63
68
|
|
|
69
|
+
/** One redirect rule: the props of `redirect`, and each item of `redirects`. */
|
|
70
|
+
const REDIRECT_RULE = {
|
|
71
|
+
type: "object",
|
|
72
|
+
required: ["from", "to", "permanent"],
|
|
73
|
+
properties: {
|
|
74
|
+
from: { type: "string", title: "From" },
|
|
75
|
+
to: { type: "string", title: "To" },
|
|
76
|
+
permanent: {
|
|
77
|
+
type: "boolean",
|
|
78
|
+
title: "Permanent",
|
|
79
|
+
description: "301 when true, 307 otherwise",
|
|
80
|
+
},
|
|
81
|
+
status: { type: "number", enum: [301, 302, 307, 308], title: "Status" },
|
|
82
|
+
discardQueryParameters: { type: "boolean", title: "Discard query parameters" },
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
|
|
64
86
|
/** The form of each test in a `split-traffic` block: a whole percentage. */
|
|
65
87
|
const ALLOCATION = {
|
|
66
88
|
type: "integer",
|
|
@@ -213,19 +235,16 @@ function builtInProps(name: string, ctx: BuiltInContext): any {
|
|
|
213
235
|
},
|
|
214
236
|
};
|
|
215
237
|
case "redirect":
|
|
238
|
+
return REDIRECT_RULE;
|
|
239
|
+
case "redirects":
|
|
216
240
|
return {
|
|
217
241
|
type: "object",
|
|
218
|
-
required: ["from", "to", "permanent"],
|
|
219
242
|
properties: {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
title: "Permanent",
|
|
225
|
-
description: "301 when true, 302 otherwise",
|
|
243
|
+
redirects: {
|
|
244
|
+
type: "array",
|
|
245
|
+
title: "Redirects",
|
|
246
|
+
items: { ...REDIRECT_RULE, title: "Redirect" },
|
|
226
247
|
},
|
|
227
|
-
status: { type: "number", enum: [301, 302, 307, 308], title: "Status" },
|
|
228
|
-
discardQueryParameters: { type: "boolean", title: "Discard query parameters" },
|
|
229
248
|
},
|
|
230
249
|
};
|
|
231
250
|
case "cms-settings":
|