@astryxdesign/cli 0.6.5 → 0.6.6-canary.408ad59
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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @file Theme descriptor discovery shared by Project, theme list/add, and
|
|
4
|
+
* @file Theme descriptor discovery shared by Project, theme list/add/eject, and
|
|
5
5
|
* integration validation.
|
|
6
6
|
*
|
|
7
7
|
* A theme root contains one directory per lower-kebab slug. Each directory has
|
|
@@ -22,6 +22,7 @@ import * as path from 'node:path';
|
|
|
22
22
|
import {lowerDoc} from '../doc-compiler/compile.mjs';
|
|
23
23
|
import {packageSource} from '../doc-compiler/source.mjs';
|
|
24
24
|
import {CLI_ROOT} from '../fs/paths.mjs';
|
|
25
|
+
import {LOCAL_THEME_ROOT} from '../config/theme-state.mjs';
|
|
25
26
|
import {assertWithin, PathSafetyError} from '../fs/path-safety.mjs';
|
|
26
27
|
|
|
27
28
|
export const BUNDLED_THEME_PACKAGE = '@astryxdesign/cli';
|
|
@@ -62,14 +63,28 @@ function sourceParser() {
|
|
|
62
63
|
* @property {boolean} maintained
|
|
63
64
|
* @property {string} entry
|
|
64
65
|
* @property {string} exportName
|
|
65
|
-
* @property {string[]} files what `theme
|
|
66
|
+
* @property {string[]} files what `theme eject` copies, relative to sourceDir,
|
|
66
67
|
* entry first
|
|
67
|
-
* @property {string} package
|
|
68
|
+
* @property {string} package package exposed for discovery and --package selection
|
|
69
|
+
* @property {string} [importPackage] package that owns built imports when it differs from the selector package
|
|
70
|
+
* @property {string} [packageDir] absolute package/project directory
|
|
71
|
+
* @property {Record<string, unknown>|null} [packageExports] parsed package exports
|
|
72
|
+
* @property {'bundled'|'package'|'local'} source
|
|
68
73
|
* @property {string} sourceDir absolute directory holding this theme's files
|
|
69
74
|
* @property {boolean} bundled
|
|
70
75
|
* @property {string} docPath absolute descriptor path
|
|
71
76
|
*/
|
|
72
77
|
|
|
78
|
+
/**
|
|
79
|
+
* The package written to the app record and used for built imports. Bundled
|
|
80
|
+
* themes keep the released CLI package as their selector while importing from
|
|
81
|
+
* their standalone theme package.
|
|
82
|
+
* @param {DiscoveredTheme} theme
|
|
83
|
+
*/
|
|
84
|
+
export function themeImportPackage(theme) {
|
|
85
|
+
return theme.importPackage ?? theme.package;
|
|
86
|
+
}
|
|
87
|
+
|
|
73
88
|
/**
|
|
74
89
|
* Resolve one authored relative path without allowing POSIX or Windows escape
|
|
75
90
|
* syntax, even when discovery runs on the other platform.
|
|
@@ -200,6 +215,15 @@ function moduleSpecifiers(file, jscodeshift) {
|
|
|
200
215
|
return specifiers;
|
|
201
216
|
}
|
|
202
217
|
|
|
218
|
+
/**
|
|
219
|
+
* Every module a theme source file imports or re-exports, as written.
|
|
220
|
+
* @param {string} file
|
|
221
|
+
* @returns {string[]}
|
|
222
|
+
*/
|
|
223
|
+
export function themeFileImports(file) {
|
|
224
|
+
return moduleSpecifiers(file, sourceParser());
|
|
225
|
+
}
|
|
226
|
+
|
|
203
227
|
/**
|
|
204
228
|
* Validate that every local static dependency is copied with the theme.
|
|
205
229
|
* @param {string} file
|
|
@@ -1007,7 +1031,7 @@ export function isThemeFolder(folder) {
|
|
|
1007
1031
|
/**
|
|
1008
1032
|
* The files one theme folder ships: every regular file below it except
|
|
1009
1033
|
* {@link isIgnoredThemeEntry} entries. What pack-check requires and what
|
|
1010
|
-
* `theme
|
|
1034
|
+
* `theme eject` copies.
|
|
1011
1035
|
* @param {string} folder absolute path
|
|
1012
1036
|
* @returns {string[]} sorted POSIX paths relative to the folder
|
|
1013
1037
|
*/
|
|
@@ -1015,14 +1039,76 @@ export function listThemeFiles(folder) {
|
|
|
1015
1039
|
return listThemeFolder(folder).files;
|
|
1016
1040
|
}
|
|
1017
1041
|
|
|
1042
|
+
/**
|
|
1043
|
+
* @typedef {object} UnmigratedThemeCopy
|
|
1044
|
+
* @property {string} slug
|
|
1045
|
+
* @property {string} sourceDir
|
|
1046
|
+
* @property {string} entry
|
|
1047
|
+
* @property {string} exportName
|
|
1048
|
+
* @property {string} descriptor
|
|
1049
|
+
*/
|
|
1050
|
+
|
|
1051
|
+
/**
|
|
1052
|
+
* Recognize the shape released `theme add` copied before local descriptors
|
|
1053
|
+
* existed. Keep this narrow so an unrelated broken folder still follows the
|
|
1054
|
+
* ordinary discovery error path.
|
|
1055
|
+
* @param {string} folder
|
|
1056
|
+
* @returns {UnmigratedThemeCopy|null}
|
|
1057
|
+
*/
|
|
1058
|
+
function unmigratedThemeCopy(folder) {
|
|
1059
|
+
const slug = path.basename(folder);
|
|
1060
|
+
if (!THEME_SLUG_RE.test(slug)) return null;
|
|
1061
|
+
const listing = listThemeFolder(folder);
|
|
1062
|
+
if (
|
|
1063
|
+
listing.symlinks.length > 0 ||
|
|
1064
|
+
listing.files.some(file => file.endsWith(THEME_DOC_SUFFIX))
|
|
1065
|
+
) {
|
|
1066
|
+
return null;
|
|
1067
|
+
}
|
|
1068
|
+
const sources = listing.files.filter(
|
|
1069
|
+
file => !file.includes('/') && THEME_SOURCE_RE.test(file),
|
|
1070
|
+
);
|
|
1071
|
+
if (sources.length !== 1) return null;
|
|
1072
|
+
const entry = sources[0];
|
|
1073
|
+
const exportName = entry.replace(/\.(?:mjs|js|mts|ts|tsx|jsx)$/u, '');
|
|
1074
|
+
return {
|
|
1075
|
+
slug,
|
|
1076
|
+
sourceDir: folder,
|
|
1077
|
+
entry,
|
|
1078
|
+
exportName,
|
|
1079
|
+
descriptor: `${exportName}${THEME_DOC_SUFFIX}`,
|
|
1080
|
+
};
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
/**
|
|
1084
|
+
* Source copies left by the released `theme add`, before it copied a
|
|
1085
|
+
* descriptor. Commands skip these until the next-release project codemod adds
|
|
1086
|
+
* the same-stem descriptor.
|
|
1087
|
+
* @param {string} projectDir
|
|
1088
|
+
* @param {string} [owner]
|
|
1089
|
+
* @returns {UnmigratedThemeCopy[]}
|
|
1090
|
+
*/
|
|
1091
|
+
export function discoverUnmigratedThemeCopies(
|
|
1092
|
+
projectDir,
|
|
1093
|
+
owner = LOCAL_THEME_ROOT,
|
|
1094
|
+
) {
|
|
1095
|
+
const root = path.resolve(projectDir, owner);
|
|
1096
|
+
if (!fs.existsSync(root) || !fs.statSync(root).isDirectory()) return [];
|
|
1097
|
+
return fs
|
|
1098
|
+
.readdirSync(root, {withFileTypes: true})
|
|
1099
|
+
.filter(entry => entry.isDirectory() && !isIgnoredThemeEntry(entry.name))
|
|
1100
|
+
.map(entry => unmigratedThemeCopy(path.join(root, entry.name)))
|
|
1101
|
+
.filter(copy => copy !== null)
|
|
1102
|
+
.sort((a, b) => a.slug.localeCompare(b.slug));
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1018
1105
|
/** @param {string[]} files */
|
|
1019
1106
|
function quoted(files) {
|
|
1020
1107
|
return files.map(file => `"${file}"`).join(', ');
|
|
1021
1108
|
}
|
|
1022
1109
|
|
|
1023
1110
|
/**
|
|
1024
|
-
* The files `theme
|
|
1025
|
-
* copy order. SYNC: scripts/generate-cli-themes.mjs bundles these.
|
|
1111
|
+
* The files `theme eject` copies after a bundled theme's entry, in copy order. SYNC: scripts/generate-cli-themes.mjs bundles these.
|
|
1026
1112
|
* @param {string} id the theme's export name without `Theme`
|
|
1027
1113
|
*/
|
|
1028
1114
|
function bundledThemeArtifacts(id) {
|
|
@@ -1037,9 +1123,9 @@ function bundledThemeArtifacts(id) {
|
|
|
1037
1123
|
}
|
|
1038
1124
|
|
|
1039
1125
|
/**
|
|
1040
|
-
* The files `theme
|
|
1041
|
-
*
|
|
1042
|
-
*
|
|
1126
|
+
* The files `theme eject` copies, entry first. Every ejected theme keeps its
|
|
1127
|
+
* same-stem descriptor so the local themes root remains discoverable without a
|
|
1128
|
+
* catalog. An integration theme copies its complete directory.
|
|
1043
1129
|
* @param {string[]} files every regular file in the theme directory, sorted
|
|
1044
1130
|
* @param {string} entry
|
|
1045
1131
|
* @param {string} descriptor
|
|
@@ -1047,13 +1133,12 @@ function bundledThemeArtifacts(id) {
|
|
|
1047
1133
|
* @param {boolean} bundled
|
|
1048
1134
|
*/
|
|
1049
1135
|
function copiedThemeFiles(files, entry, descriptor, exportName, bundled) {
|
|
1050
|
-
const rest = files.filter(
|
|
1051
|
-
|
|
1052
|
-
);
|
|
1053
|
-
if (!bundled) return [entry, ...rest];
|
|
1136
|
+
const rest = files.filter(file => file !== entry && file !== descriptor);
|
|
1137
|
+
if (!bundled) return [entry, descriptor, ...rest];
|
|
1054
1138
|
const order = bundledThemeArtifacts(exportName.replace(/Theme$/u, ''));
|
|
1055
1139
|
return [
|
|
1056
1140
|
entry,
|
|
1141
|
+
descriptor,
|
|
1057
1142
|
...order.filter(file => rest.includes(file)),
|
|
1058
1143
|
...rest.filter(file => !order.includes(file)),
|
|
1059
1144
|
];
|
|
@@ -1063,14 +1148,15 @@ function copiedThemeFiles(files, entry, descriptor, exportName, bundled) {
|
|
|
1063
1148
|
* Discover and validate one theme root.
|
|
1064
1149
|
* @param {string} themeRoot absolute root containing one directory per slug
|
|
1065
1150
|
* @param {string} owner package that owns the root
|
|
1066
|
-
* @param {{bundled?: boolean}} [options] a bundled root is the CLI's own; its
|
|
1067
|
-
* sources are checked by the CLI's tests rather than on every read
|
|
1151
|
+
* @param {{bundled?: boolean, allowUnmigrated?: boolean}} [options] a bundled root is the CLI's own; its
|
|
1152
|
+
* sources are checked by the CLI's tests rather than on every read. A local
|
|
1153
|
+
* root may skip released source copies until `astryx upgrade` adds descriptors.
|
|
1068
1154
|
* @returns {DiscoveredTheme[]}
|
|
1069
1155
|
*/
|
|
1070
1156
|
export function discoverThemeDirectory(
|
|
1071
1157
|
themeRoot,
|
|
1072
1158
|
owner,
|
|
1073
|
-
{bundled = false} = {},
|
|
1159
|
+
{bundled = false, allowUnmigrated = false} = {},
|
|
1074
1160
|
) {
|
|
1075
1161
|
if (!fs.existsSync(themeRoot) || !fs.statSync(themeRoot).isDirectory()) {
|
|
1076
1162
|
throw new Error(
|
|
@@ -1140,6 +1226,13 @@ export function discoverThemeDirectory(
|
|
|
1140
1226
|
file.endsWith(THEME_DOC_SUFFIX),
|
|
1141
1227
|
);
|
|
1142
1228
|
const docs = descriptors.filter(file => !file.includes('/'));
|
|
1229
|
+
if (
|
|
1230
|
+
allowUnmigrated &&
|
|
1231
|
+
descriptors.length === 0 &&
|
|
1232
|
+
unmigratedThemeCopy(sourceDir)
|
|
1233
|
+
) {
|
|
1234
|
+
continue;
|
|
1235
|
+
}
|
|
1143
1236
|
if (docs.length !== 1) {
|
|
1144
1237
|
const detail =
|
|
1145
1238
|
docs.length > 1
|
|
@@ -1254,6 +1347,7 @@ export function discoverThemeDirectory(
|
|
|
1254
1347
|
bundled,
|
|
1255
1348
|
),
|
|
1256
1349
|
package: owner,
|
|
1350
|
+
source: bundled ? 'bundled' : 'package',
|
|
1257
1351
|
sourceDir,
|
|
1258
1352
|
bundled,
|
|
1259
1353
|
docPath,
|
|
@@ -1366,15 +1460,46 @@ export function discoverBundledThemes() {
|
|
|
1366
1460
|
THEMES_DIR,
|
|
1367
1461
|
BUNDLED_THEME_PACKAGE,
|
|
1368
1462
|
{bundled: true},
|
|
1369
|
-
)
|
|
1463
|
+
).map(theme => ({
|
|
1464
|
+
...theme,
|
|
1465
|
+
importPackage: `@astryxdesign/theme-${theme.slug}`,
|
|
1466
|
+
source: /** @type {const} */ ('bundled'),
|
|
1467
|
+
}));
|
|
1370
1468
|
return bundledThemeCache.map(theme => ({...theme, files: [...theme.files]}));
|
|
1371
1469
|
}
|
|
1372
1470
|
|
|
1471
|
+
/**
|
|
1472
|
+
* Discover authored themes in the app's conventional local themes root.
|
|
1473
|
+
* @param {string} projectDir
|
|
1474
|
+
* @param {string} [owner]
|
|
1475
|
+
* @returns {DiscoveredTheme[]}
|
|
1476
|
+
*/
|
|
1477
|
+
export function discoverLocalThemes(projectDir, owner = LOCAL_THEME_ROOT) {
|
|
1478
|
+
const root = path.resolve(projectDir, owner);
|
|
1479
|
+
if (!fs.existsSync(root) || !fs.statSync(root).isDirectory()) return [];
|
|
1480
|
+
return discoverThemeDirectory(root, owner, {allowUnmigrated: true}).map(
|
|
1481
|
+
theme => ({
|
|
1482
|
+
...theme,
|
|
1483
|
+
package: owner,
|
|
1484
|
+
packageDir: projectDir,
|
|
1485
|
+
packageExports: null,
|
|
1486
|
+
source: /** @type {const} */ ('local'),
|
|
1487
|
+
}),
|
|
1488
|
+
);
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1373
1491
|
/**
|
|
1374
1492
|
* @param {import('../integrations/integrations.mjs').LoadedIntegration} integration
|
|
1375
1493
|
* @returns {Promise<DiscoveredTheme[]>}
|
|
1376
1494
|
*/
|
|
1377
1495
|
export async function discoverIntegrationThemes(integration) {
|
|
1378
1496
|
if (!integration.themes) return [];
|
|
1379
|
-
return discoverThemeDirectory(integration.themes, integration.name)
|
|
1497
|
+
return discoverThemeDirectory(integration.themes, integration.name).map(
|
|
1498
|
+
theme => ({
|
|
1499
|
+
...theme,
|
|
1500
|
+
packageDir: integration.__packageDir,
|
|
1501
|
+
packageExports: integration.__packageExports,
|
|
1502
|
+
source: /** @type {const} */ ('package'),
|
|
1503
|
+
}),
|
|
1504
|
+
);
|
|
1380
1505
|
}
|
|
@@ -62,12 +62,17 @@ afterEach(() => {
|
|
|
62
62
|
});
|
|
63
63
|
|
|
64
64
|
describe('theme descriptor discovery', () => {
|
|
65
|
-
it('
|
|
65
|
+
it('keeps the released selector package and records the import package', () => {
|
|
66
66
|
const themes = discoverBundledThemes();
|
|
67
67
|
expect(themes.length).toBeGreaterThan(0);
|
|
68
68
|
expect(themes.every(theme => theme.package === BUNDLED_THEME_PACKAGE)).toBe(
|
|
69
69
|
true,
|
|
70
70
|
);
|
|
71
|
+
expect(
|
|
72
|
+
themes.every(
|
|
73
|
+
theme => theme.importPackage === `@astryxdesign/theme-${theme.slug}`,
|
|
74
|
+
),
|
|
75
|
+
).toBe(true);
|
|
71
76
|
expect(themes.every(theme => theme.bundled)).toBe(true);
|
|
72
77
|
expect(
|
|
73
78
|
themes.filter(theme => theme.maintained).map(theme => theme.slug),
|
|
@@ -717,10 +722,11 @@ describe('folders under a theme root that are not themes', () => {
|
|
|
717
722
|
});
|
|
718
723
|
|
|
719
724
|
describe('bundled theme files', () => {
|
|
720
|
-
it('
|
|
725
|
+
it('keeps entry first and includes the descriptor needed by theme eject', () => {
|
|
721
726
|
const themes = discoverBundledThemes();
|
|
722
727
|
expect(themes.find(theme => theme.slug === 'neutral')?.files).toEqual([
|
|
723
728
|
'neutralTheme.ts',
|
|
729
|
+
'neutralTheme.doc.mjs',
|
|
724
730
|
'icons.tsx',
|
|
725
731
|
'neutralPalettes.ts',
|
|
726
732
|
'neutralPalettes.generated.ts',
|
|
@@ -730,7 +736,7 @@ describe('bundled theme files', () => {
|
|
|
730
736
|
]);
|
|
731
737
|
for (const theme of themes) {
|
|
732
738
|
expect(theme.files[0]).toBe(theme.entry);
|
|
733
|
-
expect(theme.files.
|
|
739
|
+
expect(theme.files).toContain(path.basename(theme.docPath));
|
|
734
740
|
}
|
|
735
741
|
});
|
|
736
742
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Resolve a discovered theme to app imports.
|
|
6
|
+
* @param {import('./theme-discovery.mjs').DiscoveredTheme} theme
|
|
7
|
+
* @param {{cwd?: string, ownerThemeCount?: number}} [options]
|
|
8
|
+
* @returns {import('../config/theme-state.mjs').ResolvedAppTheme}
|
|
9
|
+
*/
|
|
10
|
+
export function resolveThemeImports(theme: import("./theme-discovery.mjs").DiscoveredTheme, options?: {
|
|
11
|
+
cwd?: string;
|
|
12
|
+
ownerThemeCount?: number;
|
|
13
|
+
}): import("../config/theme-state.mjs").ResolvedAppTheme;
|
|
14
|
+
export class ThemeImportError extends Error {
|
|
15
|
+
}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Resolve one discovered source theme to the built imports an app uses.
|
|
5
|
+
*
|
|
6
|
+
* Package themes use their fixed public export paths. Local themes use the
|
|
7
|
+
* `.js` and `.css` outputs `astryx theme build` writes beside their source.
|
|
8
|
+
* Resolution fails closed and never falls back to runtime source or copying.
|
|
9
|
+
*
|
|
10
|
+
* @input A discovered theme, project directory, and owner theme count
|
|
11
|
+
* @output Built module/CSS import metadata with absolute files for verification
|
|
12
|
+
* @position packages/cli/foundation/discovery — source-to-built theme boundary
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import * as fs from 'node:fs';
|
|
16
|
+
import * as path from 'node:path';
|
|
17
|
+
import {findInstalledPackage} from '../fs/paths.mjs';
|
|
18
|
+
import {moduleExportsName} from './module-exports.mjs';
|
|
19
|
+
import {inspectPackageExport} from './package-exports.mjs';
|
|
20
|
+
import {themeImportPackage} from './theme-discovery.mjs';
|
|
21
|
+
import {isLocalThemeOwner, projectPath} from '../config/theme-state.mjs';
|
|
22
|
+
|
|
23
|
+
export class ThemeImportError extends Error {}
|
|
24
|
+
|
|
25
|
+
/** @param {string} file */
|
|
26
|
+
function readPackage(file) {
|
|
27
|
+
try {
|
|
28
|
+
return JSON.parse(fs.readFileSync(file, 'utf-8'));
|
|
29
|
+
} catch (error) {
|
|
30
|
+
throw new ThemeImportError(
|
|
31
|
+
`Cannot read theme package metadata at ${file}: ${
|
|
32
|
+
error instanceof Error ? error.message : String(error)
|
|
33
|
+
}`,
|
|
34
|
+
{cause: error},
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @param {import('./theme-discovery.mjs').DiscoveredTheme} theme
|
|
41
|
+
* @param {string} cwd
|
|
42
|
+
*/
|
|
43
|
+
function resolveLocalTheme(theme, cwd) {
|
|
44
|
+
const moduleFile = path.join(theme.sourceDir, `${theme.slug}.js`);
|
|
45
|
+
const stylesheetFile = path.join(theme.sourceDir, `${theme.slug}.css`);
|
|
46
|
+
const fontStylesheetFile = path.join(
|
|
47
|
+
theme.sourceDir,
|
|
48
|
+
`${theme.slug}.fonts.css`,
|
|
49
|
+
);
|
|
50
|
+
const missing = [moduleFile, stylesheetFile].filter(file => {
|
|
51
|
+
try {
|
|
52
|
+
return !fs.statSync(file).isFile();
|
|
53
|
+
} catch {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
if (missing.length > 0) {
|
|
58
|
+
const source = projectPath(
|
|
59
|
+
path.relative(cwd, path.join(theme.sourceDir, theme.entry)),
|
|
60
|
+
);
|
|
61
|
+
throw new ThemeImportError(
|
|
62
|
+
`Local theme "${theme.slug}" is not built. Run \`astryx theme build ${source}\` and try again. Missing: ${missing
|
|
63
|
+
.map(file => projectPath(path.relative(cwd, file)))
|
|
64
|
+
.join(', ')}.`,
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
if (!moduleExportsName(moduleFile, theme.exportName)) {
|
|
68
|
+
throw new ThemeImportError(
|
|
69
|
+
`Local theme "${theme.slug}" built module ${projectPath(
|
|
70
|
+
path.relative(cwd, moduleFile),
|
|
71
|
+
)} does not export "${theme.exportName}". Rebuild it with \`astryx theme build ${projectPath(
|
|
72
|
+
path.relative(cwd, path.join(theme.sourceDir, theme.entry)),
|
|
73
|
+
)}\`.`,
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
slug: theme.slug,
|
|
78
|
+
owner: theme.package,
|
|
79
|
+
exportName: theme.exportName,
|
|
80
|
+
module: '',
|
|
81
|
+
stylesheet: '',
|
|
82
|
+
moduleFile,
|
|
83
|
+
stylesheetFile,
|
|
84
|
+
...(fs.existsSync(fontStylesheetFile) ? {fontStylesheetFile} : {}),
|
|
85
|
+
source: /** @type {const} */ ('local'),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Inspect one package export triplet.
|
|
91
|
+
* @param {Record<string, any>} pkg
|
|
92
|
+
* @param {string} packageDir
|
|
93
|
+
* @param {string} moduleSubpath
|
|
94
|
+
* @param {string} stylesheetSubpath
|
|
95
|
+
* @param {string} fontSubpath
|
|
96
|
+
*/
|
|
97
|
+
function packageTriplet(
|
|
98
|
+
pkg,
|
|
99
|
+
packageDir,
|
|
100
|
+
moduleSubpath,
|
|
101
|
+
stylesheetSubpath,
|
|
102
|
+
fontSubpath,
|
|
103
|
+
) {
|
|
104
|
+
return {
|
|
105
|
+
module: inspectPackageExport(pkg, packageDir, moduleSubpath),
|
|
106
|
+
stylesheet: inspectPackageExport(pkg, packageDir, stylesheetSubpath),
|
|
107
|
+
font: inspectPackageExport(pkg, packageDir, fontSubpath),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** @param {ReturnType<typeof packageTriplet>} triplet */
|
|
112
|
+
function complete(triplet) {
|
|
113
|
+
return (
|
|
114
|
+
triplet.module.exported &&
|
|
115
|
+
triplet.module.target != null &&
|
|
116
|
+
triplet.stylesheet.exported &&
|
|
117
|
+
triplet.stylesheet.target != null
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* @param {import('./theme-discovery.mjs').DiscoveredTheme} theme
|
|
123
|
+
* @param {string} cwd
|
|
124
|
+
* @param {number} ownerThemeCount
|
|
125
|
+
*/
|
|
126
|
+
function resolvePackageTheme(theme, cwd, ownerThemeCount) {
|
|
127
|
+
const importPackage = themeImportPackage(theme);
|
|
128
|
+
const packageDir =
|
|
129
|
+
/** @type {any} */ (theme).packageDir ??
|
|
130
|
+
findInstalledPackage(cwd, importPackage);
|
|
131
|
+
if (!packageDir) {
|
|
132
|
+
throw new ThemeImportError(
|
|
133
|
+
`Theme package "${importPackage}" is not installed. Run \`npm install ${importPackage}\` (or yarn/pnpm/bun), then run \`astryx theme add ${theme.slug} --import\`.`,
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
const pkg = readPackage(path.join(packageDir, 'package.json'));
|
|
137
|
+
const perTheme = packageTriplet(
|
|
138
|
+
pkg,
|
|
139
|
+
packageDir,
|
|
140
|
+
`./themes/${theme.slug}`,
|
|
141
|
+
`./themes/${theme.slug}.css`,
|
|
142
|
+
`./themes/${theme.slug}.fonts.css`,
|
|
143
|
+
);
|
|
144
|
+
const single =
|
|
145
|
+
ownerThemeCount === 1
|
|
146
|
+
? packageTriplet(pkg, packageDir, './built', './theme.css', './fonts.css')
|
|
147
|
+
: null;
|
|
148
|
+
const selected = complete(perTheme)
|
|
149
|
+
? perTheme
|
|
150
|
+
: single && complete(single)
|
|
151
|
+
? single
|
|
152
|
+
: null;
|
|
153
|
+
if (!selected) {
|
|
154
|
+
const missing = [];
|
|
155
|
+
if (!perTheme.module.exported || !perTheme.module.target) {
|
|
156
|
+
missing.push(`module export ${pkg.name}/themes/${theme.slug}`);
|
|
157
|
+
}
|
|
158
|
+
if (!perTheme.stylesheet.exported || !perTheme.stylesheet.target) {
|
|
159
|
+
missing.push(`stylesheet export ${pkg.name}/themes/${theme.slug}.css`);
|
|
160
|
+
}
|
|
161
|
+
if (ownerThemeCount === 1) {
|
|
162
|
+
missing.push(
|
|
163
|
+
`or the single-theme exports ${pkg.name}/built and ${pkg.name}/theme.css`,
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
throw new ThemeImportError(
|
|
167
|
+
`Theme "${theme.slug}" from ${importPackage} has no resolvable built module and stylesheet. Missing ${missing.join(', ')}. The package must build and export them before it can be added.`,
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
if (selected.font.exported && selected.font.target == null) {
|
|
171
|
+
throw new ThemeImportError(
|
|
172
|
+
`Theme "${theme.slug}" from ${importPackage} exports ${selected.font.specifier}, but that font stylesheet does not resolve from the installed package.`,
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
if (
|
|
176
|
+
!selected.module.target ||
|
|
177
|
+
!moduleExportsName(selected.module.target, theme.exportName)
|
|
178
|
+
) {
|
|
179
|
+
throw new ThemeImportError(
|
|
180
|
+
`Theme "${theme.slug}" built module ${selected.module.specifier} does not export "${theme.exportName}". Rebuild the package theme before adding it.`,
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
return {
|
|
184
|
+
slug: theme.slug,
|
|
185
|
+
owner: importPackage,
|
|
186
|
+
exportName: theme.exportName,
|
|
187
|
+
module: selected.module.specifier,
|
|
188
|
+
stylesheet: selected.stylesheet.specifier,
|
|
189
|
+
...(selected.font.exported && selected.font.target
|
|
190
|
+
? {fontStylesheet: selected.font.specifier}
|
|
191
|
+
: {}),
|
|
192
|
+
moduleFile: selected.module.target,
|
|
193
|
+
stylesheetFile: /** @type {string} */ (selected.stylesheet.target),
|
|
194
|
+
...(selected.font.target ? {fontStylesheetFile: selected.font.target} : {}),
|
|
195
|
+
source:
|
|
196
|
+
/** @type {any} */ (theme).source === 'bundled' || theme.bundled
|
|
197
|
+
? /** @type {const} */ ('bundled')
|
|
198
|
+
: /** @type {const} */ ('package'),
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Resolve a discovered theme to app imports.
|
|
204
|
+
* @param {import('./theme-discovery.mjs').DiscoveredTheme} theme
|
|
205
|
+
* @param {{cwd?: string, ownerThemeCount?: number}} [options]
|
|
206
|
+
* @returns {import('../config/theme-state.mjs').ResolvedAppTheme}
|
|
207
|
+
*/
|
|
208
|
+
export function resolveThemeImports(theme, options = {}) {
|
|
209
|
+
const cwd = options.cwd ?? process.cwd();
|
|
210
|
+
if (
|
|
211
|
+
/** @type {any} */ (theme).source === 'local' ||
|
|
212
|
+
isLocalThemeOwner(theme.package)
|
|
213
|
+
) {
|
|
214
|
+
return resolveLocalTheme(theme, cwd);
|
|
215
|
+
}
|
|
216
|
+
return resolvePackageTheme(theme, cwd, options.ownerThemeCount ?? 1);
|
|
217
|
+
}
|