@astryxdesign/cli 0.1.8-canary.0c4d8d7 → 0.1.8-canary.0db5dfd
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/{src/api → api/blog}/blog.mjs +42 -6
- package/{src/api → api/blog}/blog.test.mjs +2 -2
- package/api/build/build.mjs +92 -0
- package/api/build/build.test.mjs +92 -0
- package/{src/api → api/component}/component.mjs +49 -26
- package/{src/api → api/discover}/discover.mjs +55 -18
- package/{src/api → api/docs}/docs.mjs +47 -21
- package/{src/api → api/doctor}/doctor.mjs +11 -8
- package/{src/api → api/hook}/hook.mjs +11 -11
- package/{src/api → api}/index.mjs +16 -9
- package/{src/api → api/integration}/validate-integration.mjs +48 -15
- package/{src/api → api/integration}/validate-integration.test.mjs +1 -1
- package/{src/api → api/layout}/layout.mjs +66 -17
- package/{src/api → api/layout}/layout.test.mjs +1 -1
- package/{src/api → api/search}/search.mjs +71 -12
- package/api/swizzle/swizzle.mjs +283 -0
- package/{src/commands → api/swizzle}/swizzle.test.mjs +26 -1
- package/{src/api → api/template}/template-integration.test.mjs +2 -2
- package/{src/api → api/template}/template-suffix.test.mjs +3 -3
- package/{src/api → api/template}/template.mjs +96 -19
- package/{src/api → api/theme}/theme-add.mjs +35 -7
- package/{src → authoring}/codemod.mjs +6 -6
- package/{src → authoring}/config.test.mjs +1 -1
- package/{src → authoring}/doc.mjs +1 -1
- package/{src → authoring}/doc.test.mjs +1 -1
- package/{src → authoring}/template.mjs +1 -1
- package/bin/astryx.mjs +12 -10
- package/{src → cli}/commands/blog.mjs +48 -7
- package/{src → cli}/commands/build-theme.mjs +125 -46
- package/{src → cli}/commands/build.mjs +33 -57
- package/{src → cli}/commands/component/index.mjs +49 -22
- package/{src → cli}/commands/component-ownership.test.mjs +3 -3
- package/{src → cli}/commands/component-package.test.mjs +1 -1
- package/{src → cli}/commands/component-resolution.test.mjs +2 -2
- package/{src → cli}/commands/discover.mjs +17 -8
- package/{src → cli}/commands/docs.mjs +39 -7
- package/{src → cli}/commands/docs.test.mjs +1 -1
- package/{src → cli}/commands/doctor.mjs +3 -3
- package/{src → cli}/commands/doctor.test.mjs +2 -2
- package/{src → cli}/commands/ensure-core-built.mjs +3 -2
- package/{src → cli}/commands/external-showcase.test.mjs +1 -1
- package/{src → cli}/commands/hook/index.mjs +37 -14
- package/{src → cli}/commands/import-hint-correctness.test.mjs +1 -1
- package/{src → cli}/commands/init.mjs +20 -9
- package/{src → cli}/commands/layout.mjs +58 -18
- package/{src → cli}/commands/search.mjs +19 -12
- package/{src → cli}/commands/search.test.mjs +1 -1
- package/{src → cli}/commands/setup-nudge.test.mjs +1 -1
- package/cli/commands/swizzle.mjs +103 -0
- package/{src → cli}/commands/template.mjs +73 -22
- package/{src → cli}/commands/template.path-safety.test.mjs +2 -2
- package/{src → cli}/commands/upgrade.integration-policy.test.mjs +1 -1
- package/{src → cli}/commands/upgrade.mjs +160 -52
- package/{src → cli}/commands/upgrade.test.mjs +1 -1
- package/{src → cli}/commands/validate-integration.mjs +17 -37
- package/{src → cli}/index.mjs +17 -15
- package/{src/codemods → codemods}/ensure-jscodeshift.mjs +1 -1
- package/{src/codemods → codemods}/integration-discovery.mjs +6 -3
- package/{src/codemods → codemods}/integration-discovery.test.mjs +1 -1
- package/{src/codemods → codemods}/integration-runner.mjs +8 -3
- package/{src/codemods → codemods}/registry.mjs +3 -1
- package/{src/codemods → codemods}/run-codemod.mjs +17 -10
- package/{src/codemods → codemods}/runner.mjs +22 -12
- package/{src/codemods → codemods}/transforms/v0.0.10/remove-size-props.mjs +9 -4
- package/{src/codemods → codemods}/transforms/v0.0.12/add-is-icon-only.mjs +27 -22
- package/{src/codemods → codemods}/transforms/v0.0.13/icon-name-deprecations.mjs +12 -5
- package/{src/codemods → codemods}/transforms/v0.0.13/rename-attachments-to-drawer.mjs +15 -8
- package/{src/codemods → codemods}/transforms/v0.0.13/toolbar-density-to-size.mjs +10 -4
- package/{src/codemods → codemods}/transforms/v0.0.14/rename-action-props.mjs +11 -5
- package/{src/codemods → codemods}/transforms/v0.0.14/rename-section-wash-to-muted.mjs +11 -6
- package/{src/codemods → codemods}/transforms/v0.0.14/rename-status-variants.mjs +15 -10
- package/{src/codemods → codemods}/transforms/v0.0.15/migrate-item-children-to-endcontent.mjs +13 -8
- package/{src/codemods → codemods}/transforms/v0.0.15/migrate-selector-children-to-render-option.mjs +18 -13
- package/{src/codemods → codemods}/transforms/v0.0.15/migrate-theme-selectors-to-data-attrs.mjs +8 -4
- package/{src/codemods → codemods}/transforms/v0.0.15/rename-date-picker-to-input.mjs +11 -6
- package/{src/codemods → codemods}/transforms/v0.0.15/rename-imperative-ref-to-handleRef.mjs +6 -1
- package/{src/codemods → codemods}/transforms/v0.0.15/rename-isStreaming-to-isStopShown.mjs +6 -1
- package/{src/codemods → codemods}/transforms/v0.0.15/rename-stack-element-to-as.mjs +8 -3
- package/{src/codemods → codemods}/transforms/v0.0.2/migrate-badge-dot-to-statusdot.mjs +17 -10
- package/{src/codemods → codemods}/transforms/v0.0.2/migrate-gap-to-numeric.mjs +7 -1
- package/{src/codemods → codemods}/transforms/v0.0.2/migrate-isFullBleed-to-padding.mjs +9 -4
- package/{src/codemods → codemods}/transforms/v0.0.2/migrate-useXDSIcon-to-getIcon.mjs +12 -7
- package/{src/codemods → codemods}/transforms/v0.0.2/rename-banner-endButton-to-endContent.mjs +7 -2
- package/{src/codemods → codemods}/transforms/v0.0.2/rename-form-tooltip-startIcon.mjs +8 -2
- package/{src/codemods → codemods}/transforms/v0.0.2/rename-isShown-to-isOpen.mjs +7 -2
- package/{src/codemods → codemods}/transforms/v0.0.2/rename-selector-items-to-options.mjs +7 -2
- package/{src/codemods → codemods}/transforms/v0.0.2/rename-sidenav-header-to-heading.mjs +11 -4
- package/{src/codemods → codemods}/transforms/v0.0.2/rename-topnav-title-to-heading.mjs +10 -4
- package/{src/codemods → codemods}/transforms/v0.0.2/unify-uncontrolled-to-defaultX.mjs +7 -2
- package/{src/codemods → codemods}/transforms/v0.0.2/unify-visibility-to-onOpenChange.mjs +10 -5
- package/{src/codemods → codemods}/transforms/v0.0.6/migrate-badge-children-to-label.mjs +7 -2
- package/{src/codemods → codemods}/transforms/v0.0.6/migrate-collapse-to-collapsible.mjs +9 -3
- package/{src/codemods → codemods}/transforms/v0.0.6/migrate-radius-tokens.mjs +11 -5
- package/{src/codemods → codemods}/transforms/v0.0.6/migrate-shadow-tokens.mjs +13 -6
- package/{src/codemods → codemods}/transforms/v0.0.6/migrate-skeleton-radius.mjs +7 -1
- package/{src/codemods → codemods}/transforms/v0.0.6/migrate-token-names.mjs +11 -5
- package/{src/codemods → codemods}/transforms/v0.0.7/rename-banner-variant-to-container.mjs +8 -3
- package/{src/codemods → codemods}/transforms/v0.0.8/migrate-token-renames.mjs +15 -8
- package/{src/codemods → codemods}/transforms/v0.0.8/rename-endslot-to-endcontent.mjs +7 -2
- package/{src/codemods → codemods}/transforms/v0.1.0/drop-xds-prefix-imports.mjs +19 -14
- package/{src/codemods → codemods}/transforms/v0.1.0/migrate-xds-css-surfaces.mjs +21 -17
- package/{src/codemods → codemods}/transforms/v0.1.0/migrate-xds-declare-module.mjs +7 -2
- package/{src/codemods → codemods}/transforms/v0.1.0/migrate-xds-module-specifiers.mjs +16 -11
- package/{src/codemods → codemods}/transforms/v0.1.2/rename-text-color-active-to-accent.mjs +15 -9
- package/{src/codemods → codemods}/transforms/v0.1.3/migrate-layout-components-to-experimental.mjs +17 -12
- package/{src/codemods → codemods}/transforms/v0.1.5/rename-switch-label-spacing-default-to-hug.mjs +15 -9
- package/{src/codemods → codemods}/transforms/v0.1.7/migrate-table-tableprops-to-direct-props.mjs +17 -10
- package/{src/codemods → codemods}/transforms/v0.1.7/rename-table-renderprops-styles-to-xstyle.mjs +18 -13
- package/{src/codemods → codemods}/transforms/v0.1.8/rename-avatar-size-scale.mjs +15 -10
- package/docs/internationalization.doc.mjs +92 -46
- package/{src/commands → lib/agent-docs}/agent-docs.mjs +30 -11
- package/{src/commands → lib/agent-docs}/agent-docs.path-safety.test.mjs +1 -1
- package/{src/lib → lib}/component-discovery.mjs +44 -2
- package/{src/lib → lib}/component-format.mjs +65 -24
- package/{src/lib → lib}/component-loader.mjs +27 -13
- package/{src/lib → lib}/componentDocOverlay.test.mjs +0 -1
- package/{src/lib → lib}/error-codes.test.mjs +1 -1
- package/{src/lib → lib}/hook-discovery.mjs +14 -1
- package/{src/lib → lib}/hook-format.mjs +29 -5
- package/{src/lib → lib}/integration-warnings.mjs +2 -2
- package/{src/lib → lib}/integrations.mjs +20 -0
- package/{src/lib → lib}/integrations.test.mjs +1 -1
- package/{src/lib → lib}/json-contract.test.mjs +1 -1
- package/{src/lib → lib}/json-shim.mjs +10 -5
- package/{src/lib → lib}/json-shim.test.mjs +1 -1
- package/{src/lib → lib}/levenshtein.mjs +6 -0
- package/{src/lib → lib}/manifest.mjs +7 -5
- package/{src/lib → lib}/manifest.test.mjs +2 -2
- package/{src/lib → lib}/module-loader.mjs +1 -0
- package/{src/lib → lib}/package-scanner.mjs +47 -0
- package/{src/lib → lib}/project.mjs +48 -18
- package/{src/lib → lib}/project.test.mjs +1 -1
- package/{src/lib → lib}/resolve-theme.mjs +5 -0
- package/{src/lib → lib}/string-utils.mjs +15 -0
- package/{src/lib → lib}/term-log.mjs +12 -3
- package/{src/lib → lib}/xle/browser.mjs +18 -8
- package/{src/lib → lib}/xle/expand.mjs +155 -22
- package/{src/lib → lib}/xle/parse.mjs +119 -13
- package/{src/lib → lib}/xle/print.mjs +54 -14
- package/{src/lib → lib}/xle/registry-core.mjs +28 -3
- package/{src/lib → lib}/xle/registry.mjs +9 -4
- package/{src/lib → lib}/xle/splice.mjs +13 -2
- package/{src/lib → lib}/xle/validate.mjs +95 -14
- package/lib/xle/xle-ast.d.ts +214 -0
- package/package.json +33 -26
- package/scripts/postinstall.mjs +4 -4
- package/templates/blocks/components/Avatar/AvatarShowcase.tsx +1 -1
- package/templates/blocks/components/InternationalizationProvider/InternationalizationProvider01ShippedLocale.doc.mjs +19 -0
- package/templates/blocks/components/InternationalizationProvider/InternationalizationProvider01ShippedLocale.tsx +46 -0
- package/templates/blocks/components/InternationalizationProvider/InternationalizationProvider02Overrides.doc.mjs +14 -0
- package/templates/blocks/components/InternationalizationProvider/InternationalizationProvider02Overrides.tsx +33 -0
- package/{src/types → types}/api.contract.assert.ts +17 -8
- package/{src/types → types}/api.d.ts +106 -0
- package/{src/types → types}/base.d.ts +17 -2
- package/types/build.d.ts +53 -0
- package/types/codemod.d.ts +166 -0
- package/{src/types → types}/component.d.ts +1 -1
- package/{src/types → types}/discover.d.ts +1 -1
- package/{src/types → types}/docs.d.ts +1 -4
- package/{src/types → types}/hook.d.ts +1 -1
- package/types/jscodeshift.d.ts +19 -0
- package/types/layout.d.ts +74 -0
- package/types/theme.d.ts +53 -0
- package/{src/types → types}/upgrade.d.ts +8 -1
- package/{src/utils → utils}/paths.mjs +4 -1
- package/src/commands/swizzle.mjs +0 -417
- package/src/types/build.d.ts +0 -23
- package/src/types/codemod.d.ts +0 -81
- package/src/types/theme.d.ts +0 -23
- /package/{src/api → api/docs}/docOverlays.test.mjs +0 -0
- /package/{src/api → api}/error.mjs +0 -0
- /package/{src/api → api/integration}/integration-block-exports.test.mjs +0 -0
- /package/{src/api → api/template}/template.test.mjs +0 -0
- /package/{src → authoring}/codemod.test.mjs +0 -0
- /package/{src → authoring}/config.mjs +0 -0
- /package/{src → authoring}/integration.mjs +0 -0
- /package/{src → authoring}/template.test.mjs +0 -0
- /package/{src → cli}/cli-exit-codes.test.mjs +0 -0
- /package/{src → cli}/commands/build-theme.color-scheme.test.mjs +0 -0
- /package/{src → cli}/commands/build-theme.import-path.test.mjs +0 -0
- /package/{src → cli}/commands/build-theme.path-safety.test.mjs +0 -0
- /package/{src → cli}/commands/build-theme.prose.test.mjs +0 -0
- /package/{src → cli}/commands/build-theme.variants.test.mjs +0 -0
- /package/{src → cli}/commands/build-theme.watch.test.mjs +0 -0
- /package/{src → cli}/commands/cli-postinstall.test.mjs +0 -0
- /package/{src → cli}/commands/component.test.mjs +0 -0
- /package/{src → cli}/commands/detail-levels.test.mjs +0 -0
- /package/{src → cli}/commands/init.next-steps.test.mjs +0 -0
- /package/{src → cli}/commands/interactive-guard.test.mjs +0 -0
- /package/{src → cli}/commands/json-contract.test.mjs +0 -0
- /package/{src → cli}/commands/swizzle.path-safety.test.mjs +0 -0
- /package/{src → cli}/commands/swizzle.routing.test.mjs +0 -0
- /package/{src → cli}/commands/template.test.mjs +0 -0
- /package/{src → cli}/commands/upgrade.config-ordering.test.mjs +0 -0
- /package/{src → cli}/commands/validate-integration.test.mjs +0 -0
- /package/{src → cli}/update-hint-commands.test.mjs +0 -0
- /package/{src/codemods → codemods}/__tests__/registry.test.mjs +0 -0
- /package/{src/codemods → codemods}/__tests__/rename-imperative-ref-to-handleRef.test.mjs +0 -0
- /package/{src/codemods → codemods}/__tests__/rename-isStreaming-to-isStopShown.test.mjs +0 -0
- /package/{src/codemods → codemods}/__tests__/rename-section-wash-to-muted.test.mjs +0 -0
- /package/{src/codemods → codemods}/__tests__/runner.test.mjs +0 -0
- /package/{src/codemods → codemods}/__tests__/toolbar-density-to-size.test.mjs +0 -0
- /package/{src/codemods → codemods}/__tests__/validation.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.10/__tests__/remove-size-props.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.10/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.12/__tests__/add-is-icon-only.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.12/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.13/__tests__/icon-name-deprecations.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.13/__tests__/rename-attachments-to-drawer.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.13/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.14/__tests__/rename-action-props.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.14/__tests__/rename-status-variants.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.14/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.15/__tests__/migrate-item-children-to-endcontent.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.15/__tests__/migrate-selector-children-to-render-option.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.15/__tests__/migrate-theme-selectors-to-data-attrs.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.15/__tests__/rename-date-picker-to-input.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.15/__tests__/rename-stack-element-to-as.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.15/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/migrate-badge-dot-to-statusdot.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/migrate-gap-to-numeric.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/migrate-isFullBleed-to-padding.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/migrate-useXDSIcon-to-getIcon.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/rename-banner-endButton-to-endContent.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/rename-form-tooltip-startIcon.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/rename-isShown-to-isOpen.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/rename-selector-items-to-options.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/rename-sidenav-header-to-heading.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/rename-topnav-title-to-heading.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/unify-uncontrolled-to-defaultX.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/unify-visibility-to-onOpenChange.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.6/__tests__/migrate-collapse-to-collapsible.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.6/__tests__/migrate-radius-tokens.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.6/__tests__/migrate-shadow-tokens.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.6/__tests__/migrate-skeleton-radius.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.6/__tests__/migrate-token-names.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.6/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.7/__tests__/rename-banner-variant-to-container.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.7/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.8/__tests__/migrate-token-renames.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.8/__tests__/rename-endslot-to-endcontent.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.8/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.0/__tests__/drop-xds-prefix-imports.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.0/__tests__/migrate-xds-css-surfaces.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.0/__tests__/migrate-xds-declare-module.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.0/__tests__/migrate-xds-module-specifiers.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.0/__tests__/v0.1.0-ordering.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.0/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.2/__tests__/rename-text-color-active-to-accent.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.2/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.3/__tests__/migrate-layout-components-to-experimental.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.3/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.5/__tests__/rename-switch-label-spacing-default-to-hug.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.5/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.7/__tests__/migrate-table-tableprops-to-direct-props.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.7/__tests__/rename-table-renderprops-styles-to-xstyle.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.7/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.8/__tests__/rename-avatar-size-scale.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.8/index.mjs +0 -0
- /package/{src/commands → lib/agent-docs}/agent-docs.test.mjs +0 -0
- /package/{src/lib → lib}/cli-error.mjs +0 -0
- /package/{src/lib → lib}/cli-error.test.mjs +0 -0
- /package/{src/lib → lib}/component-discovery.importpath.test.mjs +0 -0
- /package/{src/lib → lib}/component-format.test.mjs +0 -0
- /package/{src/lib → lib}/component-loader.test.mjs +0 -0
- /package/{src/lib → lib}/config-cache.mjs +0 -0
- /package/{src/lib → lib}/config-cache.test.mjs +0 -0
- /package/{src/lib → lib}/config-schema.mjs +0 -0
- /package/{src/lib → lib}/error-codes.mjs +0 -0
- /package/{src/lib → lib}/integration-warnings.test.mjs +0 -0
- /package/{src/lib → lib}/json.mjs +0 -0
- /package/{src/lib → lib}/module-loader.test.mjs +0 -0
- /package/{src/lib → lib}/node-version.mjs +0 -0
- /package/{src/lib → lib}/node-version.test.mjs +0 -0
- /package/{src/lib → lib}/parse.mjs +0 -0
- /package/{src/lib → lib}/site.mjs +0 -0
- /package/{src/lib → lib}/xle/browser.d.ts +0 -0
- /package/{src/lib → lib}/xle/xle.test.mjs +0 -0
- /package/{src/schemas → schemas}/doc-schema.mjs +0 -0
- /package/{src/schemas → schemas}/template-schema.mjs +0 -0
- /package/{src/types → types}/config.d.ts +0 -0
- /package/{src/types → types}/doc.d.ts +0 -0
- /package/{src/types → types}/doctor.d.ts +0 -0
- /package/{src/types → types}/error-codes.d.ts +0 -0
- /package/{src/types → types}/index.d.ts +0 -0
- /package/{src/types → types}/integration.d.ts +0 -0
- /package/{src/types → types}/manifest.d.ts +0 -0
- /package/{src/types → types}/search.d.ts +0 -0
- /package/{src/types → types}/swizzle.d.ts +0 -0
- /package/{src/types → types}/template-api.d.ts +0 -0
- /package/{src/types → types}/template.d.ts +0 -0
- /package/{src/types → types}/validate-integration.d.ts +0 -0
- /package/{src/utils → utils}/github.mjs +0 -0
- /package/{src/utils → utils}/package-manager.mjs +0 -0
- /package/{src/utils → utils}/package-manager.test.mjs +0 -0
- /package/{src/utils → utils}/path-safety.mjs +0 -0
- /package/{src/utils → utils}/path-safety.test.mjs +0 -0
- /package/{src/utils → utils}/paths.test.mjs +0 -0
- /package/{src/utils → utils}/semver.mjs +0 -0
- /package/{src/utils → utils}/semver.test.mjs +0 -0
- /package/{src/utils → utils}/update-check.mjs +0 -0
- /package/{src/utils → utils}/update-check.test.mjs +0 -0
|
@@ -6,16 +6,44 @@
|
|
|
6
6
|
|
|
7
7
|
import * as path from 'node:path';
|
|
8
8
|
import * as fs from 'node:fs';
|
|
9
|
-
import {jsonOut, humanLog} from '
|
|
10
|
-
import {cliError} from '
|
|
11
|
-
import {ERROR_CODES} from '
|
|
12
|
-
import {template as templateApi} from '
|
|
13
|
-
import {Project} from '
|
|
14
|
-
import {warnOnIntegrationIssues} from '
|
|
15
|
-
import {getCliInvocation} from '
|
|
9
|
+
import {jsonOut, humanLog} from '../../lib/json.mjs';
|
|
10
|
+
import {cliError} from '../../lib/cli-error.mjs';
|
|
11
|
+
import {ERROR_CODES} from '../../lib/error-codes.mjs';
|
|
12
|
+
import {template as templateApi} from '../../api/template/template.mjs';
|
|
13
|
+
import {Project} from '../../lib/project.mjs';
|
|
14
|
+
import {warnOnIntegrationIssues} from '../../lib/integration-warnings.mjs';
|
|
15
|
+
import {getCliInvocation} from '../../utils/package-manager.mjs';
|
|
16
16
|
|
|
17
|
-
export {discoverTemplates, listTemplates} from '
|
|
17
|
+
export {discoverTemplates, listTemplates} from '../../api/template/template.mjs';
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* A template entry as produced by the discover* helpers in api/template.mjs.
|
|
21
|
+
* The api layer returns these as `object[]`; this local shape captures the
|
|
22
|
+
* fields the command consumes. Remove once api/template.mjs exports a precise
|
|
23
|
+
* type for its discovered templates.
|
|
24
|
+
* @typedef {object} DiscoveredTemplate
|
|
25
|
+
* @property {'page' | 'block'} type
|
|
26
|
+
* @property {string} dirName
|
|
27
|
+
* @property {string} name
|
|
28
|
+
* @property {string} filePath
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The discriminated response returned by the template API. The api layer
|
|
33
|
+
* currently declares `{type: string, data: unknown}`; narrow it here to the
|
|
34
|
+
* precise union so the switch below type-checks. Replace with the api's own
|
|
35
|
+
* return type once it is tightened.
|
|
36
|
+
* @typedef {(
|
|
37
|
+
* import('../../types/template').TemplateListResponse |
|
|
38
|
+
* import('../../types/template').TemplateShowResponse |
|
|
39
|
+
* import('../../types/template').TemplateSkeletonResponse |
|
|
40
|
+
* import('../../types/template').TemplateCopyResponse
|
|
41
|
+
* )} TemplateResponse
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @param {import('commander').Command} program
|
|
46
|
+
*/
|
|
19
47
|
export function registerTemplate(program) {
|
|
20
48
|
program
|
|
21
49
|
.command('template [name] [path]')
|
|
@@ -25,7 +53,13 @@ export function registerTemplate(program) {
|
|
|
25
53
|
.option('--package <pkg>', 'Narrow to templates from a specific package')
|
|
26
54
|
.option('--skeleton', 'Show layout skeleton with spatial annotations (padding, gap, nesting)')
|
|
27
55
|
.option('-f, --overwrite', 'Overwrite existing files without prompting')
|
|
28
|
-
.action(
|
|
56
|
+
.action(
|
|
57
|
+
/**
|
|
58
|
+
* @param {string | undefined} name
|
|
59
|
+
* @param {string | undefined} targetPath
|
|
60
|
+
* @param {{list?: boolean, type?: string, package?: string, skeleton?: boolean, overwrite?: boolean}} options
|
|
61
|
+
*/
|
|
62
|
+
async (name, targetPath, options) => {
|
|
29
63
|
const json = program.opts().json || false;
|
|
30
64
|
const run = getCliInvocation();
|
|
31
65
|
|
|
@@ -34,7 +68,12 @@ export function registerTemplate(program) {
|
|
|
34
68
|
// validate-integration. Best-effort; suppressed in --json mode.
|
|
35
69
|
try {
|
|
36
70
|
const project = await Project.load(process.cwd());
|
|
37
|
-
await warnOnIntegrationIssues(
|
|
71
|
+
await warnOnIntegrationIssues(
|
|
72
|
+
/** @type {Array<import('../../lib/integrations.mjs').LoadedIntegration>} */ (
|
|
73
|
+
project.loadedIntegrations
|
|
74
|
+
),
|
|
75
|
+
{json},
|
|
76
|
+
);
|
|
38
77
|
} catch {
|
|
39
78
|
// Never let the nudge break the command.
|
|
40
79
|
}
|
|
@@ -59,20 +98,24 @@ export function registerTemplate(program) {
|
|
|
59
98
|
}
|
|
60
99
|
}
|
|
61
100
|
|
|
101
|
+
/** @type {TemplateResponse} */
|
|
62
102
|
let result;
|
|
63
103
|
try {
|
|
64
|
-
result =
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
104
|
+
result = /** @type {TemplateResponse} */ (
|
|
105
|
+
await templateApi(name, {
|
|
106
|
+
list: options.list,
|
|
107
|
+
skeleton: options.skeleton,
|
|
108
|
+
type: /** @type {'page' | 'block' | undefined} */ (options.type),
|
|
109
|
+
package: options.package,
|
|
110
|
+
targetPath,
|
|
111
|
+
cwd: process.cwd(),
|
|
112
|
+
})
|
|
113
|
+
);
|
|
72
114
|
} catch (e) {
|
|
73
115
|
// template API throws structured errors with {name, reason} suggestions —
|
|
74
116
|
// pass them through untouched so the CLI envelope matches the API.
|
|
75
|
-
|
|
117
|
+
const err = /** @type {import('../../api/error.mjs').AstryxError} */ (e);
|
|
118
|
+
cliError(err.message, {suggestions: err.suggestions || [], code: err.code});
|
|
76
119
|
return;
|
|
77
120
|
}
|
|
78
121
|
|
|
@@ -82,6 +125,7 @@ export function registerTemplate(program) {
|
|
|
82
125
|
case 'template.list': {
|
|
83
126
|
const pages = result.data.filter(t => t.type === 'page');
|
|
84
127
|
const blocks = result.data.filter(t => t.type === 'block');
|
|
128
|
+
/** @param {import('../../types/template').TemplateListEntry} t */
|
|
85
129
|
const renderEntry = t => {
|
|
86
130
|
const status = t.isReady ? '' : ' (WIP)';
|
|
87
131
|
const pkg =
|
|
@@ -139,12 +183,19 @@ export function registerTemplate(program) {
|
|
|
139
183
|
* Path-safety enforcement happens inside the API; here we only need
|
|
140
184
|
* enough precision to check existence — a false negative just means the
|
|
141
185
|
* API will catch the issue and abort.
|
|
186
|
+
*
|
|
187
|
+
* @param {string} name
|
|
188
|
+
* @param {string} targetPath
|
|
189
|
+
* @returns {Promise<string | null>}
|
|
142
190
|
*/
|
|
143
191
|
async function detectTemplateCollision(name, targetPath) {
|
|
144
|
-
const {discoverTemplates} = await import('
|
|
192
|
+
const {discoverTemplates} = await import('../../api/template/template.mjs');
|
|
193
|
+
/** @type {DiscoveredTemplate[]} */
|
|
145
194
|
let templates;
|
|
146
195
|
try {
|
|
147
|
-
templates =
|
|
196
|
+
templates = /** @type {DiscoveredTemplate[]} */ (
|
|
197
|
+
await discoverTemplates(process.cwd())
|
|
198
|
+
);
|
|
148
199
|
} catch {
|
|
149
200
|
return null;
|
|
150
201
|
}
|
|
@@ -157,7 +208,7 @@ async function detectTemplateCollision(name, targetPath) {
|
|
|
157
208
|
const resolved = path.resolve(process.cwd(), targetPath);
|
|
158
209
|
|
|
159
210
|
// File-arg branch: targetPath looks like `./foo.tsx`.
|
|
160
|
-
const {isFilePathArg} = await import('
|
|
211
|
+
const {isFilePathArg} = await import('../../utils/path-safety.mjs');
|
|
161
212
|
let dest;
|
|
162
213
|
if (isFilePathArg(targetPath)) {
|
|
163
214
|
dest = resolved;
|
|
@@ -18,7 +18,7 @@ let templateApi;
|
|
|
18
18
|
|
|
19
19
|
beforeEach(async () => {
|
|
20
20
|
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-template-paths-'));
|
|
21
|
-
templateApi = (await import('
|
|
21
|
+
templateApi = (await import('../../api/template/template.mjs')).template;
|
|
22
22
|
});
|
|
23
23
|
afterEach(() => {
|
|
24
24
|
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
@@ -57,7 +57,7 @@ describe('template path safety', () => {
|
|
|
57
57
|
fs.mkdirSync(cwd, {recursive: true});
|
|
58
58
|
|
|
59
59
|
// Use a real template name from the discovered set.
|
|
60
|
-
const {discoverTemplates} = await import('
|
|
60
|
+
const {discoverTemplates} = await import('../../api/template/template.mjs');
|
|
61
61
|
const all = await discoverTemplates();
|
|
62
62
|
const page = all.find(t => t.type === 'page');
|
|
63
63
|
if (!page) {
|
|
@@ -40,23 +40,23 @@ import * as fs from 'node:fs';
|
|
|
40
40
|
import * as path from 'node:path';
|
|
41
41
|
import {execFile} from 'node:child_process';
|
|
42
42
|
import {promisify} from 'node:util';
|
|
43
|
-
import * as p from '
|
|
44
|
-
import {ensureJscodeshift} from '
|
|
45
|
-
import {getTransformsBetween, latestVersion} from '
|
|
46
|
-
import {runCodemods} from '
|
|
43
|
+
import * as p from '../../lib/term-log.mjs';
|
|
44
|
+
import {ensureJscodeshift} from '../../codemods/ensure-jscodeshift.mjs';
|
|
45
|
+
import {getTransformsBetween, latestVersion} from '../../codemods/registry.mjs';
|
|
46
|
+
import {runCodemods} from '../../codemods/runner.mjs';
|
|
47
47
|
import {
|
|
48
48
|
discoverIntegrationCodemods,
|
|
49
49
|
selectIntegrationCodemods,
|
|
50
|
-
} from '
|
|
51
|
-
import {runIntegrationCodemods} from '
|
|
52
|
-
import {installAgentDocs, inspectAgentDocs} from '
|
|
53
|
-
import {getCliInvocation, formatCliCommand} from '
|
|
54
|
-
import {isValidSemver, semverGte} from '
|
|
55
|
-
import {jsonOut, jsonError} from '
|
|
56
|
-
import {Project} from '
|
|
57
|
-
import {loadIntegrations} from '
|
|
58
|
-
import {warnOnIntegrationIssues} from '
|
|
59
|
-
import {ERROR_CODES} from '
|
|
50
|
+
} from '../../codemods/integration-discovery.mjs';
|
|
51
|
+
import {runIntegrationCodemods} from '../../codemods/integration-runner.mjs';
|
|
52
|
+
import {installAgentDocs, inspectAgentDocs} from '../../lib/agent-docs/agent-docs.mjs';
|
|
53
|
+
import {getCliInvocation, formatCliCommand} from '../../utils/package-manager.mjs';
|
|
54
|
+
import {isValidSemver, semverGte} from '../../utils/semver.mjs';
|
|
55
|
+
import {jsonOut, jsonError} from '../../lib/json.mjs';
|
|
56
|
+
import {Project} from '../../lib/project.mjs';
|
|
57
|
+
import {loadIntegrations} from '../../lib/integrations.mjs';
|
|
58
|
+
import {warnOnIntegrationIssues} from '../../lib/integration-warnings.mjs';
|
|
59
|
+
import {ERROR_CODES} from '../../lib/error-codes.mjs';
|
|
60
60
|
|
|
61
61
|
const execFileAsync = promisify(execFile);
|
|
62
62
|
|
|
@@ -82,8 +82,18 @@ function detectInstalledTargetVersion() {
|
|
|
82
82
|
return null;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
/**
|
|
86
|
+
* @param {(string | null | undefined | false)[] | undefined} files
|
|
87
|
+
* @returns {string[]}
|
|
88
|
+
*/
|
|
85
89
|
function uniqueFiles(files) {
|
|
86
|
-
return [
|
|
90
|
+
return [
|
|
91
|
+
...new Set(
|
|
92
|
+
(files ?? []).filter(
|
|
93
|
+
/** @returns {f is string} */ f => Boolean(f),
|
|
94
|
+
),
|
|
95
|
+
),
|
|
96
|
+
];
|
|
87
97
|
}
|
|
88
98
|
|
|
89
99
|
/**
|
|
@@ -95,7 +105,7 @@ function uniqueFiles(files) {
|
|
|
95
105
|
* In apply mode the commands run in order via execFile; a nonzero exit (or a
|
|
96
106
|
* buildCommand throw) fails the upgrade.
|
|
97
107
|
*
|
|
98
|
-
* @param {import('
|
|
108
|
+
* @param {import('../../types/config').PostCodemodHook[]} hooks
|
|
99
109
|
* @param {{packageDir: string, files: string[], apply: boolean}} context
|
|
100
110
|
* @param {boolean} silent
|
|
101
111
|
*/
|
|
@@ -126,14 +136,18 @@ async function runPostCodemodHooks(hooks, context, silent) {
|
|
|
126
136
|
continue;
|
|
127
137
|
}
|
|
128
138
|
|
|
129
|
-
await execFileAsync(
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
139
|
+
await execFileAsync(
|
|
140
|
+
cmd.command,
|
|
141
|
+
cmd.args ?? [],
|
|
142
|
+
/** @type {import('node:child_process').ExecFileOptions & {encoding: 'utf-8'}} */ ({
|
|
143
|
+
cwd: cmd.options?.cwd ?? packageDir,
|
|
144
|
+
timeout: cmd.options?.timeout ?? 300_000,
|
|
145
|
+
stdio: 'pipe',
|
|
146
|
+
encoding: 'utf-8',
|
|
147
|
+
...cmd.options,
|
|
148
|
+
env: {...process.env, ...(cmd.options?.env ?? {})},
|
|
149
|
+
}),
|
|
150
|
+
);
|
|
137
151
|
log.success(`Post-codemod hook ${label} completed.`);
|
|
138
152
|
}
|
|
139
153
|
}
|
|
@@ -156,11 +170,11 @@ async function runPostCodemodHooks(hooks, context, silent) {
|
|
|
156
170
|
* - `current` — every block already matches the installed version: stay silent.
|
|
157
171
|
*
|
|
158
172
|
* @param {{cwd: string, installedVersion: string, apply: boolean, json: boolean}} ctx
|
|
159
|
-
* @returns {import('
|
|
173
|
+
* @returns {import('../../types/upgrade').AgentDocsSummary}
|
|
160
174
|
*/
|
|
161
175
|
export function refreshAgentDocs({cwd, installedVersion, apply, json}) {
|
|
162
176
|
const inspection = inspectAgentDocs(cwd, installedVersion);
|
|
163
|
-
/** @type {import('
|
|
177
|
+
/** @type {import('../../types/upgrade').AgentDocsSummary} */
|
|
164
178
|
const summary = {
|
|
165
179
|
status: inspection.status,
|
|
166
180
|
installedVersion,
|
|
@@ -235,8 +249,27 @@ export function refreshAgentDocs({cwd, installedVersion, apply, json}) {
|
|
|
235
249
|
return summary;
|
|
236
250
|
}
|
|
237
251
|
|
|
252
|
+
/**
|
|
253
|
+
* A single core transform entry as produced by the registry manifests. The
|
|
254
|
+
* registry's declared return type omits the optional `optional` flag and the
|
|
255
|
+
* `pr`/`codemodType` meta fields that the transform modules actually carry;
|
|
256
|
+
* this local shape captures what the upgrade command reads. Remove once
|
|
257
|
+
* codemods/registry.mjs declares these fields on its return type.
|
|
258
|
+
* @typedef {object} CoreTransformEntry
|
|
259
|
+
* @property {string} name
|
|
260
|
+
* @property {import('../../types/codemod').CodemodTransform} transform
|
|
261
|
+
* @property {{title: string, description?: string, pr?: string, codemodType?: string}} meta
|
|
262
|
+
* @property {boolean} [optional]
|
|
263
|
+
*/
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* A version-scoped group of core transforms from the registry.
|
|
267
|
+
* @typedef {{version: string, transforms: CoreTransformEntry[]}} CoreVersionManifest
|
|
268
|
+
*/
|
|
269
|
+
|
|
238
270
|
/**
|
|
239
271
|
* Register the `upgrade` command (codemod-driven version migration).
|
|
272
|
+
* @param {import('commander').Command} program
|
|
240
273
|
*/
|
|
241
274
|
export function registerUpgrade(program) {
|
|
242
275
|
program
|
|
@@ -260,6 +293,10 @@ export function registerUpgrade(program) {
|
|
|
260
293
|
.option(
|
|
261
294
|
'--integration <package-or-file>',
|
|
262
295
|
'Explicit integration package name or integration file path (repeatable)',
|
|
296
|
+
/**
|
|
297
|
+
* @param {string} value
|
|
298
|
+
* @param {string[]} previous
|
|
299
|
+
*/
|
|
263
300
|
(value, previous) => [...(previous ?? []), value],
|
|
264
301
|
[],
|
|
265
302
|
)
|
|
@@ -270,7 +307,21 @@ export function registerUpgrade(program) {
|
|
|
270
307
|
false,
|
|
271
308
|
)
|
|
272
309
|
.option('--list', 'List available codemods', false)
|
|
273
|
-
.action(
|
|
310
|
+
.action(
|
|
311
|
+
/**
|
|
312
|
+
* @param {{
|
|
313
|
+
* list?: boolean,
|
|
314
|
+
* from?: string,
|
|
315
|
+
* apply: boolean,
|
|
316
|
+
* force?: boolean,
|
|
317
|
+
* codemod?: string,
|
|
318
|
+
* skipCodemod?: string[],
|
|
319
|
+
* integration?: string[],
|
|
320
|
+
* path: string,
|
|
321
|
+
* installDeps?: boolean,
|
|
322
|
+
* }} options
|
|
323
|
+
*/
|
|
324
|
+
async options => {
|
|
274
325
|
const json = program.opts().json || false;
|
|
275
326
|
if (!json) p.intro('Upgrade');
|
|
276
327
|
|
|
@@ -301,7 +352,9 @@ export function registerUpgrade(program) {
|
|
|
301
352
|
// over every version and re-walked getTransformsBetween('0.0.0', v),
|
|
302
353
|
// so each codemod was printed once per release that included it
|
|
303
354
|
// (31 unique × 9 ≈ 201 lines on the current registry).
|
|
304
|
-
const manifests =
|
|
355
|
+
const manifests = /** @type {CoreVersionManifest[]} */ (
|
|
356
|
+
await getTransformsBetween('0.0.0', latestVersion)
|
|
357
|
+
);
|
|
305
358
|
for (const {version, transforms} of manifests) {
|
|
306
359
|
for (const {name, meta, optional} of transforms) {
|
|
307
360
|
codemods.push({
|
|
@@ -333,7 +386,8 @@ export function registerUpgrade(program) {
|
|
|
333
386
|
return;
|
|
334
387
|
}
|
|
335
388
|
|
|
336
|
-
|
|
389
|
+
// Guarded above: reaching here means --from passed isValidSemver, so it's a string.
|
|
390
|
+
const currentVersion = /** @type {string} */ (options.from);
|
|
337
391
|
const installed = detectInstalledTargetVersion();
|
|
338
392
|
if (!installed) {
|
|
339
393
|
const msg =
|
|
@@ -400,9 +454,9 @@ export function registerUpgrade(program) {
|
|
|
400
454
|
// Resolve CORE transforms from the registry. These do not need the loaded
|
|
401
455
|
// config. Integration codemods are discovered later, AFTER the config
|
|
402
456
|
// loads successfully (they require a valid config to resolve).
|
|
403
|
-
const versionManifests = [
|
|
457
|
+
const versionManifests = /** @type {CoreVersionManifest[]} */ ([
|
|
404
458
|
...(await getTransformsBetween(currentVersion, targetVersion)),
|
|
405
|
-
];
|
|
459
|
+
]);
|
|
406
460
|
|
|
407
461
|
// Does the selected core set include >=1 CONFIG codemod? A config codemod
|
|
408
462
|
// is the established convention `meta.codemodType === 'config'` (see
|
|
@@ -470,6 +524,15 @@ export function registerUpgrade(program) {
|
|
|
470
524
|
skipCodemods,
|
|
471
525
|
silent: json,
|
|
472
526
|
});
|
|
527
|
+
// runCodemods returns either a success accounting or a
|
|
528
|
+
// {ok: false, reason} sentinel (e.g. source_path_missing). Narrow to the
|
|
529
|
+
// success shape so downstream property reads type-check; the sentinel
|
|
530
|
+
// branch collapses to null and the `?? 0`/`?? []` fallbacks below treat
|
|
531
|
+
// it as "no files changed", matching the existing runtime behavior.
|
|
532
|
+
const coreResult =
|
|
533
|
+
codemodResult && 'totalFilesChanged' in codemodResult
|
|
534
|
+
? codemodResult
|
|
535
|
+
: null;
|
|
473
536
|
|
|
474
537
|
// STEP 4 — Load the consumer's config (STRICT validation; unchanged). On
|
|
475
538
|
// --apply this now sees the repaired config the core codemod just wrote.
|
|
@@ -477,8 +540,11 @@ export function registerUpgrade(program) {
|
|
|
477
540
|
// here. Wrap in a graceful dry-run catch (see below).
|
|
478
541
|
// Assigned inside the try below; every catch branch returns, so these
|
|
479
542
|
// are always set before any later read.
|
|
543
|
+
/** @type {Array<import('../../lib/integrations.mjs').LoadedIntegration>} */
|
|
480
544
|
let integrations;
|
|
545
|
+
/** @type {import('../../types/config').PostCodemodHook[]} */
|
|
481
546
|
let postCodemodHooks;
|
|
547
|
+
/** @type {Array<{version: string, codemods: import('../../types/codemod').CodemodEntry[]}>} */
|
|
482
548
|
let integrationVersionGroups;
|
|
483
549
|
try {
|
|
484
550
|
const project = await Project.load(process.cwd());
|
|
@@ -489,6 +555,7 @@ export function registerUpgrade(program) {
|
|
|
489
555
|
]);
|
|
490
556
|
integrations = await loadIntegrations(integrationSpecs);
|
|
491
557
|
} catch (err) {
|
|
558
|
+
const configErr = /** @type {Error} */ (err);
|
|
492
559
|
// GRACEFUL DRY-RUN CATCH. A config that fails strict validation is the
|
|
493
560
|
// EXPECTED, fixable case ONLY when we are in dry-run AND a pending core
|
|
494
561
|
// config codemod just PREVIEWED a change to the config — i.e. the very
|
|
@@ -499,7 +566,7 @@ export function registerUpgrade(program) {
|
|
|
499
566
|
// gate and aborts below — preserving the strictness contract.) This is
|
|
500
567
|
// the reason this PR reorders the pipeline.
|
|
501
568
|
const codemodWouldFixConfig =
|
|
502
|
-
hasCoreConfigCodemod && (
|
|
569
|
+
hasCoreConfigCodemod && (coreResult?.totalFilesChanged ?? 0) > 0;
|
|
503
570
|
if (!options.apply && codemodWouldFixConfig) {
|
|
504
571
|
const codemodFlags = coreConfigCodemodNames
|
|
505
572
|
.map(name => `--codemod ${name}`)
|
|
@@ -518,7 +585,7 @@ export function registerUpgrade(program) {
|
|
|
518
585
|
status: 'config_fixable',
|
|
519
586
|
from: currentVersion,
|
|
520
587
|
to: targetVersion,
|
|
521
|
-
configError:
|
|
588
|
+
configError: configErr.message,
|
|
522
589
|
configCodemods: coreConfigCodemodNames,
|
|
523
590
|
suggestedCommand,
|
|
524
591
|
message: guidance,
|
|
@@ -539,11 +606,11 @@ export function registerUpgrade(program) {
|
|
|
539
606
|
// refresh already ran (it's independent of config), so surface it.
|
|
540
607
|
if (json)
|
|
541
608
|
return jsonError(
|
|
542
|
-
|
|
543
|
-
{agentDocs},
|
|
609
|
+
configErr.message,
|
|
610
|
+
/** @type {import('../../types/base').Suggestion[]} */ (/** @type {unknown} */ ({agentDocs})),
|
|
544
611
|
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
545
612
|
);
|
|
546
|
-
p.log.error(
|
|
613
|
+
p.log.error(configErr.message);
|
|
547
614
|
p.outro('Aborted');
|
|
548
615
|
process.exitCode = 1;
|
|
549
616
|
return;
|
|
@@ -574,12 +641,21 @@ export function registerUpgrade(program) {
|
|
|
574
641
|
// hard-failing the upgrade. An EXECUTION-time failure (a transform
|
|
575
642
|
// throwing) is handled later by the codemod-error gate, which still
|
|
576
643
|
// aborts the upgrade.
|
|
644
|
+
/** @type {Map<string, Array<import('../../types/codemod').CodemodEntry>>} */
|
|
577
645
|
const integrationCodemodsByVersion = new Map();
|
|
578
646
|
for (const integration of integrations) {
|
|
579
647
|
if (!integration?.codemods) continue;
|
|
580
648
|
try {
|
|
581
649
|
const byVersion = await discoverIntegrationCodemods([integration]);
|
|
582
|
-
for (const [version,
|
|
650
|
+
for (const [version, rawList] of byVersion) {
|
|
651
|
+
// discoverIntegrationCodemods declares `codemod: object` (loose); the
|
|
652
|
+
// runtime entries carry the full CodemodEntry.codemod shape. Narrow
|
|
653
|
+
// to the map's element type. Report: integration-discovery.mjs's
|
|
654
|
+
// @returns should declare CodemodEntry instead of the loose object.
|
|
655
|
+
const list =
|
|
656
|
+
/** @type {Array<import('../../types/codemod').CodemodEntry>} */ (
|
|
657
|
+
/** @type {unknown} */ (rawList)
|
|
658
|
+
);
|
|
583
659
|
const existing = integrationCodemodsByVersion.get(version);
|
|
584
660
|
if (existing) existing.push(...list);
|
|
585
661
|
else integrationCodemodsByVersion.set(version, [...list]);
|
|
@@ -589,11 +665,14 @@ export function registerUpgrade(program) {
|
|
|
589
665
|
// above surfaces the underlying issue. Best-effort, non-blocking.
|
|
590
666
|
}
|
|
591
667
|
}
|
|
592
|
-
integrationVersionGroups =
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
668
|
+
integrationVersionGroups =
|
|
669
|
+
/** @type {Array<{version: string, codemods: import('../../types/codemod').CodemodEntry[]}>} */ (
|
|
670
|
+
selectIntegrationCodemods(
|
|
671
|
+
integrationCodemodsByVersion,
|
|
672
|
+
currentVersion,
|
|
673
|
+
targetVersion,
|
|
674
|
+
)
|
|
675
|
+
);
|
|
597
676
|
const hasIntegrationCodemods = integrationVersionGroups.some(
|
|
598
677
|
g => g.codemods.length > 0,
|
|
599
678
|
);
|
|
@@ -630,7 +709,7 @@ export function registerUpgrade(program) {
|
|
|
630
709
|
if (totalTransforms === 0 && totalOptional === 0) {
|
|
631
710
|
const msg = `Codemod "${options.codemod}" not found. Use --list to see available codemods.`;
|
|
632
711
|
if (json)
|
|
633
|
-
return jsonError(msg, {agentDocs}, ERROR_CODES.ERR_UNKNOWN_CODEMOD);
|
|
712
|
+
return jsonError(msg, /** @type {import('../../types/base').Suggestion[]} */ (/** @type {unknown} */ ({agentDocs})), ERROR_CODES.ERR_UNKNOWN_CODEMOD);
|
|
634
713
|
p.log.error(msg);
|
|
635
714
|
p.outro('Aborted');
|
|
636
715
|
process.exitCode = 1;
|
|
@@ -647,6 +726,26 @@ export function registerUpgrade(program) {
|
|
|
647
726
|
}
|
|
648
727
|
}
|
|
649
728
|
|
|
729
|
+
/**
|
|
730
|
+
* Terminal upgrade receipt. NOTE: the shape emitted here (with
|
|
731
|
+
* `integrations`, `filesChanged`, `transformsApplied`, `errors`) is what
|
|
732
|
+
* the command has always produced and what upgrade.test/config-ordering
|
|
733
|
+
* assert on; it does NOT match `UpgradeRunResponse.data` in
|
|
734
|
+
* types/upgrade.d.ts (which declares a stale `depsUpdated` field and omits
|
|
735
|
+
* these). The jsonOut call below is cast to bridge that drift. See the
|
|
736
|
+
* report: types/upgrade.d.ts needs reconciling with the real envelope.
|
|
737
|
+
* @type {{
|
|
738
|
+
* from: string,
|
|
739
|
+
* to: string,
|
|
740
|
+
* codemods: number,
|
|
741
|
+
* integrations: string[],
|
|
742
|
+
* agentDocsRefreshed: boolean,
|
|
743
|
+
* agentDocs: import('../../types/upgrade').AgentDocsSummary,
|
|
744
|
+
* filesChanged?: number,
|
|
745
|
+
* transformsApplied?: number,
|
|
746
|
+
* errors?: Array<{file: string, codemod: string, error: string}>,
|
|
747
|
+
* }}
|
|
748
|
+
*/
|
|
650
749
|
const receipt = {
|
|
651
750
|
from: currentVersion,
|
|
652
751
|
to: targetVersion,
|
|
@@ -679,17 +778,17 @@ export function registerUpgrade(program) {
|
|
|
679
778
|
// Merge core + integration codemod results into a single accounting so
|
|
680
779
|
// hooks, receipts, and error gating see both.
|
|
681
780
|
const mergedFilesChanged =
|
|
682
|
-
(
|
|
781
|
+
(coreResult?.totalFilesChanged ?? 0) +
|
|
683
782
|
(integrationResult?.totalFilesChanged ?? 0);
|
|
684
783
|
const mergedTransformsApplied =
|
|
685
|
-
(
|
|
784
|
+
(coreResult?.totalTransformsApplied ?? 0) +
|
|
686
785
|
(integrationResult?.totalTransformsApplied ?? 0);
|
|
687
786
|
const mergedWrittenFiles = [
|
|
688
|
-
...(
|
|
787
|
+
...(coreResult?.writtenFiles ?? []),
|
|
689
788
|
...(integrationResult?.writtenFiles ?? []),
|
|
690
789
|
];
|
|
691
790
|
const mergedErrors = [
|
|
692
|
-
...(
|
|
791
|
+
...(coreResult?.errors ?? []),
|
|
693
792
|
...(integrationResult?.errors ?? []),
|
|
694
793
|
];
|
|
695
794
|
|
|
@@ -714,13 +813,14 @@ export function registerUpgrade(program) {
|
|
|
714
813
|
json,
|
|
715
814
|
);
|
|
716
815
|
} catch (err) {
|
|
816
|
+
const hookErr = /** @type {Error} */ (err);
|
|
717
817
|
if (json)
|
|
718
818
|
return jsonError(
|
|
719
|
-
`Post-codemod hook failed: ${
|
|
720
|
-
{receipt},
|
|
819
|
+
`Post-codemod hook failed: ${hookErr.message}`,
|
|
820
|
+
/** @type {import('../../types/base').Suggestion[]} */ (/** @type {unknown} */ ({receipt})),
|
|
721
821
|
ERROR_CODES.ERR_CODEMOD_FAILED,
|
|
722
822
|
);
|
|
723
|
-
p.log.error(`Post-codemod hook failed: ${
|
|
823
|
+
p.log.error(`Post-codemod hook failed: ${hookErr.message}`);
|
|
724
824
|
p.outro('Upgrade failed');
|
|
725
825
|
process.exitCode = 1;
|
|
726
826
|
return;
|
|
@@ -738,7 +838,7 @@ export function registerUpgrade(program) {
|
|
|
738
838
|
if (receipt.errors?.length > 0) {
|
|
739
839
|
const msg = `Upgrade completed with ${receipt.errors.length} codemod error${receipt.errors.length === 1 ? '' : 's'}.`;
|
|
740
840
|
if (json) {
|
|
741
|
-
return jsonError(msg, {receipt}, ERROR_CODES.ERR_CODEMOD_FAILED);
|
|
841
|
+
return jsonError(msg, /** @type {import('../../types/base').Suggestion[]} */ (/** @type {unknown} */ ({receipt})), ERROR_CODES.ERR_CODEMOD_FAILED);
|
|
742
842
|
}
|
|
743
843
|
p.outro('Upgrade failed');
|
|
744
844
|
process.exitCode = 1;
|
|
@@ -746,7 +846,15 @@ export function registerUpgrade(program) {
|
|
|
746
846
|
}
|
|
747
847
|
|
|
748
848
|
if (json) {
|
|
749
|
-
|
|
849
|
+
// The emitted receipt intentionally differs from UpgradeRunResponse.data
|
|
850
|
+
// (see the typedef note above and the report): cast to the declared
|
|
851
|
+
// envelope shape until types/upgrade.d.ts is reconciled.
|
|
852
|
+
return jsonOut(
|
|
853
|
+
'upgrade.run',
|
|
854
|
+
/** @type {import('../../types/upgrade').UpgradeRunResponse['data']} */ (
|
|
855
|
+
/** @type {unknown} */ (receipt)
|
|
856
|
+
),
|
|
857
|
+
);
|
|
750
858
|
}
|
|
751
859
|
p.outro(options.apply ? 'Upgrade complete' : 'Dry run complete');
|
|
752
860
|
});
|
|
@@ -6,7 +6,7 @@ import * as path from 'node:path';
|
|
|
6
6
|
import * as os from 'node:os';
|
|
7
7
|
import {Command} from 'commander';
|
|
8
8
|
import {registerUpgrade} from './upgrade.mjs';
|
|
9
|
-
import {generateCompressedIndex} from '
|
|
9
|
+
import {generateCompressedIndex} from '../../lib/agent-docs/agent-docs.mjs';
|
|
10
10
|
|
|
11
11
|
let tmpDir;
|
|
12
12
|
let originalCwd;
|