@astryxdesign/cli 0.6.6 → 0.6.7-canary.13feb39
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 +52 -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 +11 -197
- package/assets/docs/theme.doc.mjs +16 -764
- 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 +28 -11
- 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,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
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
* Extract bare (non-relative) package names from ES import statements.
|
|
6
|
+
*
|
|
7
|
+
* @param {string} source Template source code
|
|
8
|
+
* @returns {Set<string>} Unique package names (scoped packages normalized to
|
|
9
|
+
* `@scope/name`, unscoped to the first path segment).
|
|
10
|
+
*/
|
|
11
|
+
export function extractImportedPackages(source: string): Set<string>;
|
|
12
|
+
/**
|
|
13
|
+
* Analyze what a template source needs that the target project lacks.
|
|
14
|
+
*
|
|
15
|
+
* Returns a `notes` array of human-readable setup notes, a structured
|
|
16
|
+
* `missingPackages` list, and an `installCommand` string ready to print.
|
|
17
|
+
* Each note is one actionable line.
|
|
18
|
+
*
|
|
19
|
+
* @param {string} source Template source code
|
|
20
|
+
* @param {string} cwd Target project directory
|
|
21
|
+
* @returns {{
|
|
22
|
+
* notes: string[],
|
|
23
|
+
* missingPackages: string[],
|
|
24
|
+
* installCommand: string | null,
|
|
25
|
+
* }}
|
|
26
|
+
*/
|
|
27
|
+
export function analyzeTemplateNeeds(source: string, cwd: string): {
|
|
28
|
+
notes: string[];
|
|
29
|
+
missingPackages: string[];
|
|
30
|
+
installCommand: string | null;
|
|
31
|
+
};
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Analyze what a scaffolded template needs that the target project lacks.
|
|
5
|
+
*
|
|
6
|
+
* Derives needs from the template's own source — its bare import specifiers —
|
|
7
|
+
* rather than from a hand-maintained list. Every import that is not an Astryx
|
|
8
|
+
* package, react/react-dom, or @stylexjs/stylex is external; the source is the
|
|
9
|
+
* only authority on what a template uses.
|
|
10
|
+
*
|
|
11
|
+
* Shared between `api/template/copy` (the scaffold receipt) and
|
|
12
|
+
* `api/build/kit` (the start recommendation).
|
|
13
|
+
*
|
|
14
|
+
* @position packages/cli/foundation/discovery — template discovery helpers;
|
|
15
|
+
* consumed by the template and build API leaves.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import * as fs from 'node:fs';
|
|
19
|
+
import * as path from 'node:path';
|
|
20
|
+
import module from 'node:module';
|
|
21
|
+
import {CLI_ROOT} from '../fs/paths.mjs';
|
|
22
|
+
import {detectStylingSystem} from '../agent-docs/agent-docs.mjs';
|
|
23
|
+
|
|
24
|
+
// ── Known packages that a template may import without the user installing them.
|
|
25
|
+
// react and react-dom are the framework; @astryxdesign/* is the design system
|
|
26
|
+
// the CLI already told the user to install; @stylexjs/stylex is a peer of Core.
|
|
27
|
+
const FRAMEWORK_PREFIXES = ['react', 'react-dom'];
|
|
28
|
+
const DESIGN_SYSTEM_SCOPE = '@astryxdesign/';
|
|
29
|
+
const STYLEX_RUNTIME = '@stylexjs/stylex';
|
|
30
|
+
|
|
31
|
+
// Node builtins: anything with a `node:` prefix or in builtinModules.
|
|
32
|
+
const NODE_BUILTINS = new Set(module.builtinModules);
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Extract bare (non-relative) package names from ES import statements.
|
|
36
|
+
*
|
|
37
|
+
* @param {string} source Template source code
|
|
38
|
+
* @returns {Set<string>} Unique package names (scoped packages normalized to
|
|
39
|
+
* `@scope/name`, unscoped to the first path segment).
|
|
40
|
+
*/
|
|
41
|
+
export function extractImportedPackages(source) {
|
|
42
|
+
// Matches `import … from '<specifier>'`, `import '<specifier>'`, and
|
|
43
|
+
// dynamic `import('<specifier>')`. Only bare specifiers (not starting with
|
|
44
|
+
// `.` or `/`).
|
|
45
|
+
const re = /(?:from\s+|import\s*\(?)['"]((?:@[^/'"]+\/)?[^./'"@][^'"]*)['"]/g;
|
|
46
|
+
/** @type {Set<string>} */
|
|
47
|
+
const pkgs = new Set();
|
|
48
|
+
let m;
|
|
49
|
+
while ((m = re.exec(source)) !== null) {
|
|
50
|
+
const spec = m[1];
|
|
51
|
+
// Skip Node builtins: `node:fs`, `fs`, `fs/promises`, etc.
|
|
52
|
+
if (spec.startsWith('node:')) continue;
|
|
53
|
+
const name = spec.startsWith('@')
|
|
54
|
+
? spec.split('/').slice(0, 2).join('/')
|
|
55
|
+
: spec.split('/')[0];
|
|
56
|
+
if (NODE_BUILTINS.has(name)) continue;
|
|
57
|
+
pkgs.add(name);
|
|
58
|
+
}
|
|
59
|
+
return pkgs;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Detect which package manager the project uses, from its lockfile.
|
|
64
|
+
* @param {string} cwd Project root
|
|
65
|
+
* @returns {'pnpm add' | 'yarn add' | 'bun add' | 'npm install'}
|
|
66
|
+
*/
|
|
67
|
+
function detectInstallCommand(cwd) {
|
|
68
|
+
if (fs.existsSync(path.join(cwd, 'pnpm-lock.yaml'))) return 'pnpm add';
|
|
69
|
+
if (fs.existsSync(path.join(cwd, 'yarn.lock'))) return 'yarn add';
|
|
70
|
+
if (fs.existsSync(path.join(cwd, 'bun.lockb'))) return 'bun add';
|
|
71
|
+
return 'npm install';
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Read the CLI package's own devDependencies for authoritative version ranges
|
|
76
|
+
* of external packages the templates use.
|
|
77
|
+
* @returns {Record<string, string>}
|
|
78
|
+
*/
|
|
79
|
+
function cliPackageRanges() {
|
|
80
|
+
try {
|
|
81
|
+
const pkgPath = path.join(CLI_ROOT, 'package.json');
|
|
82
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
83
|
+
return {...pkg.devDependencies};
|
|
84
|
+
} catch {
|
|
85
|
+
return {};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Analyze what a template source needs that the target project lacks.
|
|
91
|
+
*
|
|
92
|
+
* Returns a `notes` array of human-readable setup notes, a structured
|
|
93
|
+
* `missingPackages` list, and an `installCommand` string ready to print.
|
|
94
|
+
* Each note is one actionable line.
|
|
95
|
+
*
|
|
96
|
+
* @param {string} source Template source code
|
|
97
|
+
* @param {string} cwd Target project directory
|
|
98
|
+
* @returns {{
|
|
99
|
+
* notes: string[],
|
|
100
|
+
* missingPackages: string[],
|
|
101
|
+
* installCommand: string | null,
|
|
102
|
+
* }}
|
|
103
|
+
*/
|
|
104
|
+
export function analyzeTemplateNeeds(source, cwd) {
|
|
105
|
+
const imported = extractImportedPackages(source);
|
|
106
|
+
|
|
107
|
+
// ── External packages (not framework / design system / stylex runtime) ──
|
|
108
|
+
const external = [...imported].filter(
|
|
109
|
+
name =>
|
|
110
|
+
!FRAMEWORK_PREFIXES.includes(name) &&
|
|
111
|
+
!name.startsWith(DESIGN_SYSTEM_SCOPE) &&
|
|
112
|
+
name !== STYLEX_RUNTIME,
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
// Read the project's installed packages.
|
|
116
|
+
/** @type {Record<string, string>} */
|
|
117
|
+
let projectDeps = {};
|
|
118
|
+
try {
|
|
119
|
+
const pkg = JSON.parse(
|
|
120
|
+
fs.readFileSync(path.join(cwd, 'package.json'), 'utf-8'),
|
|
121
|
+
);
|
|
122
|
+
projectDeps = {...pkg.dependencies, ...pkg.devDependencies};
|
|
123
|
+
} catch {
|
|
124
|
+
// No package.json or unreadable — treat everything as missing.
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const missing = external.filter(p => !(p in projectDeps));
|
|
128
|
+
|
|
129
|
+
// Build the install command with version ranges from the CLI workspace.
|
|
130
|
+
let installCommand = null;
|
|
131
|
+
if (missing.length > 0) {
|
|
132
|
+
const pm = detectInstallCommand(cwd);
|
|
133
|
+
const ranges = cliPackageRanges();
|
|
134
|
+
const specs = missing.map(p => (ranges[p] ? `${p}@"${ranges[p]}"` : p));
|
|
135
|
+
installCommand = `${pm} ${specs.join(' ')}`;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// ── StyleX compiler ────────────────────────────────────────────────────
|
|
139
|
+
const usesStylex = imported.has(STYLEX_RUNTIME);
|
|
140
|
+
const stylexCompilerNeeded =
|
|
141
|
+
usesStylex && detectStylingSystem(cwd) !== 'stylex';
|
|
142
|
+
|
|
143
|
+
// ── Notes ──────────────────────────────────────────────────────────────
|
|
144
|
+
/** @type {string[]} */
|
|
145
|
+
const notes = [];
|
|
146
|
+
if (missing.length > 0) {
|
|
147
|
+
notes.push(`Install missing dependencies: ${installCommand}`);
|
|
148
|
+
}
|
|
149
|
+
if (stylexCompilerNeeded) {
|
|
150
|
+
notes.push(
|
|
151
|
+
'This template uses StyleX. Your project needs a StyleX compiler plugin \u2014 see `astryx docs styling-overview` for setup steps.',
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return {notes, missingPackages: missing, installCommand};
|
|
156
|
+
}
|