@astryxdesign/cli 0.6.6 → 0.6.7-canary.796bcc2
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 +129 -0
- package/README.md +84 -82
- package/api/build/_adapter.d.mts +20 -0
- package/api/build/_adapter.mjs +24 -0
- package/api/build/build.doc.mjs +1 -1
- package/api/build/build.test.mjs +1 -1
- package/api/build/build.type.d.mts +12 -0
- package/api/build/build.type.mjs +3 -0
- package/api/build/help/help.mjs +1 -1
- package/api/build/kit/kit.mjs +13 -1
- package/api/component/_adapter.d.mts +19 -0
- package/api/component/_adapter.mjs +33 -0
- package/api/component/component-replacement.test.mjs +615 -0
- package/api/component/component.doc.mjs +5 -2
- 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 +73 -1
- package/api/docs/compiled-topics.test.mjs +1 -1
- package/api/docs/detail/detail.mjs +19 -3
- package/api/docs/detail/section/section.d.mts +44 -0
- package/api/docs/detail/section/section.mjs +171 -14
- package/api/docs/detail/section/section.test.mjs +4 -4
- package/api/docs/docOverlays.test.mjs +38 -23
- package/api/docs/docs.depth.test.mjs +2 -0
- package/api/docs/docs.doc.mjs +3 -3
- package/api/docs/docs.mjs +13 -16
- package/api/docs/docs.test.mjs +9 -10
- package/api/docs/docs.type.d.mts +43 -3
- package/api/docs/docs.type.mjs +23 -3
- package/api/docs/index/index.mjs +11 -2
- package/api/docs/index/index.test.mjs +7 -2
- package/api/docs/integration-tree.test.mjs +26 -26
- package/api/docs/integrationDocs.test.mjs +8 -7
- package/api/docs/namespace-section.test.mjs +260 -0
- package/api/docs/node/node.mjs +3 -0
- package/api/docs/token-tables.test.mjs +93 -0
- package/api/doctor/_adapter.d.mts +50 -0
- package/api/doctor/_adapter.mjs +190 -0
- package/api/doctor/doctor.d.mts +6 -10
- package/api/doctor/doctor.doc.mjs +1 -3
- package/api/doctor/doctor.mjs +144 -150
- package/api/doctor/doctor.test.mjs +104 -0
- 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/gap-report/gap-report.doc.mjs +2 -1
- package/api/gap-report/gap-report.mjs +15 -1
- 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.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-helpers.d.mts +26 -5
- package/api/integration/add-helpers.mjs +50 -5
- package/api/integration/add-theme.mjs +16 -2
- package/api/integration/add-theme.test.mjs +66 -15
- package/api/integration/authoring-checks.mjs +21 -1
- package/api/integration/integrationComponentConflicts.doc.mjs +6 -3
- 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 +485 -3
- package/api/integration/pack-check.test.mjs +578 -10
- package/api/integration/validate-integration.mjs +20 -4
- package/api/integration/validate-integration.test.mjs +73 -0
- 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 +1 -0
- package/api/layout/grammar/grammar.d.mts +1 -0
- package/api/layout/grammar/grammar.mjs +1 -0
- package/api/layout/layoutCheck.doc.mjs +1 -1
- package/api/layout/layoutExpand.doc.mjs +1 -1
- package/api/layout/layoutGrammar.doc.mjs +1 -1
- package/api/search/search.d.mts +47 -3
- package/api/search/search.doc.mjs +1 -1
- package/api/search/search.domain-priority.test.mjs +261 -0
- package/api/search/search.mjs +247 -43
- package/api/search/search.test.mjs +5 -1
- package/api/search/search.type.d.mts +3 -3
- package/api/search/search.type.mjs +2 -2
- 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 +29 -10
- package/api/swizzle/list/list.mjs +2 -2
- package/api/swizzle/swizzle.doc.mjs +5 -2
- 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 +14 -1
- package/api/template/show/show.mjs +2 -0
- package/api/template/skeleton/skeleton.mjs +2 -1
- package/api/template/template.d.mts +1 -1
- package/api/template/template.doc.mjs +1 -1
- package/api/template/template.mjs +1 -0
- package/api/template/template.type.d.mts +15 -0
- package/api/template/template.type.mjs +6 -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 +96 -2
- package/api/theme/build/build.family.test.mjs +13 -4
- package/api/theme/build/build.mjs +286 -118
- package/api/theme/build/build.test.mjs +30 -0
- package/api/theme/build/font-warning.d.mts +11 -0
- package/api/theme/build/font-warning.mjs +28 -3
- 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.mjs +1 -1
- 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/upgrade.type.d.mts +4 -0
- package/api/upgrade/upgrade.type.mjs +1 -0
- package/assets/codemods/__tests__/registry.test.mjs +1 -0
- package/assets/codemods/integration-discovery.mjs +1 -1
- package/assets/codemods/integration-discovery.test.mjs +64 -0
- package/assets/codemods/registry.mjs +1 -0
- package/assets/codemods/transforms/v0.6.7/__tests__/migrate-copied-themes-to-descriptors.test.mjs +129 -0
- package/assets/codemods/transforms/v0.6.7/index.mjs +23 -0
- package/assets/codemods/transforms/v0.6.7/migrate-copied-themes-to-descriptors.mjs +54 -0
- package/assets/docs/author-a-theme.doc.mjs +166 -0
- package/assets/docs/getting-started.doc.mjs +61 -17
- package/assets/docs/principles.doc.dense.mjs +4 -4
- package/assets/docs/principles.doc.mjs +6 -6
- package/assets/docs/principles.doc.zh.mjs +4 -4
- package/assets/docs/styling-overview.doc.mjs +211 -0
- package/assets/docs/theme.doc.dense.mjs +10 -198
- package/assets/docs/theme.doc.mjs +13 -771
- package/assets/docs/theme.doc.zh.mjs +31 -12
- package/assets/docs/tree/add-a-theme.doc.mjs +2 -2
- package/assets/docs/tree/checks.doc.mjs +6 -5
- package/assets/docs/tree/component-migration.doc.mjs +107 -0
- package/assets/docs/tree/css-and-stylex.doc.mjs +150 -0
- package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
- package/assets/docs/tree/document-the-theme.doc.mjs +4 -4
- package/assets/docs/tree/font-setup.doc.mjs +122 -0
- package/assets/docs/tree/fonts-and-assets.doc.mjs +25 -20
- package/assets/docs/tree/headers-and-footers.doc.mjs +67 -0
- package/assets/docs/tree/i18n-library-integration.doc.mjs +167 -0
- package/assets/docs/tree/i18n-quick-start.doc.mjs +101 -0
- package/assets/docs/{internationalization.doc.mjs → tree/i18n-rtl-and-testing.doc.mjs} +17 -223
- package/assets/docs/tree/internationalization.doc.mjs +29 -0
- package/assets/docs/tree/layout-spacing.doc.mjs +168 -0
- package/assets/docs/tree/layout.doc.mjs +55 -0
- package/assets/docs/{migration.doc.mjs → tree/migration-setup.doc.mjs} +24 -129
- package/assets/docs/tree/migration-verification.doc.mjs +67 -0
- package/assets/docs/tree/migration.doc.mjs +28 -0
- package/assets/docs/tree/non-css-processing.doc.mjs +112 -0
- package/assets/docs/tree/other-libraries.doc.mjs +218 -0
- package/assets/docs/tree/replace-a-core-component.doc.mjs +21 -4
- package/assets/docs/tree/replace-a-core-template.doc.mjs +1 -1
- package/assets/docs/tree/responsive.doc.mjs +98 -0
- package/assets/docs/tree/scaffold.doc.mjs +140 -0
- package/assets/docs/tree/side-panels.doc.mjs +81 -0
- package/assets/docs/tree/structure.doc.mjs +140 -0
- package/assets/docs/tree/styling-advanced.doc.mjs +159 -0
- package/assets/docs/tree/styling-basics.doc.mjs +181 -0
- package/assets/docs/tree/styling-libraries.doc.mjs +30 -0
- package/assets/docs/tree/styling.doc.mjs +29 -0
- package/assets/docs/tree/tailwind.doc.mjs +65 -0
- package/assets/docs/tree/template-doc-overview.doc.mjs +1 -1
- package/assets/docs/tree/themes.doc.mjs +2 -2
- package/assets/docs/tree/tokens-and-setup.doc.mjs +128 -0
- package/assets/docs/tree/tokens-border.doc.mjs +46 -0
- package/assets/docs/tree/tokens-color.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-color.doc.mjs +438 -0
- package/assets/docs/tree/tokens-color.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-data.doc.mjs +323 -0
- package/assets/docs/tree/tokens-duration.doc.mjs +78 -0
- package/assets/docs/tree/tokens-ease.doc.mjs +46 -0
- package/assets/docs/tree/tokens-focus.doc.mjs +57 -0
- package/assets/docs/tree/tokens-font-weight.doc.mjs +58 -0
- package/assets/docs/tree/tokens-radius.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-radius.doc.mjs +70 -0
- package/assets/docs/tree/tokens-radius.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-shadow.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-shadow.doc.mjs +74 -0
- package/assets/docs/tree/tokens-shadow.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-size.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-size.doc.mjs +54 -0
- package/assets/docs/tree/tokens-size.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-spacing.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-spacing.doc.mjs +102 -0
- package/assets/docs/tree/tokens-spacing.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-syntax.doc.mjs +98 -0
- package/assets/docs/tree/tokens-text-size.doc.mjs +90 -0
- package/assets/docs/tree/tokens-type-scale.doc.mjs +210 -0
- package/assets/docs/tree/tokens-typography.doc.mjs +54 -0
- package/assets/docs/tree/tokens-usage.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-usage.doc.mjs +36 -0
- package/assets/docs/tree/tokens-usage.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens.doc.mjs +28 -0
- package/assets/docs/tree/troubleshooting.doc.mjs +7 -3
- package/assets/docs/tree/type-scale.doc.mjs +147 -0
- package/assets/docs/tree/typography-best-practices.doc.mjs +55 -0
- package/assets/docs/tree/typography.doc.mjs +29 -0
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +22 -5
- package/assets/docs/tree/versioning.doc.mjs +6 -3
- package/assets/docs/use-a-theme.doc.mjs +212 -0
- package/assets/templates/pages/incident-console/page.tsx +1 -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/theme.template.ts +4 -3
- 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/template.doc.mjs +2 -2
- package/authoring/doctypes/template/type.ts +5 -3
- package/authoring/integration/integration.doc.mjs +1 -1
- package/clients/cli/commands/blog.mjs +3 -3
- package/clients/cli/commands/build-theme.adaptations.test.mjs +1 -1
- package/clients/cli/commands/build-theme.ascii-output.test.mjs +11 -1
- package/clients/cli/commands/build-theme.batch-report.test.mjs +335 -0
- package/clients/cli/commands/build-theme.font-warning.test.mjs +36 -7
- package/clients/cli/commands/build-theme.import-path.test.mjs +3 -3
- package/clients/cli/commands/build-theme.mjs +338 -45
- package/clients/cli/commands/build-theme.watch.test.mjs +33 -0
- package/clients/cli/commands/build.mjs +8 -6
- package/clients/cli/commands/build.text-fields.test.mjs +1 -1
- package/clients/cli/commands/component/index.mjs +91 -12
- package/clients/cli/commands/component-replacement.text.test.mjs +316 -0
- package/clients/cli/commands/component.doc.mjs +9 -2
- package/clients/cli/commands/docs.doc.mjs +2 -1
- package/clients/cli/commands/docs.mjs +63 -23
- package/clients/cli/commands/docs.test.mjs +17 -15
- 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.test.mjs +59 -52
- package/clients/cli/commands/gap-report.doc.mjs +2 -2
- package/clients/cli/commands/hook/index.mjs +7 -2
- package/clients/cli/commands/import-hint-correctness.test.mjs +28 -5
- package/clients/cli/commands/init.next-steps.test.mjs +18 -23
- package/clients/cli/commands/integration-real-world.test.mjs +61 -12
- package/clients/cli/commands/layout-check.doc.mjs +2 -0
- package/clients/cli/commands/layout-expand.doc.mjs +2 -0
- 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.mjs +40 -4
- package/clients/cli/commands/no-prompt-wording.test.mjs +4 -4
- package/clients/cli/commands/search.test.mjs +10 -4
- package/clients/cli/commands/swizzle.doc.mjs +12 -3
- package/clients/cli/commands/swizzle.mjs +2 -1
- package/clients/cli/commands/swizzle.routing.test.mjs +2 -1
- package/clients/cli/commands/template.mjs +56 -5
- package/clients/cli/commands/text-json-parity.test.mjs +40 -0
- package/clients/cli/commands/theme-add-lifecycle.test.mjs +135 -0
- package/clients/cli/commands/theme-add.doc.mjs +19 -19
- package/clients/cli/commands/theme-build.doc.mjs +3 -1
- package/clients/cli/commands/theme-eject.doc.mjs +47 -0
- package/clients/cli/commands/theme-list.behavior.test.mjs +5 -2
- 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.config-ordering.test.mjs +2 -1
- package/clients/cli/commands/upgrade.mjs +1 -1
- package/clients/cli/index.mjs +5 -2
- package/clients/cli/lib/component-format.mjs +29 -2
- package/clients/cli/lib/component-format.test.mjs +1 -1
- package/clients/cli/lib/define-command.mjs +4 -0
- 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 +48 -30
- package/foundation/agent-docs/agent-docs.test.mjs +47 -34
- 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/project.test.mjs +1 -1
- 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-discovery.test.mjs +1 -1
- 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-needs.d.mts +31 -0
- package/foundation/discovery/template-needs.mjs +156 -0
- package/foundation/discovery/template-needs.test.mjs +203 -0
- package/foundation/discovery/theme-discovery.d.mts +72 -5
- package/foundation/discovery/theme-discovery.mjs +134 -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/bundle.mjs +52 -1
- package/foundation/doc-compiler/doc-loads.test.mjs +15 -5
- package/foundation/doc-compiler/inputs.mjs +2 -1
- package/foundation/doc-compiler/lenses.d.mts +4 -2
- package/foundation/doc-compiler/lenses.mjs +1 -1
- package/foundation/doc-compiler/split-topic-keywords.test.mjs +73 -0
- package/foundation/doc-compiler/tree.d.mts +10 -0
- package/foundation/doc-compiler/tree.mjs +22 -0
- package/foundation/doc-compiler/tree.test.mjs +3 -2
- package/foundation/env/package-manager.d.mts +31 -8
- package/foundation/env/package-manager.mjs +120 -13
- package/foundation/env/package-manager.test.mjs +174 -1
- package/foundation/fs/module-loader.d.mts +9 -0
- package/foundation/fs/module-loader.mjs +71 -2
- package/foundation/integrations/cli-requirement.d.mts +43 -10
- package/foundation/integrations/cli-requirement.mjs +56 -13
- package/foundation/integrations/cli-requirement.test.mjs +160 -23
- package/foundation/integrations/contribution-inventory.mjs +3 -3
- package/foundation/integrations/validate-contributions.d.mts +16 -0
- package/foundation/integrations/validate-contributions.mjs +56 -8
- 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.mjs +41 -26
- 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
- package/assets/docs/styling-libraries.doc.mjs +0 -469
- package/assets/docs/styling.doc.mjs +0 -412
- package/assets/docs/tokens.doc.dense.mjs +0 -15
- package/assets/docs/tokens.doc.mjs +0 -1491
- package/assets/docs/tokens.doc.zh.mjs +0 -15
- package/assets/docs/typography.doc.mjs +0 -286
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Tests for template-needs analysis: external package detection, StyleX
|
|
5
|
+
* compiler warning, and install command generation.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import {describe, it, expect, beforeEach, afterEach} from 'vitest';
|
|
9
|
+
import * as fs from 'node:fs';
|
|
10
|
+
import * as os from 'node:os';
|
|
11
|
+
import * as path from 'node:path';
|
|
12
|
+
import {
|
|
13
|
+
extractImportedPackages,
|
|
14
|
+
analyzeTemplateNeeds,
|
|
15
|
+
} from './template-needs.mjs';
|
|
16
|
+
|
|
17
|
+
// ── extractImportedPackages ─────────────────────────────────────────────────
|
|
18
|
+
|
|
19
|
+
describe('extractImportedPackages', () => {
|
|
20
|
+
it('extracts bare package names from static imports', () => {
|
|
21
|
+
const source = `
|
|
22
|
+
import {Button} from '@astryxdesign/core';
|
|
23
|
+
import {ArrowIcon} from '@heroicons/react/24/outline';
|
|
24
|
+
import * as stylex from '@stylexjs/stylex';
|
|
25
|
+
import {useState} from 'react';
|
|
26
|
+
import recharts from 'recharts';
|
|
27
|
+
`;
|
|
28
|
+
const pkgs = extractImportedPackages(source);
|
|
29
|
+
expect(pkgs).toEqual(
|
|
30
|
+
new Set([
|
|
31
|
+
'@astryxdesign/core',
|
|
32
|
+
'@heroicons/react',
|
|
33
|
+
'@stylexjs/stylex',
|
|
34
|
+
'react',
|
|
35
|
+
'recharts',
|
|
36
|
+
]),
|
|
37
|
+
);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('ignores relative and absolute imports', () => {
|
|
41
|
+
const source = `
|
|
42
|
+
import {foo} from './bar';
|
|
43
|
+
import {baz} from '../qux';
|
|
44
|
+
import {thing} from '/absolute/path';
|
|
45
|
+
`;
|
|
46
|
+
expect(extractImportedPackages(source).size).toBe(0);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('ignores Node builtins with the node: prefix', () => {
|
|
50
|
+
const source = `
|
|
51
|
+
import * as fs from 'node:fs';
|
|
52
|
+
import * as path from 'node:path';
|
|
53
|
+
import {createRequire} from 'node:module';
|
|
54
|
+
`;
|
|
55
|
+
expect(extractImportedPackages(source).size).toBe(0);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('ignores bare Node builtins and their subpaths', () => {
|
|
59
|
+
const source = `
|
|
60
|
+
import * as fs from 'fs';
|
|
61
|
+
import {join} from 'path';
|
|
62
|
+
import {createReadStream} from 'fs/promises';
|
|
63
|
+
`;
|
|
64
|
+
expect(extractImportedPackages(source).size).toBe(0);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('handles type imports', () => {
|
|
68
|
+
const source = `import type {Props} from 'some-package';`;
|
|
69
|
+
expect(extractImportedPackages(source)).toEqual(new Set(['some-package']));
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('deduplicates multiple imports from the same package', () => {
|
|
73
|
+
const source = `
|
|
74
|
+
import {A} from '@heroicons/react/24/outline';
|
|
75
|
+
import {B} from '@heroicons/react/24/solid';
|
|
76
|
+
`;
|
|
77
|
+
expect(extractImportedPackages(source)).toEqual(
|
|
78
|
+
new Set(['@heroicons/react']),
|
|
79
|
+
);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('maps subpath imports to the package root', () => {
|
|
83
|
+
const source = `
|
|
84
|
+
import debounce from 'lodash/debounce';
|
|
85
|
+
import {Chart} from 'recharts/es6';
|
|
86
|
+
`;
|
|
87
|
+
const pkgs = extractImportedPackages(source);
|
|
88
|
+
expect(pkgs).toEqual(new Set(['lodash', 'recharts']));
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// ── analyzeTemplateNeeds ────────────────────────────────────────────────────
|
|
93
|
+
|
|
94
|
+
describe('analyzeTemplateNeeds', () => {
|
|
95
|
+
let dir;
|
|
96
|
+
beforeEach(() => {
|
|
97
|
+
dir = fs.mkdtempSync(path.join(os.tmpdir(), 'tmpl-needs-'));
|
|
98
|
+
});
|
|
99
|
+
afterEach(() => fs.rmSync(dir, {recursive: true, force: true}));
|
|
100
|
+
|
|
101
|
+
it('reports missing external packages with an install command', () => {
|
|
102
|
+
fs.writeFileSync(
|
|
103
|
+
path.join(dir, 'package.json'),
|
|
104
|
+
JSON.stringify({dependencies: {'react': '^19.0.0', '@astryxdesign/core': '^0.6.0'}}),
|
|
105
|
+
);
|
|
106
|
+
const source = `
|
|
107
|
+
import {Button} from '@astryxdesign/core';
|
|
108
|
+
import {ArrowIcon} from '@heroicons/react/24/outline';
|
|
109
|
+
import {useState} from 'react';
|
|
110
|
+
`;
|
|
111
|
+
const result = analyzeTemplateNeeds(source, dir);
|
|
112
|
+
expect(result.missingPackages).toEqual(['@heroicons/react']);
|
|
113
|
+
expect(result.installCommand).toMatch(/npm install @heroicons\/react/);
|
|
114
|
+
expect(result.notes.length).toBeGreaterThanOrEqual(1);
|
|
115
|
+
expect(result.notes[0]).toMatch(/Install missing dependencies/);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('reports nothing when all packages are installed', () => {
|
|
119
|
+
fs.writeFileSync(
|
|
120
|
+
path.join(dir, 'package.json'),
|
|
121
|
+
JSON.stringify({
|
|
122
|
+
dependencies: {
|
|
123
|
+
'react': '^19.0.0',
|
|
124
|
+
'@astryxdesign/core': '^0.6.0',
|
|
125
|
+
'@heroicons/react': '^2.2.0',
|
|
126
|
+
},
|
|
127
|
+
}),
|
|
128
|
+
);
|
|
129
|
+
const source = `
|
|
130
|
+
import {Button} from '@astryxdesign/core';
|
|
131
|
+
import {ArrowIcon} from '@heroicons/react/24/outline';
|
|
132
|
+
`;
|
|
133
|
+
const result = analyzeTemplateNeeds(source, dir);
|
|
134
|
+
expect(result.missingPackages).toEqual([]);
|
|
135
|
+
expect(result.installCommand).toBeNull();
|
|
136
|
+
expect(result.notes).toEqual([]);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('warns about StyleX compiler when template uses it and project lacks one', () => {
|
|
140
|
+
fs.writeFileSync(
|
|
141
|
+
path.join(dir, 'package.json'),
|
|
142
|
+
JSON.stringify({dependencies: {'@stylexjs/stylex': '^0.10.0'}}),
|
|
143
|
+
);
|
|
144
|
+
const source = `import * as stylex from '@stylexjs/stylex';`;
|
|
145
|
+
const result = analyzeTemplateNeeds(source, dir);
|
|
146
|
+
expect(result.notes).toEqual(
|
|
147
|
+
expect.arrayContaining([
|
|
148
|
+
expect.stringContaining('StyleX'),
|
|
149
|
+
expect.stringContaining('styling-overview'),
|
|
150
|
+
]),
|
|
151
|
+
);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it('does NOT warn about StyleX when the project has a compiler', () => {
|
|
155
|
+
fs.writeFileSync(
|
|
156
|
+
path.join(dir, 'package.json'),
|
|
157
|
+
JSON.stringify({
|
|
158
|
+
devDependencies: {
|
|
159
|
+
'@stylexjs/stylex': '^0.10.0',
|
|
160
|
+
'@stylexjs/rollup-plugin': '^0.10.0',
|
|
161
|
+
},
|
|
162
|
+
}),
|
|
163
|
+
);
|
|
164
|
+
const source = `import * as stylex from '@stylexjs/stylex';`;
|
|
165
|
+
const result = analyzeTemplateNeeds(source, dir);
|
|
166
|
+
const stylexNotes = result.notes.filter(n => n.includes('StyleX'));
|
|
167
|
+
expect(stylexNotes).toEqual([]);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it('detects pnpm from lockfile', () => {
|
|
171
|
+
fs.writeFileSync(path.join(dir, 'package.json'), '{}');
|
|
172
|
+
fs.writeFileSync(path.join(dir, 'pnpm-lock.yaml'), '');
|
|
173
|
+
const source = `import {Chart} from 'recharts';`;
|
|
174
|
+
const result = analyzeTemplateNeeds(source, dir);
|
|
175
|
+
expect(result.installCommand).toMatch(/^pnpm add /);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it('detects yarn from lockfile', () => {
|
|
179
|
+
fs.writeFileSync(path.join(dir, 'package.json'), '{}');
|
|
180
|
+
fs.writeFileSync(path.join(dir, 'yarn.lock'), '');
|
|
181
|
+
const source = `import {Chart} from 'recharts';`;
|
|
182
|
+
const result = analyzeTemplateNeeds(source, dir);
|
|
183
|
+
expect(result.installCommand).toMatch(/^yarn add /);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it('excludes @stylexjs/stylex from missing packages (it is a Core peer)', () => {
|
|
187
|
+
fs.writeFileSync(path.join(dir, 'package.json'), '{}');
|
|
188
|
+
const source = `import * as stylex from '@stylexjs/stylex';`;
|
|
189
|
+
const result = analyzeTemplateNeeds(source, dir);
|
|
190
|
+
expect(result.missingPackages).not.toContain('@stylexjs/stylex');
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
it('handles a template with no external imports', () => {
|
|
194
|
+
fs.writeFileSync(path.join(dir, 'package.json'), '{}');
|
|
195
|
+
const source = `
|
|
196
|
+
import {useState} from 'react';
|
|
197
|
+
import {Button} from '@astryxdesign/core';
|
|
198
|
+
`;
|
|
199
|
+
const result = analyzeTemplateNeeds(source, dir);
|
|
200
|
+
expect(result.notes).toEqual([]);
|
|
201
|
+
expect(result.missingPackages).toEqual([]);
|
|
202
|
+
});
|
|
203
|
+
});
|
|
@@ -1,6 +1,32 @@
|
|
|
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;
|
|
4
30
|
/**
|
|
5
31
|
* Every module a theme source file imports or re-exports, as written.
|
|
6
32
|
* @param {string} file
|
|
@@ -37,21 +63,32 @@ export function isThemeFolder(folder: string): boolean;
|
|
|
37
63
|
/**
|
|
38
64
|
* The files one theme folder ships: every regular file below it except
|
|
39
65
|
* {@link isIgnoredThemeEntry} entries. What pack-check requires and what
|
|
40
|
-
* `theme
|
|
66
|
+
* `theme eject` copies.
|
|
41
67
|
* @param {string} folder absolute path
|
|
42
68
|
* @returns {string[]} sorted POSIX paths relative to the folder
|
|
43
69
|
*/
|
|
44
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[];
|
|
45
80
|
/**
|
|
46
81
|
* Discover and validate one theme root.
|
|
47
82
|
* @param {string} themeRoot absolute root containing one directory per slug
|
|
48
83
|
* @param {string} owner package that owns the root
|
|
49
|
-
* @param {{bundled?: boolean}} [options] a bundled root is the CLI's own; its
|
|
50
|
-
* 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.
|
|
51
87
|
* @returns {DiscoveredTheme[]}
|
|
52
88
|
*/
|
|
53
|
-
export function discoverThemeDirectory(themeRoot: string, owner: string, { bundled }?: {
|
|
89
|
+
export function discoverThemeDirectory(themeRoot: string, owner: string, { bundled, allowUnmigrated }?: {
|
|
54
90
|
bundled?: boolean;
|
|
91
|
+
allowUnmigrated?: boolean;
|
|
55
92
|
}): DiscoveredTheme[];
|
|
56
93
|
/**
|
|
57
94
|
* Folders under a themes root that look like themes (see looksLikeTheme)
|
|
@@ -69,6 +106,13 @@ export function unreadThemeFolders(themeRoot: string, { packageDir, packageName
|
|
|
69
106
|
}): string[];
|
|
70
107
|
/** @returns {DiscoveredTheme[]} */
|
|
71
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[];
|
|
72
116
|
/**
|
|
73
117
|
* @param {import('../integrations/integrations.mjs').LoadedIntegration} integration
|
|
74
118
|
* @returns {Promise<DiscoveredTheme[]>}
|
|
@@ -88,11 +132,27 @@ export type DiscoveredTheme = {
|
|
|
88
132
|
entry: string;
|
|
89
133
|
exportName: string;
|
|
90
134
|
/**
|
|
91
|
-
* what `theme
|
|
135
|
+
* what `theme eject` copies, relative to sourceDir,
|
|
92
136
|
* entry first
|
|
93
137
|
*/
|
|
94
138
|
files: string[];
|
|
139
|
+
/**
|
|
140
|
+
* package exposed for discovery and --package selection
|
|
141
|
+
*/
|
|
95
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";
|
|
96
156
|
/**
|
|
97
157
|
* absolute directory holding this theme's files
|
|
98
158
|
*/
|
|
@@ -103,3 +163,10 @@ export type DiscoveredTheme = {
|
|
|
103
163
|
*/
|
|
104
164
|
docPath: string;
|
|
105
165
|
};
|
|
166
|
+
export type UnmigratedThemeCopy = {
|
|
167
|
+
slug: string;
|
|
168
|
+
sourceDir: string;
|
|
169
|
+
entry: string;
|
|
170
|
+
exportName: string;
|
|
171
|
+
descriptor: string;
|
|
172
|
+
};
|
|
@@ -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.
|
|
@@ -1016,7 +1031,7 @@ export function isThemeFolder(folder) {
|
|
|
1016
1031
|
/**
|
|
1017
1032
|
* The files one theme folder ships: every regular file below it except
|
|
1018
1033
|
* {@link isIgnoredThemeEntry} entries. What pack-check requires and what
|
|
1019
|
-
* `theme
|
|
1034
|
+
* `theme eject` copies.
|
|
1020
1035
|
* @param {string} folder absolute path
|
|
1021
1036
|
* @returns {string[]} sorted POSIX paths relative to the folder
|
|
1022
1037
|
*/
|
|
@@ -1024,14 +1039,76 @@ export function listThemeFiles(folder) {
|
|
|
1024
1039
|
return listThemeFolder(folder).files;
|
|
1025
1040
|
}
|
|
1026
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
|
+
|
|
1027
1105
|
/** @param {string[]} files */
|
|
1028
1106
|
function quoted(files) {
|
|
1029
1107
|
return files.map(file => `"${file}"`).join(', ');
|
|
1030
1108
|
}
|
|
1031
1109
|
|
|
1032
1110
|
/**
|
|
1033
|
-
* The files `theme
|
|
1034
|
-
* 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.
|
|
1035
1112
|
* @param {string} id the theme's export name without `Theme`
|
|
1036
1113
|
*/
|
|
1037
1114
|
function bundledThemeArtifacts(id) {
|
|
@@ -1046,9 +1123,9 @@ function bundledThemeArtifacts(id) {
|
|
|
1046
1123
|
}
|
|
1047
1124
|
|
|
1048
1125
|
/**
|
|
1049
|
-
* The files `theme
|
|
1050
|
-
*
|
|
1051
|
-
*
|
|
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.
|
|
1052
1129
|
* @param {string[]} files every regular file in the theme directory, sorted
|
|
1053
1130
|
* @param {string} entry
|
|
1054
1131
|
* @param {string} descriptor
|
|
@@ -1056,13 +1133,12 @@ function bundledThemeArtifacts(id) {
|
|
|
1056
1133
|
* @param {boolean} bundled
|
|
1057
1134
|
*/
|
|
1058
1135
|
function copiedThemeFiles(files, entry, descriptor, exportName, bundled) {
|
|
1059
|
-
const rest = files.filter(
|
|
1060
|
-
|
|
1061
|
-
);
|
|
1062
|
-
if (!bundled) return [entry, ...rest];
|
|
1136
|
+
const rest = files.filter(file => file !== entry && file !== descriptor);
|
|
1137
|
+
if (!bundled) return [entry, descriptor, ...rest];
|
|
1063
1138
|
const order = bundledThemeArtifacts(exportName.replace(/Theme$/u, ''));
|
|
1064
1139
|
return [
|
|
1065
1140
|
entry,
|
|
1141
|
+
descriptor,
|
|
1066
1142
|
...order.filter(file => rest.includes(file)),
|
|
1067
1143
|
...rest.filter(file => !order.includes(file)),
|
|
1068
1144
|
];
|
|
@@ -1072,14 +1148,15 @@ function copiedThemeFiles(files, entry, descriptor, exportName, bundled) {
|
|
|
1072
1148
|
* Discover and validate one theme root.
|
|
1073
1149
|
* @param {string} themeRoot absolute root containing one directory per slug
|
|
1074
1150
|
* @param {string} owner package that owns the root
|
|
1075
|
-
* @param {{bundled?: boolean}} [options] a bundled root is the CLI's own; its
|
|
1076
|
-
* 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.
|
|
1077
1154
|
* @returns {DiscoveredTheme[]}
|
|
1078
1155
|
*/
|
|
1079
1156
|
export function discoverThemeDirectory(
|
|
1080
1157
|
themeRoot,
|
|
1081
1158
|
owner,
|
|
1082
|
-
{bundled = false} = {},
|
|
1159
|
+
{bundled = false, allowUnmigrated = false} = {},
|
|
1083
1160
|
) {
|
|
1084
1161
|
if (!fs.existsSync(themeRoot) || !fs.statSync(themeRoot).isDirectory()) {
|
|
1085
1162
|
throw new Error(
|
|
@@ -1149,6 +1226,13 @@ export function discoverThemeDirectory(
|
|
|
1149
1226
|
file.endsWith(THEME_DOC_SUFFIX),
|
|
1150
1227
|
);
|
|
1151
1228
|
const docs = descriptors.filter(file => !file.includes('/'));
|
|
1229
|
+
if (
|
|
1230
|
+
allowUnmigrated &&
|
|
1231
|
+
descriptors.length === 0 &&
|
|
1232
|
+
unmigratedThemeCopy(sourceDir)
|
|
1233
|
+
) {
|
|
1234
|
+
continue;
|
|
1235
|
+
}
|
|
1152
1236
|
if (docs.length !== 1) {
|
|
1153
1237
|
const detail =
|
|
1154
1238
|
docs.length > 1
|
|
@@ -1263,6 +1347,7 @@ export function discoverThemeDirectory(
|
|
|
1263
1347
|
bundled,
|
|
1264
1348
|
),
|
|
1265
1349
|
package: owner,
|
|
1350
|
+
source: bundled ? 'bundled' : 'package',
|
|
1266
1351
|
sourceDir,
|
|
1267
1352
|
bundled,
|
|
1268
1353
|
docPath,
|
|
@@ -1375,15 +1460,46 @@ export function discoverBundledThemes() {
|
|
|
1375
1460
|
THEMES_DIR,
|
|
1376
1461
|
BUNDLED_THEME_PACKAGE,
|
|
1377
1462
|
{bundled: true},
|
|
1378
|
-
)
|
|
1463
|
+
).map(theme => ({
|
|
1464
|
+
...theme,
|
|
1465
|
+
importPackage: `@astryxdesign/theme-${theme.slug}`,
|
|
1466
|
+
source: /** @type {const} */ ('bundled'),
|
|
1467
|
+
}));
|
|
1379
1468
|
return bundledThemeCache.map(theme => ({...theme, files: [...theme.files]}));
|
|
1380
1469
|
}
|
|
1381
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
|
+
|
|
1382
1491
|
/**
|
|
1383
1492
|
* @param {import('../integrations/integrations.mjs').LoadedIntegration} integration
|
|
1384
1493
|
* @returns {Promise<DiscoveredTheme[]>}
|
|
1385
1494
|
*/
|
|
1386
1495
|
export async function discoverIntegrationThemes(integration) {
|
|
1387
1496
|
if (!integration.themes) return [];
|
|
1388
|
-
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
|
+
);
|
|
1389
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
|
+
}
|