@astryxdesign/cli 0.6.5 → 0.6.6-canary.11a80dd
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 +91 -88
- package/api/build/_adapter.d.mts +70 -2
- package/api/build/_adapter.mjs +122 -10
- package/api/build/build.doc.mjs +3 -3
- package/api/build/build.test.mjs +111 -2
- package/api/build/build.type.d.mts +12 -0
- package/api/build/build.type.mjs +3 -0
- package/api/build/help/help.mjs +1 -1
- package/api/build/kit/kit.mjs +110 -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 +50 -0
- package/api/doctor/_adapter.mjs +190 -0
- package/api/doctor/doctor.d.mts +0 -10
- package/api/doctor/doctor.doc.mjs +1 -3
- package/api/doctor/doctor.mjs +8 -123
- package/api/doctor/theme-checks.d.mts +24 -0
- package/api/doctor/theme-checks.mjs +1231 -0
- package/api/doctor/theme-checks.test.mjs +667 -0
- package/api/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 +11 -11
- package/api/integration/__fixtures__/released-0.6.5-ocean.d.mts +14 -0
- package/api/integration/__fixtures__/released-0.6.5-ocean.mjs +15 -0
- package/api/integration/add-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/check/check.d.mts +1 -0
- package/api/layout/check/check.mjs +1 -0
- package/api/layout/expand/expand.d.mts +1 -0
- package/api/layout/expand/expand.mjs +13 -7
- package/api/layout/expand/expand.receipt.test.mjs +74 -0
- package/api/layout/grammar/grammar.d.mts +1 -0
- package/api/layout/grammar/grammar.mjs +1 -0
- package/api/layout/layout.type.d.mts +1 -0
- package/api/layout/layout.type.mjs +1 -0
- package/api/layout/layoutCheck.doc.mjs +1 -1
- package/api/layout/layoutExpand.doc.mjs +2 -2
- package/api/layout/layoutGrammar.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 +27 -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 +17 -0
- package/api/template/template.type.mjs +8 -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 +120 -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 +667 -195
- package/api/theme/build/build.project-core.test.mjs +165 -0
- package/api/theme/build/build.test.mjs +220 -1
- package/api/theme/build/font-warning.d.mts +11 -0
- package/api/theme/build/font-warning.mjs +28 -3
- 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 +166 -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-overview.doc.mjs +211 -0
- 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 +52 -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 +212 -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/page.tsx +1 -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 +11 -0
- package/authoring/integration/integration.doc.mjs +1 -1
- package/clients/cli/commands/blog.mjs +3 -3
- package/clients/cli/commands/build-theme.adaptations.test.mjs +1 -1
- package/clients/cli/commands/build-theme.ascii-output.test.mjs +11 -1
- package/clients/cli/commands/build-theme.batch-report.test.mjs +335 -0
- package/clients/cli/commands/build-theme.font-warning.test.mjs +36 -7
- package/clients/cli/commands/build-theme.import-path.test.mjs +3 -3
- package/clients/cli/commands/build-theme.mjs +346 -47
- package/clients/cli/commands/build-theme.watch.test.mjs +33 -0
- package/clients/cli/commands/build.mjs +8 -6
- package/clients/cli/commands/build.text-fields.test.mjs +1 -1
- package/clients/cli/commands/component/index.mjs +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 +383 -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 +26 -52
- 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 +28 -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 +2 -0
- package/clients/cli/commands/layout-expand.doc.mjs +5 -1
- package/clients/cli/commands/layout-grammar.doc.mjs +2 -0
- package/clients/cli/commands/layout.deprecation-lifecycle.test.mjs +140 -0
- package/clients/cli/commands/layout.doc.mjs +2 -0
- package/clients/cli/commands/layout.expand-receipt.test.mjs +94 -0
- package/clients/cli/commands/layout.mjs +56 -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 +69 -19
- package/clients/cli/commands/swizzle.doc.mjs +12 -3
- package/clients/cli/commands/swizzle.mjs +2 -1
- package/clients/cli/commands/swizzle.routing.test.mjs +2 -1
- package/clients/cli/commands/template.copy-receipt.test.mjs +60 -0
- package/clients/cli/commands/template.mjs +71 -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 +135 -0
- package/clients/cli/commands/theme-add.doc.mjs +19 -19
- package/clients/cli/commands/theme-build.doc.mjs +3 -1
- package/clients/cli/commands/theme-eject.doc.mjs +47 -0
- package/clients/cli/commands/theme-list.behavior.test.mjs +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.config-ordering.test.mjs +2 -1
- package/clients/cli/commands/upgrade.mjs +1 -1
- package/clients/cli/commands/write-failure.test.mjs +175 -0
- package/clients/cli/index.mjs +5 -2
- package/clients/cli/lib/component-format.mjs +19 -2
- package/clients/cli/lib/component-format.test.mjs +1 -1
- package/clients/cli/lib/define-command.mjs +4 -0
- 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 +34 -28
- package/foundation/agent-docs/agent-docs.test.mjs +1181 -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/template-needs.d.mts +31 -0
- package/foundation/discovery/template-needs.mjs +156 -0
- package/foundation/discovery/template-needs.test.mjs +203 -0
- package/foundation/discovery/theme-discovery.d.mts +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/env/package-manager.d.mts +28 -8
- package/foundation/env/package-manager.mjs +49 -10
- package/foundation/env/package-manager.test.mjs +93 -1
- package/foundation/fs/module-loader.d.mts +9 -0
- package/foundation/fs/module-loader.mjs +71 -2
- package/foundation/integrations/cli-requirement.d.mts +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 +52 -37
- 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
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* The domain a search result belongs to.
|
|
6
6
|
*/
|
|
7
|
-
export type SearchDomain = "component" | "hook" | "doc" | "template";
|
|
7
|
+
export type SearchDomain = "component" | "hook" | "doc" | "template" | "theme";
|
|
8
8
|
/**
|
|
9
9
|
* A single ranked search result, tagged with its domain.
|
|
10
10
|
*/
|
|
@@ -14,7 +14,7 @@ export type SearchResultEntry = {
|
|
|
14
14
|
*/
|
|
15
15
|
domain: SearchDomain;
|
|
16
16
|
/**
|
|
17
|
-
* - Primary identifier (component/hook name, doc topic or docs-tree route, template dir).
|
|
17
|
+
* - Primary identifier (component/hook name, doc topic or docs-tree route, template dir, theme slug).
|
|
18
18
|
*/
|
|
19
19
|
name: string;
|
|
20
20
|
/**
|
|
@@ -30,7 +30,7 @@ export type SearchResultEntry = {
|
|
|
30
30
|
*/
|
|
31
31
|
description: string;
|
|
32
32
|
/**
|
|
33
|
-
* - Follow-up command to act on this result (e.g. `astryx component Button`).
|
|
33
|
+
* - Follow-up command to act on this result (e.g. `astryx component Button`, or `astryx theme add --import neutral` for a theme).
|
|
34
34
|
*/
|
|
35
35
|
command: string;
|
|
36
36
|
/**
|
|
@@ -46,15 +46,15 @@ export type SearchResultEntry = {
|
|
|
46
46
|
*/
|
|
47
47
|
section?: string | undefined;
|
|
48
48
|
/**
|
|
49
|
-
* - The npm package that
|
|
49
|
+
* - The npm package that owns the result: `@astryxdesign/core` for a Core component, hook, or template, `@astryxdesign/cli` for a doc the CLI ships, or the integration package that contributed it. For a doc section, the package whose file the section came from.
|
|
50
50
|
*/
|
|
51
|
-
package
|
|
51
|
+
package: string;
|
|
52
52
|
/**
|
|
53
53
|
* - Command that opens the level above a doc result — its topic's section list for a section, the docs-tree namespace it sits in for a tree node — so a reader can see the siblings and open another.
|
|
54
54
|
*/
|
|
55
55
|
parent?: string | undefined;
|
|
56
56
|
/**
|
|
57
|
-
* - Friendly display name — present for template results.
|
|
57
|
+
* - Friendly display name — present for template and theme results.
|
|
58
58
|
*/
|
|
59
59
|
displayName?: string | undefined;
|
|
60
60
|
/**
|
|
@@ -9,24 +9,24 @@
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* The domain a search result belongs to.
|
|
12
|
-
* @typedef {'component' | 'hook' | 'doc' | 'template'} SearchDomain
|
|
12
|
+
* @typedef {'component' | 'hook' | 'doc' | 'template' | 'theme'} SearchDomain
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* A single ranked search result, tagged with its domain.
|
|
17
17
|
* @typedef {object} SearchResultEntry
|
|
18
18
|
* @property {SearchDomain} domain - Which content domain this result came from.
|
|
19
|
-
* @property {string} name - Primary identifier (component/hook name, doc topic or docs-tree route, template dir).
|
|
19
|
+
* @property {string} name - Primary identifier (component/hook name, doc topic or docs-tree route, template dir, theme slug).
|
|
20
20
|
* @property {number} score - Relevance score (higher is better).
|
|
21
21
|
* @property {string} reason - Human-readable reason the candidate matched (e.g. `keyword "button"`).
|
|
22
22
|
* @property {string} description - One-line description, when available.
|
|
23
|
-
* @property {string} command - Follow-up command to act on this result (e.g. `astryx component Button`).
|
|
23
|
+
* @property {string} command - Follow-up command to act on this result (e.g. `astryx component Button`, or `astryx theme add --import neutral` for a theme).
|
|
24
24
|
* @property {string} [import] - Import path — present for component and hook results.
|
|
25
25
|
* @property {string} [title] - Doc title — present for doc results.
|
|
26
26
|
* @property {string} [section] - Section key — present when a doc result is one section of a topic; `command` reads only that section.
|
|
27
|
-
* @property {string}
|
|
27
|
+
* @property {string} package - The npm package that owns the result: `@astryxdesign/core` for a Core component, hook, or template, `@astryxdesign/cli` for a doc the CLI ships, or the integration package that contributed it. For a doc section, the package whose file the section came from.
|
|
28
28
|
* @property {string} [parent] - Command that opens the level above a doc result — its topic's section list for a section, the docs-tree namespace it sits in for a tree node — so a reader can see the siblings and open another.
|
|
29
|
-
* @property {string} [displayName] - Friendly display name — present for template results.
|
|
29
|
+
* @property {string} [displayName] - Friendly display name — present for template and theme results.
|
|
30
30
|
* @property {'page' | 'block'} [kind] - Template kind (`page` | `block`) — present for template results.
|
|
31
31
|
*/
|
|
32
32
|
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
// @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* The integration component that replaces the Core component `name`
|
|
6
|
+
* (spec:AST-035 FR11), or undefined when none does.
|
|
7
|
+
* @param {string} coreDir
|
|
8
|
+
* @param {import('../../foundation/integrations/integrations.mjs').LoadedIntegration[]} loadedIntegrations
|
|
9
|
+
* @param {string} name
|
|
10
|
+
* @returns {Promise<import('../../foundation/discovery/component-replacement.mjs').ActiveComponentReplacement | undefined>}
|
|
11
|
+
*/
|
|
12
|
+
export function resolveComponentReplacement(coreDir: string, loadedIntegrations: import("../../foundation/integrations/integrations.mjs").LoadedIntegration[], name: string): Promise<import("../../foundation/discovery/component-replacement.mjs").ActiveComponentReplacement | undefined>;
|
|
4
13
|
/**
|
|
5
14
|
* Locate @astryxdesign/core for `cwd` and list its swizzlable components.
|
|
6
15
|
* @param {string} cwd
|
|
@@ -10,3 +19,4 @@ export function resolveCore(cwd: string): {
|
|
|
10
19
|
coreDir: string;
|
|
11
20
|
components: string[];
|
|
12
21
|
};
|
|
22
|
+
export { CORE_PROVIDER_ID as CORE_PACKAGE } from "../../foundation/identity/providers.mjs";
|
package/api/swizzle/_adapter.mjs
CHANGED
|
@@ -12,9 +12,32 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import {findCoreDir, listComponents} from '../../foundation/fs/paths.mjs';
|
|
15
|
+
import {resolveComponentReplacements} from '../../foundation/discovery/component-replacement.mjs';
|
|
15
16
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
16
17
|
import {AstryxError} from '../error.mjs';
|
|
17
18
|
|
|
19
|
+
/** The package that owns Core's components, hooks, and codemods. */
|
|
20
|
+
export {CORE_PROVIDER_ID as CORE_PACKAGE} from '../../foundation/identity/providers.mjs';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The integration component that replaces the Core component `name`
|
|
24
|
+
* (spec:AST-035 FR11), or undefined when none does.
|
|
25
|
+
* @param {string} coreDir
|
|
26
|
+
* @param {import('../../foundation/integrations/integrations.mjs').LoadedIntegration[]} loadedIntegrations
|
|
27
|
+
* @param {string} name
|
|
28
|
+
* @returns {Promise<import('../../foundation/discovery/component-replacement.mjs').ActiveComponentReplacement | undefined>}
|
|
29
|
+
*/
|
|
30
|
+
export async function resolveComponentReplacement(
|
|
31
|
+
coreDir,
|
|
32
|
+
loadedIntegrations,
|
|
33
|
+
name,
|
|
34
|
+
) {
|
|
35
|
+
if (loadedIntegrations.length === 0) return undefined;
|
|
36
|
+
return (
|
|
37
|
+
await resolveComponentReplacements(coreDir, loadedIntegrations)
|
|
38
|
+
).forTarget(name);
|
|
39
|
+
}
|
|
40
|
+
|
|
18
41
|
/**
|
|
19
42
|
* Locate @astryxdesign/core for `cwd` and list its swizzlable components.
|
|
20
43
|
* @param {string} cwd
|
|
@@ -17,12 +17,11 @@
|
|
|
17
17
|
* - Asset files (`.json`, `.css`): exported by full subpath (e.g.
|
|
18
18
|
* `./locales/*.json`, `./reset.css`), and collapsing a two-levels-up
|
|
19
19
|
* `../../locales/x.json` would emit the invalid `<pkg>/..`.
|
|
20
|
-
* -
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* keep the barrel collapse.
|
|
20
|
+
* - StyleX modules (`*.stylex`): the StyleX compiler needs the real module
|
|
21
|
+
* path so it can resolve the styles at compile time. The barrel re-export
|
|
22
|
+
* loses the module identity. Core exports every `.stylex` file by its
|
|
23
|
+
* deep subpath (e.g. `./utils/focusOutline.stylex`,
|
|
24
|
+
* `./theme/tokens.stylex`).
|
|
26
25
|
*
|
|
27
26
|
* @param {string} content
|
|
28
27
|
* @param {string} [ownerPackage]
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
import * as fs from 'node:fs';
|
|
17
17
|
import * as path from 'node:path';
|
|
18
|
-
import {resolveCore} from '../_adapter.mjs';
|
|
18
|
+
import {resolveComponentReplacement, resolveCore} from '../_adapter.mjs';
|
|
19
19
|
import {assertWithin, sanitizeName, PathSafetyError} from '../../../foundation/fs/path-safety.mjs';
|
|
20
20
|
import {checkGhCli} from '../_github.mjs';
|
|
21
21
|
import {Project} from '../../../foundation/config/project.mjs';
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
findIntegrationComponentSource,
|
|
26
26
|
} from '../../../foundation/discovery/component-discovery.mjs';
|
|
27
27
|
import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
|
|
28
|
-
import {AstryxError} from '../../error.mjs';
|
|
28
|
+
import {AstryxError, writeFailed} from '../../error.mjs';
|
|
29
29
|
|
|
30
30
|
/** Default issue tracker for maintainer feedback after swizzling. */
|
|
31
31
|
const DEFAULT_ISSUES_URL = 'https://github.com/facebook/astryx/issues/new';
|
|
@@ -46,12 +46,11 @@ const DEFAULT_ISSUES_URL = 'https://github.com/facebook/astryx/issues/new';
|
|
|
46
46
|
* - Asset files (`.json`, `.css`): exported by full subpath (e.g.
|
|
47
47
|
* `./locales/*.json`, `./reset.css`), and collapsing a two-levels-up
|
|
48
48
|
* `../../locales/x.json` would emit the invalid `<pkg>/..`.
|
|
49
|
-
* -
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* keep the barrel collapse.
|
|
49
|
+
* - StyleX modules (`*.stylex`): the StyleX compiler needs the real module
|
|
50
|
+
* path so it can resolve the styles at compile time. The barrel re-export
|
|
51
|
+
* loses the module identity. Core exports every `.stylex` file by its
|
|
52
|
+
* deep subpath (e.g. `./utils/focusOutline.stylex`,
|
|
53
|
+
* `./theme/tokens.stylex`).
|
|
55
54
|
*
|
|
56
55
|
* @param {string} content
|
|
57
56
|
* @param {string} [ownerPackage]
|
|
@@ -67,8 +66,8 @@ export function rewriteImports(content, ownerPackage = CORE_PACKAGE) {
|
|
|
67
66
|
if (/\.(?:json|css)$/.test(last)) {
|
|
68
67
|
return `${ownerPackage}/${rest}`;
|
|
69
68
|
}
|
|
70
|
-
//
|
|
71
|
-
if (
|
|
69
|
+
// StyleX modules need the deep path so the compiler can resolve them.
|
|
70
|
+
if (/\.stylex(?:\.[cm]?[jt]sx?)?$/.test(last)) {
|
|
72
71
|
return `${ownerPackage}/${rest}`;
|
|
73
72
|
}
|
|
74
73
|
return `${ownerPackage}/${parts[0]}`;
|
|
@@ -221,6 +220,26 @@ export async function swizzleCopy(component, options = {}) {
|
|
|
221
220
|
const coreIssuesUrl = project
|
|
222
221
|
? project.issuesUrl({package: CORE_PACKAGE})
|
|
223
222
|
: undefined;
|
|
223
|
+
// An active integration replacement answers to the Core name it replaces,
|
|
224
|
+
// bare or qualified by its own package (spec:AST-035 FR11): copy it under its
|
|
225
|
+
// own name. `--package @astryxdesign/core` still copies the Core original.
|
|
226
|
+
if (pkg !== CORE_PACKAGE) {
|
|
227
|
+
const replacement = await resolveComponentReplacement(
|
|
228
|
+
coreDir,
|
|
229
|
+
loadedIntegrations,
|
|
230
|
+
dirName,
|
|
231
|
+
);
|
|
232
|
+
if (
|
|
233
|
+
replacement &&
|
|
234
|
+
(!pkg || (pkg === replacement.package && replacement.name !== dirName))
|
|
235
|
+
) {
|
|
236
|
+
return swizzleCopy(replacement.name, {
|
|
237
|
+
...options,
|
|
238
|
+
package: replacement.package,
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
224
243
|
const allOwners = resolveOwners(coreDir, loadedIntegrations, dirName, coreIssuesUrl);
|
|
225
244
|
|
|
226
245
|
if (allOwners.length === 0) {
|
|
@@ -290,11 +309,21 @@ export async function swizzleCopy(component, options = {}) {
|
|
|
290
309
|
);
|
|
291
310
|
}
|
|
292
311
|
|
|
293
|
-
fs.
|
|
312
|
+
const outputDirExisted = fs.existsSync(outputDir);
|
|
313
|
+
try {
|
|
314
|
+
fs.mkdirSync(outputDir, {recursive: true});
|
|
315
|
+
} catch (err) {
|
|
316
|
+
throw writeFailed(outputDir, cwd, err);
|
|
317
|
+
}
|
|
294
318
|
|
|
295
319
|
const files = fs.readdirSync(componentDir);
|
|
296
320
|
let copied = 0;
|
|
297
321
|
let usesStyleX = false;
|
|
322
|
+
// A copy that fails part-way undoes what it already wrote, so the report is
|
|
323
|
+
// true and a retry does not trip over half a component. Each entry keeps
|
|
324
|
+
// the bytes the file had before this run (null when the copy created it).
|
|
325
|
+
/** @type {Array<{dest: string, original: Buffer|null}>} */
|
|
326
|
+
const written = [];
|
|
298
327
|
for (const file of files) {
|
|
299
328
|
if (isExcludedFromCopy(file)) continue;
|
|
300
329
|
const srcPath = path.join(componentDir, file);
|
|
@@ -309,7 +338,25 @@ export async function swizzleCopy(component, options = {}) {
|
|
|
309
338
|
) {
|
|
310
339
|
usesStyleX = true;
|
|
311
340
|
}
|
|
312
|
-
|
|
341
|
+
const dest = path.join(outputDir, file);
|
|
342
|
+
try {
|
|
343
|
+
// The snapshot read is guarded too: a destination that cannot be read
|
|
344
|
+
// back (no permission, or a directory with this name) must still undo
|
|
345
|
+
// the earlier writes and report ERR_WRITE_FAILED.
|
|
346
|
+
const original = fs.existsSync(dest) ? fs.readFileSync(dest) : null;
|
|
347
|
+
written.push({dest, original});
|
|
348
|
+
fs.writeFileSync(dest, content);
|
|
349
|
+
} catch (err) {
|
|
350
|
+
const unrestored = undoCopy(written);
|
|
351
|
+
if (!outputDirExisted) {
|
|
352
|
+
try {
|
|
353
|
+
fs.rmdirSync(outputDir);
|
|
354
|
+
} catch {
|
|
355
|
+
// Not empty (something could not be undone), or already gone.
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
throw writeFailed(dest, cwd, err, unrestored);
|
|
359
|
+
}
|
|
313
360
|
copied++;
|
|
314
361
|
}
|
|
315
362
|
|
|
@@ -331,5 +378,40 @@ export async function swizzleCopy(component, options = {}) {
|
|
|
331
378
|
usesStyleX,
|
|
332
379
|
};
|
|
333
380
|
if (feedback) data.feedback = feedback;
|
|
334
|
-
return {type: 'swizzle.copy', data};
|
|
381
|
+
return {type: 'swizzle.copy', package: data.package, data};
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Undo the writes of a copy that failed part-way, newest first: delete the
|
|
386
|
+
* files the copy created and put back the bytes of the files it replaced. A
|
|
387
|
+
* file whose bytes are already the original ones is left alone, so a write
|
|
388
|
+
* that failed before changing anything is not reported as unrestored.
|
|
389
|
+
*
|
|
390
|
+
* @param {Array<{dest: string, original: Buffer|null}>} written
|
|
391
|
+
* @returns {string[]} the files it could not restore
|
|
392
|
+
*/
|
|
393
|
+
function undoCopy(written) {
|
|
394
|
+
/** @type {string[]} */
|
|
395
|
+
const unrestored = [];
|
|
396
|
+
for (const {dest, original} of [...written].reverse()) {
|
|
397
|
+
try {
|
|
398
|
+
if (original == null) {
|
|
399
|
+
fs.rmSync(dest, {force: true});
|
|
400
|
+
continue;
|
|
401
|
+
}
|
|
402
|
+
/** @type {Buffer|null} */
|
|
403
|
+
let current = null;
|
|
404
|
+
try {
|
|
405
|
+
current = fs.readFileSync(dest);
|
|
406
|
+
} catch {
|
|
407
|
+
current = null;
|
|
408
|
+
}
|
|
409
|
+
if (current == null || !current.equals(original)) {
|
|
410
|
+
fs.writeFileSync(dest, original);
|
|
411
|
+
}
|
|
412
|
+
} catch {
|
|
413
|
+
unrestored.push(dest);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
return unrestored;
|
|
335
417
|
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* shared seam. All human prose / usage hints live in the CLI renderer.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import {resolveCore} from '../_adapter.mjs';
|
|
11
|
+
import {CORE_PACKAGE, resolveCore} from '../_adapter.mjs';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* List swizzlable components discoverable from `cwd`'s @astryxdesign/core.
|
|
@@ -17,5 +17,5 @@ import {resolveCore} from '../_adapter.mjs';
|
|
|
17
17
|
*/
|
|
18
18
|
export function swizzleList(cwd = process.cwd()) {
|
|
19
19
|
const {components} = resolveCore(cwd);
|
|
20
|
-
return {type: 'swizzle.list', data: components};
|
|
20
|
+
return {type: 'swizzle.list', package: CORE_PACKAGE, data: components};
|
|
21
21
|
}
|
|
@@ -101,6 +101,10 @@ export const doc = {
|
|
|
101
101
|
code: 'ERR_FILE_EXISTS',
|
|
102
102
|
when: 'copying would overwrite existing files and overwrite is not set',
|
|
103
103
|
},
|
|
104
|
+
{
|
|
105
|
+
code: 'ERR_WRITE_FAILED',
|
|
106
|
+
when: 'the output directory or a copied file could not be written (no permission, read-only mount, full disk)',
|
|
107
|
+
},
|
|
104
108
|
],
|
|
105
109
|
examples: [
|
|
106
110
|
{
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
import {describe, it, expect} from 'vitest';
|
|
4
|
+
import * as fs from 'node:fs';
|
|
4
5
|
import * as path from 'node:path';
|
|
5
6
|
import {fileURLToPath} from 'node:url';
|
|
6
7
|
import {rewriteImports, swizzle} from './swizzle.mjs';
|
|
@@ -76,12 +77,26 @@ describe('rewriteImports', () => {
|
|
|
76
77
|
);
|
|
77
78
|
});
|
|
78
79
|
|
|
79
|
-
it('
|
|
80
|
-
//
|
|
81
|
-
// .
|
|
82
|
-
const input = `import {
|
|
80
|
+
it('rewrites ANY non-theme .stylex import to a deep path (not the barrel)', () => {
|
|
81
|
+
// Every .stylex module needs the deep path so the StyleX compiler can
|
|
82
|
+
// resolve styles at compile time. The barrel re-export loses identity.
|
|
83
|
+
const input = `import { interactionOverlayStyles } from '../utils/interactionOverlay.stylex';`;
|
|
83
84
|
expect(rewriteImports(input)).toBe(
|
|
84
|
-
`import {
|
|
85
|
+
`import { interactionOverlayStyles } from '@astryxdesign/core/utils/interactionOverlay.stylex';`,
|
|
86
|
+
);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('rewrites a Layout .stylex import to a deep path', () => {
|
|
90
|
+
const input = `import { container } from '../Layout/container.stylex';`;
|
|
91
|
+
expect(rewriteImports(input)).toBe(
|
|
92
|
+
`import { container } from '@astryxdesign/core/Layout/container.stylex';`,
|
|
93
|
+
);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('rewrites a two-levels-up .stylex import to a deep path', () => {
|
|
97
|
+
const input = `import { focusOutlineProps } from '../../utils/focusOutline.stylex';`;
|
|
98
|
+
expect(rewriteImports(input)).toBe(
|
|
99
|
+
`import { focusOutlineProps } from '@astryxdesign/core/utils/focusOutline.stylex';`,
|
|
85
100
|
);
|
|
86
101
|
});
|
|
87
102
|
});
|
|
@@ -105,3 +120,38 @@ describe('swizzle() API', () => {
|
|
|
105
120
|
});
|
|
106
121
|
});
|
|
107
122
|
});
|
|
123
|
+
|
|
124
|
+
describe('swizzle rewriteImports compiles for components with .stylex imports', () => {
|
|
125
|
+
it('Button: every rewritten import resolves in the core exports map', async () => {
|
|
126
|
+
const corePkg = JSON.parse(
|
|
127
|
+
fs.readFileSync(
|
|
128
|
+
path.join(REPO, 'packages/core/package.json'),
|
|
129
|
+
'utf-8',
|
|
130
|
+
),
|
|
131
|
+
);
|
|
132
|
+
const exportKeys = new Set(Object.keys(corePkg.exports));
|
|
133
|
+
|
|
134
|
+
const buttonDir = path.join(REPO, 'packages/core/src/Button');
|
|
135
|
+
const files = fs.readdirSync(buttonDir).filter(
|
|
136
|
+
f => (f.endsWith('.ts') || f.endsWith('.tsx')) && !f.includes('.test.') && !f.includes('.doc.'),
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
for (const file of files) {
|
|
140
|
+
const content = fs.readFileSync(path.join(buttonDir, file), 'utf-8');
|
|
141
|
+
const rewritten = rewriteImports(content);
|
|
142
|
+
|
|
143
|
+
// Extract all rewritten @astryxdesign/core/* imports
|
|
144
|
+
const importRe = /from ['"](@astryxdesign\/core\/[^'"]+)['"]/g;
|
|
145
|
+
let m;
|
|
146
|
+
while ((m = importRe.exec(rewritten)) !== null) {
|
|
147
|
+
const specifier = m[1];
|
|
148
|
+
const subpath = './' + specifier.replace('@astryxdesign/core/', '');
|
|
149
|
+
|
|
150
|
+
expect(
|
|
151
|
+
exportKeys.has(subpath),
|
|
152
|
+
`${specifier} (subpath ${subpath}) must resolve in core exports`,
|
|
153
|
+
).toBe(true);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
});
|
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export type SwizzleListResponse = {
|
|
8
8
|
type: "swizzle.list";
|
|
9
|
+
/**
|
|
10
|
+
* `@astryxdesign/core`, the package the listed components come from.
|
|
11
|
+
*/
|
|
12
|
+
package: string;
|
|
9
13
|
data: string[];
|
|
10
14
|
};
|
|
11
15
|
/**
|
|
@@ -26,6 +30,10 @@ export type SwizzleFeedback = {
|
|
|
26
30
|
*/
|
|
27
31
|
export type SwizzleCopyResponse = {
|
|
28
32
|
type: "swizzle.copy";
|
|
33
|
+
/**
|
|
34
|
+
* Owner package the component source was copied from (as `data.package`).
|
|
35
|
+
*/
|
|
36
|
+
package: string;
|
|
29
37
|
data: {
|
|
30
38
|
component: string;
|
|
31
39
|
package: string;
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*
|
|
12
12
|
* @typedef {object} SwizzleListResponse
|
|
13
13
|
* @property {'swizzle.list'} type
|
|
14
|
+
* @property {string} package `@astryxdesign/core`, the package the listed components come from.
|
|
14
15
|
* @property {string[]} data
|
|
15
16
|
*/
|
|
16
17
|
|
|
@@ -27,6 +28,7 @@
|
|
|
27
28
|
*
|
|
28
29
|
* @typedef {object} SwizzleCopyResponse
|
|
29
30
|
* @property {'swizzle.copy'} type
|
|
31
|
+
* @property {string} package Owner package the component source was copied from (as `data.package`).
|
|
30
32
|
* @property {object} data
|
|
31
33
|
* @property {string} data.component
|
|
32
34
|
* @property {string} data.package Owner package the component source was copied from.
|
|
@@ -16,9 +16,10 @@ import {
|
|
|
16
16
|
isFilePathArg,
|
|
17
17
|
PathSafetyError,
|
|
18
18
|
} from '../../../foundation/fs/path-safety.mjs';
|
|
19
|
-
import {AstryxError} from '../../error.mjs';
|
|
19
|
+
import {AstryxError, writeFailed} from '../../error.mjs';
|
|
20
20
|
import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
|
|
21
|
-
import {
|
|
21
|
+
import {pkgOf, replaceDemoMedia} from '../../../foundation/discovery/template-adapter.mjs';
|
|
22
|
+
import {analyzeTemplateNeeds} from '../../../foundation/discovery/template-needs.mjs';
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* Scaffold an already-resolved template to `targetPath` (relative to `cwd`) and
|
|
@@ -80,22 +81,40 @@ export function templateCopy(match, {targetPath, cwd, overwrite = false}) {
|
|
|
80
81
|
);
|
|
81
82
|
}
|
|
82
83
|
|
|
83
|
-
fs.mkdirSync(outputDir, {recursive: true});
|
|
84
|
-
|
|
85
84
|
// Strip demo image references so the scaffolded file renders without a
|
|
86
|
-
// Meta-only network dependency.
|
|
87
|
-
|
|
88
|
-
const outputSource =
|
|
89
|
-
|
|
85
|
+
// Meta-only network dependency. Read before any write, so a failure below
|
|
86
|
+
// leaves nothing behind.
|
|
87
|
+
const {source: outputSource, demoMediaReplaced} = replaceDemoMedia(
|
|
88
|
+
fs.readFileSync(match.filePath, 'utf-8'),
|
|
89
|
+
);
|
|
90
|
+
try {
|
|
91
|
+
fs.mkdirSync(outputDir, {recursive: true});
|
|
92
|
+
fs.writeFileSync(outputFilePath, outputSource);
|
|
93
|
+
} catch (err) {
|
|
94
|
+
throw writeFailed(outputFilePath, cwd, err);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Analyze what the template needs that the project lacks: external packages
|
|
98
|
+
// and the StyleX compiler. Derived from the source's own imports.
|
|
99
|
+
const {notes, missingPackages, installCommand} = analyzeTemplateNeeds(
|
|
100
|
+
outputSource,
|
|
101
|
+
cwd,
|
|
102
|
+
);
|
|
103
|
+
const missing = missingPackages;
|
|
90
104
|
|
|
91
105
|
const relOutput = path.relative(cwd, outputDir) || '.';
|
|
92
106
|
return {
|
|
93
107
|
type: 'template.copy',
|
|
108
|
+
package: pkgOf(match),
|
|
94
109
|
data: {
|
|
95
110
|
template: match.dirName,
|
|
96
111
|
outputDir: relOutput,
|
|
97
112
|
fileName: outputFileName,
|
|
98
113
|
filesCopied: 1,
|
|
114
|
+
demoMediaReplaced,
|
|
115
|
+
notes,
|
|
116
|
+
missingPackages: missing,
|
|
117
|
+
installCommand,
|
|
99
118
|
},
|
|
100
119
|
};
|
|
101
120
|
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file The template.copy receipt discloses replaced demo media. Templates are
|
|
5
|
+
* picked by what their source contains, not by slug, so catalog renames do not
|
|
6
|
+
* break the suite.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {describe, it, expect, beforeEach, afterEach} 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 {template, discoverTemplates} from '../template.mjs';
|
|
14
|
+
|
|
15
|
+
const SLOW = 60_000;
|
|
16
|
+
const FIXTURE_REF = /\/template-assets\/[\w.-]+\.(\w+)/g;
|
|
17
|
+
const VIDEO = new Set(['mp4', 'webm', 'mov', 'ogv', 'm4v']);
|
|
18
|
+
|
|
19
|
+
/** @param {string} filePath */
|
|
20
|
+
const fixtureRefs = filePath =>
|
|
21
|
+
[...fs.readFileSync(filePath, 'utf-8').matchAll(FIXTURE_REF)].map(m =>
|
|
22
|
+
m[1].toLowerCase(),
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @param {(refs: string[]) => boolean} predicate
|
|
27
|
+
* @param {'page' | 'block'} type
|
|
28
|
+
*/
|
|
29
|
+
async function findTemplate(type, predicate) {
|
|
30
|
+
const all = /** @type {Array<{dirName: string, type: string, filePath: string}>} */ (
|
|
31
|
+
await discoverTemplates()
|
|
32
|
+
);
|
|
33
|
+
const ids = new Map();
|
|
34
|
+
for (const t of all) ids.set(t.dirName, (ids.get(t.dirName) ?? 0) + 1);
|
|
35
|
+
const found = all.find(
|
|
36
|
+
t =>
|
|
37
|
+
t.type === type &&
|
|
38
|
+
ids.get(t.dirName) === 1 &&
|
|
39
|
+
fs.existsSync(t.filePath) &&
|
|
40
|
+
predicate(fixtureRefs(t.filePath)),
|
|
41
|
+
);
|
|
42
|
+
if (!found) throw new Error(`no ${type} template matches`);
|
|
43
|
+
return {id: found.dirName, refs: fixtureRefs(found.filePath)};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
describe('template.copy receipt — replaced demo media', () => {
|
|
47
|
+
let dir;
|
|
48
|
+
beforeEach(() => {
|
|
49
|
+
dir = fs.mkdtempSync(path.join(os.tmpdir(), 'tmpl-receipt-'));
|
|
50
|
+
});
|
|
51
|
+
afterEach(() => fs.rmSync(dir, {recursive: true, force: true}));
|
|
52
|
+
|
|
53
|
+
it('counts every demo image a page template carried, and leaves none behind', async () => {
|
|
54
|
+
const {id, refs} = await findTemplate(
|
|
55
|
+
'page',
|
|
56
|
+
r => r.length > 0 && r.every(ext => !VIDEO.has(ext)),
|
|
57
|
+
);
|
|
58
|
+
const res = await template(id, {targetPath: './dest', cwd: dir});
|
|
59
|
+
expect(res.type).toBe('template.copy');
|
|
60
|
+
expect(res.data.demoMediaReplaced).toBe(refs.length);
|
|
61
|
+
expect(
|
|
62
|
+
fs.readFileSync(path.join(dir, 'dest', 'page.tsx'), 'utf-8'),
|
|
63
|
+
).not.toContain('/template-assets/');
|
|
64
|
+
}, SLOW);
|
|
65
|
+
|
|
66
|
+
it('counts a demo video in a block template', async () => {
|
|
67
|
+
const {id, refs} = await findTemplate('block', r => r.some(ext => VIDEO.has(ext)));
|
|
68
|
+
const res = await template(id, {targetPath: './dest', cwd: dir});
|
|
69
|
+
expect(res.data.demoMediaReplaced).toBe(refs.length);
|
|
70
|
+
}, SLOW);
|
|
71
|
+
|
|
72
|
+
it('reports 0 when the template carries no demo media', async () => {
|
|
73
|
+
const {id} = await findTemplate('page', r => r.length === 0);
|
|
74
|
+
const res = await template(id, {targetPath: './dest', cwd: dir});
|
|
75
|
+
expect(res.data.demoMediaReplaced).toBe(0);
|
|
76
|
+
}, SLOW);
|
|
77
|
+
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @file `template.show` leaf — return a resolved template's
|
|
5
|
-
* components it composes.
|
|
4
|
+
* @file `template.show` leaf — return a resolved template's source, exactly as
|
|
5
|
+
* `template.copy` writes it, plus the components it composes.
|
|
6
6
|
*
|
|
7
7
|
* @position api/template/show — reads the resolved match's source file; the
|
|
8
8
|
* template dispatcher routes `show` (and the no-target-path default) here.
|
|
@@ -11,7 +11,11 @@
|
|
|
11
11
|
import * as fs from 'node:fs';
|
|
12
12
|
import {AstryxError} from '../../error.mjs';
|
|
13
13
|
import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
extractComponents,
|
|
16
|
+
pkgOf,
|
|
17
|
+
replaceDemoMedia,
|
|
18
|
+
} from '../../../foundation/discovery/template-adapter.mjs';
|
|
15
19
|
|
|
16
20
|
/**
|
|
17
21
|
* Build the `template.show` envelope for an already-resolved template.
|
|
@@ -27,14 +31,23 @@ export function templateShow(match) {
|
|
|
27
31
|
);
|
|
28
32
|
}
|
|
29
33
|
|
|
34
|
+
// The source template.copy writes (spec:AST-028 FR7): a template printed and
|
|
35
|
+
// pasted must not keep a media path only Astryx's previews serve, and the
|
|
36
|
+
// caller is told how many it replaced, the way the copy receipt tells it.
|
|
37
|
+
const {source, demoMediaReplaced} = replaceDemoMedia(
|
|
38
|
+
fs.readFileSync(match.filePath, 'utf-8'),
|
|
39
|
+
);
|
|
40
|
+
|
|
30
41
|
return {
|
|
31
42
|
type: 'template.show',
|
|
43
|
+
package: pkgOf(match),
|
|
32
44
|
data: {
|
|
33
45
|
template: match.dirName,
|
|
34
46
|
description: match.description,
|
|
35
47
|
type: match.type,
|
|
36
48
|
components: extractComponents(match.filePath),
|
|
37
|
-
source
|
|
49
|
+
source,
|
|
50
|
+
demoMediaReplaced,
|
|
38
51
|
},
|
|
39
52
|
};
|
|
40
53
|
}
|