@astryxdesign/cli 0.6.5 → 0.6.6-canary.e1dda17
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 +43 -0
- package/api/doctor/_adapter.mjs +142 -0
- package/api/doctor/doctor.d.mts +0 -10
- package/api/doctor/doctor.doc.mjs +1 -3
- package/api/doctor/doctor.mjs +6 -123
- package/api/doctor/theme-checks.d.mts +12 -0
- package/api/doctor/theme-checks.mjs +1117 -0
- package/api/doctor/theme-checks.test.mjs +526 -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.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 +97 -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 +10 -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
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/** @file Fault-injection coverage for all ten app-theme doctor checks. */
|
|
4
|
+
|
|
5
|
+
import {afterEach, describe, expect, it} from 'vitest';
|
|
6
|
+
import * as fs from 'node:fs';
|
|
7
|
+
import * as path from 'node:path';
|
|
8
|
+
import {spawnSync} from 'node:child_process';
|
|
9
|
+
import {checkAppThemes} from './theme-checks.mjs';
|
|
10
|
+
import {themeAdd} from '../theme/add/add.mjs';
|
|
11
|
+
import {themeEject} from '../theme/eject/eject.mjs';
|
|
12
|
+
import {themeBuild} from '../theme/build/build.mjs';
|
|
13
|
+
import {parseThemeModuleRecord} from '../../foundation/config/theme-state.mjs';
|
|
14
|
+
|
|
15
|
+
/** @type {string[]} */
|
|
16
|
+
const dirs = [];
|
|
17
|
+
const REPO_ROOT = path.resolve(import.meta.dirname, '../../../..');
|
|
18
|
+
|
|
19
|
+
/** @param {string} file @param {string} content */
|
|
20
|
+
function write(file, content) {
|
|
21
|
+
fs.mkdirSync(path.dirname(file), {recursive: true});
|
|
22
|
+
fs.writeFileSync(file, content);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @param {Array<{slug: string, css?: string, fontFamily?: string, fontCss?: string}>} themeSpecs
|
|
27
|
+
* @param {{peerRange?: string, importModule?: boolean}} [options]
|
|
28
|
+
*/
|
|
29
|
+
async function fixture(themeSpecs = [{slug: 'ocean'}], options = {}) {
|
|
30
|
+
const dir = fs.mkdtempSync(
|
|
31
|
+
path.join(process.cwd(), '.astryx-doctor-themes-'),
|
|
32
|
+
);
|
|
33
|
+
dirs.push(dir);
|
|
34
|
+
fs.mkdirSync(path.join(dir, 'src'), {recursive: true});
|
|
35
|
+
write(path.join(dir, 'tsconfig.json'), '{}\n');
|
|
36
|
+
write(
|
|
37
|
+
path.join(dir, 'package.json'),
|
|
38
|
+
JSON.stringify({
|
|
39
|
+
name: 'doctor-app',
|
|
40
|
+
private: true,
|
|
41
|
+
dependencies: {
|
|
42
|
+
'@acme/themes': '1.0.0',
|
|
43
|
+
'@astryxdesign/core': '1.0.0',
|
|
44
|
+
},
|
|
45
|
+
}),
|
|
46
|
+
);
|
|
47
|
+
write(
|
|
48
|
+
path.join(dir, 'node_modules/@astryxdesign/core/package.json'),
|
|
49
|
+
JSON.stringify({name: '@astryxdesign/core', version: '1.0.0'}),
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const packageDir = path.join(dir, 'node_modules/@acme/themes');
|
|
53
|
+
const exportsMap = {};
|
|
54
|
+
for (const spec of themeSpecs) {
|
|
55
|
+
exportsMap[`./themes/${spec.slug}`] = `./dist/${spec.slug}.js`;
|
|
56
|
+
exportsMap[`./themes/${spec.slug}.css`] = `./dist/${spec.slug}.css`;
|
|
57
|
+
if (spec.fontCss != null) {
|
|
58
|
+
exportsMap[`./themes/${spec.slug}.fonts.css`] =
|
|
59
|
+
`./dist/${spec.slug}.fonts.css`;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
write(
|
|
63
|
+
path.join(packageDir, 'package.json'),
|
|
64
|
+
JSON.stringify({
|
|
65
|
+
name: '@acme/themes',
|
|
66
|
+
version: '1.0.0',
|
|
67
|
+
type: 'module',
|
|
68
|
+
peerDependencies: {
|
|
69
|
+
'@astryxdesign/core': options.peerRange ?? '^1.0.0',
|
|
70
|
+
},
|
|
71
|
+
exports: exportsMap,
|
|
72
|
+
}),
|
|
73
|
+
);
|
|
74
|
+
write(
|
|
75
|
+
path.join(packageDir, 'astryx.integration.mjs'),
|
|
76
|
+
"export default {themes: './themes'};\n",
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
for (const spec of themeSpecs) {
|
|
80
|
+
const exportName = `${spec.slug}Theme`;
|
|
81
|
+
const sourceDir = path.join(packageDir, 'themes', spec.slug);
|
|
82
|
+
const fontProperty = spec.fontFamily
|
|
83
|
+
? `, fontFamily: ${JSON.stringify(spec.fontFamily)}`
|
|
84
|
+
: '';
|
|
85
|
+
write(
|
|
86
|
+
path.join(sourceDir, `${exportName}.doc.mjs`),
|
|
87
|
+
`/** @type {import('@astryxdesign/cli/authoring').ThemeDoc} */\nexport default {type: 'theme', name: '${spec.slug}', displayName: '${spec.slug}', description: '${spec.slug} theme.', maintained: true};\n`,
|
|
88
|
+
);
|
|
89
|
+
write(
|
|
90
|
+
path.join(sourceDir, `${exportName}.ts`),
|
|
91
|
+
`export const ${exportName} = {name: '${spec.slug}', tokens: {}${fontProperty}};\n`,
|
|
92
|
+
);
|
|
93
|
+
write(
|
|
94
|
+
path.join(packageDir, `dist/${spec.slug}.js`),
|
|
95
|
+
`export const ${exportName} = {name: '${spec.slug}', tokens: {}${fontProperty}};\n`,
|
|
96
|
+
);
|
|
97
|
+
write(
|
|
98
|
+
path.join(packageDir, `dist/${spec.slug}.css`),
|
|
99
|
+
spec.css ??
|
|
100
|
+
`[data-astryx-theme="${spec.slug}"] { --color-text: black; }\n`,
|
|
101
|
+
);
|
|
102
|
+
if (spec.fontCss != null) {
|
|
103
|
+
write(path.join(packageDir, `dist/${spec.slug}.fonts.css`), spec.fontCss);
|
|
104
|
+
}
|
|
105
|
+
await themeAdd(spec.slug, {
|
|
106
|
+
cwd: dir,
|
|
107
|
+
import: true,
|
|
108
|
+
package: '@acme/themes',
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (options.importModule !== false) {
|
|
113
|
+
write(
|
|
114
|
+
path.join(dir, 'src/index.tsx'),
|
|
115
|
+
"import {themes, defaultThemeSlug} from './astryx-themes';\nvoid themes[defaultThemeSlug];\n",
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
return {dir, packageDir, moduleFile: path.join(dir, 'src/astryx-themes.ts')};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** @param {Awaited<ReturnType<typeof checkAppThemes>>} checks @param {string} id */
|
|
122
|
+
function check(checks, id) {
|
|
123
|
+
const result = checks.find(item => item.id === id);
|
|
124
|
+
if (!result) throw new Error(`Missing doctor check ${id}`);
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** @param {string} dir */
|
|
129
|
+
function runDoctor(dir) {
|
|
130
|
+
return spawnSync(
|
|
131
|
+
process.execPath,
|
|
132
|
+
[path.join(REPO_ROOT, 'packages/cli/clients/cli/bin/astryx.mjs'), 'doctor'],
|
|
133
|
+
{cwd: dir, encoding: 'utf-8', timeout: 30_000},
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
afterEach(() => {
|
|
138
|
+
while (dirs.length > 0) {
|
|
139
|
+
fs.rmSync(dirs.pop(), {recursive: true, force: true});
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
describe('app-theme doctor checks', () => {
|
|
144
|
+
it('returns ten positive passes for a healthy package theme', async () => {
|
|
145
|
+
const {dir} = await fixture();
|
|
146
|
+
const checks = await checkAppThemes(dir);
|
|
147
|
+
|
|
148
|
+
expect(checks.map(item => item.id)).toEqual([
|
|
149
|
+
'theme-owners',
|
|
150
|
+
'theme-module',
|
|
151
|
+
'theme-module-import',
|
|
152
|
+
'theme-stylesheet-imports',
|
|
153
|
+
'theme-local-builds',
|
|
154
|
+
'theme-private-variables',
|
|
155
|
+
'theme-core-peers',
|
|
156
|
+
'theme-default',
|
|
157
|
+
'theme-fonts',
|
|
158
|
+
'theme-global-rules',
|
|
159
|
+
]);
|
|
160
|
+
expect(checks.map(item => item.status)).toEqual(Array(10).fill('pass'));
|
|
161
|
+
expect(check(checks, 'theme-owners').message).toContain(
|
|
162
|
+
'every built module loads',
|
|
163
|
+
);
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it('fails theme-owners when a recorded module has a missing dependency', async () => {
|
|
167
|
+
const {dir, packageDir} = await fixture();
|
|
168
|
+
write(
|
|
169
|
+
path.join(packageDir, 'dist/ocean.js'),
|
|
170
|
+
`import '@acme/definitely-missing-dep';\nexport const oceanTheme = {name: 'ocean', tokens: {}};\n`,
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
const result = check(await checkAppThemes(dir), 'theme-owners');
|
|
174
|
+
|
|
175
|
+
expect(result).toMatchObject({id: 'theme-owners', status: 'fail'});
|
|
176
|
+
expect(result.message).toContain('Theme "ocean"');
|
|
177
|
+
expect(result.message).toContain('@acme/definitely-missing-dep');
|
|
178
|
+
expect(result.message).not.toMatch(/\n\s+at /u);
|
|
179
|
+
const cli = runDoctor(dir);
|
|
180
|
+
expect(cli.status).toBe(1);
|
|
181
|
+
expect(cli.stdout).not.toContain('No failures');
|
|
182
|
+
expect(cli.stdout).toContain('Theme owners and built imports');
|
|
183
|
+
expect(cli.stdout).toContain('@acme/definitely-missing-dep');
|
|
184
|
+
expect(cli.stderr).not.toMatch(/\n\s+at /u);
|
|
185
|
+
}, 30_000);
|
|
186
|
+
|
|
187
|
+
it('fails theme-owners when a recorded module is malformed', async () => {
|
|
188
|
+
const {dir, packageDir} = await fixture();
|
|
189
|
+
write(
|
|
190
|
+
path.join(packageDir, 'dist/ocean.js'),
|
|
191
|
+
'export const oceanTheme = ;\n',
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
const result = check(await checkAppThemes(dir), 'theme-owners');
|
|
195
|
+
|
|
196
|
+
expect(result).toMatchObject({id: 'theme-owners', status: 'fail'});
|
|
197
|
+
expect(result.message).toContain('Theme "ocean"');
|
|
198
|
+
expect(result.message).toContain('does not export "oceanTheme"');
|
|
199
|
+
expect(result.message).not.toMatch(/\n\s+at /u);
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it('fails theme-owners for an ambiguous multi-theme record', async () => {
|
|
203
|
+
const {dir, packageDir} = await fixture([{slug: 'ocean'}, {slug: 'reef'}]);
|
|
204
|
+
const packageFile = path.join(packageDir, 'package.json');
|
|
205
|
+
const pkg = JSON.parse(fs.readFileSync(packageFile, 'utf-8'));
|
|
206
|
+
delete pkg.exports['./themes/ocean'];
|
|
207
|
+
write(packageFile, JSON.stringify(pkg));
|
|
208
|
+
|
|
209
|
+
const result = check(await checkAppThemes(dir), 'theme-owners');
|
|
210
|
+
|
|
211
|
+
expect(result).toMatchObject({id: 'theme-owners', status: 'fail'});
|
|
212
|
+
expect(result.message).toContain('ocean');
|
|
213
|
+
expect(result.message).not.toMatch(/\n\s+at /u);
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
it.each([
|
|
217
|
+
'theme-local-builds',
|
|
218
|
+
'theme-private-variables',
|
|
219
|
+
'theme-core-peers',
|
|
220
|
+
'theme-fonts',
|
|
221
|
+
'theme-global-rules',
|
|
222
|
+
])('%s cannot pass when theme discovery throws', async id => {
|
|
223
|
+
const {dir} = await fixture();
|
|
224
|
+
write(
|
|
225
|
+
path.join(dir, 'astryx.config.mjs'),
|
|
226
|
+
"throw new Error('fixture discovery failure');\n",
|
|
227
|
+
);
|
|
228
|
+
|
|
229
|
+
expect(check(await checkAppThemes(dir), id)).toMatchObject({
|
|
230
|
+
status: 'info',
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
it('lets the static default check pass when discovery throws', async () => {
|
|
235
|
+
const {dir} = await fixture();
|
|
236
|
+
write(
|
|
237
|
+
path.join(dir, 'astryx.config.mjs'),
|
|
238
|
+
"throw new Error('fixture discovery failure');\n",
|
|
239
|
+
);
|
|
240
|
+
|
|
241
|
+
expect(check(await checkAppThemes(dir), 'theme-default')).toMatchObject({
|
|
242
|
+
status: 'pass',
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
it('check 1 fails when a recorded built stylesheet no longer resolves', async () => {
|
|
247
|
+
const {dir, packageDir} = await fixture();
|
|
248
|
+
fs.rmSync(path.join(packageDir, 'dist/ocean.css'));
|
|
249
|
+
|
|
250
|
+
expect(check(await checkAppThemes(dir), 'theme-owners')).toMatchObject({
|
|
251
|
+
status: 'fail',
|
|
252
|
+
fix: expect.stringContaining('theme add ocean --import'),
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
it('check 2 fails when the generated module is hand-edited', async () => {
|
|
257
|
+
const {dir, moduleFile} = await fixture();
|
|
258
|
+
fs.appendFileSync(moduleFile, '// hand edit\n');
|
|
259
|
+
|
|
260
|
+
expect(check(await checkAppThemes(dir), 'theme-module')).toMatchObject({
|
|
261
|
+
status: 'fail',
|
|
262
|
+
fix: expect.stringContaining('theme use ocean'),
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
it('check 3 warns when no project source imports the generated module', async () => {
|
|
267
|
+
const {dir} = await fixture([{slug: 'ocean'}], {importModule: false});
|
|
268
|
+
|
|
269
|
+
expect(
|
|
270
|
+
check(await checkAppThemes(dir), 'theme-module-import'),
|
|
271
|
+
).toMatchObject({
|
|
272
|
+
status: 'warn',
|
|
273
|
+
fix: expect.stringContaining('themes[defaultThemeSlug]'),
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
it('check 4 fails when a built module import loses its stylesheet pair', async () => {
|
|
278
|
+
const {dir, moduleFile} = await fixture();
|
|
279
|
+
const source = fs
|
|
280
|
+
.readFileSync(moduleFile, 'utf-8')
|
|
281
|
+
.replace('import "@acme/themes/themes/ocean.css";\n', '');
|
|
282
|
+
fs.writeFileSync(moduleFile, source);
|
|
283
|
+
|
|
284
|
+
expect(
|
|
285
|
+
check(await checkAppThemes(dir), 'theme-stylesheet-imports'),
|
|
286
|
+
).toMatchObject({
|
|
287
|
+
status: 'fail',
|
|
288
|
+
fix: expect.stringContaining('theme use ocean'),
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
it('check 5 fails when an added local theme cannot reproduce its outputs', async () => {
|
|
293
|
+
const {dir} = await fixture();
|
|
294
|
+
await themeEject('ocean', {cwd: dir, package: '@acme/themes'});
|
|
295
|
+
const localDir = path.join(dir, 'src/themes/ocean');
|
|
296
|
+
const sourceFile = path.join(localDir, 'oceanTheme.ts');
|
|
297
|
+
fs.writeFileSync(
|
|
298
|
+
sourceFile,
|
|
299
|
+
"const oceanTheme = {name: 'ocean', tokens: {'--color-bg': '#000'}};\nexport {oceanTheme};\nexport default oceanTheme;\n",
|
|
300
|
+
);
|
|
301
|
+
await themeBuild(sourceFile, {}, {cwd: dir});
|
|
302
|
+
await themeAdd('ocean', {cwd: dir, import: true});
|
|
303
|
+
expect(
|
|
304
|
+
parseThemeModuleRecord(
|
|
305
|
+
fs.readFileSync(path.join(dir, 'src/astryx-themes.ts'), 'utf-8'),
|
|
306
|
+
),
|
|
307
|
+
).toMatchObject({themes: {ocean: './src/themes'}});
|
|
308
|
+
fs.appendFileSync(path.join(localDir, 'ocean.css'), '\n.injected {}\n');
|
|
309
|
+
|
|
310
|
+
expect(
|
|
311
|
+
check(await checkAppThemes(dir), 'theme-local-builds'),
|
|
312
|
+
).toMatchObject({
|
|
313
|
+
status: 'fail',
|
|
314
|
+
fix: expect.stringContaining('theme build'),
|
|
315
|
+
});
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
it('check 6 ignores private variables generated from guaranteed component properties', async () => {
|
|
319
|
+
const {dir, packageDir} = await fixture([
|
|
320
|
+
{
|
|
321
|
+
slug: 'ocean',
|
|
322
|
+
css: '[data-astryx-theme="ocean"] { --_button-radius: var(--radius-full); }\n',
|
|
323
|
+
},
|
|
324
|
+
]);
|
|
325
|
+
write(
|
|
326
|
+
path.join(packageDir, 'themes/ocean/oceanTheme.ts'),
|
|
327
|
+
"export const oceanTheme = {name: 'ocean', tokens: {}, components: {button: {base: {borderRadius: 'var(--radius-full)'}}}};\n",
|
|
328
|
+
);
|
|
329
|
+
|
|
330
|
+
expect(
|
|
331
|
+
check(await checkAppThemes(dir), 'theme-private-variables'),
|
|
332
|
+
).toMatchObject({status: 'pass'});
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
it('check 6 fails on a private --_* key in theme input', async () => {
|
|
336
|
+
const {dir, packageDir} = await fixture();
|
|
337
|
+
write(
|
|
338
|
+
path.join(packageDir, 'themes/ocean/oceanTheme.ts'),
|
|
339
|
+
"export const oceanTheme = {name: 'ocean', tokens: {}, components: {button: {base: {'--_button-radius': '2px'}}}};\n",
|
|
340
|
+
);
|
|
341
|
+
|
|
342
|
+
const result = check(await checkAppThemes(dir), 'theme-private-variables');
|
|
343
|
+
expect(result).toMatchObject({status: 'fail'});
|
|
344
|
+
expect(result.message).toContain('--_button-radius');
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
it('check 7 fails when a theme peer range rejects installed Core', async () => {
|
|
348
|
+
const {dir} = await fixture([{slug: 'ocean'}], {peerRange: '^9.0.0'});
|
|
349
|
+
|
|
350
|
+
const result = check(await checkAppThemes(dir), 'theme-core-peers');
|
|
351
|
+
expect(result).toMatchObject({
|
|
352
|
+
status: 'fail',
|
|
353
|
+
fix: expect.stringContaining('npm install'),
|
|
354
|
+
});
|
|
355
|
+
expect(result.message).toContain('^9.0.0');
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
it('check 8 fails when the static default is not an added slug', async () => {
|
|
359
|
+
const {dir, moduleFile} = await fixture();
|
|
360
|
+
const source = fs
|
|
361
|
+
.readFileSync(moduleFile, 'utf-8')
|
|
362
|
+
.replace('"defaultThemeSlug":"ocean"', '"defaultThemeSlug":"ghost"');
|
|
363
|
+
fs.writeFileSync(moduleFile, source);
|
|
364
|
+
|
|
365
|
+
expect(check(await checkAppThemes(dir), 'theme-default')).toMatchObject({
|
|
366
|
+
status: 'fail',
|
|
367
|
+
fix: expect.stringContaining('theme use ocean'),
|
|
368
|
+
});
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
it('check 9 warns when a named font has no stylesheet loader', async () => {
|
|
372
|
+
const {dir} = await fixture([{slug: 'ocean', fontFamily: 'Ocean Sans'}]);
|
|
373
|
+
|
|
374
|
+
const checks = await checkAppThemes(dir);
|
|
375
|
+
const result = check(checks, 'theme-fonts');
|
|
376
|
+
expect(result).toMatchObject({
|
|
377
|
+
status: 'warn',
|
|
378
|
+
fix: expect.stringContaining('fonts.css'),
|
|
379
|
+
});
|
|
380
|
+
expect(result.message).toContain('Ocean Sans');
|
|
381
|
+
expect(checks.some(item => item.status === 'fail')).toBe(false);
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
it('check 9 warns when a local theme has no font stylesheet', async () => {
|
|
385
|
+
const {dir} = await fixture([{slug: 'ocean', fontFamily: 'Ocean Sans'}]);
|
|
386
|
+
await themeEject('ocean', {cwd: dir, package: '@acme/themes'});
|
|
387
|
+
const sourceFile = path.join(dir, 'src/themes/ocean/oceanTheme.ts');
|
|
388
|
+
await themeBuild(sourceFile, {}, {cwd: dir});
|
|
389
|
+
await themeAdd('ocean', {cwd: dir, import: true});
|
|
390
|
+
|
|
391
|
+
const checks = await checkAppThemes(dir);
|
|
392
|
+
expect(check(checks, 'theme-fonts')).toMatchObject({
|
|
393
|
+
status: 'warn',
|
|
394
|
+
message: expect.stringContaining('Ocean Sans'),
|
|
395
|
+
fix: expect.stringContaining('<slug>.fonts.css'),
|
|
396
|
+
});
|
|
397
|
+
expect(checks.some(item => item.status === 'fail')).toBe(false);
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
it('check 9 passes when a local @font-face proves the named family', async () => {
|
|
401
|
+
const {dir} = await fixture([
|
|
402
|
+
{
|
|
403
|
+
slug: 'ocean',
|
|
404
|
+
fontFamily: 'Ocean Sans',
|
|
405
|
+
fontCss:
|
|
406
|
+
'@font-face { font-family: "Ocean Sans"; src: url("./ocean.woff2"); }\n',
|
|
407
|
+
},
|
|
408
|
+
]);
|
|
409
|
+
|
|
410
|
+
expect(check(await checkAppThemes(dir), 'theme-fonts')).toMatchObject({
|
|
411
|
+
status: 'pass',
|
|
412
|
+
});
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
it('check 9 warns when an external import cannot prove the named family', async () => {
|
|
416
|
+
const {dir} = await fixture([
|
|
417
|
+
{
|
|
418
|
+
slug: 'ocean',
|
|
419
|
+
fontFamily: 'Ocean Sans',
|
|
420
|
+
fontCss: '@import url("https://fonts.example/ocean.css");\n',
|
|
421
|
+
},
|
|
422
|
+
]);
|
|
423
|
+
|
|
424
|
+
expect(check(await checkAppThemes(dir), 'theme-fonts')).toMatchObject({
|
|
425
|
+
status: 'warn',
|
|
426
|
+
message: expect.stringContaining('Ocean Sans'),
|
|
427
|
+
});
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
it('check 10 fails on conflicting unscoped rules across added themes', async () => {
|
|
431
|
+
const {dir} = await fixture([
|
|
432
|
+
{slug: 'ocean', css: 'body { color: blue; }\n'},
|
|
433
|
+
{slug: 'sunset', css: 'body { color: red; }\n'},
|
|
434
|
+
]);
|
|
435
|
+
|
|
436
|
+
const result = check(await checkAppThemes(dir), 'theme-global-rules');
|
|
437
|
+
expect(result).toMatchObject({status: 'fail'});
|
|
438
|
+
expect(result.message).toContain('body');
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
it('reports one information check when the CLI manages no themes', async () => {
|
|
442
|
+
const dir = fs.mkdtempSync(
|
|
443
|
+
path.join(process.cwd(), '.astryx-doctor-empty-'),
|
|
444
|
+
);
|
|
445
|
+
dirs.push(dir);
|
|
446
|
+
write(path.join(dir, 'package.json'), '{"name":"empty"}\n');
|
|
447
|
+
|
|
448
|
+
const checks = await checkAppThemes(dir);
|
|
449
|
+
expect(checks).toEqual([
|
|
450
|
+
expect.objectContaining({
|
|
451
|
+
id: 'theme-management',
|
|
452
|
+
status: 'info',
|
|
453
|
+
message: expect.stringContaining('manages no themes'),
|
|
454
|
+
fix: expect.stringContaining('theme add <slug> --import'),
|
|
455
|
+
}),
|
|
456
|
+
]);
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
it('reads astryx.theme from the app package when node_modules is hoisted to a workspace root', async () => {
|
|
460
|
+
const root = fs.mkdtempSync(
|
|
461
|
+
path.join(process.cwd(), '.astryx-doctor-monorepo-'),
|
|
462
|
+
);
|
|
463
|
+
dirs.push(root);
|
|
464
|
+
write(
|
|
465
|
+
path.join(root, 'package.json'),
|
|
466
|
+
JSON.stringify({name: 'mono', private: true, workspaces: ['packages/*']}),
|
|
467
|
+
);
|
|
468
|
+
for (const name of ['@astryxdesign/core', '@astryxdesign/theme-neutral']) {
|
|
469
|
+
write(
|
|
470
|
+
path.join(root, 'node_modules', name, 'package.json'),
|
|
471
|
+
JSON.stringify({name, version: '1.0.0'}),
|
|
472
|
+
);
|
|
473
|
+
}
|
|
474
|
+
const app = path.join(root, 'packages/app');
|
|
475
|
+
write(
|
|
476
|
+
path.join(app, 'package.json'),
|
|
477
|
+
JSON.stringify({
|
|
478
|
+
name: 'app',
|
|
479
|
+
private: true,
|
|
480
|
+
dependencies: {
|
|
481
|
+
'@astryxdesign/core': '1.0.0',
|
|
482
|
+
'@astryxdesign/theme-neutral': '1.0.0',
|
|
483
|
+
},
|
|
484
|
+
astryx: {theme: '@astryxdesign/theme-neutral'},
|
|
485
|
+
}),
|
|
486
|
+
);
|
|
487
|
+
|
|
488
|
+
expect(await checkAppThemes(app)).toEqual([
|
|
489
|
+
expect.objectContaining({
|
|
490
|
+
id: 'theme-management',
|
|
491
|
+
status: 'info',
|
|
492
|
+
message: expect.stringContaining(
|
|
493
|
+
'astryx.theme value "@astryxdesign/theme-neutral" remains active',
|
|
494
|
+
),
|
|
495
|
+
}),
|
|
496
|
+
]);
|
|
497
|
+
const doctor = runDoctor(app);
|
|
498
|
+
expect(doctor.stdout).toContain('remains active');
|
|
499
|
+
expect(doctor.stdout).not.toContain('no theme appears wired');
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
it('names an unmigrated copy without failing a project that has no module', async () => {
|
|
503
|
+
const dir = fs.mkdtempSync(
|
|
504
|
+
path.join(process.cwd(), '.astryx-doctor-unmigrated-'),
|
|
505
|
+
);
|
|
506
|
+
dirs.push(dir);
|
|
507
|
+
write(path.join(dir, 'package.json'), '{"name":"empty"}\n');
|
|
508
|
+
write(
|
|
509
|
+
path.join(dir, 'src/themes/ocean/oceanTheme.ts'),
|
|
510
|
+
'export const oceanTheme = {};\n',
|
|
511
|
+
);
|
|
512
|
+
|
|
513
|
+
const checks = await checkAppThemes(dir);
|
|
514
|
+
|
|
515
|
+
expect(checks).toHaveLength(2);
|
|
516
|
+
expect(checks.some(item => item.status === 'fail')).toBe(false);
|
|
517
|
+
expect(checks).toContainEqual(
|
|
518
|
+
expect.objectContaining({
|
|
519
|
+
id: 'theme-unmigrated-copies',
|
|
520
|
+
status: 'warn',
|
|
521
|
+
message: expect.stringContaining('src/themes/ocean'),
|
|
522
|
+
fix: expect.stringContaining('upgrade --from 0.6.4 --path . --apply'),
|
|
523
|
+
}),
|
|
524
|
+
);
|
|
525
|
+
});
|
|
526
|
+
});
|
package/api/error.d.mts
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
// @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* The error for a write that failed on the filesystem: no permission, a
|
|
6
|
+
* read-only mount, a full disk, a path component that is not a directory.
|
|
7
|
+
*
|
|
8
|
+
* A raw Node errno error reached the envelope as
|
|
9
|
+
* `{"error": "EACCES: permission denied, open '/home/you/p/readonly/x.tsx'",
|
|
10
|
+
* "code": "ERR_UNKNOWN"}` — the wrong code (ERR_WRITE_FAILED is in the frozen
|
|
11
|
+
* registry for exactly this) and an absolute host path in the message. This
|
|
12
|
+
* keeps the errno, which is the part that tells you what to fix, and reports
|
|
13
|
+
* the target the way every other Astryx message does: relative to the project.
|
|
14
|
+
*
|
|
15
|
+
* A caller that wrote files before the failure must undo them first and pass
|
|
16
|
+
* the ones it could not restore as `unrestored`, so the message never says
|
|
17
|
+
* nothing was written when something was.
|
|
18
|
+
*
|
|
19
|
+
* @param {string} target absolute path the write was aimed at
|
|
20
|
+
* @param {string} cwd project root, for the relative form
|
|
21
|
+
* @param {unknown} cause the error the filesystem call threw
|
|
22
|
+
* @param {string[]} [unrestored] absolute paths an undo could not put back
|
|
23
|
+
* @returns {AstryxError}
|
|
24
|
+
*/
|
|
25
|
+
export function writeFailed(target: string, cwd: string, cause: unknown, unrestored?: string[]): AstryxError;
|
|
4
26
|
export class AstryxError extends Error {
|
|
5
27
|
/**
|
|
6
28
|
* @param {string} message
|
package/api/error.mjs
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import {ERROR_CODES} from '../foundation/response/error-codes.mjs';
|
|
15
|
+
import * as path from 'node:path';
|
|
15
16
|
|
|
16
17
|
export class AstryxError extends Error {
|
|
17
18
|
/** @type {import('../foundation/response/base').Suggestion[] | undefined} */
|
|
@@ -36,3 +37,44 @@ export class AstryxError extends Error {
|
|
|
36
37
|
if (Array.isArray(suggestions) && suggestions.length) this.suggestions = suggestions;
|
|
37
38
|
}
|
|
38
39
|
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The error for a write that failed on the filesystem: no permission, a
|
|
43
|
+
* read-only mount, a full disk, a path component that is not a directory.
|
|
44
|
+
*
|
|
45
|
+
* A raw Node errno error reached the envelope as
|
|
46
|
+
* `{"error": "EACCES: permission denied, open '/home/you/p/readonly/x.tsx'",
|
|
47
|
+
* "code": "ERR_UNKNOWN"}` — the wrong code (ERR_WRITE_FAILED is in the frozen
|
|
48
|
+
* registry for exactly this) and an absolute host path in the message. This
|
|
49
|
+
* keeps the errno, which is the part that tells you what to fix, and reports
|
|
50
|
+
* the target the way every other Astryx message does: relative to the project.
|
|
51
|
+
*
|
|
52
|
+
* A caller that wrote files before the failure must undo them first and pass
|
|
53
|
+
* the ones it could not restore as `unrestored`, so the message never says
|
|
54
|
+
* nothing was written when something was.
|
|
55
|
+
*
|
|
56
|
+
* @param {string} target absolute path the write was aimed at
|
|
57
|
+
* @param {string} cwd project root, for the relative form
|
|
58
|
+
* @param {unknown} cause the error the filesystem call threw
|
|
59
|
+
* @param {string[]} [unrestored] absolute paths an undo could not put back
|
|
60
|
+
* @returns {AstryxError}
|
|
61
|
+
*/
|
|
62
|
+
export function writeFailed(target, cwd, cause, unrestored = []) {
|
|
63
|
+
const rel = path.relative(cwd, target) || target;
|
|
64
|
+
const errno =
|
|
65
|
+
typeof (/** @type {any} */ (cause)?.code) === 'string'
|
|
66
|
+
? /** @type {any} */ (cause).code
|
|
67
|
+
: null;
|
|
68
|
+
const why = errno === 'EACCES' || errno === 'EPERM' ? ' (no permission)' : '';
|
|
69
|
+
const outcome =
|
|
70
|
+
unrestored.length === 0
|
|
71
|
+
? 'Nothing was written.'
|
|
72
|
+
: `Earlier writes could not all be undone: ${unrestored
|
|
73
|
+
.map(file => path.relative(cwd, file) || file)
|
|
74
|
+
.join(', ')}.`;
|
|
75
|
+
return new AstryxError(
|
|
76
|
+
`Could not write ${rel}${errno ? `: ${errno}` : ''}${why}. ${outcome}`,
|
|
77
|
+
undefined,
|
|
78
|
+
ERROR_CODES.ERR_WRITE_FAILED,
|
|
79
|
+
);
|
|
80
|
+
}
|
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* Collect the effective handler set in delivery order: project config first,
|
|
6
6
|
* then integrations in config order. Valid handlers dedupe by handle identity;
|
|
7
|
-
* malformed integration exports
|
|
7
|
+
* malformed integration exports and integrations that failed to load retain
|
|
8
|
+
* their position as failed deliveries. An unloadable integration may export a
|
|
9
|
+
* handler, so it never counts as an empty set that enables the fallback.
|
|
8
10
|
*
|
|
9
11
|
* @param {Project} project
|
|
10
12
|
* @returns {HandlerEntry[]}
|
|
@@ -164,9 +164,23 @@ async function selectTarget(project, component, packageName) {
|
|
|
164
164
|
const bareComponent = component.startsWith('XDS')
|
|
165
165
|
? component.slice(3)
|
|
166
166
|
: component;
|
|
167
|
+
const records = await project.components();
|
|
168
|
+
// A replaced Core component routes to the package that replaces it
|
|
169
|
+
// (spec:AST-035 FR11). Owners below match without case, so the Core name
|
|
170
|
+
// does too.
|
|
171
|
+
const coreName =
|
|
172
|
+
records.find(
|
|
173
|
+
record =>
|
|
174
|
+
record.package === CORE_PACKAGE &&
|
|
175
|
+
record.name.toLowerCase() === bareComponent.toLowerCase(),
|
|
176
|
+
)?.name ?? bareComponent;
|
|
177
|
+
const replacement = (await project.componentReplacements()).forTarget(
|
|
178
|
+
coreName,
|
|
179
|
+
);
|
|
180
|
+
if (replacement) return targetForPackage(project, replacement.package);
|
|
167
181
|
const owners = [
|
|
168
182
|
...new Set(
|
|
169
|
-
|
|
183
|
+
records
|
|
170
184
|
.filter(
|
|
171
185
|
record => record.name.toLowerCase() === bareComponent.toLowerCase(),
|
|
172
186
|
)
|
|
@@ -189,7 +203,9 @@ async function selectTarget(project, component, packageName) {
|
|
|
189
203
|
/**
|
|
190
204
|
* Collect the effective handler set in delivery order: project config first,
|
|
191
205
|
* then integrations in config order. Valid handlers dedupe by handle identity;
|
|
192
|
-
* malformed integration exports
|
|
206
|
+
* malformed integration exports and integrations that failed to load retain
|
|
207
|
+
* their position as failed deliveries. An unloadable integration may export a
|
|
208
|
+
* handler, so it never counts as an empty set that enables the fallback.
|
|
193
209
|
*
|
|
194
210
|
* @param {Project} project
|
|
195
211
|
* @returns {HandlerEntry[]}
|
|
@@ -214,7 +230,15 @@ export function collectGapReportHandlers(project) {
|
|
|
214
230
|
}
|
|
215
231
|
|
|
216
232
|
for (const integration of project.loadedIntegrations) {
|
|
217
|
-
if (integration.__loadError)
|
|
233
|
+
if (integration.__loadError) {
|
|
234
|
+
entries.push({
|
|
235
|
+
kind: 'malformed',
|
|
236
|
+
handlerType: 'integration',
|
|
237
|
+
handlerName: integration.name,
|
|
238
|
+
error: `Integration failed to load, so it could not receive this report: ${integration.__loadError}. Fix the package or remove it from integrations in astryx.config, then rerun.`,
|
|
239
|
+
});
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
218
242
|
if (integration.__gapReportError) {
|
|
219
243
|
entries.push({
|
|
220
244
|
kind: 'malformed',
|