@astryxdesign/cli 0.6.3-canary.ea2f048 → 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 -72
- 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 +32 -24
- package/api/docs/_adapter.mjs +81 -87
- package/api/docs/compiled-topics.test.mjs +78 -0
- package/api/docs/detail/detail.mjs +14 -63
- package/api/docs/detail/section/section.d.mts +1 -1
- package/api/docs/detail/section/section.mjs +44 -20
- package/api/docs/detail/section/section.test.mjs +41 -0
- package/api/docs/docs.d.mts +7 -2
- package/api/docs/docs.doc.mjs +28 -10
- package/api/docs/docs.mjs +16 -9
- package/api/docs/docs.test.mjs +6 -0
- package/api/docs/docs.type.d.mts +40 -3
- package/api/docs/docs.type.mjs +36 -8
- package/api/docs/index/index.d.mts +18 -0
- package/api/docs/index/index.mjs +32 -0
- package/api/docs/index/index.test.mjs +62 -0
- package/api/docs/integrationDocs.test.mjs +106 -0
- package/api/docs/list/list.mjs +3 -7
- package/api/doctor/doctor.d.mts +70 -0
- package/api/doctor/doctor.doc.mjs +1 -0
- package/api/doctor/doctor.mjs +404 -0
- package/api/doctor/doctor.test.mjs +522 -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 +2 -2
- 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-authoring.type.d.mts +1 -1
- 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 +3 -10
- 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 +2 -2
- 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.d.mts +1 -1
- package/api/template/template.doc.mjs +3 -1
- package/api/template/template.type.d.mts +6 -6
- 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 +123 -19
- package/api/upgrade/list/list.mjs +2 -1
- package/api/upgrade/list/list.test.mjs +73 -0
- package/api/upgrade/project-context.test.mjs +272 -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 +7 -4
- package/api/upgrade/upgrade.type.d.mts +9 -5
- package/api/upgrade/upgrade.type.mjs +12 -11
- 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/README.md +9 -0
- package/assets/docs/authoring.doc.mjs +14 -0
- package/assets/docs/cli-integrations.doc.mjs +78 -20
- 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 +5 -5
- package/authoring/debug/parse.mjs +3 -3
- package/authoring/doctypes/_schema.d.mts +788 -23
- package/authoring/doctypes/_schema.mjs +492 -39
- package/authoring/doctypes/base/graph-fields.doc.d.mts +9 -0
- package/authoring/doctypes/base/graph-fields.doc.mjs +62 -0
- package/authoring/doctypes/base/type.ts +40 -0
- 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 +4 -3
- package/authoring/doctypes/component/component.doc.mjs +6 -3
- package/authoring/doctypes/component/parse.d.mts +2 -2
- package/authoring/doctypes/component/parse.mjs +1 -1
- package/authoring/doctypes/component/type.ts +6 -5
- 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 +4 -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 +7 -3
- 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 +5 -4
- package/authoring/doctypes/legacy.d.mts +8 -6
- package/authoring/doctypes/legacy.mjs +5 -4
- package/authoring/doctypes/load-contract.test.mjs +208 -0
- package/authoring/doctypes/namespace/namespace.doc.d.mts +9 -0
- package/authoring/doctypes/namespace/namespace.doc.mjs +132 -0
- package/authoring/doctypes/namespace/parse.d.mts +12 -0
- package/authoring/doctypes/namespace/parse.mjs +25 -0
- package/authoring/doctypes/namespace/parse.test.mjs +165 -0
- package/authoring/doctypes/namespace/type.ts +71 -0
- package/authoring/doctypes/parse.d.mts +22 -18
- package/authoring/doctypes/parse.mjs +22 -12
- package/authoring/doctypes/parse.test.mjs +77 -3
- package/authoring/doctypes/reference/parse.d.mts +2 -2
- package/authoring/doctypes/reference/parse.mjs +8 -5
- package/authoring/doctypes/reference/reference.doc.mjs +18 -5
- package/authoring/doctypes/reference/type.ts +53 -7
- 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 +4 -4
- package/authoring/doctypes/template/parse.d.mts +92 -1
- package/authoring/doctypes/template/parse.mjs +36 -2
- package/authoring/doctypes/template/parse.test.mjs +8 -2
- package/authoring/doctypes/template/template.doc.mjs +7 -3
- package/authoring/doctypes/template/type.ts +5 -2
- 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 -10
- 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 +10 -10
- package/authoring/gap-report/parse.mjs +6 -6
- package/authoring/gap-report/type.ts +1 -1
- package/authoring/identity/identity.doc.d.mts +9 -0
- package/authoring/identity/identity.doc.mjs +61 -0
- package/authoring/identity/type.ts +132 -0
- package/authoring/index.d.mts +2 -0
- package/authoring/index.d.ts +51 -17
- package/authoring/index.mjs +3 -1
- package/authoring/integration/integration.doc.mjs +15 -8
- package/authoring/integration/parse.d.mts +2 -2
- package/authoring/integration/parse.mjs +1 -1
- package/authoring/integration/parse.test.mjs +10 -1
- package/authoring/integration/schema.d.mts +6 -4
- package/authoring/integration/schema.mjs +9 -3
- package/authoring/integration/type.ts +18 -7
- package/authoring/shadcn/receipt.d.mts +6 -6
- 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 +14 -4
- package/clients/cli/commands/docs.mjs +121 -21
- package/clients/cli/commands/docs.test.mjs +88 -0
- 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 +9 -5
- 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 +20 -9
- 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/formatters/index.mjs +162 -1
- package/clients/cli/formatters/index.test.mjs +91 -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 +29 -2
- 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 +190 -32
- package/foundation/config/project.test.mjs +129 -16
- package/foundation/discovery/authoring-self-docs.d.mts +75 -0
- package/foundation/discovery/authoring-self-docs.mjs +224 -0
- package/foundation/discovery/authoring-self-docs.test.mjs +154 -0
- 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-discovery.d.mts +1 -1
- package/foundation/discovery/component-discovery.mjs +2 -1
- package/foundation/discovery/component-loader.d.mts +35 -38
- package/foundation/discovery/component-loader.mjs +53 -222
- package/foundation/discovery/docs-discovery.d.mts +12 -4
- package/foundation/discovery/docs-discovery.mjs +214 -98
- package/foundation/discovery/docs-discovery.test.mjs +284 -15
- package/foundation/discovery/docs-output-budget.d.mts +28 -0
- package/foundation/discovery/docs-output-budget.mjs +50 -0
- package/foundation/discovery/docs-section-key.d.mts +98 -0
- package/foundation/discovery/docs-section-key.mjs +221 -0
- package/foundation/discovery/docs-section-key.test.mjs +224 -0
- 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 +321 -66
- 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/identity/provider-identity.d.mts +90 -0
- package/foundation/identity/provider-identity.mjs +320 -0
- package/foundation/identity/provider-identity.test.mjs +254 -0
- package/foundation/identity/providers.d.mts +7 -0
- package/foundation/identity/providers.mjs +16 -0
- package/foundation/integrations/autolink.d.mts +58 -1
- package/foundation/integrations/autolink.mjs +143 -45
- 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/integration-warnings.mjs +6 -0
- package/foundation/integrations/integrations.d.mts +49 -2
- package/foundation/integrations/integrations.mjs +81 -8
- package/foundation/integrations/integrations.test.mjs +384 -1
- package/foundation/integrations/provider-conflicts.test.mjs +125 -0
- 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.d.mts +2 -0
- package/foundation/integrations/validate-contributions.mjs +114 -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 +57 -17
- package/foundation/response/json.d.mts +4 -2
- package/foundation/response/json.mjs +8 -10
- package/foundation/response/response-types.doc.mjs +16 -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
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Where `upgrade` and Project still disagree on a provider ID's winner.
|
|
5
|
+
*
|
|
6
|
+
* Both repros are `it.fails`: each asserts the agreeing result, and fails
|
|
7
|
+
* today. `upgrade` lets an `--integration` extra of the same name@version stand
|
|
8
|
+
* in for an autolinked package, from any directory, and orders that extra with
|
|
9
|
+
* the extras. So another extra can take the provider ID in `upgrade` while
|
|
10
|
+
* every other command gives it to the autolinked package. The provider ledger
|
|
11
|
+
* property test carves out exactly this shape.
|
|
12
|
+
*
|
|
13
|
+
* Fixtures live under a repo-local temp dir, not /tmp, because Vite refuses to
|
|
14
|
+
* dynamically import a module from outside the project root.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import {afterEach, beforeEach, describe, expect, it} from 'vitest';
|
|
18
|
+
import * as fs from 'node:fs';
|
|
19
|
+
import * as path from 'node:path';
|
|
20
|
+
import {loadProjectContext} from './_adapter.mjs';
|
|
21
|
+
import {Project, providerLedgerOf} from '../../foundation/config/project.mjs';
|
|
22
|
+
|
|
23
|
+
let tmpDir;
|
|
24
|
+
let originalCwd;
|
|
25
|
+
|
|
26
|
+
beforeEach(() => {
|
|
27
|
+
originalCwd = process.cwd();
|
|
28
|
+
tmpDir = fs.mkdtempSync(
|
|
29
|
+
path.join(process.cwd(), '.astryx-upgrade-agreement-'),
|
|
30
|
+
);
|
|
31
|
+
process.chdir(tmpDir);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
afterEach(() => {
|
|
35
|
+
process.chdir(originalCwd);
|
|
36
|
+
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Install a package under node_modules/<dir>.
|
|
41
|
+
* @param {string} dir
|
|
42
|
+
* @param {{name: string, version: string}} pkg
|
|
43
|
+
* @param {string} manifest manifest module source
|
|
44
|
+
*/
|
|
45
|
+
function install(dir, pkg, manifest) {
|
|
46
|
+
const pkgDir = path.join(tmpDir, 'node_modules', ...dir.split('/'));
|
|
47
|
+
fs.mkdirSync(pkgDir, {recursive: true});
|
|
48
|
+
fs.writeFileSync(path.join(pkgDir, 'package.json'), JSON.stringify(pkg));
|
|
49
|
+
fs.writeFileSync(path.join(pkgDir, 'astryx.integration.mjs'), manifest);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** An autolinked `@acme/a` and an `@acme/other` that claims its provider ID. */
|
|
53
|
+
function autolinkedWithRival() {
|
|
54
|
+
fs.writeFileSync(
|
|
55
|
+
path.join(tmpDir, 'package.json'),
|
|
56
|
+
JSON.stringify({name: 'consumer', dependencies: {'@acme/a': '1.0.0'}}),
|
|
57
|
+
);
|
|
58
|
+
install(
|
|
59
|
+
'@acme/a',
|
|
60
|
+
{name: '@acme/a', version: '1.0.0'},
|
|
61
|
+
'export default {};\n',
|
|
62
|
+
);
|
|
63
|
+
install(
|
|
64
|
+
'@acme/other',
|
|
65
|
+
{name: '@acme/other', version: '1.0.0'},
|
|
66
|
+
"export default {providerId: '@acme/a'};\n",
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The package each resolution lets contribute under a provider ID.
|
|
72
|
+
* @param {Map<string, any>} ledger
|
|
73
|
+
* @param {string} providerId
|
|
74
|
+
*/
|
|
75
|
+
function winnerOf(ledger, providerId) {
|
|
76
|
+
return [...ledger.values()].find(
|
|
77
|
+
entry => entry.outcome === 'contributes' && entry.providerId === providerId,
|
|
78
|
+
)?.key;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** @param {Array<import('../../foundation/integrations/integrations.mjs').LoadedIntegration>} integrations */
|
|
82
|
+
function claims(integrations) {
|
|
83
|
+
return integrations.map(integration => [
|
|
84
|
+
integration.name,
|
|
85
|
+
integration.__providerConflict?.claimedBy ?? null,
|
|
86
|
+
]);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
describe('upgrade and Project on an autolinked package named with --integration', () => {
|
|
90
|
+
it('agree when the autolinked package is named first', async () => {
|
|
91
|
+
autolinkedWithRival();
|
|
92
|
+
const project = await Project.load(tmpDir, {fresh: true});
|
|
93
|
+
const upgrade = await loadProjectContext(tmpDir, [
|
|
94
|
+
'@acme/a',
|
|
95
|
+
'@acme/other',
|
|
96
|
+
]);
|
|
97
|
+
|
|
98
|
+
expect(claims(upgrade.integrations)).toEqual([
|
|
99
|
+
['@acme/a', null],
|
|
100
|
+
['@acme/other', '@acme/a'],
|
|
101
|
+
]);
|
|
102
|
+
expect(winnerOf(upgrade.ledger, '@acme/a')).toBe(
|
|
103
|
+
winnerOf(providerLedgerOf(project), '@acme/a'),
|
|
104
|
+
);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it.fails(
|
|
108
|
+
'agree when an extra that claims its ID is named first',
|
|
109
|
+
async () => {
|
|
110
|
+
autolinkedWithRival();
|
|
111
|
+
const project = await Project.load(tmpDir, {fresh: true});
|
|
112
|
+
// Today upgrade runs @acme/other and reports @acme/a, which every other
|
|
113
|
+
// command uses, as contributing nothing.
|
|
114
|
+
const upgrade = await loadProjectContext(tmpDir, [
|
|
115
|
+
'@acme/other',
|
|
116
|
+
'@acme/a',
|
|
117
|
+
]);
|
|
118
|
+
|
|
119
|
+
expect(winnerOf(upgrade.ledger, '@acme/a')).toBe(
|
|
120
|
+
winnerOf(providerLedgerOf(project), '@acme/a'),
|
|
121
|
+
);
|
|
122
|
+
expect(claims(upgrade.integrations)).toEqual([
|
|
123
|
+
['@acme/other', '@acme/a'],
|
|
124
|
+
['@acme/a', null],
|
|
125
|
+
]);
|
|
126
|
+
},
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
it.fails(
|
|
130
|
+
'agree when a copy of it in another directory is named',
|
|
131
|
+
async () => {
|
|
132
|
+
autolinkedWithRival();
|
|
133
|
+
// The same name@version in another directory, with a manifest that fails.
|
|
134
|
+
install(
|
|
135
|
+
'@acme/a-copy',
|
|
136
|
+
{name: '@acme/a', version: '1.0.0'},
|
|
137
|
+
"throw new Error('broken copy');\n",
|
|
138
|
+
);
|
|
139
|
+
const project = await Project.load(tmpDir, {fresh: true});
|
|
140
|
+
// Today the broken copy stands in for @acme/a by name@version, so upgrade
|
|
141
|
+
// has no claimant left for the ID and @acme/other takes it.
|
|
142
|
+
const upgrade = await loadProjectContext(tmpDir, [
|
|
143
|
+
'@acme/a-copy',
|
|
144
|
+
'@acme/other',
|
|
145
|
+
]);
|
|
146
|
+
|
|
147
|
+
expect(winnerOf(upgrade.ledger, '@acme/a')).toBe(
|
|
148
|
+
winnerOf(providerLedgerOf(project), '@acme/a'),
|
|
149
|
+
);
|
|
150
|
+
},
|
|
151
|
+
);
|
|
152
|
+
});
|
package/api/upgrade/run/run.mjs
CHANGED
|
@@ -171,6 +171,7 @@ export async function run(options = {}, {cwd = process.cwd()} = {}) {
|
|
|
171
171
|
path: path_,
|
|
172
172
|
codemod: options.codemod,
|
|
173
173
|
skipCodemods,
|
|
174
|
+
root: cwd,
|
|
174
175
|
});
|
|
175
176
|
const coreResult = codemodResult && 'totalFilesChanged' in codemodResult ? codemodResult : null;
|
|
176
177
|
|
|
@@ -24,7 +24,7 @@ import {logger} from '../../logger.mjs';
|
|
|
24
24
|
* @returns {import('../upgrade.type.mjs').UpgradeStatusResponse}
|
|
25
25
|
*/
|
|
26
26
|
export function statusUpToDate({from, to, agentDocs, registryCompositions}) {
|
|
27
|
-
logger.log('
|
|
27
|
+
logger.log('[ok] Already up to date - no codemods to run.');
|
|
28
28
|
logger.log('Use --force to run codemods anyway.');
|
|
29
29
|
logger.log(registryCompositions?.ok === false ? 'Finished with unresolved registry items\n' : 'Done\n');
|
|
30
30
|
return {
|
|
@@ -45,7 +45,7 @@ export function statusUpToDate({from, to, agentDocs, registryCompositions}) {
|
|
|
45
45
|
* @returns {import('../upgrade.type.mjs').UpgradeStatusResponse}
|
|
46
46
|
*/
|
|
47
47
|
export function statusNoCodemods({from, to, agentDocs, registryCompositions}) {
|
|
48
|
-
logger.log('
|
|
48
|
+
logger.log('[ok] No codemods available for this version range.');
|
|
49
49
|
logger.log(registryCompositions?.ok === false ? 'Finished with unresolved registry items\n' : 'Done\n');
|
|
50
50
|
return {
|
|
51
51
|
type: 'upgrade.status',
|
|
@@ -11,13 +11,15 @@ export const doc = {
|
|
|
11
11
|
type: 'function',
|
|
12
12
|
kind: 'api',
|
|
13
13
|
name: 'upgrade',
|
|
14
|
+
namespace: 'cli/api',
|
|
14
15
|
displayName: 'upgrade()',
|
|
15
16
|
summary: 'Run version migrations and reconcile copied compositions.',
|
|
16
17
|
description:
|
|
17
18
|
'Migrates project source from a previous Astryx version to the currently ' +
|
|
18
19
|
'installed one by running the registered codemods, and compares the fully ' +
|
|
19
|
-
'rendered managed agent-docs block on every path, including
|
|
20
|
-
'integration guidance changes
|
|
20
|
+
'rendered managed agent-docs block on every migration path, including ' +
|
|
21
|
+
'same-Core integration guidance changes; list and registry-only modes do not ' +
|
|
22
|
+
'run migration reconciliation. Dry-run previews without writing; `apply` ' +
|
|
21
23
|
'writes the prepared block only after selected codemods and hooks succeed. ' +
|
|
22
24
|
'Core codemods run before ' +
|
|
23
25
|
'the config is loaded so a config codemod can repair an otherwise-invalid ' +
|
|
@@ -68,7 +70,7 @@ export const doc = {
|
|
|
68
70
|
name: 'options.integration',
|
|
69
71
|
type: 'string[]',
|
|
70
72
|
description:
|
|
71
|
-
'Explicit integration
|
|
73
|
+
'Explicit integration specifiers to process. Resolved beneath node_modules; absolute paths and `.` or `..` segments are rejected.',
|
|
72
74
|
},
|
|
73
75
|
{
|
|
74
76
|
name: 'options.path',
|
|
@@ -79,7 +81,8 @@ export const doc = {
|
|
|
79
81
|
{
|
|
80
82
|
name: 'options.installDeps',
|
|
81
83
|
type: 'boolean',
|
|
82
|
-
description:
|
|
84
|
+
description:
|
|
85
|
+
'Install jscodeshift when it is missing; otherwise a missing jscodeshift throws ERR_DEP_MISSING.',
|
|
83
86
|
},
|
|
84
87
|
{
|
|
85
88
|
name: 'options.registry',
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* astryx --json upgrade --list
|
|
6
6
|
*/
|
|
7
7
|
export type UpgradeListResponse = {
|
|
8
8
|
type: "upgrade.list";
|
|
@@ -12,6 +12,10 @@ export type UpgradeListEntry = {
|
|
|
12
12
|
name: string;
|
|
13
13
|
title: string;
|
|
14
14
|
version: string;
|
|
15
|
+
/**
|
|
16
|
+
* True when the codemod runs only if named with `--codemod`.
|
|
17
|
+
*/
|
|
18
|
+
optional: boolean;
|
|
15
19
|
};
|
|
16
20
|
/**
|
|
17
21
|
* State of the managed agent-docs block (`<!-- ASTRYX:START --> … END -->`)
|
|
@@ -121,14 +125,14 @@ export type RegistryCompositionSummary = {
|
|
|
121
125
|
items: RegistryCompositionItemSummary[];
|
|
122
126
|
};
|
|
123
127
|
/**
|
|
124
|
-
*
|
|
128
|
+
* astryx --json upgrade --registry [--apply]
|
|
125
129
|
*/
|
|
126
130
|
export type UpgradeRegistryResponse = {
|
|
127
131
|
type: "upgrade.registry";
|
|
128
132
|
data: RegistryCompositionSummary;
|
|
129
133
|
};
|
|
130
134
|
/**
|
|
131
|
-
*
|
|
135
|
+
* astryx --json upgrade [--apply]
|
|
132
136
|
*/
|
|
133
137
|
export type UpgradeRunResponse = {
|
|
134
138
|
type: "upgrade.run";
|
|
@@ -150,7 +154,7 @@ export type UpgradeRunResponse = {
|
|
|
150
154
|
};
|
|
151
155
|
};
|
|
152
156
|
/**
|
|
153
|
-
*
|
|
157
|
+
* astryx --json upgrade — short-circuit status results.
|
|
154
158
|
*
|
|
155
159
|
* - `up_to_date`: `--from` is >= installed target and `--force` was not passed.
|
|
156
160
|
* - `no_codemods`: no codemods (core or integration) apply to the range.
|
|
@@ -211,7 +215,7 @@ export type UpgradeOptions = {
|
|
|
211
215
|
*/
|
|
212
216
|
skipCodemod?: string[] | undefined;
|
|
213
217
|
/**
|
|
214
|
-
* Explicit integration
|
|
218
|
+
* Explicit integration specifiers resolved beneath node_modules; absolute paths and `.` or `..` segments are rejected.
|
|
215
219
|
*/
|
|
216
220
|
integration?: string[] | undefined;
|
|
217
221
|
/**
|
|
@@ -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.
|
|
@@ -135,7 +136,7 @@
|
|
|
135
136
|
* @property {boolean} [force] Run codemods even if `from` >= installed.
|
|
136
137
|
* @property {string} [codemod] Run a single named transform.
|
|
137
138
|
* @property {string[]} [skipCodemod] Exclude named codemods (re-run past a failure).
|
|
138
|
-
* @property {string[]} [integration] Explicit integration
|
|
139
|
+
* @property {string[]} [integration] Explicit integration specifiers resolved beneath node_modules; absolute paths and `.` or `..` segments are rejected.
|
|
139
140
|
* @property {string} [path] Source directory to scan (default `./src`).
|
|
140
141
|
* @property {boolean} [installDeps] Auto-install jscodeshift without prompting.
|
|
141
142
|
* @property {boolean} [registry] Reconcile only ShadCN-copied compositions; `from` is not required.
|
|
@@ -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,
|