@astryxdesign/cli 0.6.3-canary.98a2e4e → 0.6.3-canary.a00065f
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 +36 -2
- package/api/build/build.type.mjs +25 -4
- 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 +22 -11
- package/api/component/component.type.mjs +32 -24
- 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/discover/discover.type.d.mts +4 -4
- package/api/discover/discover.type.mjs +10 -10
- package/api/docs/_adapter.d.mts +28 -30
- package/api/docs/_adapter.mjs +73 -135
- package/api/docs/compiled-topics.test.mjs +78 -0
- package/api/docs/detail/detail.d.mts +0 -15
- package/api/docs/detail/detail.mjs +14 -78
- package/api/docs/detail/section/section.mjs +22 -18
- package/api/docs/detail/section/section.test.mjs +4 -3
- package/api/docs/docs.doc.mjs +1 -0
- package/api/docs/docs.type.d.mts +4 -4
- package/api/docs/docs.type.mjs +10 -10
- package/api/docs/index/index.mjs +6 -5
- 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 +186 -18
- 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/hook.type.d.mts +3 -3
- package/api/hook/hook.type.mjs +11 -11
- 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 +23 -10
- package/api/integration/add-contribution.test.mjs +121 -7
- 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.mjs +49 -7
- package/api/integration/pack-check.test.mjs +266 -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 +31 -14
- package/api/search/search.test.mjs +34 -0
- package/api/search/search.type.d.mts +1 -1
- package/api/search/search.type.mjs +1 -1
- package/api/swizzle/copy/copy.mjs +28 -11
- package/api/swizzle/swizzle.doc.mjs +2 -1
- package/api/swizzle/swizzle.type.d.mts +2 -2
- package/api/swizzle/swizzle.type.mjs +2 -2
- 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/template/template.type.d.mts +5 -5
- package/api/template/template.type.mjs +12 -12
- 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 +133 -42
- 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/build.test.mjs +127 -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 +8 -3
- package/api/theme/palette/generate/generate.test.mjs +96 -0
- package/api/theme/palette/generate/generator.d.mts +10 -13
- package/api/theme/palette/generate/generator.mjs +15 -4
- 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/theme.type.d.mts +170 -11
- package/api/theme/theme.type.mjs +94 -27
- 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 +8 -4
- package/api/upgrade/upgrade.type.mjs +11 -10
- package/assets/codemods/integration-discovery.mjs +48 -4
- package/assets/codemods/integration-discovery.test.mjs +73 -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.3.0/__tests__/unwrap-authoring-factories.test.mjs +27 -5
- package/assets/codemods/transforms/v0.3.0/unwrap-authoring-factories.mjs +20 -5
- 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 +26 -30
- package/assets/docs/cli.doc.mjs +15 -0
- package/assets/docs/styling-libraries.doc.mjs +1 -1
- package/assets/docs/theme.doc.mjs +1 -1
- package/assets/docs/working-with-ai.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/_shared/contract.ts +22 -0
- package/authoring/codemod/codemod.doc.mjs +7 -2
- package/authoring/codemod/parse.d.mts +8 -8
- package/authoring/codemod/parse.mjs +8 -6
- package/authoring/config/config.doc.mjs +2 -2
- package/authoring/config/debug-composition.test.mjs +92 -0
- package/authoring/config/parse.d.mts +13 -13
- package/authoring/config/parse.mjs +8 -8
- package/authoring/config/type.ts +18 -6
- package/authoring/debug/debug.doc.d.mts +11 -0
- package/authoring/debug/debug.doc.mjs +182 -0
- package/authoring/debug/parse.d.mts +4 -4
- package/authoring/debug/parse.mjs +3 -3
- package/authoring/doctypes/_schema.d.mts +121 -11
- package/authoring/doctypes/_schema.mjs +144 -13
- package/authoring/doctypes/base/graph-fields.doc.mjs +11 -4
- package/authoring/doctypes/base/type.ts +8 -4
- package/authoring/doctypes/command/command.doc.mjs +4 -3
- package/authoring/doctypes/command/parse.d.mts +2 -2
- package/authoring/doctypes/command/parse.mjs +1 -1
- package/authoring/doctypes/command/type.ts +3 -3
- package/authoring/doctypes/component/component.doc.mjs +5 -2
- package/authoring/doctypes/component/parse.d.mts +2 -2
- package/authoring/doctypes/component/parse.mjs +1 -1
- package/authoring/doctypes/component/type.ts +3 -3
- package/authoring/doctypes/doctypes-new.test.mjs +48 -6
- package/authoring/doctypes/enum/enum.doc.mjs +1 -1
- package/authoring/doctypes/enum/parse.d.mts +2 -2
- package/authoring/doctypes/enum/parse.mjs +1 -1
- package/authoring/doctypes/enum/type.ts +2 -2
- package/authoring/doctypes/function/function.doc.mjs +5 -1
- package/authoring/doctypes/function/parse.d.mts +2 -2
- package/authoring/doctypes/function/parse.mjs +1 -1
- package/authoring/doctypes/function/type.ts +2 -2
- package/authoring/doctypes/hook/hook.doc.mjs +4 -0
- package/authoring/doctypes/hook/parse.d.mts +2 -2
- package/authoring/doctypes/hook/parse.mjs +1 -1
- package/authoring/doctypes/hook/type.ts +3 -3
- package/authoring/doctypes/legacy.d.mts +6 -6
- package/authoring/doctypes/legacy.mjs +3 -3
- package/authoring/doctypes/load-contract.test.mjs +208 -0
- package/authoring/doctypes/namespace/namespace.doc.mjs +7 -3
- package/authoring/doctypes/namespace/parse.d.mts +2 -2
- package/authoring/doctypes/namespace/parse.mjs +1 -1
- package/authoring/doctypes/namespace/type.ts +2 -2
- package/authoring/doctypes/parse.d.mts +22 -20
- package/authoring/doctypes/parse.mjs +16 -12
- package/authoring/doctypes/reference/parse.d.mts +2 -2
- package/authoring/doctypes/reference/parse.mjs +1 -1
- package/authoring/doctypes/reference/reference.doc.mjs +7 -3
- package/authoring/doctypes/reference/type.ts +3 -3
- package/authoring/doctypes/schema/parse.d.mts +2 -2
- package/authoring/doctypes/schema/parse.mjs +1 -1
- package/authoring/doctypes/schema/schema.doc.mjs +1 -1
- package/authoring/doctypes/schema/type.ts +3 -4
- package/authoring/doctypes/template/parse.d.mts +92 -1
- package/authoring/doctypes/template/parse.mjs +33 -1
- package/authoring/doctypes/template/template.doc.mjs +7 -3
- package/authoring/doctypes/template/type.ts +4 -1
- 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 +12 -11
- package/authoring/gap-report/gap-report.doc.d.mts +12 -0
- package/authoring/gap-report/gap-report.doc.mjs +183 -0
- package/authoring/gap-report/parse.d.mts +9 -9
- package/authoring/gap-report/parse.mjs +6 -6
- package/authoring/gap-report/type.ts +1 -1
- package/authoring/identity/identity.doc.mjs +3 -2
- package/authoring/identity/type.ts +10 -10
- package/authoring/index.d.mts +1 -0
- package/authoring/index.d.ts +21 -19
- package/authoring/index.mjs +2 -1
- package/authoring/integration/integration.doc.mjs +2 -2
- package/authoring/integration/parse.d.mts +2 -2
- package/authoring/integration/parse.mjs +1 -1
- package/authoring/integration/schema.d.mts +4 -4
- package/authoring/integration/schema.mjs +3 -3
- package/authoring/integration/type.ts +4 -10
- 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-authoring.test.mjs +13 -9
- 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-self-docs.test.mjs +71 -12
- 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 +7 -2
- package/foundation/discovery/docs-discovery.mjs +24 -14
- package/foundation/discovery/docs-discovery.test.mjs +55 -16
- 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/discovery/theming-targets.test.mjs +4 -0
- 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 +362 -0
- package/foundation/doc-compiler/compile.mjs +511 -0
- 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 +714 -0
- 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 +22 -0
- package/foundation/doc-compiler/ir.mjs +464 -0
- package/foundation/doc-compiler/lenses.d.mts +33 -0
- package/foundation/doc-compiler/lenses.mjs +127 -0
- 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 -11
- 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
|
@@ -4,17 +4,17 @@
|
|
|
4
4
|
* @file Colocated types for the `upgrade` command — source of truth for the
|
|
5
5
|
* upgrade command JSON responses. Re-exported by `types/upgrade.d.ts`.
|
|
6
6
|
*
|
|
7
|
-
* Invocation
|
|
7
|
+
* Invocation -> type discriminator
|
|
8
8
|
* ------------------------------------------------------------------
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* (version detection failure)
|
|
9
|
+
* astryx --json upgrade --list -> upgrade.list
|
|
10
|
+
* astryx --json upgrade [--apply] -> upgrade.run
|
|
11
|
+
* astryx --json upgrade --registry [--apply] -> upgrade.registry
|
|
12
|
+
* astryx --json upgrade (status short-circuit) -> upgrade.status
|
|
13
|
+
* (version detection failure) -> CLIError
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* astryx --json upgrade --list
|
|
18
18
|
* @typedef {object} UpgradeListResponse
|
|
19
19
|
* @property {'upgrade.list'} type
|
|
20
20
|
* @property {UpgradeListEntry[]} data
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
* @property {string} name
|
|
26
26
|
* @property {string} title
|
|
27
27
|
* @property {string} version
|
|
28
|
+
* @property {boolean} optional True when the codemod runs only if named with `--codemod`.
|
|
28
29
|
*/
|
|
29
30
|
|
|
30
31
|
/**
|
|
@@ -88,14 +89,14 @@
|
|
|
88
89
|
*/
|
|
89
90
|
|
|
90
91
|
/**
|
|
91
|
-
*
|
|
92
|
+
* astryx --json upgrade --registry [--apply]
|
|
92
93
|
* @typedef {object} UpgradeRegistryResponse
|
|
93
94
|
* @property {'upgrade.registry'} type
|
|
94
95
|
* @property {RegistryCompositionSummary} data
|
|
95
96
|
*/
|
|
96
97
|
|
|
97
98
|
/**
|
|
98
|
-
*
|
|
99
|
+
* astryx --json upgrade [--apply]
|
|
99
100
|
* @typedef {object} UpgradeRunResponse
|
|
100
101
|
* @property {'upgrade.run'} type
|
|
101
102
|
* @property {object} data
|
|
@@ -112,7 +113,7 @@
|
|
|
112
113
|
*/
|
|
113
114
|
|
|
114
115
|
/**
|
|
115
|
-
*
|
|
116
|
+
* astryx --json upgrade — short-circuit status results.
|
|
116
117
|
*
|
|
117
118
|
* - `up_to_date`: `--from` is >= installed target and `--force` was not passed.
|
|
118
119
|
* - `no_codemods`: no codemods (core or integration) apply to the range.
|
|
@@ -32,6 +32,40 @@ import {semverCompare} from '../../foundation/env/semver.mjs';
|
|
|
32
32
|
/** File extensions recognized as codemod modules. */
|
|
33
33
|
const CODEMOD_EXTENSIONS = ['.ts', '.mjs', '.js'];
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Directories never walked for codemods: a test directory beside a transform is
|
|
37
|
+
* the natural place to put its test, and every file found here is loaded and
|
|
38
|
+
* validated as a codemod.
|
|
39
|
+
*/
|
|
40
|
+
const SKIP_DIRS = new Set([
|
|
41
|
+
'node_modules',
|
|
42
|
+
'.git',
|
|
43
|
+
'__tests__',
|
|
44
|
+
'__fixtures__',
|
|
45
|
+
]);
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Whether a file name is a test or fixture rather than a codemod.
|
|
49
|
+
*
|
|
50
|
+
* The trap this closes: EVERY `.ts`/`.mjs`/`.js` under a version folder used to
|
|
51
|
+
* be loaded as a codemod, so a test file colocated with its transform failed
|
|
52
|
+
* validation and — because a definition error is a hard error — took every
|
|
53
|
+
* codemod in that package's version with it. `astryx upgrade` then applied no
|
|
54
|
+
* transforms and reported success, which is the worst shape a failure can take.
|
|
55
|
+
*
|
|
56
|
+
* Core's own codemods never hit this: they are enumerated in a registry, and
|
|
57
|
+
* their colocated tests are simply not in it. Only integrations are discovered
|
|
58
|
+
* by walking a directory, so only integrations carry the landmine — which is why
|
|
59
|
+
* this is a loader fix and not a documentation one. It protects the integrations
|
|
60
|
+
* that already exist, which no authoring tool can reach.
|
|
61
|
+
*
|
|
62
|
+
* @param {string} name a file's base name
|
|
63
|
+
* @returns {boolean}
|
|
64
|
+
*/
|
|
65
|
+
function isTestFile(name) {
|
|
66
|
+
return /\.(test|spec)\.[^.]+$/.test(name) || /\.fixture\.[^.]+$/.test(name);
|
|
67
|
+
}
|
|
68
|
+
|
|
35
69
|
/**
|
|
36
70
|
* Recursively collect codemod module files under a version folder. Returns
|
|
37
71
|
* entries of {id, file} where id is the extension-less relative path
|
|
@@ -49,14 +83,18 @@ function collectCodemodFiles(versionDir) {
|
|
|
49
83
|
for (const entry of entries) {
|
|
50
84
|
const full = path.join(dir, entry.name);
|
|
51
85
|
if (entry.isDirectory()) {
|
|
52
|
-
if (
|
|
86
|
+
if (SKIP_DIRS.has(entry.name)) continue;
|
|
53
87
|
walk(full);
|
|
54
88
|
continue;
|
|
55
89
|
}
|
|
56
90
|
const ext = path.extname(entry.name);
|
|
57
91
|
if (!CODEMOD_EXTENSIONS.includes(ext)) continue;
|
|
92
|
+
if (isTestFile(entry.name)) continue;
|
|
58
93
|
const rel = path.relative(versionDir, full);
|
|
59
|
-
const id = rel
|
|
94
|
+
const id = rel
|
|
95
|
+
.slice(0, rel.length - ext.length)
|
|
96
|
+
.split(path.sep)
|
|
97
|
+
.join('/');
|
|
60
98
|
out.push({id, file: full});
|
|
61
99
|
}
|
|
62
100
|
}
|
|
@@ -68,7 +106,7 @@ function collectCodemodFiles(versionDir) {
|
|
|
68
106
|
/**
|
|
69
107
|
* Discover file-based codemods contributed by configured integrations.
|
|
70
108
|
*
|
|
71
|
-
* @param {Array<{name?: string, codemods?: string, __spec?: string}>} loadedIntegrations
|
|
109
|
+
* @param {Array<{name?: string, codemods?: string, __spec?: string, __packageDir?: string}>} loadedIntegrations
|
|
72
110
|
* @returns {Promise<Map<string, Array<{id: string, type: 'code'|'config', codemod: object, package: string}>>>}
|
|
73
111
|
* Map keyed by version string; each value is the list of discovered codemods
|
|
74
112
|
* for that version (across all integrations).
|
|
@@ -107,7 +145,13 @@ export async function discoverIntegrationCodemods(loadedIntegrations = []) {
|
|
|
107
145
|
const seenInVersion = new Set();
|
|
108
146
|
|
|
109
147
|
for (const {id, file} of files) {
|
|
110
|
-
const
|
|
148
|
+
const shown = integration.__packageDir
|
|
149
|
+
? path
|
|
150
|
+
.relative(integration.__packageDir, file)
|
|
151
|
+
.split(path.sep)
|
|
152
|
+
.join('/')
|
|
153
|
+
: file;
|
|
154
|
+
const label = `Integration "${pkgLabel}" codemod ${version}/${id} (${shown})`;
|
|
111
155
|
|
|
112
156
|
if (seenInVersion.has(id)) {
|
|
113
157
|
throw new Error(
|
|
@@ -163,6 +163,21 @@ describe('integration codemod discovery', () => {
|
|
|
163
163
|
).rejects.toThrow(/is invalid/i);
|
|
164
164
|
});
|
|
165
165
|
|
|
166
|
+
it('names a broken codemod by its path inside the package', async () => {
|
|
167
|
+
scaffold({
|
|
168
|
+
'1.1.0/no-default.mjs': `export const nope = 1;\n`,
|
|
169
|
+
});
|
|
170
|
+
const project = await Project.load(tmpDir);
|
|
171
|
+
const failure = await discoverIntegrationCodemods(
|
|
172
|
+
project.loadedIntegrations,
|
|
173
|
+
).then(
|
|
174
|
+
() => null,
|
|
175
|
+
error => error,
|
|
176
|
+
);
|
|
177
|
+
expect(failure?.message).toContain('(codemods/1.1.0/no-default.mjs)');
|
|
178
|
+
expect(failure?.message).not.toContain(tmpDir);
|
|
179
|
+
});
|
|
180
|
+
|
|
166
181
|
it('fails discovery when default export is not a codemod envelope', async () => {
|
|
167
182
|
scaffold({
|
|
168
183
|
'0.2.0/bad.mjs': `export default { title: 'x', transform: () => null };\n`,
|
|
@@ -221,3 +236,61 @@ describe('integration codemod discovery', () => {
|
|
|
221
236
|
).rejects.toThrow(/across versions/i);
|
|
222
237
|
});
|
|
223
238
|
});
|
|
239
|
+
|
|
240
|
+
describe('test files beside a codemod', () => {
|
|
241
|
+
// The incident this closes: every .ts/.mjs/.js under a version folder was
|
|
242
|
+
// loaded AND VALIDATED as a codemod, so a test file colocated with its
|
|
243
|
+
// transform failed validation — and because a definition error is a hard
|
|
244
|
+
// error, it took every codemod in that version with it. `astryx upgrade`
|
|
245
|
+
// then applied nothing and reported success. Core is immune because its own
|
|
246
|
+
// codemods are enumerated in a registry rather than discovered by walking a
|
|
247
|
+
// directory, so its colocated tests are simply never visited. Only
|
|
248
|
+
// integrations carry the landmine.
|
|
249
|
+
const TRANSFORM = `
|
|
250
|
+
export default {
|
|
251
|
+
type: 'code',
|
|
252
|
+
title: 'Drop foo',
|
|
253
|
+
transform: (file) => file.source.replace(/foo/g, 'bar'),
|
|
254
|
+
};
|
|
255
|
+
`;
|
|
256
|
+
// Not a codemod: no default export of the right shape. Loading it throws.
|
|
257
|
+
const A_TEST = `
|
|
258
|
+
import {describe, it, expect} from 'vitest';
|
|
259
|
+
describe('drop-foo', () => {
|
|
260
|
+
it('drops foo', () => expect(1).toBe(1));
|
|
261
|
+
});
|
|
262
|
+
`;
|
|
263
|
+
|
|
264
|
+
it.each([
|
|
265
|
+
['a .test. sibling', '0.2.0/drop-foo.test.mjs'],
|
|
266
|
+
['a .spec. sibling', '0.2.0/drop-foo.spec.mjs'],
|
|
267
|
+
['a fixture sibling', '0.2.0/drop-foo.fixture.mjs'],
|
|
268
|
+
['a __tests__ directory', '0.2.0/__tests__/drop-foo.mjs'],
|
|
269
|
+
['a __fixtures__ directory', '0.2.0/__fixtures__/input.mjs'],
|
|
270
|
+
])('ignores %s and still discovers the codemod', async (_label, testPath) => {
|
|
271
|
+
scaffold({'0.2.0/drop-foo.mjs': TRANSFORM, [testPath]: A_TEST});
|
|
272
|
+
|
|
273
|
+
const project = await Project.load(tmpDir);
|
|
274
|
+
const byVersion = await discoverIntegrationCodemods(
|
|
275
|
+
project.loadedIntegrations,
|
|
276
|
+
);
|
|
277
|
+
|
|
278
|
+
expect([...byVersion.keys()]).toEqual(['0.2.0']);
|
|
279
|
+
expect(byVersion.get('0.2.0').map(entry => entry.id)).toEqual(['drop-foo']);
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
it('a nested helper directory is still walked', async () => {
|
|
283
|
+
// Only test and fixture names are skipped. A package that organises its
|
|
284
|
+
// transforms into subdirectories keeps working.
|
|
285
|
+
scaffold({'0.2.0/imports/drop-foo.mjs': TRANSFORM});
|
|
286
|
+
|
|
287
|
+
const project = await Project.load(tmpDir);
|
|
288
|
+
const byVersion = await discoverIntegrationCodemods(
|
|
289
|
+
project.loadedIntegrations,
|
|
290
|
+
);
|
|
291
|
+
|
|
292
|
+
expect(byVersion.get('0.2.0').map(entry => entry.id)).toEqual([
|
|
293
|
+
'imports/drop-foo',
|
|
294
|
+
]);
|
|
295
|
+
});
|
|
296
|
+
});
|
|
@@ -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
|
+
});
|