@astryxdesign/cli 0.6.5 → 0.6.6-canary.1f4eb3c
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 +87 -0
- package/README.md +58 -55
- package/api/build/_adapter.d.mts +55 -2
- package/api/build/_adapter.mjs +100 -10
- package/api/build/build.doc.mjs +2 -2
- package/api/build/build.test.mjs +111 -2
- package/api/build/build.type.d.mts +8 -0
- package/api/build/build.type.mjs +2 -0
- package/api/build/kit/kit.mjs +99 -22
- package/api/build/kit/rank.d.mts +32 -8
- package/api/build/kit/rank.mjs +291 -97
- package/api/build/kit/rank.test.mjs +231 -48
- package/api/build/kit/weights.d.mts +82 -0
- package/api/build/kit/weights.json +1 -0
- package/api/build/kit/weights.mjs +305 -0
- package/api/build/kit/weights.test.mjs +190 -0
- package/api/component/_adapter.d.mts +19 -0
- package/api/component/_adapter.mjs +33 -0
- package/api/component/component-replacement.test.mjs +603 -0
- 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 +25 -0
- package/api/docs/detail/detail.mjs +19 -3
- package/api/docs/detail/section/section.mjs +7 -1
- package/api/docs/docOverlays.test.mjs +10 -6
- package/api/docs/docs.d.mts +6 -0
- package/api/docs/docs.depth.test.mjs +134 -0
- package/api/docs/docs.doc.mjs +31 -2
- package/api/docs/docs.mjs +46 -1
- package/api/docs/docs.test.mjs +279 -0
- package/api/docs/docs.type.d.mts +81 -4
- package/api/docs/docs.type.mjs +41 -4
- package/api/docs/index/index.mjs +11 -2
- package/api/docs/index/index.test.mjs +7 -2
- package/api/docs/integration-tree.test.mjs +572 -0
- package/api/docs/integrationDocs.test.mjs +337 -0
- package/api/docs/node/node.d.mts +28 -3
- package/api/docs/node/node.mjs +149 -23
- package/api/doctor/_adapter.d.mts +43 -0
- package/api/doctor/_adapter.mjs +142 -0
- package/api/doctor/doctor.d.mts +0 -10
- package/api/doctor/doctor.doc.mjs +1 -3
- package/api/doctor/doctor.mjs +6 -123
- package/api/doctor/theme-checks.d.mts +12 -0
- package/api/doctor/theme-checks.mjs +1117 -0
- package/api/doctor/theme-checks.test.mjs +526 -0
- package/api/error.d.mts +22 -0
- package/api/error.mjs +42 -0
- package/api/gap-report/gap-report.d.mts +3 -1
- package/api/gap-report/gap-report.mjs +27 -3
- package/api/gap-report/gap-report.test.mjs +106 -0
- 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.d.mts +1 -1
- 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 +10 -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-contribution.d.mts +2 -1
- package/api/integration/add-contribution.mjs +7 -3
- package/api/integration/add-contribution.test.mjs +3 -3
- package/api/integration/add-helpers.d.mts +26 -5
- package/api/integration/add-helpers.mjs +50 -5
- package/api/integration/add-theme.mjs +354 -28
- package/api/integration/add-theme.test.mjs +380 -16
- package/api/integration/authoring-checks.mjs +31 -8
- package/api/integration/authoring-checks.type.d.mts +8 -0
- package/api/integration/authoring-checks.type.mjs +7 -3
- package/api/integration/integration-authoring.type.d.mts +4 -1
- package/api/integration/integration-authoring.type.mjs +6 -1
- package/api/integration/integrationAdd.doc.mjs +6 -0
- package/api/integration/integrationAddTheme.doc.mjs +10 -0
- package/api/integration/integrationComponentConflicts.doc.mjs +6 -3
- package/api/integration/integrationDocConflicts.doc.mjs +1 -1
- package/api/integration/integrationTemplateConflicts.doc.mjs +1 -1
- 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 +495 -4
- package/api/integration/pack-check.test.mjs +619 -10
- package/api/integration/validate-integration.d.mts +4 -2
- package/api/integration/validate-integration.mjs +7 -2
- package/api/integration/validate-integration.test.mjs +55 -0
- package/api/integration/validate-integration.type.d.mts +5 -0
- package/api/integration/validate-integration.type.mjs +5 -1
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/layout/expand/expand.mjs +12 -7
- package/api/layout/expand/expand.receipt.test.mjs +74 -0
- package/api/layout/layout.type.d.mts +1 -0
- package/api/layout/layout.type.mjs +1 -0
- package/api/layout/layoutExpand.doc.mjs +1 -1
- package/api/search/search.d.mts +39 -8
- package/api/search/search.doc.mjs +4 -4
- package/api/search/search.mjs +248 -66
- package/api/search/search.test.mjs +829 -0
- package/api/search/search.type.d.mts +6 -6
- package/api/search/search.type.mjs +5 -5
- 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 +95 -13
- package/api/swizzle/list/list.mjs +2 -2
- package/api/swizzle/swizzle.doc.mjs +4 -0
- 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 +15 -8
- package/api/template/copy/copy.receipt.test.mjs +77 -0
- package/api/template/show/show.mjs +17 -4
- package/api/template/show/show.test.mjs +76 -0
- package/api/template/skeleton/skeleton.mjs +2 -1
- package/api/template/template-integration.test.mjs +14 -0
- package/api/template/template.d.mts +1 -1
- package/api/template/template.doc.mjs +6 -2
- package/api/template/template.mjs +2 -0
- package/api/template/template.type.d.mts +14 -0
- package/api/template/template.type.mjs +5 -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 +50 -2
- package/api/theme/build/build.family.test.mjs +13 -4
- package/api/theme/build/build.icon-lineage.test.mjs +117 -0
- package/api/theme/build/build.icon-preservation.test.mjs +639 -0
- package/api/theme/build/build.mjs +463 -155
- package/api/theme/build/build.project-core.test.mjs +165 -0
- package/api/theme/build/build.test.mjs +220 -1
- package/api/theme/build/icon-imports.d.mts +47 -0
- package/api/theme/build/icon-imports.mjs +691 -0
- 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.d.mts +4 -1
- package/api/theme/themeBuild.doc.mjs +15 -4
- 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/run/run.mjs +20 -3
- package/api/upgrade/run/run.test.mjs +45 -1
- package/api/upgrade/upgrade.doc.mjs +1 -1
- package/api/upgrade/upgrade.type.d.mts +5 -0
- package/api/upgrade/upgrade.type.mjs +2 -0
- package/assets/codemods/integration-discovery.mjs +1 -1
- package/assets/codemods/integration-discovery.test.mjs +64 -0
- package/assets/codemods/transforms/next/__tests__/migrate-copied-themes-to-descriptors.test.mjs +129 -0
- package/assets/codemods/transforms/next/index.mjs +14 -1
- package/assets/codemods/transforms/next/migrate-copied-themes-to-descriptors.mjs +54 -0
- package/assets/docs/author-a-theme.doc.mjs +161 -0
- package/assets/docs/getting-started.doc.mjs +59 -15
- package/assets/docs/icons.doc.mjs +1 -0
- package/assets/docs/principles.doc.dense.mjs +2 -2
- package/assets/docs/principles.doc.mjs +2 -2
- package/assets/docs/principles.doc.zh.mjs +2 -2
- package/assets/docs/styling-libraries.doc.mjs +1 -1
- package/assets/docs/styling.doc.mjs +2 -2
- package/assets/docs/theme.doc.dense.mjs +10 -198
- package/assets/docs/theme.doc.mjs +13 -770
- package/assets/docs/theme.doc.zh.mjs +31 -12
- package/assets/docs/tokens.doc.mjs +4 -4
- package/assets/docs/tree/add-a-theme.doc.mjs +6 -2
- package/assets/docs/tree/add-a-topic.doc.mjs +1 -1
- package/assets/docs/tree/check-your-docs.doc.mjs +2 -2
- package/assets/docs/tree/checks.doc.mjs +6 -5
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +1 -1
- package/assets/docs/tree/define-the-theme.doc.mjs +2 -2
- package/assets/docs/tree/document-the-theme.doc.mjs +4 -4
- package/assets/docs/tree/fonts-and-assets.doc.mjs +25 -20
- package/assets/docs/tree/headers-and-footers.doc.mjs +68 -0
- package/assets/docs/tree/layout-spacing.doc.mjs +168 -0
- package/assets/docs/tree/layout.doc.mjs +32 -0
- package/assets/docs/tree/replace-a-core-component.doc.mjs +21 -4
- package/assets/docs/tree/responsive.doc.mjs +102 -0
- package/assets/docs/tree/scaffold.doc.mjs +145 -0
- package/assets/docs/tree/sections-and-placement.doc.mjs +1 -1
- package/assets/docs/tree/side-panels.doc.mjs +82 -0
- package/assets/docs/tree/structure.doc.mjs +144 -0
- package/assets/docs/tree/template-doc-overview.doc.mjs +13 -1
- package/assets/docs/tree/themes.doc.mjs +2 -2
- package/assets/docs/tree/troubleshooting.doc.mjs +13 -5
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +22 -5
- package/assets/docs/tree/versioning.doc.mjs +11 -7
- package/assets/docs/use-a-theme.doc.mjs +97 -0
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.doc.mjs +15 -0
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.tsx +38 -0
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.doc.mjs +20 -0
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.tsx +48 -0
- package/assets/templates/pages/ai-chat/template.doc.mjs +16 -1
- package/assets/templates/pages/ai-chat-landing/template.doc.mjs +9 -1
- package/assets/templates/pages/blank/template.doc.mjs +3 -1
- package/assets/templates/pages/canvas-editor/template.doc.mjs +9 -1
- package/assets/templates/pages/centered-hero/template.doc.mjs +3 -1
- package/assets/templates/pages/checkout-wizard/template.doc.mjs +1 -0
- package/assets/templates/pages/classic-gallery/template.doc.mjs +3 -1
- package/assets/templates/pages/contact-form/template.doc.mjs +16 -1
- package/assets/templates/pages/dashboard/template.doc.mjs +15 -1
- package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +23 -1
- package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +10 -1
- package/assets/templates/pages/dashboard-comparison/template.doc.mjs +9 -1
- package/assets/templates/pages/dashboard-composition/template.doc.mjs +10 -1
- package/assets/templates/pages/dashboard-progress/template.doc.mjs +17 -1
- package/assets/templates/pages/dashboard-scorecard/template.doc.mjs +2 -1
- package/assets/templates/pages/detail-page/template.doc.mjs +8 -0
- package/assets/templates/pages/documentation/template.doc.mjs +10 -1
- package/assets/templates/pages/documentation-design/template.doc.mjs +10 -1
- package/assets/templates/pages/documentation-technical/template.doc.mjs +10 -1
- package/assets/templates/pages/editor/template.doc.mjs +9 -1
- package/assets/templates/pages/file-explorer/template.doc.mjs +3 -1
- package/assets/templates/pages/form-two-column/template.doc.mjs +17 -1
- package/assets/templates/pages/form-wizard/template.doc.mjs +14 -1
- package/assets/templates/pages/form-wizard-dialog/template.doc.mjs +1 -0
- package/assets/templates/pages/gallery-hero/template.doc.mjs +10 -1
- package/assets/templates/pages/ide/template.doc.mjs +9 -1
- package/assets/templates/pages/incident-console/template.doc.mjs +10 -1
- package/assets/templates/pages/kanban-board/template.doc.mjs +11 -1
- package/assets/templates/pages/library/template.doc.mjs +15 -1
- package/assets/templates/pages/login/template.doc.mjs +10 -1
- package/assets/templates/pages/login-card/template.doc.mjs +11 -1
- package/assets/templates/pages/login-split/template.doc.mjs +10 -1
- package/assets/templates/pages/login-sso/template.doc.mjs +10 -1
- package/assets/templates/pages/messaging-shell/template.doc.mjs +11 -1
- package/assets/templates/pages/mixed-gallery/template.doc.mjs +10 -1
- package/assets/templates/pages/payment-form/template.doc.mjs +3 -1
- package/assets/templates/pages/product-detail/template.doc.mjs +9 -1
- package/assets/templates/pages/product-gallery/template.doc.mjs +10 -1
- package/assets/templates/pages/settings/template.doc.mjs +3 -1
- package/assets/templates/pages/settings-dialog/template.doc.mjs +9 -1
- package/assets/templates/pages/settings-sidebar/template.doc.mjs +9 -1
- package/assets/templates/pages/shell-nav/template.doc.mjs +10 -1
- package/assets/templates/pages/shell-side-nav/template.doc.mjs +14 -1
- package/assets/templates/pages/shell-top-nav/template.doc.mjs +11 -1
- package/assets/templates/pages/side-gallery/template.doc.mjs +3 -1
- package/assets/templates/pages/table/template.doc.mjs +11 -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/templates/pages/table-filter/template.doc.mjs +21 -1
- package/assets/templates/pages/table-grouped/template.doc.mjs +15 -1
- package/assets/templates/pages/table-inbox/template.doc.mjs +18 -6
- package/assets/templates/pages/table-page/template.doc.mjs +20 -1
- package/assets/templates/pages/table-tree/template.doc.mjs +14 -1
- package/assets/templates/pages/theme-showcase/template.doc.mjs +10 -1
- package/assets/templates/pages/work-item-detail/template.doc.mjs +10 -0
- package/assets/templates/themes/butter/icons.tsx +2 -0
- package/assets/templates/themes/chocolate/icons.tsx +2 -0
- package/assets/templates/themes/gothic/icons.tsx +2 -0
- package/assets/templates/themes/matcha/icons.tsx +2 -0
- package/assets/templates/themes/neutral/icons.tsx +2 -0
- package/assets/templates/themes/stone/icons.tsx +2 -0
- package/assets/templates/themes/y2k/icons.tsx +2 -0
- 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/parse.d.mts +2 -0
- package/authoring/doctypes/template/parse.mjs +1 -0
- package/authoring/doctypes/template/parse.test.mjs +21 -0
- package/authoring/doctypes/template/template.doc.mjs +6 -0
- package/authoring/doctypes/template/type.ts +10 -0
- package/authoring/integration/integration.doc.mjs +1 -1
- package/clients/cli/commands/build-theme.mjs +279 -30
- package/clients/cli/commands/build.mjs +7 -6
- package/clients/cli/commands/build.text-fields.test.mjs +1 -1
- package/clients/cli/commands/component/index.mjs +88 -12
- package/clients/cli/commands/component-replacement.text.test.mjs +271 -0
- package/clients/cli/commands/component.doc.mjs +9 -2
- package/clients/cli/commands/discover.mjs +29 -1
- package/clients/cli/commands/discover.no-source.test.mjs +75 -0
- package/clients/cli/commands/docs.depth.test.mjs +219 -0
- package/clients/cli/commands/docs.doc.mjs +15 -2
- package/clients/cli/commands/docs.mjs +273 -16
- package/clients/cli/commands/docs.test.mjs +382 -0
- 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.mjs +4 -4
- package/clients/cli/commands/doctor.test.mjs +9 -51
- package/clients/cli/commands/gap-report.doc.mjs +2 -2
- package/clients/cli/commands/gap-report.mjs +12 -0
- package/clients/cli/commands/gap-report.test.mjs +63 -0
- package/clients/cli/commands/hook/index.mjs +7 -2
- package/clients/cli/commands/import-hint-correctness.test.mjs +5 -5
- package/clients/cli/commands/init.next-steps.test.mjs +18 -23
- package/clients/cli/commands/integration-add.doc.mjs +10 -0
- package/clients/cli/commands/integration-authoring.test.mjs +12 -2
- package/clients/cli/commands/integration-real-world.test.mjs +61 -12
- package/clients/cli/commands/integration.mjs +3 -1
- package/clients/cli/commands/layout-check.doc.mjs +1 -0
- package/clients/cli/commands/layout-expand.doc.mjs +4 -1
- package/clients/cli/commands/layout-grammar.doc.mjs +1 -0
- package/clients/cli/commands/layout.doc.mjs +1 -0
- package/clients/cli/commands/layout.expand-receipt.test.mjs +94 -0
- package/clients/cli/commands/layout.mjs +61 -4
- package/clients/cli/commands/no-prompt-wording.test.mjs +4 -4
- package/clients/cli/commands/search.doc.mjs +5 -4
- package/clients/cli/commands/search.mjs +30 -6
- package/clients/cli/commands/search.test.mjs +63 -17
- package/clients/cli/commands/swizzle.doc.mjs +12 -3
- package/clients/cli/commands/swizzle.mjs +2 -1
- package/clients/cli/commands/template.copy-receipt.test.mjs +60 -0
- package/clients/cli/commands/template.mjs +70 -6
- package/clients/cli/commands/template.show-media.test.mjs +62 -0
- package/clients/cli/commands/text-json-parity.test.mjs +40 -0
- package/clients/cli/commands/theme-add-lifecycle.test.mjs +132 -0
- package/clients/cli/commands/theme-add.doc.mjs +19 -19
- package/clients/cli/commands/theme-eject.doc.mjs +47 -0
- package/clients/cli/commands/theme-list.behavior.test.mjs +44 -0
- 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.ascii-output.test.mjs +14 -0
- package/clients/cli/commands/upgrade.mjs +1 -1
- package/clients/cli/commands/write-failure.test.mjs +175 -0
- package/clients/cli/index.mjs +4 -1
- package/clients/cli/lib/component-format.mjs +19 -2
- package/clients/cli/lib/manifest.mjs +44 -165
- package/clients/cli/lib/manifest.test.mjs +98 -7
- 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 +31 -28
- package/foundation/agent-docs/agent-docs.test.mjs +1163 -0
- 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/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-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-adapter.d.mts +14 -0
- package/foundation/discovery/template-adapter.fixture-refs.test.mjs +37 -1
- package/foundation/discovery/template-adapter.mjs +21 -1
- package/foundation/discovery/theme-discovery.d.mts +78 -5
- package/foundation/discovery/theme-discovery.mjs +143 -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/doc-loads.test.mjs +18 -8
- package/foundation/doc-compiler/inputs.mjs +2 -1
- package/foundation/doc-compiler/inputs.test.mjs +0 -1
- package/foundation/doc-compiler/lenses.d.mts +4 -2
- package/foundation/doc-compiler/lenses.mjs +1 -1
- package/foundation/doc-compiler/tree.test.mjs +649 -0
- package/foundation/fs/module-loader.d.mts +9 -0
- package/foundation/fs/module-loader.mjs +71 -2
- package/foundation/integrations/cli-requirement.d.mts +79 -13
- package/foundation/integrations/cli-requirement.mjs +115 -22
- package/foundation/integrations/cli-requirement.test.mjs +205 -8
- package/foundation/integrations/contribution-inventory.mjs +3 -3
- 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.d.mts +5 -5
- package/foundation/response/response-types.doc.mjs +50 -35
- 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
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Component replacement in text mode (spec:AST-035 FR11, FR13, FR15;
|
|
5
|
+
* architecture:cli-surface INV28): what a person sees from the real CLI for a
|
|
6
|
+
* replaced Core component, at every detail level, single, batch, and list,
|
|
7
|
+
* plus the help that documents it.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import {afterAll, beforeAll, describe, expect, it, vi} from 'vitest';
|
|
11
|
+
import * as fs from 'node:fs';
|
|
12
|
+
import * as path from 'node:path';
|
|
13
|
+
import {runCli} from '../../../test-utils/run-cli.mjs';
|
|
14
|
+
import {COMPONENT_REPLACES_CLI} from '../../../foundation/integrations/cli-requirement.mjs';
|
|
15
|
+
|
|
16
|
+
vi.setConfig({testTimeout: 60_000, hookTimeout: 60_000});
|
|
17
|
+
|
|
18
|
+
const FLOOR = {'@astryxdesign/cli': `>=${COMPONENT_REPLACES_CLI}`};
|
|
19
|
+
|
|
20
|
+
let tmpDir;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @param {string} name
|
|
24
|
+
* @param {Array<{name: string, replaces?: string}>} components
|
|
25
|
+
* @param {Record<string, string>} [peers]
|
|
26
|
+
*/
|
|
27
|
+
function writeIntegration(name, components, peers) {
|
|
28
|
+
const pkgDir = path.join(tmpDir, 'node_modules', ...name.split('/'));
|
|
29
|
+
const componentsDir = path.join(pkgDir, 'components');
|
|
30
|
+
fs.mkdirSync(componentsDir, {recursive: true});
|
|
31
|
+
fs.writeFileSync(
|
|
32
|
+
path.join(pkgDir, 'package.json'),
|
|
33
|
+
JSON.stringify({
|
|
34
|
+
name,
|
|
35
|
+
version: '1.0.0',
|
|
36
|
+
...(peers ? {peerDependencies: peers} : {}),
|
|
37
|
+
}),
|
|
38
|
+
);
|
|
39
|
+
fs.writeFileSync(
|
|
40
|
+
path.join(pkgDir, 'astryx.integration.mjs'),
|
|
41
|
+
"export default {components: './components'};\n",
|
|
42
|
+
);
|
|
43
|
+
for (const component of components) {
|
|
44
|
+
fs.writeFileSync(
|
|
45
|
+
path.join(componentsDir, `${component.name}.doc.mjs`),
|
|
46
|
+
`export default ${JSON.stringify({
|
|
47
|
+
type: 'component',
|
|
48
|
+
name: component.name,
|
|
49
|
+
displayName: component.name,
|
|
50
|
+
...(component.replaces ? {replaces: component.replaces} : {}),
|
|
51
|
+
import: `${name}/components/${component.name}`,
|
|
52
|
+
usage: {description: `${component.name} for Acme apps.`},
|
|
53
|
+
props: [],
|
|
54
|
+
})};\n`,
|
|
55
|
+
);
|
|
56
|
+
fs.writeFileSync(
|
|
57
|
+
path.join(componentsDir, `${component.name}.tsx`),
|
|
58
|
+
`export function ${component.name}() { return null; }\n`,
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
beforeAll(() => {
|
|
64
|
+
// Under the repository so the project resolves the workspace's Core.
|
|
65
|
+
tmpDir = fs.mkdtempSync(
|
|
66
|
+
path.join(process.cwd(), '.astryx-component-replacement-text-'),
|
|
67
|
+
);
|
|
68
|
+
writeIntegration(
|
|
69
|
+
'@acme/nav',
|
|
70
|
+
[{name: 'AcmeSideNav', replaces: 'SideNav'}],
|
|
71
|
+
FLOOR,
|
|
72
|
+
);
|
|
73
|
+
writeIntegration('@acme/old', [{name: 'OldTopNav', replaces: 'TopNav'}]);
|
|
74
|
+
writeIntegration(
|
|
75
|
+
'@acme/bad',
|
|
76
|
+
[{name: 'BadThing', replaces: 'NoSuchComponent'}],
|
|
77
|
+
FLOOR,
|
|
78
|
+
);
|
|
79
|
+
fs.writeFileSync(
|
|
80
|
+
path.join(tmpDir, 'package.json'),
|
|
81
|
+
JSON.stringify({
|
|
82
|
+
name: 'consumer',
|
|
83
|
+
version: '1.0.0',
|
|
84
|
+
dependencies: {
|
|
85
|
+
'@acme/nav': '1.0.0',
|
|
86
|
+
'@acme/old': '1.0.0',
|
|
87
|
+
'@acme/bad': '1.0.0',
|
|
88
|
+
},
|
|
89
|
+
}),
|
|
90
|
+
);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
afterAll(() => {
|
|
94
|
+
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const IMPORT =
|
|
98
|
+
"import { AcmeSideNav } from '@acme/nav/components/AcmeSideNav';";
|
|
99
|
+
|
|
100
|
+
describe('component detail text', () => {
|
|
101
|
+
it('prints the replacement at full detail, naming its package', async () => {
|
|
102
|
+
const run = await runCli(['component', 'SideNav'], {cwd: tmpDir});
|
|
103
|
+
expect(run.status, run.stderr).toBe(0);
|
|
104
|
+
expect(run.stdout).toContain('package: @acme/nav');
|
|
105
|
+
expect(run.stdout).toContain('# AcmeSideNav');
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('imports the export the package has at compact detail', async () => {
|
|
109
|
+
const run = await runCli(['component', 'SideNav', '--detail', 'compact'], {
|
|
110
|
+
cwd: tmpDir,
|
|
111
|
+
});
|
|
112
|
+
expect(run.status, run.stderr).toBe(0);
|
|
113
|
+
expect(run.stdout).toContain(IMPORT);
|
|
114
|
+
expect(run.stdout).not.toContain('import { SideNav }');
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('names the export the package has at brief detail', async () => {
|
|
118
|
+
const run = await runCli(['component', 'SideNav', '--detail', 'brief'], {
|
|
119
|
+
cwd: tmpDir,
|
|
120
|
+
});
|
|
121
|
+
expect(run.status, run.stderr).toBe(0);
|
|
122
|
+
expect(run.stdout).toMatch(
|
|
123
|
+
/^AcmeSideNav {2}<- from '@acme\/nav\/components\/AcmeSideNav'/m,
|
|
124
|
+
);
|
|
125
|
+
expect(run.stdout).not.toMatch(/^SideNav {2}<- from '@acme/m);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('answers to the Core name qualified by the replacing package', async () => {
|
|
129
|
+
const run = await runCli(
|
|
130
|
+
['component', '@acme/nav/SideNav', '--detail', 'compact'],
|
|
131
|
+
{
|
|
132
|
+
cwd: tmpDir,
|
|
133
|
+
},
|
|
134
|
+
);
|
|
135
|
+
expect(run.status, run.stderr).toBe(0);
|
|
136
|
+
expect(run.stdout).toContain(IMPORT);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('keeps the Core original behind --package @astryxdesign/core', async () => {
|
|
140
|
+
const run = await runCli(
|
|
141
|
+
[
|
|
142
|
+
'component',
|
|
143
|
+
'SideNav',
|
|
144
|
+
'--package',
|
|
145
|
+
'@astryxdesign/core',
|
|
146
|
+
'--detail',
|
|
147
|
+
'compact',
|
|
148
|
+
],
|
|
149
|
+
{cwd: tmpDir},
|
|
150
|
+
);
|
|
151
|
+
expect(run.status, run.stderr).toBe(0);
|
|
152
|
+
expect(run.stdout).toContain('package: @astryxdesign/core');
|
|
153
|
+
expect(run.stdout).toContain("from '@astryxdesign/core/SideNav'");
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
describe('component batch text', () => {
|
|
158
|
+
it.each(['compact', 'brief'])(
|
|
159
|
+
'uses the replacement export at %s detail',
|
|
160
|
+
async detail => {
|
|
161
|
+
const run = await runCli(
|
|
162
|
+
['component', 'SideNav', 'Button', '--detail', detail],
|
|
163
|
+
{
|
|
164
|
+
cwd: tmpDir,
|
|
165
|
+
},
|
|
166
|
+
);
|
|
167
|
+
expect(run.status, run.stderr).toBe(0);
|
|
168
|
+
expect(run.stdout).toContain('AcmeSideNav');
|
|
169
|
+
expect(run.stdout).toContain("'@acme/nav/components/AcmeSideNav'");
|
|
170
|
+
expect(run.stdout).not.toContain('import { SideNav }');
|
|
171
|
+
expect(run.stdout).not.toMatch(/^SideNav {2}<- from '@acme/m);
|
|
172
|
+
},
|
|
173
|
+
);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
describe('component list text', () => {
|
|
177
|
+
it('lists the replacement once, with its package, at brief detail', async () => {
|
|
178
|
+
const run = await runCli(['component', '--list'], {cwd: tmpDir});
|
|
179
|
+
expect(run.status, run.stderr).toBe(0);
|
|
180
|
+
expect(run.stdout).toContain('name: AcmeSideNav');
|
|
181
|
+
expect(run.stdout).toContain(
|
|
182
|
+
'@acme/nav/components/AcmeSideNav [@acme/nav]',
|
|
183
|
+
);
|
|
184
|
+
expect(run.stdout.match(/name: {3}AcmeSideNav\n/g)).toHaveLength(1);
|
|
185
|
+
expect(run.stdout).not.toMatch(/name: {3}SideNav\n/);
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it('names the replacement package at compact detail', async () => {
|
|
189
|
+
const run = await runCli(['component', '--list', '--detail', 'compact'], {
|
|
190
|
+
cwd: tmpDir,
|
|
191
|
+
});
|
|
192
|
+
expect(run.status, run.stderr).toBe(0);
|
|
193
|
+
expect(run.stdout).toContain(
|
|
194
|
+
'@acme/nav/components/AcmeSideNav [@acme/nav]',
|
|
195
|
+
);
|
|
196
|
+
expect(run.stdout).not.toMatch(/name: +SideNav\n/);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it('prints the replacement in the Core slot at full detail', async () => {
|
|
200
|
+
const run = await runCli(['component', '--list', '--detail', 'full'], {
|
|
201
|
+
cwd: tmpDir,
|
|
202
|
+
});
|
|
203
|
+
expect(run.status, run.stderr).toBe(0);
|
|
204
|
+
expect(run.stdout).toMatch(
|
|
205
|
+
/^AcmeSideNav {2}<- from '@acme\/nav\/components\/AcmeSideNav' {2}\[@acme\/nav\]$/m,
|
|
206
|
+
);
|
|
207
|
+
expect(run.stdout).not.toMatch(/^SideNav[( ]/m);
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it.each(['brief', 'compact', 'full'])(
|
|
211
|
+
'keeps the replacement in its category at %s detail',
|
|
212
|
+
async detail => {
|
|
213
|
+
const run = await runCli(
|
|
214
|
+
['component', '--category', 'Navigation', '--detail', detail],
|
|
215
|
+
{cwd: tmpDir},
|
|
216
|
+
);
|
|
217
|
+
expect(run.status, run.stderr).toBe(0);
|
|
218
|
+
expect(run.stdout).toContain('AcmeSideNav');
|
|
219
|
+
},
|
|
220
|
+
);
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
describe('help documents the replacement', () => {
|
|
224
|
+
it.each([
|
|
225
|
+
[
|
|
226
|
+
['component', '--help'],
|
|
227
|
+
['replaced by an integration component', '--package @astryxdesign/core'],
|
|
228
|
+
],
|
|
229
|
+
[
|
|
230
|
+
['swizzle', '--help'],
|
|
231
|
+
['replaces', '--package @astryxdesign/core', '--list'],
|
|
232
|
+
],
|
|
233
|
+
[
|
|
234
|
+
['gap-report', '--help'],
|
|
235
|
+
['the integration whose component replaces the named Core component'],
|
|
236
|
+
],
|
|
237
|
+
[
|
|
238
|
+
['doctor', 'integration', 'components', '--help'],
|
|
239
|
+
['replaces', 'an invalid replaces'],
|
|
240
|
+
],
|
|
241
|
+
])('%s', async (args, needles) => {
|
|
242
|
+
const run = await runCli(/** @type {string[]} */ (args), {cwd: tmpDir});
|
|
243
|
+
const help = run.stdout + run.stderr;
|
|
244
|
+
for (const needle of needles) expect(help).toContain(needle);
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
describe('doctor integration components text and exit codes', () => {
|
|
249
|
+
it('exits 1 for an invalid replaces in a package with the floor', async () => {
|
|
250
|
+
const run = await runCli(
|
|
251
|
+
['doctor', 'integration', 'components', '@acme/bad'],
|
|
252
|
+
{
|
|
253
|
+
cwd: tmpDir,
|
|
254
|
+
},
|
|
255
|
+
);
|
|
256
|
+
expect(run.status).toBe(1);
|
|
257
|
+
expect(run.stdout).toContain('missing_component_replacement_target');
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
it('warns and exits 0 for a package without the floor', async () => {
|
|
261
|
+
const run = await runCli(
|
|
262
|
+
['doctor', 'integration', 'components', '@acme/old'],
|
|
263
|
+
{
|
|
264
|
+
cwd: tmpDir,
|
|
265
|
+
},
|
|
266
|
+
);
|
|
267
|
+
expect(run.status, run.stdout).toBe(0);
|
|
268
|
+
expect(run.stdout).toContain('inactive_component_replacement');
|
|
269
|
+
expect(run.stdout).toContain(`">=${COMPONENT_REPLACES_CLI}"`);
|
|
270
|
+
});
|
|
271
|
+
});
|
|
@@ -21,7 +21,10 @@ export const doc = {
|
|
|
21
21
|
"Use 'Button', 'widgets/Button', '@acme/widgets/Button', or " +
|
|
22
22
|
"'@acme/widgets@1.2.3/Button'. A version applies to the package and must match the " +
|
|
23
23
|
'installed version. Boolean flags narrow every resolved component to just its props, ' +
|
|
24
|
-
'source, showcase, or example blocks.'
|
|
24
|
+
'source, showcase, or example blocks. An integration component that replaces a Core ' +
|
|
25
|
+
'component (its doc sets replaces, and its package declares the CLI range that turns ' +
|
|
26
|
+
'replacement on) answers to the Core name in detail, batch, and list views; use ' +
|
|
27
|
+
'--package @astryxdesign/core for the original.',
|
|
25
28
|
fn: 'component',
|
|
26
29
|
args: [
|
|
27
30
|
{
|
|
@@ -69,7 +72,7 @@ export const doc = {
|
|
|
69
72
|
flag: '--package <name>',
|
|
70
73
|
param: 'options.package',
|
|
71
74
|
description:
|
|
72
|
-
'Scope lookup to an external package (e.g. @acme/xds-widgets)',
|
|
75
|
+
'Scope lookup to an external package (e.g. @acme/xds-widgets). Use @astryxdesign/core to select an original replaced by an integration component.',
|
|
73
76
|
},
|
|
74
77
|
],
|
|
75
78
|
examples: [
|
|
@@ -82,6 +85,10 @@ export const doc = {
|
|
|
82
85
|
label: 'Props table as JSON',
|
|
83
86
|
cli: 'astryx component Button --props --json',
|
|
84
87
|
},
|
|
88
|
+
{
|
|
89
|
+
label: 'Select a replaced Core original',
|
|
90
|
+
cli: 'astryx component SideNav --package @astryxdesign/core',
|
|
91
|
+
},
|
|
85
92
|
],
|
|
86
93
|
exitCodes: [
|
|
87
94
|
{code: 0, when: 'success'},
|
|
@@ -268,19 +268,47 @@ export function registerDiscover(program) {
|
|
|
268
268
|
// No discover source: the list of what this project has, as always.
|
|
269
269
|
if (available === undefined) {
|
|
270
270
|
if (result.data.length === 0) {
|
|
271
|
-
if (
|
|
271
|
+
if (options.available) {
|
|
272
|
+
// The user specifically asked for available packages but
|
|
273
|
+
// there is no source to answer from. Say so honestly.
|
|
274
|
+
emit(
|
|
275
|
+
text('No discover source is configured.'),
|
|
276
|
+
text(
|
|
277
|
+
[
|
|
278
|
+
'Available integrations are listed by discover sources.',
|
|
279
|
+
'A project can set one in astryx.config.mjs, and installed',
|
|
280
|
+
'integrations can provide one.',
|
|
281
|
+
].join(' '),
|
|
282
|
+
),
|
|
283
|
+
text(
|
|
284
|
+
[
|
|
285
|
+
`Find Astryx packages on npm: npm search @astryxdesign`,
|
|
286
|
+
`Learn more: ${run} docs cli/integrations`,
|
|
287
|
+
].join('\n'),
|
|
288
|
+
),
|
|
289
|
+
);
|
|
290
|
+
} else if (result.meta && result.meta.configured === false) {
|
|
272
291
|
emit(
|
|
273
292
|
text('No integrations configured.'),
|
|
274
293
|
text('Add integration package names to astryx.config.mjs:'),
|
|
275
294
|
code(
|
|
276
295
|
"export default {\n integrations: ['@scope/your-integration'],\n};",
|
|
277
296
|
),
|
|
297
|
+
text(
|
|
298
|
+
[
|
|
299
|
+
`Find Astryx packages on npm: npm search @astryxdesign`,
|
|
300
|
+
`Learn more: ${run} docs cli/integrations`,
|
|
301
|
+
].join('\n'),
|
|
302
|
+
),
|
|
278
303
|
);
|
|
279
304
|
} else {
|
|
280
305
|
emit(
|
|
281
306
|
text(
|
|
282
307
|
'No external components found in configured integrations.',
|
|
283
308
|
),
|
|
309
|
+
text(
|
|
310
|
+
`Find more packages: ${run} discover --available (needs a discover source)`,
|
|
311
|
+
),
|
|
284
312
|
);
|
|
285
313
|
}
|
|
286
314
|
break;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file `astryx discover` when no discover source is configured and no
|
|
5
|
+
* integration provides one.
|
|
6
|
+
*
|
|
7
|
+
* In a fresh public app with no integrations, `discover --available` used to
|
|
8
|
+
* print "No integrations configured. Add integration package names..." — a
|
|
9
|
+
* message that told users to add names they had no way to find. These tests
|
|
10
|
+
* pin the honest replacement.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import {describe, it, expect, beforeEach, afterEach} from 'vitest';
|
|
14
|
+
import * as fs from 'node:fs';
|
|
15
|
+
import * as path from 'node:path';
|
|
16
|
+
import * as os from 'node:os';
|
|
17
|
+
import {runCli} from '../../../test-utils/run-cli.mjs';
|
|
18
|
+
|
|
19
|
+
let tmpDir;
|
|
20
|
+
let project;
|
|
21
|
+
|
|
22
|
+
beforeEach(() => {
|
|
23
|
+
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-discover-nosource-'));
|
|
24
|
+
project = path.join(tmpDir, 'project');
|
|
25
|
+
fs.mkdirSync(project, {recursive: true});
|
|
26
|
+
fs.writeFileSync(
|
|
27
|
+
path.join(project, 'package.json'),
|
|
28
|
+
JSON.stringify({name: 'my-app', version: '1.0.0'}),
|
|
29
|
+
);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
afterEach(() => {
|
|
33
|
+
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
describe('astryx discover --available with no source', () => {
|
|
37
|
+
it('explains what discover sources are and where to find packages', async () => {
|
|
38
|
+
const {status, stdout} = await runCli(['discover', '--available'], {
|
|
39
|
+
cwd: project,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
expect(status).toBe(0);
|
|
43
|
+
expect(stdout).toContain('No discover source is configured.');
|
|
44
|
+
expect(stdout).toContain('discover sources');
|
|
45
|
+
expect(stdout).toContain('npm search @astryxdesign');
|
|
46
|
+
expect(stdout).toContain('docs cli/integrations');
|
|
47
|
+
// Must not show the old misleading message
|
|
48
|
+
expect(stdout).not.toContain('Add integration package names');
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('returns an empty list with configured=false in --json', async () => {
|
|
52
|
+
const {status, stdout} = await runCli(
|
|
53
|
+
['discover', '--available', '--json'],
|
|
54
|
+
{cwd: project},
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
expect(status).toBe(0);
|
|
58
|
+
const result = JSON.parse(stdout);
|
|
59
|
+
expect(result.type).toBe('discover.list');
|
|
60
|
+
expect(result.data).toEqual([]);
|
|
61
|
+
expect(result.meta).toEqual({configured: false});
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
describe('astryx discover with nothing configured', () => {
|
|
66
|
+
it('shows the config snippet and a pointer to npm and docs', async () => {
|
|
67
|
+
const {status, stdout} = await runCli(['discover'], {cwd: project});
|
|
68
|
+
|
|
69
|
+
expect(status).toBe(0);
|
|
70
|
+
expect(stdout).toContain('No integrations configured.');
|
|
71
|
+
expect(stdout).toContain("integrations: ['@scope/your-integration']");
|
|
72
|
+
expect(stdout).toContain('npm search @astryxdesign');
|
|
73
|
+
expect(stdout).toContain('docs cli/integrations');
|
|
74
|
+
});
|
|
75
|
+
});
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
import * as fs from 'node:fs';
|
|
4
|
+
import * as path from 'node:path';
|
|
5
|
+
import {afterEach, beforeEach, describe, expect, it} from 'vitest';
|
|
6
|
+
import {runCli} from '../../../test-utils/run-cli.mjs';
|
|
7
|
+
|
|
8
|
+
const SLOW = 60_000;
|
|
9
|
+
|
|
10
|
+
/** @type {string} */
|
|
11
|
+
let tmpDir;
|
|
12
|
+
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
tmpDir = fs.mkdtempSync(path.join(process.cwd(), '.astryx-docs-depth-test-'));
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
afterEach(() => {
|
|
18
|
+
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
/** An app with an integration that places one guide under its namespace. */
|
|
22
|
+
function scaffoldGuide() {
|
|
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 packageDir = path.join(tmpDir, 'node_modules', '@acme', 'kit');
|
|
32
|
+
fs.mkdirSync(path.join(packageDir, 'docs'), {recursive: true});
|
|
33
|
+
fs.writeFileSync(
|
|
34
|
+
path.join(packageDir, 'package.json'),
|
|
35
|
+
JSON.stringify({name: '@acme/kit', version: '1.0.0'}),
|
|
36
|
+
);
|
|
37
|
+
fs.writeFileSync(
|
|
38
|
+
path.join(packageDir, 'astryx.integration.mjs'),
|
|
39
|
+
"export default {docs: './docs'};\n",
|
|
40
|
+
);
|
|
41
|
+
const namespace = {
|
|
42
|
+
type: 'namespace',
|
|
43
|
+
name: 'acme',
|
|
44
|
+
title: 'Acme docs',
|
|
45
|
+
summary: 'Build with the Acme kit.',
|
|
46
|
+
slots: {guides: {title: 'Guides', accepts: {kinds: ['generic']}}},
|
|
47
|
+
};
|
|
48
|
+
const guide = {
|
|
49
|
+
type: 'generic',
|
|
50
|
+
name: 'themes',
|
|
51
|
+
title: 'Theme building',
|
|
52
|
+
description: 'Build an Acme theme.',
|
|
53
|
+
placement: {parent: 'namespace:acme', slot: 'guides'},
|
|
54
|
+
sections: [
|
|
55
|
+
{
|
|
56
|
+
title: 'Create the theme',
|
|
57
|
+
content: [
|
|
58
|
+
{
|
|
59
|
+
type: 'prose',
|
|
60
|
+
text: 'Child guide body marker: compile the ocean palette.',
|
|
61
|
+
},
|
|
62
|
+
{type: 'code', lang: 'bash', code: 'npx acme theme build ocean'},
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
};
|
|
67
|
+
for (const [file, doc] of [
|
|
68
|
+
['acme.doc.mjs', namespace],
|
|
69
|
+
['themes.doc.mjs', guide],
|
|
70
|
+
]) {
|
|
71
|
+
fs.writeFileSync(
|
|
72
|
+
path.join(packageDir, 'docs', file),
|
|
73
|
+
`export const docs = ${JSON.stringify(doc, null, 2)};\n`,
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
describe('astryx docs --depth', () => {
|
|
79
|
+
it(
|
|
80
|
+
'lists every doc below a namespace, one line each, by where it sits',
|
|
81
|
+
async () => {
|
|
82
|
+
const result = await runCli(['docs', 'cli/api', '--depth', 'all']);
|
|
83
|
+
expect(result.status).toBe(0);
|
|
84
|
+
expect(result.stdout).toMatch(/^functions\s+\S/m);
|
|
85
|
+
expect(result.stdout).toMatch(/^functions\/search\s+search\(\): /m);
|
|
86
|
+
expect(result.stdout).toContain('Open one: ');
|
|
87
|
+
expect(result.stdout).toContain('docs cli/api/<name>');
|
|
88
|
+
// One line each: no doc's body.
|
|
89
|
+
expect(result.stdout).not.toContain('`astryx search` runs it.');
|
|
90
|
+
},
|
|
91
|
+
SLOW,
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
it(
|
|
95
|
+
'says how many docs sit below where the read stops',
|
|
96
|
+
async () => {
|
|
97
|
+
const zero = await runCli(['docs', 'cli/api', '--depth', '0']);
|
|
98
|
+
expect(zero.status).toBe(0);
|
|
99
|
+
expect(zero.stdout).toMatch(
|
|
100
|
+
/^\d+ docs below\. Read them: .*docs cli\/api --depth 1$/m,
|
|
101
|
+
);
|
|
102
|
+
expect(zero.stdout).not.toMatch(/^functions\s/m);
|
|
103
|
+
|
|
104
|
+
const one = await runCli(['docs', 'cli/api', '--depth', '1']);
|
|
105
|
+
expect(one.status).toBe(0);
|
|
106
|
+
expect(one.stdout).toMatch(/^functions\s+.*\(\d+ docs below\)$/m);
|
|
107
|
+
expect(one.stdout).not.toMatch(/^functions\/search\s/m);
|
|
108
|
+
},
|
|
109
|
+
SLOW,
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
it(
|
|
113
|
+
'prints each doc below whole with --detail full, and drops code at compact',
|
|
114
|
+
async () => {
|
|
115
|
+
scaffoldGuide();
|
|
116
|
+
const full = await runCli(
|
|
117
|
+
['docs', 'acme', '--depth', 'all', '--detail', 'full'],
|
|
118
|
+
tmpDir,
|
|
119
|
+
);
|
|
120
|
+
expect(full.status).toBe(0);
|
|
121
|
+
expect(full.stdout).toMatch(/^## Theme building \(themes\)$/m);
|
|
122
|
+
expect(full.stdout).toMatch(/^### Create the theme$/m);
|
|
123
|
+
expect(full.stdout).toContain(
|
|
124
|
+
'Child guide body marker: compile the ocean palette.',
|
|
125
|
+
);
|
|
126
|
+
expect(full.stdout).toContain('npx acme theme build ocean');
|
|
127
|
+
|
|
128
|
+
const compact = await runCli(
|
|
129
|
+
['docs', 'acme', '--depth', '1', '--detail', 'compact'],
|
|
130
|
+
tmpDir,
|
|
131
|
+
);
|
|
132
|
+
expect(compact.status).toBe(0);
|
|
133
|
+
expect(compact.stdout).toContain('Child guide body marker');
|
|
134
|
+
expect(compact.stdout).not.toContain('npx acme theme build ocean');
|
|
135
|
+
|
|
136
|
+
// Without --depth, the namespace still lists the guide by one line.
|
|
137
|
+
const plain = await runCli(['docs', 'acme'], tmpDir);
|
|
138
|
+
expect(plain.status).toBe(0);
|
|
139
|
+
expect(plain.stdout).toMatch(/^themes\s+Build an Acme theme\./m);
|
|
140
|
+
expect(plain.stdout).not.toContain('Child guide body marker');
|
|
141
|
+
},
|
|
142
|
+
SLOW,
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
it(
|
|
146
|
+
'returns the same tree as JSON, with text only when --detail asks',
|
|
147
|
+
async () => {
|
|
148
|
+
const brief = await runCli(['--json', 'docs', 'cli/api', '--depth', '2']);
|
|
149
|
+
expect(brief.status).toBe(0);
|
|
150
|
+
const briefData = JSON.parse(brief.stdout);
|
|
151
|
+
expect(briefData.type).toBe('docs.node');
|
|
152
|
+
const functions = briefData.data.slots
|
|
153
|
+
.flatMap((/** @type {any} */ slot) => slot.children)
|
|
154
|
+
.find(
|
|
155
|
+
(/** @type {any} */ child) => child.route === 'cli/api/functions',
|
|
156
|
+
);
|
|
157
|
+
const search = functions.slots
|
|
158
|
+
.flatMap((/** @type {any} */ slot) => slot.children)
|
|
159
|
+
.find(
|
|
160
|
+
(/** @type {any} */ child) =>
|
|
161
|
+
child.route === 'cli/api/functions/search',
|
|
162
|
+
);
|
|
163
|
+
expect(search).not.toHaveProperty('content');
|
|
164
|
+
|
|
165
|
+
const full = await runCli([
|
|
166
|
+
'--json',
|
|
167
|
+
'docs',
|
|
168
|
+
'cli/api',
|
|
169
|
+
'--depth',
|
|
170
|
+
'2',
|
|
171
|
+
'--detail',
|
|
172
|
+
'full',
|
|
173
|
+
]);
|
|
174
|
+
expect(full.status).toBe(0);
|
|
175
|
+
expect(full.stdout).toContain('`astryx search` runs it.');
|
|
176
|
+
},
|
|
177
|
+
SLOW,
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
it(
|
|
181
|
+
'composes with --index and --full, and leaves a topic read as it was',
|
|
182
|
+
async () => {
|
|
183
|
+
const depth = await runCli(['docs', 'cli/api', '--depth', '1']);
|
|
184
|
+
expect(depth.status).toBe(0);
|
|
185
|
+
for (const flag of ['--index', '--full']) {
|
|
186
|
+
const both = await runCli(['docs', 'cli/api', '--depth', '1', flag]);
|
|
187
|
+
expect(both.status).toBe(0);
|
|
188
|
+
expect(both.stdout).toBe(depth.stdout);
|
|
189
|
+
}
|
|
190
|
+
for (const args of [
|
|
191
|
+
['docs', 'theme'],
|
|
192
|
+
['docs', 'theme', '--index'],
|
|
193
|
+
['docs', 'theme', '--full'],
|
|
194
|
+
]) {
|
|
195
|
+
const plain = await runCli(args);
|
|
196
|
+
const withDepth = await runCli([...args, '--depth', '2']);
|
|
197
|
+
expect(withDepth.status).toBe(plain.status);
|
|
198
|
+
expect(withDepth.stdout).toBe(plain.stdout);
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
SLOW,
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
it(
|
|
205
|
+
'refuses a depth that is not a number of levels',
|
|
206
|
+
async () => {
|
|
207
|
+
const result = await runCli([
|
|
208
|
+
'--json',
|
|
209
|
+
'docs',
|
|
210
|
+
'cli/api',
|
|
211
|
+
'--depth',
|
|
212
|
+
'deep',
|
|
213
|
+
]);
|
|
214
|
+
expect(result.status).toBe(1);
|
|
215
|
+
expect(JSON.parse(result.stdout).code).toBe('ERR_INVALID_ARGUMENT');
|
|
216
|
+
},
|
|
217
|
+
SLOW,
|
|
218
|
+
);
|
|
219
|
+
});
|
|
@@ -22,7 +22,9 @@ export const doc = {
|
|
|
22
22
|
'does, and `--index` its section index. A route ' +
|
|
23
23
|
'opens a node of the docs tree: `cli` lists its guides and reference, ' +
|
|
24
24
|
'`cli/api/functions` lists every API function, and `cli/api/functions/search` prints ' +
|
|
25
|
-
'one.'
|
|
25
|
+
'one. `--depth` reads as far down the tree as you ask, from the doc alone (0) to ' +
|
|
26
|
+
'everything below it (all), and with it `--detail` sets how much of each doc below ' +
|
|
27
|
+
'shows: one line (brief, the default), its sections (compact), or all of it (full).',
|
|
26
28
|
fn: 'docs',
|
|
27
29
|
args: [
|
|
28
30
|
{name: 'topic', param: 'topic', required: false},
|
|
@@ -39,6 +41,12 @@ export const doc = {
|
|
|
39
41
|
description:
|
|
40
42
|
'Print the whole topic instead of its sections (text; `--json` returns the whole topic unless --index). Cannot be set with --index',
|
|
41
43
|
},
|
|
44
|
+
{
|
|
45
|
+
flag: '--depth <levels>',
|
|
46
|
+
param: 'options.depth',
|
|
47
|
+
description:
|
|
48
|
+
'How many levels of the docs tree to read below a namespace: 0 for the namespace alone, 1 for its children (what a read without --depth shows), all for everything below it. With it, --detail sets how much of each doc below shows: brief (one line each, the default), compact (with its sections), or full',
|
|
49
|
+
},
|
|
42
50
|
],
|
|
43
51
|
examples: [
|
|
44
52
|
{label: 'List topics', cli: 'astryx docs'},
|
|
@@ -46,6 +54,11 @@ export const doc = {
|
|
|
46
54
|
{label: 'A whole topic as JSON', cli: 'astryx docs spacing --json'},
|
|
47
55
|
{label: 'One section', cli: 'astryx docs theme quick-start'},
|
|
48
56
|
{label: 'The CLI docs tree', cli: 'astryx docs cli'},
|
|
57
|
+
{label: 'Every CLI doc, one line each', cli: 'astryx docs cli --depth all'},
|
|
58
|
+
{
|
|
59
|
+
label: 'The integration guides as one read',
|
|
60
|
+
cli: 'astryx docs cli/integrations --depth all --detail full',
|
|
61
|
+
},
|
|
49
62
|
{label: 'One API function', cli: 'astryx docs cli/api/functions/search'},
|
|
50
63
|
{label: 'A whole guide', cli: 'astryx docs cli/integrations/quick-start --full'},
|
|
51
64
|
],
|
|
@@ -53,7 +66,7 @@ export const doc = {
|
|
|
53
66
|
{code: 0, when: 'success'},
|
|
54
67
|
{
|
|
55
68
|
code: 1,
|
|
56
|
-
when: 'unknown topic or route,
|
|
69
|
+
when: 'unknown topic or route, a section that matches no section or more than one, or a --depth that is not a number of levels or all',
|
|
57
70
|
},
|
|
58
71
|
],
|
|
59
72
|
related: ['search', 'component', 'hook', 'template'],
|