@astryxdesign/cli 0.6.5 → 0.6.6-canary.1eb16a0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +87 -0
- package/README.md +58 -55
- package/api/build/_adapter.d.mts +55 -2
- package/api/build/_adapter.mjs +100 -10
- package/api/build/build.doc.mjs +2 -2
- package/api/build/build.test.mjs +111 -2
- package/api/build/build.type.d.mts +8 -0
- package/api/build/build.type.mjs +2 -0
- package/api/build/kit/kit.mjs +99 -22
- package/api/build/kit/rank.d.mts +32 -8
- package/api/build/kit/rank.mjs +291 -97
- package/api/build/kit/rank.test.mjs +231 -48
- package/api/build/kit/weights.d.mts +82 -0
- package/api/build/kit/weights.json +1 -0
- package/api/build/kit/weights.mjs +305 -0
- package/api/build/kit/weights.test.mjs +190 -0
- package/api/component/_adapter.d.mts +19 -0
- package/api/component/_adapter.mjs +33 -0
- package/api/component/component-replacement.test.mjs +603 -0
- package/api/component/component.mjs +49 -15
- package/api/component/component.test.mjs +32 -0
- package/api/component/component.type.d.mts +33 -3
- package/api/component/component.type.mjs +10 -3
- package/api/component/detail/blocks/blocks.d.mts +2 -1
- package/api/component/detail/blocks/blocks.mjs +5 -2
- package/api/component/detail/detail.mjs +5 -1
- package/api/component/detail/props/props.d.mts +2 -1
- package/api/component/detail/props/props.mjs +3 -2
- package/api/component/detail/showcase/showcase.d.mts +3 -1
- package/api/component/detail/showcase/showcase.mjs +3 -1
- package/api/component/detail/source/source.d.mts +3 -2
- package/api/component/detail/source/source.mjs +7 -3
- package/api/component/list/list.mjs +128 -10
- package/api/docs/_adapter.d.mts +11 -0
- package/api/docs/_adapter.mjs +25 -0
- package/api/docs/detail/detail.mjs +19 -3
- package/api/docs/detail/section/section.mjs +7 -1
- package/api/docs/docOverlays.test.mjs +10 -6
- package/api/docs/docs.d.mts +6 -0
- package/api/docs/docs.depth.test.mjs +134 -0
- package/api/docs/docs.doc.mjs +31 -2
- package/api/docs/docs.mjs +46 -1
- package/api/docs/docs.test.mjs +279 -0
- package/api/docs/docs.type.d.mts +81 -4
- package/api/docs/docs.type.mjs +41 -4
- package/api/docs/index/index.mjs +11 -2
- package/api/docs/index/index.test.mjs +7 -2
- package/api/docs/integration-tree.test.mjs +572 -0
- package/api/docs/integrationDocs.test.mjs +337 -0
- package/api/docs/node/node.d.mts +28 -3
- package/api/docs/node/node.mjs +149 -23
- package/api/doctor/_adapter.d.mts +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 +10 -11
- package/api/integration/__fixtures__/released-0.6.5-ocean.d.mts +14 -0
- package/api/integration/__fixtures__/released-0.6.5-ocean.mjs +15 -0
- package/api/integration/add-contribution.d.mts +2 -1
- package/api/integration/add-contribution.mjs +7 -3
- package/api/integration/add-contribution.test.mjs +3 -3
- package/api/integration/add-helpers.d.mts +26 -5
- package/api/integration/add-helpers.mjs +50 -5
- package/api/integration/add-theme.mjs +354 -28
- package/api/integration/add-theme.test.mjs +380 -16
- package/api/integration/authoring-checks.mjs +31 -8
- package/api/integration/authoring-checks.type.d.mts +8 -0
- package/api/integration/authoring-checks.type.mjs +7 -3
- package/api/integration/integration-authoring.type.d.mts +4 -1
- package/api/integration/integration-authoring.type.mjs +6 -1
- package/api/integration/integrationAdd.doc.mjs +6 -0
- package/api/integration/integrationAddTheme.doc.mjs +10 -0
- package/api/integration/integrationComponentConflicts.doc.mjs +6 -3
- package/api/integration/integrationDocConflicts.doc.mjs +1 -1
- package/api/integration/integrationTemplateConflicts.doc.mjs +1 -1
- package/api/integration/pack-check.component-replaces.test.mjs +126 -0
- package/api/integration/pack-check.d.mts +10 -0
- package/api/integration/pack-check.lifecycle-output.test.mjs +21 -2
- package/api/integration/pack-check.mjs +495 -4
- package/api/integration/pack-check.test.mjs +619 -10
- package/api/integration/validate-integration.d.mts +4 -2
- package/api/integration/validate-integration.mjs +7 -2
- package/api/integration/validate-integration.test.mjs +55 -0
- package/api/integration/validate-integration.type.d.mts +5 -0
- package/api/integration/validate-integration.type.mjs +5 -1
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/layout/expand/expand.mjs +12 -7
- package/api/layout/expand/expand.receipt.test.mjs +74 -0
- package/api/layout/layout.type.d.mts +1 -0
- package/api/layout/layout.type.mjs +1 -0
- package/api/layout/layoutExpand.doc.mjs +1 -1
- package/api/search/search.d.mts +39 -8
- package/api/search/search.doc.mjs +4 -4
- package/api/search/search.mjs +248 -66
- package/api/search/search.test.mjs +829 -0
- package/api/search/search.type.d.mts +6 -6
- package/api/search/search.type.mjs +5 -5
- package/api/swizzle/_adapter.d.mts +10 -0
- package/api/swizzle/_adapter.mjs +23 -0
- package/api/swizzle/copy/copy.d.mts +5 -6
- package/api/swizzle/copy/copy.mjs +95 -13
- package/api/swizzle/list/list.mjs +2 -2
- package/api/swizzle/swizzle.doc.mjs +4 -0
- package/api/swizzle/swizzle.test.mjs +55 -5
- package/api/swizzle/swizzle.type.d.mts +8 -0
- package/api/swizzle/swizzle.type.mjs +2 -0
- package/api/template/copy/copy.mjs +15 -8
- package/api/template/copy/copy.receipt.test.mjs +77 -0
- package/api/template/show/show.mjs +17 -4
- package/api/template/show/show.test.mjs +76 -0
- package/api/template/skeleton/skeleton.mjs +2 -1
- package/api/template/template-integration.test.mjs +14 -0
- package/api/template/template.d.mts +1 -1
- package/api/template/template.doc.mjs +6 -2
- package/api/template/template.mjs +2 -0
- package/api/template/template.type.d.mts +14 -0
- package/api/template/template.type.mjs +5 -0
- package/api/theme/_adapter.d.mts +106 -6
- package/api/theme/_adapter.mjs +687 -18
- package/api/theme/add/add.binary.test.mjs +76 -3
- package/api/theme/add/add.d.mts +5 -9
- package/api/theme/add/add.mjs +87 -64
- package/api/theme/add/add.rollback.test.mjs +9 -9
- package/api/theme/add/add.staging.test.mjs +9 -9
- package/api/theme/add/add.test.mjs +461 -55
- package/api/theme/add/add.types.test.mjs +151 -0
- package/api/theme/build/build.d.mts +50 -2
- package/api/theme/build/build.family.test.mjs +13 -4
- package/api/theme/build/build.icon-lineage.test.mjs +117 -0
- package/api/theme/build/build.icon-preservation.test.mjs +639 -0
- package/api/theme/build/build.mjs +463 -155
- package/api/theme/build/build.project-core.test.mjs +165 -0
- package/api/theme/build/build.test.mjs +220 -1
- package/api/theme/build/icon-imports.d.mts +47 -0
- package/api/theme/build/icon-imports.mjs +691 -0
- package/api/theme/eject/eject.binary.test.mjs +90 -0
- package/api/theme/eject/eject.d.mts +17 -0
- package/api/theme/eject/eject.mjs +65 -0
- package/api/theme/eject/eject.rollback.test.mjs +158 -0
- package/api/theme/eject/eject.staging.test.mjs +83 -0
- package/api/theme/eject/eject.test.mjs +160 -0
- package/api/theme/integration-themes.test.mjs +30 -6
- package/api/theme/list/list.d.mts +10 -0
- package/api/theme/list/list.mjs +75 -7
- package/api/theme/list/list.test.mjs +155 -4
- package/api/theme/remove/remove.d.mts +12 -0
- package/api/theme/remove/remove.mjs +15 -0
- package/api/theme/remove/remove.test.mjs +94 -0
- package/api/theme/template/template.mjs +3 -4
- package/api/theme/theme.d.mts +5 -2
- package/api/theme/theme.mjs +13 -8
- package/api/theme/theme.type.d.mts +106 -2
- package/api/theme/theme.type.mjs +54 -5
- package/api/theme/themeAdd.doc.d.mts +1 -3
- package/api/theme/themeAdd.doc.mjs +35 -22
- package/api/theme/themeBuild.doc.d.mts +4 -1
- package/api/theme/themeBuild.doc.mjs +15 -4
- package/api/theme/themeEject.doc.d.mts +8 -0
- package/api/theme/themeEject.doc.mjs +89 -0
- package/api/theme/themeListAvailable.doc.mjs +4 -4
- package/api/theme/themeListCopySources.doc.d.mts +8 -0
- package/api/theme/themeListCopySources.doc.mjs +60 -0
- package/api/theme/themeRemove.doc.d.mts +6 -0
- package/api/theme/themeRemove.doc.mjs +50 -0
- package/api/theme/themeTemplate.doc.mjs +4 -3
- package/api/theme/themeUse.doc.d.mts +6 -0
- package/api/theme/themeUse.doc.mjs +47 -0
- package/api/theme/use/use.d.mts +12 -0
- package/api/theme/use/use.mjs +15 -0
- package/api/theme/use/use.test.mjs +98 -0
- package/api/upgrade/_adapter.d.mts +1 -0
- package/api/upgrade/_adapter.mjs +3 -0
- package/api/upgrade/list/list.mjs +9 -3
- package/api/upgrade/run/run.mjs +20 -3
- package/api/upgrade/run/run.test.mjs +45 -1
- package/api/upgrade/upgrade.doc.mjs +1 -1
- package/api/upgrade/upgrade.type.d.mts +5 -0
- package/api/upgrade/upgrade.type.mjs +2 -0
- package/assets/codemods/integration-discovery.mjs +1 -1
- package/assets/codemods/integration-discovery.test.mjs +64 -0
- package/assets/codemods/transforms/next/__tests__/migrate-copied-themes-to-descriptors.test.mjs +129 -0
- package/assets/codemods/transforms/next/index.mjs +14 -1
- package/assets/codemods/transforms/next/migrate-copied-themes-to-descriptors.mjs +54 -0
- package/assets/docs/author-a-theme.doc.mjs +161 -0
- package/assets/docs/getting-started.doc.mjs +59 -15
- package/assets/docs/icons.doc.mjs +1 -0
- package/assets/docs/principles.doc.dense.mjs +2 -2
- package/assets/docs/principles.doc.mjs +2 -2
- package/assets/docs/principles.doc.zh.mjs +2 -2
- package/assets/docs/styling-libraries.doc.mjs +1 -1
- package/assets/docs/styling-overview.doc.mjs +211 -0
- package/assets/docs/styling.doc.mjs +2 -2
- package/assets/docs/theme.doc.dense.mjs +10 -198
- package/assets/docs/theme.doc.mjs +13 -770
- package/assets/docs/theme.doc.zh.mjs +31 -12
- package/assets/docs/tokens.doc.mjs +4 -4
- package/assets/docs/tree/add-a-theme.doc.mjs +6 -2
- package/assets/docs/tree/add-a-topic.doc.mjs +1 -1
- package/assets/docs/tree/check-your-docs.doc.mjs +2 -2
- package/assets/docs/tree/checks.doc.mjs +6 -5
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +1 -1
- package/assets/docs/tree/define-the-theme.doc.mjs +2 -2
- package/assets/docs/tree/document-the-theme.doc.mjs +4 -4
- package/assets/docs/tree/fonts-and-assets.doc.mjs +25 -20
- package/assets/docs/tree/headers-and-footers.doc.mjs +68 -0
- package/assets/docs/tree/layout-spacing.doc.mjs +168 -0
- package/assets/docs/tree/layout.doc.mjs +32 -0
- package/assets/docs/tree/replace-a-core-component.doc.mjs +21 -4
- package/assets/docs/tree/responsive.doc.mjs +102 -0
- package/assets/docs/tree/scaffold.doc.mjs +145 -0
- package/assets/docs/tree/sections-and-placement.doc.mjs +1 -1
- package/assets/docs/tree/side-panels.doc.mjs +82 -0
- package/assets/docs/tree/structure.doc.mjs +144 -0
- package/assets/docs/tree/template-doc-overview.doc.mjs +13 -1
- package/assets/docs/tree/themes.doc.mjs +2 -2
- package/assets/docs/tree/troubleshooting.doc.mjs +13 -5
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +22 -5
- package/assets/docs/tree/versioning.doc.mjs +11 -7
- package/assets/docs/use-a-theme.doc.mjs +209 -0
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.doc.mjs +15 -0
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.tsx +38 -0
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.doc.mjs +20 -0
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.tsx +48 -0
- package/assets/templates/pages/ai-chat/template.doc.mjs +16 -1
- package/assets/templates/pages/ai-chat-landing/template.doc.mjs +9 -1
- package/assets/templates/pages/blank/template.doc.mjs +3 -1
- package/assets/templates/pages/canvas-editor/template.doc.mjs +9 -1
- package/assets/templates/pages/centered-hero/template.doc.mjs +3 -1
- package/assets/templates/pages/checkout-wizard/template.doc.mjs +1 -0
- package/assets/templates/pages/classic-gallery/template.doc.mjs +3 -1
- package/assets/templates/pages/contact-form/template.doc.mjs +16 -1
- package/assets/templates/pages/dashboard/template.doc.mjs +15 -1
- package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +23 -1
- package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +10 -1
- package/assets/templates/pages/dashboard-comparison/template.doc.mjs +9 -1
- package/assets/templates/pages/dashboard-composition/template.doc.mjs +10 -1
- package/assets/templates/pages/dashboard-progress/template.doc.mjs +17 -1
- package/assets/templates/pages/dashboard-scorecard/template.doc.mjs +2 -1
- package/assets/templates/pages/detail-page/template.doc.mjs +8 -0
- package/assets/templates/pages/documentation/template.doc.mjs +10 -1
- package/assets/templates/pages/documentation-design/template.doc.mjs +10 -1
- package/assets/templates/pages/documentation-technical/template.doc.mjs +10 -1
- package/assets/templates/pages/editor/template.doc.mjs +9 -1
- package/assets/templates/pages/file-explorer/template.doc.mjs +3 -1
- package/assets/templates/pages/form-two-column/template.doc.mjs +17 -1
- package/assets/templates/pages/form-wizard/template.doc.mjs +14 -1
- package/assets/templates/pages/form-wizard-dialog/template.doc.mjs +1 -0
- package/assets/templates/pages/gallery-hero/template.doc.mjs +10 -1
- package/assets/templates/pages/ide/template.doc.mjs +9 -1
- package/assets/templates/pages/incident-console/template.doc.mjs +10 -1
- package/assets/templates/pages/kanban-board/template.doc.mjs +11 -1
- package/assets/templates/pages/library/template.doc.mjs +15 -1
- package/assets/templates/pages/login/template.doc.mjs +10 -1
- package/assets/templates/pages/login-card/template.doc.mjs +11 -1
- package/assets/templates/pages/login-split/template.doc.mjs +10 -1
- package/assets/templates/pages/login-sso/template.doc.mjs +10 -1
- package/assets/templates/pages/messaging-shell/template.doc.mjs +11 -1
- package/assets/templates/pages/mixed-gallery/template.doc.mjs +10 -1
- package/assets/templates/pages/payment-form/template.doc.mjs +3 -1
- package/assets/templates/pages/product-detail/template.doc.mjs +9 -1
- package/assets/templates/pages/product-gallery/template.doc.mjs +10 -1
- package/assets/templates/pages/settings/template.doc.mjs +3 -1
- package/assets/templates/pages/settings-dialog/template.doc.mjs +9 -1
- package/assets/templates/pages/settings-sidebar/template.doc.mjs +9 -1
- package/assets/templates/pages/shell-nav/template.doc.mjs +10 -1
- package/assets/templates/pages/shell-side-nav/template.doc.mjs +14 -1
- package/assets/templates/pages/shell-top-nav/template.doc.mjs +11 -1
- package/assets/templates/pages/side-gallery/template.doc.mjs +3 -1
- package/assets/templates/pages/table/template.doc.mjs +11 -1
- package/assets/templates/pages/table-collapsible/page.tsx +1474 -0
- package/assets/templates/pages/table-collapsible/template.doc.mjs +12 -0
- package/assets/templates/pages/table-comparison/page.tsx +1449 -0
- package/assets/templates/pages/table-comparison/template.doc.mjs +12 -0
- package/assets/templates/pages/table-filter/template.doc.mjs +21 -1
- package/assets/templates/pages/table-grouped/template.doc.mjs +15 -1
- package/assets/templates/pages/table-inbox/template.doc.mjs +18 -6
- package/assets/templates/pages/table-page/template.doc.mjs +20 -1
- package/assets/templates/pages/table-tree/template.doc.mjs +14 -1
- package/assets/templates/pages/theme-showcase/template.doc.mjs +10 -1
- package/assets/templates/pages/work-item-detail/template.doc.mjs +10 -0
- package/assets/templates/themes/butter/icons.tsx +2 -0
- package/assets/templates/themes/chocolate/icons.tsx +2 -0
- package/assets/templates/themes/gothic/icons.tsx +2 -0
- package/assets/templates/themes/matcha/icons.tsx +2 -0
- package/assets/templates/themes/neutral/icons.tsx +2 -0
- package/assets/templates/themes/stone/icons.tsx +2 -0
- package/assets/templates/themes/y2k/icons.tsx +2 -0
- package/authoring/doctypes/command/command.doc.mjs +5 -0
- package/authoring/doctypes/command/type.ts +2 -0
- package/authoring/doctypes/component/component.doc.mjs +1 -1
- package/authoring/doctypes/component/type.ts +8 -4
- package/authoring/doctypes/template/parse.d.mts +2 -0
- package/authoring/doctypes/template/parse.mjs +1 -0
- package/authoring/doctypes/template/parse.test.mjs +21 -0
- package/authoring/doctypes/template/template.doc.mjs +6 -0
- package/authoring/doctypes/template/type.ts +11 -0
- package/authoring/integration/integration.doc.mjs +1 -1
- package/clients/cli/commands/build-theme.mjs +279 -30
- package/clients/cli/commands/build.mjs +7 -6
- package/clients/cli/commands/build.text-fields.test.mjs +1 -1
- package/clients/cli/commands/component/index.mjs +88 -12
- package/clients/cli/commands/component-replacement.text.test.mjs +271 -0
- package/clients/cli/commands/component.doc.mjs +9 -2
- package/clients/cli/commands/discover.mjs +29 -1
- package/clients/cli/commands/discover.no-source.test.mjs +75 -0
- package/clients/cli/commands/docs.depth.test.mjs +219 -0
- package/clients/cli/commands/docs.doc.mjs +15 -2
- package/clients/cli/commands/docs.mjs +273 -16
- package/clients/cli/commands/docs.test.mjs +382 -0
- package/clients/cli/commands/doctor-integration-components.doc.mjs +15 -4
- package/clients/cli/commands/doctor.doc.mjs +1 -1
- package/clients/cli/commands/doctor.mjs +4 -4
- package/clients/cli/commands/doctor.test.mjs +9 -51
- package/clients/cli/commands/gap-report.doc.mjs +2 -2
- package/clients/cli/commands/gap-report.mjs +12 -0
- package/clients/cli/commands/gap-report.test.mjs +63 -0
- package/clients/cli/commands/hook/index.mjs +7 -2
- package/clients/cli/commands/import-hint-correctness.test.mjs +5 -5
- package/clients/cli/commands/init.next-steps.test.mjs +18 -23
- package/clients/cli/commands/integration-add.doc.mjs +10 -0
- package/clients/cli/commands/integration-authoring.test.mjs +12 -2
- package/clients/cli/commands/integration-real-world.test.mjs +61 -12
- package/clients/cli/commands/integration.mjs +3 -1
- package/clients/cli/commands/layout-check.doc.mjs +1 -0
- package/clients/cli/commands/layout-expand.doc.mjs +4 -1
- package/clients/cli/commands/layout-grammar.doc.mjs +1 -0
- package/clients/cli/commands/layout.doc.mjs +1 -0
- package/clients/cli/commands/layout.expand-receipt.test.mjs +94 -0
- package/clients/cli/commands/layout.mjs +61 -4
- package/clients/cli/commands/no-prompt-wording.test.mjs +4 -4
- package/clients/cli/commands/search.doc.mjs +5 -4
- package/clients/cli/commands/search.mjs +30 -6
- package/clients/cli/commands/search.test.mjs +63 -17
- package/clients/cli/commands/swizzle.doc.mjs +12 -3
- package/clients/cli/commands/swizzle.mjs +2 -1
- package/clients/cli/commands/template.copy-receipt.test.mjs +60 -0
- package/clients/cli/commands/template.mjs +70 -6
- package/clients/cli/commands/template.show-media.test.mjs +62 -0
- package/clients/cli/commands/text-json-parity.test.mjs +40 -0
- package/clients/cli/commands/theme-add-lifecycle.test.mjs +132 -0
- package/clients/cli/commands/theme-add.doc.mjs +19 -19
- package/clients/cli/commands/theme-eject.doc.mjs +47 -0
- package/clients/cli/commands/theme-list.behavior.test.mjs +44 -0
- package/clients/cli/commands/theme-list.doc.mjs +2 -2
- package/clients/cli/commands/theme-palette-generate.doc.mjs +1 -2
- package/clients/cli/commands/theme-remove.doc.mjs +22 -0
- package/clients/cli/commands/theme-template.doc.mjs +4 -3
- package/clients/cli/commands/theme-use.doc.mjs +22 -0
- package/clients/cli/commands/theme.doc.mjs +21 -16
- package/clients/cli/commands/upgrade.ascii-output.test.mjs +14 -0
- package/clients/cli/commands/upgrade.mjs +1 -1
- package/clients/cli/commands/write-failure.test.mjs +175 -0
- package/clients/cli/index.mjs +4 -1
- package/clients/cli/lib/component-format.mjs +19 -2
- package/clients/cli/lib/manifest.mjs +44 -165
- package/clients/cli/lib/manifest.test.mjs +98 -7
- package/clients/cli/lib/resolve-theme.mjs +80 -78
- package/clients/cli/lib/resolve-theme.test.mjs +523 -27
- package/foundation/agent-docs/agent-docs.mjs +31 -28
- package/foundation/agent-docs/agent-docs.test.mjs +1163 -0
- package/foundation/agent-docs/app-theme-workflow.test.mjs +13 -0
- package/foundation/config/project.d.mts +20 -5
- package/foundation/config/project.mjs +43 -6
- package/foundation/config/theme-private-vars.d.mts +12 -0
- package/foundation/config/theme-private-vars.mjs +107 -0
- package/foundation/config/theme-private-vars.test.mjs +55 -0
- package/foundation/config/theme-state.d.mts +145 -0
- package/foundation/config/theme-state.mjs +417 -0
- package/foundation/config/theme-state.test.mjs +182 -0
- package/foundation/discovery/component-discovery.d.mts +5 -2
- package/foundation/discovery/component-discovery.mjs +12 -6
- package/foundation/discovery/component-replacement.d.mts +91 -0
- package/foundation/discovery/component-replacement.mjs +417 -0
- package/foundation/discovery/component-replacement.test.mjs +480 -0
- package/foundation/discovery/docs-output-budget.d.mts +6 -2
- package/foundation/discovery/docs-output-budget.mjs +2 -1
- package/foundation/discovery/docs-section-key.d.mts +4 -2
- package/foundation/discovery/docs-section-key.mjs +1 -1
- package/foundation/discovery/module-exports.d.mts +10 -0
- package/foundation/discovery/module-exports.mjs +146 -0
- package/foundation/discovery/package-exports.d.mts +29 -0
- package/foundation/discovery/package-exports.mjs +200 -0
- package/foundation/discovery/template-adapter.d.mts +14 -0
- package/foundation/discovery/template-adapter.fixture-refs.test.mjs +37 -1
- package/foundation/discovery/template-adapter.mjs +21 -1
- package/foundation/discovery/theme-discovery.d.mts +78 -5
- package/foundation/discovery/theme-discovery.mjs +143 -18
- package/foundation/discovery/theme-discovery.test.mjs +9 -3
- package/foundation/discovery/theme-imports.d.mts +15 -0
- package/foundation/discovery/theme-imports.mjs +217 -0
- package/foundation/discovery/theme-imports.test.mjs +173 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +18 -8
- package/foundation/doc-compiler/inputs.mjs +2 -1
- package/foundation/doc-compiler/inputs.test.mjs +0 -1
- package/foundation/doc-compiler/lenses.d.mts +4 -2
- package/foundation/doc-compiler/lenses.mjs +1 -1
- package/foundation/doc-compiler/tree.test.mjs +649 -0
- package/foundation/fs/module-loader.d.mts +9 -0
- package/foundation/fs/module-loader.mjs +71 -2
- package/foundation/integrations/cli-requirement.d.mts +79 -13
- package/foundation/integrations/cli-requirement.mjs +115 -22
- package/foundation/integrations/cli-requirement.test.mjs +205 -8
- package/foundation/integrations/contribution-inventory.mjs +3 -3
- package/foundation/response/base.d.ts +9 -3
- package/foundation/response/json.d.mts +7 -4
- package/foundation/response/json.mjs +10 -6
- package/foundation/response/response-types.doc.d.mts +5 -5
- package/foundation/response/response-types.doc.mjs +50 -35
- package/foundation/response/response.doc.mjs +18 -4
- package/foundation/text/copyright-header.mjs +1 -1
- package/foundation/text/copyright-header.test.mjs +1 -1
- package/package.json +9 -9
- package/assets/docs/layout.doc.dense.mjs +0 -388
- package/assets/docs/layout.doc.mjs +0 -550
|
@@ -1,63 +1,208 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
* @file Direct-API tests for the `theme add` leaf. Copies real bundled themes
|
|
5
|
-
* into a tmp cwd and asserts the receipt + on-disk effects, plus the guard rails
|
|
6
|
-
* (unknown slug, no-overwrite, path traversal). Uses the maintained `neutral`
|
|
7
|
-
* theme so the fixture stays stable.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import {describe, it, expect, beforeEach, afterEach} from 'vitest';
|
|
3
|
+
import {afterEach, beforeEach, describe, expect, it} from 'vitest';
|
|
11
4
|
import * as fs from 'node:fs';
|
|
12
5
|
import * as path from 'node:path';
|
|
13
|
-
import * as os from 'node:os';
|
|
14
6
|
import {themeAdd} from './add.mjs';
|
|
7
|
+
import {themeEject} from '../eject/eject.mjs';
|
|
8
|
+
import {
|
|
9
|
+
THEME_MODULE_MARKER,
|
|
10
|
+
parseThemeModuleRecord,
|
|
11
|
+
} from '../../../foundation/config/theme-state.mjs';
|
|
15
12
|
|
|
16
13
|
let tmpDir;
|
|
17
14
|
|
|
15
|
+
function installTheme(
|
|
16
|
+
slug = 'ocean',
|
|
17
|
+
packageName = '@acme/themes',
|
|
18
|
+
options = {},
|
|
19
|
+
) {
|
|
20
|
+
const packageDir = path.join(
|
|
21
|
+
tmpDir,
|
|
22
|
+
'node_modules',
|
|
23
|
+
...packageName.split('/'),
|
|
24
|
+
);
|
|
25
|
+
const sourceDir = path.join(packageDir, 'themes', slug);
|
|
26
|
+
const exportName = `${slug}Theme`;
|
|
27
|
+
fs.mkdirSync(sourceDir, {recursive: true});
|
|
28
|
+
fs.mkdirSync(path.join(packageDir, 'dist'), {recursive: true});
|
|
29
|
+
fs.writeFileSync(
|
|
30
|
+
path.join(packageDir, 'package.json'),
|
|
31
|
+
JSON.stringify({
|
|
32
|
+
name: packageName,
|
|
33
|
+
version: '1.0.0',
|
|
34
|
+
type: 'module',
|
|
35
|
+
exports: {
|
|
36
|
+
[`./themes/${slug}`]: `./dist/${slug}.js`,
|
|
37
|
+
[`./themes/${slug}.css`]: `./dist/${slug}.css`,
|
|
38
|
+
},
|
|
39
|
+
}),
|
|
40
|
+
);
|
|
41
|
+
fs.writeFileSync(
|
|
42
|
+
path.join(packageDir, 'astryx.integration.mjs'),
|
|
43
|
+
"export default {themes: './themes'};\n",
|
|
44
|
+
);
|
|
45
|
+
fs.writeFileSync(
|
|
46
|
+
path.join(sourceDir, `${exportName}.doc.mjs`),
|
|
47
|
+
`/** @type {import('@astryxdesign/cli/authoring').ThemeDoc} */\nexport default {type: 'theme', name: '${slug}', displayName: '${slug}', description: '${slug} theme.', maintained: true};\n`,
|
|
48
|
+
);
|
|
49
|
+
fs.writeFileSync(
|
|
50
|
+
path.join(sourceDir, `${exportName}.ts`),
|
|
51
|
+
`export const ${exportName} = {};\n`,
|
|
52
|
+
);
|
|
53
|
+
if (!options.missingBuilt) {
|
|
54
|
+
fs.writeFileSync(
|
|
55
|
+
path.join(packageDir, `dist/${slug}.js`),
|
|
56
|
+
`export const ${exportName} = {name: '${slug}', __built: true};\n`,
|
|
57
|
+
);
|
|
58
|
+
fs.writeFileSync(
|
|
59
|
+
path.join(packageDir, `dist/${slug}.css`),
|
|
60
|
+
`[data-astryx-theme="${slug}"] {}\n`,
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
const pkg = JSON.parse(
|
|
64
|
+
fs.readFileSync(path.join(tmpDir, 'package.json'), 'utf-8'),
|
|
65
|
+
);
|
|
66
|
+
pkg.dependencies[packageName] = '^1.0.0';
|
|
67
|
+
fs.writeFileSync(
|
|
68
|
+
path.join(tmpDir, 'package.json'),
|
|
69
|
+
`${JSON.stringify(pkg)}\n`,
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function installBuiltThemePackage(slug) {
|
|
74
|
+
const packageName = `@astryxdesign/theme-${slug}`;
|
|
75
|
+
const packageDir = path.join(
|
|
76
|
+
tmpDir,
|
|
77
|
+
'node_modules',
|
|
78
|
+
...packageName.split('/'),
|
|
79
|
+
);
|
|
80
|
+
const exportName = `${slug}Theme`;
|
|
81
|
+
fs.mkdirSync(path.join(packageDir, 'dist'), {recursive: true});
|
|
82
|
+
fs.writeFileSync(
|
|
83
|
+
path.join(packageDir, 'package.json'),
|
|
84
|
+
JSON.stringify({
|
|
85
|
+
name: packageName,
|
|
86
|
+
version: '1.0.0',
|
|
87
|
+
type: 'module',
|
|
88
|
+
exports: {
|
|
89
|
+
'./built': './dist/built.js',
|
|
90
|
+
'./theme.css': './dist/theme.css',
|
|
91
|
+
},
|
|
92
|
+
}),
|
|
93
|
+
);
|
|
94
|
+
fs.writeFileSync(
|
|
95
|
+
path.join(packageDir, 'dist/built.js'),
|
|
96
|
+
`export const ${exportName} = {name: '${slug}', __built: true};\n`,
|
|
97
|
+
);
|
|
98
|
+
fs.writeFileSync(
|
|
99
|
+
path.join(packageDir, 'dist/theme.css'),
|
|
100
|
+
`[data-astryx-theme="${slug}"] {}\n`,
|
|
101
|
+
);
|
|
102
|
+
const pkg = JSON.parse(
|
|
103
|
+
fs.readFileSync(path.join(tmpDir, 'package.json'), 'utf-8'),
|
|
104
|
+
);
|
|
105
|
+
pkg.dependencies[packageName] = '^1.0.0';
|
|
106
|
+
fs.writeFileSync(
|
|
107
|
+
path.join(tmpDir, 'package.json'),
|
|
108
|
+
`${JSON.stringify(pkg)}\n`,
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
18
112
|
beforeEach(() => {
|
|
19
|
-
tmpDir = fs.mkdtempSync(path.join(
|
|
113
|
+
tmpDir = fs.mkdtempSync(path.join(process.cwd(), '.astryx-theme-add-app-'));
|
|
114
|
+
fs.mkdirSync(path.join(tmpDir, 'src'));
|
|
115
|
+
fs.writeFileSync(
|
|
116
|
+
path.join(tmpDir, 'package.json'),
|
|
117
|
+
JSON.stringify({name: 'app', dependencies: {}}),
|
|
118
|
+
);
|
|
119
|
+
fs.writeFileSync(path.join(tmpDir, 'tsconfig.json'), '{}\n');
|
|
20
120
|
});
|
|
21
121
|
|
|
22
122
|
afterEach(() => {
|
|
23
123
|
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
24
124
|
});
|
|
25
125
|
|
|
26
|
-
describe('themeAdd
|
|
27
|
-
it('
|
|
126
|
+
describe('themeAdd', () => {
|
|
127
|
+
it('keeps the released source-copy response and works without built exports', async () => {
|
|
128
|
+
installTheme('ocean', '@acme/themes', {missingBuilt: true});
|
|
129
|
+
|
|
130
|
+
const result = await themeAdd('ocean', {
|
|
131
|
+
cwd: tmpDir,
|
|
132
|
+
package: '@acme/themes',
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
expect(result).toMatchObject({
|
|
136
|
+
type: 'theme.add',
|
|
137
|
+
data: {
|
|
138
|
+
slug: 'ocean',
|
|
139
|
+
displayName: 'ocean',
|
|
140
|
+
maintained: true,
|
|
141
|
+
package: '@acme/themes',
|
|
142
|
+
outputDir: 'src/themes/ocean',
|
|
143
|
+
entry: 'oceanTheme.ts',
|
|
144
|
+
exportName: 'oceanTheme',
|
|
145
|
+
files: ['oceanTheme.ts', 'oceanTheme.doc.mjs'],
|
|
146
|
+
},
|
|
147
|
+
meta: {
|
|
148
|
+
deprecations: [
|
|
149
|
+
{
|
|
150
|
+
id: 'DEP-0005',
|
|
151
|
+
replacements: ['theme eject', 'theme add --import'],
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
expect(
|
|
157
|
+
fs.readFileSync(
|
|
158
|
+
path.join(tmpDir, 'src/themes/ocean/oceanTheme.ts'),
|
|
159
|
+
'utf-8',
|
|
160
|
+
),
|
|
161
|
+
).toContain('export const oceanTheme');
|
|
162
|
+
expect(
|
|
163
|
+
fs.readFileSync(
|
|
164
|
+
path.join(tmpDir, 'src/themes/ocean/oceanTheme.doc.mjs'),
|
|
165
|
+
'utf-8',
|
|
166
|
+
),
|
|
167
|
+
).toContain("name: 'ocean'");
|
|
168
|
+
expect(fs.existsSync(path.join(tmpDir, 'src/astryx-themes.ts'))).toBe(
|
|
169
|
+
false,
|
|
170
|
+
);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it('keeps every released bundled copy receipt field and file', async () => {
|
|
28
174
|
const result = await themeAdd('neutral', {cwd: tmpDir});
|
|
29
|
-
|
|
30
|
-
expect(result.data
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
'neutralTheme.ts',
|
|
37
|
-
'
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
175
|
+
|
|
176
|
+
expect(result.data).toEqual({
|
|
177
|
+
slug: 'neutral',
|
|
178
|
+
displayName: 'Neutral',
|
|
179
|
+
maintained: true,
|
|
180
|
+
package: '@astryxdesign/cli',
|
|
181
|
+
outputDir: path.join('src', 'themes', 'neutral'),
|
|
182
|
+
entry: 'neutralTheme.ts',
|
|
183
|
+
exportName: 'neutralTheme',
|
|
184
|
+
files: [
|
|
185
|
+
'neutralTheme.ts',
|
|
186
|
+
'icons.tsx',
|
|
187
|
+
'neutralPalettes.ts',
|
|
188
|
+
'neutralPalettes.generated.ts',
|
|
189
|
+
'neutralPaletteRefs.generated.ts',
|
|
190
|
+
'neutralPalettes.generated.receipt.json',
|
|
191
|
+
'palette.config.json',
|
|
192
|
+
],
|
|
193
|
+
});
|
|
44
194
|
expect(
|
|
45
|
-
fs.readdirSync(path.join(tmpDir, 'src
|
|
195
|
+
fs.readdirSync(path.join(tmpDir, 'src/themes/neutral')).sort(),
|
|
46
196
|
).toEqual([...result.data.files].sort());
|
|
47
|
-
for (const f of result.data.files) {
|
|
48
|
-
expect(
|
|
49
|
-
fs.existsSync(path.join(tmpDir, 'src', 'themes', 'neutral', f)),
|
|
50
|
-
).toBe(true);
|
|
51
|
-
}
|
|
52
197
|
});
|
|
53
198
|
|
|
54
|
-
it('
|
|
199
|
+
it('keeps every relative import required by a copied theme', async () => {
|
|
55
200
|
const result = await themeAdd('neutral', {cwd: tmpDir});
|
|
56
201
|
const outputDir = path.join(tmpDir, result.data.outputDir);
|
|
57
|
-
const relativeImports = /from\s+['"](\.\.?\/[^'"]+)['"]/
|
|
202
|
+
const relativeImports = /from\s+['"](\.\.?\/[^'"]+)['"]/gu;
|
|
58
203
|
|
|
59
204
|
for (const file of result.data.files) {
|
|
60
|
-
if (!/\.(?:ts|tsx|mjs)
|
|
205
|
+
if (!/\.(?:ts|tsx|mjs)$/u.test(file)) continue;
|
|
61
206
|
const source = fs.readFileSync(path.join(outputDir, file), 'utf-8');
|
|
62
207
|
for (const [, specifier] of source.matchAll(relativeImports)) {
|
|
63
208
|
const imported = path.resolve(outputDir, path.dirname(file), specifier);
|
|
@@ -71,7 +216,7 @@ describe('themeAdd (api/theme/add)', () => {
|
|
|
71
216
|
}
|
|
72
217
|
});
|
|
73
218
|
|
|
74
|
-
it('strips the
|
|
219
|
+
it('strips the repository copyright header from copied text', async () => {
|
|
75
220
|
const result = await themeAdd('neutral', {cwd: tmpDir});
|
|
76
221
|
const first = path.join(
|
|
77
222
|
tmpDir,
|
|
@@ -79,16 +224,16 @@ describe('themeAdd (api/theme/add)', () => {
|
|
|
79
224
|
result.data.files[0],
|
|
80
225
|
);
|
|
81
226
|
expect(fs.readFileSync(first, 'utf-8')).not.toMatch(
|
|
82
|
-
/Copyright \(c\) Meta Platforms
|
|
227
|
+
/Copyright \(c\) Meta Platforms/u,
|
|
83
228
|
);
|
|
84
229
|
});
|
|
85
230
|
|
|
86
|
-
it('
|
|
231
|
+
it('keeps case-insensitive copy lookup', async () => {
|
|
87
232
|
const result = await themeAdd('Neutral', {cwd: tmpDir});
|
|
88
233
|
expect(result.data.slug).toBe('neutral');
|
|
89
234
|
});
|
|
90
235
|
|
|
91
|
-
it('
|
|
236
|
+
it('keeps an explicit copy target path', async () => {
|
|
92
237
|
const result = await themeAdd('neutral', {
|
|
93
238
|
cwd: tmpDir,
|
|
94
239
|
targetPath: 'themes/mine',
|
|
@@ -99,49 +244,310 @@ describe('themeAdd (api/theme/add)', () => {
|
|
|
99
244
|
).toBe(true);
|
|
100
245
|
});
|
|
101
246
|
|
|
102
|
-
it('
|
|
247
|
+
it('keeps unknown-theme errors on the copy path', async () => {
|
|
103
248
|
await expect(
|
|
104
249
|
themeAdd('does-not-exist', {cwd: tmpDir}),
|
|
105
250
|
).rejects.toMatchObject({code: 'ERR_UNKNOWN_THEME'});
|
|
106
251
|
});
|
|
107
252
|
|
|
108
|
-
it('
|
|
253
|
+
it('keeps the copy overwrite guard and explicit replacement', async () => {
|
|
109
254
|
await themeAdd('neutral', {cwd: tmpDir});
|
|
110
255
|
await expect(themeAdd('neutral', {cwd: tmpDir})).rejects.toMatchObject({
|
|
111
256
|
code: 'ERR_FILE_EXISTS',
|
|
112
257
|
});
|
|
258
|
+
await expect(
|
|
259
|
+
themeAdd('neutral', {cwd: tmpDir, overwrite: true}),
|
|
260
|
+
).resolves.toMatchObject({type: 'theme.add'});
|
|
113
261
|
});
|
|
114
262
|
|
|
115
|
-
it('
|
|
116
|
-
await themeAdd('neutral', {cwd: tmpDir});
|
|
117
|
-
const result = await themeAdd('neutral', {cwd: tmpDir, overwrite: true});
|
|
118
|
-
expect(result.type).toBe('theme.add');
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it('rejects a target path that escapes cwd', async () => {
|
|
263
|
+
it('keeps copy path traversal protection', async () => {
|
|
122
264
|
await expect(
|
|
123
265
|
themeAdd('neutral', {cwd: tmpDir, targetPath: '../escape'}),
|
|
124
266
|
).rejects.toMatchObject({code: 'ERR_PATH_TRAVERSAL'});
|
|
125
267
|
});
|
|
126
268
|
|
|
127
|
-
it('
|
|
269
|
+
it('keeps stable write errors when a copy target is a file', async () => {
|
|
128
270
|
fs.writeFileSync(path.join(tmpDir, 'blocker'), 'x');
|
|
129
271
|
await expect(
|
|
130
272
|
themeAdd('neutral', {cwd: tmpDir, targetPath: 'blocker'}),
|
|
131
273
|
).rejects.toMatchObject({code: 'ERR_WRITE_FAILED'});
|
|
132
274
|
});
|
|
133
275
|
|
|
134
|
-
it('
|
|
135
|
-
|
|
276
|
+
it('keeps stable write errors when the default copy ancestor is a file', async () => {
|
|
277
|
+
fs.rmSync(path.join(tmpDir, 'src'), {recursive: true, force: true});
|
|
136
278
|
fs.writeFileSync(path.join(tmpDir, 'src'), 'x');
|
|
137
279
|
await expect(themeAdd('neutral', {cwd: tmpDir})).rejects.toMatchObject({
|
|
138
280
|
code: 'ERR_WRITE_FAILED',
|
|
139
281
|
});
|
|
140
282
|
});
|
|
141
283
|
|
|
142
|
-
it('
|
|
284
|
+
it('keeps copying into an existing empty target directory', async () => {
|
|
143
285
|
fs.mkdirSync(path.join(tmpDir, 'mydir'));
|
|
144
|
-
const
|
|
145
|
-
|
|
286
|
+
const result = await themeAdd('neutral', {
|
|
287
|
+
cwd: tmpDir,
|
|
288
|
+
targetPath: 'mydir',
|
|
289
|
+
});
|
|
290
|
+
expect(result.data.outputDir).toBe('mydir');
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
it('excludes local themes from the copying lookup', async () => {
|
|
294
|
+
installTheme();
|
|
295
|
+
const localDir = path.join(tmpDir, 'src', 'themes', 'ocean');
|
|
296
|
+
fs.mkdirSync(localDir, {recursive: true});
|
|
297
|
+
fs.writeFileSync(
|
|
298
|
+
path.join(localDir, 'oceanTheme.doc.mjs'),
|
|
299
|
+
"/** @type {import('@astryxdesign/cli/authoring').ThemeDoc} */\nexport default {type: 'theme', name: 'ocean', displayName: 'Local ocean', description: 'Local.', maintained: false};\n",
|
|
300
|
+
);
|
|
301
|
+
fs.writeFileSync(
|
|
302
|
+
path.join(localDir, 'oceanTheme.ts'),
|
|
303
|
+
'export const oceanTheme = {source: "local"};\n',
|
|
304
|
+
);
|
|
305
|
+
|
|
306
|
+
const result = await themeAdd('ocean', {
|
|
307
|
+
cwd: tmpDir,
|
|
308
|
+
targetPath: 'src/copied-ocean',
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
expect(result.type).toBe('theme.add');
|
|
312
|
+
expect(result.data.package).toBe('@acme/themes');
|
|
313
|
+
expect(
|
|
314
|
+
fs.readFileSync(
|
|
315
|
+
path.join(tmpDir, 'src', 'copied-ocean', 'oceanTheme.ts'),
|
|
316
|
+
'utf-8',
|
|
317
|
+
),
|
|
318
|
+
).not.toContain('source: "local"');
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
it.each([
|
|
322
|
+
['a target path', {targetPath: 'src/brand'}],
|
|
323
|
+
['overwrite', {overwrite: true}],
|
|
324
|
+
])('rejects --import with %s before writing', async (_label, copyOption) => {
|
|
325
|
+
installTheme();
|
|
326
|
+
|
|
327
|
+
await expect(
|
|
328
|
+
themeAdd('ocean', {
|
|
329
|
+
cwd: tmpDir,
|
|
330
|
+
import: true,
|
|
331
|
+
package: '@acme/themes',
|
|
332
|
+
...copyOption,
|
|
333
|
+
}),
|
|
334
|
+
).rejects.toMatchObject({
|
|
335
|
+
code: 'ERR_THEME_INVALID',
|
|
336
|
+
message: expect.stringContaining('cannot be combined'),
|
|
337
|
+
});
|
|
338
|
+
expect(fs.existsSync(path.join(tmpDir, 'src/astryx-themes.ts'))).toBe(
|
|
339
|
+
false,
|
|
340
|
+
);
|
|
341
|
+
expect(fs.existsSync(path.join(tmpDir, 'src/brand'))).toBe(false);
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
it('records and imports a built package theme without copying source', async () => {
|
|
345
|
+
installTheme();
|
|
346
|
+
const packageBefore = fs.readFileSync(
|
|
347
|
+
path.join(tmpDir, 'package.json'),
|
|
348
|
+
'utf-8',
|
|
349
|
+
);
|
|
350
|
+
|
|
351
|
+
const result = await themeAdd('ocean', {
|
|
352
|
+
cwd: tmpDir,
|
|
353
|
+
import: true,
|
|
354
|
+
package: '@acme/themes',
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
expect(result).toMatchObject({
|
|
358
|
+
type: 'theme.app',
|
|
359
|
+
data: {
|
|
360
|
+
default: 'ocean',
|
|
361
|
+
modulePath: 'src/astryx-themes.ts',
|
|
362
|
+
change: {action: 'add', slug: 'ocean', changed: true},
|
|
363
|
+
themes: [
|
|
364
|
+
{
|
|
365
|
+
slug: 'ocean',
|
|
366
|
+
owner: '@acme/themes',
|
|
367
|
+
module: '@acme/themes/themes/ocean',
|
|
368
|
+
stylesheet: '@acme/themes/themes/ocean.css',
|
|
369
|
+
source: 'package',
|
|
370
|
+
},
|
|
371
|
+
],
|
|
372
|
+
},
|
|
373
|
+
});
|
|
374
|
+
expect(fs.readFileSync(path.join(tmpDir, 'package.json'), 'utf-8')).toBe(
|
|
375
|
+
packageBefore,
|
|
376
|
+
);
|
|
377
|
+
expect(fs.existsSync(path.join(tmpDir, 'src/themes/ocean'))).toBe(false);
|
|
378
|
+
const module = fs.readFileSync(
|
|
379
|
+
path.join(tmpDir, 'src/astryx-themes.ts'),
|
|
380
|
+
'utf-8',
|
|
381
|
+
);
|
|
382
|
+
expect(module).toContain(THEME_MODULE_MARKER);
|
|
383
|
+
expect(module).toContain('from "@acme/themes/themes/ocean"');
|
|
384
|
+
expect(module).toContain('import "@acme/themes/themes/ocean.css"');
|
|
385
|
+
expect(parseThemeModuleRecord(module)).toEqual({
|
|
386
|
+
themes: {ocean: '@acme/themes'},
|
|
387
|
+
defaultSlug: 'ocean',
|
|
388
|
+
});
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
it('keeps the released CLI selector while recording the import package', async () => {
|
|
392
|
+
installBuiltThemePackage('neutral');
|
|
393
|
+
const result = await themeAdd('neutral', {
|
|
394
|
+
cwd: tmpDir,
|
|
395
|
+
import: true,
|
|
396
|
+
package: '@astryxdesign/cli',
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
expect(result.data.themes).toEqual([
|
|
400
|
+
expect.objectContaining({
|
|
401
|
+
slug: 'neutral',
|
|
402
|
+
owner: '@astryxdesign/theme-neutral',
|
|
403
|
+
module: '@astryxdesign/theme-neutral/built',
|
|
404
|
+
stylesheet: '@astryxdesign/theme-neutral/theme.css',
|
|
405
|
+
source: 'bundled',
|
|
406
|
+
}),
|
|
407
|
+
]);
|
|
408
|
+
expect(
|
|
409
|
+
parseThemeModuleRecord(
|
|
410
|
+
fs.readFileSync(path.join(tmpDir, 'src/astryx-themes.ts'), 'utf-8'),
|
|
411
|
+
),
|
|
412
|
+
).toEqual({
|
|
413
|
+
themes: {neutral: '@astryxdesign/theme-neutral'},
|
|
414
|
+
defaultSlug: 'neutral',
|
|
415
|
+
});
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
it('regenerates an already-added theme and reports no state change', async () => {
|
|
419
|
+
installTheme();
|
|
420
|
+
await themeAdd('ocean', {
|
|
421
|
+
cwd: tmpDir,
|
|
422
|
+
import: true,
|
|
423
|
+
package: '@acme/themes',
|
|
424
|
+
});
|
|
425
|
+
const moduleFile = path.join(tmpDir, 'src/astryx-themes.ts');
|
|
426
|
+
fs.appendFileSync(moduleFile, '\n// hand edit\n');
|
|
427
|
+
|
|
428
|
+
const result = await themeAdd('ocean', {
|
|
429
|
+
cwd: tmpDir,
|
|
430
|
+
import: true,
|
|
431
|
+
package: '@acme/themes',
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
expect(result.data.change.changed).toBe(false);
|
|
435
|
+
expect(fs.readFileSync(moduleFile, 'utf-8')).not.toContain('hand edit');
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
it('fails before writing when the selected module path is authored', async () => {
|
|
439
|
+
installTheme();
|
|
440
|
+
const moduleFile = path.join(tmpDir, 'src/astryx-themes.ts');
|
|
441
|
+
fs.writeFileSync(moduleFile, 'export const mine = true;\n');
|
|
442
|
+
|
|
443
|
+
await expect(
|
|
444
|
+
themeAdd('ocean', {
|
|
445
|
+
cwd: tmpDir,
|
|
446
|
+
import: true,
|
|
447
|
+
package: '@acme/themes',
|
|
448
|
+
}),
|
|
449
|
+
).rejects.toMatchObject({code: 'ERR_FILE_EXISTS'});
|
|
450
|
+
expect(fs.readFileSync(moduleFile, 'utf-8')).toBe(
|
|
451
|
+
'export const mine = true;\n',
|
|
452
|
+
);
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
it('uses a JavaScript module at the project root when there is no src', async () => {
|
|
456
|
+
fs.rmSync(path.join(tmpDir, 'src'), {recursive: true});
|
|
457
|
+
fs.rmSync(path.join(tmpDir, 'tsconfig.json'));
|
|
458
|
+
installTheme();
|
|
459
|
+
|
|
460
|
+
const result = await themeAdd('ocean', {
|
|
461
|
+
cwd: tmpDir,
|
|
462
|
+
import: true,
|
|
463
|
+
package: '@acme/themes',
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
expect(result.data.modulePath).toBe('astryx-themes.js');
|
|
467
|
+
expect(fs.existsSync(path.join(tmpDir, 'astryx-themes.js'))).toBe(true);
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
it('prefers a built local theme and switches the recorded owner', async () => {
|
|
471
|
+
installTheme();
|
|
472
|
+
await themeAdd('ocean', {
|
|
473
|
+
cwd: tmpDir,
|
|
474
|
+
import: true,
|
|
475
|
+
package: '@acme/themes',
|
|
476
|
+
});
|
|
477
|
+
await themeEject('ocean', {cwd: tmpDir, package: '@acme/themes'});
|
|
478
|
+
const localDir = path.join(tmpDir, 'src', 'themes', 'ocean');
|
|
479
|
+
fs.writeFileSync(
|
|
480
|
+
path.join(localDir, 'ocean.js'),
|
|
481
|
+
'export const oceanTheme = {name: "local-ocean", __built: true};\n',
|
|
482
|
+
);
|
|
483
|
+
fs.writeFileSync(path.join(localDir, 'ocean.css'), '/* local css */\n');
|
|
484
|
+
|
|
485
|
+
const result = await themeAdd('ocean', {cwd: tmpDir, import: true});
|
|
486
|
+
|
|
487
|
+
expect(result).toMatchObject({
|
|
488
|
+
type: 'theme.app',
|
|
489
|
+
data: {
|
|
490
|
+
change: {action: 'add', slug: 'ocean', changed: true},
|
|
491
|
+
themes: [
|
|
492
|
+
{
|
|
493
|
+
slug: 'ocean',
|
|
494
|
+
owner: './src/themes',
|
|
495
|
+
module: './themes/ocean/ocean.js',
|
|
496
|
+
stylesheet: './themes/ocean/ocean.css',
|
|
497
|
+
source: 'local',
|
|
498
|
+
},
|
|
499
|
+
],
|
|
500
|
+
},
|
|
501
|
+
});
|
|
502
|
+
expect(
|
|
503
|
+
parseThemeModuleRecord(
|
|
504
|
+
fs.readFileSync(path.join(tmpDir, 'src/astryx-themes.ts'), 'utf-8'),
|
|
505
|
+
),
|
|
506
|
+
).toEqual({
|
|
507
|
+
themes: {ocean: './src/themes'},
|
|
508
|
+
defaultSlug: 'ocean',
|
|
509
|
+
});
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
it('ignores an unmigrated local copy without changing it', async () => {
|
|
513
|
+
const copyDir = path.join(tmpDir, 'src', 'themes', 'ocean');
|
|
514
|
+
fs.mkdirSync(copyDir, {recursive: true});
|
|
515
|
+
const source = 'export const oceanTheme = {name: "copied"};\n';
|
|
516
|
+
fs.writeFileSync(path.join(copyDir, 'oceanTheme.ts'), source);
|
|
517
|
+
installTheme();
|
|
518
|
+
|
|
519
|
+
const result = await themeAdd('ocean', {
|
|
520
|
+
cwd: tmpDir,
|
|
521
|
+
import: true,
|
|
522
|
+
package: '@acme/themes',
|
|
523
|
+
});
|
|
524
|
+
|
|
525
|
+
expect(result.data.themes).toEqual([
|
|
526
|
+
expect.objectContaining({slug: 'ocean', owner: '@acme/themes'}),
|
|
527
|
+
]);
|
|
528
|
+
expect(fs.readFileSync(path.join(copyDir, 'oceanTheme.ts'), 'utf-8')).toBe(
|
|
529
|
+
source,
|
|
530
|
+
);
|
|
531
|
+
expect(fs.existsSync(path.join(copyDir, 'oceanTheme.doc.mjs'))).toBe(false);
|
|
532
|
+
});
|
|
533
|
+
|
|
534
|
+
it('never falls back to package source when built exports are missing', async () => {
|
|
535
|
+
installTheme('ocean', '@acme/themes', {missingBuilt: true});
|
|
536
|
+
|
|
537
|
+
await expect(
|
|
538
|
+
themeAdd('ocean', {
|
|
539
|
+
cwd: tmpDir,
|
|
540
|
+
import: true,
|
|
541
|
+
package: '@acme/themes',
|
|
542
|
+
}),
|
|
543
|
+
).rejects.toMatchObject({
|
|
544
|
+
code: 'ERR_THEME_INVALID',
|
|
545
|
+
message: expect.stringMatching(
|
|
546
|
+
/no resolvable built module and stylesheet/i,
|
|
547
|
+
),
|
|
548
|
+
});
|
|
549
|
+
expect(fs.existsSync(path.join(tmpDir, 'src/astryx-themes.ts'))).toBe(
|
|
550
|
+
false,
|
|
551
|
+
);
|
|
146
552
|
});
|
|
147
553
|
});
|