@astryxdesign/cli 0.6.5 → 0.6.6-canary.e1dda17
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
|
@@ -13,11 +13,11 @@ export const doc = {
|
|
|
13
13
|
name: 'search',
|
|
14
14
|
displayName: 'astryx search',
|
|
15
15
|
namespace: 'cli/commands',
|
|
16
|
-
summary: 'Search components, hooks, docs, and
|
|
16
|
+
summary: 'Search components, hooks, docs, templates, and themes in one ranked list',
|
|
17
17
|
description:
|
|
18
18
|
'Terminal front-end to search(): prints one ranked, greppable list across ' +
|
|
19
19
|
'every content domain, each row carrying a follow-up command to act on it. ' +
|
|
20
|
-
'Outside an app, where @astryxdesign/core is not installed, it searches the docs.',
|
|
20
|
+
'Outside an app, where @astryxdesign/core is not installed, it searches the docs and themes.',
|
|
21
21
|
fn: 'search',
|
|
22
22
|
// Every word after `search` is the query: `astryx search dark mode` searches
|
|
23
23
|
// for "dark mode", with no quotes needed.
|
|
@@ -26,8 +26,8 @@ export const doc = {
|
|
|
26
26
|
{
|
|
27
27
|
flag: '--type <domain>',
|
|
28
28
|
param: 'options.type',
|
|
29
|
-
choices: ['component', 'hook', 'doc', 'template'],
|
|
30
|
-
description: 'Filter to one domain (component|hook|doc|template)',
|
|
29
|
+
choices: ['component', 'hook', 'doc', 'template', 'theme'],
|
|
30
|
+
description: 'Filter to one domain (component|hook|doc|template|theme)',
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
33
|
flag: '--limit <n>',
|
|
@@ -49,6 +49,7 @@ export const doc = {
|
|
|
49
49
|
label: 'Filter + JSON',
|
|
50
50
|
cli: 'astryx search "data table" --type template --json',
|
|
51
51
|
},
|
|
52
|
+
{label: 'Themes you can add', cli: 'astryx search warm --type theme'},
|
|
52
53
|
],
|
|
53
54
|
exitCodes: [
|
|
54
55
|
{code: 0, when: 'success (including zero matches)'},
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* @file search command — unified ranked search with a stable result summary.
|
|
5
5
|
*
|
|
6
6
|
* One "I'm looking for X" entry point spanning components, hooks, docs topics,
|
|
7
|
-
*
|
|
8
|
-
* with their domain, with a follow-up command so the user knows what to
|
|
9
|
-
* next.
|
|
7
|
+
* templates (page + block), and themes. Results are ranked by relevance and
|
|
8
|
+
* tagged with their domain, with a follow-up command so the user knows what to
|
|
9
|
+
* run next.
|
|
10
10
|
*
|
|
11
11
|
* The command surface (description, args, flags) is sourced from the colocated
|
|
12
12
|
* `search.doc.mjs` CommandDoc via `defineCommand`; this file supplies only the
|
|
@@ -104,13 +104,13 @@ export function registerSearch(program) {
|
|
|
104
104
|
// ── Text output ──────────────────────────────────────────────
|
|
105
105
|
const run = getCliInvocation();
|
|
106
106
|
const {query: q, matchCount, results} = result.data;
|
|
107
|
-
// Outside an app an open search covers the docs alone. Say
|
|
108
|
-
//
|
|
107
|
+
// Outside an app an open search covers the docs and themes alone. Say
|
|
108
|
+
// so, so that list does not read as "Astryx has no such component".
|
|
109
109
|
const note =
|
|
110
110
|
!options.type && !findCoreDir(process.cwd())
|
|
111
111
|
? [
|
|
112
112
|
text(
|
|
113
|
-
'@astryxdesign/core is not installed here, so only the docs were searched.',
|
|
113
|
+
'@astryxdesign/core is not installed here, so only the docs and themes were searched.',
|
|
114
114
|
),
|
|
115
115
|
]
|
|
116
116
|
: [];
|
|
@@ -123,6 +123,7 @@ export function registerSearch(program) {
|
|
|
123
123
|
text(
|
|
124
124
|
`Try a broader term, or browse: ${run} ${note.length > 0 ? 'docs' : 'component --list'}`,
|
|
125
125
|
),
|
|
126
|
+
...discoverHint(run, q, options.type),
|
|
126
127
|
);
|
|
127
128
|
return answered;
|
|
128
129
|
}
|
|
@@ -174,11 +175,34 @@ export function registerSearch(program) {
|
|
|
174
175
|
format: {command: formatCliCommand, parent: formatCliCommand},
|
|
175
176
|
}),
|
|
176
177
|
...note,
|
|
178
|
+
...discoverHint(run, q, options.type),
|
|
177
179
|
);
|
|
178
180
|
return answered;
|
|
179
181
|
},
|
|
180
182
|
});
|
|
181
183
|
}
|
|
182
184
|
|
|
185
|
+
/**
|
|
186
|
+
* Search reads only what is installed. Point at `discover` for the packages
|
|
187
|
+
* that could add more, except for hooks, which no integration adds.
|
|
188
|
+
* @param {string} run - The caller's CLI invocation prefix.
|
|
189
|
+
* @param {string} query
|
|
190
|
+
* @param {string | undefined} type
|
|
191
|
+
*/
|
|
192
|
+
function discoverHint(run, query, type) {
|
|
193
|
+
if (type === 'hook') return [];
|
|
194
|
+
return [
|
|
195
|
+
text(`More in packages you could add: ${run} discover ${shellWord(query)}`),
|
|
196
|
+
];
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* One shell word: the value itself when it is plain, else single-quoted.
|
|
201
|
+
* @param {string} value
|
|
202
|
+
*/
|
|
203
|
+
function shellWord(value) {
|
|
204
|
+
return /^[\w@./:-]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\''`)}'`;
|
|
205
|
+
}
|
|
206
|
+
|
|
183
207
|
// Re-export the API for external consumers.
|
|
184
208
|
export {search, SEARCH_DOMAINS} from '../../../api/search/search.mjs';
|
|
@@ -118,6 +118,15 @@ describe('search() API — filters', () => {
|
|
|
118
118
|
}
|
|
119
119
|
});
|
|
120
120
|
|
|
121
|
+
it('--type theme returns only themes, each with the command that adds it', async () => {
|
|
122
|
+
const {data} = await search('warm', {...OPTS, type: 'theme'});
|
|
123
|
+
expect(data.results.map(r => r.name)).toContain('neutral');
|
|
124
|
+
for (const r of data.results) {
|
|
125
|
+
expect(r.domain).toBe('theme');
|
|
126
|
+
expect(r.command).toBe(`astryx theme add --import ${r.name}`);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
|
|
121
130
|
it('respects --limit', async () => {
|
|
122
131
|
const {data} = await search('button', {...OPTS, limit: 3});
|
|
123
132
|
expect(data.results.length).toBeLessThanOrEqual(3);
|
|
@@ -198,7 +207,9 @@ describe('search CLI — exit codes + JSON contract', () => {
|
|
|
198
207
|
expect(json.status).toBe(0);
|
|
199
208
|
const env = JSON.parse(json.stdout);
|
|
200
209
|
expect(env.data.query).toBe('dark mode');
|
|
201
|
-
|
|
210
|
+
// theme topic-level and section tie; either is correct
|
|
211
|
+
const top = env.data.results[0];
|
|
212
|
+
expect(top.name === 'theme' || top.name === 'use-a-theme' || top.section === 'light-dark-mode').toBe(true);
|
|
202
213
|
const text = await runCli(['search', 'dark', 'mode', '--type', 'doc'], REPO_ROOT);
|
|
203
214
|
expect(text.stdout).toContain('Results for "dark mode"');
|
|
204
215
|
}, SCAN_TIMEOUT);
|
|
@@ -279,22 +290,31 @@ describe('search CLI — exit codes + JSON contract', () => {
|
|
|
279
290
|
});
|
|
280
291
|
|
|
281
292
|
it('prints every result field under its JSON key (score and reason with --verbose)', async () => {
|
|
282
|
-
//
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
const
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
293
|
+
// Between them these reach every domain, so every per-domain field shows.
|
|
294
|
+
// A theme matches `theme` only through its description, a prose mention
|
|
295
|
+
// ranked below every name and keyword hit, so the theme domain comes from
|
|
296
|
+
// a theme's own name.
|
|
297
|
+
const domains = new Set();
|
|
298
|
+
for (const args of [
|
|
299
|
+
['search', 'theme', '--limit', '60'],
|
|
300
|
+
['search', 'neutral', '--type', 'theme'],
|
|
301
|
+
]) {
|
|
302
|
+
const env = JSON.parse((await runCli(['--json', ...args], REPO_ROOT)).stdout);
|
|
303
|
+
const plain = (await runCli(args, REPO_ROOT)).stdout.split('\n');
|
|
304
|
+
const verbose = (await runCli([...args, '--verbose'], REPO_ROOT)).stdout.split('\n');
|
|
305
|
+
for (const result of env.data.results) {
|
|
306
|
+
domains.add(result.domain);
|
|
307
|
+
for (const [key, value] of Object.entries(result)) {
|
|
308
|
+
if (value == null || value === '') continue;
|
|
309
|
+
const label = `${result.domain} ${result.name}: ${key}`;
|
|
310
|
+
expect(printsField(verbose, key, value), label).toBe(true);
|
|
311
|
+
if (key !== 'score' && key !== 'reason') {
|
|
312
|
+
expect(printsField(plain, key, value), label).toBe(true);
|
|
313
|
+
}
|
|
295
314
|
}
|
|
296
315
|
}
|
|
297
316
|
}
|
|
317
|
+
expect(domains).toEqual(new Set(SEARCH_DOMAINS));
|
|
298
318
|
}, 90_000);
|
|
299
319
|
|
|
300
320
|
it('--verbose exits 0 and prints import/match detail', async () => {
|
|
@@ -311,16 +331,42 @@ describe('search CLI — exit codes + JSON contract', () => {
|
|
|
311
331
|
expect(r.stdout).toContain('reason:');
|
|
312
332
|
});
|
|
313
333
|
|
|
314
|
-
it('
|
|
334
|
+
it('points at discover for packages that could add more, except for hooks', async () => {
|
|
335
|
+
const open = await runCli(['search', 'data', 'table'], REPO_ROOT);
|
|
336
|
+
expect(open.status).toBe(0);
|
|
337
|
+
expect(open.stdout).toMatch(/^More in packages you could add: .*discover 'data table'$/m);
|
|
338
|
+
const none = await runCli(['search', 'zzqqxxnomatch'], REPO_ROOT);
|
|
339
|
+
expect(none.stdout).toMatch(/^More in packages you could add: .*discover zzqqxxnomatch$/m);
|
|
340
|
+
const hooks = await runCli(['search', 'click', '--type', 'hook'], REPO_ROOT);
|
|
341
|
+
expect(hooks.status).toBe(0);
|
|
342
|
+
expect(hooks.stdout).not.toContain('More in packages you could add');
|
|
343
|
+
const json = await runCli(['--json', 'search', 'button'], REPO_ROOT);
|
|
344
|
+
expect(json.stdout).not.toContain('More in packages you could add');
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
it('searches the docs and themes when no @astryxdesign/core is reachable, and exits 1 for --type component', async () => {
|
|
315
348
|
const empty = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-search-cli-no-core-'));
|
|
316
349
|
try {
|
|
317
350
|
const open = await runCli(['--json', 'search', 'make', 'an', 'integration'], empty);
|
|
318
351
|
expect(open.status).toBe(0);
|
|
319
352
|
expect(JSON.parse(open.stdout).data.results[0]).toMatchObject({domain: 'doc'});
|
|
320
|
-
//
|
|
353
|
+
// Bundled themes need no project, so an open search finds them too.
|
|
354
|
+
const theme = await runCli(['--json', 'search', 'neutral'], empty);
|
|
355
|
+
expect(theme.status).toBe(0);
|
|
356
|
+
expect(JSON.parse(theme.stdout).data.results[0]).toMatchObject({
|
|
357
|
+
domain: 'theme',
|
|
358
|
+
name: 'neutral',
|
|
359
|
+
});
|
|
360
|
+
// The text says the search covered the docs and themes alone.
|
|
321
361
|
const text = await runCli(['search', 'button'], empty);
|
|
322
362
|
expect(text.status).toBe(0);
|
|
323
|
-
expect(text.stdout).toContain('only the docs were searched');
|
|
363
|
+
expect(text.stdout).toContain('only the docs and themes were searched');
|
|
364
|
+
// A themes-only search needs no core, like a docs-only one.
|
|
365
|
+
const themes = await runCli(['--json', 'search', 'warm', '--type', 'theme'], empty);
|
|
366
|
+
expect(themes.status).toBe(0);
|
|
367
|
+
const found = JSON.parse(themes.stdout).data.results;
|
|
368
|
+
expect(found.map(r => r.name)).toContain('neutral');
|
|
369
|
+
expect(found.every(r => r.domain === 'theme')).toBe(true);
|
|
324
370
|
const json = await runCli(['--json', 'search', 'button', '--type', 'component'], empty);
|
|
325
371
|
expect(json.status).toBe(1);
|
|
326
372
|
expect(JSON.parse(json.stdout)).toMatchObject({code: 'ERR_CORE_NOT_FOUND'});
|
|
@@ -17,7 +17,10 @@ export const doc = {
|
|
|
17
17
|
description:
|
|
18
18
|
"Ejects a component's source from the resolved @astryxdesign/core (or its owning " +
|
|
19
19
|
'integration) into your project for deep customization, rewriting imports that ' +
|
|
20
|
-
'escape the component directory. With no name it lists the swizzlable components.'
|
|
20
|
+
'escape the component directory. With no name it lists the swizzlable components. ' +
|
|
21
|
+
'An integration component that replaces a Core component is what that Core name ' +
|
|
22
|
+
'copies; --package @astryxdesign/core copies the original. --list lists Core ' +
|
|
23
|
+
'components, including one an integration replaces.',
|
|
21
24
|
fn: 'swizzle',
|
|
22
25
|
args: [{name: 'component', param: 'component', required: false}],
|
|
23
26
|
options: [
|
|
@@ -30,12 +33,14 @@ export const doc = {
|
|
|
30
33
|
{
|
|
31
34
|
flag: '--package <pkg>',
|
|
32
35
|
param: 'options.package',
|
|
33
|
-
description:
|
|
36
|
+
description:
|
|
37
|
+
'Scope to a specific owning package. Use @astryxdesign/core to copy an original replaced by an integration component',
|
|
34
38
|
},
|
|
35
39
|
{
|
|
36
40
|
flag: '--list',
|
|
37
41
|
param: 'options.list',
|
|
38
|
-
description:
|
|
42
|
+
description:
|
|
43
|
+
'List the swizzlable Core components, including any that an integration component replaces',
|
|
39
44
|
},
|
|
40
45
|
{
|
|
41
46
|
flag: '-f, --overwrite',
|
|
@@ -47,6 +52,10 @@ export const doc = {
|
|
|
47
52
|
examples: [
|
|
48
53
|
{label: 'List swizzlable components', cli: 'astryx swizzle --list'},
|
|
49
54
|
{label: 'Eject a component', cli: 'astryx swizzle Button'},
|
|
55
|
+
{
|
|
56
|
+
label: 'Copy a replaced Core original',
|
|
57
|
+
cli: 'astryx swizzle SideNav --package @astryxdesign/core',
|
|
58
|
+
},
|
|
50
59
|
],
|
|
51
60
|
exitCodes: [
|
|
52
61
|
{code: 0, when: 'success'},
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import {jsonOut} from '../../../foundation/response/json.mjs';
|
|
14
|
-
import {emit, section, list, text, WARN} from '../formatters/index.mjs';
|
|
14
|
+
import {emit, section, list, text, WARN, record} from '../formatters/index.mjs';
|
|
15
15
|
import {cliError} from '../lib/cli-error.mjs';
|
|
16
16
|
import {getCliInvocation} from '../../../foundation/env/package-manager.mjs';
|
|
17
17
|
import {swizzle as swizzleApi} from '../../../api/swizzle/swizzle.mjs';
|
|
@@ -60,6 +60,7 @@ export function registerSwizzle(program) {
|
|
|
60
60
|
if (result.type === 'swizzle.list') {
|
|
61
61
|
const components = result.data;
|
|
62
62
|
emit(
|
|
63
|
+
record({package: result.package}),
|
|
63
64
|
section('Available components'),
|
|
64
65
|
list(components),
|
|
65
66
|
text(`Usage: ${run} swizzle <component>`),
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file `astryx template <name> <path>` tells the caller, in JSON and in text,
|
|
5
|
+
* when demo media in the copied file was replaced with placeholders.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import {describe, it, expect, beforeEach, afterEach} from 'vitest';
|
|
9
|
+
import * as fs from 'node:fs';
|
|
10
|
+
import * as os from 'node:os';
|
|
11
|
+
import * as path from 'node:path';
|
|
12
|
+
import {runCli} from '../../../test-utils/run-cli.mjs';
|
|
13
|
+
import {discoverTemplates} from '../../../api/template/template.mjs';
|
|
14
|
+
|
|
15
|
+
const SLOW = 60_000;
|
|
16
|
+
|
|
17
|
+
/** A page template whose source carries demo media, and one that carries none. */
|
|
18
|
+
async function pickPages() {
|
|
19
|
+
const pages = /** @type {Array<{dirName: string, type: string, filePath: string}>} */ (
|
|
20
|
+
await discoverTemplates()
|
|
21
|
+
).filter(t => t.type === 'page' && fs.existsSync(t.filePath));
|
|
22
|
+
const hasMedia = (/** @type {{filePath: string}} */ t) =>
|
|
23
|
+
/\/template-assets\/[\w.-]+\.\w+/.test(fs.readFileSync(t.filePath, 'utf-8'));
|
|
24
|
+
const withMedia = pages.find(hasMedia);
|
|
25
|
+
const without = pages.find(t => !hasMedia(t));
|
|
26
|
+
if (!withMedia || !without) throw new Error('catalog lacks a page with and without demo media');
|
|
27
|
+
return {withMedia: withMedia.dirName, without: without.dirName};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
describe('template copy receipt discloses replaced demo media', () => {
|
|
31
|
+
let dir;
|
|
32
|
+
beforeEach(() => {
|
|
33
|
+
dir = fs.mkdtempSync(path.join(os.tmpdir(), 'tmpl-receipt-cli-'));
|
|
34
|
+
});
|
|
35
|
+
afterEach(() => fs.rmSync(dir, {recursive: true, force: true}));
|
|
36
|
+
|
|
37
|
+
it('--json carries demoMediaReplaced and the text states the same count', async () => {
|
|
38
|
+
const {withMedia} = await pickPages();
|
|
39
|
+
const json = await runCli(['template', withMedia, './a', '--json'], dir);
|
|
40
|
+
expect(json.status).toBe(0);
|
|
41
|
+
const {data} = JSON.parse(json.stdout);
|
|
42
|
+
expect(data.demoMediaReplaced).toBeGreaterThan(0);
|
|
43
|
+
|
|
44
|
+
const human = await runCli(['template', withMedia, './b'], dir);
|
|
45
|
+
expect(human.status).toBe(0);
|
|
46
|
+
expect(human.stdout).toContain(
|
|
47
|
+
`Replaced ${data.demoMediaReplaced} Astryx demo media reference`,
|
|
48
|
+
);
|
|
49
|
+
expect(human.stdout).toContain('b/page.tsx');
|
|
50
|
+
}, SLOW);
|
|
51
|
+
|
|
52
|
+
it('says nothing about media when none was replaced', async () => {
|
|
53
|
+
const {without} = await pickPages();
|
|
54
|
+
const json = await runCli(['template', without, './a', '--json'], dir);
|
|
55
|
+
expect(JSON.parse(json.stdout).data.demoMediaReplaced).toBe(0);
|
|
56
|
+
const human = await runCli(['template', without, './b'], dir);
|
|
57
|
+
expect(human.status).toBe(0);
|
|
58
|
+
expect(human.stdout).not.toMatch(/demo media/i);
|
|
59
|
+
}, SLOW);
|
|
60
|
+
});
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import {jsonOut} from '../../../foundation/response/json.mjs';
|
|
8
|
-
import {emit, section, text, records, code} from '../formatters/index.mjs';
|
|
8
|
+
import {emit, section, text, records, code, record} from '../formatters/index.mjs';
|
|
9
9
|
import {cliError} from '../lib/cli-error.mjs';
|
|
10
10
|
import {template as templateApi} from '../../../api/template/template.mjs';
|
|
11
11
|
import {Project} from '../../../foundation/config/project.mjs';
|
|
@@ -111,6 +111,52 @@ export function registerTemplate(program) {
|
|
|
111
111
|
case 'template.list': {
|
|
112
112
|
const pages = result.data.filter(t => t.type === 'page');
|
|
113
113
|
const blocks = result.data.filter(t => t.type === 'block');
|
|
114
|
+
|
|
115
|
+
// Bare `template` (no --list, no name) shows a grouped summary so a
|
|
116
|
+
// no-context agent or terminal doesn't receive 150 KB of catalog. The
|
|
117
|
+
// full catalog stays reachable via `template --list`.
|
|
118
|
+
if (!options.list && !name) {
|
|
119
|
+
/** @param {import('../../../api/template/template.type.mjs').TemplateListEntry[]} items */
|
|
120
|
+
const grouped = items => {
|
|
121
|
+
/** @type {Map<string, string[]>} */
|
|
122
|
+
const groups = new Map();
|
|
123
|
+
for (const t of items) {
|
|
124
|
+
const cat = t.category || 'Other';
|
|
125
|
+
const list = groups.get(cat);
|
|
126
|
+
if (list) {
|
|
127
|
+
list.push(t.id);
|
|
128
|
+
} else {
|
|
129
|
+
groups.set(cat, [t.id]);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/** @type {string[]} */
|
|
133
|
+
const lines = [];
|
|
134
|
+
for (const [cat, ids] of groups) {
|
|
135
|
+
lines.push(`${cat}: ${ids.join(', ')}`);
|
|
136
|
+
}
|
|
137
|
+
return lines.join('\n');
|
|
138
|
+
};
|
|
139
|
+
emit(
|
|
140
|
+
section(`Page Templates (${pages.length})`),
|
|
141
|
+
pages.length > 0 && text(grouped(pages)),
|
|
142
|
+
section(`Block Templates (${blocks.length})`),
|
|
143
|
+
blocks.length > 0 && text(grouped(blocks)),
|
|
144
|
+
section('Usage'),
|
|
145
|
+
text(
|
|
146
|
+
[
|
|
147
|
+
`${run} template <id> Show full source`,
|
|
148
|
+
`${run} template <id> [target-path] Scaffold page or block`,
|
|
149
|
+
`${run} template <id> --skeleton Layout reference`,
|
|
150
|
+
`${run} template --list Full catalog with descriptions`,
|
|
151
|
+
`${run} template --list --type block List only blocks`,
|
|
152
|
+
`${run} template --list --package <pkg> List from one package`,
|
|
153
|
+
`${run} template --cdn CDN starter page, no build step`,
|
|
154
|
+
].join('\n'),
|
|
155
|
+
),
|
|
156
|
+
);
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
|
|
114
160
|
// Project each entry to its JSON-mirroring fields; the WIP marker is
|
|
115
161
|
// folded into `name` (as before) and the package is shown only when it
|
|
116
162
|
// isn't the built-in core package.
|
|
@@ -146,6 +192,7 @@ export function registerTemplate(program) {
|
|
|
146
192
|
case 'template.skeleton': {
|
|
147
193
|
const {template: tName, description, components, skeleton} = result.data;
|
|
148
194
|
emit(
|
|
195
|
+
record({package: result.package}),
|
|
149
196
|
text(
|
|
150
197
|
`# ${tName}${description ? ' — ' + description : ''}\n` +
|
|
151
198
|
`# Components: ${components.join(', ')}`,
|
|
@@ -156,16 +203,33 @@ export function registerTemplate(program) {
|
|
|
156
203
|
}
|
|
157
204
|
|
|
158
205
|
case 'template.show': {
|
|
159
|
-
// Source must survive piping byte-for-byte
|
|
160
|
-
|
|
206
|
+
// Source must survive piping byte-for-byte, so the package it comes
|
|
207
|
+
// from (cli-surface INV28) and the note about replaced demo media go
|
|
208
|
+
// to stderr, the note in the copy receipt's words. (Text mode only:
|
|
209
|
+
// --json returned above with both in the envelope.)
|
|
210
|
+
const {source, demoMediaReplaced} = result.data;
|
|
211
|
+
console.error(`package: ${result.package}`);
|
|
212
|
+
emit(code(source));
|
|
213
|
+
if (demoMediaReplaced > 0) {
|
|
214
|
+
console.error(
|
|
215
|
+
`Replaced ${demoMediaReplaced} Astryx demo media reference${demoMediaReplaced === 1 ? '' : 's'}: ` +
|
|
216
|
+
'images now show a neutral placeholder and videos have an empty source. Supply your own media there.',
|
|
217
|
+
);
|
|
218
|
+
}
|
|
161
219
|
break;
|
|
162
220
|
}
|
|
163
221
|
|
|
164
222
|
case 'template.copy': {
|
|
223
|
+
const {outputDir, fileName, demoMediaReplaced} = result.data;
|
|
224
|
+
const file = `${outputDir}/${fileName}`;
|
|
165
225
|
emit(
|
|
166
|
-
text(
|
|
167
|
-
|
|
168
|
-
|
|
226
|
+
text(`Copied template to ${file}`),
|
|
227
|
+
record({package: result.package}),
|
|
228
|
+
demoMediaReplaced > 0 &&
|
|
229
|
+
text(
|
|
230
|
+
`Replaced ${demoMediaReplaced} Astryx demo media reference${demoMediaReplaced === 1 ? '' : 's'} in ${file}: ` +
|
|
231
|
+
'images now show a neutral placeholder and videos have an empty source. Supply your own media there.',
|
|
232
|
+
),
|
|
169
233
|
);
|
|
170
234
|
break;
|
|
171
235
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file `astryx template <name>` says how many demo media references it
|
|
5
|
+
* replaced: in `--json` as `demoMediaReplaced`, and in text on stderr, so that
|
|
6
|
+
* stdout stays exactly the source a copy writes and can be piped into a file.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {describe, it, expect, beforeAll, afterAll} from 'vitest';
|
|
10
|
+
import * as fs from 'node:fs';
|
|
11
|
+
import * as os from 'node:os';
|
|
12
|
+
import * as path from 'node:path';
|
|
13
|
+
import {runCli} from '../../../test-utils/run-cli.mjs';
|
|
14
|
+
import {discoverTemplates} from '../../../api/template/template.mjs';
|
|
15
|
+
|
|
16
|
+
const SLOW = 60_000;
|
|
17
|
+
|
|
18
|
+
/** A page template whose source carries demo media, and one that carries none. */
|
|
19
|
+
async function pickPages() {
|
|
20
|
+
const pages = /** @type {Array<{dirName: string, type: string, filePath: string}>} */ (
|
|
21
|
+
await discoverTemplates()
|
|
22
|
+
).filter(t => t.type === 'page' && fs.existsSync(t.filePath));
|
|
23
|
+
const hasMedia = (/** @type {{filePath: string}} */ t) =>
|
|
24
|
+
/\/template-assets\/[\w.-]+\.\w+/.test(fs.readFileSync(t.filePath, 'utf-8'));
|
|
25
|
+
const withMedia = pages.find(hasMedia);
|
|
26
|
+
const without = pages.find(t => !hasMedia(t));
|
|
27
|
+
if (!withMedia || !without) throw new Error('catalog lacks a page with and without demo media');
|
|
28
|
+
return {withMedia: withMedia.dirName, without: without.dirName};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
describe('template show discloses replaced demo media', () => {
|
|
32
|
+
/** @type {string} */
|
|
33
|
+
let dir;
|
|
34
|
+
beforeAll(() => {
|
|
35
|
+
dir = fs.mkdtempSync(path.join(os.tmpdir(), 'tmpl-show-cli-'));
|
|
36
|
+
});
|
|
37
|
+
afterAll(() => fs.rmSync(dir, {recursive: true, force: true}));
|
|
38
|
+
|
|
39
|
+
it('--json carries demoMediaReplaced, and text states it on stderr with stdout left as the source', async () => {
|
|
40
|
+
const {withMedia} = await pickPages();
|
|
41
|
+
const json = await runCli(['template', withMedia, '--type', 'page', '--json'], dir);
|
|
42
|
+
expect(json.status).toBe(0);
|
|
43
|
+
const {data} = JSON.parse(json.stdout);
|
|
44
|
+
expect(data.demoMediaReplaced).toBeGreaterThan(0);
|
|
45
|
+
|
|
46
|
+
const human = await runCli(['template', withMedia, '--type', 'page'], dir);
|
|
47
|
+
expect(human.status).toBe(0);
|
|
48
|
+
expect(human.stdout.trimEnd()).toBe(data.source.trimEnd());
|
|
49
|
+
expect(human.stderr).toContain(
|
|
50
|
+
`Replaced ${data.demoMediaReplaced} Astryx demo media reference`,
|
|
51
|
+
);
|
|
52
|
+
}, SLOW);
|
|
53
|
+
|
|
54
|
+
it('says nothing about media when none was replaced', async () => {
|
|
55
|
+
const {without} = await pickPages();
|
|
56
|
+
const json = await runCli(['template', without, '--type', 'page', '--json'], dir);
|
|
57
|
+
expect(JSON.parse(json.stdout).data.demoMediaReplaced).toBe(0);
|
|
58
|
+
const human = await runCli(['template', without, '--type', 'page'], dir);
|
|
59
|
+
expect(human.status).toBe(0);
|
|
60
|
+
expect(human.stderr).not.toMatch(/demo media/i);
|
|
61
|
+
}, SLOW);
|
|
62
|
+
});
|
|
@@ -35,6 +35,17 @@ import {runCli} from '../../../test-utils/run-cli.mjs';
|
|
|
35
35
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
36
36
|
const REPO_ROOT = path.resolve(__dirname, '../../../../..');
|
|
37
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Response types whose text output is the artifact's source, printed byte for
|
|
40
|
+
* byte so it can be piped (spec cli-surface INV28). Their JSON still names the
|
|
41
|
+
* package; their text does not.
|
|
42
|
+
*/
|
|
43
|
+
const VERBATIM_TYPES = new Set([
|
|
44
|
+
'component.detail.source',
|
|
45
|
+
'component.detail.showcase',
|
|
46
|
+
'template.show',
|
|
47
|
+
]);
|
|
48
|
+
|
|
38
49
|
// ─── Helpers ────────────────────────────────────────────────────────────────
|
|
39
50
|
|
|
40
51
|
/**
|
|
@@ -438,6 +449,24 @@ const CASES = [
|
|
|
438
449
|
// Themes are rendered as list items, not records.
|
|
439
450
|
skipFieldChecks: true,
|
|
440
451
|
},
|
|
452
|
+
{
|
|
453
|
+
name: 'theme remove',
|
|
454
|
+
args: ['theme', 'remove', 'does-not-exist'],
|
|
455
|
+
errorExpected: true,
|
|
456
|
+
skipFieldChecks: true,
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
name: 'theme use',
|
|
460
|
+
args: ['theme', 'use', 'does-not-exist'],
|
|
461
|
+
errorExpected: true,
|
|
462
|
+
skipFieldChecks: true,
|
|
463
|
+
},
|
|
464
|
+
{
|
|
465
|
+
name: 'theme eject',
|
|
466
|
+
args: ['theme', 'eject', 'does-not-exist'],
|
|
467
|
+
errorExpected: true,
|
|
468
|
+
skipFieldChecks: true,
|
|
469
|
+
},
|
|
441
470
|
{
|
|
442
471
|
name: 'theme build',
|
|
443
472
|
args: ['theme', 'build', 'nonexistent.ts'],
|
|
@@ -561,6 +590,15 @@ describe('text-json-parity', () => {
|
|
|
561
590
|
expect(run.textStatus).toBe(run.jsonStatus);
|
|
562
591
|
});
|
|
563
592
|
|
|
593
|
+
// spec cli-surface INV28: text names the package the envelope names.
|
|
594
|
+
// Verbatim source output prints only the source, so a pipe gets the
|
|
595
|
+
// file byte for byte.
|
|
596
|
+
it('text names the package the JSON envelope names', () => {
|
|
597
|
+
if (run.json?.package === undefined) return;
|
|
598
|
+
if (VERBATIM_TYPES.has(run.json.type)) return;
|
|
599
|
+
expect(run.text).toContain(run.json.package);
|
|
600
|
+
});
|
|
601
|
+
|
|
564
602
|
if (!tc.skipFieldChecks && !tc.errorExpected) {
|
|
565
603
|
it('every text record key exists in the JSON data', () => {
|
|
566
604
|
if (!run.json?.data) return;
|
|
@@ -569,6 +607,8 @@ describe('text-json-parity', () => {
|
|
|
569
607
|
if (run.json.meta) {
|
|
570
608
|
for (const k of jsonLeafKeys(run.json.meta)) jsonKeys.add(k);
|
|
571
609
|
}
|
|
610
|
+
// The envelope's own `package` (spec cli-surface INV28) is JSON too.
|
|
611
|
+
if (run.json.package !== undefined) jsonKeys.add('package');
|
|
572
612
|
const violations = [];
|
|
573
613
|
for (const key of textKeys.keys()) {
|
|
574
614
|
if (!jsonKeys.has(key)) {
|