@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
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Stable section keys, section lookup, and the topic index.
|
|
5
|
+
*
|
|
6
|
+
* @input Reference-doc sections, each with an optional authored `id`.
|
|
7
|
+
* @output The key a section is addressed by (its `id`, else a kebab-case key
|
|
8
|
+
* derived from its authored title), lookup by key or title, and the compact
|
|
9
|
+
* index a topic-only docs read returns.
|
|
10
|
+
* @position Shared by docs discovery (which rejects colliding keys before a
|
|
11
|
+
* reader sees them), the docs leaves (index, section, detail), and Doctor
|
|
12
|
+
* (output budgets). Imports nothing from discovery, so both can use it.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** A stable key: lowercase letters and digits, joined by single hyphens. */
|
|
16
|
+
export const SECTION_KEY_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
17
|
+
|
|
18
|
+
/** The longest summary an index entry carries, in characters. */
|
|
19
|
+
export const SECTION_SUMMARY_MAX = 240;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* A section's authored title. A `--zh`/`--dense` overlay replaces the visible
|
|
23
|
+
* title, but extensions are written against the authored one and keys derive
|
|
24
|
+
* from it, so both stay the same in every language.
|
|
25
|
+
*/
|
|
26
|
+
const SOURCE_TITLE = Symbol('astryx.docs.sourceTitle');
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Record the authored title of a section whose visible title a translation
|
|
30
|
+
* overlay replaces.
|
|
31
|
+
* @template {object} T
|
|
32
|
+
* @param {T} section
|
|
33
|
+
* @param {string} title
|
|
34
|
+
* @returns {T}
|
|
35
|
+
*/
|
|
36
|
+
export function withSourceTitle(section, title) {
|
|
37
|
+
Object.defineProperty(section, SOURCE_TITLE, {value: title, configurable: true});
|
|
38
|
+
return section;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @param {any} section
|
|
43
|
+
* @returns {string}
|
|
44
|
+
*/
|
|
45
|
+
export function sourceTitle(section) {
|
|
46
|
+
return section?.[SOURCE_TITLE] ?? section?.title;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The key a title derives: accents folded, `&` spelled out, and every other
|
|
51
|
+
* run of non-alphanumerics collapsed to one hyphen. Empty when the title has
|
|
52
|
+
* no Latin letters or digits to derive from.
|
|
53
|
+
* @param {unknown} title
|
|
54
|
+
* @returns {string}
|
|
55
|
+
*/
|
|
56
|
+
export function sectionTitleKey(title) {
|
|
57
|
+
if (typeof title !== 'string') return '';
|
|
58
|
+
return title
|
|
59
|
+
.normalize('NFKD')
|
|
60
|
+
.replace(/[\u0300-\u036f]/g, '')
|
|
61
|
+
.toLowerCase()
|
|
62
|
+
.replace(/&/g, ' and ')
|
|
63
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
64
|
+
.replace(/^-+|-+$/g, '');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The key a section is addressed by: its authored `id`, else the key its
|
|
69
|
+
* authored title derives.
|
|
70
|
+
* @param {any} section
|
|
71
|
+
* @returns {string}
|
|
72
|
+
*/
|
|
73
|
+
export function sectionKey(section) {
|
|
74
|
+
return typeof section?.id === 'string'
|
|
75
|
+
? section.id
|
|
76
|
+
: sectionTitleKey(sourceTitle(section));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Problems with the keys of a topic's sections: an authored id that is not a
|
|
81
|
+
* stable key, a title no key derives from, and two sections sharing a key.
|
|
82
|
+
* Keys are never suffixed to make them unique, because readers link to them.
|
|
83
|
+
* @param {any[]} sections
|
|
84
|
+
* @returns {string[]}
|
|
85
|
+
*/
|
|
86
|
+
export function sectionKeyProblems(sections) {
|
|
87
|
+
/** @type {string[]} */
|
|
88
|
+
const problems = [];
|
|
89
|
+
/** @type {Map<string, number>} */
|
|
90
|
+
const seen = new Map();
|
|
91
|
+
sections.forEach((section, s) => {
|
|
92
|
+
const at = `sections[${s}]`;
|
|
93
|
+
// A missing title is reported where titles are checked; no key to judge.
|
|
94
|
+
if (
|
|
95
|
+
section?.id == null &&
|
|
96
|
+
(typeof section?.title !== 'string' || section.title === '')
|
|
97
|
+
) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (
|
|
101
|
+
section?.id != null &&
|
|
102
|
+
(typeof section.id !== 'string' || !SECTION_KEY_RE.test(section.id))
|
|
103
|
+
) {
|
|
104
|
+
problems.push(
|
|
105
|
+
`${at}.id: ${JSON.stringify(section.id)} is not a stable key. Use lowercase letters and digits joined by single hyphens.`,
|
|
106
|
+
);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const key = sectionKey(section);
|
|
110
|
+
if (key === '') {
|
|
111
|
+
problems.push(
|
|
112
|
+
`${at}: no key derives from the title ${JSON.stringify(section?.title)}. Give the section an id.`,
|
|
113
|
+
);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
const first = seen.get(key);
|
|
117
|
+
if (first != null) {
|
|
118
|
+
problems.push(
|
|
119
|
+
`${at}: the key "${key}" is already used by sections[${first}]. Give one of them a distinct id or title.`,
|
|
120
|
+
);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
seen.set(key, s);
|
|
124
|
+
});
|
|
125
|
+
return problems;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Stamp every section with the key it is addressed by. Runs only after
|
|
130
|
+
* extensions merge: a derived key must never take part in merge matching.
|
|
131
|
+
* @template {{sections: any[]}} T
|
|
132
|
+
* @param {T} doc
|
|
133
|
+
* @returns {T}
|
|
134
|
+
*/
|
|
135
|
+
export function withSectionKeys(doc) {
|
|
136
|
+
return {
|
|
137
|
+
...doc,
|
|
138
|
+
sections: doc.sections.map(section =>
|
|
139
|
+
section.id != null
|
|
140
|
+
? section
|
|
141
|
+
: withSourceTitle(
|
|
142
|
+
{...section, id: sectionKey(section)},
|
|
143
|
+
sourceTitle(section),
|
|
144
|
+
),
|
|
145
|
+
),
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Find the section a reader asked for: by key, then by exact title (or the
|
|
151
|
+
* key the query derives), then by a title that contains the query. More than
|
|
152
|
+
* one match is refused rather than guessed.
|
|
153
|
+
* @param {any[]} sections
|
|
154
|
+
* @param {string} query
|
|
155
|
+
* @returns {{section: any | null, candidates: any[]}} `candidates` lists the
|
|
156
|
+
* matches when the query is ambiguous, and is empty when nothing matches
|
|
157
|
+
*/
|
|
158
|
+
export function findDocSection(sections, query) {
|
|
159
|
+
const wanted = query.trim();
|
|
160
|
+
const byKey = sections.find(section => sectionKey(section) === wanted);
|
|
161
|
+
if (byKey) return {section: byKey, candidates: []};
|
|
162
|
+
|
|
163
|
+
const lower = wanted.toLowerCase();
|
|
164
|
+
const derived = sectionTitleKey(wanted);
|
|
165
|
+
const exact = sections.filter(
|
|
166
|
+
section =>
|
|
167
|
+
section.title.toLowerCase() === lower ||
|
|
168
|
+
(derived !== '' && sectionTitleKey(sourceTitle(section)) === derived),
|
|
169
|
+
);
|
|
170
|
+
if (exact.length === 1) return {section: exact[0], candidates: []};
|
|
171
|
+
if (exact.length > 1) return {section: null, candidates: exact};
|
|
172
|
+
|
|
173
|
+
const partial = sections.filter(section =>
|
|
174
|
+
section.title.toLowerCase().includes(lower),
|
|
175
|
+
);
|
|
176
|
+
if (partial.length === 1) return {section: partial[0], candidates: []};
|
|
177
|
+
return {section: null, candidates: partial};
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* One line that says what a section holds: its first prose or list text,
|
|
182
|
+
* whitespace collapsed, cut at a word boundary.
|
|
183
|
+
* @param {any} section
|
|
184
|
+
* @param {number} [max]
|
|
185
|
+
* @returns {string}
|
|
186
|
+
*/
|
|
187
|
+
export function sectionSummary(section, max = SECTION_SUMMARY_MAX) {
|
|
188
|
+
const first = (section?.content ?? []).find(
|
|
189
|
+
(/** @type {any} */ block) =>
|
|
190
|
+
(block?.type === 'prose' && typeof block.text === 'string') ||
|
|
191
|
+
(block?.type === 'list' && Array.isArray(block.items)),
|
|
192
|
+
);
|
|
193
|
+
const raw =
|
|
194
|
+
first == null ? '' : first.type === 'prose' ? first.text : first.items[0];
|
|
195
|
+
const text = String(raw ?? '')
|
|
196
|
+
.replace(/\s+/g, ' ')
|
|
197
|
+
.trim();
|
|
198
|
+
if (text.length <= max) return text;
|
|
199
|
+
const cut = text.slice(0, max - 1);
|
|
200
|
+
const space = cut.lastIndexOf(' ');
|
|
201
|
+
return `${(space > max / 2 ? cut.slice(0, space) : cut).trimEnd()}…`;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* The index a topic-only read returns: what the topic is, and one entry per
|
|
206
|
+
* section with the key to read it by.
|
|
207
|
+
* @param {{name: string, title: string, description: string, sections: any[]}} doc
|
|
208
|
+
* @returns {import('../../api/docs/docs.type.mjs').DocsIndex}
|
|
209
|
+
*/
|
|
210
|
+
export function buildDocsIndexData(doc) {
|
|
211
|
+
return {
|
|
212
|
+
name: doc.name,
|
|
213
|
+
title: doc.title,
|
|
214
|
+
description: doc.description,
|
|
215
|
+
sections: doc.sections.map(section => ({
|
|
216
|
+
id: sectionKey(section),
|
|
217
|
+
title: section.title,
|
|
218
|
+
summary: sectionSummary(section),
|
|
219
|
+
})),
|
|
220
|
+
};
|
|
221
|
+
}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
import {describe, expect, it} from 'vitest';
|
|
4
|
+
import {
|
|
5
|
+
SECTION_KEY_RE,
|
|
6
|
+
SECTION_SUMMARY_MAX,
|
|
7
|
+
buildDocsIndexData,
|
|
8
|
+
findDocSection,
|
|
9
|
+
sectionKey,
|
|
10
|
+
sectionKeyProblems,
|
|
11
|
+
sectionSummary,
|
|
12
|
+
sectionTitleKey,
|
|
13
|
+
sourceTitle,
|
|
14
|
+
withSectionKeys,
|
|
15
|
+
withSourceTitle,
|
|
16
|
+
} from './docs-section-key.mjs';
|
|
17
|
+
|
|
18
|
+
/** @param {string} title @param {object} [fields] */
|
|
19
|
+
const section = (title, fields = {}) => ({title, content: [], ...fields});
|
|
20
|
+
|
|
21
|
+
describe('sectionTitleKey', () => {
|
|
22
|
+
it.each([
|
|
23
|
+
['Quick Start', 'quick-start'],
|
|
24
|
+
['Light/Dark Mode', 'light-dark-mode'],
|
|
25
|
+
["Do & Don't", 'do-and-don-t'],
|
|
26
|
+
[' Café Crème ', 'cafe-creme'],
|
|
27
|
+
['useTheme()', 'usetheme'],
|
|
28
|
+
['--- Tokens ---', 'tokens'],
|
|
29
|
+
['亮/暗模式', ''],
|
|
30
|
+
['', ''],
|
|
31
|
+
])('%j derives %j', (title, key) => {
|
|
32
|
+
expect(sectionTitleKey(title)).toBe(key);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('derives only stable keys', () => {
|
|
36
|
+
for (const title of ['A B', 'x__y', 'Élan 2.0', 'a-b-', '-a']) {
|
|
37
|
+
expect(sectionTitleKey(title)).toMatch(SECTION_KEY_RE);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('derives nothing from a non-string', () => {
|
|
42
|
+
expect(sectionTitleKey(undefined)).toBe('');
|
|
43
|
+
expect(sectionTitleKey(42)).toBe('');
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe('sectionKey', () => {
|
|
48
|
+
it('prefers the authored id', () => {
|
|
49
|
+
expect(sectionKey(section('Quick Start', {id: 'start'}))).toBe('start');
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('derives from the authored title, not a translated one', () => {
|
|
53
|
+
const translated = withSourceTitle(section('快速开始'), 'Quick Start');
|
|
54
|
+
expect(sectionKey(translated)).toBe('quick-start');
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
describe('sectionKeyProblems', () => {
|
|
59
|
+
it('accepts distinct keys', () => {
|
|
60
|
+
expect(
|
|
61
|
+
sectionKeyProblems([section('Install'), section('Usage', {id: 'use'})]),
|
|
62
|
+
).toEqual([]);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('rejects two sections that share a key', () => {
|
|
66
|
+
const problems = sectionKeyProblems([
|
|
67
|
+
section('Quick Start'),
|
|
68
|
+
section('Quick-start'),
|
|
69
|
+
]);
|
|
70
|
+
expect(problems).toHaveLength(1);
|
|
71
|
+
expect(problems[0]).toContain('"quick-start" is already used by sections[0]');
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('rejects an authored id that collides with a derived key', () => {
|
|
75
|
+
expect(
|
|
76
|
+
sectionKeyProblems([section('Install'), section('Setup', {id: 'install'})]),
|
|
77
|
+
).toHaveLength(1);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('rejects an unsafe id and never suffixes one', () => {
|
|
81
|
+
for (const id of ['Quick Start', 'a_b', 'a--b', '-a', '', 7]) {
|
|
82
|
+
expect(sectionKeyProblems([section('Install', {id})])[0]).toContain(
|
|
83
|
+
'is not a stable key',
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('rejects a title no key derives from', () => {
|
|
89
|
+
expect(sectionKeyProblems([section('亮/暗模式')])[0]).toContain(
|
|
90
|
+
'Give the section an id',
|
|
91
|
+
);
|
|
92
|
+
expect(sectionKeyProblems([section('亮/暗模式', {id: 'light-dark'})])).toEqual(
|
|
93
|
+
[],
|
|
94
|
+
);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('leaves a missing title to the title check', () => {
|
|
98
|
+
expect(sectionKeyProblems([{content: []}, section('')])).toEqual([]);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
describe('withSectionKeys', () => {
|
|
103
|
+
it('stamps derived keys and keeps authored ones', () => {
|
|
104
|
+
const doc = withSectionKeys({
|
|
105
|
+
sections: [section('Quick Start'), section('Usage', {id: 'use'})],
|
|
106
|
+
});
|
|
107
|
+
expect(doc.sections.map(s => s.id)).toEqual(['quick-start', 'use']);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('keeps the authored title of a translated section', () => {
|
|
111
|
+
const doc = withSectionKeys({
|
|
112
|
+
sections: [withSourceTitle(section('快速开始'), 'Quick Start')],
|
|
113
|
+
});
|
|
114
|
+
expect(doc.sections[0].id).toBe('quick-start');
|
|
115
|
+
expect(sourceTitle(doc.sections[0])).toBe('Quick Start');
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
describe('findDocSection', () => {
|
|
120
|
+
const sections = withSectionKeys({
|
|
121
|
+
sections: [
|
|
122
|
+
section('Quick Start'),
|
|
123
|
+
section('Theme Props'),
|
|
124
|
+
section('Theme Tokens', {id: 'tokens'}),
|
|
125
|
+
section('Overview', {id: 'overview-a'}),
|
|
126
|
+
section('Overview', {id: 'overview-b'}),
|
|
127
|
+
],
|
|
128
|
+
}).sections;
|
|
129
|
+
|
|
130
|
+
it('finds a section by key first', () => {
|
|
131
|
+
expect(findDocSection(sections, 'tokens').section.title).toBe(
|
|
132
|
+
'Theme Tokens',
|
|
133
|
+
);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it('finds a section by exact title, case-insensitively', () => {
|
|
137
|
+
expect(findDocSection(sections, 'quick start').section.id).toBe(
|
|
138
|
+
'quick-start',
|
|
139
|
+
);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('finds a section by the key its query derives', () => {
|
|
143
|
+
expect(findDocSection(sections, 'Quick-Start!').section.id).toBe(
|
|
144
|
+
'quick-start',
|
|
145
|
+
);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it('finds a section by a unique part of its title', () => {
|
|
149
|
+
expect(findDocSection(sections, 'props').section.id).toBe('theme-props');
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it('refuses an ambiguous exact title and lists the candidates', () => {
|
|
153
|
+
const {section: match, candidates} = findDocSection(sections, 'Overview');
|
|
154
|
+
expect(match).toBeNull();
|
|
155
|
+
expect(candidates.map(s => s.id)).toEqual(['overview-a', 'overview-b']);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it('refuses an ambiguous partial title', () => {
|
|
159
|
+
const {section: match, candidates} = findDocSection(sections, 'theme');
|
|
160
|
+
expect(match).toBeNull();
|
|
161
|
+
expect(candidates.map(s => s.id)).toEqual(['theme-props', 'tokens']);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it('returns nothing for no match', () => {
|
|
165
|
+
expect(findDocSection(sections, 'zzz')).toEqual({
|
|
166
|
+
section: null,
|
|
167
|
+
candidates: [],
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
describe('sectionSummary', () => {
|
|
173
|
+
it('uses the first prose or list text, whitespace collapsed', () => {
|
|
174
|
+
expect(
|
|
175
|
+
sectionSummary({
|
|
176
|
+
content: [
|
|
177
|
+
{type: 'code', lang: 'ts', code: 'x'},
|
|
178
|
+
{type: 'prose', text: 'Line one.\n\n Line two.'},
|
|
179
|
+
],
|
|
180
|
+
}),
|
|
181
|
+
).toBe('Line one. Line two.');
|
|
182
|
+
expect(
|
|
183
|
+
sectionSummary({content: [{type: 'list', items: ['First', 'Second']}]}),
|
|
184
|
+
).toBe('First');
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it('is empty when the section has no text', () => {
|
|
188
|
+
expect(sectionSummary({content: [{type: 'table', headers: [], rows: []}]})).toBe(
|
|
189
|
+
'',
|
|
190
|
+
);
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
it('cuts a long summary at a word boundary', () => {
|
|
194
|
+
const summary = sectionSummary({
|
|
195
|
+
content: [{type: 'prose', text: 'word '.repeat(200)}],
|
|
196
|
+
});
|
|
197
|
+
expect(summary.length).toBeLessThanOrEqual(SECTION_SUMMARY_MAX);
|
|
198
|
+
expect(summary.endsWith('word…')).toBe(true);
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
describe('buildDocsIndexData', () => {
|
|
203
|
+
it('lists each section by key, title, and summary', () => {
|
|
204
|
+
expect(
|
|
205
|
+
buildDocsIndexData({
|
|
206
|
+
name: 'theme',
|
|
207
|
+
title: 'Theme',
|
|
208
|
+
description: 'Theming.',
|
|
209
|
+
sections: [
|
|
210
|
+
section('Quick Start', {content: [{type: 'prose', text: 'Start.'}]}),
|
|
211
|
+
section('Usage', {id: 'use'}),
|
|
212
|
+
],
|
|
213
|
+
}),
|
|
214
|
+
).toEqual({
|
|
215
|
+
name: 'theme',
|
|
216
|
+
title: 'Theme',
|
|
217
|
+
description: 'Theming.',
|
|
218
|
+
sections: [
|
|
219
|
+
{id: 'quick-start', title: 'Quick Start', summary: 'Start.'},
|
|
220
|
+
{id: 'use', title: 'Usage', summary: ''},
|
|
221
|
+
],
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
});
|
|
@@ -11,11 +11,20 @@ export function pkgOf(t: {
|
|
|
11
11
|
package?: string;
|
|
12
12
|
}): string;
|
|
13
13
|
/**
|
|
14
|
-
* Replace
|
|
15
|
-
* render with zero setup. Images get a self-contained data
|
|
16
|
-
* (which have no equivalent inline placeholder — see
|
|
17
|
-
* stripped to an empty src instead of being
|
|
18
|
-
* Builders drop in their own media either way.
|
|
14
|
+
* Replace each Astryx template fixture reference with a placeholder so
|
|
15
|
+
* scaffolded pages render with zero setup. Images get a self-contained data
|
|
16
|
+
* URI; videos (which have no equivalent inline placeholder — see
|
|
17
|
+
* VIDEO_EXTENSIONS) are stripped to an empty src instead of being
|
|
18
|
+
* mis-replaced with image data. Builders drop in their own media either way.
|
|
19
|
+
*
|
|
20
|
+
* A reference is a URL token that resolves to a root-relative path under
|
|
21
|
+
* FIXTURE_SEGMENT. It is replaced whole, query and fragment included, and
|
|
22
|
+
* classified by the suffix of its last path segment. A reference that cannot
|
|
23
|
+
* be replaced safely throws with its path rather than being guessed at or
|
|
24
|
+
* left behind. Prose is left as written: in text (JSX text, a word inside a
|
|
25
|
+
* longer string) trailing punctuation is not part of a path and a path with
|
|
26
|
+
* no suffix, such as the bare directory, is a mention; inside a comment
|
|
27
|
+
* nothing throws.
|
|
19
28
|
*
|
|
20
29
|
* @param {string} source - Template source code.
|
|
21
30
|
* @returns {string} Source with demo asset references replaced.
|
|
@@ -28,6 +37,13 @@ export function stripTemplateAssetRefs(source: string): string;
|
|
|
28
37
|
* @returns {string[]}
|
|
29
38
|
*/
|
|
30
39
|
export function listTemplates(): string[];
|
|
40
|
+
/**
|
|
41
|
+
* Resolve the template-spec file for a core page directory: the first existing
|
|
42
|
+
* metadata file in {@link ALL_TEMPLATE_SUFFIXES} precedence, or null.
|
|
43
|
+
* @param {string} dirPath
|
|
44
|
+
* @returns {string | null}
|
|
45
|
+
*/
|
|
46
|
+
export function findPageDocFile(dirPath: string): string | null;
|
|
31
47
|
/**
|
|
32
48
|
* Discover only the templates built into @astryxdesign/core. Integration
|
|
33
49
|
* authoring checks use this narrower surface so a broken project config or a
|