@astryxdesign/cli 0.6.6 → 0.6.7-canary.796bcc2
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/CHANGELOG.md +129 -0
- package/README.md +84 -82
- package/api/build/_adapter.d.mts +20 -0
- package/api/build/_adapter.mjs +24 -0
- package/api/build/build.doc.mjs +1 -1
- package/api/build/build.test.mjs +1 -1
- package/api/build/build.type.d.mts +12 -0
- package/api/build/build.type.mjs +3 -0
- package/api/build/help/help.mjs +1 -1
- package/api/build/kit/kit.mjs +13 -1
- package/api/component/_adapter.d.mts +19 -0
- package/api/component/_adapter.mjs +33 -0
- package/api/component/component-replacement.test.mjs +615 -0
- package/api/component/component.doc.mjs +5 -2
- package/api/component/component.mjs +49 -15
- package/api/component/component.test.mjs +32 -0
- package/api/component/component.type.d.mts +33 -3
- package/api/component/component.type.mjs +10 -3
- package/api/component/detail/blocks/blocks.d.mts +2 -1
- package/api/component/detail/blocks/blocks.mjs +5 -2
- package/api/component/detail/detail.mjs +5 -1
- package/api/component/detail/props/props.d.mts +2 -1
- package/api/component/detail/props/props.mjs +3 -2
- package/api/component/detail/showcase/showcase.d.mts +3 -1
- package/api/component/detail/showcase/showcase.mjs +3 -1
- package/api/component/detail/source/source.d.mts +3 -2
- package/api/component/detail/source/source.mjs +7 -3
- package/api/component/list/list.mjs +128 -10
- package/api/docs/_adapter.d.mts +11 -0
- package/api/docs/_adapter.mjs +73 -1
- package/api/docs/compiled-topics.test.mjs +1 -1
- package/api/docs/detail/detail.mjs +19 -3
- package/api/docs/detail/section/section.d.mts +44 -0
- package/api/docs/detail/section/section.mjs +171 -14
- package/api/docs/detail/section/section.test.mjs +4 -4
- package/api/docs/docOverlays.test.mjs +38 -23
- package/api/docs/docs.depth.test.mjs +2 -0
- package/api/docs/docs.doc.mjs +3 -3
- package/api/docs/docs.mjs +13 -16
- package/api/docs/docs.test.mjs +9 -10
- package/api/docs/docs.type.d.mts +43 -3
- package/api/docs/docs.type.mjs +23 -3
- package/api/docs/index/index.mjs +11 -2
- package/api/docs/index/index.test.mjs +7 -2
- package/api/docs/integration-tree.test.mjs +26 -26
- package/api/docs/integrationDocs.test.mjs +8 -7
- package/api/docs/namespace-section.test.mjs +260 -0
- package/api/docs/node/node.mjs +3 -0
- package/api/docs/token-tables.test.mjs +93 -0
- package/api/doctor/_adapter.d.mts +50 -0
- package/api/doctor/_adapter.mjs +190 -0
- package/api/doctor/doctor.d.mts +6 -10
- package/api/doctor/doctor.doc.mjs +1 -3
- package/api/doctor/doctor.mjs +144 -150
- package/api/doctor/doctor.test.mjs +104 -0
- package/api/doctor/theme-checks.d.mts +24 -0
- package/api/doctor/theme-checks.mjs +1231 -0
- package/api/doctor/theme-checks.test.mjs +667 -0
- package/api/gap-report/gap-report.doc.mjs +2 -1
- package/api/gap-report/gap-report.mjs +15 -1
- package/api/hook/_adapter.d.mts +1 -0
- package/api/hook/_adapter.mjs +3 -0
- package/api/hook/detail/detail.mjs +2 -2
- package/api/hook/detail/params/params.mjs +2 -2
- package/api/hook/hook.type.d.mts +12 -0
- package/api/hook/hook.type.mjs +3 -0
- package/api/hook/list/list.mjs +8 -8
- package/api/index.d.mts +1 -1
- package/api/index.mjs +4 -0
- package/api/init/run/run.d.mts +3 -5
- package/api/init/run/run.mjs +11 -11
- package/api/integration/__fixtures__/released-0.6.5-ocean.d.mts +14 -0
- package/api/integration/__fixtures__/released-0.6.5-ocean.mjs +15 -0
- package/api/integration/add-helpers.d.mts +26 -5
- package/api/integration/add-helpers.mjs +50 -5
- package/api/integration/add-theme.mjs +16 -2
- package/api/integration/add-theme.test.mjs +66 -15
- package/api/integration/authoring-checks.mjs +21 -1
- package/api/integration/integrationComponentConflicts.doc.mjs +6 -3
- package/api/integration/pack-check.component-replaces.test.mjs +126 -0
- package/api/integration/pack-check.d.mts +10 -0
- package/api/integration/pack-check.lifecycle-output.test.mjs +21 -2
- package/api/integration/pack-check.mjs +485 -3
- package/api/integration/pack-check.test.mjs +578 -10
- package/api/integration/validate-integration.mjs +20 -4
- package/api/integration/validate-integration.test.mjs +73 -0
- package/api/layout/check/check.d.mts +1 -0
- package/api/layout/check/check.mjs +1 -0
- package/api/layout/expand/expand.d.mts +1 -0
- package/api/layout/expand/expand.mjs +1 -0
- package/api/layout/grammar/grammar.d.mts +1 -0
- package/api/layout/grammar/grammar.mjs +1 -0
- package/api/layout/layoutCheck.doc.mjs +1 -1
- package/api/layout/layoutExpand.doc.mjs +1 -1
- package/api/layout/layoutGrammar.doc.mjs +1 -1
- package/api/search/search.d.mts +47 -3
- package/api/search/search.doc.mjs +1 -1
- package/api/search/search.domain-priority.test.mjs +261 -0
- package/api/search/search.mjs +247 -43
- package/api/search/search.test.mjs +5 -1
- package/api/search/search.type.d.mts +3 -3
- package/api/search/search.type.mjs +2 -2
- package/api/swizzle/_adapter.d.mts +10 -0
- package/api/swizzle/_adapter.mjs +23 -0
- package/api/swizzle/copy/copy.d.mts +5 -6
- package/api/swizzle/copy/copy.mjs +29 -10
- package/api/swizzle/list/list.mjs +2 -2
- package/api/swizzle/swizzle.doc.mjs +5 -2
- package/api/swizzle/swizzle.test.mjs +55 -5
- package/api/swizzle/swizzle.type.d.mts +8 -0
- package/api/swizzle/swizzle.type.mjs +2 -0
- package/api/template/copy/copy.mjs +14 -1
- package/api/template/show/show.mjs +2 -0
- package/api/template/skeleton/skeleton.mjs +2 -1
- package/api/template/template.d.mts +1 -1
- package/api/template/template.doc.mjs +1 -1
- package/api/template/template.mjs +1 -0
- package/api/template/template.type.d.mts +15 -0
- package/api/template/template.type.mjs +6 -0
- package/api/theme/_adapter.d.mts +106 -6
- package/api/theme/_adapter.mjs +687 -18
- package/api/theme/add/add.binary.test.mjs +76 -3
- package/api/theme/add/add.d.mts +5 -9
- package/api/theme/add/add.mjs +87 -64
- package/api/theme/add/add.rollback.test.mjs +9 -9
- package/api/theme/add/add.staging.test.mjs +9 -9
- package/api/theme/add/add.test.mjs +461 -55
- package/api/theme/add/add.types.test.mjs +151 -0
- package/api/theme/build/build.d.mts +96 -2
- package/api/theme/build/build.family.test.mjs +13 -4
- package/api/theme/build/build.mjs +286 -118
- package/api/theme/build/build.test.mjs +30 -0
- package/api/theme/build/font-warning.d.mts +11 -0
- package/api/theme/build/font-warning.mjs +28 -3
- package/api/theme/eject/eject.binary.test.mjs +90 -0
- package/api/theme/eject/eject.d.mts +17 -0
- package/api/theme/eject/eject.mjs +65 -0
- package/api/theme/eject/eject.rollback.test.mjs +158 -0
- package/api/theme/eject/eject.staging.test.mjs +83 -0
- package/api/theme/eject/eject.test.mjs +160 -0
- package/api/theme/integration-themes.test.mjs +30 -6
- package/api/theme/list/list.d.mts +10 -0
- package/api/theme/list/list.mjs +75 -7
- package/api/theme/list/list.test.mjs +155 -4
- package/api/theme/remove/remove.d.mts +12 -0
- package/api/theme/remove/remove.mjs +15 -0
- package/api/theme/remove/remove.test.mjs +94 -0
- package/api/theme/template/template.mjs +3 -4
- package/api/theme/theme.d.mts +5 -2
- package/api/theme/theme.mjs +13 -8
- package/api/theme/theme.type.d.mts +106 -2
- package/api/theme/theme.type.mjs +54 -5
- package/api/theme/themeAdd.doc.d.mts +1 -3
- package/api/theme/themeAdd.doc.mjs +35 -22
- package/api/theme/themeBuild.doc.mjs +1 -1
- package/api/theme/themeEject.doc.d.mts +8 -0
- package/api/theme/themeEject.doc.mjs +89 -0
- package/api/theme/themeListAvailable.doc.mjs +4 -4
- package/api/theme/themeListCopySources.doc.d.mts +8 -0
- package/api/theme/themeListCopySources.doc.mjs +60 -0
- package/api/theme/themeRemove.doc.d.mts +6 -0
- package/api/theme/themeRemove.doc.mjs +50 -0
- package/api/theme/themeTemplate.doc.mjs +4 -3
- package/api/theme/themeUse.doc.d.mts +6 -0
- package/api/theme/themeUse.doc.mjs +47 -0
- package/api/theme/use/use.d.mts +12 -0
- package/api/theme/use/use.mjs +15 -0
- package/api/theme/use/use.test.mjs +98 -0
- package/api/upgrade/_adapter.d.mts +1 -0
- package/api/upgrade/_adapter.mjs +3 -0
- package/api/upgrade/list/list.mjs +9 -3
- package/api/upgrade/upgrade.type.d.mts +4 -0
- package/api/upgrade/upgrade.type.mjs +1 -0
- package/assets/codemods/__tests__/registry.test.mjs +1 -0
- package/assets/codemods/integration-discovery.mjs +1 -1
- package/assets/codemods/integration-discovery.test.mjs +64 -0
- package/assets/codemods/registry.mjs +1 -0
- package/assets/codemods/transforms/v0.6.7/__tests__/migrate-copied-themes-to-descriptors.test.mjs +129 -0
- package/assets/codemods/transforms/v0.6.7/index.mjs +23 -0
- package/assets/codemods/transforms/v0.6.7/migrate-copied-themes-to-descriptors.mjs +54 -0
- package/assets/docs/author-a-theme.doc.mjs +166 -0
- package/assets/docs/getting-started.doc.mjs +61 -17
- package/assets/docs/principles.doc.dense.mjs +4 -4
- package/assets/docs/principles.doc.mjs +6 -6
- package/assets/docs/principles.doc.zh.mjs +4 -4
- package/assets/docs/styling-overview.doc.mjs +211 -0
- package/assets/docs/theme.doc.dense.mjs +10 -198
- package/assets/docs/theme.doc.mjs +13 -771
- package/assets/docs/theme.doc.zh.mjs +31 -12
- package/assets/docs/tree/add-a-theme.doc.mjs +2 -2
- package/assets/docs/tree/checks.doc.mjs +6 -5
- package/assets/docs/tree/component-migration.doc.mjs +107 -0
- package/assets/docs/tree/css-and-stylex.doc.mjs +150 -0
- package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
- package/assets/docs/tree/document-the-theme.doc.mjs +4 -4
- package/assets/docs/tree/font-setup.doc.mjs +122 -0
- package/assets/docs/tree/fonts-and-assets.doc.mjs +25 -20
- package/assets/docs/tree/headers-and-footers.doc.mjs +67 -0
- package/assets/docs/tree/i18n-library-integration.doc.mjs +167 -0
- package/assets/docs/tree/i18n-quick-start.doc.mjs +101 -0
- package/assets/docs/{internationalization.doc.mjs → tree/i18n-rtl-and-testing.doc.mjs} +17 -223
- package/assets/docs/tree/internationalization.doc.mjs +29 -0
- package/assets/docs/tree/layout-spacing.doc.mjs +168 -0
- package/assets/docs/tree/layout.doc.mjs +55 -0
- package/assets/docs/{migration.doc.mjs → tree/migration-setup.doc.mjs} +24 -129
- package/assets/docs/tree/migration-verification.doc.mjs +67 -0
- package/assets/docs/tree/migration.doc.mjs +28 -0
- package/assets/docs/tree/non-css-processing.doc.mjs +112 -0
- package/assets/docs/tree/other-libraries.doc.mjs +218 -0
- package/assets/docs/tree/replace-a-core-component.doc.mjs +21 -4
- package/assets/docs/tree/replace-a-core-template.doc.mjs +1 -1
- package/assets/docs/tree/responsive.doc.mjs +98 -0
- package/assets/docs/tree/scaffold.doc.mjs +140 -0
- package/assets/docs/tree/side-panels.doc.mjs +81 -0
- package/assets/docs/tree/structure.doc.mjs +140 -0
- package/assets/docs/tree/styling-advanced.doc.mjs +159 -0
- package/assets/docs/tree/styling-basics.doc.mjs +181 -0
- package/assets/docs/tree/styling-libraries.doc.mjs +30 -0
- package/assets/docs/tree/styling.doc.mjs +29 -0
- package/assets/docs/tree/tailwind.doc.mjs +65 -0
- package/assets/docs/tree/template-doc-overview.doc.mjs +1 -1
- package/assets/docs/tree/themes.doc.mjs +2 -2
- package/assets/docs/tree/tokens-and-setup.doc.mjs +128 -0
- package/assets/docs/tree/tokens-border.doc.mjs +46 -0
- package/assets/docs/tree/tokens-color.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-color.doc.mjs +438 -0
- package/assets/docs/tree/tokens-color.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-data.doc.mjs +323 -0
- package/assets/docs/tree/tokens-duration.doc.mjs +78 -0
- package/assets/docs/tree/tokens-ease.doc.mjs +46 -0
- package/assets/docs/tree/tokens-focus.doc.mjs +57 -0
- package/assets/docs/tree/tokens-font-weight.doc.mjs +58 -0
- package/assets/docs/tree/tokens-radius.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-radius.doc.mjs +70 -0
- package/assets/docs/tree/tokens-radius.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-shadow.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-shadow.doc.mjs +74 -0
- package/assets/docs/tree/tokens-shadow.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-size.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-size.doc.mjs +54 -0
- package/assets/docs/tree/tokens-size.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-spacing.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-spacing.doc.mjs +102 -0
- package/assets/docs/tree/tokens-spacing.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-syntax.doc.mjs +98 -0
- package/assets/docs/tree/tokens-text-size.doc.mjs +90 -0
- package/assets/docs/tree/tokens-type-scale.doc.mjs +210 -0
- package/assets/docs/tree/tokens-typography.doc.mjs +54 -0
- package/assets/docs/tree/tokens-usage.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-usage.doc.mjs +36 -0
- package/assets/docs/tree/tokens-usage.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens.doc.mjs +28 -0
- package/assets/docs/tree/troubleshooting.doc.mjs +7 -3
- package/assets/docs/tree/type-scale.doc.mjs +147 -0
- package/assets/docs/tree/typography-best-practices.doc.mjs +55 -0
- package/assets/docs/tree/typography.doc.mjs +29 -0
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +22 -5
- package/assets/docs/tree/versioning.doc.mjs +6 -3
- package/assets/docs/use-a-theme.doc.mjs +212 -0
- package/assets/templates/pages/incident-console/page.tsx +1 -1
- package/assets/templates/pages/table-collapsible/page.tsx +1474 -0
- package/assets/templates/pages/table-collapsible/template.doc.mjs +12 -0
- package/assets/templates/pages/table-comparison/page.tsx +1449 -0
- package/assets/templates/pages/table-comparison/template.doc.mjs +12 -0
- package/assets/theme.template.ts +4 -3
- package/authoring/doctypes/command/command.doc.mjs +5 -0
- package/authoring/doctypes/command/type.ts +2 -0
- package/authoring/doctypes/component/component.doc.mjs +1 -1
- package/authoring/doctypes/component/type.ts +8 -4
- package/authoring/doctypes/template/template.doc.mjs +2 -2
- package/authoring/doctypes/template/type.ts +5 -3
- package/authoring/integration/integration.doc.mjs +1 -1
- package/clients/cli/commands/blog.mjs +3 -3
- package/clients/cli/commands/build-theme.adaptations.test.mjs +1 -1
- package/clients/cli/commands/build-theme.ascii-output.test.mjs +11 -1
- package/clients/cli/commands/build-theme.batch-report.test.mjs +335 -0
- package/clients/cli/commands/build-theme.font-warning.test.mjs +36 -7
- package/clients/cli/commands/build-theme.import-path.test.mjs +3 -3
- package/clients/cli/commands/build-theme.mjs +338 -45
- package/clients/cli/commands/build-theme.watch.test.mjs +33 -0
- package/clients/cli/commands/build.mjs +8 -6
- package/clients/cli/commands/build.text-fields.test.mjs +1 -1
- package/clients/cli/commands/component/index.mjs +91 -12
- package/clients/cli/commands/component-replacement.text.test.mjs +316 -0
- package/clients/cli/commands/component.doc.mjs +9 -2
- package/clients/cli/commands/docs.doc.mjs +2 -1
- package/clients/cli/commands/docs.mjs +63 -23
- package/clients/cli/commands/docs.test.mjs +17 -15
- package/clients/cli/commands/doctor-integration-components.doc.mjs +15 -4
- package/clients/cli/commands/doctor.doc.mjs +1 -1
- package/clients/cli/commands/doctor.test.mjs +59 -52
- package/clients/cli/commands/gap-report.doc.mjs +2 -2
- package/clients/cli/commands/hook/index.mjs +7 -2
- package/clients/cli/commands/import-hint-correctness.test.mjs +28 -5
- package/clients/cli/commands/init.next-steps.test.mjs +18 -23
- package/clients/cli/commands/integration-real-world.test.mjs +61 -12
- package/clients/cli/commands/layout-check.doc.mjs +2 -0
- package/clients/cli/commands/layout-expand.doc.mjs +2 -0
- package/clients/cli/commands/layout-grammar.doc.mjs +2 -0
- package/clients/cli/commands/layout.deprecation-lifecycle.test.mjs +140 -0
- package/clients/cli/commands/layout.doc.mjs +2 -0
- package/clients/cli/commands/layout.mjs +40 -4
- package/clients/cli/commands/no-prompt-wording.test.mjs +4 -4
- package/clients/cli/commands/search.test.mjs +10 -4
- package/clients/cli/commands/swizzle.doc.mjs +12 -3
- package/clients/cli/commands/swizzle.mjs +2 -1
- package/clients/cli/commands/swizzle.routing.test.mjs +2 -1
- package/clients/cli/commands/template.mjs +56 -5
- package/clients/cli/commands/text-json-parity.test.mjs +40 -0
- package/clients/cli/commands/theme-add-lifecycle.test.mjs +135 -0
- package/clients/cli/commands/theme-add.doc.mjs +19 -19
- package/clients/cli/commands/theme-build.doc.mjs +3 -1
- package/clients/cli/commands/theme-eject.doc.mjs +47 -0
- package/clients/cli/commands/theme-list.behavior.test.mjs +5 -2
- package/clients/cli/commands/theme-list.doc.mjs +2 -2
- package/clients/cli/commands/theme-palette-generate.doc.mjs +1 -2
- package/clients/cli/commands/theme-remove.doc.mjs +22 -0
- package/clients/cli/commands/theme-template.doc.mjs +4 -3
- package/clients/cli/commands/theme-use.doc.mjs +22 -0
- package/clients/cli/commands/theme.doc.mjs +21 -16
- package/clients/cli/commands/upgrade.config-ordering.test.mjs +2 -1
- package/clients/cli/commands/upgrade.mjs +1 -1
- package/clients/cli/index.mjs +5 -2
- package/clients/cli/lib/component-format.mjs +29 -2
- package/clients/cli/lib/component-format.test.mjs +1 -1
- package/clients/cli/lib/define-command.mjs +4 -0
- package/clients/cli/lib/resolve-theme.mjs +80 -78
- package/clients/cli/lib/resolve-theme.test.mjs +523 -27
- package/foundation/agent-docs/agent-docs.mjs +48 -30
- package/foundation/agent-docs/agent-docs.test.mjs +47 -34
- package/foundation/agent-docs/app-theme-workflow.test.mjs +13 -0
- package/foundation/config/project.d.mts +20 -5
- package/foundation/config/project.mjs +43 -6
- package/foundation/config/project.test.mjs +1 -1
- package/foundation/config/theme-private-vars.d.mts +12 -0
- package/foundation/config/theme-private-vars.mjs +107 -0
- package/foundation/config/theme-private-vars.test.mjs +55 -0
- package/foundation/config/theme-state.d.mts +145 -0
- package/foundation/config/theme-state.mjs +417 -0
- package/foundation/config/theme-state.test.mjs +182 -0
- package/foundation/discovery/component-discovery.d.mts +5 -2
- package/foundation/discovery/component-discovery.mjs +12 -6
- package/foundation/discovery/component-replacement.d.mts +91 -0
- package/foundation/discovery/component-replacement.mjs +417 -0
- package/foundation/discovery/component-replacement.test.mjs +480 -0
- package/foundation/discovery/docs-discovery.test.mjs +1 -1
- package/foundation/discovery/docs-output-budget.d.mts +6 -2
- package/foundation/discovery/docs-output-budget.mjs +2 -1
- package/foundation/discovery/docs-section-key.d.mts +4 -2
- package/foundation/discovery/docs-section-key.mjs +1 -1
- package/foundation/discovery/module-exports.d.mts +10 -0
- package/foundation/discovery/module-exports.mjs +146 -0
- package/foundation/discovery/package-exports.d.mts +29 -0
- package/foundation/discovery/package-exports.mjs +200 -0
- package/foundation/discovery/template-needs.d.mts +31 -0
- package/foundation/discovery/template-needs.mjs +156 -0
- package/foundation/discovery/template-needs.test.mjs +203 -0
- package/foundation/discovery/theme-discovery.d.mts +72 -5
- package/foundation/discovery/theme-discovery.mjs +134 -18
- package/foundation/discovery/theme-discovery.test.mjs +9 -3
- package/foundation/discovery/theme-imports.d.mts +15 -0
- package/foundation/discovery/theme-imports.mjs +217 -0
- package/foundation/discovery/theme-imports.test.mjs +173 -0
- package/foundation/doc-compiler/bundle.mjs +52 -1
- package/foundation/doc-compiler/doc-loads.test.mjs +15 -5
- package/foundation/doc-compiler/inputs.mjs +2 -1
- package/foundation/doc-compiler/lenses.d.mts +4 -2
- package/foundation/doc-compiler/lenses.mjs +1 -1
- package/foundation/doc-compiler/split-topic-keywords.test.mjs +73 -0
- package/foundation/doc-compiler/tree.d.mts +10 -0
- package/foundation/doc-compiler/tree.mjs +22 -0
- package/foundation/doc-compiler/tree.test.mjs +3 -2
- package/foundation/env/package-manager.d.mts +31 -8
- package/foundation/env/package-manager.mjs +120 -13
- package/foundation/env/package-manager.test.mjs +174 -1
- package/foundation/fs/module-loader.d.mts +9 -0
- package/foundation/fs/module-loader.mjs +71 -2
- package/foundation/integrations/cli-requirement.d.mts +43 -10
- package/foundation/integrations/cli-requirement.mjs +56 -13
- package/foundation/integrations/cli-requirement.test.mjs +160 -23
- package/foundation/integrations/contribution-inventory.mjs +3 -3
- package/foundation/integrations/validate-contributions.d.mts +16 -0
- package/foundation/integrations/validate-contributions.mjs +56 -8
- package/foundation/response/base.d.ts +9 -3
- package/foundation/response/json.d.mts +7 -4
- package/foundation/response/json.mjs +10 -6
- package/foundation/response/response-types.doc.mjs +41 -26
- package/foundation/response/response.doc.mjs +18 -4
- package/foundation/text/copyright-header.mjs +1 -1
- package/foundation/text/copyright-header.test.mjs +1 -1
- package/package.json +9 -9
- package/assets/docs/layout.doc.dense.mjs +0 -388
- package/assets/docs/layout.doc.mjs +0 -550
- package/assets/docs/styling-libraries.doc.mjs +0 -469
- package/assets/docs/styling.doc.mjs +0 -412
- package/assets/docs/tokens.doc.dense.mjs +0 -15
- package/assets/docs/tokens.doc.mjs +0 -1491
- package/assets/docs/tokens.doc.zh.mjs +0 -15
- package/assets/docs/typography.doc.mjs +0 -286
package/api/docs/index/index.mjs
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import {indexView} from '../../../foundation/doc-compiler/lenses.mjs';
|
|
18
|
-
import {resolveTopicDocs, topicLinks} from '../_adapter.mjs';
|
|
18
|
+
import {resolveTopicDocs, sectionPackageOf, topicLinks} from '../_adapter.mjs';
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* @param {string} topic
|
|
@@ -29,12 +29,21 @@ import {resolveTopicDocs, topicLinks} from '../_adapter.mjs';
|
|
|
29
29
|
export async function index(topic, options = {}) {
|
|
30
30
|
const {node, entry, catalog} = await resolveTopicDocs(topic, options);
|
|
31
31
|
const view = indexView(node);
|
|
32
|
+
const sectionPackage = sectionPackageOf(entry, node);
|
|
32
33
|
/** @type {import('../docs.type.mjs').DocsIndex} */
|
|
33
34
|
const data = {
|
|
34
35
|
...view,
|
|
35
36
|
// A guide the docs tree places is read by its route, not its doc name.
|
|
36
37
|
name: entry.tree ? entry.name : view.name,
|
|
38
|
+
// Each section names the package that wrote it: the topic's own, or an
|
|
39
|
+
// extension's.
|
|
40
|
+
sections: view.sections.map(s => ({
|
|
41
|
+
id: s.id,
|
|
42
|
+
title: s.title,
|
|
43
|
+
package: sectionPackage(s.id),
|
|
44
|
+
summary: s.summary,
|
|
45
|
+
})),
|
|
37
46
|
links: await topicLinks(catalog, entry),
|
|
38
47
|
};
|
|
39
|
-
return {type: 'docs.index', data};
|
|
48
|
+
return {type: 'docs.index', package: entry.package, data};
|
|
40
49
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import {describe, expect, it} from 'vitest';
|
|
4
4
|
import {docs} from '../docs.mjs';
|
|
5
5
|
import {index} from './index.mjs';
|
|
6
|
-
import {loadDocsCatalog} from '../_adapter.mjs';
|
|
6
|
+
import {loadDocsCatalog, holdsOwnName, projectTree} from '../_adapter.mjs';
|
|
7
7
|
|
|
8
8
|
const SLOW = 60_000;
|
|
9
9
|
|
|
@@ -15,7 +15,8 @@ describe('docs.index leaf', () => {
|
|
|
15
15
|
const keys = res.data.sections.map(s => s.id);
|
|
16
16
|
expect(new Set(keys).size).toBe(keys.length);
|
|
17
17
|
for (const entry of res.data.sections) {
|
|
18
|
-
expect(Object.keys(entry)).toEqual(['id', 'title', 'summary']);
|
|
18
|
+
expect(Object.keys(entry)).toEqual(['id', 'title', 'package', 'summary']);
|
|
19
|
+
expect(entry.package).toBe(res.package);
|
|
19
20
|
expect(entry.summary.length).toBeLessThanOrEqual(240);
|
|
20
21
|
}
|
|
21
22
|
}, SLOW);
|
|
@@ -38,7 +39,11 @@ describe('docs.index leaf', () => {
|
|
|
38
39
|
|
|
39
40
|
it('lists keys every section can be read by', async () => {
|
|
40
41
|
const catalog = await loadDocsCatalog();
|
|
42
|
+
const tree = await projectTree(catalog);
|
|
41
43
|
for (const entry of catalog.entries()) {
|
|
44
|
+
// A flat topic whose name is now owned by a namespace (e.g. layout)
|
|
45
|
+
// cannot be read as a topic — skip it.
|
|
46
|
+
if (!holdsOwnName(tree, catalog, entry)) continue;
|
|
42
47
|
const {data} = await index(entry.name);
|
|
43
48
|
for (const {id, title} of data.sections) {
|
|
44
49
|
const read = await docs(entry.name, id);
|
|
@@ -247,7 +247,7 @@ describe('integration docs in the docs tree', () => {
|
|
|
247
247
|
scaffold({
|
|
248
248
|
...kit(),
|
|
249
249
|
'unorganized.doc.mjs': {...NAMESPACE, name: 'unorganized', title: 'Mine', summary: 'Mine.'},
|
|
250
|
-
'
|
|
250
|
+
'use-a-theme.doc.mjs': {...NAMESPACE, name: 'use-a-theme', title: 'Acme use-a-theme', summary: 'Acme use-a-theme.'},
|
|
251
251
|
'cli.doc.mjs': flat('cli'),
|
|
252
252
|
});
|
|
253
253
|
const listed = await docs(undefined, undefined, {cwd: tmpDir});
|
|
@@ -257,24 +257,24 @@ describe('integration docs in the docs tree', () => {
|
|
|
257
257
|
expect.objectContaining({topic: 'unorganized', package: '@astryxdesign/cli'}),
|
|
258
258
|
]),
|
|
259
259
|
);
|
|
260
|
-
expect(listed.meta.namespaces.filter(n => ['
|
|
260
|
+
expect(listed.meta.namespaces.filter(n => ['use-a-theme', 'unorganized'].includes(n.topic) && n.package === '@acme/kit')).toEqual([]);
|
|
261
261
|
expect(listed.data.map(entry => entry.topic)).not.toContain('cli');
|
|
262
262
|
// Each name opens the CLI's doc, and a CLI topic keeps its home.
|
|
263
263
|
expect((await docs('cli', undefined, {cwd: tmpDir})).data).toMatchObject({route: 'cli', package: '@astryxdesign/cli'});
|
|
264
264
|
expect((await docs('unorganized', undefined, {cwd: tmpDir})).data).toMatchObject({route: 'unorganized', package: '@astryxdesign/cli'});
|
|
265
|
-
const tokens = await docs('
|
|
265
|
+
const tokens = await docs('use-a-theme', undefined, {cwd: tmpDir});
|
|
266
266
|
expect(tokens.type).toBe('docs.detail');
|
|
267
267
|
expect(tokens.data.links.up).toBe('astryx docs unorganized');
|
|
268
268
|
// The project doctor and the package doctor both name the claims.
|
|
269
269
|
const check = await checkDocsTree({docsCatalog: await loadDocsCatalog(tmpDir)});
|
|
270
270
|
expect(check.status).toBe('warn');
|
|
271
271
|
expect(check.message).toContain('takes the route "unorganized", which the CLI\'s own docs keep');
|
|
272
|
-
expect(check.message).toContain('takes the route "
|
|
272
|
+
expect(check.message).toContain('takes the route "use-a-theme"');
|
|
273
273
|
expect(check.message).toContain('both have the route "cli"');
|
|
274
274
|
const result = await integrationDocConflicts('@acme/kit', {cwd: tmpDir});
|
|
275
275
|
const graph = result.data.issues.filter(issue => issue.code === 'invalid_doc_graph').map(issue => issue.message).join('\n');
|
|
276
276
|
expect(graph).toContain('takes the route "unorganized"');
|
|
277
|
-
expect(graph).toContain('takes the route "
|
|
277
|
+
expect(graph).toContain('takes the route "use-a-theme"');
|
|
278
278
|
expect(graph).toContain('route "cli"');
|
|
279
279
|
}, SLOW);
|
|
280
280
|
|
|
@@ -298,8 +298,8 @@ describe('integration docs in the docs tree', () => {
|
|
|
298
298
|
`export const docs = ${JSON.stringify(flat('Unorganized'), null, 2)};\n`,
|
|
299
299
|
);
|
|
300
300
|
fs.writeFileSync(
|
|
301
|
-
path.join(nested, 'caps-
|
|
302
|
-
`export const docs = ${JSON.stringify(flat('
|
|
301
|
+
path.join(nested, 'caps-use-a-theme.doc.mjs'),
|
|
302
|
+
`export const docs = ${JSON.stringify(flat('USE-A-THEME'), null, 2)};\n`,
|
|
303
303
|
);
|
|
304
304
|
expect((await docs('cli', undefined, {cwd: tmpDir})).data).toMatchObject({route: 'cli', package: '@astryxdesign/cli'});
|
|
305
305
|
expect((await docs('unorganized', undefined, {cwd: tmpDir})).data).toMatchObject({route: 'unorganized', package: '@astryxdesign/cli'});
|
|
@@ -315,10 +315,10 @@ describe('integration docs in the docs tree', () => {
|
|
|
315
315
|
expect(check.status).toBe('warn');
|
|
316
316
|
expect(check.message).toContain('route "CLI"');
|
|
317
317
|
expect(check.message).toContain('takes the route "Unorganized"');
|
|
318
|
-
// `
|
|
319
|
-
const tokens = await docs('
|
|
320
|
-
expect(tokens.data).toMatchObject({name: '
|
|
321
|
-
expect(tokens.data.title).not.toBe('Acme
|
|
318
|
+
// `USE-A-THEME` is the CLI's topic `use-a-theme` in another spelling: the CLI's wins.
|
|
319
|
+
const tokens = await docs('USE-A-THEME', undefined, {cwd: tmpDir, index: true});
|
|
320
|
+
expect(tokens.data).toMatchObject({name: 'use-a-theme', links: {up: 'astryx docs unorganized'}});
|
|
321
|
+
expect(tokens.data.title).not.toBe('Acme USE-A-THEME');
|
|
322
322
|
const result = await integrationDocConflicts('@acme/kit', {cwd: tmpDir});
|
|
323
323
|
const graph = result.data.issues
|
|
324
324
|
.filter(issue => issue.code === 'invalid_doc_graph')
|
|
@@ -329,7 +329,7 @@ describe('integration docs in the docs tree', () => {
|
|
|
329
329
|
}, SLOW);
|
|
330
330
|
|
|
331
331
|
it("keeps a replaced name for the topic that replaces it, over another integration's namespace", async () => {
|
|
332
|
-
scaffold({...kit(), '
|
|
332
|
+
scaffold({...kit(), 'use-a-theme-ns.doc.mjs': {...NAMESPACE, name: 'use-a-theme', title: 'Kit use-a-theme', summary: 'Kit use-a-theme.'}});
|
|
333
333
|
const two = path.join(tmpDir, 'node_modules', '@acme', 'two');
|
|
334
334
|
fs.mkdirSync(path.join(two, 'docs'), {recursive: true});
|
|
335
335
|
fs.writeFileSync(path.join(two, 'package.json'), JSON.stringify({name: '@acme/two', version: '1.0.0'}));
|
|
@@ -341,7 +341,7 @@ describe('integration docs in the docs tree', () => {
|
|
|
341
341
|
name: 'acme-tokens',
|
|
342
342
|
title: 'Acme tokens',
|
|
343
343
|
description: 'Acme tokens.',
|
|
344
|
-
replaces: '
|
|
344
|
+
replaces: 'use-a-theme',
|
|
345
345
|
sections: [{title: 'One', content: [{type: 'prose', text: 'One.'}]}],
|
|
346
346
|
}, null, 2)};\n`,
|
|
347
347
|
);
|
|
@@ -350,8 +350,8 @@ describe('integration docs in the docs tree', () => {
|
|
|
350
350
|
"export default {integrations: ['@acme/kit', '@acme/two']};\n",
|
|
351
351
|
);
|
|
352
352
|
const listed = await docs(undefined, undefined, {cwd: tmpDir});
|
|
353
|
-
expect(listed.meta.namespaces.map(entry => entry.topic)).not.toContain('
|
|
354
|
-
const read = await docs('
|
|
353
|
+
expect(listed.meta.namespaces.map(entry => entry.topic)).not.toContain('use-a-theme');
|
|
354
|
+
const read = await docs('use-a-theme', undefined, {cwd: tmpDir, index: true});
|
|
355
355
|
expect(read.data.name).toBe('acme-tokens');
|
|
356
356
|
const check = await checkDocsTree({docsCatalog: await loadDocsCatalog(tmpDir)});
|
|
357
357
|
expect(check.status).toBe('warn');
|
|
@@ -359,7 +359,7 @@ describe('integration docs in the docs tree', () => {
|
|
|
359
359
|
}, SLOW);
|
|
360
360
|
|
|
361
361
|
it('keeps every name a topic replaced twice answers to, and the CLI\'s links to it still open', async () => {
|
|
362
|
-
scaffold({...kit(), '
|
|
362
|
+
scaffold({...kit(), 'use-a-theme-ns.doc.mjs': {...NAMESPACE, name: 'use-a-theme', title: 'Kit use-a-theme', summary: 'Kit use-a-theme.'}});
|
|
363
363
|
/** @param {string} pkg @param {string} name @param {string} replaces */
|
|
364
364
|
const replacement = (pkg, name, replaces) => {
|
|
365
365
|
const dir = path.join(tmpDir, 'node_modules', '@acme', pkg);
|
|
@@ -378,30 +378,30 @@ describe('integration docs in the docs tree', () => {
|
|
|
378
378
|
}, null, 2)};\n`,
|
|
379
379
|
);
|
|
380
380
|
};
|
|
381
|
-
replacement('two', 'acme-tokens', '
|
|
382
|
-
replacement('three', 'b-tokens', '
|
|
381
|
+
replacement('two', 'acme-tokens', 'use-a-theme');
|
|
382
|
+
replacement('three', 'b-tokens', 'use-a-theme');
|
|
383
383
|
replacement('four', 'super-tokens', 'b-tokens');
|
|
384
384
|
fs.writeFileSync(
|
|
385
385
|
path.join(tmpDir, 'astryx.config.mjs'),
|
|
386
386
|
"export default {integrations: ['@acme/kit', '@acme/two', '@acme/three', '@acme/four']};\n",
|
|
387
387
|
);
|
|
388
388
|
const listed = await docs(undefined, undefined, {cwd: tmpDir});
|
|
389
|
-
expect(listed.meta.namespaces.map(entry => entry.topic)).not.toContain('
|
|
390
|
-
for (const name of ['
|
|
389
|
+
expect(listed.meta.namespaces.map(entry => entry.topic)).not.toContain('use-a-theme');
|
|
390
|
+
for (const name of ['use-a-theme', 'acme-tokens', 'b-tokens', 'super-tokens']) {
|
|
391
391
|
expect((await docs(name, undefined, {cwd: tmpDir, index: true})).data.name).toBe('super-tokens');
|
|
392
392
|
}
|
|
393
|
-
// A walk over every topic: the CLI's own links to `
|
|
393
|
+
// A walk over every topic: the CLI's own links to `use-a-theme` still open it.
|
|
394
394
|
/** @type {string[]} */
|
|
395
395
|
const raw = [];
|
|
396
396
|
for (const entry of listed.data) {
|
|
397
397
|
const read = await docs(entry.topic, undefined, {cwd: tmpDir});
|
|
398
|
-
if (/\{@link [^}]*
|
|
398
|
+
if (/\{@link [^}]*use-a-theme\}/.test(JSON.stringify(read.data))) raw.push(entry.topic);
|
|
399
399
|
}
|
|
400
400
|
expect(raw).toEqual([]);
|
|
401
|
-
const
|
|
402
|
-
expect(JSON.stringify(
|
|
401
|
+
const theme = await docs('theme', undefined, {cwd: tmpDir});
|
|
402
|
+
expect(JSON.stringify(theme.data)).toContain('astryx docs super-tokens');
|
|
403
403
|
const check = await checkDocsTree({docsCatalog: await loadDocsCatalog(tmpDir)});
|
|
404
|
-
expect(check.message).toContain('takes the route "
|
|
404
|
+
expect(check.message).toContain('takes the route "use-a-theme", which the topic "super-tokens" also answers to');
|
|
405
405
|
expect(check.message).not.toContain('names no doc');
|
|
406
406
|
}, SLOW);
|
|
407
407
|
|
|
@@ -510,7 +510,7 @@ describe('integration docs in the docs tree', () => {
|
|
|
510
510
|
content: [
|
|
511
511
|
{
|
|
512
512
|
type: 'prose',
|
|
513
|
-
text: 'See {@link generic:integrations}, and {@link @astryxdesign/cli:
|
|
513
|
+
text: 'See {@link generic:integrations}, and {@link @astryxdesign/cli:namespace:tokens} for the tokens.',
|
|
514
514
|
},
|
|
515
515
|
],
|
|
516
516
|
},
|
|
@@ -100,7 +100,7 @@ describe('integration-contributed topics', () => {
|
|
|
100
100
|
package: '@acme/widgets',
|
|
101
101
|
});
|
|
102
102
|
// The built-in topics keep their own owner.
|
|
103
|
-
expect(listed.data.find(t => t.topic === '
|
|
103
|
+
expect(listed.data.find(t => t.topic === 'color').package).toBe('@astryxdesign/cli');
|
|
104
104
|
|
|
105
105
|
const detail = await docs('deploying', undefined, {cwd: tmpDir, full: true});
|
|
106
106
|
expect(detail.type).toBe('docs.detail');
|
|
@@ -243,7 +243,7 @@ describe('integration-contributed topics', () => {
|
|
|
243
243
|
const english = await docs('theme', undefined, {full: true});
|
|
244
244
|
const englishTitles = english.data.sections.map(section => section.title);
|
|
245
245
|
expect(englishTitles).toEqual(
|
|
246
|
-
expect.arrayContaining(['
|
|
246
|
+
expect.arrayContaining(['Wrap your app in a theme', 'Dark mode']),
|
|
247
247
|
);
|
|
248
248
|
scaffold({
|
|
249
249
|
'theme-internal.doc.mjs': topic({
|
|
@@ -251,12 +251,13 @@ describe('integration-contributed topics', () => {
|
|
|
251
251
|
extends: 'theme',
|
|
252
252
|
sections: [
|
|
253
253
|
{
|
|
254
|
-
id: '
|
|
255
|
-
title: '
|
|
254
|
+
id: 'quick-start',
|
|
255
|
+
title: 'Wrap your app in a theme',
|
|
256
256
|
content: [{type: 'prose', text: 'Acme themes.'}],
|
|
257
257
|
},
|
|
258
258
|
{
|
|
259
|
-
|
|
259
|
+
id: 'light-dark-mode',
|
|
260
|
+
title: 'Dark mode',
|
|
260
261
|
content: [{type: 'prose', text: 'Acme props.'}],
|
|
261
262
|
},
|
|
262
263
|
],
|
|
@@ -271,7 +272,7 @@ describe('integration-contributed topics', () => {
|
|
|
271
272
|
expect(extended.data.sections).toHaveLength(base.data.sections.length);
|
|
272
273
|
expect(
|
|
273
274
|
extended.data.sections.filter(
|
|
274
|
-
section => section.id === '
|
|
275
|
+
section => section.id === 'quick-start',
|
|
275
276
|
),
|
|
276
277
|
).toHaveLength(1);
|
|
277
278
|
expect(
|
|
@@ -330,7 +331,7 @@ describe('integration-contributed topics', () => {
|
|
|
330
331
|
it("falls back to the CLI's own topics when the project config is unreadable", async () => {
|
|
331
332
|
scaffold({'deploying.doc.mjs': topic()}, {config: 'export default {integrations: 42};\n'});
|
|
332
333
|
const catalog = await loadDocsCatalog(tmpDir);
|
|
333
|
-
expect(catalog.resolve('
|
|
334
|
+
expect(catalog.resolve('color')).toBeTruthy();
|
|
334
335
|
expect(catalog.resolve('deploying')).toBeUndefined();
|
|
335
336
|
}, SLOW);
|
|
336
337
|
});
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file A section read on a namespace (spec:AST-046 FR6): `astryx docs
|
|
5
|
+
* <namespace> <section>` answers from the one guide below the namespace that
|
|
6
|
+
* has the section, exactly as that guide's own section read does, so a section
|
|
7
|
+
* read that worked before a topic became a namespace still works.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import * as fs from 'node:fs';
|
|
11
|
+
import * as path from 'node:path';
|
|
12
|
+
import {afterEach, beforeEach, describe, expect, it} from 'vitest';
|
|
13
|
+
import {docs} from './docs.mjs';
|
|
14
|
+
import {oneGuide} from './detail/section/section.mjs';
|
|
15
|
+
|
|
16
|
+
const SLOW = 60_000;
|
|
17
|
+
|
|
18
|
+
/** @type {string} */
|
|
19
|
+
let tmpDir;
|
|
20
|
+
|
|
21
|
+
/** @param {Record<string, object>} files the integration's doc files */
|
|
22
|
+
function scaffold(files) {
|
|
23
|
+
fs.writeFileSync(
|
|
24
|
+
path.join(tmpDir, 'package.json'),
|
|
25
|
+
JSON.stringify({name: 'consumer'}),
|
|
26
|
+
);
|
|
27
|
+
fs.writeFileSync(
|
|
28
|
+
path.join(tmpDir, 'astryx.config.mjs'),
|
|
29
|
+
"export default {integrations: ['@acme/kit']};\n",
|
|
30
|
+
);
|
|
31
|
+
const pkgDir = path.join(tmpDir, 'node_modules', '@acme', 'kit');
|
|
32
|
+
fs.mkdirSync(path.join(pkgDir, 'docs'), {recursive: true});
|
|
33
|
+
fs.writeFileSync(
|
|
34
|
+
path.join(pkgDir, 'package.json'),
|
|
35
|
+
JSON.stringify({name: '@acme/kit', version: '1.0.0'}),
|
|
36
|
+
);
|
|
37
|
+
fs.writeFileSync(
|
|
38
|
+
path.join(pkgDir, 'astryx.integration.mjs'),
|
|
39
|
+
"export default {docs: './docs'};\n",
|
|
40
|
+
);
|
|
41
|
+
for (const [file, doc] of Object.entries(files)) {
|
|
42
|
+
fs.writeFileSync(
|
|
43
|
+
path.join(pkgDir, 'docs', file),
|
|
44
|
+
`export const docs = ${JSON.stringify(doc, null, 2)};\n`,
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @param {string} name
|
|
51
|
+
* @param {number} order
|
|
52
|
+
* @param {Array<{title: string, id?: string}>} sections
|
|
53
|
+
*/
|
|
54
|
+
function guide(name, order, sections) {
|
|
55
|
+
return {
|
|
56
|
+
type: 'generic',
|
|
57
|
+
name,
|
|
58
|
+
title: `Acme ${name}`,
|
|
59
|
+
description: `The ${name} guide.`,
|
|
60
|
+
placement: {parent: 'namespace:acme', slot: 'guides', order},
|
|
61
|
+
sections: sections.map(section => ({
|
|
62
|
+
...section,
|
|
63
|
+
content: [{type: 'prose', text: `${section.title} text.`}],
|
|
64
|
+
})),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** A namespace of two guides that both have a section titled "...setup". */
|
|
69
|
+
function kit() {
|
|
70
|
+
return {
|
|
71
|
+
'acme.doc.mjs': {
|
|
72
|
+
type: 'namespace',
|
|
73
|
+
name: 'acme',
|
|
74
|
+
title: 'Acme',
|
|
75
|
+
summary: 'Everything about the Acme kit.',
|
|
76
|
+
slots: {guides: {title: 'Guides', accepts: {kinds: ['generic']}}},
|
|
77
|
+
},
|
|
78
|
+
'install.doc.mjs': guide('install', 1, [
|
|
79
|
+
{title: 'Package setup', id: 'package-setup'},
|
|
80
|
+
{title: 'Verify'},
|
|
81
|
+
]),
|
|
82
|
+
'theme.doc.mjs': guide('theme', 2, [
|
|
83
|
+
{title: 'Theme setup'},
|
|
84
|
+
{title: 'Dark mode'},
|
|
85
|
+
]),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
beforeEach(() => {
|
|
90
|
+
tmpDir = fs.mkdtempSync(
|
|
91
|
+
path.join(process.cwd(), '.astryx-namespace-section-test-'),
|
|
92
|
+
);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
afterEach(() => {
|
|
96
|
+
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
describe('a section read on a namespace', () => {
|
|
100
|
+
it(
|
|
101
|
+
'returns the one guide section, by key and by title, as the guide read does',
|
|
102
|
+
async () => {
|
|
103
|
+
for (const query of ['side-panels', 'Side panels', 'side panels']) {
|
|
104
|
+
const read = await docs('layout', query);
|
|
105
|
+
expect(read).toEqual(await docs('layout/side-panels', 'side-panels'));
|
|
106
|
+
expect(read).toMatchObject({
|
|
107
|
+
type: 'docs.detail.section',
|
|
108
|
+
package: '@astryxdesign/cli',
|
|
109
|
+
data: {id: 'side-panels', title: 'Side panels'},
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
// A section in a guide of its own, and a section past a guide's first.
|
|
113
|
+
expect((await docs('layout', 'shell')).data.id).toBe('shell');
|
|
114
|
+
expect((await docs('layout', 'responsive-contract')).data.id).toBe(
|
|
115
|
+
'responsive-contract',
|
|
116
|
+
);
|
|
117
|
+
},
|
|
118
|
+
SLOW,
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
it(
|
|
122
|
+
'reads dense and Chinese the way the guide read does',
|
|
123
|
+
async () => {
|
|
124
|
+
for (const options of [{dense: true}, {zh: true}, {lang: 'dense'}]) {
|
|
125
|
+
expect(await docs('layout', 'side-panels', options)).toEqual(
|
|
126
|
+
await docs('layout/side-panels', 'side-panels', options),
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
SLOW,
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
it(
|
|
134
|
+
"prefers the guide whose section key is the query over another guide's title match",
|
|
135
|
+
async () => {
|
|
136
|
+
scaffold(kit());
|
|
137
|
+
const read = await docs('acme', 'package-setup', {cwd: tmpDir});
|
|
138
|
+
expect(read.data).toMatchObject({
|
|
139
|
+
id: 'package-setup',
|
|
140
|
+
title: 'Package setup',
|
|
141
|
+
});
|
|
142
|
+
expect(read.data.links.up).toBe('astryx docs acme/install --index');
|
|
143
|
+
expect((await docs('acme', 'dark mode', {cwd: tmpDir})).data.title).toBe(
|
|
144
|
+
'Dark mode',
|
|
145
|
+
);
|
|
146
|
+
},
|
|
147
|
+
SLOW,
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
it(
|
|
151
|
+
'fails on a miss, naming every guide below the namespace',
|
|
152
|
+
async () => {
|
|
153
|
+
const err = await docs('layout', 'zzzz-nope').catch(e => e);
|
|
154
|
+
expect(err.code).toBe('ERR_UNKNOWN_SECTION');
|
|
155
|
+
const names = err.suggestions.map(s => s.name);
|
|
156
|
+
expect(names).toContain('layout/scaffold');
|
|
157
|
+
expect(names).toContain('layout/side-panels');
|
|
158
|
+
expect(names.every(name => name.startsWith('layout/'))).toBe(true);
|
|
159
|
+
// At any depth: guides under nested namespaces are named, namespaces are not.
|
|
160
|
+
const cli = await docs('cli', 'zzzz-nope').catch(e => e);
|
|
161
|
+
expect(cli.code).toBe('ERR_UNKNOWN_SECTION');
|
|
162
|
+
expect(cli.suggestions.map(s => s.name)).toContain(
|
|
163
|
+
'cli/integrations/quick-start',
|
|
164
|
+
);
|
|
165
|
+
expect(cli.suggestions.map(s => s.name)).not.toContain(
|
|
166
|
+
'cli/integrations',
|
|
167
|
+
);
|
|
168
|
+
},
|
|
169
|
+
SLOW,
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
it(
|
|
173
|
+
'still fails a section on a typed doc, naming the doc',
|
|
174
|
+
async () => {
|
|
175
|
+
const err = await docs('cli/commands/docs', 'anything').catch(e => e);
|
|
176
|
+
expect(err.code).toBe('ERR_UNKNOWN_SECTION');
|
|
177
|
+
expect(err.suggestions.map(s => s.name)).toEqual(['cli/commands/docs']);
|
|
178
|
+
},
|
|
179
|
+
SLOW,
|
|
180
|
+
);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
describe('a namespace read answers what the guide read answers', () => {
|
|
184
|
+
/** A guide with a title match before a key match, and a second guide. */
|
|
185
|
+
function competing() {
|
|
186
|
+
return {
|
|
187
|
+
...kit(),
|
|
188
|
+
'install.doc.mjs': guide('install', 1, [
|
|
189
|
+
{title: 'Shell contract'},
|
|
190
|
+
{title: 'Shell'},
|
|
191
|
+
]),
|
|
192
|
+
'theme.doc.mjs': guide('theme', 2, [{title: 'Setup', id: 'setup'}]),
|
|
193
|
+
'extra.doc.mjs': guide('extra', 3, [{title: 'Theme setup'}]),
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
it(
|
|
198
|
+
'returns the section the guide read returns, even when a later section has the key',
|
|
199
|
+
async () => {
|
|
200
|
+
scaffold(competing());
|
|
201
|
+
const own = await docs('acme/install', 'shell', {cwd: tmpDir});
|
|
202
|
+
const read = await docs('acme', 'shell', {cwd: tmpDir});
|
|
203
|
+
expect(read).toEqual(own);
|
|
204
|
+
expect(read.data.title).toBe('Shell contract');
|
|
205
|
+
},
|
|
206
|
+
SLOW,
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
it(
|
|
210
|
+
"prefers the guide whose own match is the query's key over another guide's title match",
|
|
211
|
+
async () => {
|
|
212
|
+
scaffold(competing());
|
|
213
|
+
const read = await docs('acme', 'setup', {cwd: tmpDir});
|
|
214
|
+
expect(read).toEqual(await docs('acme/theme', 'setup', {cwd: tmpDir}));
|
|
215
|
+
expect(read.data).toMatchObject({id: 'setup', title: 'Setup'});
|
|
216
|
+
},
|
|
217
|
+
SLOW,
|
|
218
|
+
);
|
|
219
|
+
|
|
220
|
+
it(
|
|
221
|
+
'names the children of a namespace with no guide below it',
|
|
222
|
+
async () => {
|
|
223
|
+
const err = await docs('cli/api', 'anything').catch(e => e);
|
|
224
|
+
expect(err.code).toBe('ERR_UNKNOWN_SECTION');
|
|
225
|
+
const api = (await docs('cli/api')).data;
|
|
226
|
+
expect(err.suggestions.map(s => s.name)).toEqual(
|
|
227
|
+
api.slots.flatMap(slot => slot.children.map(child => child.route)),
|
|
228
|
+
);
|
|
229
|
+
expect(err.suggestions.length).toBeGreaterThan(0);
|
|
230
|
+
expect(err.message).toContain('Open one of its children');
|
|
231
|
+
},
|
|
232
|
+
SLOW,
|
|
233
|
+
);
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
describe('a section query that matches sections in several guides', () => {
|
|
237
|
+
// It used to guess; now it asks. A flat topic's section read returns its
|
|
238
|
+
// first title match; across guides, the read names each guide instead.
|
|
239
|
+
it(
|
|
240
|
+
'asks which guide, naming each guide that matches',
|
|
241
|
+
async () => {
|
|
242
|
+
scaffold(kit());
|
|
243
|
+
const err = await docs('acme', 'setup', {cwd: tmpDir}).catch(e => e);
|
|
244
|
+
expect(err.code).toBe('ERR_UNKNOWN_SECTION');
|
|
245
|
+
expect(err.suggestions).toEqual([
|
|
246
|
+
{name: 'acme/install', reason: 'has "Package setup"'},
|
|
247
|
+
{name: 'acme/theme', reason: 'has "Theme setup"'},
|
|
248
|
+
]);
|
|
249
|
+
},
|
|
250
|
+
SLOW,
|
|
251
|
+
);
|
|
252
|
+
|
|
253
|
+
it('decides in one place: oneGuide answers only a single match', () => {
|
|
254
|
+
const a = /** @type {any} */ ({guide: {route: 'acme/install'}});
|
|
255
|
+
const b = /** @type {any} */ ({guide: {route: 'acme/theme'}});
|
|
256
|
+
expect(oneGuide([a])).toBe(a);
|
|
257
|
+
expect(oneGuide([a, b])).toBeNull();
|
|
258
|
+
expect(oneGuide([])).toBeNull();
|
|
259
|
+
});
|
|
260
|
+
});
|
package/api/docs/node/node.mjs
CHANGED
|
@@ -94,6 +94,7 @@ function childIdentity(child) {
|
|
|
94
94
|
return {
|
|
95
95
|
route: child.route,
|
|
96
96
|
name: child.route.slice(child.route.lastIndexOf('/') + 1),
|
|
97
|
+
package: child.provider,
|
|
97
98
|
kind: child.kind,
|
|
98
99
|
title: child.title,
|
|
99
100
|
summary: child.summary,
|
|
@@ -310,6 +311,8 @@ export async function node(route, options = {}) {
|
|
|
310
311
|
throw await unknownTopicError(route, found.catalog);
|
|
311
312
|
return {
|
|
312
313
|
type: 'docs.node',
|
|
314
|
+
// The docs tree names each node's npm package as its provider.
|
|
315
|
+
package: found.node.provider,
|
|
313
316
|
data: await nodeView(found.catalog, found.tree, found.node),
|
|
314
317
|
};
|
|
315
318
|
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file The design tokens are written once. Each category's table lives in its
|
|
5
|
+
* guide under the tokens namespace; a token reference to `tokens` reads that
|
|
6
|
+
* guide, so no flat copy of the tables is listed, searched, or compiled.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import fs from 'node:fs';
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
import {fileURLToPath} from 'node:url';
|
|
12
|
+
import {describe, expect, it} from 'vitest';
|
|
13
|
+
import {docs} from './docs.mjs';
|
|
14
|
+
import {search} from '../search/search.mjs';
|
|
15
|
+
|
|
16
|
+
const SLOW = 60_000;
|
|
17
|
+
const DOCS_DIR = path.resolve(
|
|
18
|
+
path.dirname(fileURLToPath(import.meta.url)),
|
|
19
|
+
'../../assets/docs',
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
/** Every authored CLI doc file, flat and placed (translation overlays aside). */
|
|
23
|
+
function authoredDocFiles() {
|
|
24
|
+
return [DOCS_DIR, path.join(DOCS_DIR, 'tree')].flatMap(dir =>
|
|
25
|
+
fs
|
|
26
|
+
.readdirSync(dir)
|
|
27
|
+
.filter(file => /^[\w-]+\.doc\.mjs$/.test(file))
|
|
28
|
+
.map(file => path.join(dir, file)),
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
describe('the design tokens', () => {
|
|
33
|
+
it('are each written in exactly one doc table', async () => {
|
|
34
|
+
/** @type {Map<string, string[]>} */
|
|
35
|
+
const owners = new Map();
|
|
36
|
+
for (const file of authoredDocFiles()) {
|
|
37
|
+
const {docs: doc} = await import(file);
|
|
38
|
+
for (const section of doc.sections ?? []) {
|
|
39
|
+
for (const block of section.content ?? []) {
|
|
40
|
+
if (block?.type !== 'table') continue;
|
|
41
|
+
for (const row of block.rows) {
|
|
42
|
+
if (!/^--[a-z]/.test(row[0])) continue;
|
|
43
|
+
owners.set(row[0], [
|
|
44
|
+
...(owners.get(row[0]) ?? []),
|
|
45
|
+
path.relative(DOCS_DIR, file),
|
|
46
|
+
]);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
expect(owners.size).toBeGreaterThan(200);
|
|
52
|
+
expect([...owners].filter(([, files]) => files.length > 1)).toEqual([]);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it(
|
|
56
|
+
'are not listed or searched twice',
|
|
57
|
+
async () => {
|
|
58
|
+
const listed = await docs();
|
|
59
|
+
const names = listed.data.map(entry => entry.topic);
|
|
60
|
+
expect(names).not.toContain('token-tables');
|
|
61
|
+
expect(listed.meta.namespaces.map(entry => entry.topic)).toContain(
|
|
62
|
+
'tokens',
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const found = (await search('spacing tokens', {type: 'doc', limit: 50}))
|
|
66
|
+
.data.results;
|
|
67
|
+
const holders = found
|
|
68
|
+
.filter(
|
|
69
|
+
hit =>
|
|
70
|
+
hit.section === 'spacing-tokens' ||
|
|
71
|
+
hit.name === 'tokens/tokens-spacing',
|
|
72
|
+
)
|
|
73
|
+
.map(hit => hit.name);
|
|
74
|
+
expect(new Set(holders)).toEqual(new Set(['tokens/tokens-spacing']));
|
|
75
|
+
},
|
|
76
|
+
SLOW,
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
it(
|
|
80
|
+
'still answer a token reference to `tokens`, in every language',
|
|
81
|
+
async () => {
|
|
82
|
+
for (const options of [{}, {dense: true}, {zh: true}]) {
|
|
83
|
+
const read = await docs('color', null, options);
|
|
84
|
+
const text = JSON.stringify(read.data.sections);
|
|
85
|
+
expect(text).not.toContain('[token-ref');
|
|
86
|
+
expect(text).toContain('--color-accent');
|
|
87
|
+
}
|
|
88
|
+
const section = await docs('spacing', 'scale');
|
|
89
|
+
expect(JSON.stringify(section.data)).toContain('--spacing-4');
|
|
90
|
+
},
|
|
91
|
+
SLOW,
|
|
92
|
+
);
|
|
93
|
+
});
|