@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
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/** @file Compatibility and deprecation coverage for the two-step theme-add lifecycle. */
|
|
4
|
+
|
|
5
|
+
import {afterEach, beforeEach, describe, expect, it} from 'vitest';
|
|
6
|
+
import * as fs from 'node:fs';
|
|
7
|
+
import * as os from 'node:os';
|
|
8
|
+
import * as path from 'node:path';
|
|
9
|
+
import {runCli} from '../../../test-utils/run-cli.mjs';
|
|
10
|
+
|
|
11
|
+
let tmpDir;
|
|
12
|
+
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-theme-add-cli-'));
|
|
15
|
+
fs.mkdirSync(path.join(tmpDir, 'src'));
|
|
16
|
+
fs.writeFileSync(
|
|
17
|
+
path.join(tmpDir, 'package.json'),
|
|
18
|
+
JSON.stringify({name: 'app', private: true}),
|
|
19
|
+
);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
afterEach(() => {
|
|
23
|
+
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
describe('theme add compatibility lifecycle', () => {
|
|
27
|
+
it('keeps copy stdout and emits one text-only deprecation warning', async () => {
|
|
28
|
+
const result = await runCli(['theme', 'add', 'neutral'], tmpDir);
|
|
29
|
+
|
|
30
|
+
expect(result.status, result.stderr).toBe(0);
|
|
31
|
+
expect(result.stdout).toContain(
|
|
32
|
+
'[ok] Added Neutral theme from @astryxdesign/cli to src/themes/neutral/',
|
|
33
|
+
);
|
|
34
|
+
expect(result.stdout).toContain('This is your copy of the Neutral theme');
|
|
35
|
+
expect(result.stderr.match(/source copying is deprecated/g)).toHaveLength(
|
|
36
|
+
1,
|
|
37
|
+
);
|
|
38
|
+
expect(result.stderr).toContain('pnpm exec astryx theme eject neutral');
|
|
39
|
+
expect(result.stderr).toContain(
|
|
40
|
+
'pnpm exec astryx theme add neutral --import',
|
|
41
|
+
);
|
|
42
|
+
expect(fs.existsSync(path.join(tmpDir, 'src/themes/neutral'))).toBe(true);
|
|
43
|
+
expect(fs.existsSync(path.join(tmpDir, 'src/astryx-themes.ts'))).toBe(
|
|
44
|
+
false,
|
|
45
|
+
);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('keeps theme.add data and adds machine-readable deprecation metadata', async () => {
|
|
49
|
+
const result = await runCli(['theme', 'add', 'neutral', '--json'], tmpDir);
|
|
50
|
+
|
|
51
|
+
expect(result.status, result.stderr).toBe(0);
|
|
52
|
+
expect(result.stderr).not.toContain('source copying is deprecated');
|
|
53
|
+
expect(JSON.parse(result.stdout)).toMatchObject({
|
|
54
|
+
type: 'theme.add',
|
|
55
|
+
data: {
|
|
56
|
+
slug: 'neutral',
|
|
57
|
+
package: '@astryxdesign/cli',
|
|
58
|
+
outputDir: 'src/themes/neutral',
|
|
59
|
+
},
|
|
60
|
+
meta: {
|
|
61
|
+
deprecations: [
|
|
62
|
+
{
|
|
63
|
+
id: 'DEP-0005',
|
|
64
|
+
replacements: ['theme eject', 'theme add --import'],
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('keeps the list JSON unchanged and names the stage commands in text', async () => {
|
|
72
|
+
fs.mkdirSync(path.join(tmpDir, 'src/themes/broken'), {recursive: true});
|
|
73
|
+
fs.writeFileSync(
|
|
74
|
+
path.join(tmpDir, 'src/themes/broken/brokenTheme.ts'),
|
|
75
|
+
'export const brokenTheme = {};\n',
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const textResult = await runCli(['theme', 'add', '--list'], tmpDir);
|
|
79
|
+
expect(textResult.status, textResult.stderr).toBe(0);
|
|
80
|
+
expect(textResult.stdout).toContain(
|
|
81
|
+
'Import one: pnpm exec astryx theme add <slug> --import [--package <package>]',
|
|
82
|
+
);
|
|
83
|
+
expect(textResult.stdout).toContain(
|
|
84
|
+
'Fork source: pnpm exec astryx theme eject <slug> [target-path]',
|
|
85
|
+
);
|
|
86
|
+
expect(textResult.stdout).not.toContain('theme add <slug> [target-path]');
|
|
87
|
+
expect(textResult.stderr).not.toContain('deprecated');
|
|
88
|
+
|
|
89
|
+
const result = await runCli(['theme', 'add', '--list', '--json'], tmpDir);
|
|
90
|
+
|
|
91
|
+
expect(result.status, result.stderr).toBe(0);
|
|
92
|
+
const payload = JSON.parse(result.stdout);
|
|
93
|
+
expect(payload).toMatchObject({type: 'theme.list'});
|
|
94
|
+
expect(payload.meta).toBeUndefined();
|
|
95
|
+
expect(payload.data.some(theme => theme.slug === 'broken')).toBe(false);
|
|
96
|
+
expect(Object.keys(payload.data[0]).sort()).toEqual([
|
|
97
|
+
'description',
|
|
98
|
+
'displayName',
|
|
99
|
+
'maintained',
|
|
100
|
+
'package',
|
|
101
|
+
'slug',
|
|
102
|
+
]);
|
|
103
|
+
expect(result.stderr).not.toContain('deprecated');
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it.each([
|
|
107
|
+
['target path', ['src/brand']],
|
|
108
|
+
['overwrite', ['--overwrite']],
|
|
109
|
+
])('rejects --import with a %s before writing', async (_label, extra) => {
|
|
110
|
+
const result = await runCli(
|
|
111
|
+
['theme', 'add', 'neutral', '--import', ...extra, '--json'],
|
|
112
|
+
tmpDir,
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
expect(result.status).not.toBe(0);
|
|
116
|
+
expect(JSON.parse(result.stdout)).toMatchObject({
|
|
117
|
+
code: 'ERR_THEME_INVALID',
|
|
118
|
+
error: expect.stringContaining('cannot be combined'),
|
|
119
|
+
});
|
|
120
|
+
expect(fs.existsSync(path.join(tmpDir, 'src/astryx-themes.ts'))).toBe(
|
|
121
|
+
false,
|
|
122
|
+
);
|
|
123
|
+
expect(fs.existsSync(path.join(tmpDir, 'src/brand'))).toBe(false);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('lists --import in help', async () => {
|
|
127
|
+
const result = await runCli(['theme', 'add', '--help'], tmpDir);
|
|
128
|
+
|
|
129
|
+
expect(result.status, result.stderr).toBe(0);
|
|
130
|
+
expect(result.stdout).toContain('--import');
|
|
131
|
+
});
|
|
132
|
+
});
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* @file CommandDoc for `astryx theme add`. The terminal binding of the
|
|
5
|
-
* `themeAdd()` function (referenced via `fn`); its args/flags map to that
|
|
6
|
-
* function's params so a converter can build Commander config + --help from one
|
|
7
|
-
* source of truth.
|
|
8
|
-
* @position packages/cli/clients/cli/commands — command documentation
|
|
9
|
-
*/
|
|
3
|
+
/** @file CommandDoc for `astryx theme add`. */
|
|
10
4
|
|
|
11
5
|
/** @type {import('@astryxdesign/cli/authoring').CommandDoc} */
|
|
12
6
|
export const doc = {
|
|
@@ -14,11 +8,9 @@ export const doc = {
|
|
|
14
8
|
name: 'theme add',
|
|
15
9
|
displayName: 'astryx theme add',
|
|
16
10
|
namespace: 'cli/commands',
|
|
17
|
-
summary: '
|
|
11
|
+
summary: 'Copy a theme, or import its built output into the app',
|
|
18
12
|
description:
|
|
19
|
-
|
|
20
|
-
'Writes are staged then renamed, rolling back on failure. Running it with no slug, or with ' +
|
|
21
|
-
'--list, lists available themes; use --package when more than one owner provides the slug.',
|
|
13
|
+
'With --import, records the theme in the generated app module and imports its built module and stylesheets. Without --import, keeps the released source-copy behavior, emits one text warning, and adds meta.deprecations with DEP-0005 and the theme eject/theme add --import replacements to JSON. A bare command or --list delegates to themeListCopySources() so the released list fields stay unchanged; use --package when owners share a slug.',
|
|
22
14
|
fn: 'themeAdd',
|
|
23
15
|
args: [
|
|
24
16
|
{name: 'slug', param: 'slug', required: false},
|
|
@@ -28,10 +20,15 @@ export const doc = {
|
|
|
28
20
|
{
|
|
29
21
|
flag: '-f, --overwrite',
|
|
30
22
|
param: 'options.overwrite',
|
|
31
|
-
description:
|
|
32
|
-
'Replace existing files. Without it, existing files fail the command with ERR_FILE_EXISTS and nothing is written',
|
|
23
|
+
description: 'Replace copied files. Cannot be combined with --import',
|
|
33
24
|
},
|
|
34
25
|
{flag: '--list', description: 'List available themes'},
|
|
26
|
+
{
|
|
27
|
+
flag: '--import',
|
|
28
|
+
param: 'options.import',
|
|
29
|
+
description:
|
|
30
|
+
'Use the built theme through the generated app module instead of copying source',
|
|
31
|
+
},
|
|
35
32
|
{
|
|
36
33
|
flag: '--package <package>',
|
|
37
34
|
param: 'options.package',
|
|
@@ -39,18 +36,21 @@ export const doc = {
|
|
|
39
36
|
},
|
|
40
37
|
],
|
|
41
38
|
examples: [
|
|
42
|
-
{label: 'Scaffold a theme', cli: 'astryx theme add matcha'},
|
|
43
39
|
{
|
|
44
|
-
label: '
|
|
45
|
-
cli: 'astryx theme add ocean --
|
|
40
|
+
label: 'Import a built theme into the app',
|
|
41
|
+
cli: 'astryx theme add ocean --import',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
label: 'Select a package theme over a local theme',
|
|
45
|
+
cli: 'astryx theme add ocean --import --package @acme/themes',
|
|
46
46
|
},
|
|
47
47
|
],
|
|
48
48
|
exitCodes: [
|
|
49
|
-
{code: 0, when: '
|
|
49
|
+
{code: 0, when: 'the theme is listed, copied, or imported'},
|
|
50
50
|
{
|
|
51
51
|
code: 1,
|
|
52
|
-
when: '
|
|
52
|
+
when: 'the theme, its source or built imports, its record, the target path, or the option combination is invalid',
|
|
53
53
|
},
|
|
54
54
|
],
|
|
55
|
-
related: ['theme list', 'theme
|
|
55
|
+
related: ['theme list', 'theme remove', 'theme use', 'theme eject'],
|
|
56
56
|
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/** @file CommandDoc for `astryx theme eject`. */
|
|
4
|
+
|
|
5
|
+
/** @type {import('@astryxdesign/cli/authoring').CommandDoc} */
|
|
6
|
+
export const doc = {
|
|
7
|
+
type: 'command',
|
|
8
|
+
name: 'theme eject',
|
|
9
|
+
displayName: 'astryx theme eject',
|
|
10
|
+
namespace: 'cli/commands',
|
|
11
|
+
summary: 'Fork a theme as editable local source',
|
|
12
|
+
description:
|
|
13
|
+
"Copies a bundled or installed package theme's complete source into the local themes root, including a local descriptor. Writes are atomic. Existing files require --overwrite. Use --package when package themes share a slug.",
|
|
14
|
+
fn: 'themeEject',
|
|
15
|
+
args: [
|
|
16
|
+
{name: 'slug', param: 'slug', required: true},
|
|
17
|
+
{name: 'path', param: 'options.targetPath', required: false},
|
|
18
|
+
],
|
|
19
|
+
options: [
|
|
20
|
+
{
|
|
21
|
+
flag: '-f, --overwrite',
|
|
22
|
+
param: 'options.overwrite',
|
|
23
|
+
description:
|
|
24
|
+
'Replace existing files. Without it, an existing file fails with ERR_FILE_EXISTS and nothing is written',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
flag: '--package <package>',
|
|
28
|
+
param: 'options.package',
|
|
29
|
+
description: 'Select the package that owns the theme',
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
examples: [
|
|
33
|
+
{label: 'Fork a theme into the local root', cli: 'astryx theme eject ocean'},
|
|
34
|
+
{
|
|
35
|
+
label: 'Fork one package theme elsewhere',
|
|
36
|
+
cli: 'astryx theme eject ocean src/themes/my-ocean --package @acme/themes',
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
exitCodes: [
|
|
40
|
+
{code: 0, when: 'all source and descriptor files are written'},
|
|
41
|
+
{
|
|
42
|
+
code: 1,
|
|
43
|
+
when: 'the theme is unknown or ambiguous, a path escapes, a source file is missing, or a destination exists',
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
related: ['theme add', 'theme build', 'theme list'],
|
|
47
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file CLI behavior for `astryx theme list`.
|
|
5
|
+
*
|
|
6
|
+
* `theme list` shows the themes this project can add now. Themes in packages
|
|
7
|
+
* it has not installed are `discover`'s, so the list ends by pointing there:
|
|
8
|
+
* an agent that never learns `discover` exists searches the registry instead.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import {describe, it, expect, beforeEach, afterEach} from 'vitest';
|
|
12
|
+
import * as fs from 'node:fs';
|
|
13
|
+
import * as path from 'node:path';
|
|
14
|
+
import * as os from 'node:os';
|
|
15
|
+
import {runCli} from '../../../test-utils/run-cli.mjs';
|
|
16
|
+
|
|
17
|
+
let tmpDir;
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-cli-theme-list-'));
|
|
20
|
+
});
|
|
21
|
+
afterEach(() => {
|
|
22
|
+
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
describe('astryx theme list', () => {
|
|
26
|
+
it('lists bundled themes and points at import, eject, and discover', async () => {
|
|
27
|
+
const {status, stdout} = await runCli(['theme', 'list'], {cwd: tmpDir});
|
|
28
|
+
|
|
29
|
+
expect(status).toBe(0);
|
|
30
|
+
expect(stdout).toMatch(/^slug:\s+neutral$/m);
|
|
31
|
+
expect(stdout).toMatch(/^package:\s+@astryxdesign\/cli$/m);
|
|
32
|
+
expect(stdout).toMatch(/Import one: .*theme add <slug> --import/m);
|
|
33
|
+
expect(stdout).toMatch(/Fork source: .*theme eject <slug>/m);
|
|
34
|
+
expect(stdout).toMatch(/More themes in packages you could add: .*discover theme$/m);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('keeps the JSON envelope free of the hint', async () => {
|
|
38
|
+
const {status, stdout} = await runCli(['--json', 'theme', 'list'], {cwd: tmpDir});
|
|
39
|
+
|
|
40
|
+
expect(status).toBe(0);
|
|
41
|
+
expect(stdout).not.toContain('discover');
|
|
42
|
+
expect(JSON.parse(stdout).type).toBe('theme.list');
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -16,8 +16,8 @@ export const doc = {
|
|
|
16
16
|
namespace: 'cli/commands',
|
|
17
17
|
summary: 'List themes available to add',
|
|
18
18
|
description:
|
|
19
|
-
'Lists
|
|
20
|
-
'
|
|
19
|
+
'Lists bundled, package, and local themes with their owner, source, added state, and default state. ' +
|
|
20
|
+
'Earlier descriptor-less copies are not listed as themes; the receipt names them with the upgrade command.',
|
|
21
21
|
fn: 'themeListAvailable',
|
|
22
22
|
options: [
|
|
23
23
|
{
|
|
@@ -21,8 +21,7 @@ export const doc = {
|
|
|
21
21
|
'JSON is also supported. Existing author-owned files are left untouched unless --overwrite is explicit. ' +
|
|
22
22
|
'When used in a theme integration, keep the palette request under the theme slug, ' +
|
|
23
23
|
'write the candidate and receipt under that same slug, import the candidate from the theme source, ' +
|
|
24
|
-
'and keep all three inside the theme directory
|
|
25
|
-
'directory into the consumer project, so nothing else has to list them.',
|
|
24
|
+
'and keep all three inside the theme directory. The package ships that directory as one source unit for discovery and explicit eject, while apps use its built exports.',
|
|
26
25
|
fn: 'themePaletteGenerate',
|
|
27
26
|
args: [{name: 'config', param: 'configPath', required: true}],
|
|
28
27
|
options: [
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/** @file CommandDoc for `astryx theme remove`. */
|
|
4
|
+
|
|
5
|
+
/** @type {import('@astryxdesign/cli/authoring').CommandDoc} */
|
|
6
|
+
export const doc = {
|
|
7
|
+
type: 'command',
|
|
8
|
+
name: 'theme remove',
|
|
9
|
+
displayName: 'astryx theme remove',
|
|
10
|
+
namespace: 'cli/commands',
|
|
11
|
+
summary: 'Remove a non-default theme from the app',
|
|
12
|
+
description:
|
|
13
|
+
'Removes one added theme from the generated module and regenerates the whole module. Choose another default with theme use before removing the current default.',
|
|
14
|
+
fn: 'themeRemove',
|
|
15
|
+
args: [{name: 'slug', param: 'slug', required: true}],
|
|
16
|
+
examples: [{label: 'Remove an added theme', cli: 'astryx theme remove ocean'}],
|
|
17
|
+
exitCodes: [
|
|
18
|
+
{code: 0, when: 'the module is regenerated without the theme'},
|
|
19
|
+
{code: 1, when: 'the theme is not added, is the default, or state is invalid'},
|
|
20
|
+
],
|
|
21
|
+
related: ['theme add', 'theme use', 'theme list'],
|
|
22
|
+
};
|
|
@@ -19,8 +19,9 @@ export const doc = {
|
|
|
19
19
|
'Writes theme.template.ts: the annotated reference for the whole theme surface, covering every ' +
|
|
20
20
|
'defineTheme field, the token families, the component override syntax, and how a theme is ' +
|
|
21
21
|
'consumed, naming the CLI command that prints the authoritative reference for each. Read ' +
|
|
22
|
-
'it, copy what you need into your own theme file, delete it. Use `theme add <slug
|
|
23
|
-
'
|
|
22
|
+
'it, copy what you need into your own theme file, delete it. Use `theme add <slug> --import` to ' +
|
|
23
|
+
'use an installed built theme, extend that theme for ordinary customization, or use ' +
|
|
24
|
+
'`theme eject <slug>` for a complete source fork. Leaves an existing file untouched unless --overwrite.',
|
|
24
25
|
fn: 'themeTemplate',
|
|
25
26
|
args: [{name: 'path', param: 'options.targetPath', required: false}],
|
|
26
27
|
options: [
|
|
@@ -38,5 +39,5 @@ export const doc = {
|
|
|
38
39
|
{code: 0, when: 'success, including when an existing file was left untouched'},
|
|
39
40
|
{code: 1, when: 'the target path escapes the project, or the file cannot be written'},
|
|
40
41
|
],
|
|
41
|
-
related: ['theme add', 'theme list', 'theme build'],
|
|
42
|
+
related: ['theme add', 'theme eject', 'theme list', 'theme build'],
|
|
42
43
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/** @file CommandDoc for `astryx theme use`. */
|
|
4
|
+
|
|
5
|
+
/** @type {import('@astryxdesign/cli/authoring').CommandDoc} */
|
|
6
|
+
export const doc = {
|
|
7
|
+
type: 'command',
|
|
8
|
+
name: 'theme use',
|
|
9
|
+
displayName: 'astryx theme use',
|
|
10
|
+
namespace: 'cli/commands',
|
|
11
|
+
summary: 'Choose the app default from its added themes',
|
|
12
|
+
description:
|
|
13
|
+
'Sets one added slug as the default and regenerates the generated theme module. Add the theme first if it is not already in the app.',
|
|
14
|
+
fn: 'themeUse',
|
|
15
|
+
args: [{name: 'slug', param: 'slug', required: true}],
|
|
16
|
+
examples: [{label: 'Choose the default theme', cli: 'astryx theme use ocean'}],
|
|
17
|
+
exitCodes: [
|
|
18
|
+
{code: 0, when: 'the module is regenerated with the selected default'},
|
|
19
|
+
{code: 1, when: 'the theme is not added or state is invalid'},
|
|
20
|
+
],
|
|
21
|
+
related: ['theme add', 'theme remove', 'theme list'],
|
|
22
|
+
};
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @file CommandDoc for the `astryx theme` command group.
|
|
5
|
-
*
|
|
6
|
-
* carry the actual args, flags, and wrapped functions.
|
|
7
|
-
* @position packages/cli/clients/cli/commands — command documentation
|
|
4
|
+
* @file CommandDoc for the `astryx theme` command group. It is a real group,
|
|
5
|
+
* not a compatibility alias. Its subcommands own the work.
|
|
8
6
|
*/
|
|
9
7
|
|
|
10
8
|
/** @type {import('@astryxdesign/cli/authoring').CommandDoc} */
|
|
@@ -13,18 +11,25 @@ export const doc = {
|
|
|
13
11
|
name: 'theme',
|
|
14
12
|
displayName: 'astryx theme',
|
|
15
13
|
namespace: 'cli/commands',
|
|
16
|
-
summary:
|
|
17
|
-
'Create and build themes: add a shipped one, compile to CSS, or list what a theme can override',
|
|
14
|
+
summary: 'Add, switch, build, and author themes',
|
|
18
15
|
description:
|
|
19
|
-
'The theme command group.
|
|
20
|
-
|
|
21
|
-
'
|
|
22
|
-
'list
|
|
23
|
-
'
|
|
24
|
-
|
|
16
|
+
'The theme command group. Import built themes into an app, choose its default, remove them, list available and added themes, or eject source to make a local fork. Plain theme add still copies source while that default is deprecated. The authoring commands build themes, generate palettes, write the annotated template, and list component theme targets.',
|
|
17
|
+
subcommands: [
|
|
18
|
+
'build',
|
|
19
|
+
'list',
|
|
20
|
+
'add',
|
|
21
|
+
'remove',
|
|
22
|
+
'use',
|
|
23
|
+
'eject',
|
|
24
|
+
'template',
|
|
25
|
+
'palette',
|
|
26
|
+
'targets',
|
|
27
|
+
],
|
|
25
28
|
examples: [
|
|
26
|
-
{label: 'List available themes', cli: 'astryx theme list'},
|
|
27
|
-
{label: '
|
|
29
|
+
{label: 'List available and added themes', cli: 'astryx theme list'},
|
|
30
|
+
{label: 'Import a theme into the app', cli: 'astryx theme add ocean --import'},
|
|
31
|
+
{label: 'Choose the default', cli: 'astryx theme use ocean'},
|
|
32
|
+
{label: 'Fork source to customize', cli: 'astryx theme eject ocean'},
|
|
28
33
|
{
|
|
29
34
|
label: 'Generate a palette candidate',
|
|
30
35
|
cli: 'astryx theme palette generate palette.config.json',
|
|
@@ -32,8 +37,8 @@ export const doc = {
|
|
|
32
37
|
{label: 'See what a theme can override', cli: 'astryx theme targets'},
|
|
33
38
|
],
|
|
34
39
|
exitCodes: [
|
|
35
|
-
{code: 0, when: '
|
|
36
|
-
{code: 1, when: 'an unknown subcommand'},
|
|
40
|
+
{code: 0, when: 'help is shown or a subcommand succeeds'},
|
|
41
|
+
{code: 1, when: 'an unknown subcommand or a subcommand failure'},
|
|
37
42
|
],
|
|
38
43
|
related: ['init'],
|
|
39
44
|
};
|
|
@@ -84,4 +84,18 @@ describe('upgrade human output is ASCII', () => {
|
|
|
84
84
|
'minSize: 200',
|
|
85
85
|
);
|
|
86
86
|
});
|
|
87
|
+
|
|
88
|
+
// Every fixture above has a real src/, so the completion line for a project
|
|
89
|
+
// whose source is somewhere else was never reached — this suite was green on
|
|
90
|
+
// that path by luck, not by coverage.
|
|
91
|
+
it('reports a source directory that does not exist', async () => {
|
|
92
|
+
fs.rmSync(path.join(tmpDir, 'src'), {recursive: true, force: true});
|
|
93
|
+
fs.mkdirSync(path.join(tmpDir, 'app'), {recursive: true});
|
|
94
|
+
write('app/panel.tsx', 'export const x = 1;\n');
|
|
95
|
+
|
|
96
|
+
expect(await nonAsciiLines(['upgrade', '--from', '0.5.0'])).toEqual([]);
|
|
97
|
+
expect(
|
|
98
|
+
await nonAsciiLines(['upgrade', '--from', '0.5.0', '--apply']),
|
|
99
|
+
).toEqual([]);
|
|
100
|
+
});
|
|
87
101
|
});
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file A write that fails on the filesystem reports ERR_WRITE_FAILED.
|
|
5
|
+
*
|
|
6
|
+
* An unwritable target produced `{"error": "EACCES: permission denied, open
|
|
7
|
+
* '/abs/host/path/readonly/x.tsx'", "code": "ERR_UNKNOWN"}` — the raw Node
|
|
8
|
+
* errno error, with the wrong code and an absolute host path in the message.
|
|
9
|
+
* ERR_WRITE_FAILED is in the frozen registry for exactly this case, and every
|
|
10
|
+
* other Astryx message names its target relative to the project.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import {describe, it, expect, beforeEach, afterEach} from 'vitest';
|
|
14
|
+
import * as fs from 'node:fs';
|
|
15
|
+
import * as os from 'node:os';
|
|
16
|
+
import * as path from 'node:path';
|
|
17
|
+
import {fileURLToPath} from 'node:url';
|
|
18
|
+
import {runCli} from '../../../test-utils/run-cli.mjs';
|
|
19
|
+
|
|
20
|
+
const REPO = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../..');
|
|
21
|
+
|
|
22
|
+
// chmod means nothing to root, so the unwritable directory would be writable
|
|
23
|
+
// and the command would succeed. Skip rather than assert something false.
|
|
24
|
+
const asRoot = typeof process.getuid === 'function' && process.getuid() === 0;
|
|
25
|
+
|
|
26
|
+
let dir;
|
|
27
|
+
let readonlyDir;
|
|
28
|
+
|
|
29
|
+
beforeEach(() => {
|
|
30
|
+
dir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-write-fail-'));
|
|
31
|
+
fs.writeFileSync(
|
|
32
|
+
path.join(dir, 'package.json'),
|
|
33
|
+
JSON.stringify({
|
|
34
|
+
name: 'scratch',
|
|
35
|
+
version: '1.0.0',
|
|
36
|
+
dependencies: {'@astryxdesign/core': '0.6.3'},
|
|
37
|
+
}),
|
|
38
|
+
);
|
|
39
|
+
fs.mkdirSync(path.join(dir, 'node_modules', '@astryxdesign'), {recursive: true});
|
|
40
|
+
fs.symlinkSync(
|
|
41
|
+
path.join(REPO, 'packages', 'core'),
|
|
42
|
+
path.join(dir, 'node_modules', '@astryxdesign', 'core'),
|
|
43
|
+
'dir',
|
|
44
|
+
);
|
|
45
|
+
readonlyDir = path.join(dir, 'readonly');
|
|
46
|
+
fs.mkdirSync(readonlyDir);
|
|
47
|
+
fs.chmodSync(readonlyDir, 0o500);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
afterEach(() => {
|
|
51
|
+
try {
|
|
52
|
+
fs.chmodSync(readonlyDir, 0o700);
|
|
53
|
+
} catch {
|
|
54
|
+
// already gone
|
|
55
|
+
}
|
|
56
|
+
fs.rmSync(dir, {recursive: true, force: true});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
/** @param {string[]} args */
|
|
60
|
+
const json = async args => {
|
|
61
|
+
const {status, stdout} = await runCli(['--json', ...args], {cwd: dir});
|
|
62
|
+
return {status, body: JSON.parse(stdout)};
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
describe.skipIf(asRoot)('a failed write reports ERR_WRITE_FAILED', () => {
|
|
66
|
+
it('template into an unwritable directory', async () => {
|
|
67
|
+
const {status, body} = await json(['template', 'ai-chat', 'readonly/x.tsx']);
|
|
68
|
+
|
|
69
|
+
expect(status).toBe(1);
|
|
70
|
+
expect(body.code).toBe('ERR_WRITE_FAILED');
|
|
71
|
+
expect(body.error).toContain('readonly/x.tsx');
|
|
72
|
+
expect(body.error).toContain('EACCES');
|
|
73
|
+
// The whole point of the relative form: no absolute host path escapes.
|
|
74
|
+
expect(body.error).not.toContain(dir);
|
|
75
|
+
expect(fs.existsSync(path.join(readonlyDir, 'x.tsx'))).toBe(false);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('swizzle into an unwritable directory', async () => {
|
|
79
|
+
const {status, body} = await json([
|
|
80
|
+
'swizzle',
|
|
81
|
+
'Button',
|
|
82
|
+
'--output',
|
|
83
|
+
'readonly/sub',
|
|
84
|
+
]);
|
|
85
|
+
|
|
86
|
+
expect(status).toBe(1);
|
|
87
|
+
expect(body.code).toBe('ERR_WRITE_FAILED');
|
|
88
|
+
expect(body.error).toContain('readonly/sub');
|
|
89
|
+
expect(body.error).not.toContain(dir);
|
|
90
|
+
expect(fs.existsSync(path.join(readonlyDir, 'sub'))).toBe(false);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('still writes normally into a writable directory', async () => {
|
|
94
|
+
const {status, body} = await json(['template', 'ai-chat', 'src/page.tsx']);
|
|
95
|
+
|
|
96
|
+
expect(status, JSON.stringify(body).slice(0, 200)).toBe(0);
|
|
97
|
+
expect(body.type).toBe('template.copy');
|
|
98
|
+
expect(fs.existsSync(path.join(dir, 'src', 'page.tsx'))).toBe(true);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
describe.skipIf(asRoot)('a swizzle that fails part-way undoes what it wrote', () => {
|
|
103
|
+
it('restores replaced files, removes created ones, and says nothing was written', async () => {
|
|
104
|
+
// Learn the component's files, in copy order, from a successful swizzle.
|
|
105
|
+
const probe = await json(['swizzle', 'Button', '--output', 'probe']);
|
|
106
|
+
expect(probe.status, JSON.stringify(probe.body).slice(0, 200)).toBe(0);
|
|
107
|
+
const files = probe.body.data.files;
|
|
108
|
+
expect(files.length).toBeGreaterThan(1);
|
|
109
|
+
const outDir = path.join(dir, 'out', path.basename(probe.body.data.outputDir));
|
|
110
|
+
|
|
111
|
+
// The first file exists (replaceable), the middle ones do not, and the
|
|
112
|
+
// last one is read-only, so --overwrite fails after writing the others.
|
|
113
|
+
const first = files[0];
|
|
114
|
+
const middle = files.slice(1, -1);
|
|
115
|
+
const last = files[files.length - 1];
|
|
116
|
+
fs.mkdirSync(outDir, {recursive: true});
|
|
117
|
+
fs.writeFileSync(path.join(outDir, first), 'before first\n');
|
|
118
|
+
fs.writeFileSync(path.join(outDir, last), 'before last\n');
|
|
119
|
+
fs.chmodSync(path.join(outDir, last), 0o444);
|
|
120
|
+
|
|
121
|
+
const {status, body} = await json([
|
|
122
|
+
'swizzle',
|
|
123
|
+
'Button',
|
|
124
|
+
'--output',
|
|
125
|
+
'out',
|
|
126
|
+
'--overwrite',
|
|
127
|
+
]);
|
|
128
|
+
fs.chmodSync(path.join(outDir, last), 0o644);
|
|
129
|
+
|
|
130
|
+
expect(status).toBe(1);
|
|
131
|
+
expect(body.code).toBe('ERR_WRITE_FAILED');
|
|
132
|
+
expect(body.error).toContain(last);
|
|
133
|
+
expect(body.error).toContain('Nothing was written.');
|
|
134
|
+
expect(body.error).not.toContain(dir);
|
|
135
|
+
expect(fs.readFileSync(path.join(outDir, first), 'utf8')).toBe('before first\n');
|
|
136
|
+
expect(fs.readFileSync(path.join(outDir, last), 'utf8')).toBe('before last\n');
|
|
137
|
+
for (const file of middle) {
|
|
138
|
+
expect(fs.existsSync(path.join(outDir, file))).toBe(false);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('undoes the copy when a destination cannot be read back', async () => {
|
|
143
|
+
const probe = await json(['swizzle', 'Button', '--output', 'probe']);
|
|
144
|
+
expect(probe.status, JSON.stringify(probe.body).slice(0, 200)).toBe(0);
|
|
145
|
+
const files = probe.body.data.files;
|
|
146
|
+
const outDir = path.join(dir, 'out', path.basename(probe.body.data.outputDir));
|
|
147
|
+
|
|
148
|
+
// A directory where the last file goes: the rollback snapshot cannot read
|
|
149
|
+
// it, and the earlier files are already written when the copy reaches it.
|
|
150
|
+
const first = files[0];
|
|
151
|
+
const middle = files.slice(1, -1);
|
|
152
|
+
const last = files[files.length - 1];
|
|
153
|
+
fs.mkdirSync(path.join(outDir, last), {recursive: true});
|
|
154
|
+
fs.writeFileSync(path.join(outDir, first), 'before first\n');
|
|
155
|
+
|
|
156
|
+
const {status, body} = await json([
|
|
157
|
+
'swizzle',
|
|
158
|
+
'Button',
|
|
159
|
+
'--output',
|
|
160
|
+
'out',
|
|
161
|
+
'--overwrite',
|
|
162
|
+
]);
|
|
163
|
+
|
|
164
|
+
expect(status).toBe(1);
|
|
165
|
+
expect(body.code).toBe('ERR_WRITE_FAILED');
|
|
166
|
+
expect(body.error).toContain(last);
|
|
167
|
+
expect(body.error).toContain('Nothing was written.');
|
|
168
|
+
expect(body.error).not.toContain(dir);
|
|
169
|
+
expect(fs.readFileSync(path.join(outDir, first), 'utf8')).toBe('before first\n');
|
|
170
|
+
expect(fs.statSync(path.join(outDir, last)).isDirectory()).toBe(true);
|
|
171
|
+
for (const file of middle) {
|
|
172
|
+
expect(fs.existsSync(path.join(outDir, file))).toBe(false);
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
});
|