@astryxdesign/cli 0.6.5 → 0.6.6-canary.0d27f83
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +87 -0
- package/README.md +91 -88
- package/api/build/_adapter.d.mts +70 -2
- package/api/build/_adapter.mjs +122 -10
- package/api/build/build.doc.mjs +3 -3
- package/api/build/build.test.mjs +111 -2
- package/api/build/build.type.d.mts +12 -0
- package/api/build/build.type.mjs +3 -0
- package/api/build/help/help.mjs +1 -1
- package/api/build/kit/kit.mjs +110 -22
- package/api/build/kit/rank.d.mts +32 -8
- package/api/build/kit/rank.mjs +291 -97
- package/api/build/kit/rank.test.mjs +231 -48
- package/api/build/kit/weights.d.mts +82 -0
- package/api/build/kit/weights.json +1 -0
- package/api/build/kit/weights.mjs +305 -0
- package/api/build/kit/weights.test.mjs +190 -0
- package/api/component/_adapter.d.mts +19 -0
- package/api/component/_adapter.mjs +33 -0
- package/api/component/component-replacement.test.mjs +603 -0
- package/api/component/component.mjs +49 -15
- package/api/component/component.test.mjs +32 -0
- package/api/component/component.type.d.mts +33 -3
- package/api/component/component.type.mjs +10 -3
- package/api/component/detail/blocks/blocks.d.mts +2 -1
- package/api/component/detail/blocks/blocks.mjs +5 -2
- package/api/component/detail/detail.mjs +5 -1
- package/api/component/detail/props/props.d.mts +2 -1
- package/api/component/detail/props/props.mjs +3 -2
- package/api/component/detail/showcase/showcase.d.mts +3 -1
- package/api/component/detail/showcase/showcase.mjs +3 -1
- package/api/component/detail/source/source.d.mts +3 -2
- package/api/component/detail/source/source.mjs +7 -3
- package/api/component/list/list.mjs +128 -10
- package/api/docs/_adapter.d.mts +11 -0
- package/api/docs/_adapter.mjs +25 -0
- package/api/docs/detail/detail.mjs +19 -3
- package/api/docs/detail/section/section.mjs +7 -1
- package/api/docs/docOverlays.test.mjs +10 -6
- package/api/docs/docs.d.mts +6 -0
- package/api/docs/docs.depth.test.mjs +134 -0
- package/api/docs/docs.doc.mjs +31 -2
- package/api/docs/docs.mjs +46 -1
- package/api/docs/docs.test.mjs +279 -0
- package/api/docs/docs.type.d.mts +81 -4
- package/api/docs/docs.type.mjs +41 -4
- package/api/docs/index/index.mjs +11 -2
- package/api/docs/index/index.test.mjs +7 -2
- package/api/docs/integration-tree.test.mjs +572 -0
- package/api/docs/integrationDocs.test.mjs +337 -0
- package/api/docs/node/node.d.mts +28 -3
- package/api/docs/node/node.mjs +149 -23
- package/api/doctor/_adapter.d.mts +50 -0
- package/api/doctor/_adapter.mjs +190 -0
- package/api/doctor/doctor.d.mts +0 -10
- package/api/doctor/doctor.doc.mjs +1 -3
- package/api/doctor/doctor.mjs +8 -123
- package/api/doctor/theme-checks.d.mts +24 -0
- package/api/doctor/theme-checks.mjs +1231 -0
- package/api/doctor/theme-checks.test.mjs +667 -0
- package/api/error.d.mts +22 -0
- package/api/error.mjs +42 -0
- package/api/gap-report/gap-report.d.mts +3 -1
- package/api/gap-report/gap-report.mjs +27 -3
- package/api/gap-report/gap-report.test.mjs +106 -0
- package/api/hook/_adapter.d.mts +1 -0
- package/api/hook/_adapter.mjs +3 -0
- package/api/hook/detail/detail.mjs +2 -2
- package/api/hook/detail/params/params.mjs +2 -2
- package/api/hook/hook.type.d.mts +12 -0
- package/api/hook/hook.type.mjs +3 -0
- package/api/hook/list/list.d.mts +1 -1
- package/api/hook/list/list.mjs +8 -8
- package/api/index.d.mts +1 -1
- package/api/index.mjs +4 -0
- package/api/init/run/run.d.mts +3 -5
- package/api/init/run/run.mjs +11 -11
- package/api/integration/__fixtures__/released-0.6.5-ocean.d.mts +14 -0
- package/api/integration/__fixtures__/released-0.6.5-ocean.mjs +15 -0
- package/api/integration/add-contribution.d.mts +2 -1
- package/api/integration/add-contribution.mjs +7 -3
- package/api/integration/add-contribution.test.mjs +3 -3
- package/api/integration/add-helpers.d.mts +26 -5
- package/api/integration/add-helpers.mjs +50 -5
- package/api/integration/add-theme.mjs +354 -28
- package/api/integration/add-theme.test.mjs +380 -16
- package/api/integration/authoring-checks.mjs +31 -8
- package/api/integration/authoring-checks.type.d.mts +8 -0
- package/api/integration/authoring-checks.type.mjs +7 -3
- package/api/integration/integration-authoring.type.d.mts +4 -1
- package/api/integration/integration-authoring.type.mjs +6 -1
- package/api/integration/integrationAdd.doc.mjs +6 -0
- package/api/integration/integrationAddTheme.doc.mjs +10 -0
- package/api/integration/integrationComponentConflicts.doc.mjs +6 -3
- package/api/integration/integrationDocConflicts.doc.mjs +1 -1
- package/api/integration/integrationTemplateConflicts.doc.mjs +1 -1
- package/api/integration/pack-check.component-replaces.test.mjs +126 -0
- package/api/integration/pack-check.d.mts +10 -0
- package/api/integration/pack-check.lifecycle-output.test.mjs +21 -2
- package/api/integration/pack-check.mjs +495 -4
- package/api/integration/pack-check.test.mjs +619 -10
- package/api/integration/validate-integration.d.mts +4 -2
- package/api/integration/validate-integration.mjs +7 -2
- package/api/integration/validate-integration.test.mjs +55 -0
- package/api/integration/validate-integration.type.d.mts +5 -0
- package/api/integration/validate-integration.type.mjs +5 -1
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/layout/check/check.d.mts +1 -0
- package/api/layout/check/check.mjs +1 -0
- package/api/layout/expand/expand.d.mts +1 -0
- package/api/layout/expand/expand.mjs +13 -7
- package/api/layout/expand/expand.receipt.test.mjs +74 -0
- package/api/layout/grammar/grammar.d.mts +1 -0
- package/api/layout/grammar/grammar.mjs +1 -0
- package/api/layout/layout.type.d.mts +1 -0
- package/api/layout/layout.type.mjs +1 -0
- package/api/layout/layoutCheck.doc.mjs +1 -1
- package/api/layout/layoutExpand.doc.mjs +2 -2
- package/api/layout/layoutGrammar.doc.mjs +1 -1
- package/api/search/search.d.mts +39 -8
- package/api/search/search.doc.mjs +4 -4
- package/api/search/search.mjs +248 -66
- package/api/search/search.test.mjs +829 -0
- package/api/search/search.type.d.mts +6 -6
- package/api/search/search.type.mjs +5 -5
- package/api/swizzle/_adapter.d.mts +10 -0
- package/api/swizzle/_adapter.mjs +23 -0
- package/api/swizzle/copy/copy.d.mts +5 -6
- package/api/swizzle/copy/copy.mjs +95 -13
- package/api/swizzle/list/list.mjs +2 -2
- package/api/swizzle/swizzle.doc.mjs +4 -0
- package/api/swizzle/swizzle.test.mjs +55 -5
- package/api/swizzle/swizzle.type.d.mts +8 -0
- package/api/swizzle/swizzle.type.mjs +2 -0
- package/api/template/copy/copy.mjs +27 -8
- package/api/template/copy/copy.receipt.test.mjs +77 -0
- package/api/template/show/show.mjs +17 -4
- package/api/template/show/show.test.mjs +76 -0
- package/api/template/skeleton/skeleton.mjs +2 -1
- package/api/template/template-integration.test.mjs +14 -0
- package/api/template/template.d.mts +1 -1
- package/api/template/template.doc.mjs +6 -2
- package/api/template/template.mjs +2 -0
- package/api/template/template.type.d.mts +17 -0
- package/api/template/template.type.mjs +8 -0
- package/api/theme/_adapter.d.mts +106 -6
- package/api/theme/_adapter.mjs +687 -18
- package/api/theme/add/add.binary.test.mjs +76 -3
- package/api/theme/add/add.d.mts +5 -9
- package/api/theme/add/add.mjs +87 -64
- package/api/theme/add/add.rollback.test.mjs +9 -9
- package/api/theme/add/add.staging.test.mjs +9 -9
- package/api/theme/add/add.test.mjs +461 -55
- package/api/theme/add/add.types.test.mjs +151 -0
- package/api/theme/build/build.d.mts +120 -2
- package/api/theme/build/build.family.test.mjs +13 -4
- package/api/theme/build/build.icon-lineage.test.mjs +117 -0
- package/api/theme/build/build.icon-preservation.test.mjs +639 -0
- package/api/theme/build/build.mjs +667 -195
- package/api/theme/build/build.project-core.test.mjs +165 -0
- package/api/theme/build/build.test.mjs +220 -1
- package/api/theme/build/font-warning.d.mts +11 -0
- package/api/theme/build/font-warning.mjs +28 -3
- package/api/theme/build/icon-imports.d.mts +47 -0
- package/api/theme/build/icon-imports.mjs +691 -0
- package/api/theme/eject/eject.binary.test.mjs +90 -0
- package/api/theme/eject/eject.d.mts +17 -0
- package/api/theme/eject/eject.mjs +65 -0
- package/api/theme/eject/eject.rollback.test.mjs +158 -0
- package/api/theme/eject/eject.staging.test.mjs +83 -0
- package/api/theme/eject/eject.test.mjs +160 -0
- package/api/theme/integration-themes.test.mjs +30 -6
- package/api/theme/list/list.d.mts +10 -0
- package/api/theme/list/list.mjs +75 -7
- package/api/theme/list/list.test.mjs +155 -4
- package/api/theme/remove/remove.d.mts +12 -0
- package/api/theme/remove/remove.mjs +15 -0
- package/api/theme/remove/remove.test.mjs +94 -0
- package/api/theme/template/template.mjs +3 -4
- package/api/theme/theme.d.mts +5 -2
- package/api/theme/theme.mjs +13 -8
- package/api/theme/theme.type.d.mts +106 -2
- package/api/theme/theme.type.mjs +54 -5
- package/api/theme/themeAdd.doc.d.mts +1 -3
- package/api/theme/themeAdd.doc.mjs +35 -22
- package/api/theme/themeBuild.doc.d.mts +4 -1
- package/api/theme/themeBuild.doc.mjs +15 -4
- package/api/theme/themeEject.doc.d.mts +8 -0
- package/api/theme/themeEject.doc.mjs +89 -0
- package/api/theme/themeListAvailable.doc.mjs +4 -4
- package/api/theme/themeListCopySources.doc.d.mts +8 -0
- package/api/theme/themeListCopySources.doc.mjs +60 -0
- package/api/theme/themeRemove.doc.d.mts +6 -0
- package/api/theme/themeRemove.doc.mjs +50 -0
- package/api/theme/themeTemplate.doc.mjs +4 -3
- package/api/theme/themeUse.doc.d.mts +6 -0
- package/api/theme/themeUse.doc.mjs +47 -0
- package/api/theme/use/use.d.mts +12 -0
- package/api/theme/use/use.mjs +15 -0
- package/api/theme/use/use.test.mjs +98 -0
- package/api/upgrade/_adapter.d.mts +1 -0
- package/api/upgrade/_adapter.mjs +3 -0
- package/api/upgrade/list/list.mjs +9 -3
- package/api/upgrade/run/run.mjs +20 -3
- package/api/upgrade/run/run.test.mjs +45 -1
- package/api/upgrade/upgrade.doc.mjs +1 -1
- package/api/upgrade/upgrade.type.d.mts +5 -0
- package/api/upgrade/upgrade.type.mjs +2 -0
- package/assets/codemods/integration-discovery.mjs +1 -1
- package/assets/codemods/integration-discovery.test.mjs +64 -0
- package/assets/codemods/transforms/next/__tests__/migrate-copied-themes-to-descriptors.test.mjs +129 -0
- package/assets/codemods/transforms/next/index.mjs +14 -1
- package/assets/codemods/transforms/next/migrate-copied-themes-to-descriptors.mjs +54 -0
- package/assets/docs/author-a-theme.doc.mjs +166 -0
- package/assets/docs/getting-started.doc.mjs +59 -15
- package/assets/docs/icons.doc.mjs +1 -0
- package/assets/docs/principles.doc.dense.mjs +2 -2
- package/assets/docs/principles.doc.mjs +2 -2
- package/assets/docs/principles.doc.zh.mjs +2 -2
- package/assets/docs/styling-libraries.doc.mjs +1 -1
- package/assets/docs/styling-overview.doc.mjs +211 -0
- package/assets/docs/styling.doc.mjs +2 -2
- package/assets/docs/theme.doc.dense.mjs +10 -198
- package/assets/docs/theme.doc.mjs +13 -770
- package/assets/docs/theme.doc.zh.mjs +31 -12
- package/assets/docs/tokens.doc.mjs +4 -4
- package/assets/docs/tree/add-a-theme.doc.mjs +6 -2
- package/assets/docs/tree/add-a-topic.doc.mjs +1 -1
- package/assets/docs/tree/check-your-docs.doc.mjs +2 -2
- package/assets/docs/tree/checks.doc.mjs +6 -5
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +1 -1
- package/assets/docs/tree/define-the-theme.doc.mjs +2 -2
- package/assets/docs/tree/document-the-theme.doc.mjs +4 -4
- package/assets/docs/tree/fonts-and-assets.doc.mjs +25 -20
- package/assets/docs/tree/headers-and-footers.doc.mjs +68 -0
- package/assets/docs/tree/layout-spacing.doc.mjs +168 -0
- package/assets/docs/tree/layout.doc.mjs +52 -0
- package/assets/docs/tree/replace-a-core-component.doc.mjs +21 -4
- package/assets/docs/tree/responsive.doc.mjs +102 -0
- package/assets/docs/tree/scaffold.doc.mjs +145 -0
- package/assets/docs/tree/sections-and-placement.doc.mjs +1 -1
- package/assets/docs/tree/side-panels.doc.mjs +82 -0
- package/assets/docs/tree/structure.doc.mjs +144 -0
- package/assets/docs/tree/template-doc-overview.doc.mjs +13 -1
- package/assets/docs/tree/themes.doc.mjs +2 -2
- package/assets/docs/tree/troubleshooting.doc.mjs +13 -5
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +22 -5
- package/assets/docs/tree/versioning.doc.mjs +11 -7
- package/assets/docs/use-a-theme.doc.mjs +212 -0
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.doc.mjs +15 -0
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.tsx +38 -0
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.doc.mjs +20 -0
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.tsx +48 -0
- package/assets/templates/pages/ai-chat/template.doc.mjs +16 -1
- package/assets/templates/pages/ai-chat-landing/template.doc.mjs +9 -1
- package/assets/templates/pages/blank/template.doc.mjs +3 -1
- package/assets/templates/pages/canvas-editor/template.doc.mjs +9 -1
- package/assets/templates/pages/centered-hero/template.doc.mjs +3 -1
- package/assets/templates/pages/checkout-wizard/template.doc.mjs +1 -0
- package/assets/templates/pages/classic-gallery/template.doc.mjs +3 -1
- package/assets/templates/pages/contact-form/template.doc.mjs +16 -1
- package/assets/templates/pages/dashboard/template.doc.mjs +15 -1
- package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +23 -1
- package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +10 -1
- package/assets/templates/pages/dashboard-comparison/template.doc.mjs +9 -1
- package/assets/templates/pages/dashboard-composition/template.doc.mjs +10 -1
- package/assets/templates/pages/dashboard-progress/template.doc.mjs +17 -1
- package/assets/templates/pages/dashboard-scorecard/template.doc.mjs +2 -1
- package/assets/templates/pages/detail-page/template.doc.mjs +8 -0
- package/assets/templates/pages/documentation/template.doc.mjs +10 -1
- package/assets/templates/pages/documentation-design/template.doc.mjs +10 -1
- package/assets/templates/pages/documentation-technical/template.doc.mjs +10 -1
- package/assets/templates/pages/editor/template.doc.mjs +9 -1
- package/assets/templates/pages/file-explorer/template.doc.mjs +3 -1
- package/assets/templates/pages/form-two-column/template.doc.mjs +17 -1
- package/assets/templates/pages/form-wizard/template.doc.mjs +14 -1
- package/assets/templates/pages/form-wizard-dialog/template.doc.mjs +1 -0
- package/assets/templates/pages/gallery-hero/template.doc.mjs +10 -1
- package/assets/templates/pages/ide/template.doc.mjs +9 -1
- package/assets/templates/pages/incident-console/page.tsx +1 -1
- package/assets/templates/pages/incident-console/template.doc.mjs +10 -1
- package/assets/templates/pages/kanban-board/template.doc.mjs +11 -1
- package/assets/templates/pages/library/template.doc.mjs +15 -1
- package/assets/templates/pages/login/template.doc.mjs +10 -1
- package/assets/templates/pages/login-card/template.doc.mjs +11 -1
- package/assets/templates/pages/login-split/template.doc.mjs +10 -1
- package/assets/templates/pages/login-sso/template.doc.mjs +10 -1
- package/assets/templates/pages/messaging-shell/template.doc.mjs +11 -1
- package/assets/templates/pages/mixed-gallery/template.doc.mjs +10 -1
- package/assets/templates/pages/payment-form/template.doc.mjs +3 -1
- package/assets/templates/pages/product-detail/template.doc.mjs +9 -1
- package/assets/templates/pages/product-gallery/template.doc.mjs +10 -1
- package/assets/templates/pages/settings/template.doc.mjs +3 -1
- package/assets/templates/pages/settings-dialog/template.doc.mjs +9 -1
- package/assets/templates/pages/settings-sidebar/template.doc.mjs +9 -1
- package/assets/templates/pages/shell-nav/template.doc.mjs +10 -1
- package/assets/templates/pages/shell-side-nav/template.doc.mjs +14 -1
- package/assets/templates/pages/shell-top-nav/template.doc.mjs +11 -1
- package/assets/templates/pages/side-gallery/template.doc.mjs +3 -1
- package/assets/templates/pages/table/template.doc.mjs +11 -1
- package/assets/templates/pages/table-collapsible/page.tsx +1474 -0
- package/assets/templates/pages/table-collapsible/template.doc.mjs +12 -0
- package/assets/templates/pages/table-comparison/page.tsx +1449 -0
- package/assets/templates/pages/table-comparison/template.doc.mjs +12 -0
- package/assets/templates/pages/table-filter/template.doc.mjs +21 -1
- package/assets/templates/pages/table-grouped/template.doc.mjs +15 -1
- package/assets/templates/pages/table-inbox/template.doc.mjs +18 -6
- package/assets/templates/pages/table-page/template.doc.mjs +20 -1
- package/assets/templates/pages/table-tree/template.doc.mjs +14 -1
- package/assets/templates/pages/theme-showcase/template.doc.mjs +10 -1
- package/assets/templates/pages/work-item-detail/template.doc.mjs +10 -0
- package/assets/templates/themes/butter/icons.tsx +2 -0
- package/assets/templates/themes/chocolate/icons.tsx +2 -0
- package/assets/templates/themes/gothic/icons.tsx +2 -0
- package/assets/templates/themes/matcha/icons.tsx +2 -0
- package/assets/templates/themes/neutral/icons.tsx +2 -0
- package/assets/templates/themes/stone/icons.tsx +2 -0
- package/assets/templates/themes/y2k/icons.tsx +2 -0
- package/authoring/doctypes/command/command.doc.mjs +5 -0
- package/authoring/doctypes/command/type.ts +2 -0
- package/authoring/doctypes/component/component.doc.mjs +1 -1
- package/authoring/doctypes/component/type.ts +8 -4
- package/authoring/doctypes/template/parse.d.mts +2 -0
- package/authoring/doctypes/template/parse.mjs +1 -0
- package/authoring/doctypes/template/parse.test.mjs +21 -0
- package/authoring/doctypes/template/template.doc.mjs +6 -0
- package/authoring/doctypes/template/type.ts +11 -0
- package/authoring/integration/integration.doc.mjs +1 -1
- package/clients/cli/commands/blog.mjs +3 -3
- package/clients/cli/commands/build-theme.adaptations.test.mjs +1 -1
- package/clients/cli/commands/build-theme.ascii-output.test.mjs +11 -1
- package/clients/cli/commands/build-theme.batch-report.test.mjs +335 -0
- package/clients/cli/commands/build-theme.font-warning.test.mjs +36 -7
- package/clients/cli/commands/build-theme.import-path.test.mjs +3 -3
- package/clients/cli/commands/build-theme.mjs +346 -47
- package/clients/cli/commands/build-theme.watch.test.mjs +33 -0
- package/clients/cli/commands/build.mjs +8 -6
- package/clients/cli/commands/build.text-fields.test.mjs +1 -1
- package/clients/cli/commands/component/index.mjs +88 -12
- package/clients/cli/commands/component-replacement.text.test.mjs +271 -0
- package/clients/cli/commands/component.doc.mjs +9 -2
- package/clients/cli/commands/discover.mjs +29 -1
- package/clients/cli/commands/discover.no-source.test.mjs +75 -0
- package/clients/cli/commands/docs.depth.test.mjs +219 -0
- package/clients/cli/commands/docs.doc.mjs +15 -2
- package/clients/cli/commands/docs.mjs +273 -16
- package/clients/cli/commands/docs.test.mjs +383 -0
- package/clients/cli/commands/doctor-integration-components.doc.mjs +15 -4
- package/clients/cli/commands/doctor.doc.mjs +1 -1
- package/clients/cli/commands/doctor.mjs +4 -4
- package/clients/cli/commands/doctor.test.mjs +26 -52
- package/clients/cli/commands/gap-report.doc.mjs +2 -2
- package/clients/cli/commands/gap-report.mjs +12 -0
- package/clients/cli/commands/gap-report.test.mjs +63 -0
- package/clients/cli/commands/hook/index.mjs +7 -2
- package/clients/cli/commands/import-hint-correctness.test.mjs +28 -5
- package/clients/cli/commands/init.next-steps.test.mjs +18 -23
- package/clients/cli/commands/integration-add.doc.mjs +10 -0
- package/clients/cli/commands/integration-authoring.test.mjs +12 -2
- package/clients/cli/commands/integration-real-world.test.mjs +61 -12
- package/clients/cli/commands/integration.mjs +3 -1
- package/clients/cli/commands/layout-check.doc.mjs +2 -0
- package/clients/cli/commands/layout-expand.doc.mjs +5 -1
- package/clients/cli/commands/layout-grammar.doc.mjs +2 -0
- package/clients/cli/commands/layout.deprecation-lifecycle.test.mjs +140 -0
- package/clients/cli/commands/layout.doc.mjs +2 -0
- package/clients/cli/commands/layout.expand-receipt.test.mjs +94 -0
- package/clients/cli/commands/layout.mjs +56 -4
- package/clients/cli/commands/no-prompt-wording.test.mjs +4 -4
- package/clients/cli/commands/search.doc.mjs +5 -4
- package/clients/cli/commands/search.mjs +30 -6
- package/clients/cli/commands/search.test.mjs +69 -19
- package/clients/cli/commands/swizzle.doc.mjs +12 -3
- package/clients/cli/commands/swizzle.mjs +2 -1
- package/clients/cli/commands/swizzle.routing.test.mjs +2 -1
- package/clients/cli/commands/template.copy-receipt.test.mjs +60 -0
- package/clients/cli/commands/template.mjs +71 -6
- package/clients/cli/commands/template.show-media.test.mjs +62 -0
- package/clients/cli/commands/text-json-parity.test.mjs +40 -0
- package/clients/cli/commands/theme-add-lifecycle.test.mjs +135 -0
- package/clients/cli/commands/theme-add.doc.mjs +19 -19
- package/clients/cli/commands/theme-build.doc.mjs +3 -1
- package/clients/cli/commands/theme-eject.doc.mjs +47 -0
- package/clients/cli/commands/theme-list.behavior.test.mjs +44 -0
- package/clients/cli/commands/theme-list.doc.mjs +2 -2
- package/clients/cli/commands/theme-palette-generate.doc.mjs +1 -2
- package/clients/cli/commands/theme-remove.doc.mjs +22 -0
- package/clients/cli/commands/theme-template.doc.mjs +4 -3
- package/clients/cli/commands/theme-use.doc.mjs +22 -0
- package/clients/cli/commands/theme.doc.mjs +21 -16
- package/clients/cli/commands/upgrade.ascii-output.test.mjs +14 -0
- package/clients/cli/commands/upgrade.config-ordering.test.mjs +2 -1
- package/clients/cli/commands/upgrade.mjs +1 -1
- package/clients/cli/commands/write-failure.test.mjs +175 -0
- package/clients/cli/index.mjs +5 -2
- package/clients/cli/lib/component-format.mjs +19 -2
- package/clients/cli/lib/component-format.test.mjs +1 -1
- package/clients/cli/lib/define-command.mjs +4 -0
- package/clients/cli/lib/manifest.mjs +44 -165
- package/clients/cli/lib/manifest.test.mjs +98 -7
- package/clients/cli/lib/resolve-theme.mjs +80 -78
- package/clients/cli/lib/resolve-theme.test.mjs +523 -27
- package/foundation/agent-docs/agent-docs.mjs +34 -28
- package/foundation/agent-docs/agent-docs.test.mjs +1181 -0
- package/foundation/agent-docs/app-theme-workflow.test.mjs +13 -0
- package/foundation/config/project.d.mts +20 -5
- package/foundation/config/project.mjs +43 -6
- package/foundation/config/theme-private-vars.d.mts +12 -0
- package/foundation/config/theme-private-vars.mjs +107 -0
- package/foundation/config/theme-private-vars.test.mjs +55 -0
- package/foundation/config/theme-state.d.mts +145 -0
- package/foundation/config/theme-state.mjs +417 -0
- package/foundation/config/theme-state.test.mjs +182 -0
- package/foundation/discovery/component-discovery.d.mts +5 -2
- package/foundation/discovery/component-discovery.mjs +12 -6
- package/foundation/discovery/component-replacement.d.mts +91 -0
- package/foundation/discovery/component-replacement.mjs +417 -0
- package/foundation/discovery/component-replacement.test.mjs +480 -0
- package/foundation/discovery/docs-output-budget.d.mts +6 -2
- package/foundation/discovery/docs-output-budget.mjs +2 -1
- package/foundation/discovery/docs-section-key.d.mts +4 -2
- package/foundation/discovery/docs-section-key.mjs +1 -1
- package/foundation/discovery/module-exports.d.mts +10 -0
- package/foundation/discovery/module-exports.mjs +146 -0
- package/foundation/discovery/package-exports.d.mts +29 -0
- package/foundation/discovery/package-exports.mjs +200 -0
- package/foundation/discovery/template-adapter.d.mts +14 -0
- package/foundation/discovery/template-adapter.fixture-refs.test.mjs +37 -1
- package/foundation/discovery/template-adapter.mjs +21 -1
- package/foundation/discovery/template-needs.d.mts +31 -0
- package/foundation/discovery/template-needs.mjs +156 -0
- package/foundation/discovery/template-needs.test.mjs +203 -0
- package/foundation/discovery/theme-discovery.d.mts +78 -5
- package/foundation/discovery/theme-discovery.mjs +143 -18
- package/foundation/discovery/theme-discovery.test.mjs +9 -3
- package/foundation/discovery/theme-imports.d.mts +15 -0
- package/foundation/discovery/theme-imports.mjs +217 -0
- package/foundation/discovery/theme-imports.test.mjs +173 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +18 -8
- package/foundation/doc-compiler/inputs.mjs +2 -1
- package/foundation/doc-compiler/inputs.test.mjs +0 -1
- package/foundation/doc-compiler/lenses.d.mts +4 -2
- package/foundation/doc-compiler/lenses.mjs +1 -1
- package/foundation/doc-compiler/tree.test.mjs +649 -0
- package/foundation/env/package-manager.d.mts +28 -8
- package/foundation/env/package-manager.mjs +49 -10
- package/foundation/env/package-manager.test.mjs +93 -1
- package/foundation/fs/module-loader.d.mts +9 -0
- package/foundation/fs/module-loader.mjs +71 -2
- package/foundation/integrations/cli-requirement.d.mts +79 -13
- package/foundation/integrations/cli-requirement.mjs +115 -22
- package/foundation/integrations/cli-requirement.test.mjs +205 -8
- package/foundation/integrations/contribution-inventory.mjs +3 -3
- package/foundation/response/base.d.ts +9 -3
- package/foundation/response/json.d.mts +7 -4
- package/foundation/response/json.mjs +10 -6
- package/foundation/response/response-types.doc.d.mts +5 -5
- package/foundation/response/response-types.doc.mjs +52 -37
- package/foundation/response/response.doc.mjs +18 -4
- package/foundation/text/copyright-header.mjs +1 -1
- package/foundation/text/copyright-header.test.mjs +1 -1
- package/package.json +9 -9
- package/assets/docs/layout.doc.dense.mjs +0 -388
- package/assets/docs/layout.doc.mjs +0 -550
|
@@ -24,16 +24,24 @@ export function findPackageDir(startDir: string): string;
|
|
|
24
24
|
* @property {string} target package-relative target, e.g. `./components/Card.tsx`
|
|
25
25
|
*/
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
27
|
+
* @typedef {object} PackageJsonUpdateOptions
|
|
28
|
+
* @property {boolean} [createExports] create a subpath map when the package has
|
|
29
|
+
* no exports field
|
|
30
|
+
* @property {string[]} [sideEffects] side-effect glob patterns to preserve when
|
|
31
|
+
* package.json currently declares `sideEffects: false` or a pattern array
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* Compute one package.json update for an existing `files` allowlist and an
|
|
35
|
+
* optional exports map. An exports map is created only when `createExports` is
|
|
36
|
+
* explicit because doing so makes every unlisted deep import private.
|
|
30
37
|
*
|
|
31
38
|
* @param {string} packageFile
|
|
32
39
|
* @param {string[]} entries project-relative files or directories
|
|
33
40
|
* @param {PackageExportEntry[]} [publicExports]
|
|
41
|
+
* @param {PackageJsonUpdateOptions} [options]
|
|
34
42
|
* @returns {PackageJsonUpdate|null}
|
|
35
43
|
*/
|
|
36
|
-
export function packageJsonFilesUpdate(packageFile: string, entries: string[], publicExports?: PackageExportEntry[]): PackageJsonUpdate | null;
|
|
44
|
+
export function packageJsonFilesUpdate(packageFile: string, entries: string[], publicExports?: PackageExportEntry[], { createExports, sideEffects }?: PackageJsonUpdateOptions): PackageJsonUpdate | null;
|
|
37
45
|
/**
|
|
38
46
|
* Include one contribution root, the manifest, and any public source entries in
|
|
39
47
|
* existing package allowlists.
|
|
@@ -41,9 +49,10 @@ export function packageJsonFilesUpdate(packageFile: string, entries: string[], p
|
|
|
41
49
|
* @param {string} rootPath
|
|
42
50
|
* @param {string} manifestName
|
|
43
51
|
* @param {PackageExportEntry[]} [publicExports]
|
|
52
|
+
* @param {PackageJsonUpdateOptions} [options]
|
|
44
53
|
* @returns {PackageJsonUpdate|null}
|
|
45
54
|
*/
|
|
46
|
-
export function packageJsonUpdate(packageFile: string, rootPath: string, manifestName: string, publicExports?: PackageExportEntry[]): PackageJsonUpdate | null;
|
|
55
|
+
export function packageJsonUpdate(packageFile: string, rootPath: string, manifestName: string, publicExports?: PackageExportEntry[], options?: PackageJsonUpdateOptions): PackageJsonUpdate | null;
|
|
47
56
|
/**
|
|
48
57
|
* Apply several writes as one operation. New files publish with an atomic
|
|
49
58
|
* hard link so a racing creator is never overwritten; replacements are
|
|
@@ -81,3 +90,15 @@ export type PackageExportEntry = {
|
|
|
81
90
|
*/
|
|
82
91
|
target: string;
|
|
83
92
|
};
|
|
93
|
+
export type PackageJsonUpdateOptions = {
|
|
94
|
+
/**
|
|
95
|
+
* create a subpath map when the package has
|
|
96
|
+
* no exports field
|
|
97
|
+
*/
|
|
98
|
+
createExports?: boolean | undefined;
|
|
99
|
+
/**
|
|
100
|
+
* side-effect glob patterns to preserve when
|
|
101
|
+
* package.json currently declares `sideEffects: false` or a pattern array
|
|
102
|
+
*/
|
|
103
|
+
sideEffects?: string[] | undefined;
|
|
104
|
+
};
|
|
@@ -60,19 +60,29 @@ export function findPackageDir(startDir) {
|
|
|
60
60
|
*/
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
63
|
+
* @typedef {object} PackageJsonUpdateOptions
|
|
64
|
+
* @property {boolean} [createExports] create a subpath map when the package has
|
|
65
|
+
* no exports field
|
|
66
|
+
* @property {string[]} [sideEffects] side-effect glob patterns to preserve when
|
|
67
|
+
* package.json currently declares `sideEffects: false` or a pattern array
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Compute one package.json update for an existing `files` allowlist and an
|
|
72
|
+
* optional exports map. An exports map is created only when `createExports` is
|
|
73
|
+
* explicit because doing so makes every unlisted deep import private.
|
|
66
74
|
*
|
|
67
75
|
* @param {string} packageFile
|
|
68
76
|
* @param {string[]} entries project-relative files or directories
|
|
69
77
|
* @param {PackageExportEntry[]} [publicExports]
|
|
78
|
+
* @param {PackageJsonUpdateOptions} [options]
|
|
70
79
|
* @returns {PackageJsonUpdate|null}
|
|
71
80
|
*/
|
|
72
81
|
export function packageJsonFilesUpdate(
|
|
73
82
|
packageFile,
|
|
74
83
|
entries,
|
|
75
84
|
publicExports = [],
|
|
85
|
+
{createExports = false, sideEffects = []} = {},
|
|
76
86
|
) {
|
|
77
87
|
const expectedOriginal = fs.readFileSync(packageFile);
|
|
78
88
|
const original = expectedOriginal.toString('utf-8');
|
|
@@ -117,11 +127,13 @@ export function packageJsonFilesUpdate(
|
|
|
117
127
|
}
|
|
118
128
|
}
|
|
119
129
|
|
|
120
|
-
if (pkg.exports !== undefined && publicExports.length > 0) {
|
|
130
|
+
if ((pkg.exports !== undefined || createExports) && publicExports.length > 0) {
|
|
121
131
|
const authored = pkg.exports;
|
|
122
132
|
/** @type {Record<string, unknown>} */
|
|
123
133
|
let exportsMap;
|
|
124
|
-
if (
|
|
134
|
+
if (authored === undefined) {
|
|
135
|
+
exportsMap = {};
|
|
136
|
+
} else if (
|
|
125
137
|
authored == null ||
|
|
126
138
|
typeof authored !== 'object' ||
|
|
127
139
|
Array.isArray(authored)
|
|
@@ -160,6 +172,36 @@ export function packageJsonFilesUpdate(
|
|
|
160
172
|
if (changed || exportsMap !== authored) pkg.exports = exportsMap;
|
|
161
173
|
}
|
|
162
174
|
|
|
175
|
+
if (sideEffects.length > 0 && pkg.sideEffects !== undefined) {
|
|
176
|
+
if (pkg.sideEffects === false) {
|
|
177
|
+
pkg.sideEffects = [...sideEffects];
|
|
178
|
+
changed = true;
|
|
179
|
+
} else if (Array.isArray(pkg.sideEffects)) {
|
|
180
|
+
if (
|
|
181
|
+
pkg.sideEffects.some(
|
|
182
|
+
(/** @type {unknown} */ item) => typeof item !== 'string',
|
|
183
|
+
)
|
|
184
|
+
) {
|
|
185
|
+
throw new AstryxError(
|
|
186
|
+
'package.json sideEffects must be a boolean or an array of strings before Astryx can add theme CSS.',
|
|
187
|
+
undefined,
|
|
188
|
+
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
for (const pattern of sideEffects) {
|
|
192
|
+
if (pkg.sideEffects.includes(pattern)) continue;
|
|
193
|
+
pkg.sideEffects.push(pattern);
|
|
194
|
+
changed = true;
|
|
195
|
+
}
|
|
196
|
+
} else if (pkg.sideEffects !== true) {
|
|
197
|
+
throw new AstryxError(
|
|
198
|
+
'package.json sideEffects must be a boolean or an array of strings before Astryx can add theme CSS.',
|
|
199
|
+
undefined,
|
|
200
|
+
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
163
205
|
if (!changed) return null;
|
|
164
206
|
const indent = original.match(/\n([ \t]+)"/u)?.[1] ?? ' ';
|
|
165
207
|
return {
|
|
@@ -176,6 +218,7 @@ export function packageJsonFilesUpdate(
|
|
|
176
218
|
* @param {string} rootPath
|
|
177
219
|
* @param {string} manifestName
|
|
178
220
|
* @param {PackageExportEntry[]} [publicExports]
|
|
221
|
+
* @param {PackageJsonUpdateOptions} [options]
|
|
179
222
|
* @returns {PackageJsonUpdate|null}
|
|
180
223
|
*/
|
|
181
224
|
export function packageJsonUpdate(
|
|
@@ -183,11 +226,13 @@ export function packageJsonUpdate(
|
|
|
183
226
|
rootPath,
|
|
184
227
|
manifestName,
|
|
185
228
|
publicExports = [],
|
|
229
|
+
options = {},
|
|
186
230
|
) {
|
|
187
231
|
return packageJsonFilesUpdate(
|
|
188
232
|
packageFile,
|
|
189
233
|
[rootPath, manifestName],
|
|
190
234
|
publicExports,
|
|
235
|
+
options,
|
|
191
236
|
);
|
|
192
237
|
}
|
|
193
238
|
|
|
@@ -2,20 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @file `astryx integration add theme` — scaffold one strongly typed,
|
|
5
|
-
* same-stem source/descriptor pair into an integration package
|
|
6
|
-
* themes root on first use.
|
|
5
|
+
* same-stem source/descriptor pair into an integration package, declare the
|
|
6
|
+
* themes root on first use, and add the built module and stylesheet exports.
|
|
7
|
+
*
|
|
8
|
+
* `--from <base>` forks an existing theme's source files as the starting point
|
|
9
|
+
* instead of writing a blank `defineTheme` skeleton.
|
|
7
10
|
*/
|
|
8
11
|
|
|
9
12
|
import * as fs from 'node:fs';
|
|
13
|
+
import {isBuiltin} from 'node:module';
|
|
10
14
|
import * as path from 'node:path';
|
|
11
15
|
import {AstryxError} from '../error.mjs';
|
|
16
|
+
import {CLI_ROOT} from '../../foundation/fs/paths.mjs';
|
|
12
17
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
13
18
|
import {
|
|
14
19
|
assertWithin,
|
|
15
20
|
PathSafetyError,
|
|
16
21
|
sanitizeName,
|
|
17
22
|
} from '../../foundation/fs/path-safety.mjs';
|
|
18
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
discoverBundledThemes,
|
|
25
|
+
discoverThemeDirectory,
|
|
26
|
+
themeFileImports,
|
|
27
|
+
} from '../../foundation/discovery/theme-discovery.mjs';
|
|
19
28
|
import {
|
|
20
29
|
findLocalIntegrationManifestOrNull,
|
|
21
30
|
IntegrationRootConflictError,
|
|
@@ -25,9 +34,11 @@ import {loadManifestObject} from '../../foundation/integrations/integrations.mjs
|
|
|
25
34
|
import {themeDescriptorSource} from '../../foundation/integrations/theme-descriptor.mjs';
|
|
26
35
|
import {assertContributionVisible} from '../../foundation/integrations/contribution-inventory.mjs';
|
|
27
36
|
import {
|
|
37
|
+
THEMES_CLI,
|
|
28
38
|
themesCliProblem,
|
|
29
|
-
|
|
39
|
+
withCliPeer,
|
|
30
40
|
} from '../../foundation/integrations/cli-requirement.mjs';
|
|
41
|
+
import {stripCopyrightHeader} from '../../foundation/text/copyright-header.mjs';
|
|
31
42
|
import {
|
|
32
43
|
applyWrites,
|
|
33
44
|
findPackageDir,
|
|
@@ -69,6 +80,7 @@ function themeIdentity(slug) {
|
|
|
69
80
|
.join(' ');
|
|
70
81
|
return {
|
|
71
82
|
slug,
|
|
83
|
+
identifier,
|
|
72
84
|
displayName,
|
|
73
85
|
exportName: `${identifier}Theme`,
|
|
74
86
|
entry: `${identifier}Theme.ts`,
|
|
@@ -92,6 +104,253 @@ function themeDescriptor(identity) {
|
|
|
92
104
|
});
|
|
93
105
|
}
|
|
94
106
|
|
|
107
|
+
// ── --from: resolve and fork a base theme ───────────────────────────
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Resolve a theme slug to its discovered record, searching the bundled themes
|
|
111
|
+
* and the package's own themes root (when it has one).
|
|
112
|
+
* @param {string} slug
|
|
113
|
+
* @param {string} packageDir
|
|
114
|
+
* @param {string} owner
|
|
115
|
+
* @param {string | undefined} themesRoot resolved absolute themes root, if any
|
|
116
|
+
* @returns {import('../../foundation/discovery/theme-discovery.mjs').DiscoveredTheme}
|
|
117
|
+
*/
|
|
118
|
+
function resolveBaseTheme(slug, packageDir, owner, themesRoot) {
|
|
119
|
+
const normalized = slug.toLowerCase();
|
|
120
|
+
|
|
121
|
+
/** @type {import('../../foundation/discovery/theme-discovery.mjs').DiscoveredTheme[]} */
|
|
122
|
+
let candidates = [];
|
|
123
|
+
try {
|
|
124
|
+
candidates = discoverBundledThemes();
|
|
125
|
+
} catch {
|
|
126
|
+
// Bundled themes unavailable — not fatal, package themes may suffice.
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Also check the package's own themes root.
|
|
130
|
+
if (themesRoot && fs.existsSync(themesRoot)) {
|
|
131
|
+
try {
|
|
132
|
+
candidates = [...candidates, ...discoverThemeDirectory(themesRoot, owner)];
|
|
133
|
+
} catch {
|
|
134
|
+
// A broken local root is not the caller's problem here.
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const match = candidates.find(t => t.slug.toLowerCase() === normalized);
|
|
139
|
+
if (!match) {
|
|
140
|
+
throw new AstryxError(
|
|
141
|
+
`Unknown base theme "${slug}". Available themes: ${candidates.map(t => t.slug).join(', ') || '(none)'}.`,
|
|
142
|
+
candidates.map(t => ({
|
|
143
|
+
name: t.slug,
|
|
144
|
+
reason: t.bundled ? 'bundled theme' : `provided by ${t.package}`,
|
|
145
|
+
})),
|
|
146
|
+
ERROR_CODES.ERR_UNKNOWN_THEME,
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
return match;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Rename a file from the base theme's namespace to the new theme's namespace.
|
|
154
|
+
* Files whose name starts with the base identifier get the new identifier;
|
|
155
|
+
* others keep their name as-is.
|
|
156
|
+
* @param {string} file POSIX relative path inside the theme directory
|
|
157
|
+
* @param {string} baseIdentifier
|
|
158
|
+
* @param {string} newIdentifier
|
|
159
|
+
* @returns {string}
|
|
160
|
+
*/
|
|
161
|
+
function renameThemeFile(file, baseIdentifier, newIdentifier) {
|
|
162
|
+
const basename = path.posix.basename(file);
|
|
163
|
+
const dir = path.posix.dirname(file);
|
|
164
|
+
if (!basename.startsWith(baseIdentifier)) return file;
|
|
165
|
+
const renamed = newIdentifier + basename.slice(baseIdentifier.length);
|
|
166
|
+
return dir === '.' ? renamed : `${dir}/${renamed}`;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Rewrite a source file's contents from the base theme's names to the new
|
|
171
|
+
* theme's names. This replaces:
|
|
172
|
+
* 1. Identifier prefixes (camelCase variables, import paths): baseIdentifier
|
|
173
|
+
* followed by an uppercase letter.
|
|
174
|
+
* 2. The theme slug in string literals: 'baseSlug' → 'newSlug' and
|
|
175
|
+
* 'astryx-baseSlug' → 'astryx-newSlug'.
|
|
176
|
+
* 3. CSS custom properties scoped to the theme: --astryx-theme-baseSlug-.
|
|
177
|
+
* @param {string} source
|
|
178
|
+
* @param {string} baseSlug
|
|
179
|
+
* @param {string} baseIdentifier
|
|
180
|
+
* @param {string} newSlug
|
|
181
|
+
* @param {string} newIdentifier
|
|
182
|
+
* @returns {string}
|
|
183
|
+
*/
|
|
184
|
+
function rewriteThemeSource(
|
|
185
|
+
source,
|
|
186
|
+
baseSlug,
|
|
187
|
+
baseIdentifier,
|
|
188
|
+
newSlug,
|
|
189
|
+
newIdentifier,
|
|
190
|
+
) {
|
|
191
|
+
let result = source;
|
|
192
|
+
// 1. Identifier prefixes: neutralPalettes → oceanPalettes, neutralTheme → oceanTheme
|
|
193
|
+
const identRe = new RegExp(`${escapeRegExp(baseIdentifier)}(?=[A-Z])`, 'gu');
|
|
194
|
+
result = result.replace(identRe, newIdentifier);
|
|
195
|
+
// 2. String-literal theme names
|
|
196
|
+
result = result.replace(
|
|
197
|
+
new RegExp(`'astryx-${escapeRegExp(baseSlug)}'`, 'gu'),
|
|
198
|
+
`'astryx-${newSlug}'`,
|
|
199
|
+
);
|
|
200
|
+
result = result.replace(
|
|
201
|
+
new RegExp(`'${escapeRegExp(baseSlug)}'`, 'gu'),
|
|
202
|
+
`'${newSlug}'`,
|
|
203
|
+
);
|
|
204
|
+
// 3. CSS custom properties scoped to the base theme
|
|
205
|
+
result = result.replace(
|
|
206
|
+
new RegExp(
|
|
207
|
+
`--astryx-theme-${escapeRegExp(baseSlug)}-`,
|
|
208
|
+
'gu',
|
|
209
|
+
),
|
|
210
|
+
`--astryx-theme-${newSlug}-`,
|
|
211
|
+
);
|
|
212
|
+
return result;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/** @param {string} s */
|
|
216
|
+
function escapeRegExp(s) {
|
|
217
|
+
return s.replace(/[.*+?^${}()|[\]\\]/gu, '\\$&');
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** What every app that uses Astryx already has: Core, and React through Core's peers. */
|
|
221
|
+
const APP_PROVIDED = new Set(['@astryxdesign/core', 'react', 'react-dom']);
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* The npm package a module specifier names, or null for a relative path, an
|
|
225
|
+
* absolute path, or a Node built-in.
|
|
226
|
+
* @param {string} specifier
|
|
227
|
+
* @returns {string | null}
|
|
228
|
+
*/
|
|
229
|
+
function packageOfSpecifier(specifier) {
|
|
230
|
+
if (specifier.startsWith('.') || specifier.startsWith('/')) return null;
|
|
231
|
+
if (isBuiltin(specifier)) return null;
|
|
232
|
+
const parts = specifier.split('/');
|
|
233
|
+
return specifier.startsWith('@') ? parts.slice(0, 2).join('/') : parts[0];
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* The npm packages a fork's copied files import that its package does not
|
|
238
|
+
* declare yet, each at the range the bundled themes are built against (the
|
|
239
|
+
* CLI's own package.json). The fork depends on them at runtime, so an app that
|
|
240
|
+
* installs the package needs them too. Derived from the imports, not copied
|
|
241
|
+
* from a base's whole dependency list. Core and React are left out, since every
|
|
242
|
+
* Astryx app has them; so is a fork of the package's own theme, whose imports
|
|
243
|
+
* the package already resolves.
|
|
244
|
+
*
|
|
245
|
+
* @param {import('../../foundation/discovery/theme-discovery.mjs').DiscoveredTheme} base
|
|
246
|
+
* @param {Record<string, any>} pkg - The package's package.json.
|
|
247
|
+
* @returns {Record<string, string>} package name to range
|
|
248
|
+
*/
|
|
249
|
+
function forkDependencies(base, pkg) {
|
|
250
|
+
if (!base.bundled) return {};
|
|
251
|
+
/** @type {Record<string, any>} */
|
|
252
|
+
let cli;
|
|
253
|
+
try {
|
|
254
|
+
cli = JSON.parse(
|
|
255
|
+
fs.readFileSync(path.join(CLI_ROOT, 'package.json'), 'utf-8'),
|
|
256
|
+
);
|
|
257
|
+
} catch {
|
|
258
|
+
return {};
|
|
259
|
+
}
|
|
260
|
+
/** @type {Record<string, string>} */
|
|
261
|
+
const ranges = {
|
|
262
|
+
...cli.devDependencies,
|
|
263
|
+
...cli.peerDependencies,
|
|
264
|
+
...cli.dependencies,
|
|
265
|
+
};
|
|
266
|
+
const declared = {
|
|
267
|
+
...pkg.devDependencies,
|
|
268
|
+
...pkg.peerDependencies,
|
|
269
|
+
...pkg.dependencies,
|
|
270
|
+
};
|
|
271
|
+
/** @type {Record<string, string>} */
|
|
272
|
+
const needed = {};
|
|
273
|
+
for (const file of base.files) {
|
|
274
|
+
const code = /\.(?:[cm]?[jt]sx?)$/u.test(file);
|
|
275
|
+
if (!code || file.endsWith('.doc.mjs')) continue;
|
|
276
|
+
let specifiers;
|
|
277
|
+
try {
|
|
278
|
+
specifiers = themeFileImports(path.join(base.sourceDir, file));
|
|
279
|
+
} catch {
|
|
280
|
+
continue; // discovery already refuses a theme whose source does not parse
|
|
281
|
+
}
|
|
282
|
+
for (const specifier of specifiers) {
|
|
283
|
+
const name = packageOfSpecifier(specifier);
|
|
284
|
+
if (name == null || APP_PROVIDED.has(name) || name in declared) continue;
|
|
285
|
+
if (typeof ranges[name] === 'string') needed[name] = ranges[name];
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return needed;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Build the write plans for a forked theme.
|
|
293
|
+
* @param {import('../../foundation/discovery/theme-discovery.mjs').DiscoveredTheme} base
|
|
294
|
+
* @param {ReturnType<typeof themeIdentity>} identity new theme identity
|
|
295
|
+
* @param {string} themeDir absolute target directory
|
|
296
|
+
* @returns {import('./add-helpers.mjs').WritePlan[]}
|
|
297
|
+
*/
|
|
298
|
+
function forkThemePlans(base, identity, themeDir) {
|
|
299
|
+
const baseIdentity = themeIdentity(base.slug);
|
|
300
|
+
/** @type {import('./add-helpers.mjs').WritePlan[]} */
|
|
301
|
+
const plans = [];
|
|
302
|
+
|
|
303
|
+
// Copy every file the base theme ships (entry first, then the rest), except
|
|
304
|
+
// the descriptor — we write a fresh one.
|
|
305
|
+
const filesToCopy = base.files.filter(
|
|
306
|
+
file => path.posix.basename(file) !== `${baseIdentity.exportName}.doc.mjs`,
|
|
307
|
+
);
|
|
308
|
+
|
|
309
|
+
for (const file of filesToCopy) {
|
|
310
|
+
const srcPath = path.join(base.sourceDir, file);
|
|
311
|
+
const newFileName = renameThemeFile(
|
|
312
|
+
file,
|
|
313
|
+
baseIdentity.identifier,
|
|
314
|
+
identity.identifier,
|
|
315
|
+
);
|
|
316
|
+
const destPath = assertWithin(newFileName, themeDir, {
|
|
317
|
+
label: `forked theme file "${newFileName}"`,
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
// Read source bytes; for text, strip copyright and rewrite identifiers.
|
|
321
|
+
const bytes = fs.readFileSync(srcPath);
|
|
322
|
+
const text = bytes.toString('utf-8');
|
|
323
|
+
const isText = Buffer.from(text, 'utf-8').equals(bytes);
|
|
324
|
+
|
|
325
|
+
/** @type {string | Buffer} */
|
|
326
|
+
let contents;
|
|
327
|
+
if (isText) {
|
|
328
|
+
contents = rewriteThemeSource(
|
|
329
|
+
stripCopyrightHeader(text),
|
|
330
|
+
base.slug,
|
|
331
|
+
baseIdentity.identifier,
|
|
332
|
+
identity.slug,
|
|
333
|
+
identity.identifier,
|
|
334
|
+
);
|
|
335
|
+
} else {
|
|
336
|
+
contents = bytes;
|
|
337
|
+
}
|
|
338
|
+
plans.push({path: destPath, contents, createOnly: true});
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// Write a fresh descriptor — the fork is a new theme, not a derivative.
|
|
342
|
+
const descriptorPath = assertWithin(identity.descriptor, themeDir, {
|
|
343
|
+
label: 'theme descriptor file',
|
|
344
|
+
});
|
|
345
|
+
plans.push({
|
|
346
|
+
path: descriptorPath,
|
|
347
|
+
contents: themeDescriptor(identity),
|
|
348
|
+
createOnly: true,
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
return plans;
|
|
352
|
+
}
|
|
353
|
+
|
|
95
354
|
/**
|
|
96
355
|
* Read bytes back through the same discovery seam Project uses. A write is not
|
|
97
356
|
* successful until the requested slug resolves.
|
|
@@ -129,7 +388,7 @@ async function verifyThemeContribution(packageDir, manifestFile, owner, slug) {
|
|
|
129
388
|
* @returns {Promise<import('./integration-authoring.type.mjs').IntegrationAddResponse>}
|
|
130
389
|
*/
|
|
131
390
|
export async function integrationAddTheme(name, options = {}) {
|
|
132
|
-
const {cwd = process.cwd(), dryRun = false} = options;
|
|
391
|
+
const {cwd = process.cwd(), dryRun = false, from} = options;
|
|
133
392
|
const packageDir = findPackageDir(cwd);
|
|
134
393
|
const packageFile = path.join(packageDir, 'package.json');
|
|
135
394
|
let pkg;
|
|
@@ -211,36 +470,82 @@ export async function integrationAddTheme(name, options = {}) {
|
|
|
211
470
|
const themeDir = assertWithin(identity.slug, root, {
|
|
212
471
|
label: 'theme directory',
|
|
213
472
|
});
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
// An existing folder is filled; only a file this would write is refused.
|
|
221
|
-
for (const file of [sourceFile, descriptorFile]) {
|
|
222
|
-
if (fs.existsSync(file)) {
|
|
473
|
+
|
|
474
|
+
// Resolve the base theme when --from is given, before writing anything.
|
|
475
|
+
/** @type {import('../../foundation/discovery/theme-discovery.mjs').DiscoveredTheme | undefined} */
|
|
476
|
+
let baseTheme;
|
|
477
|
+
if (from != null) {
|
|
478
|
+
if (from === name) {
|
|
223
479
|
throw new AstryxError(
|
|
224
|
-
`
|
|
480
|
+
`Cannot fork theme "${from}" into itself.`,
|
|
225
481
|
undefined,
|
|
226
|
-
ERROR_CODES.
|
|
482
|
+
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
227
483
|
);
|
|
228
484
|
}
|
|
485
|
+
baseTheme = resolveBaseTheme(from, packageDir, owner, root);
|
|
229
486
|
}
|
|
230
487
|
|
|
231
488
|
/** @type {import('./add-helpers.mjs').WritePlan[]} */
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
489
|
+
let plans;
|
|
490
|
+
|
|
491
|
+
if (baseTheme) {
|
|
492
|
+
// Fork: copy the base theme's files, renamed and rewritten.
|
|
493
|
+
plans = forkThemePlans(baseTheme, identity, themeDir);
|
|
494
|
+
// Check that no target file already exists.
|
|
495
|
+
for (const plan of plans) {
|
|
496
|
+
if (fs.existsSync(plan.path)) {
|
|
497
|
+
throw new AstryxError(
|
|
498
|
+
`Refusing to overwrite existing file ${projectPath(path.relative(packageDir, plan.path))}.`,
|
|
499
|
+
undefined,
|
|
500
|
+
ERROR_CODES.ERR_FILE_EXISTS,
|
|
501
|
+
);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
} else {
|
|
505
|
+
// Blank scaffold.
|
|
506
|
+
const sourceFile = assertWithin(identity.entry, themeDir, {
|
|
507
|
+
label: 'theme source file',
|
|
508
|
+
});
|
|
509
|
+
const descriptorFile = assertWithin(identity.descriptor, themeDir, {
|
|
510
|
+
label: 'theme descriptor file',
|
|
511
|
+
});
|
|
512
|
+
for (const file of [sourceFile, descriptorFile]) {
|
|
513
|
+
if (fs.existsSync(file)) {
|
|
514
|
+
throw new AstryxError(
|
|
515
|
+
`Refusing to overwrite existing file ${projectPath(path.relative(packageDir, file))}.`,
|
|
516
|
+
undefined,
|
|
517
|
+
ERROR_CODES.ERR_FILE_EXISTS,
|
|
518
|
+
);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
plans = [
|
|
522
|
+
{path: sourceFile, contents: themeSource(identity), createOnly: true},
|
|
523
|
+
{
|
|
524
|
+
path: descriptorFile,
|
|
525
|
+
contents: themeDescriptor(identity),
|
|
526
|
+
createOnly: true,
|
|
527
|
+
},
|
|
528
|
+
];
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
const outputBase = projectPath(
|
|
532
|
+
path.relative(packageDir, path.join(themeDir, identity.slug)),
|
|
533
|
+
);
|
|
240
534
|
let packageUpdate = packageJsonUpdate(
|
|
241
535
|
packageFile,
|
|
242
536
|
rootPath,
|
|
243
537
|
path.basename(manifestFile),
|
|
538
|
+
[
|
|
539
|
+
{
|
|
540
|
+
subpath: `themes/${identity.slug}`,
|
|
541
|
+
target: `${outputBase}.js`,
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
subpath: `themes/${identity.slug}.css`,
|
|
545
|
+
target: `${outputBase}.css`,
|
|
546
|
+
},
|
|
547
|
+
],
|
|
548
|
+
{createExports: true, sideEffects: ['**/*.css']},
|
|
244
549
|
);
|
|
245
550
|
// A CLI older than the one that reads typed theme descriptors rejects the
|
|
246
551
|
// themes root and withholds the package's themes and docs. Declare the CLI
|
|
@@ -250,11 +555,27 @@ export async function integrationAddTheme(name, options = {}) {
|
|
|
250
555
|
packageUpdate?.expectedOriginal ?? fs.readFileSync(packageFile);
|
|
251
556
|
const text = packageUpdate?.contents ?? expectedOriginal.toString('utf-8');
|
|
252
557
|
const current = JSON.parse(text);
|
|
253
|
-
|
|
558
|
+
let next =
|
|
559
|
+
themesCliProblem(current) != null
|
|
560
|
+
? withCliPeer(current, THEMES_CLI)
|
|
561
|
+
: current;
|
|
562
|
+
// A fork runs the base's imports: declare the packages they come from.
|
|
563
|
+
const forked = baseTheme ? forkDependencies(baseTheme, next) : {};
|
|
564
|
+
if (Object.keys(forked).length > 0) {
|
|
565
|
+
const dependencies = {...next.dependencies, ...forked};
|
|
566
|
+
next = {
|
|
567
|
+
...next,
|
|
568
|
+
dependencies: Object.fromEntries(
|
|
569
|
+
Object.keys(dependencies)
|
|
570
|
+
.sort()
|
|
571
|
+
.map(name => [name, dependencies[name]]),
|
|
572
|
+
),
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
if (next !== current) {
|
|
254
576
|
packageUpdate = {
|
|
255
577
|
contents:
|
|
256
|
-
JSON.stringify(
|
|
257
|
-
(text.endsWith('\n') ? '\n' : ''),
|
|
578
|
+
JSON.stringify(next, null, 2) + (text.endsWith('\n') ? '\n' : ''),
|
|
258
579
|
expectedOriginal,
|
|
259
580
|
};
|
|
260
581
|
}
|
|
@@ -308,7 +629,8 @@ export async function integrationAddTheme(name, options = {}) {
|
|
|
308
629
|
writtenFiles.push(manifestPath);
|
|
309
630
|
}
|
|
310
631
|
|
|
311
|
-
|
|
632
|
+
/** @type {import('./integration-authoring.type.mjs').IntegrationAddResponse} */
|
|
633
|
+
const response = {
|
|
312
634
|
type: 'integration.add',
|
|
313
635
|
data: {
|
|
314
636
|
kind: 'theme',
|
|
@@ -320,4 +642,8 @@ export async function integrationAddTheme(name, options = {}) {
|
|
|
320
642
|
dryRun,
|
|
321
643
|
},
|
|
322
644
|
};
|
|
645
|
+
if (from != null) {
|
|
646
|
+
response.data.from = from;
|
|
647
|
+
}
|
|
648
|
+
return response;
|
|
323
649
|
}
|