@astryxdesign/cli 0.6.3-canary.ea2f048 → 0.6.3-canary.f04b501
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/README.md +106 -72
- package/api/blog/blog.doc.mjs +1 -0
- package/api/build/build.doc.mjs +4 -3
- package/api/build/build.test.mjs +14 -3
- package/api/build/build.type.d.mts +36 -2
- package/api/build/build.type.mjs +25 -4
- package/api/build/help/help.d.mts +8 -5
- package/api/build/help/help.mjs +56 -6
- package/api/component/component.doc.mjs +13 -3
- package/api/component/component.mjs +31 -2
- package/api/component/component.test.mjs +38 -0
- package/api/component/component.type.d.mts +22 -11
- package/api/component/component.type.mjs +32 -24
- package/api/component/detail/blocks/blocks.d.mts +2 -1
- package/api/component/detail/blocks/blocks.mjs +4 -3
- package/api/component/list/list.d.mts +0 -5
- package/api/component/list/list.mjs +37 -9
- package/api/discover/discover.doc.mjs +2 -1
- package/api/discover/discover.type.d.mts +4 -4
- package/api/discover/discover.type.mjs +10 -10
- package/api/docs/_adapter.d.mts +32 -24
- package/api/docs/_adapter.mjs +81 -87
- package/api/docs/compiled-topics.test.mjs +78 -0
- package/api/docs/detail/detail.mjs +14 -63
- package/api/docs/detail/section/section.d.mts +1 -1
- package/api/docs/detail/section/section.mjs +44 -20
- package/api/docs/detail/section/section.test.mjs +41 -0
- package/api/docs/docs.d.mts +7 -2
- package/api/docs/docs.doc.mjs +28 -10
- package/api/docs/docs.mjs +16 -9
- package/api/docs/docs.test.mjs +6 -0
- package/api/docs/docs.type.d.mts +40 -3
- package/api/docs/docs.type.mjs +36 -8
- package/api/docs/index/index.d.mts +18 -0
- package/api/docs/index/index.mjs +32 -0
- package/api/docs/index/index.test.mjs +62 -0
- package/api/docs/integrationDocs.test.mjs +106 -0
- package/api/docs/list/list.mjs +3 -7
- package/api/doctor/doctor.d.mts +70 -0
- package/api/doctor/doctor.doc.mjs +1 -0
- package/api/doctor/doctor.mjs +404 -0
- package/api/doctor/doctor.test.mjs +522 -1
- package/api/gap-report/gap-report.doc.mjs +8 -4
- package/api/hook/_adapter.mjs +19 -5
- package/api/hook/hook.doc.mjs +1 -0
- package/api/hook/hook.type.d.mts +3 -3
- package/api/hook/hook.type.mjs +11 -11
- package/api/hook/list/list.d.mts +2 -2
- package/api/hook/list/list.mjs +69 -17
- package/api/init/init.doc.mjs +5 -0
- package/api/init/init.test.mjs +41 -1
- package/api/init/remove/remove.mjs +1 -1
- package/api/init/run/run.mjs +20 -10
- package/api/integration/add-contribution.component-names.test.mjs +120 -0
- package/api/integration/add-contribution.mjs +23 -10
- package/api/integration/add-contribution.test.mjs +121 -7
- package/api/integration/add-theme.mjs +34 -64
- package/api/integration/add-theme.test.mjs +105 -21
- package/api/integration/authoring-checks.test.mjs +8 -4
- package/api/integration/integration-authoring.type.d.mts +1 -1
- package/api/integration/integration-block-exports.test.mjs +10 -6
- package/api/integration/integrationAdd.doc.mjs +8 -4
- package/api/integration/integrationAddAgentDoc.doc.mjs +1 -0
- package/api/integration/integrationAddCodemod.doc.mjs +1 -0
- package/api/integration/integrationAddComponent.doc.mjs +2 -1
- package/api/integration/integrationAddDoc.doc.mjs +1 -0
- package/api/integration/integrationAddTemplate.doc.mjs +1 -0
- package/api/integration/integrationAddTheme.doc.mjs +6 -5
- package/api/integration/integrationComponentConflicts.doc.mjs +1 -0
- package/api/integration/integrationDocConflicts.doc.mjs +1 -0
- package/api/integration/integrationPackCheck.doc.mjs +1 -0
- package/api/integration/integrationTemplateConflicts.doc.mjs +1 -0
- package/api/integration/pack-check.mjs +49 -7
- package/api/integration/pack-check.test.mjs +266 -47
- package/api/integration/summarizeIssues.doc.mjs +1 -0
- package/api/integration/validate-integration-fixes.test.mjs +1389 -0
- package/api/integration/validate-integration.mjs +52 -102
- package/api/integration/validate-integration.test.mjs +176 -23
- package/api/integration/validate-unread-theme-folders.test.mjs +110 -0
- package/api/integration/validateIntegration.doc.mjs +2 -1
- package/api/json/assertResponse.doc.mjs +1 -0
- package/api/json/envelope-types.test.mjs +76 -0
- package/api/json/isError.doc.mjs +1 -0
- package/api/json/parseResponse.doc.mjs +3 -2
- package/api/layout/expand/expand.mjs +7 -5
- package/api/layout/expand/expand.path-safety.test.mjs +53 -0
- package/api/layout/grammar/grammar.mjs +2 -1
- package/api/layout/layoutCheck.doc.mjs +1 -0
- package/api/layout/layoutExpand.doc.mjs +2 -1
- package/api/layout/layoutGrammar.doc.mjs +1 -0
- package/api/search/search-return-type.test.mjs +54 -0
- package/api/search/search.d.mts +3 -10
- package/api/search/search.doc.mjs +6 -1
- package/api/search/search.mjs +31 -14
- package/api/search/search.test.mjs +34 -0
- package/api/search/search.type.d.mts +2 -2
- package/api/search/search.type.mjs +1 -1
- package/api/swizzle/copy/copy.mjs +28 -11
- package/api/swizzle/swizzle.doc.mjs +2 -1
- package/api/swizzle/swizzle.type.d.mts +2 -2
- package/api/swizzle/swizzle.type.mjs +2 -2
- package/api/template/copy/copy.mjs +17 -23
- package/api/template/copy/copy.test.mjs +17 -0
- package/api/template/template-suffix.test.mjs +41 -21
- package/api/template/template.d.mts +1 -1
- package/api/template/template.doc.mjs +3 -1
- package/api/template/template.type.d.mts +6 -6
- package/api/template/template.type.mjs +12 -12
- package/api/theme/_adapter.d.mts +2 -3
- package/api/theme/_adapter.mjs +4 -5
- package/api/theme/add/add.binary.test.mjs +84 -0
- package/api/theme/add/add.mjs +20 -3
- package/api/theme/add/add.staging.test.mjs +66 -0
- package/api/theme/add/add.test.mjs +14 -1
- package/api/theme/build/build.mjs +133 -42
- package/api/theme/build/build.public-component-vars.test.mjs +1 -1
- package/api/theme/build/build.receipt-doc.test.mjs +111 -0
- package/api/theme/build/build.test.mjs +127 -0
- package/api/theme/build/font-warning.mjs +3 -3
- package/api/theme/build/font-warning.test.mjs +5 -2
- package/api/theme/generateTonalPalette.doc.mjs +1 -0
- package/api/theme/integration-themes.test.mjs +39 -28
- package/api/theme/list/list.test.mjs +19 -20
- package/api/theme/listThemes.doc.mjs +6 -5
- package/api/theme/palette/generate/generate.mjs +8 -3
- package/api/theme/palette/generate/generate.test.mjs +96 -0
- package/api/theme/palette/generate/generator.d.mts +10 -13
- package/api/theme/palette/generate/generator.mjs +15 -4
- package/api/theme/palette/generate/generator.test.mjs +10 -0
- package/api/theme/template/template.mjs +11 -2
- package/api/theme/template/template.test.mjs +15 -0
- package/api/theme/theme.type.d.mts +170 -11
- package/api/theme/theme.type.mjs +94 -27
- package/api/theme/themeAdd.doc.mjs +4 -3
- package/api/theme/themeBuild.doc.mjs +8 -4
- package/api/theme/themeList.doc.mjs +6 -3
- package/api/theme/themeListAvailable.doc.mjs +5 -3
- package/api/theme/themePaletteGenerate.doc.mjs +1 -0
- package/api/theme/themeTargets.doc.mjs +1 -0
- package/api/theme/themeTemplate.doc.mjs +5 -1
- package/api/upgrade/_adapter.d.mts +12 -3
- package/api/upgrade/_adapter.mjs +123 -19
- package/api/upgrade/list/list.mjs +2 -1
- package/api/upgrade/list/list.test.mjs +73 -0
- package/api/upgrade/project-context.test.mjs +272 -0
- package/api/upgrade/provider-agreement.test.mjs +152 -0
- package/api/upgrade/run/run.mjs +1 -0
- package/api/upgrade/status/status.mjs +2 -2
- package/api/upgrade/upgrade.doc.mjs +7 -4
- package/api/upgrade/upgrade.type.d.mts +9 -5
- package/api/upgrade/upgrade.type.mjs +12 -11
- package/assets/codemods/integration-discovery.mjs +48 -4
- package/assets/codemods/integration-discovery.test.mjs +73 -0
- package/assets/codemods/runner.mjs +115 -5
- package/assets/codemods/term-log.mjs +32 -8
- package/assets/codemods/term-log.test.mjs +19 -1
- package/assets/codemods/transform-prop.mjs +109 -0
- package/assets/codemods/transform-prop.test.mjs +95 -0
- package/assets/codemods/transforms/next/__tests__/migrate-theme-catalog-to-descriptors.test.mjs +216 -0
- package/assets/codemods/transforms/next/index.mjs +11 -1
- package/assets/codemods/transforms/next/migrate-theme-catalog-to-descriptors.mjs +141 -0
- package/assets/codemods/transforms/v0.0.14/__tests__/rename-status-variants.test.mjs +86 -165
- package/assets/codemods/transforms/v0.0.14/rename-status-variants.mjs +72 -210
- package/assets/codemods/transforms/v0.1.8/__tests__/rename-avatar-size-scale.test.mjs +83 -115
- package/assets/codemods/transforms/v0.1.8/rename-avatar-size-scale.mjs +57 -186
- package/assets/codemods/transforms/v0.3.0/__tests__/unwrap-authoring-factories.test.mjs +27 -5
- package/assets/codemods/transforms/v0.3.0/unwrap-authoring-factories.mjs +20 -5
- package/assets/codemods/transforms/v0.6.0/__tests__/next-codemods.test.mjs +47 -0
- package/assets/codemods/transforms/v0.6.0/rename-resizable-pixel-bounds.mjs +57 -10
- package/assets/docs/README.md +9 -0
- package/assets/docs/authoring.doc.mjs +14 -0
- package/assets/docs/cli-integrations.doc.mjs +78 -20
- package/assets/docs/cli.doc.mjs +15 -0
- package/assets/docs/styling-libraries.doc.mjs +1 -1
- package/assets/docs/theme.doc.mjs +1 -1
- package/assets/docs/working-with-ai.doc.mjs +1 -1
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaInlineRail.doc.mjs +14 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaInlineRail.tsx +61 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaOverscrollChaining.doc.mjs +14 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaOverscrollChaining.tsx +126 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaShowcase.doc.mjs +15 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaShowcase.tsx +86 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyGroupHeaders.doc.mjs +14 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyGroupHeaders.tsx +99 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyPassthrough.doc.mjs +14 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyPassthrough.tsx +122 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaTwoAxisBoard.doc.mjs +14 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaTwoAxisBoard.tsx +95 -0
- package/assets/templates/pages/table-tree/page.tsx +1704 -0
- package/assets/templates/pages/table-tree/template.doc.mjs +12 -0
- package/assets/templates/themes/butter/butterTheme.doc.mjs +11 -0
- package/assets/templates/themes/chocolate/chocolateTheme.doc.mjs +11 -0
- package/assets/templates/themes/gothic/gothicTheme.doc.mjs +11 -0
- package/assets/templates/themes/matcha/matchaTheme.doc.mjs +11 -0
- package/assets/templates/themes/neutral/neutralTheme.doc.mjs +11 -0
- package/assets/templates/themes/stone/stoneTheme.doc.mjs +11 -0
- package/assets/templates/themes/y2k/y2kTheme.doc.mjs +11 -0
- package/authoring/_shared/contract.ts +22 -0
- package/authoring/codemod/codemod.doc.mjs +7 -2
- package/authoring/codemod/parse.d.mts +8 -8
- package/authoring/codemod/parse.mjs +8 -6
- package/authoring/config/config.doc.mjs +2 -2
- package/authoring/config/debug-composition.test.mjs +92 -0
- package/authoring/config/parse.d.mts +13 -13
- package/authoring/config/parse.mjs +8 -8
- package/authoring/config/type.ts +18 -6
- package/authoring/debug/debug.doc.d.mts +11 -0
- package/authoring/debug/debug.doc.mjs +182 -0
- package/authoring/debug/parse.d.mts +5 -5
- package/authoring/debug/parse.mjs +3 -3
- package/authoring/doctypes/_schema.d.mts +788 -23
- package/authoring/doctypes/_schema.mjs +492 -39
- package/authoring/doctypes/base/graph-fields.doc.d.mts +9 -0
- package/authoring/doctypes/base/graph-fields.doc.mjs +62 -0
- package/authoring/doctypes/base/type.ts +40 -0
- package/authoring/doctypes/command/command.doc.mjs +4 -3
- package/authoring/doctypes/command/parse.d.mts +2 -2
- package/authoring/doctypes/command/parse.mjs +1 -1
- package/authoring/doctypes/command/type.ts +4 -3
- package/authoring/doctypes/component/component.doc.mjs +6 -3
- package/authoring/doctypes/component/parse.d.mts +2 -2
- package/authoring/doctypes/component/parse.mjs +1 -1
- package/authoring/doctypes/component/type.ts +6 -5
- package/authoring/doctypes/doctypes-new.test.mjs +48 -6
- package/authoring/doctypes/enum/enum.doc.mjs +1 -1
- package/authoring/doctypes/enum/parse.d.mts +2 -2
- package/authoring/doctypes/enum/parse.mjs +1 -1
- package/authoring/doctypes/enum/type.ts +4 -2
- package/authoring/doctypes/function/function.doc.mjs +5 -1
- package/authoring/doctypes/function/parse.d.mts +2 -2
- package/authoring/doctypes/function/parse.mjs +1 -1
- package/authoring/doctypes/function/type.ts +7 -3
- package/authoring/doctypes/hook/hook.doc.mjs +4 -0
- package/authoring/doctypes/hook/parse.d.mts +2 -2
- package/authoring/doctypes/hook/parse.mjs +1 -1
- package/authoring/doctypes/hook/type.ts +5 -4
- package/authoring/doctypes/legacy.d.mts +8 -6
- package/authoring/doctypes/legacy.mjs +5 -4
- package/authoring/doctypes/load-contract.test.mjs +208 -0
- package/authoring/doctypes/namespace/namespace.doc.d.mts +9 -0
- package/authoring/doctypes/namespace/namespace.doc.mjs +132 -0
- package/authoring/doctypes/namespace/parse.d.mts +12 -0
- package/authoring/doctypes/namespace/parse.mjs +25 -0
- package/authoring/doctypes/namespace/parse.test.mjs +165 -0
- package/authoring/doctypes/namespace/type.ts +71 -0
- package/authoring/doctypes/parse.d.mts +22 -18
- package/authoring/doctypes/parse.mjs +22 -12
- package/authoring/doctypes/parse.test.mjs +77 -3
- package/authoring/doctypes/reference/parse.d.mts +2 -2
- package/authoring/doctypes/reference/parse.mjs +8 -5
- package/authoring/doctypes/reference/reference.doc.mjs +18 -5
- package/authoring/doctypes/reference/type.ts +53 -7
- package/authoring/doctypes/schema/parse.d.mts +2 -2
- package/authoring/doctypes/schema/parse.mjs +1 -1
- package/authoring/doctypes/schema/schema.doc.mjs +1 -1
- package/authoring/doctypes/schema/type.ts +4 -4
- package/authoring/doctypes/template/parse.d.mts +92 -1
- package/authoring/doctypes/template/parse.mjs +36 -2
- package/authoring/doctypes/template/parse.test.mjs +8 -2
- package/authoring/doctypes/template/template.doc.mjs +7 -3
- package/authoring/doctypes/template/type.ts +5 -2
- package/authoring/doctypes/theme/parse.d.mts +35 -0
- package/authoring/doctypes/theme/parse.mjs +76 -0
- package/authoring/doctypes/theme/theme.doc.d.mts +9 -0
- package/authoring/doctypes/theme/theme.doc.mjs +79 -0
- package/authoring/doctypes/theme/type.ts +42 -0
- package/authoring/doctypes/types.ts +12 -10
- package/authoring/gap-report/gap-report.doc.d.mts +12 -0
- package/authoring/gap-report/gap-report.doc.mjs +183 -0
- package/authoring/gap-report/parse.d.mts +10 -10
- package/authoring/gap-report/parse.mjs +6 -6
- package/authoring/gap-report/type.ts +1 -1
- package/authoring/identity/identity.doc.d.mts +9 -0
- package/authoring/identity/identity.doc.mjs +61 -0
- package/authoring/identity/type.ts +132 -0
- package/authoring/index.d.mts +2 -0
- package/authoring/index.d.ts +51 -17
- package/authoring/index.mjs +3 -1
- package/authoring/integration/integration.doc.mjs +15 -8
- package/authoring/integration/parse.d.mts +2 -2
- package/authoring/integration/parse.mjs +1 -1
- package/authoring/integration/parse.test.mjs +10 -1
- package/authoring/integration/schema.d.mts +6 -4
- package/authoring/integration/schema.mjs +9 -3
- package/authoring/integration/type.ts +18 -7
- package/authoring/shadcn/receipt.d.mts +6 -6
- package/clients/cli/__tests__/cliManifest.test.ts +27 -29
- package/clients/cli/command-load-failure.test.mjs +83 -0
- package/clients/cli/commands/blog.doc.mjs +1 -1
- package/clients/cli/commands/blog.mjs +23 -8
- package/clients/cli/commands/blog.test.mjs +42 -1
- package/clients/cli/commands/build-theme.ascii-output.test.mjs +161 -0
- package/clients/cli/commands/build-theme.flag-docs.test.mjs +110 -0
- package/clients/cli/commands/build-theme.mjs +5 -5
- package/clients/cli/commands/build-theme.path-safety.test.mjs +86 -1
- package/clients/cli/commands/build-theme.variants.test.mjs +76 -0
- package/clients/cli/commands/build.doc.mjs +5 -2
- package/clients/cli/commands/build.exit-codes-doc.test.mjs +50 -0
- package/clients/cli/commands/build.mjs +32 -47
- package/clients/cli/commands/build.playbook.test.mjs +75 -0
- package/clients/cli/commands/build.text-fields.test.mjs +40 -0
- package/clients/cli/commands/component/index.mjs +2 -7
- package/clients/cli/commands/component-package.test.mjs +46 -0
- package/clients/cli/commands/component-resolution.test.mjs +21 -0
- package/clients/cli/commands/component.doc.mjs +1 -1
- package/clients/cli/commands/component.test.mjs +19 -0
- package/clients/cli/commands/detail-levels.test.mjs +2 -2
- package/clients/cli/commands/discover.broken-integration.test.mjs +48 -0
- package/clients/cli/commands/discover.components-flag.test.mjs +97 -0
- package/clients/cli/commands/discover.doc.mjs +5 -3
- package/clients/cli/commands/discover.mjs +3 -3
- package/clients/cli/commands/discover.text-projection.test.mjs +103 -0
- package/clients/cli/commands/docs.doc.mjs +14 -4
- package/clients/cli/commands/docs.mjs +121 -21
- package/clients/cli/commands/docs.test.mjs +88 -0
- package/clients/cli/commands/doctor-integration-components.doc.mjs +1 -1
- package/clients/cli/commands/doctor-integration-docs.doc.mjs +1 -1
- package/clients/cli/commands/doctor-integration-templates.doc.mjs +1 -1
- package/clients/cli/commands/doctor-integration-validate.doc.mjs +1 -1
- package/clients/cli/commands/doctor-integration.doc.mjs +1 -1
- package/clients/cli/commands/doctor-integration.package-json.test.mjs +53 -0
- package/clients/cli/commands/doctor-integration.test.mjs +15 -7
- package/clients/cli/commands/doctor.doc.mjs +1 -1
- package/clients/cli/commands/doctor.mjs +6 -16
- package/clients/cli/commands/doctor.test.mjs +42 -0
- package/clients/cli/commands/gap-report.doc.mjs +17 -6
- package/clients/cli/commands/gap-report.test.mjs +72 -0
- package/clients/cli/commands/hook/index.mjs +7 -17
- package/clients/cli/commands/hook.doc.mjs +1 -1
- package/clients/cli/commands/hook.text-projection.test.mjs +45 -0
- package/clients/cli/commands/init.doc.mjs +20 -9
- package/clients/cli/commands/init.flag-help.test.mjs +153 -0
- package/clients/cli/commands/integration-add.controls.test.mjs +132 -0
- package/clients/cli/commands/integration-add.doc.mjs +22 -6
- package/clients/cli/commands/integration-authoring.test.mjs +13 -9
- package/clients/cli/commands/integration-pack.doc.mjs +1 -1
- package/clients/cli/commands/integration-real-world.test.mjs +3 -9
- package/clients/cli/commands/integration.doc.mjs +1 -1
- package/clients/cli/commands/interactive-guard.test.mjs +101 -24
- package/clients/cli/commands/json-contract.test.mjs +33 -0
- package/clients/cli/commands/layout-check.doc.mjs +15 -4
- package/clients/cli/commands/layout-expand.doc.mjs +22 -5
- package/clients/cli/commands/layout-grammar.doc.mjs +1 -1
- package/clients/cli/commands/layout.doc.mjs +3 -3
- package/clients/cli/commands/layout.mjs +21 -9
- package/clients/cli/commands/layout.path-help.test.mjs +33 -0
- package/clients/cli/commands/layout.stdin-cap.test.mjs +47 -0
- package/clients/cli/commands/layout.text-fields.test.mjs +39 -0
- package/clients/cli/commands/manifest.doc.mjs +1 -1
- package/clients/cli/commands/no-prompt-wording.test.mjs +94 -0
- package/clients/cli/commands/search.doc.mjs +7 -4
- package/clients/cli/commands/search.mjs +17 -7
- package/clients/cli/commands/search.test.mjs +75 -0
- package/clients/cli/commands/swizzle.doc.mjs +3 -2
- package/clients/cli/commands/swizzle.path-safety.test.mjs +42 -0
- package/clients/cli/commands/template.doc.mjs +29 -7
- package/clients/cli/commands/template.flag-help.test.mjs +117 -0
- package/clients/cli/commands/template.path-help.test.mjs +40 -0
- package/clients/cli/commands/theme-add.doc.mjs +4 -3
- package/clients/cli/commands/theme-build.doc.mjs +8 -7
- package/clients/cli/commands/theme-list.doc.mjs +2 -2
- package/clients/cli/commands/theme-palette-generate.doc.mjs +9 -5
- package/clients/cli/commands/theme-palette-generate.test.mjs +19 -0
- package/clients/cli/commands/theme-palette.doc.mjs +1 -1
- package/clients/cli/commands/theme-targets.doc.mjs +1 -1
- package/clients/cli/commands/theme-template.behavior.test.mjs +12 -0
- package/clients/cli/commands/theme-template.doc.mjs +2 -2
- package/clients/cli/commands/theme.doc.mjs +1 -1
- package/clients/cli/commands/upgrade.ascii-output.test.mjs +87 -0
- package/clients/cli/commands/upgrade.doc.mjs +20 -9
- package/clients/cli/commands/upgrade.flag-help.test.mjs +188 -0
- package/clients/cli/commands/upgrade.hook-output.test.mjs +88 -0
- package/clients/cli/formatters/index.mjs +162 -1
- package/clients/cli/formatters/index.test.mjs +91 -0
- package/clients/cli/index.mjs +13 -30
- package/clients/cli/latest-version-env.test.mjs +50 -0
- package/clients/cli/lib/cli-error.test.mjs +7 -0
- package/clients/cli/lib/component-format.mjs +9 -9
- package/clients/cli/lib/component-format.test.mjs +1 -1
- package/clients/cli/lib/define-command.mjs +32 -6
- package/clients/cli/lib/doc-text-ascii.test.mjs +82 -0
- package/clients/cli/lib/exit-codes.test.mjs +97 -0
- package/clients/cli/lib/hook-format.mjs +19 -10
- package/clients/cli/lib/json-shim.mjs +38 -2
- package/clients/cli/lib/json-shim.test.mjs +83 -0
- package/clients/cli/lib/manifest.d.ts +2 -0
- package/clients/cli/lib/manifest.mjs +29 -2
- package/clients/cli/lib/manifest.test.mjs +17 -0
- package/foundation/agent-docs/agent-docs.d.mts +4 -0
- package/foundation/agent-docs/agent-docs.mjs +69 -3
- package/foundation/agent-docs/agent-docs.path-safety.test.mjs +266 -4
- package/foundation/config/integration-debug.test.mjs +28 -3
- package/foundation/config/project-themes.test.mjs +11 -19
- package/foundation/config/project.d.mts +8 -0
- package/foundation/config/project.mjs +190 -32
- package/foundation/config/project.test.mjs +129 -16
- package/foundation/discovery/authoring-self-docs.d.mts +75 -0
- package/foundation/discovery/authoring-self-docs.mjs +224 -0
- package/foundation/discovery/authoring-self-docs.test.mjs +154 -0
- package/foundation/discovery/authoring-surface.d.mts +74 -0
- package/foundation/discovery/authoring-surface.mjs +525 -0
- package/foundation/discovery/authoring-surface.test.mjs +392 -0
- package/foundation/discovery/cli-self-docs.d.mts +113 -0
- package/foundation/discovery/cli-self-docs.mjs +514 -0
- package/foundation/discovery/cli-self-docs.test.mjs +437 -0
- package/foundation/discovery/component-discovery.d.mts +1 -1
- package/foundation/discovery/component-discovery.mjs +2 -1
- package/foundation/discovery/component-loader.d.mts +35 -38
- package/foundation/discovery/component-loader.mjs +53 -222
- package/foundation/discovery/docs-discovery.d.mts +12 -4
- package/foundation/discovery/docs-discovery.mjs +214 -98
- package/foundation/discovery/docs-discovery.test.mjs +284 -15
- package/foundation/discovery/docs-output-budget.d.mts +28 -0
- package/foundation/discovery/docs-output-budget.mjs +50 -0
- package/foundation/discovery/docs-section-key.d.mts +98 -0
- package/foundation/discovery/docs-section-key.mjs +221 -0
- package/foundation/discovery/docs-section-key.test.mjs +224 -0
- package/foundation/discovery/template-adapter.d.mts +21 -5
- package/foundation/discovery/template-adapter.fixture-refs.test.mjs +248 -0
- package/foundation/discovery/template-adapter.integration-isolation.test.mjs +94 -0
- package/foundation/discovery/template-adapter.mjs +321 -66
- package/foundation/discovery/template-adapter.test.mjs +15 -0
- package/foundation/discovery/theme-discovery.d.mts +67 -7
- package/foundation/discovery/theme-discovery.mjs +916 -186
- package/foundation/discovery/theme-discovery.test.mjs +613 -219
- package/foundation/discovery/theming-targets.test.mjs +4 -0
- package/foundation/doc-compiler/bundle.d.mts +47 -0
- package/foundation/doc-compiler/bundle.mjs +218 -0
- package/foundation/doc-compiler/bundle.test.mjs +255 -0
- package/foundation/doc-compiler/compile.d.mts +362 -0
- package/foundation/doc-compiler/compile.mjs +511 -0
- package/foundation/doc-compiler/diagnostics.d.mts +126 -0
- package/foundation/doc-compiler/diagnostics.mjs +277 -0
- package/foundation/doc-compiler/doc-compiler.test.mjs +714 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +1642 -0
- package/foundation/doc-compiler/import.d.mts +24 -0
- package/foundation/doc-compiler/import.mjs +59 -0
- package/foundation/doc-compiler/inputs.d.mts +102 -0
- package/foundation/doc-compiler/inputs.mjs +286 -0
- package/foundation/doc-compiler/inputs.test.mjs +299 -0
- package/foundation/doc-compiler/ir.d.mts +22 -0
- package/foundation/doc-compiler/ir.mjs +464 -0
- package/foundation/doc-compiler/lenses.d.mts +33 -0
- package/foundation/doc-compiler/lenses.mjs +127 -0
- package/foundation/doc-compiler/lower-doc.test.mjs +492 -0
- package/foundation/doc-compiler/overlays.d.mts +37 -0
- package/foundation/doc-compiler/overlays.mjs +206 -0
- package/foundation/doc-compiler/parse-readable.d.mts +9 -0
- package/foundation/doc-compiler/parse-readable.mjs +29 -0
- package/foundation/doc-compiler/read.d.mts +126 -0
- package/foundation/doc-compiler/read.mjs +320 -0
- package/foundation/doc-compiler/read.test.mjs +313 -0
- package/foundation/doc-compiler/source.d.mts +33 -0
- package/foundation/doc-compiler/source.mjs +128 -0
- package/foundation/fs/module-loader.d.mts +1 -0
- package/foundation/fs/module-loader.mjs +50 -1
- package/foundation/fs/module-loader.stdout.test.mjs +332 -0
- package/foundation/fs/path-safety.d.mts +3 -2
- package/foundation/fs/path-safety.mjs +49 -19
- package/foundation/fs/path-safety.test.mjs +50 -0
- package/foundation/fs/publish-file-hardlink-unavailable.test.mjs +129 -94
- package/foundation/identity/provider-identity.d.mts +90 -0
- package/foundation/identity/provider-identity.mjs +320 -0
- package/foundation/identity/provider-identity.test.mjs +254 -0
- package/foundation/identity/providers.d.mts +7 -0
- package/foundation/identity/providers.mjs +16 -0
- package/foundation/integrations/autolink.d.mts +58 -1
- package/foundation/integrations/autolink.mjs +143 -45
- package/foundation/integrations/contribution-fixes.d.mts +145 -0
- package/foundation/integrations/contribution-fixes.mjs +1284 -0
- package/foundation/integrations/contribution-inventory.d.mts +1 -1
- package/foundation/integrations/contribution-inventory.mjs +17 -20
- package/foundation/integrations/contribution-inventory.test.mjs +67 -27
- package/foundation/integrations/integration-warnings.mjs +6 -0
- package/foundation/integrations/integrations.d.mts +49 -2
- package/foundation/integrations/integrations.mjs +81 -8
- package/foundation/integrations/integrations.test.mjs +384 -1
- package/foundation/integrations/provider-conflicts.test.mjs +125 -0
- package/foundation/integrations/provider-ledger.test.mjs +275 -0
- package/foundation/integrations/provider-resolution.d.mts +152 -0
- package/foundation/integrations/provider-resolution.mjs +576 -0
- package/foundation/integrations/provider-resolution.test.mjs +369 -0
- package/foundation/integrations/theme-descriptor.d.mts +8 -0
- package/foundation/integrations/theme-descriptor.mjs +44 -0
- package/foundation/integrations/validate-contributions.d.mts +2 -0
- package/foundation/integrations/validate-contributions.mjs +114 -10
- package/foundation/response/base.d.ts +8 -4
- package/foundation/response/error-codes.doc.mjs +3 -4
- package/foundation/response/error-codes.mjs +2 -2
- package/foundation/response/error-codes.test.mjs +83 -0
- package/foundation/response/json-contract.test.mjs +57 -17
- package/foundation/response/json.d.mts +4 -2
- package/foundation/response/json.mjs +8 -10
- package/foundation/response/response-types.doc.mjs +16 -11
- package/foundation/response/response-types.doc.test.mjs +158 -0
- package/foundation/response/response.doc.mjs +1 -1
- package/foundation/text/string-utils.mjs +22 -10
- package/foundation/xle/expand.d.mts +2 -0
- package/foundation/xle/expand.mjs +3 -2
- package/foundation/xle/expand.test.mjs +54 -0
- package/package.json +9 -11
- package/assets/templates/themes/manifest.json +0 -95
- package/clients/cli/lib/update-check.mjs +0 -83
- package/clients/cli/lib/update-check.test.mjs +0 -137
- package/clients/cli/update-hint-commands.test.mjs +0 -54
|
@@ -23,14 +23,16 @@
|
|
|
23
23
|
|
|
24
24
|
import * as fs from 'node:fs';
|
|
25
25
|
import * as path from 'node:path';
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {parseTemplate} from '../../authoring/doctypes/template/parse.mjs';
|
|
26
|
+
import {createRequire} from 'node:module';
|
|
27
|
+
import {readDocView} from '../doc-compiler/read.mjs';
|
|
29
28
|
import {CLI_ROOT, discoverExternalPackages} from '../fs/paths.mjs';
|
|
29
|
+
import {CORE_PROVIDER_ID} from '../identity/providers.mjs';
|
|
30
30
|
import {Project} from '../config/project.mjs';
|
|
31
31
|
|
|
32
|
+
const require = createRequire(import.meta.url);
|
|
33
|
+
|
|
32
34
|
/** Identity used for core (built-in) templates in package-scoped listings. */
|
|
33
|
-
const CORE_PACKAGE =
|
|
35
|
+
const CORE_PACKAGE = CORE_PROVIDER_ID;
|
|
34
36
|
|
|
35
37
|
/**
|
|
36
38
|
* Identity for a template in package-scoped views. Core (built-in) templates
|
|
@@ -80,31 +82,28 @@ export function pkgOf(t) {
|
|
|
80
82
|
*/
|
|
81
83
|
|
|
82
84
|
/**
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
* name.
|
|
85
|
+
* Released compatibility suffixes, in precedence order. Stable 0.6.0
|
|
86
|
+
* documented `.template.*`, so discovery keeps reading those files while all
|
|
87
|
+
* new authoring uses `.doc.mjs`.
|
|
87
88
|
*/
|
|
88
89
|
const TEMPLATE_SUFFIXES = ['.template.ts', '.template.mjs', '.template.js'];
|
|
89
90
|
|
|
90
91
|
/**
|
|
91
|
-
*
|
|
92
|
-
* `.doc
|
|
93
|
-
* had their own name; it is still accepted during the transition window.
|
|
92
|
+
* Descriptor suffixes for templates, in precedence order. New authoring always
|
|
93
|
+
* emits `.doc.mjs`; the TypeScript and JavaScript variants remain readable.
|
|
94
94
|
*/
|
|
95
95
|
const DOC_SUFFIXES = ['.doc.ts', '.doc.mjs', '.doc.js'];
|
|
96
96
|
|
|
97
97
|
/**
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
* like a legacy `Foo.doc.mjs`.
|
|
98
|
+
* Every template-spec suffix, in the released precedence a core page directory
|
|
99
|
+
* uses to pick one file. Integration discovery never picks: every match is a
|
|
100
|
+
* template, so two specs for one stem list twice and read as ambiguous.
|
|
102
101
|
*/
|
|
103
102
|
const ALL_TEMPLATE_SUFFIXES = [...TEMPLATE_SUFFIXES, ...DOC_SUFFIXES];
|
|
104
103
|
|
|
105
104
|
/**
|
|
106
105
|
* The template-spec suffix present on `file`, or null if none matches.
|
|
107
|
-
* Recognizes both the canonical `.
|
|
106
|
+
* Recognizes both the canonical `.doc.*` and released `.template.*` families.
|
|
108
107
|
* @param {string} file
|
|
109
108
|
* @returns {string | null}
|
|
110
109
|
*/
|
|
@@ -118,16 +117,6 @@ function matchedTemplateSuffix(file) {
|
|
|
118
117
|
*/
|
|
119
118
|
const TEMPLATE_SUFFIX_RE = /\.(template|doc)\.(ts|mjs|js)$/;
|
|
120
119
|
|
|
121
|
-
/** @type {ReturnType<typeof createJiti> | undefined} */
|
|
122
|
-
let jitiInstance;
|
|
123
|
-
/** Lazily-created jiti for loading `.ts` template specs (JSX-capable). */
|
|
124
|
-
function getJiti() {
|
|
125
|
-
if (!jitiInstance) {
|
|
126
|
-
jitiInstance = createJiti(import.meta.url, {jsx: true});
|
|
127
|
-
}
|
|
128
|
-
return jitiInstance;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
120
|
/**
|
|
132
121
|
* Load an integration template doc module and validate it against the template
|
|
133
122
|
* envelope at the load boundary. Default export only — `.ts` via jiti,
|
|
@@ -140,7 +129,13 @@ function getJiti() {
|
|
|
140
129
|
* @param {string} [label]
|
|
141
130
|
*/
|
|
142
131
|
async function loadIntegrationDoc(file, label) {
|
|
143
|
-
return
|
|
132
|
+
return readDocView(file, {
|
|
133
|
+
root: 'templates',
|
|
134
|
+
exports: ['default'],
|
|
135
|
+
label: label ?? file,
|
|
136
|
+
strict: true,
|
|
137
|
+
value: 'parsed',
|
|
138
|
+
});
|
|
144
139
|
}
|
|
145
140
|
|
|
146
141
|
const TEMPLATES_DIR = path.join(CLI_ROOT, 'assets', 'templates');
|
|
@@ -184,17 +179,53 @@ const IMAGE_EXTENSIONS = new Set([
|
|
|
184
179
|
]);
|
|
185
180
|
|
|
186
181
|
/**
|
|
187
|
-
*
|
|
182
|
+
* First path segment of every Astryx template fixture. Template demo imagery
|
|
188
183
|
* is self-hosted under the docsite's `/template-assets/*` dir (committed there,
|
|
189
|
-
* mirrored into the sandbox preview by scripts/sync-templates.js)
|
|
190
|
-
* only resolve inside the Astryx docsite/sandbox
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
* paypalobjects.com) are intentionally left untouched.
|
|
194
|
-
*
|
|
195
|
-
* @type {RegExp}
|
|
184
|
+
* mirrored into the sandbox preview by scripts/sync-templates.js), so those
|
|
185
|
+
* paths only resolve inside the Astryx docsite/sandbox and are replaced on
|
|
186
|
+
* scaffold. Only a root-relative URL whose first segment this is counts: the
|
|
187
|
+
* same text inside a third-party URL or a product path is left untouched.
|
|
196
188
|
*/
|
|
197
|
-
const
|
|
189
|
+
const FIXTURE_SEGMENT = 'template-assets';
|
|
190
|
+
|
|
191
|
+
/** Characters that end a URL token in template source, besides whitespace. */
|
|
192
|
+
const TOKEN_DELIMITERS = new Set([
|
|
193
|
+
"'",
|
|
194
|
+
'"',
|
|
195
|
+
'`',
|
|
196
|
+
'(',
|
|
197
|
+
')',
|
|
198
|
+
'<',
|
|
199
|
+
'>',
|
|
200
|
+
'{',
|
|
201
|
+
'}',
|
|
202
|
+
'[',
|
|
203
|
+
']',
|
|
204
|
+
'\\',
|
|
205
|
+
'|',
|
|
206
|
+
'^',
|
|
207
|
+
]);
|
|
208
|
+
|
|
209
|
+
/** The closing delimiter each opening delimiter must pair with. */
|
|
210
|
+
const CLOSING_DELIMITERS = new Map([
|
|
211
|
+
["'", "'"],
|
|
212
|
+
['"', '"'],
|
|
213
|
+
['`', '`'],
|
|
214
|
+
['(', ')'],
|
|
215
|
+
]);
|
|
216
|
+
const CLOSERS = new Set(CLOSING_DELIMITERS.values());
|
|
217
|
+
|
|
218
|
+
/** A URL with a scheme: absolute, so never a fixture reference. */
|
|
219
|
+
const ABSOLUTE_URL = /^[a-z][a-z\d+.-]*:/iu;
|
|
220
|
+
|
|
221
|
+
/** What may lead up to the fixture segment inside a relative product path. */
|
|
222
|
+
const RELATIVE_PATH_PREFIX = /^[\w.~%@/-]+$/u;
|
|
223
|
+
|
|
224
|
+
/** Punctuation that ends a sentence or list item after a path in text. */
|
|
225
|
+
const PROSE_PUNCTUATION = new Set(['.', ',', ';', ':', '!', '?']);
|
|
226
|
+
|
|
227
|
+
/** `from`, `import` or `require` right before a quoted module specifier. */
|
|
228
|
+
const MODULE_SPECIFIER_LEAD = /(?:^|[^\w$])(?:from|import|require)\s*\(?$/u;
|
|
198
229
|
|
|
199
230
|
/**
|
|
200
231
|
* Normalize path into Unix path (using forward slashes) for consistent comparison
|
|
@@ -208,36 +239,255 @@ function toPosixPath(p) {
|
|
|
208
239
|
}
|
|
209
240
|
|
|
210
241
|
/**
|
|
211
|
-
* Replace
|
|
212
|
-
* render with zero setup. Images get a self-contained data
|
|
213
|
-
* (which have no equivalent inline placeholder — see
|
|
214
|
-
* stripped to an empty src instead of being
|
|
215
|
-
* Builders drop in their own media either way.
|
|
242
|
+
* Replace each Astryx template fixture reference with a placeholder so
|
|
243
|
+
* scaffolded pages render with zero setup. Images get a self-contained data
|
|
244
|
+
* URI; videos (which have no equivalent inline placeholder — see
|
|
245
|
+
* VIDEO_EXTENSIONS) are stripped to an empty src instead of being
|
|
246
|
+
* mis-replaced with image data. Builders drop in their own media either way.
|
|
247
|
+
*
|
|
248
|
+
* A reference is a URL token that resolves to a root-relative path under
|
|
249
|
+
* FIXTURE_SEGMENT. It is replaced whole, query and fragment included, and
|
|
250
|
+
* classified by the suffix of its last path segment. A reference that cannot
|
|
251
|
+
* be replaced safely throws with its path rather than being guessed at or
|
|
252
|
+
* left behind. Prose is left as written: in text (JSX text, a word inside a
|
|
253
|
+
* longer string) trailing punctuation is not part of a path and a path with
|
|
254
|
+
* no suffix, such as the bare directory, is a mention; inside a comment
|
|
255
|
+
* nothing throws.
|
|
216
256
|
*
|
|
217
257
|
* @param {string} source - Template source code.
|
|
218
258
|
* @returns {string} Source with demo asset references replaced.
|
|
219
259
|
*/
|
|
220
260
|
export function stripTemplateAssetRefs(source) {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
261
|
+
const needle = `/${FIXTURE_SEGMENT}`;
|
|
262
|
+
let output = '';
|
|
263
|
+
let copied = 0;
|
|
264
|
+
/** @type {Array<[number, number]> | undefined} */
|
|
265
|
+
let comments;
|
|
266
|
+
let at = source.indexOf(needle);
|
|
267
|
+
while (at !== -1) {
|
|
268
|
+
let start = at;
|
|
269
|
+
while (start > 0 && !isTokenDelimiter(source[start - 1])) start--;
|
|
270
|
+
let end = at + needle.length;
|
|
271
|
+
while (end < source.length && !isTokenDelimiter(source[end])) end++;
|
|
272
|
+
/** @type {{text: string, end: number} | null} */
|
|
273
|
+
let edit;
|
|
274
|
+
try {
|
|
275
|
+
edit = fixtureEdit(source, start, at, end);
|
|
276
|
+
} catch (err) {
|
|
277
|
+
comments ??= commentRanges(source);
|
|
278
|
+
if (!comments.some(([from, to]) => from <= at && at < to)) throw err;
|
|
279
|
+
edit = null;
|
|
225
280
|
}
|
|
226
|
-
if (
|
|
227
|
-
|
|
281
|
+
if (edit) {
|
|
282
|
+
output += source.slice(copied, start) + edit.text;
|
|
283
|
+
copied = edit.end;
|
|
228
284
|
}
|
|
229
|
-
|
|
230
|
-
}
|
|
285
|
+
at = source.indexOf(needle, end);
|
|
286
|
+
}
|
|
287
|
+
return output + source.slice(copied);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/** @param {string | undefined} char */
|
|
291
|
+
function isTokenDelimiter(char) {
|
|
292
|
+
return char === undefined || /\s/u.test(char) || TOKEN_DELIMITERS.has(char);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Whitespace, the source edge, or a tag bracket: what bounds a word of text.
|
|
297
|
+
* @param {string | undefined} char
|
|
298
|
+
*/
|
|
299
|
+
function isTextDelimiter(char) {
|
|
300
|
+
return char === undefined || /\s/u.test(char) || char === '<' || char === '>';
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* The path segments of a root-relative URL under FIXTURE_SEGMENT, or null.
|
|
305
|
+
* @param {string} reference
|
|
306
|
+
* @returns {string[] | null}
|
|
307
|
+
*/
|
|
308
|
+
function fixtureSegments(reference) {
|
|
309
|
+
if (!reference.startsWith('/') || reference.startsWith('//')) return null;
|
|
310
|
+
const segments = new URL(reference, 'http://template.invalid').pathname.split(
|
|
311
|
+
'/',
|
|
312
|
+
);
|
|
313
|
+
return segments[1] === FIXTURE_SEGMENT ? segments : null;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* The replacement for the fixture reference in the URL token [start, end),
|
|
318
|
+
* which contains FIXTURE_SEGMENT's path at `at`; null when the token is not a
|
|
319
|
+
* fixture reference or is a prose mention.
|
|
320
|
+
* @param {string} source
|
|
321
|
+
* @param {number} start
|
|
322
|
+
* @param {number} at
|
|
323
|
+
* @param {number} end
|
|
324
|
+
* @returns {{text: string, end: number} | null}
|
|
325
|
+
*/
|
|
326
|
+
function fixtureEdit(source, start, at, end) {
|
|
327
|
+
const token = source.slice(start, end);
|
|
328
|
+
if (ABSOLUTE_URL.test(token)) return null;
|
|
329
|
+
if (!token.startsWith('/')) {
|
|
330
|
+
if (!fixtureSegments(source.slice(at, end))) return null;
|
|
331
|
+
if (
|
|
332
|
+
source[start - 1] !== '\\' &&
|
|
333
|
+
RELATIVE_PATH_PREFIX.test(source.slice(start, at))
|
|
334
|
+
) {
|
|
335
|
+
return null;
|
|
336
|
+
}
|
|
337
|
+
throw unsafeFixtureReference(
|
|
338
|
+
source,
|
|
339
|
+
at,
|
|
340
|
+
'it is joined to text the copy cannot parse',
|
|
341
|
+
);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
const before = source[start - 1];
|
|
345
|
+
const after = source[end];
|
|
346
|
+
if (after === '{' && token.endsWith('$')) {
|
|
347
|
+
if (!fixtureSegments(token.slice(0, -1))) return null;
|
|
348
|
+
throw unsafeFixtureReference(
|
|
349
|
+
source,
|
|
350
|
+
at,
|
|
351
|
+
'it is built by a template-literal interpolation',
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
const quoted =
|
|
355
|
+
before !== undefined && CLOSING_DELIMITERS.get(before) === after;
|
|
356
|
+
const escapedQuoted =
|
|
357
|
+
(before === "'" || before === '"') &&
|
|
358
|
+
source[start - 2] === '\\' &&
|
|
359
|
+
after === '\\' &&
|
|
360
|
+
source[end + 1] === before;
|
|
361
|
+
const whole = quoted || escapedQuoted;
|
|
362
|
+
let referenceEnd = end;
|
|
363
|
+
if (!whole) {
|
|
364
|
+
while (
|
|
365
|
+
referenceEnd > at &&
|
|
366
|
+
PROSE_PUNCTUATION.has(source[referenceEnd - 1])
|
|
367
|
+
) {
|
|
368
|
+
referenceEnd--;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
const segments = fixtureSegments(source.slice(start, referenceEnd));
|
|
372
|
+
if (!segments) return null;
|
|
373
|
+
|
|
374
|
+
const inText =
|
|
375
|
+
(isTextDelimiter(before) || CLOSING_DELIMITERS.has(before)) &&
|
|
376
|
+
(isTextDelimiter(after) || CLOSERS.has(after)) &&
|
|
377
|
+
(isTextDelimiter(before) || isTextDelimiter(after));
|
|
378
|
+
if (!whole && !inText) {
|
|
379
|
+
throw unsafeFixtureReference(
|
|
380
|
+
source,
|
|
381
|
+
at,
|
|
382
|
+
'it is not a whole quoted, url(), or text value',
|
|
383
|
+
);
|
|
384
|
+
}
|
|
385
|
+
if (quoted && before !== '(') {
|
|
386
|
+
const use = expressionUse(source, start - 1, end);
|
|
387
|
+
if (use) throw unsafeFixtureReference(source, at, use);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
const ext = path.posix
|
|
391
|
+
.extname(segments[segments.length - 1])
|
|
392
|
+
.slice(1)
|
|
393
|
+
.toLowerCase();
|
|
394
|
+
if (VIDEO_EXTENSIONS.has(ext)) return {text: '', end: referenceEnd};
|
|
395
|
+
if (IMAGE_EXTENSIONS.has(ext)) {
|
|
396
|
+
return {text: PLACEHOLDER_IMAGE, end: referenceEnd};
|
|
397
|
+
}
|
|
398
|
+
if (whole || ext) {
|
|
399
|
+
throw new Error(
|
|
400
|
+
`Unrecognized template asset format ${ext || '(none)'} for ${displayReference(source, at)}`,
|
|
401
|
+
);
|
|
402
|
+
}
|
|
403
|
+
return null;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Why the string quoted at `open` and `close` cannot be replaced on its own,
|
|
408
|
+
* or null when it is a plain value.
|
|
409
|
+
* @param {string} source
|
|
410
|
+
* @param {number} open
|
|
411
|
+
* @param {number} close
|
|
412
|
+
* @returns {string | null}
|
|
413
|
+
*/
|
|
414
|
+
function expressionUse(source, open, close) {
|
|
415
|
+
let prev = open - 1;
|
|
416
|
+
while (prev >= 0 && /\s/u.test(source[prev])) prev--;
|
|
417
|
+
let next = close + 1;
|
|
418
|
+
while (next < source.length && /\s/u.test(source[next])) next++;
|
|
419
|
+
if (
|
|
420
|
+
source[prev] === '+' ||
|
|
421
|
+
(source[prev] === '=' && source[prev - 1] === '+') ||
|
|
422
|
+
source[next] === '+'
|
|
423
|
+
) {
|
|
424
|
+
return 'the string is concatenated with another value';
|
|
425
|
+
}
|
|
426
|
+
if (source[next] === '.' && /[A-Za-z_$]/u.test(source[next + 1] ?? '')) {
|
|
427
|
+
return 'a method is called on the string';
|
|
428
|
+
}
|
|
429
|
+
if (
|
|
430
|
+
MODULE_SPECIFIER_LEAD.test(source.slice(Math.max(0, prev - 16), prev + 1))
|
|
431
|
+
) {
|
|
432
|
+
return 'it is imported as a module';
|
|
433
|
+
}
|
|
434
|
+
return null;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* The [start, end) range of every comment in `source`, or none when it does
|
|
439
|
+
* not parse as TSX.
|
|
440
|
+
* @param {string} source
|
|
441
|
+
* @returns {Array<[number, number]>}
|
|
442
|
+
*/
|
|
443
|
+
function commentRanges(source) {
|
|
444
|
+
try {
|
|
445
|
+
const {parse} = require('@babel/parser');
|
|
446
|
+
const {comments} = parse(source, {
|
|
447
|
+
sourceType: 'module',
|
|
448
|
+
plugins: ['jsx', 'typescript'],
|
|
449
|
+
});
|
|
450
|
+
return (comments ?? []).map(
|
|
451
|
+
comment =>
|
|
452
|
+
/** @type {[number, number]} */ ([
|
|
453
|
+
comment.start ?? 0,
|
|
454
|
+
comment.end ?? 0,
|
|
455
|
+
]),
|
|
456
|
+
);
|
|
457
|
+
} catch {
|
|
458
|
+
return [];
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* The fixture path at `at`, up to the next whitespace, quote, or tag bracket.
|
|
464
|
+
* @param {string} source
|
|
465
|
+
* @param {number} at
|
|
466
|
+
*/
|
|
467
|
+
function displayReference(source, at) {
|
|
468
|
+
let end = at;
|
|
469
|
+
while (end < source.length && !/[\s'"`<>]/u.test(source[end])) end++;
|
|
470
|
+
return source.slice(at, end);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* @param {string} source
|
|
475
|
+
* @param {number} at
|
|
476
|
+
* @param {string} reason
|
|
477
|
+
*/
|
|
478
|
+
function unsafeFixtureReference(source, at, reason) {
|
|
479
|
+
return new Error(
|
|
480
|
+
`Template asset reference ${displayReference(source, at)} cannot be replaced safely: ${reason}. Use the complete path as one static string.`,
|
|
481
|
+
);
|
|
231
482
|
}
|
|
232
483
|
/**
|
|
233
484
|
* Load a template-spec module and return its metadata object. Supports both
|
|
234
485
|
* families of suffix:
|
|
235
|
-
* -
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
* Prefers the default export, falling back to the named `doc` export
|
|
239
|
-
*
|
|
240
|
-
* `Foo.doc.mjs` (`doc` export). `.ts` is loaded via jiti; `.mjs`/`.js` via a
|
|
486
|
+
* - Canonical `.doc.*` specs may export the stamped object (`type: 'page' |
|
|
487
|
+
* 'block'`) as the default export or use the historical named `doc` export.
|
|
488
|
+
* - Released `.template.*` compatibility specs use the same object shape.
|
|
489
|
+
* Prefers the default export, falling back to the named `doc` export. `.ts` is
|
|
490
|
+
* loaded via jiti; `.mjs`/`.js` via a
|
|
241
491
|
* native dynamic import. Returns null if the file does not exist.
|
|
242
492
|
*
|
|
243
493
|
* @param {string} docPath absolute path to the spec file
|
|
@@ -245,10 +495,7 @@ export function stripTemplateAssetRefs(source) {
|
|
|
245
495
|
*/
|
|
246
496
|
async function loadDocModule(docPath) {
|
|
247
497
|
if (!fs.existsSync(docPath)) return null;
|
|
248
|
-
|
|
249
|
-
? await getJiti().import(docPath)
|
|
250
|
-
: await import(`file://${docPath}`);
|
|
251
|
-
return docModule.default ?? docModule.doc;
|
|
498
|
+
return readDocView(docPath, {root: 'templates', loader: 'template'});
|
|
252
499
|
}
|
|
253
500
|
|
|
254
501
|
/**
|
|
@@ -293,11 +540,11 @@ function findDocFiles(dir, pattern) {
|
|
|
293
540
|
|
|
294
541
|
/**
|
|
295
542
|
* Resolve the template-spec file for a core page directory: the first existing
|
|
296
|
-
*
|
|
543
|
+
* metadata file in {@link ALL_TEMPLATE_SUFFIXES} precedence, or null.
|
|
297
544
|
* @param {string} dirPath
|
|
298
545
|
* @returns {string | null}
|
|
299
546
|
*/
|
|
300
|
-
function findPageDocFile(dirPath) {
|
|
547
|
+
export function findPageDocFile(dirPath) {
|
|
301
548
|
for (const suffix of ALL_TEMPLATE_SUFFIXES) {
|
|
302
549
|
const candidate = path.join(dirPath, `template${suffix}`);
|
|
303
550
|
if (fs.existsSync(candidate)) return candidate;
|
|
@@ -473,7 +720,7 @@ export async function discoverAllWithErrors(cwd = process.cwd()) {
|
|
|
473
720
|
/**
|
|
474
721
|
* Recursively collect integration template-spec files under `root`.
|
|
475
722
|
* Returns absolute paths to files ending in one of ALL_TEMPLATE_SUFFIXES
|
|
476
|
-
* (canonical `.
|
|
723
|
+
* (canonical `.doc.*` or released `.template.*` compatibility files).
|
|
477
724
|
*
|
|
478
725
|
* @param {string} root
|
|
479
726
|
* @returns {string[]}
|
|
@@ -503,7 +750,7 @@ function findIntegrationDocFiles(root) {
|
|
|
503
750
|
* Discover templates contributed by configured integrations.
|
|
504
751
|
*
|
|
505
752
|
* For each integration with a resolved `templates` root, every
|
|
506
|
-
* `<id>.
|
|
753
|
+
* canonical `<id>.doc.{mjs,ts,js}` (or released `<id>.template.{ts,mjs,js}`) file is a
|
|
507
754
|
* template whose id is its path relative to the templates root with the
|
|
508
755
|
* matched suffix stripped (kebab-case, may be nested). The doc's `type`
|
|
509
756
|
* (page|block) decides scaffolding — there is no `/pages` vs `/blocks`
|
|
@@ -544,9 +791,17 @@ async function discoverIntegrationTemplates(cwd = process.cwd()) {
|
|
|
544
791
|
}
|
|
545
792
|
|
|
546
793
|
for (const integration of loadedIntegrations) {
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
794
|
+
// One integration's unreadable root must not cost core or the others theirs.
|
|
795
|
+
try {
|
|
796
|
+
const result = await discoverIntegrationTemplatesForOne(integration);
|
|
797
|
+
templates.push(...result.templates);
|
|
798
|
+
errors.push(...result.errors);
|
|
799
|
+
} catch (err) {
|
|
800
|
+
errors.push({
|
|
801
|
+
package: integration?.name ?? integration?.__spec ?? 'integration',
|
|
802
|
+
message: err instanceof Error ? err.message : String(err),
|
|
803
|
+
});
|
|
804
|
+
}
|
|
550
805
|
}
|
|
551
806
|
|
|
552
807
|
return {templates, errors};
|
|
@@ -18,6 +18,7 @@ import * as os from 'node:os';
|
|
|
18
18
|
import * as path from 'node:path';
|
|
19
19
|
import {
|
|
20
20
|
extractComponents,
|
|
21
|
+
findPageDocFile,
|
|
21
22
|
stripTemplateAssetRefs,
|
|
22
23
|
} from './template-adapter.mjs';
|
|
23
24
|
|
|
@@ -164,3 +165,17 @@ describe('stripTemplateAssetRefs', () => {
|
|
|
164
165
|
);
|
|
165
166
|
});
|
|
166
167
|
});
|
|
168
|
+
|
|
169
|
+
describe('findPageDocFile', () => {
|
|
170
|
+
it('keeps the released precedence when one page has two specs', () => {
|
|
171
|
+
const page = fs.mkdtempSync(path.join(dir, 'page-'));
|
|
172
|
+
fs.writeFileSync(path.join(page, 'template.doc.mjs'), 'export {};\n');
|
|
173
|
+
fs.writeFileSync(path.join(page, 'template.doc.ts'), 'export {};\n');
|
|
174
|
+
expect(findPageDocFile(page)).toBe(path.join(page, 'template.doc.ts'));
|
|
175
|
+
|
|
176
|
+
fs.writeFileSync(path.join(page, 'template.template.mjs'), 'export {};\n');
|
|
177
|
+
expect(findPageDocFile(page)).toBe(
|
|
178
|
+
path.join(page, 'template.template.mjs'),
|
|
179
|
+
);
|
|
180
|
+
});
|
|
181
|
+
});
|
|
@@ -2,15 +2,65 @@
|
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
* @param {string}
|
|
7
|
-
* @param {string} owner
|
|
8
|
-
|
|
5
|
+
* How messages about a theme descriptor name it.
|
|
6
|
+
* @param {string} docPath
|
|
7
|
+
* @param {string} owner
|
|
8
|
+
*/
|
|
9
|
+
export function themeDescriptorLabel(docPath: string, owner: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* The static value a theme descriptor default-exports, read from its source
|
|
12
|
+
* without executing it. Throws when the file is not one static ThemeDoc
|
|
13
|
+
* object.
|
|
14
|
+
* @param {string} docPath
|
|
15
|
+
* @param {string} label
|
|
16
|
+
* @returns {Record<string, string | boolean>}
|
|
17
|
+
*/
|
|
18
|
+
export function readThemeDescriptorValue(docPath: string, label: string): Record<string, string | boolean>;
|
|
19
|
+
/**
|
|
20
|
+
* Whether an entry at any depth of a themes root is outside every theme: a dot
|
|
21
|
+
* entry, or a name npm never publishes (npm-packlist's defaults).
|
|
22
|
+
* @param {string} name
|
|
23
|
+
*/
|
|
24
|
+
export function isIgnoredThemeEntry(name: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Whether discovery reads a folder under a theme root as a theme. Dot-folders
|
|
27
|
+
* and folders with neither a descriptor nor a `<name>Theme` source are not.
|
|
28
|
+
* @param {string} folder absolute path
|
|
29
|
+
*/
|
|
30
|
+
export function isThemeFolder(folder: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* The files one theme folder ships: every regular file below it except
|
|
33
|
+
* {@link isIgnoredThemeEntry} entries. What pack-check requires and what
|
|
34
|
+
* `theme add` copies.
|
|
35
|
+
* @param {string} folder absolute path
|
|
36
|
+
* @returns {string[]} sorted POSIX paths relative to the folder
|
|
37
|
+
*/
|
|
38
|
+
export function listThemeFiles(folder: string): string[];
|
|
39
|
+
/**
|
|
40
|
+
* Discover and validate one theme root.
|
|
41
|
+
* @param {string} themeRoot absolute root containing one directory per slug
|
|
42
|
+
* @param {string} owner package that owns the root
|
|
43
|
+
* @param {{bundled?: boolean}} [options] a bundled root is the CLI's own; its
|
|
44
|
+
* sources are checked by the CLI's tests rather than on every read
|
|
9
45
|
* @returns {DiscoveredTheme[]}
|
|
10
46
|
*/
|
|
11
|
-
export function
|
|
47
|
+
export function discoverThemeDirectory(themeRoot: string, owner: string, { bundled }?: {
|
|
12
48
|
bundled?: boolean;
|
|
13
49
|
}): DiscoveredTheme[];
|
|
50
|
+
/**
|
|
51
|
+
* Folders under a themes root that look like themes (see looksLikeTheme)
|
|
52
|
+
* but that discovery does not read as themes, and that no module elsewhere
|
|
53
|
+
* under the root imports, by a relative path or through the package's own
|
|
54
|
+
* name. Discovery skips them silently, as the released catalog skipped
|
|
55
|
+
* unlisted folders; doctor warns.
|
|
56
|
+
* @param {string} themeRoot
|
|
57
|
+
* @param {{packageDir?: string, packageName?: string}} [owner]
|
|
58
|
+
* @returns {string[]} absolute folder paths, sorted
|
|
59
|
+
*/
|
|
60
|
+
export function unreadThemeFolders(themeRoot: string, { packageDir, packageName }?: {
|
|
61
|
+
packageDir?: string;
|
|
62
|
+
packageName?: string;
|
|
63
|
+
}): string[];
|
|
14
64
|
/** @returns {DiscoveredTheme[]} */
|
|
15
65
|
export function discoverBundledThemes(): DiscoveredTheme[];
|
|
16
66
|
/**
|
|
@@ -20,8 +70,10 @@ export function discoverBundledThemes(): DiscoveredTheme[];
|
|
|
20
70
|
export function discoverIntegrationThemes(integration: import("../integrations/integrations.mjs").LoadedIntegration): Promise<DiscoveredTheme[]>;
|
|
21
71
|
export const BUNDLED_THEME_PACKAGE: "@astryxdesign/cli";
|
|
22
72
|
export const THEMES_DIR: string;
|
|
23
|
-
export const
|
|
24
|
-
export const
|
|
73
|
+
export const THEME_DOC_SUFFIX: ".doc.mjs";
|
|
74
|
+
export const THEME_MODULE_EXTENSIONS: string[];
|
|
75
|
+
/** A theme directory's name: lower-kebab, starting with a letter. */
|
|
76
|
+
export const THEME_SLUG_RE: RegExp;
|
|
25
77
|
export type DiscoveredTheme = {
|
|
26
78
|
slug: string;
|
|
27
79
|
displayName: string;
|
|
@@ -29,6 +81,10 @@ export type DiscoveredTheme = {
|
|
|
29
81
|
maintained: boolean;
|
|
30
82
|
entry: string;
|
|
31
83
|
exportName: string;
|
|
84
|
+
/**
|
|
85
|
+
* what `theme add` copies, relative to sourceDir,
|
|
86
|
+
* entry first
|
|
87
|
+
*/
|
|
32
88
|
files: string[];
|
|
33
89
|
package: string;
|
|
34
90
|
/**
|
|
@@ -36,4 +92,8 @@ export type DiscoveredTheme = {
|
|
|
36
92
|
*/
|
|
37
93
|
sourceDir: string;
|
|
38
94
|
bundled: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* absolute descriptor path
|
|
97
|
+
*/
|
|
98
|
+
docPath: string;
|
|
39
99
|
};
|