@astryxdesign/cli 0.6.5 → 0.6.6-canary.0e97faa
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 +60 -57
- 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/help/help.mjs +1 -1
- 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 +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 +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 +465 -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-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 +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 +209 -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 +11 -0
- package/authoring/integration/integration.doc.mjs +1 -1
- package/clients/cli/commands/build-theme.mjs +282 -31
- 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 +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 +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/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 +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 +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
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Static JavaScript module export inspection.
|
|
5
|
+
*
|
|
6
|
+
* Proves a runtime export without executing package code. Local ESM re-exports
|
|
7
|
+
* are followed recursively; unresolved or unparsable modules fail closed.
|
|
8
|
+
*
|
|
9
|
+
* @input A module path and runtime export name
|
|
10
|
+
* @output Whether that export can be proved statically
|
|
11
|
+
* @position packages/cli/foundation/discovery — shared package inspection
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import * as fs from 'node:fs';
|
|
15
|
+
import * as path from 'node:path';
|
|
16
|
+
import jscodeshift from 'jscodeshift';
|
|
17
|
+
|
|
18
|
+
const MODULE_EXTENSIONS = [
|
|
19
|
+
'.mjs',
|
|
20
|
+
'.js',
|
|
21
|
+
'.cjs',
|
|
22
|
+
'.mts',
|
|
23
|
+
'.ts',
|
|
24
|
+
'.cts',
|
|
25
|
+
'.tsx',
|
|
26
|
+
'.jsx',
|
|
27
|
+
];
|
|
28
|
+
const parser = jscodeshift.withParser('tsx');
|
|
29
|
+
|
|
30
|
+
/** @param {unknown} specifier @param {string} fromFile */
|
|
31
|
+
function resolveLocalModule(specifier, fromFile) {
|
|
32
|
+
if (typeof specifier !== 'string' || !specifier.startsWith('.')) return null;
|
|
33
|
+
const base = path.resolve(path.dirname(fromFile), specifier);
|
|
34
|
+
const candidates = [
|
|
35
|
+
base,
|
|
36
|
+
...MODULE_EXTENSIONS.map(extension => `${base}${extension}`),
|
|
37
|
+
...MODULE_EXTENSIONS.map(extension => path.join(base, `index${extension}`)),
|
|
38
|
+
];
|
|
39
|
+
return candidates.find(candidate => {
|
|
40
|
+
try {
|
|
41
|
+
return fs.statSync(candidate).isFile();
|
|
42
|
+
} catch {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
}) ?? null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** @param {any} declaration @param {string} exportName */
|
|
49
|
+
function declarationExports(declaration, exportName) {
|
|
50
|
+
if (!declaration || declaration.declare === true) return false;
|
|
51
|
+
if (['FunctionDeclaration', 'ClassDeclaration'].includes(declaration.type)) {
|
|
52
|
+
return declaration.id?.name === exportName;
|
|
53
|
+
}
|
|
54
|
+
if (declaration.type !== 'VariableDeclaration') return false;
|
|
55
|
+
return declaration.declarations.some(
|
|
56
|
+
(/** @type {any} */ item) =>
|
|
57
|
+
item.id?.type === 'Identifier' && item.id.name === exportName,
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** @param {any} declaration */
|
|
62
|
+
function runtimeDefault(declaration) {
|
|
63
|
+
return (
|
|
64
|
+
declaration != null &&
|
|
65
|
+
declaration.declare !== true &&
|
|
66
|
+
![
|
|
67
|
+
'TSDeclareFunction',
|
|
68
|
+
'TSInterfaceDeclaration',
|
|
69
|
+
'TSTypeAliasDeclaration',
|
|
70
|
+
].includes(declaration.type)
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Check one module's static export surface without executing it.
|
|
76
|
+
* @param {string} file
|
|
77
|
+
* @param {string} exportName
|
|
78
|
+
* @param {Set<string>} [seen]
|
|
79
|
+
*/
|
|
80
|
+
export function moduleExportsName(file, exportName, seen = new Set()) {
|
|
81
|
+
const identity = `${file}\0${exportName}`;
|
|
82
|
+
if (seen.has(identity)) return false;
|
|
83
|
+
seen.add(identity);
|
|
84
|
+
try {
|
|
85
|
+
if (!fs.statSync(file).isFile()) return false;
|
|
86
|
+
} catch {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
let root;
|
|
91
|
+
try {
|
|
92
|
+
root = parser(fs.readFileSync(file, 'utf-8'));
|
|
93
|
+
} catch {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
let found = false;
|
|
98
|
+
root
|
|
99
|
+
.find(parser.ExportNamedDeclaration)
|
|
100
|
+
.forEach((/** @type {any} */ exportPath) => {
|
|
101
|
+
if (found || exportPath.node.exportKind === 'type') return;
|
|
102
|
+
const node = exportPath.node;
|
|
103
|
+
if (declarationExports(node.declaration, exportName)) {
|
|
104
|
+
found = true;
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
for (const specifier of node.specifiers ?? []) {
|
|
108
|
+
if (
|
|
109
|
+
specifier.type !== 'ExportSpecifier' ||
|
|
110
|
+
specifier.exportKind === 'type'
|
|
111
|
+
) {
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
const exported = specifier.exported?.name ?? specifier.exported?.value;
|
|
115
|
+
if (exported !== exportName) continue;
|
|
116
|
+
if (!node.source) {
|
|
117
|
+
found = true;
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const target = resolveLocalModule(node.source.value, file);
|
|
121
|
+
const imported =
|
|
122
|
+
specifier.local?.name ?? specifier.local?.value ?? exportName;
|
|
123
|
+
if (target && moduleExportsName(target, imported, seen)) {
|
|
124
|
+
found = true;
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
if (found) return true;
|
|
130
|
+
|
|
131
|
+
if (exportName === 'default') {
|
|
132
|
+
const defaults = root.find(parser.ExportDefaultDeclaration).nodes();
|
|
133
|
+
if (defaults.some((/** @type {any} */ node) => runtimeDefault(node.declaration))) {
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
root
|
|
139
|
+
.find(parser.ExportAllDeclaration)
|
|
140
|
+
.forEach((/** @type {any} */ exportPath) => {
|
|
141
|
+
if (found || exportPath.node.exportKind === 'type') return;
|
|
142
|
+
const target = resolveLocalModule(exportPath.node.source?.value, file);
|
|
143
|
+
if (target && moduleExportsName(target, exportName, seen)) found = true;
|
|
144
|
+
});
|
|
145
|
+
return found;
|
|
146
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
* @typedef {object} PackageExportResult
|
|
6
|
+
* @property {string} subpath
|
|
7
|
+
* @property {string} specifier
|
|
8
|
+
* @property {boolean} exported
|
|
9
|
+
* @property {string|null} target
|
|
10
|
+
* @property {string|null} authoredTarget
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Inspect one public package subpath.
|
|
14
|
+
* @param {{name?: unknown, exports?: unknown}} pkg
|
|
15
|
+
* @param {string} packageDir
|
|
16
|
+
* @param {string} subpath `.` or a `./`-prefixed subpath
|
|
17
|
+
* @returns {PackageExportResult}
|
|
18
|
+
*/
|
|
19
|
+
export function inspectPackageExport(pkg: {
|
|
20
|
+
name?: unknown;
|
|
21
|
+
exports?: unknown;
|
|
22
|
+
}, packageDir: string, subpath: string): PackageExportResult;
|
|
23
|
+
export type PackageExportResult = {
|
|
24
|
+
subpath: string;
|
|
25
|
+
specifier: string;
|
|
26
|
+
exported: boolean;
|
|
27
|
+
target: string | null;
|
|
28
|
+
authoredTarget: string | null;
|
|
29
|
+
};
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Package export-map inspection for built theme assets.
|
|
5
|
+
*
|
|
6
|
+
* Resolves exact and wildcard subpaths through ordinary conditional export
|
|
7
|
+
* objects without executing package code. Packages with no exports map retain
|
|
8
|
+
* their legacy public deep paths and are resolved from files on disk.
|
|
9
|
+
*
|
|
10
|
+
* @input Parsed package.json, package directory, and a public subpath
|
|
11
|
+
* @output The public specifier and confined target file, when exported
|
|
12
|
+
* @position packages/cli/foundation/discovery — shared package import metadata
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import * as fs from 'node:fs';
|
|
16
|
+
import * as path from 'node:path';
|
|
17
|
+
|
|
18
|
+
const MODULE_EXTENSIONS = [
|
|
19
|
+
'.mjs',
|
|
20
|
+
'.js',
|
|
21
|
+
'.cjs',
|
|
22
|
+
'.mts',
|
|
23
|
+
'.ts',
|
|
24
|
+
'.cts',
|
|
25
|
+
'.tsx',
|
|
26
|
+
'.jsx',
|
|
27
|
+
];
|
|
28
|
+
const CONDITION_ORDER = ['import', 'default', 'browser', 'node', 'require'];
|
|
29
|
+
|
|
30
|
+
/** @param {unknown} value @returns {value is Record<string, unknown>} */
|
|
31
|
+
function isRecord(value) {
|
|
32
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Select one string target from a conditional or fallback export value.
|
|
37
|
+
* @param {unknown} value
|
|
38
|
+
* @returns {string|null}
|
|
39
|
+
*/
|
|
40
|
+
function targetString(value) {
|
|
41
|
+
if (typeof value === 'string') return value;
|
|
42
|
+
if (Array.isArray(value)) {
|
|
43
|
+
for (const item of value) {
|
|
44
|
+
const selected = targetString(item);
|
|
45
|
+
if (selected) return selected;
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
if (!isRecord(value)) return null;
|
|
50
|
+
const keys = [
|
|
51
|
+
...CONDITION_ORDER.filter(key => Object.hasOwn(value, key)),
|
|
52
|
+
...Object.keys(value).filter(
|
|
53
|
+
key => key !== 'types' && !CONDITION_ORDER.includes(key),
|
|
54
|
+
),
|
|
55
|
+
];
|
|
56
|
+
for (const key of keys) {
|
|
57
|
+
const selected = targetString(value[key]);
|
|
58
|
+
if (selected) return selected;
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Find an exact or one-star subpath mapping and the wildcard value it matched.
|
|
65
|
+
* @param {Record<string, unknown>} map
|
|
66
|
+
* @param {string} subpath
|
|
67
|
+
*/
|
|
68
|
+
function subpathValue(map, subpath) {
|
|
69
|
+
if (Object.hasOwn(map, subpath)) {
|
|
70
|
+
return {found: map[subpath] != null, value: map[subpath], wildcard: ''};
|
|
71
|
+
}
|
|
72
|
+
const patterns = Object.keys(map)
|
|
73
|
+
.filter(key => key.startsWith('./') && key.split('*').length === 2)
|
|
74
|
+
.sort((a, b) => b.length - a.length);
|
|
75
|
+
for (const pattern of patterns) {
|
|
76
|
+
const star = pattern.indexOf('*');
|
|
77
|
+
const prefix = pattern.slice(0, star);
|
|
78
|
+
const suffix = pattern.slice(star + 1);
|
|
79
|
+
if (
|
|
80
|
+
subpath.length >= prefix.length + suffix.length &&
|
|
81
|
+
subpath.startsWith(prefix) &&
|
|
82
|
+
subpath.endsWith(suffix)
|
|
83
|
+
) {
|
|
84
|
+
return {
|
|
85
|
+
found: map[pattern] != null,
|
|
86
|
+
value: map[pattern],
|
|
87
|
+
wildcard: subpath.slice(prefix.length, subpath.length - suffix.length),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return {found: false, value: null, wildcard: ''};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Select the export value for one subpath.
|
|
96
|
+
* @param {unknown} exportsField
|
|
97
|
+
* @param {string} subpath
|
|
98
|
+
*/
|
|
99
|
+
function exportValue(exportsField, subpath) {
|
|
100
|
+
if (exportsField === undefined) {
|
|
101
|
+
return {hasMap: false, exported: true, target: null};
|
|
102
|
+
}
|
|
103
|
+
if (!isRecord(exportsField)) {
|
|
104
|
+
return {
|
|
105
|
+
hasMap: true,
|
|
106
|
+
exported: subpath === '.' && exportsField != null,
|
|
107
|
+
target: subpath === '.' ? targetString(exportsField) : null,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
const keys = Object.keys(exportsField);
|
|
111
|
+
const subpathMap = keys.some(key => key.startsWith('.'));
|
|
112
|
+
if (!subpathMap) {
|
|
113
|
+
return {
|
|
114
|
+
hasMap: true,
|
|
115
|
+
exported: subpath === '.',
|
|
116
|
+
target: subpath === '.' ? targetString(exportsField) : null,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
const selected = subpathValue(exportsField, subpath);
|
|
120
|
+
const target = selected.found ? targetString(selected.value) : null;
|
|
121
|
+
return {
|
|
122
|
+
hasMap: true,
|
|
123
|
+
exported: selected.found && target != null,
|
|
124
|
+
target: target?.replaceAll('*', selected.wildcard) ?? null,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** @param {string} file */
|
|
129
|
+
function regularFile(file) {
|
|
130
|
+
try {
|
|
131
|
+
return fs.statSync(file).isFile();
|
|
132
|
+
} catch {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Resolve an export target while confining it to its package.
|
|
139
|
+
* @param {string} packageDir
|
|
140
|
+
* @param {string} target
|
|
141
|
+
*/
|
|
142
|
+
function resolveTarget(packageDir, target) {
|
|
143
|
+
if (!target.startsWith('./')) return null;
|
|
144
|
+
const resolved = path.resolve(packageDir, target);
|
|
145
|
+
const root = path.resolve(packageDir);
|
|
146
|
+
if (resolved !== root && !resolved.startsWith(root + path.sep)) return null;
|
|
147
|
+
return regularFile(resolved) ? resolved : null;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Resolve a public legacy deep path for a package with no exports map.
|
|
152
|
+
* @param {string} packageDir
|
|
153
|
+
* @param {string} subpath
|
|
154
|
+
*/
|
|
155
|
+
function resolveLegacy(packageDir, subpath) {
|
|
156
|
+
if (!subpath.startsWith('./')) return null;
|
|
157
|
+
const base = path.resolve(packageDir, subpath.slice(2));
|
|
158
|
+
const root = path.resolve(packageDir);
|
|
159
|
+
if (base !== root && !base.startsWith(root + path.sep)) return null;
|
|
160
|
+
const candidates = [
|
|
161
|
+
base,
|
|
162
|
+
...MODULE_EXTENSIONS.map(extension => `${base}${extension}`),
|
|
163
|
+
...MODULE_EXTENSIONS.map(extension => path.join(base, `index${extension}`)),
|
|
164
|
+
];
|
|
165
|
+
return candidates.find(regularFile) ?? null;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* @typedef {object} PackageExportResult
|
|
170
|
+
* @property {string} subpath
|
|
171
|
+
* @property {string} specifier
|
|
172
|
+
* @property {boolean} exported
|
|
173
|
+
* @property {string|null} target
|
|
174
|
+
* @property {string|null} authoredTarget
|
|
175
|
+
*/
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Inspect one public package subpath.
|
|
179
|
+
* @param {{name?: unknown, exports?: unknown}} pkg
|
|
180
|
+
* @param {string} packageDir
|
|
181
|
+
* @param {string} subpath `.` or a `./`-prefixed subpath
|
|
182
|
+
* @returns {PackageExportResult}
|
|
183
|
+
*/
|
|
184
|
+
export function inspectPackageExport(pkg, packageDir, subpath) {
|
|
185
|
+
const name = typeof pkg.name === 'string' ? pkg.name : '';
|
|
186
|
+
const selected = exportValue(pkg.exports, subpath);
|
|
187
|
+
const target = selected.hasMap
|
|
188
|
+
? selected.target
|
|
189
|
+
? resolveTarget(packageDir, selected.target)
|
|
190
|
+
: null
|
|
191
|
+
: resolveLegacy(packageDir, subpath);
|
|
192
|
+
const suffix = subpath === '.' ? '' : `/${subpath.slice(2)}`;
|
|
193
|
+
return {
|
|
194
|
+
subpath,
|
|
195
|
+
specifier: `${name}${suffix}`,
|
|
196
|
+
exported: selected.exported,
|
|
197
|
+
target,
|
|
198
|
+
authoredTarget: selected.target,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
@@ -49,6 +49,19 @@ export function effectiveTemplateDiscovery(templates: DiscoveredTemplate[]): Dis
|
|
|
49
49
|
* @returns {string} Source with demo asset references replaced.
|
|
50
50
|
*/
|
|
51
51
|
export function stripTemplateAssetRefs(source: string): string;
|
|
52
|
+
/**
|
|
53
|
+
* {@link stripTemplateAssetRefs}, plus how many references it replaced: one per
|
|
54
|
+
* replaced reference, however many fixture paths its URL carries (a reference
|
|
55
|
+
* is replaced whole, query included), and none for a prose mention or a
|
|
56
|
+
* third-party URL left as written. That count is what a receipt discloses.
|
|
57
|
+
*
|
|
58
|
+
* @param {string} source - Template source code.
|
|
59
|
+
* @returns {{source: string, demoMediaReplaced: number}}
|
|
60
|
+
*/
|
|
61
|
+
export function replaceDemoMedia(source: string): {
|
|
62
|
+
source: string;
|
|
63
|
+
demoMediaReplaced: number;
|
|
64
|
+
};
|
|
52
65
|
/**
|
|
53
66
|
* List the core page-template directory names (sorted). The `template --list`
|
|
54
67
|
* view discovers far more; this is the minimal core-page set `init` scaffolds
|
|
@@ -173,6 +186,7 @@ export type DiscoveredTemplate = {
|
|
|
173
186
|
name: string;
|
|
174
187
|
displayName?: string | undefined;
|
|
175
188
|
description: string;
|
|
189
|
+
keywords?: string[] | undefined;
|
|
176
190
|
category?: string | undefined;
|
|
177
191
|
isReady?: boolean | undefined;
|
|
178
192
|
scaffold?: boolean | undefined;
|
|
@@ -5,7 +5,7 @@ import * as fs from 'node:fs';
|
|
|
5
5
|
import * as path from 'node:path';
|
|
6
6
|
import {fileURLToPath} from 'node:url';
|
|
7
7
|
import jscodeshift from 'jscodeshift';
|
|
8
|
-
import {stripTemplateAssetRefs} from './template-adapter.mjs';
|
|
8
|
+
import {replaceDemoMedia, stripTemplateAssetRefs} from './template-adapter.mjs';
|
|
9
9
|
|
|
10
10
|
const PLACEHOLDER = stripTemplateAssetRefs("'/template-assets/x.png'").slice(
|
|
11
11
|
1,
|
|
@@ -212,6 +212,42 @@ describe('stripTemplateAssetRefs fixture references', () => {
|
|
|
212
212
|
});
|
|
213
213
|
});
|
|
214
214
|
|
|
215
|
+
describe('replaceDemoMedia', () => {
|
|
216
|
+
it('counts a reference once, however many fixture paths its URL carries', () => {
|
|
217
|
+
const source =
|
|
218
|
+
"const hero = '/template-assets/a.png?f=/template-assets/b.png';";
|
|
219
|
+
expect(replaceDemoMedia(source)).toEqual({
|
|
220
|
+
source: stripTemplateAssetRefs(source),
|
|
221
|
+
demoMediaReplaced: 1,
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
it('counts a poster and a video as two references', () => {
|
|
226
|
+
const source =
|
|
227
|
+
'<video poster="/template-assets/poster.jpg" src="/template-assets/clip.mp4" />';
|
|
228
|
+
const result = replaceDemoMedia(source);
|
|
229
|
+
expect(result).toEqual({
|
|
230
|
+
source: stripTemplateAssetRefs(source),
|
|
231
|
+
demoMediaReplaced: 2,
|
|
232
|
+
});
|
|
233
|
+
expect(result.source).not.toContain('/template-assets/');
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
it.each([
|
|
237
|
+
[
|
|
238
|
+
'a prose mention',
|
|
239
|
+
'<p>Demo media lives under /template-assets/ in the docsite.</p>',
|
|
240
|
+
],
|
|
241
|
+
[
|
|
242
|
+
'a third-party URL',
|
|
243
|
+
"const u = 'https://example.com/template-assets/a.png';",
|
|
244
|
+
],
|
|
245
|
+
['source with no fixture', 'const x = 1;'],
|
|
246
|
+
])('counts nothing for %s it leaves as written', (_label, source) => {
|
|
247
|
+
expect(replaceDemoMedia(source)).toEqual({source, demoMediaReplaced: 0});
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
|
|
215
251
|
describe('shipped templates', () => {
|
|
216
252
|
it('copy with every fixture replaced and still parse', () => {
|
|
217
253
|
const root = path.resolve(
|
|
@@ -102,6 +102,7 @@ export function effectiveTemplateDiscovery(templates) {
|
|
|
102
102
|
* @property {string} name
|
|
103
103
|
* @property {string} [displayName]
|
|
104
104
|
* @property {string} description
|
|
105
|
+
* @property {string[]} [keywords]
|
|
105
106
|
* @property {string} [category]
|
|
106
107
|
* @property {boolean} [isReady]
|
|
107
108
|
* @property {boolean} [scaffold]
|
|
@@ -320,9 +321,23 @@ function toPosixPath(p) {
|
|
|
320
321
|
* @returns {string} Source with demo asset references replaced.
|
|
321
322
|
*/
|
|
322
323
|
export function stripTemplateAssetRefs(source) {
|
|
324
|
+
return replaceDemoMedia(source).source;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* {@link stripTemplateAssetRefs}, plus how many references it replaced: one per
|
|
329
|
+
* replaced reference, however many fixture paths its URL carries (a reference
|
|
330
|
+
* is replaced whole, query included), and none for a prose mention or a
|
|
331
|
+
* third-party URL left as written. That count is what a receipt discloses.
|
|
332
|
+
*
|
|
333
|
+
* @param {string} source - Template source code.
|
|
334
|
+
* @returns {{source: string, demoMediaReplaced: number}}
|
|
335
|
+
*/
|
|
336
|
+
export function replaceDemoMedia(source) {
|
|
323
337
|
const needle = `/${FIXTURE_SEGMENT}`;
|
|
324
338
|
let output = '';
|
|
325
339
|
let copied = 0;
|
|
340
|
+
let demoMediaReplaced = 0;
|
|
326
341
|
/** @type {Array<[number, number]> | undefined} */
|
|
327
342
|
let comments;
|
|
328
343
|
let at = source.indexOf(needle);
|
|
@@ -343,10 +358,11 @@ export function stripTemplateAssetRefs(source) {
|
|
|
343
358
|
if (edit) {
|
|
344
359
|
output += source.slice(copied, start) + edit.text;
|
|
345
360
|
copied = edit.end;
|
|
361
|
+
demoMediaReplaced += 1;
|
|
346
362
|
}
|
|
347
363
|
at = source.indexOf(needle, end);
|
|
348
364
|
}
|
|
349
|
-
return output + source.slice(copied);
|
|
365
|
+
return {source: output + source.slice(copied), demoMediaReplaced};
|
|
350
366
|
}
|
|
351
367
|
|
|
352
368
|
/** @param {string | undefined} char */
|
|
@@ -633,6 +649,7 @@ async function discoverPages() {
|
|
|
633
649
|
name: doc?.name || dir.name,
|
|
634
650
|
description: doc?.description || '',
|
|
635
651
|
category: doc?.category || '',
|
|
652
|
+
keywords: doc?.keywords ?? [],
|
|
636
653
|
isReady: doc?.isReady ?? true,
|
|
637
654
|
scaffold: doc?.scaffold ?? false,
|
|
638
655
|
filePath: path.join(dirPath, 'page.tsx'),
|
|
@@ -661,6 +678,7 @@ async function discoverBlocks() {
|
|
|
661
678
|
dirName: basename,
|
|
662
679
|
name: doc?.name || basename,
|
|
663
680
|
description: doc?.description || '',
|
|
681
|
+
keywords: doc?.keywords ?? [],
|
|
664
682
|
isReady: doc?.isReady ?? true,
|
|
665
683
|
aspectRatio: doc?.aspectRatio ?? 1,
|
|
666
684
|
componentsUsed: doc?.componentsUsed ?? [],
|
|
@@ -702,6 +720,7 @@ async function discoverExternalBlocks(cwd = process.cwd()) {
|
|
|
702
720
|
dirName: basename,
|
|
703
721
|
name: doc?.name || basename,
|
|
704
722
|
description: doc?.description || '',
|
|
723
|
+
keywords: doc?.keywords ?? [],
|
|
705
724
|
isReady: doc?.isReady ?? true,
|
|
706
725
|
aspectRatio: doc?.aspectRatio ?? 1,
|
|
707
726
|
componentsUsed: doc?.componentsUsed ?? [],
|
|
@@ -1269,6 +1288,7 @@ export async function discoverIntegrationTemplatesForOne(integration) {
|
|
|
1269
1288
|
name: doc?.name || id,
|
|
1270
1289
|
displayName: doc?.displayName,
|
|
1271
1290
|
description: doc?.description || '',
|
|
1291
|
+
keywords: doc?.keywords ?? [],
|
|
1272
1292
|
category: doc?.category || '',
|
|
1273
1293
|
isReady: doc?.isReady ?? true,
|
|
1274
1294
|
scaffold: doc?.scaffold ?? false,
|
|
@@ -1,6 +1,38 @@
|
|
|
1
1
|
// @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {object} DiscoveredTheme
|
|
6
|
+
* @property {string} slug
|
|
7
|
+
* @property {string} displayName
|
|
8
|
+
* @property {string} description
|
|
9
|
+
* @property {boolean} maintained
|
|
10
|
+
* @property {string} entry
|
|
11
|
+
* @property {string} exportName
|
|
12
|
+
* @property {string[]} files what `theme eject` copies, relative to sourceDir,
|
|
13
|
+
* entry first
|
|
14
|
+
* @property {string} package package exposed for discovery and --package selection
|
|
15
|
+
* @property {string} [importPackage] package that owns built imports when it differs from the selector package
|
|
16
|
+
* @property {string} [packageDir] absolute package/project directory
|
|
17
|
+
* @property {Record<string, unknown>|null} [packageExports] parsed package exports
|
|
18
|
+
* @property {'bundled'|'package'|'local'} source
|
|
19
|
+
* @property {string} sourceDir absolute directory holding this theme's files
|
|
20
|
+
* @property {boolean} bundled
|
|
21
|
+
* @property {string} docPath absolute descriptor path
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* The package written to the app record and used for built imports. Bundled
|
|
25
|
+
* themes keep the released CLI package as their selector while importing from
|
|
26
|
+
* their standalone theme package.
|
|
27
|
+
* @param {DiscoveredTheme} theme
|
|
28
|
+
*/
|
|
29
|
+
export function themeImportPackage(theme: DiscoveredTheme): string;
|
|
30
|
+
/**
|
|
31
|
+
* Every module a theme source file imports or re-exports, as written.
|
|
32
|
+
* @param {string} file
|
|
33
|
+
* @returns {string[]}
|
|
34
|
+
*/
|
|
35
|
+
export function themeFileImports(file: string): string[];
|
|
4
36
|
/**
|
|
5
37
|
* How messages about a theme descriptor name it.
|
|
6
38
|
* @param {string} docPath
|
|
@@ -31,21 +63,32 @@ export function isThemeFolder(folder: string): boolean;
|
|
|
31
63
|
/**
|
|
32
64
|
* The files one theme folder ships: every regular file below it except
|
|
33
65
|
* {@link isIgnoredThemeEntry} entries. What pack-check requires and what
|
|
34
|
-
* `theme
|
|
66
|
+
* `theme eject` copies.
|
|
35
67
|
* @param {string} folder absolute path
|
|
36
68
|
* @returns {string[]} sorted POSIX paths relative to the folder
|
|
37
69
|
*/
|
|
38
70
|
export function listThemeFiles(folder: string): string[];
|
|
71
|
+
/**
|
|
72
|
+
* Source copies left by the released `theme add`, before it copied a
|
|
73
|
+
* descriptor. Commands skip these until the next-release project codemod adds
|
|
74
|
+
* the same-stem descriptor.
|
|
75
|
+
* @param {string} projectDir
|
|
76
|
+
* @param {string} [owner]
|
|
77
|
+
* @returns {UnmigratedThemeCopy[]}
|
|
78
|
+
*/
|
|
79
|
+
export function discoverUnmigratedThemeCopies(projectDir: string, owner?: string): UnmigratedThemeCopy[];
|
|
39
80
|
/**
|
|
40
81
|
* Discover and validate one theme root.
|
|
41
82
|
* @param {string} themeRoot absolute root containing one directory per slug
|
|
42
83
|
* @param {string} owner package that owns the root
|
|
43
|
-
* @param {{bundled?: boolean}} [options] a bundled root is the CLI's own; its
|
|
44
|
-
* sources are checked by the CLI's tests rather than on every read
|
|
84
|
+
* @param {{bundled?: boolean, allowUnmigrated?: boolean}} [options] a bundled root is the CLI's own; its
|
|
85
|
+
* sources are checked by the CLI's tests rather than on every read. A local
|
|
86
|
+
* root may skip released source copies until `astryx upgrade` adds descriptors.
|
|
45
87
|
* @returns {DiscoveredTheme[]}
|
|
46
88
|
*/
|
|
47
|
-
export function discoverThemeDirectory(themeRoot: string, owner: string, { bundled }?: {
|
|
89
|
+
export function discoverThemeDirectory(themeRoot: string, owner: string, { bundled, allowUnmigrated }?: {
|
|
48
90
|
bundled?: boolean;
|
|
91
|
+
allowUnmigrated?: boolean;
|
|
49
92
|
}): DiscoveredTheme[];
|
|
50
93
|
/**
|
|
51
94
|
* Folders under a themes root that look like themes (see looksLikeTheme)
|
|
@@ -63,6 +106,13 @@ export function unreadThemeFolders(themeRoot: string, { packageDir, packageName
|
|
|
63
106
|
}): string[];
|
|
64
107
|
/** @returns {DiscoveredTheme[]} */
|
|
65
108
|
export function discoverBundledThemes(): DiscoveredTheme[];
|
|
109
|
+
/**
|
|
110
|
+
* Discover authored themes in the app's conventional local themes root.
|
|
111
|
+
* @param {string} projectDir
|
|
112
|
+
* @param {string} [owner]
|
|
113
|
+
* @returns {DiscoveredTheme[]}
|
|
114
|
+
*/
|
|
115
|
+
export function discoverLocalThemes(projectDir: string, owner?: string): DiscoveredTheme[];
|
|
66
116
|
/**
|
|
67
117
|
* @param {import('../integrations/integrations.mjs').LoadedIntegration} integration
|
|
68
118
|
* @returns {Promise<DiscoveredTheme[]>}
|
|
@@ -82,11 +132,27 @@ export type DiscoveredTheme = {
|
|
|
82
132
|
entry: string;
|
|
83
133
|
exportName: string;
|
|
84
134
|
/**
|
|
85
|
-
* what `theme
|
|
135
|
+
* what `theme eject` copies, relative to sourceDir,
|
|
86
136
|
* entry first
|
|
87
137
|
*/
|
|
88
138
|
files: string[];
|
|
139
|
+
/**
|
|
140
|
+
* package exposed for discovery and --package selection
|
|
141
|
+
*/
|
|
89
142
|
package: string;
|
|
143
|
+
/**
|
|
144
|
+
* package that owns built imports when it differs from the selector package
|
|
145
|
+
*/
|
|
146
|
+
importPackage?: string | undefined;
|
|
147
|
+
/**
|
|
148
|
+
* absolute package/project directory
|
|
149
|
+
*/
|
|
150
|
+
packageDir?: string | undefined;
|
|
151
|
+
/**
|
|
152
|
+
* parsed package exports
|
|
153
|
+
*/
|
|
154
|
+
packageExports?: Record<string, unknown> | null | undefined;
|
|
155
|
+
source: "bundled" | "package" | "local";
|
|
90
156
|
/**
|
|
91
157
|
* absolute directory holding this theme's files
|
|
92
158
|
*/
|
|
@@ -97,3 +163,10 @@ export type DiscoveredTheme = {
|
|
|
97
163
|
*/
|
|
98
164
|
docPath: string;
|
|
99
165
|
};
|
|
166
|
+
export type UnmigratedThemeCopy = {
|
|
167
|
+
slug: string;
|
|
168
|
+
sourceDir: string;
|
|
169
|
+
entry: string;
|
|
170
|
+
exportName: string;
|
|
171
|
+
descriptor: string;
|
|
172
|
+
};
|