@astryxdesign/cli 0.6.3-canary.ebaebc4 → 0.6.3-canary.f04b501
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/README.md +106 -73
- package/api/blog/blog.doc.mjs +1 -0
- package/api/build/build.doc.mjs +4 -3
- package/api/build/build.test.mjs +14 -3
- package/api/build/build.type.d.mts +35 -1
- package/api/build/build.type.mjs +24 -3
- package/api/build/help/help.d.mts +8 -5
- package/api/build/help/help.mjs +56 -6
- package/api/component/component.doc.mjs +13 -3
- package/api/component/component.mjs +31 -2
- package/api/component/component.test.mjs +38 -0
- package/api/component/component.type.d.mts +16 -5
- package/api/component/component.type.mjs +13 -5
- package/api/component/detail/blocks/blocks.d.mts +2 -1
- package/api/component/detail/blocks/blocks.mjs +4 -3
- package/api/component/list/list.d.mts +0 -5
- package/api/component/list/list.mjs +37 -9
- package/api/discover/discover.doc.mjs +2 -1
- package/api/docs/_adapter.d.mts +3 -8
- package/api/docs/_adapter.mjs +13 -105
- package/api/docs/docs.doc.mjs +1 -0
- package/api/docs/list/list.mjs +3 -7
- package/api/doctor/doctor.d.mts +25 -3
- package/api/doctor/doctor.doc.mjs +1 -0
- package/api/doctor/doctor.mjs +185 -13
- package/api/doctor/doctor.test.mjs +326 -1
- package/api/gap-report/gap-report.doc.mjs +8 -4
- package/api/hook/_adapter.mjs +19 -5
- package/api/hook/hook.doc.mjs +1 -0
- package/api/hook/list/list.d.mts +1 -1
- package/api/hook/list/list.mjs +69 -17
- package/api/init/init.doc.mjs +5 -0
- package/api/init/init.test.mjs +41 -1
- package/api/init/remove/remove.mjs +1 -1
- package/api/init/run/run.mjs +20 -10
- package/api/integration/add-contribution.component-names.test.mjs +120 -0
- package/api/integration/add-contribution.mjs +18 -7
- package/api/integration/add-contribution.test.mjs +117 -3
- package/api/integration/add-theme.mjs +34 -64
- package/api/integration/add-theme.test.mjs +105 -21
- package/api/integration/authoring-checks.test.mjs +8 -4
- package/api/integration/integration-block-exports.test.mjs +10 -6
- package/api/integration/integrationAdd.doc.mjs +8 -4
- package/api/integration/integrationAddAgentDoc.doc.mjs +1 -0
- package/api/integration/integrationAddCodemod.doc.mjs +1 -0
- package/api/integration/integrationAddComponent.doc.mjs +2 -1
- package/api/integration/integrationAddDoc.doc.mjs +1 -0
- package/api/integration/integrationAddTemplate.doc.mjs +1 -0
- package/api/integration/integrationAddTheme.doc.mjs +6 -5
- package/api/integration/integrationComponentConflicts.doc.mjs +1 -0
- package/api/integration/integrationDocConflicts.doc.mjs +1 -0
- package/api/integration/integrationPackCheck.doc.mjs +1 -0
- package/api/integration/integrationTemplateConflicts.doc.mjs +1 -0
- package/api/integration/pack-check.test.mjs +17 -47
- package/api/integration/summarizeIssues.doc.mjs +1 -0
- package/api/integration/validate-integration-fixes.test.mjs +1389 -0
- package/api/integration/validate-integration.mjs +52 -102
- package/api/integration/validate-integration.test.mjs +176 -23
- package/api/integration/validate-unread-theme-folders.test.mjs +110 -0
- package/api/integration/validateIntegration.doc.mjs +2 -1
- package/api/json/assertResponse.doc.mjs +1 -0
- package/api/json/envelope-types.test.mjs +76 -0
- package/api/json/isError.doc.mjs +1 -0
- package/api/json/parseResponse.doc.mjs +3 -2
- package/api/layout/expand/expand.mjs +7 -5
- package/api/layout/expand/expand.path-safety.test.mjs +53 -0
- package/api/layout/grammar/grammar.mjs +2 -1
- package/api/layout/layoutCheck.doc.mjs +1 -0
- package/api/layout/layoutExpand.doc.mjs +2 -1
- package/api/layout/layoutGrammar.doc.mjs +1 -0
- package/api/search/search-return-type.test.mjs +54 -0
- package/api/search/search.d.mts +2 -9
- package/api/search/search.doc.mjs +6 -1
- package/api/search/search.mjs +26 -9
- package/api/search/search.test.mjs +34 -0
- package/api/swizzle/copy/copy.mjs +28 -11
- package/api/swizzle/swizzle.doc.mjs +2 -1
- package/api/template/copy/copy.mjs +17 -23
- package/api/template/copy/copy.test.mjs +17 -0
- package/api/template/template-suffix.test.mjs +41 -21
- package/api/template/template.doc.mjs +3 -1
- package/api/theme/_adapter.d.mts +2 -3
- package/api/theme/_adapter.mjs +4 -5
- package/api/theme/add/add.binary.test.mjs +84 -0
- package/api/theme/add/add.mjs +20 -3
- package/api/theme/add/add.staging.test.mjs +66 -0
- package/api/theme/add/add.test.mjs +14 -1
- package/api/theme/build/build.mjs +114 -37
- package/api/theme/build/build.public-component-vars.test.mjs +1 -1
- package/api/theme/build/build.receipt-doc.test.mjs +111 -0
- package/api/theme/build/font-warning.mjs +3 -3
- package/api/theme/build/font-warning.test.mjs +5 -2
- package/api/theme/generateTonalPalette.doc.mjs +1 -0
- package/api/theme/integration-themes.test.mjs +39 -28
- package/api/theme/list/list.test.mjs +19 -20
- package/api/theme/listThemes.doc.mjs +6 -5
- package/api/theme/palette/generate/generate.mjs +7 -2
- package/api/theme/palette/generate/generate.test.mjs +96 -0
- package/api/theme/palette/generate/generator.mjs +8 -1
- package/api/theme/palette/generate/generator.test.mjs +10 -0
- package/api/theme/template/template.mjs +11 -2
- package/api/theme/template/template.test.mjs +15 -0
- package/api/theme/themeAdd.doc.mjs +4 -3
- package/api/theme/themeBuild.doc.mjs +8 -4
- package/api/theme/themeList.doc.mjs +6 -3
- package/api/theme/themeListAvailable.doc.mjs +5 -3
- package/api/theme/themePaletteGenerate.doc.mjs +1 -0
- package/api/theme/themeTargets.doc.mjs +1 -0
- package/api/theme/themeTemplate.doc.mjs +5 -1
- package/api/upgrade/_adapter.d.mts +12 -3
- package/api/upgrade/_adapter.mjs +108 -70
- package/api/upgrade/list/list.mjs +2 -1
- package/api/upgrade/list/list.test.mjs +73 -0
- package/api/upgrade/provider-agreement.test.mjs +152 -0
- package/api/upgrade/run/run.mjs +1 -0
- package/api/upgrade/status/status.mjs +2 -2
- package/api/upgrade/upgrade.doc.mjs +3 -1
- package/api/upgrade/upgrade.type.d.mts +4 -0
- package/api/upgrade/upgrade.type.mjs +1 -0
- package/assets/codemods/integration-discovery.mjs +8 -2
- package/assets/codemods/integration-discovery.test.mjs +15 -0
- package/assets/codemods/runner.mjs +115 -5
- package/assets/codemods/term-log.mjs +32 -8
- package/assets/codemods/term-log.test.mjs +19 -1
- package/assets/codemods/transform-prop.mjs +109 -0
- package/assets/codemods/transform-prop.test.mjs +95 -0
- package/assets/codemods/transforms/next/__tests__/migrate-theme-catalog-to-descriptors.test.mjs +216 -0
- package/assets/codemods/transforms/next/index.mjs +11 -1
- package/assets/codemods/transforms/next/migrate-theme-catalog-to-descriptors.mjs +141 -0
- package/assets/codemods/transforms/v0.0.14/__tests__/rename-status-variants.test.mjs +86 -165
- package/assets/codemods/transforms/v0.0.14/rename-status-variants.mjs +72 -210
- package/assets/codemods/transforms/v0.1.8/__tests__/rename-avatar-size-scale.test.mjs +83 -115
- package/assets/codemods/transforms/v0.1.8/rename-avatar-size-scale.mjs +57 -186
- package/assets/codemods/transforms/v0.6.0/__tests__/next-codemods.test.mjs +47 -0
- package/assets/codemods/transforms/v0.6.0/rename-resizable-pixel-bounds.mjs +57 -10
- package/assets/docs/cli-integrations.doc.mjs +17 -30
- package/assets/docs/cli.doc.mjs +15 -0
- package/assets/docs/theme.doc.mjs +1 -1
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaInlineRail.doc.mjs +14 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaInlineRail.tsx +61 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaOverscrollChaining.doc.mjs +14 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaOverscrollChaining.tsx +126 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaShowcase.doc.mjs +15 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaShowcase.tsx +86 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyGroupHeaders.doc.mjs +14 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyGroupHeaders.tsx +99 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyPassthrough.doc.mjs +14 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyPassthrough.tsx +122 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaTwoAxisBoard.doc.mjs +14 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaTwoAxisBoard.tsx +95 -0
- package/assets/templates/pages/table-tree/page.tsx +1704 -0
- package/assets/templates/pages/table-tree/template.doc.mjs +12 -0
- package/assets/templates/themes/butter/butterTheme.doc.mjs +11 -0
- package/assets/templates/themes/chocolate/chocolateTheme.doc.mjs +11 -0
- package/assets/templates/themes/gothic/gothicTheme.doc.mjs +11 -0
- package/assets/templates/themes/matcha/matchaTheme.doc.mjs +11 -0
- package/assets/templates/themes/neutral/neutralTheme.doc.mjs +11 -0
- package/assets/templates/themes/stone/stoneTheme.doc.mjs +11 -0
- package/assets/templates/themes/y2k/y2kTheme.doc.mjs +11 -0
- package/authoring/codemod/codemod.doc.mjs +1 -1
- package/authoring/config/config.doc.mjs +2 -2
- package/authoring/config/debug-composition.test.mjs +92 -0
- package/authoring/config/type.ts +15 -3
- package/authoring/debug/debug.doc.d.mts +11 -0
- package/authoring/debug/debug.doc.mjs +182 -0
- package/authoring/doctypes/base/graph-fields.doc.mjs +1 -1
- package/authoring/doctypes/command/command.doc.mjs +1 -1
- package/authoring/doctypes/command/type.ts +1 -1
- package/authoring/doctypes/component/type.ts +2 -2
- package/authoring/doctypes/doctypes-new.test.mjs +48 -6
- package/authoring/doctypes/enum/enum.doc.mjs +1 -1
- package/authoring/doctypes/enum/type.ts +1 -1
- package/authoring/doctypes/function/function.doc.mjs +1 -1
- package/authoring/doctypes/function/type.ts +1 -1
- package/authoring/doctypes/hook/type.ts +2 -2
- package/authoring/doctypes/load-contract.test.mjs +2 -1
- package/authoring/doctypes/parse.d.mts +4 -2
- package/authoring/doctypes/parse.mjs +7 -3
- package/authoring/doctypes/reference/reference.doc.mjs +1 -1
- package/authoring/doctypes/reference/type.ts +2 -2
- package/authoring/doctypes/schema/schema.doc.mjs +1 -1
- package/authoring/doctypes/schema/type.ts +1 -2
- package/authoring/doctypes/template/template.doc.mjs +3 -3
- package/authoring/doctypes/theme/parse.d.mts +35 -0
- package/authoring/doctypes/theme/parse.mjs +76 -0
- package/authoring/doctypes/theme/theme.doc.d.mts +9 -0
- package/authoring/doctypes/theme/theme.doc.mjs +79 -0
- package/authoring/doctypes/theme/type.ts +42 -0
- package/authoring/doctypes/types.ts +2 -1
- package/authoring/gap-report/gap-report.doc.d.mts +12 -0
- package/authoring/gap-report/gap-report.doc.mjs +183 -0
- package/authoring/index.d.mts +1 -0
- package/authoring/index.d.ts +6 -4
- package/authoring/index.mjs +2 -1
- package/authoring/integration/integration.doc.mjs +2 -2
- package/authoring/integration/type.ts +3 -9
- package/clients/cli/__tests__/cliManifest.test.ts +27 -29
- package/clients/cli/command-load-failure.test.mjs +83 -0
- package/clients/cli/commands/blog.doc.mjs +1 -1
- package/clients/cli/commands/blog.mjs +23 -8
- package/clients/cli/commands/blog.test.mjs +42 -1
- package/clients/cli/commands/build-theme.ascii-output.test.mjs +161 -0
- package/clients/cli/commands/build-theme.flag-docs.test.mjs +110 -0
- package/clients/cli/commands/build-theme.mjs +5 -5
- package/clients/cli/commands/build-theme.path-safety.test.mjs +86 -1
- package/clients/cli/commands/build-theme.variants.test.mjs +76 -0
- package/clients/cli/commands/build.doc.mjs +5 -2
- package/clients/cli/commands/build.exit-codes-doc.test.mjs +50 -0
- package/clients/cli/commands/build.mjs +32 -47
- package/clients/cli/commands/build.playbook.test.mjs +75 -0
- package/clients/cli/commands/build.text-fields.test.mjs +40 -0
- package/clients/cli/commands/component/index.mjs +2 -7
- package/clients/cli/commands/component-package.test.mjs +46 -0
- package/clients/cli/commands/component-resolution.test.mjs +21 -0
- package/clients/cli/commands/component.doc.mjs +1 -1
- package/clients/cli/commands/component.test.mjs +19 -0
- package/clients/cli/commands/detail-levels.test.mjs +2 -2
- package/clients/cli/commands/discover.broken-integration.test.mjs +48 -0
- package/clients/cli/commands/discover.components-flag.test.mjs +97 -0
- package/clients/cli/commands/discover.doc.mjs +5 -3
- package/clients/cli/commands/discover.mjs +3 -3
- package/clients/cli/commands/discover.text-projection.test.mjs +103 -0
- package/clients/cli/commands/docs.doc.mjs +1 -1
- package/clients/cli/commands/doctor-integration-components.doc.mjs +1 -1
- package/clients/cli/commands/doctor-integration-docs.doc.mjs +1 -1
- package/clients/cli/commands/doctor-integration-templates.doc.mjs +1 -1
- package/clients/cli/commands/doctor-integration-validate.doc.mjs +1 -1
- package/clients/cli/commands/doctor-integration.doc.mjs +1 -1
- package/clients/cli/commands/doctor-integration.package-json.test.mjs +53 -0
- package/clients/cli/commands/doctor-integration.test.mjs +15 -7
- package/clients/cli/commands/doctor.doc.mjs +1 -1
- package/clients/cli/commands/doctor.mjs +6 -16
- package/clients/cli/commands/doctor.test.mjs +42 -0
- package/clients/cli/commands/gap-report.doc.mjs +17 -6
- package/clients/cli/commands/gap-report.test.mjs +72 -0
- package/clients/cli/commands/hook/index.mjs +7 -17
- package/clients/cli/commands/hook.doc.mjs +1 -1
- package/clients/cli/commands/hook.text-projection.test.mjs +45 -0
- package/clients/cli/commands/init.doc.mjs +20 -9
- package/clients/cli/commands/init.flag-help.test.mjs +153 -0
- package/clients/cli/commands/integration-add.controls.test.mjs +132 -0
- package/clients/cli/commands/integration-add.doc.mjs +22 -6
- package/clients/cli/commands/integration-pack.doc.mjs +1 -1
- package/clients/cli/commands/integration-real-world.test.mjs +3 -9
- package/clients/cli/commands/integration.doc.mjs +1 -1
- package/clients/cli/commands/interactive-guard.test.mjs +101 -24
- package/clients/cli/commands/json-contract.test.mjs +33 -0
- package/clients/cli/commands/layout-check.doc.mjs +15 -4
- package/clients/cli/commands/layout-expand.doc.mjs +22 -5
- package/clients/cli/commands/layout-grammar.doc.mjs +1 -1
- package/clients/cli/commands/layout.doc.mjs +3 -3
- package/clients/cli/commands/layout.mjs +21 -9
- package/clients/cli/commands/layout.path-help.test.mjs +33 -0
- package/clients/cli/commands/layout.stdin-cap.test.mjs +47 -0
- package/clients/cli/commands/layout.text-fields.test.mjs +39 -0
- package/clients/cli/commands/manifest.doc.mjs +1 -1
- package/clients/cli/commands/no-prompt-wording.test.mjs +94 -0
- package/clients/cli/commands/search.doc.mjs +7 -4
- package/clients/cli/commands/search.mjs +17 -7
- package/clients/cli/commands/search.test.mjs +75 -0
- package/clients/cli/commands/swizzle.doc.mjs +3 -2
- package/clients/cli/commands/swizzle.path-safety.test.mjs +42 -0
- package/clients/cli/commands/template.doc.mjs +29 -7
- package/clients/cli/commands/template.flag-help.test.mjs +117 -0
- package/clients/cli/commands/template.path-help.test.mjs +40 -0
- package/clients/cli/commands/theme-add.doc.mjs +4 -3
- package/clients/cli/commands/theme-build.doc.mjs +8 -7
- package/clients/cli/commands/theme-list.doc.mjs +2 -2
- package/clients/cli/commands/theme-palette-generate.doc.mjs +3 -3
- package/clients/cli/commands/theme-palette-generate.test.mjs +19 -0
- package/clients/cli/commands/theme-palette.doc.mjs +1 -1
- package/clients/cli/commands/theme-targets.doc.mjs +1 -1
- package/clients/cli/commands/theme-template.behavior.test.mjs +12 -0
- package/clients/cli/commands/theme-template.doc.mjs +2 -2
- package/clients/cli/commands/theme.doc.mjs +1 -1
- package/clients/cli/commands/upgrade.ascii-output.test.mjs +87 -0
- package/clients/cli/commands/upgrade.doc.mjs +18 -7
- package/clients/cli/commands/upgrade.flag-help.test.mjs +188 -0
- package/clients/cli/commands/upgrade.hook-output.test.mjs +88 -0
- package/clients/cli/index.mjs +13 -30
- package/clients/cli/latest-version-env.test.mjs +50 -0
- package/clients/cli/lib/cli-error.test.mjs +7 -0
- package/clients/cli/lib/component-format.mjs +9 -9
- package/clients/cli/lib/component-format.test.mjs +1 -1
- package/clients/cli/lib/define-command.mjs +32 -6
- package/clients/cli/lib/doc-text-ascii.test.mjs +82 -0
- package/clients/cli/lib/exit-codes.test.mjs +97 -0
- package/clients/cli/lib/hook-format.mjs +19 -10
- package/clients/cli/lib/json-shim.mjs +38 -2
- package/clients/cli/lib/json-shim.test.mjs +83 -0
- package/clients/cli/lib/manifest.d.ts +2 -0
- package/clients/cli/lib/manifest.mjs +22 -0
- package/clients/cli/lib/manifest.test.mjs +17 -0
- package/foundation/agent-docs/agent-docs.d.mts +4 -0
- package/foundation/agent-docs/agent-docs.mjs +69 -3
- package/foundation/agent-docs/agent-docs.path-safety.test.mjs +266 -4
- package/foundation/config/integration-debug.test.mjs +28 -3
- package/foundation/config/project-themes.test.mjs +11 -19
- package/foundation/config/project.d.mts +8 -0
- package/foundation/config/project.mjs +173 -30
- package/foundation/config/project.test.mjs +129 -16
- package/foundation/discovery/authoring-self-docs.d.mts +6 -0
- package/foundation/discovery/authoring-self-docs.mjs +17 -7
- package/foundation/discovery/authoring-surface.d.mts +74 -0
- package/foundation/discovery/authoring-surface.mjs +525 -0
- package/foundation/discovery/authoring-surface.test.mjs +392 -0
- package/foundation/discovery/cli-self-docs.d.mts +113 -0
- package/foundation/discovery/cli-self-docs.mjs +514 -0
- package/foundation/discovery/cli-self-docs.test.mjs +437 -0
- package/foundation/discovery/component-loader.d.mts +35 -38
- package/foundation/discovery/component-loader.mjs +53 -222
- package/foundation/discovery/docs-discovery.d.mts +3 -2
- package/foundation/discovery/docs-discovery.mjs +8 -12
- package/foundation/discovery/docs-discovery.test.mjs +8 -5
- package/foundation/discovery/template-adapter.d.mts +21 -5
- package/foundation/discovery/template-adapter.fixture-refs.test.mjs +248 -0
- package/foundation/discovery/template-adapter.integration-isolation.test.mjs +94 -0
- package/foundation/discovery/template-adapter.mjs +319 -65
- package/foundation/discovery/template-adapter.test.mjs +15 -0
- package/foundation/discovery/theme-discovery.d.mts +67 -7
- package/foundation/discovery/theme-discovery.mjs +916 -186
- package/foundation/discovery/theme-discovery.test.mjs +613 -219
- package/foundation/doc-compiler/bundle.d.mts +47 -0
- package/foundation/doc-compiler/bundle.mjs +218 -0
- package/foundation/doc-compiler/bundle.test.mjs +255 -0
- package/foundation/doc-compiler/compile.d.mts +200 -0
- package/foundation/doc-compiler/compile.mjs +254 -5
- package/foundation/doc-compiler/diagnostics.d.mts +126 -0
- package/foundation/doc-compiler/diagnostics.mjs +277 -0
- package/foundation/doc-compiler/doc-compiler.test.mjs +28 -1
- package/foundation/doc-compiler/doc-loads.test.mjs +1642 -0
- package/foundation/doc-compiler/import.d.mts +24 -0
- package/foundation/doc-compiler/import.mjs +59 -0
- package/foundation/doc-compiler/inputs.d.mts +102 -0
- package/foundation/doc-compiler/inputs.mjs +286 -0
- package/foundation/doc-compiler/inputs.test.mjs +299 -0
- package/foundation/doc-compiler/ir.d.mts +13 -0
- package/foundation/doc-compiler/ir.mjs +189 -12
- package/foundation/doc-compiler/lower-doc.test.mjs +492 -0
- package/foundation/doc-compiler/overlays.d.mts +37 -0
- package/foundation/doc-compiler/overlays.mjs +206 -0
- package/foundation/doc-compiler/parse-readable.d.mts +9 -0
- package/foundation/doc-compiler/parse-readable.mjs +29 -0
- package/foundation/doc-compiler/read.d.mts +126 -0
- package/foundation/doc-compiler/read.mjs +320 -0
- package/foundation/doc-compiler/read.test.mjs +313 -0
- package/foundation/doc-compiler/source.d.mts +33 -0
- package/foundation/doc-compiler/source.mjs +128 -0
- package/foundation/fs/module-loader.d.mts +1 -0
- package/foundation/fs/module-loader.mjs +50 -1
- package/foundation/fs/module-loader.stdout.test.mjs +332 -0
- package/foundation/fs/path-safety.d.mts +3 -2
- package/foundation/fs/path-safety.mjs +49 -19
- package/foundation/fs/path-safety.test.mjs +50 -0
- package/foundation/fs/publish-file-hardlink-unavailable.test.mjs +129 -94
- package/foundation/integrations/autolink.d.mts +58 -1
- package/foundation/integrations/autolink.mjs +143 -52
- package/foundation/integrations/contribution-fixes.d.mts +145 -0
- package/foundation/integrations/contribution-fixes.mjs +1284 -0
- package/foundation/integrations/contribution-inventory.d.mts +1 -1
- package/foundation/integrations/contribution-inventory.mjs +17 -20
- package/foundation/integrations/contribution-inventory.test.mjs +67 -27
- package/foundation/integrations/integrations.d.mts +3 -0
- package/foundation/integrations/integrations.mjs +11 -97
- package/foundation/integrations/provider-ledger.test.mjs +275 -0
- package/foundation/integrations/provider-resolution.d.mts +152 -0
- package/foundation/integrations/provider-resolution.mjs +576 -0
- package/foundation/integrations/provider-resolution.test.mjs +369 -0
- package/foundation/integrations/theme-descriptor.d.mts +8 -0
- package/foundation/integrations/theme-descriptor.mjs +44 -0
- package/foundation/integrations/validate-contributions.mjs +104 -10
- package/foundation/response/base.d.ts +8 -4
- package/foundation/response/error-codes.doc.mjs +3 -4
- package/foundation/response/error-codes.mjs +2 -2
- package/foundation/response/error-codes.test.mjs +83 -0
- package/foundation/response/json-contract.test.mjs +11 -0
- package/foundation/response/json.d.mts +4 -2
- package/foundation/response/json.mjs +8 -10
- package/foundation/response/response-types.doc.mjs +11 -11
- package/foundation/response/response-types.doc.test.mjs +158 -0
- package/foundation/response/response.doc.mjs +1 -1
- package/foundation/text/string-utils.mjs +22 -10
- package/foundation/xle/expand.d.mts +2 -0
- package/foundation/xle/expand.mjs +3 -2
- package/foundation/xle/expand.test.mjs +54 -0
- package/package.json +9 -9
- package/assets/templates/themes/manifest.json +0 -95
- package/clients/cli/lib/update-check.mjs +0 -83
- package/clients/cli/lib/update-check.test.mjs +0 -137
- package/clients/cli/update-hint-commands.test.mjs +0 -54
|
@@ -194,6 +194,89 @@ function toUnifiedEntry(transformEntry, version) {
|
|
|
194
194
|
};
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
+
/**
|
|
198
|
+
* What a core PROJECT codemod plans: whole files to write and delete under the
|
|
199
|
+
* project root, or the problems that stop it. Paths in `writes` and `deletes`
|
|
200
|
+
* are absolute; `problems` name package-relative files.
|
|
201
|
+
*
|
|
202
|
+
* @typedef {object} ProjectCodemodPlan
|
|
203
|
+
* @property {Array<{path: string, contents: string}>} writes
|
|
204
|
+
* @property {string[]} deletes
|
|
205
|
+
* @property {Array<{file: string, message: string}>} problems
|
|
206
|
+
*/
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Run one core PROJECT codemod (`meta.codemodType === 'project'`): instead of
|
|
210
|
+
* rewriting the files it is handed, it reads the project and plans whole-file
|
|
211
|
+
* writes and deletions, which this applies (or previews) as one unit. A plan
|
|
212
|
+
* that names a problem changes nothing. Core-only: integration codemods keep
|
|
213
|
+
* the file contract.
|
|
214
|
+
*
|
|
215
|
+
* @param {{name: string, transform: unknown}} transformEntry
|
|
216
|
+
* @param {{apply: boolean, root: string, log: {success: (m: string) => void, warn: (m: string) => void, error: (m: string) => void}}} options
|
|
217
|
+
* @returns {Promise<{filesChanged: number, writtenFiles: string[], errors: Array<{file: string, codemod: string, error: string}>}>}
|
|
218
|
+
*/
|
|
219
|
+
async function runProjectCodemod({name, transform}, {apply, root, log}) {
|
|
220
|
+
/** @param {string} file */
|
|
221
|
+
const rel = file => path.relative(root, file).split(path.sep).join('/');
|
|
222
|
+
/** @type {ProjectCodemodPlan} */
|
|
223
|
+
let plan;
|
|
224
|
+
try {
|
|
225
|
+
plan = await /** @type {(root: string) => Promise<ProjectCodemodPlan>} */ (
|
|
226
|
+
transform
|
|
227
|
+
)(root);
|
|
228
|
+
} catch (err) {
|
|
229
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
230
|
+
log.error(` ✗ ${message}`);
|
|
231
|
+
return {
|
|
232
|
+
filesChanged: 0,
|
|
233
|
+
writtenFiles: [],
|
|
234
|
+
errors: [{file: '.', codemod: name, error: message}],
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
if (plan.problems.length > 0) {
|
|
238
|
+
for (const {file, message} of plan.problems) {
|
|
239
|
+
log.error(` ✗ ${file} — ${message}`);
|
|
240
|
+
}
|
|
241
|
+
return {
|
|
242
|
+
filesChanged: 0,
|
|
243
|
+
writtenFiles: [],
|
|
244
|
+
errors: plan.problems.map(({file, message}) => ({
|
|
245
|
+
file,
|
|
246
|
+
codemod: name,
|
|
247
|
+
error: message,
|
|
248
|
+
})),
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
/** @type {string[]} */
|
|
252
|
+
const writtenFiles = [];
|
|
253
|
+
for (const write of plan.writes) {
|
|
254
|
+
if (apply) {
|
|
255
|
+
fs.mkdirSync(path.dirname(write.path), {recursive: true});
|
|
256
|
+
fs.writeFileSync(write.path, write.contents, 'utf-8');
|
|
257
|
+
writtenFiles.push(write.path);
|
|
258
|
+
log.success(` ✓ ${rel(write.path)}`);
|
|
259
|
+
} else {
|
|
260
|
+
log.warn(` ~ ${rel(write.path)} (would write)`);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
// Deletions go last, so a failed write leaves a state a rerun completes.
|
|
264
|
+
for (const file of plan.deletes) {
|
|
265
|
+
if (apply) {
|
|
266
|
+
fs.rmSync(file);
|
|
267
|
+
writtenFiles.push(file);
|
|
268
|
+
log.success(` ✓ ${rel(file)} (removed)`);
|
|
269
|
+
} else {
|
|
270
|
+
log.warn(` ~ ${rel(file)} (would remove)`);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return {
|
|
274
|
+
filesChanged: plan.writes.length + plan.deletes.length,
|
|
275
|
+
writtenFiles,
|
|
276
|
+
errors: [],
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
|
|
197
280
|
/**
|
|
198
281
|
* Run codemods against source files.
|
|
199
282
|
*
|
|
@@ -204,11 +287,19 @@ function toUnifiedEntry(transformEntry, version) {
|
|
|
204
287
|
* @param {string|undefined} options.codemod - Run only this specific transform
|
|
205
288
|
* @param {Set<string>} [options.skipCodemods] - Transform names to exclude
|
|
206
289
|
* @param {boolean} [options.silent] - Suppress all human-facing output (for --json)
|
|
290
|
+
* @param {string} [options.root] - Project root a project codemod reads (default: the process cwd)
|
|
207
291
|
* @returns {Promise<{totalFilesChanged: number, totalTransformsApplied: number, totalValidationBlocked: number, writtenFiles: string[], errors: Array<{file: string, codemod: string, error: string}>, skippedOptional: Array<{name: string, meta: {title: string, description?: string, fileExtensions?: string[], codemodType?: string}, version: string}>} | {ok: false, reason: string, resolvedPath: string}>}
|
|
208
292
|
*/
|
|
209
293
|
export async function runCodemods(
|
|
210
294
|
versionManifests,
|
|
211
|
-
{
|
|
295
|
+
{
|
|
296
|
+
apply,
|
|
297
|
+
path: srcPath,
|
|
298
|
+
codemod,
|
|
299
|
+
skipCodemods,
|
|
300
|
+
silent = false,
|
|
301
|
+
root = process.cwd(),
|
|
302
|
+
},
|
|
212
303
|
) {
|
|
213
304
|
// No-op stub object so silent mode skips log output entirely without
|
|
214
305
|
// littering the body with `if (!silent)` guards.
|
|
@@ -221,11 +312,14 @@ export async function runCodemods(
|
|
|
221
312
|
|
|
222
313
|
const resolvedPath = path.resolve(srcPath);
|
|
223
314
|
|
|
224
|
-
// Config codemods
|
|
225
|
-
//
|
|
226
|
-
//
|
|
315
|
+
// Config and project codemods never read the files under --path, so a
|
|
316
|
+
// missing --path should not block them. Only hard-fail on a missing source
|
|
317
|
+
// path when there is at least one CODE codemod to run.
|
|
227
318
|
const hasCodeCodemod = versionManifests.some(({transforms}) =>
|
|
228
|
-
transforms.some(
|
|
319
|
+
transforms.some(
|
|
320
|
+
t =>
|
|
321
|
+
t.meta?.codemodType !== 'config' && t.meta?.codemodType !== 'project',
|
|
322
|
+
),
|
|
229
323
|
);
|
|
230
324
|
const sourcePathExists = fs.existsSync(resolvedPath);
|
|
231
325
|
|
|
@@ -290,6 +384,22 @@ export async function runCodemods(
|
|
|
290
384
|
// `(file, api)` contract and targets the consumer's astryx.config.*.
|
|
291
385
|
// A core entry signals "config" via `meta.codemodType === 'config'`
|
|
292
386
|
// (see toUnifiedEntry).
|
|
387
|
+
if (meta?.codemodType === 'project') {
|
|
388
|
+
const result = await runProjectCodemod(transformEntry, {
|
|
389
|
+
apply,
|
|
390
|
+
root,
|
|
391
|
+
log,
|
|
392
|
+
});
|
|
393
|
+
if (result.errors.length > 0) {
|
|
394
|
+
errors.push(...result.errors);
|
|
395
|
+
} else if (result.filesChanged > 0) {
|
|
396
|
+
totalFilesChanged += result.filesChanged;
|
|
397
|
+
totalTransformsApplied += 1;
|
|
398
|
+
writtenFiles.push(...result.writtenFiles);
|
|
399
|
+
}
|
|
400
|
+
continue;
|
|
401
|
+
}
|
|
402
|
+
|
|
293
403
|
if (meta?.codemodType === 'config') {
|
|
294
404
|
const result = runConfigCodemod(toUnifiedEntry(transformEntry, version), {
|
|
295
405
|
apply,
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
* `p.log.step(...)`, `p.log.success(...)`, etc. All output routes through
|
|
12
12
|
* `humanLog`, the CLI's stdout-discipline primitive, which is a no-op in
|
|
13
13
|
* `--json` mode — so these human logs can never corrupt a JSON envelope.
|
|
14
|
+
* Every line is plain ASCII: level prefixes are ASCII and typographic glyphs
|
|
15
|
+
* in a message are transliterated before it is printed.
|
|
14
16
|
*
|
|
15
17
|
* The side-effecting API commands (upgrade/init/themeBuild) do NOT use this;
|
|
16
18
|
* they write through the shared `logger` (api/logger.mjs).
|
|
@@ -18,8 +20,30 @@
|
|
|
18
20
|
|
|
19
21
|
import {humanLog} from '../../foundation/response/json.mjs';
|
|
20
22
|
|
|
21
|
-
/** @
|
|
22
|
-
const
|
|
23
|
+
/** @type {Array<[RegExp, string]>} */
|
|
24
|
+
const ASCII_GLYPHS = [
|
|
25
|
+
[/[\u2014\u2013]/g, '-'],
|
|
26
|
+
[/\u2192/g, '->'],
|
|
27
|
+
[/\u2713/g, '[ok]'],
|
|
28
|
+
[/\u2717/g, '!!'],
|
|
29
|
+
[/\u26a0\ufe0f?/g, '!'],
|
|
30
|
+
[/\u2022/g, '-'],
|
|
31
|
+
[/\u2026/g, '...'],
|
|
32
|
+
[/[\u2018\u2019]/g, "'"],
|
|
33
|
+
[/[\u201c\u201d]/g, '"'],
|
|
34
|
+
[/\u00a0/g, ' '],
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A message as plain ASCII: typographic glyphs become their ASCII spelling.
|
|
39
|
+
* @param {unknown} msg
|
|
40
|
+
* @returns {string}
|
|
41
|
+
*/
|
|
42
|
+
export function toAscii(msg) {
|
|
43
|
+
let text = msg === undefined || msg === null ? '' : String(msg);
|
|
44
|
+
for (const [glyph, ascii] of ASCII_GLYPHS) text = text.replace(glyph, ascii);
|
|
45
|
+
return text;
|
|
46
|
+
}
|
|
23
47
|
|
|
24
48
|
/**
|
|
25
49
|
* Human-facing log surface (the small `log` API codemods use). All lines go to
|
|
@@ -28,15 +52,15 @@ const toStr = (msg) => (msg === undefined || msg === null ? '' : String(msg));
|
|
|
28
52
|
*/
|
|
29
53
|
export const log = {
|
|
30
54
|
/** @param {unknown} msg */
|
|
31
|
-
message: (msg) => humanLog(
|
|
55
|
+
message: (msg) => humanLog(toAscii(msg)),
|
|
32
56
|
/** @param {unknown} msg */
|
|
33
|
-
info: (msg) => humanLog(
|
|
57
|
+
info: (msg) => humanLog(toAscii(msg)),
|
|
34
58
|
/** @param {unknown} msg */
|
|
35
|
-
step: (msg) => humanLog(
|
|
59
|
+
step: (msg) => humanLog(toAscii(msg)),
|
|
36
60
|
/** @param {unknown} msg */
|
|
37
|
-
success: (msg) => humanLog(
|
|
61
|
+
success: (msg) => humanLog(`[ok] ${toAscii(msg)}`),
|
|
38
62
|
/** @param {unknown} msg */
|
|
39
|
-
warn: (msg) => humanLog(
|
|
63
|
+
warn: (msg) => humanLog(`! ${toAscii(msg)}`),
|
|
40
64
|
/** @param {unknown} msg */
|
|
41
|
-
error: (msg) => humanLog(
|
|
65
|
+
error: (msg) => humanLog(`!! ${toAscii(msg)}`),
|
|
42
66
|
};
|
|
@@ -51,7 +51,7 @@ describe('sanity: helpers are live in human mode', () => {
|
|
|
51
51
|
setJsonMode(false);
|
|
52
52
|
p.log.success('done');
|
|
53
53
|
expect(logSpy).toHaveBeenCalledTimes(1);
|
|
54
|
-
expect(logSpy).toHaveBeenCalledWith('
|
|
54
|
+
expect(logSpy).toHaveBeenCalledWith('[ok] done');
|
|
55
55
|
});
|
|
56
56
|
|
|
57
57
|
it('every log helper emits exactly one stdout line in human mode', () => {
|
|
@@ -60,3 +60,21 @@ describe('sanity: helpers are live in human mode', () => {
|
|
|
60
60
|
expect(logSpy).toHaveBeenCalledTimes(6);
|
|
61
61
|
});
|
|
62
62
|
});
|
|
63
|
+
|
|
64
|
+
describe('ASCII output', () => {
|
|
65
|
+
it('prints ASCII level prefixes and transliterates glyphs in messages', () => {
|
|
66
|
+
setJsonMode(false);
|
|
67
|
+
p.log.success('src/a.tsx');
|
|
68
|
+
p.log.warn('stale \u2014 refresh');
|
|
69
|
+
p.log.error(' \u2717 src/b.tsx \u2014 rename \u2192 failed');
|
|
70
|
+
p.log.info(' \u2022 name \u2014 title\u2026');
|
|
71
|
+
const lines = logSpy.mock.calls.map(call => call.join(' '));
|
|
72
|
+
expect(lines).toEqual([
|
|
73
|
+
'[ok] src/a.tsx',
|
|
74
|
+
'! stale - refresh',
|
|
75
|
+
'!! !! src/b.tsx - rename -> failed',
|
|
76
|
+
' - name - title...',
|
|
77
|
+
]);
|
|
78
|
+
for (const line of lines) expect(line).not.toMatch(/[\u0080-\uFFFF]/);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Find imported components, resolve their local JSX names (including aliases),
|
|
5
|
+
* and yield matching JSX prop paths to a visitor.
|
|
6
|
+
*
|
|
7
|
+
* This helper intentionally stops at the JSX boundary. It does not follow
|
|
8
|
+
* variables, helper calls, object spreads, wrapper components, or types.
|
|
9
|
+
*
|
|
10
|
+
* @param {any} root jscodeshift collection for one source file
|
|
11
|
+
* @param {any} j configured jscodeshift instance
|
|
12
|
+
* @param {{
|
|
13
|
+
* matchesImport: (source: string) => boolean,
|
|
14
|
+
* components: ReadonlyMap<string, ReadonlySet<string>>,
|
|
15
|
+
* normalizeComponentName?: (name: string) => string,
|
|
16
|
+
* }} options
|
|
17
|
+
* @param {(propPath: any, context: {component: string, localName: string}) => void} visit
|
|
18
|
+
*/
|
|
19
|
+
export function transformProp(root, j, options, visit) {
|
|
20
|
+
const normalize = options.normalizeComponentName ?? (name => name);
|
|
21
|
+
/** @type {Map<string, {component: string, props: ReadonlySet<string>}>} */
|
|
22
|
+
const directBindings = new Map();
|
|
23
|
+
/** @type {Set<string>} */
|
|
24
|
+
const namespaceBindings = new Set();
|
|
25
|
+
|
|
26
|
+
root.find(j.ImportDeclaration).forEach((/** @type {any} */ importPath) => {
|
|
27
|
+
const source = importPath.node.source.value;
|
|
28
|
+
if (
|
|
29
|
+
importPath.node.importKind === 'type' ||
|
|
30
|
+
typeof source !== 'string' ||
|
|
31
|
+
!options.matchesImport(source)
|
|
32
|
+
) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const subpathName = normalize(source.split('/').at(-1) ?? '');
|
|
37
|
+
const subpathProps = options.components.get(subpathName);
|
|
38
|
+
|
|
39
|
+
for (const specifier of importPath.node.specifiers ?? []) {
|
|
40
|
+
if (specifier.importKind === 'type') continue;
|
|
41
|
+
|
|
42
|
+
if (specifier.type === 'ImportSpecifier') {
|
|
43
|
+
const importedName =
|
|
44
|
+
specifier.imported?.name ?? specifier.imported?.value;
|
|
45
|
+
if (typeof importedName !== 'string') continue;
|
|
46
|
+
const component = normalize(importedName);
|
|
47
|
+
const props = options.components.get(component);
|
|
48
|
+
if (!props) continue;
|
|
49
|
+
directBindings.set(specifier.local?.name ?? importedName, {
|
|
50
|
+
component,
|
|
51
|
+
props,
|
|
52
|
+
});
|
|
53
|
+
} else if (specifier.type === 'ImportDefaultSpecifier' && subpathProps) {
|
|
54
|
+
directBindings.set(specifier.local.name, {
|
|
55
|
+
component: subpathName,
|
|
56
|
+
props: subpathProps,
|
|
57
|
+
});
|
|
58
|
+
} else if (specifier.type === 'ImportNamespaceSpecifier') {
|
|
59
|
+
namespaceBindings.add(specifier.local.name);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
if (directBindings.size === 0 && namespaceBindings.size === 0) return;
|
|
65
|
+
|
|
66
|
+
root.find(j.JSXOpeningElement).forEach((/** @type {any} */ jsxPath) => {
|
|
67
|
+
const name = jsxPath.node.name;
|
|
68
|
+
let localName;
|
|
69
|
+
let component;
|
|
70
|
+
let props;
|
|
71
|
+
|
|
72
|
+
if (name.type === 'JSXIdentifier') {
|
|
73
|
+
localName = name.name;
|
|
74
|
+
const binding = directBindings.get(localName);
|
|
75
|
+
if (!binding) return;
|
|
76
|
+
({component, props} = binding);
|
|
77
|
+
} else if (
|
|
78
|
+
name.type === 'JSXMemberExpression' &&
|
|
79
|
+
name.object?.type === 'JSXIdentifier' &&
|
|
80
|
+
name.property?.type === 'JSXIdentifier' &&
|
|
81
|
+
namespaceBindings.has(name.object.name)
|
|
82
|
+
) {
|
|
83
|
+
localName = name.object.name;
|
|
84
|
+
component = normalize(name.property.name);
|
|
85
|
+
props = options.components.get(component);
|
|
86
|
+
if (!props) return;
|
|
87
|
+
} else {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// A parameter or local declaration with the imported name shadows the
|
|
92
|
+
// module binding. Only JSX tags whose root binding resolves to Program are
|
|
93
|
+
// considered usages of the import discovered above.
|
|
94
|
+
const bindingScope = jsxPath.scope.lookup(localName);
|
|
95
|
+
if (!bindingScope || bindingScope.path.node.type !== 'Program') return;
|
|
96
|
+
|
|
97
|
+
for (let index = 0; index < jsxPath.node.attributes.length; index++) {
|
|
98
|
+
const attribute = jsxPath.node.attributes[index];
|
|
99
|
+
if (
|
|
100
|
+
attribute.type !== 'JSXAttribute' ||
|
|
101
|
+
attribute.name?.type !== 'JSXIdentifier' ||
|
|
102
|
+
!props.has(attribute.name.name)
|
|
103
|
+
) {
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
visit(jsxPath.get('attributes', index), {component, localName});
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
import {describe, expect, it} from 'vitest';
|
|
4
|
+
import jscodeshift from 'jscodeshift';
|
|
5
|
+
import {transformProp} from './transform-prop.mjs';
|
|
6
|
+
|
|
7
|
+
const j = jscodeshift.withParser('tsx');
|
|
8
|
+
const components = new Map([
|
|
9
|
+
['Widget', new Set(['tone'])],
|
|
10
|
+
['Group', new Set(['size'])],
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
function apply(source) {
|
|
14
|
+
const root = j(source);
|
|
15
|
+
transformProp(
|
|
16
|
+
root,
|
|
17
|
+
j,
|
|
18
|
+
{
|
|
19
|
+
matchesImport: value => /^@example\/core(?:\/|$)/.test(value),
|
|
20
|
+
components,
|
|
21
|
+
normalizeComponentName: name =>
|
|
22
|
+
name.startsWith('XDS') ? name.slice(3) : name,
|
|
23
|
+
},
|
|
24
|
+
propPath => {
|
|
25
|
+
propPath.node.name.name = `migrated${propPath.node.name.name}`;
|
|
26
|
+
},
|
|
27
|
+
);
|
|
28
|
+
return root.toSource({quote: 'single'});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
describe('transformProp', () => {
|
|
32
|
+
it('maps named import aliases to their JSX usages', () => {
|
|
33
|
+
const output = apply(`import {Widget as Card} from '@example/core';
|
|
34
|
+
const view = <Card tone="old" other="old" />;`);
|
|
35
|
+
|
|
36
|
+
expect(output).toContain('<Card migratedtone="old" other="old"');
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('maps default subpath imports', () => {
|
|
40
|
+
const output = apply(`import Card from '@example/core/Widget';
|
|
41
|
+
const view = <Card tone="old" />;`);
|
|
42
|
+
|
|
43
|
+
expect(output).toContain('<Card migratedtone="old"');
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('ignores declaration-level type imports', () => {
|
|
47
|
+
const output = apply(`import type {Widget} from '@example/core';
|
|
48
|
+
const Widget = props => <div {...props} />;
|
|
49
|
+
const view = <Widget tone="old" />;`);
|
|
50
|
+
|
|
51
|
+
expect(output).toContain('<Widget tone="old"');
|
|
52
|
+
expect(output).not.toContain('migratedtone');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('ignores type specifiers in mixed imports', () => {
|
|
56
|
+
const output = apply(`import {type Widget, Group} from '@example/core';
|
|
57
|
+
const Widget = props => <div {...props} />;
|
|
58
|
+
const view = <><Widget tone="old" /><Group size="old" /></>;`);
|
|
59
|
+
|
|
60
|
+
expect(output).toContain('<Widget tone="old"');
|
|
61
|
+
expect(output).toContain('<Group migratedsize="old"');
|
|
62
|
+
expect(output).not.toContain('<Widget migratedtone');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('maps namespace imports', () => {
|
|
66
|
+
const output = apply(`import * as Core from '@example/core';
|
|
67
|
+
const view = <Core.Group size="old" />;`);
|
|
68
|
+
|
|
69
|
+
expect(output).toContain('<Core.Group migratedsize="old"');
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('ignores same-named imports from other packages', () => {
|
|
73
|
+
const source = `import {Widget} from '@other/core';
|
|
74
|
+
const view = <Widget tone="old" />;`;
|
|
75
|
+
expect(apply(source)).toBe(source);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('ignores a local binding that shadows an imported alias', () => {
|
|
79
|
+
const output = apply(`import {Widget as Card} from '@example/core';
|
|
80
|
+
const migrated = <Card tone="old" />;
|
|
81
|
+
function Local(Card) { return <Card tone="local" />; }`);
|
|
82
|
+
|
|
83
|
+
expect(output).toContain('<Card migratedtone="old"');
|
|
84
|
+
expect(output).toContain('<Card tone="local"');
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('yields only configured props on configured components', () => {
|
|
88
|
+
const output = apply(`import {Widget, Group} from '@example/core';
|
|
89
|
+
const a = <Widget size="old" tone="old" />;
|
|
90
|
+
const b = <Group tone="old" size="old" />;`);
|
|
91
|
+
|
|
92
|
+
expect(output).toContain('<Widget size="old" migratedtone="old"');
|
|
93
|
+
expect(output).toContain('<Group tone="old" migratedsize="old"');
|
|
94
|
+
});
|
|
95
|
+
});
|
package/assets/codemods/transforms/next/__tests__/migrate-theme-catalog-to-descriptors.test.mjs
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
import {afterEach, beforeEach, describe, expect, it} from 'vitest';
|
|
4
|
+
import * as fs from 'node:fs';
|
|
5
|
+
import * as os from 'node:os';
|
|
6
|
+
import * as path from 'node:path';
|
|
7
|
+
import manifest from '../index.mjs';
|
|
8
|
+
import migrate from '../migrate-theme-catalog-to-descriptors.mjs';
|
|
9
|
+
import {runCodemods} from '../../../runner.mjs';
|
|
10
|
+
import {discoverThemeDirectory} from '../../../../../foundation/discovery/theme-discovery.mjs';
|
|
11
|
+
|
|
12
|
+
let root;
|
|
13
|
+
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
root = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-theme-catalog-'));
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
afterEach(() => {
|
|
19
|
+
fs.rmSync(root, {recursive: true, force: true});
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
/** A catalog entry exactly as `astryx integration add theme <slug>` wrote it in 0.6. */
|
|
23
|
+
function entry(slug, overrides = {}) {
|
|
24
|
+
const identifier = slug.replace(/-([a-z0-9])/gu, (_, c) => c.toUpperCase());
|
|
25
|
+
const displayName = slug
|
|
26
|
+
.split('-')
|
|
27
|
+
.map(part => part[0].toUpperCase() + part.slice(1))
|
|
28
|
+
.join(' ');
|
|
29
|
+
return {
|
|
30
|
+
slug,
|
|
31
|
+
displayName,
|
|
32
|
+
description: `${displayName} theme.`,
|
|
33
|
+
maintained: true,
|
|
34
|
+
entry: `${identifier}Theme.ts`,
|
|
35
|
+
exportName: `${identifier}Theme`,
|
|
36
|
+
files: [`${identifier}Theme.ts`],
|
|
37
|
+
...overrides,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** @param {ReturnType<typeof entry>[]} themes */
|
|
42
|
+
function writeKit(themes, {sources = true} = {}) {
|
|
43
|
+
fs.writeFileSync(
|
|
44
|
+
path.join(root, 'package.json'),
|
|
45
|
+
'{"name":"@acme/kit","version":"1.0.0"}\n',
|
|
46
|
+
);
|
|
47
|
+
fs.writeFileSync(
|
|
48
|
+
path.join(root, 'astryx.integration.mjs'),
|
|
49
|
+
"export default {themes: './themes'};\n",
|
|
50
|
+
);
|
|
51
|
+
for (const theme of themes) {
|
|
52
|
+
const source = path.join(root, 'themes', theme.slug, theme.entry);
|
|
53
|
+
fs.mkdirSync(path.dirname(source), {recursive: true});
|
|
54
|
+
if (sources) {
|
|
55
|
+
fs.writeFileSync(
|
|
56
|
+
source,
|
|
57
|
+
`import {defineTheme} from '@astryxdesign/core/theme';\n\nexport const ${theme.exportName} = defineTheme({\n name: '${theme.slug}',\n});\n`,
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
fs.mkdirSync(path.join(root, 'themes'), {recursive: true});
|
|
62
|
+
fs.writeFileSync(
|
|
63
|
+
path.join(root, 'themes', 'manifest.json'),
|
|
64
|
+
`${JSON.stringify({version: 1, themes}, null, 2)}\n`,
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const catalog = () => path.join(root, 'themes', 'manifest.json');
|
|
69
|
+
|
|
70
|
+
/** @param {boolean} apply @param {string} [srcPath] */
|
|
71
|
+
const run = (apply, srcPath = root) =>
|
|
72
|
+
runCodemods([{version: 'next', transforms: manifest}], {
|
|
73
|
+
apply,
|
|
74
|
+
path: srcPath,
|
|
75
|
+
codemod: undefined,
|
|
76
|
+
silent: true,
|
|
77
|
+
root,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
describe('migrate-theme-catalog-to-descriptors', () => {
|
|
81
|
+
it('is staged for the next release as a project codemod', () => {
|
|
82
|
+
expect(manifest.map(t => [t.name, t.meta.codemodType])).toEqual([
|
|
83
|
+
['migrate-theme-catalog-to-descriptors', 'project'],
|
|
84
|
+
]);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('writes one typed descriptor per catalog theme and removes the catalog', async () => {
|
|
88
|
+
writeKit([
|
|
89
|
+
entry('ocean'),
|
|
90
|
+
entry('deep-sea', {
|
|
91
|
+
displayName: "Deep 'Sea'",
|
|
92
|
+
description: 'Line one\nline two \\ done.',
|
|
93
|
+
maintained: false,
|
|
94
|
+
}),
|
|
95
|
+
]);
|
|
96
|
+
|
|
97
|
+
const result = await run(true);
|
|
98
|
+
|
|
99
|
+
expect(result).toMatchObject({errors: [], totalFilesChanged: 3});
|
|
100
|
+
expect(fs.existsSync(catalog())).toBe(false);
|
|
101
|
+
expect(
|
|
102
|
+
fs.readFileSync(
|
|
103
|
+
path.join(root, 'themes/ocean/oceanTheme.doc.mjs'),
|
|
104
|
+
'utf-8',
|
|
105
|
+
),
|
|
106
|
+
).toBe(
|
|
107
|
+
"/** @type {import('@astryxdesign/cli/authoring').ThemeDoc} */\nexport default {\n type: 'theme',\n name: 'ocean',\n displayName: 'Ocean',\n description: 'Ocean theme.',\n maintained: true,\n};\n",
|
|
108
|
+
);
|
|
109
|
+
const themes = discoverThemeDirectory(
|
|
110
|
+
path.join(root, 'themes'),
|
|
111
|
+
'@acme/kit',
|
|
112
|
+
);
|
|
113
|
+
expect(
|
|
114
|
+
themes.map(({slug, displayName, description, maintained}) => ({
|
|
115
|
+
slug,
|
|
116
|
+
displayName,
|
|
117
|
+
description,
|
|
118
|
+
maintained,
|
|
119
|
+
})),
|
|
120
|
+
).toEqual([
|
|
121
|
+
{
|
|
122
|
+
slug: 'deep-sea',
|
|
123
|
+
displayName: "Deep 'Sea'",
|
|
124
|
+
description: 'Line one\nline two \\ done.',
|
|
125
|
+
maintained: false,
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
slug: 'ocean',
|
|
129
|
+
displayName: 'Ocean',
|
|
130
|
+
description: 'Ocean theme.',
|
|
131
|
+
maintained: true,
|
|
132
|
+
},
|
|
133
|
+
]);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it('previews without writing, even with no source folder', async () => {
|
|
137
|
+
writeKit([entry('ocean')]);
|
|
138
|
+
|
|
139
|
+
const result = await run(false, path.join(root, 'src'));
|
|
140
|
+
|
|
141
|
+
expect(result).toMatchObject({
|
|
142
|
+
errors: [],
|
|
143
|
+
totalFilesChanged: 2,
|
|
144
|
+
writtenFiles: [],
|
|
145
|
+
});
|
|
146
|
+
expect(fs.existsSync(catalog())).toBe(true);
|
|
147
|
+
expect(
|
|
148
|
+
fs.existsSync(path.join(root, 'themes/ocean/oceanTheme.doc.mjs')),
|
|
149
|
+
).toBe(false);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it('keeps a descriptor that already exists and still removes the catalog', async () => {
|
|
153
|
+
writeKit([entry('ocean'), entry('reef')]);
|
|
154
|
+
const kept = path.join(root, 'themes/ocean/oceanTheme.doc.mjs');
|
|
155
|
+
fs.writeFileSync(
|
|
156
|
+
kept,
|
|
157
|
+
"export default {type: 'theme', name: 'ocean', displayName: 'Mine', description: '', maintained: true};\n",
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
const result = await run(true);
|
|
161
|
+
|
|
162
|
+
expect(result.errors).toEqual([]);
|
|
163
|
+
expect(fs.readFileSync(kept, 'utf-8')).toContain("displayName: 'Mine'");
|
|
164
|
+
expect(
|
|
165
|
+
fs.existsSync(path.join(root, 'themes/reef/reefTheme.doc.mjs')),
|
|
166
|
+
).toBe(true);
|
|
167
|
+
expect(fs.existsSync(catalog())).toBe(false);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it('changes nothing and names each entry that cannot convert', async () => {
|
|
171
|
+
writeKit([
|
|
172
|
+
entry('ocean'),
|
|
173
|
+
entry('sea', {exportName: 'oceanBlue'}),
|
|
174
|
+
entry('nested', {
|
|
175
|
+
entry: 'src/nestedTheme.ts',
|
|
176
|
+
files: ['src/nestedTheme.ts'],
|
|
177
|
+
}),
|
|
178
|
+
]);
|
|
179
|
+
fs.rmSync(path.join(root, 'themes/ocean/oceanTheme.ts'));
|
|
180
|
+
const before = fs.readFileSync(catalog(), 'utf-8');
|
|
181
|
+
|
|
182
|
+
const result = await run(true);
|
|
183
|
+
|
|
184
|
+
expect(result.errors.map(e => [e.file, e.error])).toEqual([
|
|
185
|
+
['themes/ocean', 'holds no oceanTheme.ts for theme "ocean".'],
|
|
186
|
+
[
|
|
187
|
+
'themes/manifest.json',
|
|
188
|
+
'theme "sea" exports "oceanBlue" from seaTheme.ts; a descriptor takes the export name from the file name, so rename the export or the file to match.',
|
|
189
|
+
],
|
|
190
|
+
[
|
|
191
|
+
'themes/manifest.json',
|
|
192
|
+
'theme "nested" has entry "src/nestedTheme.ts"; a descriptor sits beside a .ts, .tsx, .mjs, or .js source directly in themes/nested/.',
|
|
193
|
+
],
|
|
194
|
+
]);
|
|
195
|
+
expect(fs.readFileSync(catalog(), 'utf-8')).toBe(before);
|
|
196
|
+
expect(fs.existsSync(path.join(root, 'themes/sea/seaTheme.doc.mjs'))).toBe(
|
|
197
|
+
false,
|
|
198
|
+
);
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
it('leaves a package with no catalog to convert alone', async () => {
|
|
202
|
+
const empty = {writes: [], deletes: [], problems: []};
|
|
203
|
+
await expect(migrate(root)).resolves.toEqual(empty);
|
|
204
|
+
fs.writeFileSync(
|
|
205
|
+
path.join(root, 'astryx.integration.mjs'),
|
|
206
|
+
'export default {};\n',
|
|
207
|
+
);
|
|
208
|
+
await expect(migrate(root)).resolves.toEqual(empty);
|
|
209
|
+
fs.writeFileSync(
|
|
210
|
+
path.join(root, 'astryx.integration.mjs'),
|
|
211
|
+
"export default {themes: './themes'};\n",
|
|
212
|
+
);
|
|
213
|
+
fs.mkdirSync(path.join(root, 'themes'));
|
|
214
|
+
await expect(migrate(root)).resolves.toEqual(empty);
|
|
215
|
+
});
|
|
216
|
+
});
|
|
@@ -7,4 +7,14 @@
|
|
|
7
7
|
* this file into the resolved version folder.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
import migrateThemeCatalogToDescriptors, {
|
|
11
|
+
meta as migrateThemeCatalogToDescriptorsMeta,
|
|
12
|
+
} from './migrate-theme-catalog-to-descriptors.mjs';
|
|
13
|
+
|
|
14
|
+
export default [
|
|
15
|
+
{
|
|
16
|
+
name: 'migrate-theme-catalog-to-descriptors',
|
|
17
|
+
transform: migrateThemeCatalogToDescriptors,
|
|
18
|
+
meta: migrateThemeCatalogToDescriptorsMeta,
|
|
19
|
+
},
|
|
20
|
+
];
|