@astryxdesign/cli 0.1.7 → 0.1.8-canary.07362a9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +40 -0
- package/README.md +115 -19
- 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 +13 -10
- package/{src/api → api}/error.mjs +2 -2
- 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 +133 -115
- package/cli/commands/build.mjs +172 -0
- package/cli/commands/cli-postinstall.test.mjs +42 -0
- package/{src → cli}/commands/component/index.mjs +52 -25
- 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 +23 -12
- package/{src → cli}/commands/docs.mjs +42 -10
- 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 +40 -17
- package/{src → cli}/commands/import-hint-correctness.test.mjs +1 -1
- package/cli/commands/init.mjs +195 -0
- package/{src → cli}/commands/init.next-steps.test.mjs +1 -1
- package/cli/commands/interactive-guard.test.mjs +66 -0
- package/{src → cli}/commands/json-contract.test.mjs +2 -2
- package/{src → cli}/commands/layout.mjs +59 -19
- package/{src → cli}/commands/search.mjs +22 -15
- package/{src → cli}/commands/search.test.mjs +1 -1
- package/cli/commands/setup-nudge.test.mjs +108 -0
- package/cli/commands/swizzle.mjs +103 -0
- package/{src → cli}/commands/template.mjs +84 -53
- 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 +291 -77
- package/cli/commands/upgrade.test.mjs +314 -0
- package/{src → cli}/commands/validate-integration.mjs +17 -37
- package/{src → cli}/index.mjs +55 -19
- package/{src/codemods → codemods}/__tests__/registry.test.mjs +1 -0
- package/{src/codemods → codemods}/ensure-jscodeshift.mjs +12 -28
- 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 +4 -1
- package/{src/codemods → codemods}/run-codemod.mjs +18 -11
- package/{src/codemods → codemods}/runner.mjs +24 -14
- 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/__tests__/drop-xds-prefix-imports.test.mjs +42 -7
- package/{src/codemods → codemods}/transforms/v0.1.0/__tests__/migrate-xds-module-specifiers.test.mjs +43 -0
- package/{src/codemods → codemods}/transforms/v0.1.0/drop-xds-prefix-imports.mjs +117 -13
- 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 +86 -15
- 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/codemods/transforms/v0.1.8/__tests__/rename-avatar-size-scale.test.mjs +161 -0
- package/codemods/transforms/v0.1.8/index.mjs +19 -0
- package/codemods/transforms/v0.1.8/rename-avatar-size-scale.mjs +239 -0
- package/docs/cli-integrations.doc.mjs +150 -0
- package/docs/elevation.doc.mjs +79 -1
- package/docs/getting-started.doc.mjs +9 -9
- package/docs/internationalization.doc.mjs +92 -46
- package/docs/migration.doc.mjs +18 -18
- package/docs/principles.doc.dense.mjs +1 -1
- package/docs/principles.doc.mjs +6 -6
- package/docs/principles.doc.zh.mjs +1 -1
- package/docs/styling-libraries.doc.mjs +3 -3
- package/docs/styling.doc.mjs +4 -4
- package/docs/theme.doc.dense.mjs +2 -2
- package/docs/theme.doc.mjs +7 -7
- package/docs/theme.doc.zh.mjs +1 -1
- package/docs/tokens.doc.mjs +1 -1
- package/docs/working-with-ai.doc.mjs +19 -19
- package/{src/commands → lib/agent-docs}/agent-docs.mjs +164 -29
- package/{src/commands → lib/agent-docs}/agent-docs.path-safety.test.mjs +1 -1
- package/{src/commands → lib/agent-docs}/agent-docs.test.mjs +123 -10
- package/{src/lib → lib}/cli-error.mjs +2 -2
- package/{src/lib → lib}/component-discovery.mjs +44 -2
- package/{src/lib → lib}/component-format.mjs +67 -25
- 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 +11 -6
- package/{src/lib → lib}/json-shim.test.mjs +1 -1
- package/{src/lib → lib}/json.mjs +3 -3
- 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/lib/term-log.mjs +57 -0
- 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 +37 -28
- package/scripts/postinstall.mjs +74 -0
- package/templates/blocks/components/Avatar/AvatarFallbackChain.tsx +4 -4
- package/templates/blocks/components/Avatar/AvatarGroup.tsx +2 -2
- package/templates/blocks/components/Avatar/AvatarInitialsFallback.tsx +1 -1
- package/templates/blocks/components/Avatar/AvatarShowcase.tsx +5 -5
- package/templates/blocks/components/Avatar/AvatarUserCard.tsx +1 -1
- package/templates/blocks/components/Avatar/AvatarWithImage.tsx +4 -4
- package/templates/blocks/components/Avatar/AvatarWithStatus.tsx +3 -3
- package/templates/blocks/components/AvatarGroup/AvatarGroupShowcase.tsx +2 -2
- package/templates/blocks/components/AvatarGroupOverflow/AvatarGroupOverflowCustomText.tsx +1 -1
- package/templates/blocks/components/AvatarGroupOverflow/AvatarGroupOverflowDefault.tsx +1 -1
- package/templates/blocks/components/AvatarGroupOverflow/AvatarGroupOverflowShowcase.tsx +2 -2
- package/templates/blocks/components/AvatarStatusDot/AvatarStatusDotShowcase.tsx +3 -3
- package/templates/blocks/components/AvatarStatusDot/AvatarStatusDotVariants.tsx +3 -3
- package/templates/blocks/components/Banner/BannerFloating.doc.mjs +14 -0
- package/templates/blocks/components/Banner/BannerFloating.tsx +16 -0
- package/templates/blocks/components/Button/ButtonFloating.doc.mjs +14 -0
- package/templates/blocks/components/Button/ButtonFloating.tsx +37 -0
- package/templates/blocks/components/ButtonGroup/ButtonGroupFloating.doc.mjs +14 -0
- package/templates/blocks/components/ButtonGroup/ButtonGroupFloating.tsx +23 -0
- package/templates/blocks/components/Card/CardElevations.doc.mjs +14 -0
- package/templates/blocks/components/Card/CardElevations.tsx +32 -0
- package/templates/blocks/components/Card/ClickableCardElevated.doc.mjs +14 -0
- package/templates/blocks/components/Card/ClickableCardElevated.tsx +21 -0
- package/templates/blocks/components/Card/SelectableCardElevated.doc.mjs +14 -0
- package/templates/blocks/components/Card/SelectableCardElevated.tsx +37 -0
- package/templates/blocks/components/Carousel/CarouselSnap.tsx +1 -1
- package/templates/blocks/components/ChatComposer/ChatComposerFlat.doc.mjs +14 -0
- package/templates/blocks/components/ChatComposer/ChatComposerFlat.tsx +75 -0
- package/templates/blocks/components/ChatMessage/ChatMessageAvatarName.tsx +2 -2
- package/templates/blocks/components/ChatMessage/ChatMessageMultiBubble.tsx +1 -1
- package/templates/blocks/components/ChatMessageBubble/ChatMessageBubbleGrouping.tsx +1 -1
- package/templates/blocks/components/ChatMessageBubble/ChatMessageBubbleMetadata.tsx +1 -1
- package/templates/blocks/components/ChatMessageList/ChatMessageListDensity.tsx +5 -9
- package/templates/blocks/components/ChatMessageList/ChatMessageListFullFeatured.tsx +1 -1
- package/templates/blocks/components/CodeBlock/CodeBlockTerminal.tsx +1 -1
- package/templates/blocks/components/HoverCard/HoverCardShowcase.tsx +1 -1
- package/templates/blocks/components/IconButton/IconButtonFloating.doc.mjs +14 -0
- package/templates/blocks/components/IconButton/IconButtonFloating.tsx +37 -0
- 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/templates/blocks/components/Item/ItemWithMedia.tsx +2 -2
- package/templates/blocks/components/ListItem/ListItemWithMedia.tsx +2 -2
- package/templates/blocks/components/OverflowList/OverflowListCappedToolbar.doc.mjs +14 -0
- package/templates/blocks/components/OverflowList/OverflowListCappedToolbar.tsx +39 -0
- package/templates/blocks/components/OverflowList/OverflowListMultiRowTags.doc.mjs +14 -0
- package/templates/blocks/components/OverflowList/OverflowListMultiRowTags.tsx +44 -0
- package/templates/blocks/components/Pagination/PaginationDotsCarousel.tsx +2 -6
- package/templates/blocks/components/Stack/StackFillItem.tsx +2 -6
- package/templates/blocks/components/TabList/TabListTabsWithActions.doc.mjs +1 -1
- package/templates/blocks/components/TabList/TabListTabsWithActions.tsx +2 -7
- package/templates/blocks/components/Table/TableRowStatusTable.doc.mjs +14 -0
- package/templates/blocks/components/Table/TableRowStatusTable.tsx +59 -0
- package/templates/blocks/components/Thumbnail/ThumbnailDisabled.tsx +6 -1
- package/templates/blocks/components/Thumbnail/ThumbnailGallery.tsx +1 -0
- package/templates/blocks/components/Thumbnail/ThumbnailRemovable.tsx +1 -0
- package/templates/blocks/components/TypeaheadItem/TypeaheadItemShowcase.tsx +1 -1
- package/templates/pages/ai-chat/page.tsx +4 -4
- package/templates/pages/dashboard-portfolio/page.tsx +3 -11
- package/templates/pages/detail-page/page.tsx +5 -12
- package/templates/pages/documentation-design/page.tsx +1 -1
- package/templates/pages/messaging-shell/page.tsx +6 -8
- package/templates/pages/table-grouped/page.tsx +9 -14
- package/templates/pages/table-page/page.tsx +7 -9
- package/templates/pages/table-page-heatmap-status/page.tsx +5 -13
- package/{src/types → types}/api.contract.assert.ts +17 -8
- package/{src/types → types}/api.d.ts +110 -9
- package/{src/types → types}/base.d.ts +40 -4
- 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/{src/types → types}/index.d.ts +1 -0
- package/types/jscodeshift.d.ts +19 -0
- package/types/layout.d.ts +74 -0
- package/{src/types → types}/swizzle.d.ts +4 -0
- package/{src/types → types}/template-api.d.ts +4 -1
- package/types/theme.d.ts +53 -0
- package/types/upgrade.d.ts +108 -0
- package/utils/package-manager.mjs +178 -0
- package/utils/package-manager.test.mjs +220 -0
- package/{src/utils → utils}/path-safety.mjs +0 -18
- package/{src/utils → utils}/paths.mjs +4 -1
- package/{src/utils → utils}/update-check.mjs +5 -4
- package/{src/utils → utils}/update-check.test.mjs +3 -3
- package/docs/integration-authoring.md +0 -105
- package/src/commands/build.mjs +0 -196
- package/src/commands/init.mjs +0 -288
- package/src/commands/interactive-guard.test.mjs +0 -69
- package/src/commands/swizzle.mjs +0 -440
- package/src/commands/upgrade.test.mjs +0 -160
- package/src/types/codemod.d.ts +0 -81
- package/src/types/theme.d.ts +0 -23
- package/src/types/upgrade.d.ts +0 -64
- package/src/utils/interactive.mjs +0 -76
- package/src/utils/interactive.test.mjs +0 -70
- package/src/utils/package-manager.mjs +0 -74
- package/src/utils/package-manager.test.mjs +0 -113
- /package/{src/api → api/docs}/docOverlays.test.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/component.test.mjs +0 -0
- /package/{src → cli}/commands/detail-levels.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__/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__/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__/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/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}/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}/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}/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}/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
|
@@ -34,6 +34,7 @@ export const meta = {
|
|
|
34
34
|
'Renames --elevation-* to --shadow-base/menu/hover/dialog and --inset-shadow-border-*. Also migrates --shadow-1/2/3/4 from the brief numeric naming period.',
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
+
/** @type {Record<string, string>} */
|
|
37
38
|
const TOKEN_MAP = {
|
|
38
39
|
'--elevation-input-hover-success': '--inset-shadow-border-positive',
|
|
39
40
|
'--elevation-input-hover-warning': '--inset-shadow-border-warning',
|
|
@@ -49,6 +50,7 @@ const TOKEN_MAP = {
|
|
|
49
50
|
'--shadow-4': '--shadow-dialog',
|
|
50
51
|
};
|
|
51
52
|
|
|
53
|
+
/** @type {Record<string, string>} */
|
|
52
54
|
const IDENTIFIER_MAP = {
|
|
53
55
|
elevationDefaults: 'shadowDefaults',
|
|
54
56
|
elevationVars: 'shadowVars',
|
|
@@ -64,16 +66,21 @@ const OLD_TOKENS_PATTERN = new RegExp(
|
|
|
64
66
|
'g',
|
|
65
67
|
);
|
|
66
68
|
|
|
67
|
-
function replaceTokens(str) {
|
|
68
|
-
return str.replace(OLD_TOKENS_PATTERN, (match) => TOKEN_MAP[match] || match);
|
|
69
|
+
function replaceTokens(/** @type {any} */ str) {
|
|
70
|
+
return str.replace(OLD_TOKENS_PATTERN, (/** @type {any} */ match) => TOKEN_MAP[match] || match);
|
|
69
71
|
}
|
|
70
72
|
|
|
73
|
+
/**
|
|
74
|
+
* @param {import('../../../types/codemod').AstryxCodemodFile} file
|
|
75
|
+
* @param {import('../../../types/codemod').CodemodTransformApi} api
|
|
76
|
+
* @returns {string | null | undefined}
|
|
77
|
+
*/
|
|
71
78
|
export default function transformer(file, api) {
|
|
72
79
|
const j = api.jscodeshift;
|
|
73
80
|
const root = j(file.source);
|
|
74
81
|
let hasChanges = false;
|
|
75
82
|
|
|
76
|
-
const replaceInStringNode = (path) => {
|
|
83
|
+
const replaceInStringNode = (/** @type {any} */ path) => {
|
|
77
84
|
if (typeof path.node.value !== 'string') return;
|
|
78
85
|
const original = path.node.value;
|
|
79
86
|
const replaced = replaceTokens(original);
|
|
@@ -84,11 +91,11 @@ export default function transformer(file, api) {
|
|
|
84
91
|
};
|
|
85
92
|
|
|
86
93
|
root.find(j.StringLiteral).forEach(replaceInStringNode);
|
|
87
|
-
root.find(j.Literal).forEach((path) => {
|
|
94
|
+
root.find(j.Literal).forEach((/** @type {any} */ path) => {
|
|
88
95
|
if (typeof path.node.value === 'string') replaceInStringNode(path);
|
|
89
96
|
});
|
|
90
97
|
|
|
91
|
-
root.find(j.TemplateLiteral).forEach((path) => {
|
|
98
|
+
root.find(j.TemplateLiteral).forEach((/** @type {any} */ path) => {
|
|
92
99
|
for (const quasi of path.node.quasis) {
|
|
93
100
|
const originalRaw = quasi.value.raw;
|
|
94
101
|
const replacedRaw = replaceTokens(originalRaw);
|
|
@@ -100,7 +107,7 @@ export default function transformer(file, api) {
|
|
|
100
107
|
}
|
|
101
108
|
});
|
|
102
109
|
|
|
103
|
-
root.find(j.Identifier).forEach((path) => {
|
|
110
|
+
root.find(j.Identifier).forEach((/** @type {any} */ path) => {
|
|
104
111
|
if (Object.hasOwn(IDENTIFIER_MAP, path.node.name)) {
|
|
105
112
|
path.node.name = IDENTIFIER_MAP[path.node.name];
|
|
106
113
|
hasChanges = true;
|
|
@@ -16,6 +16,7 @@ export const meta = {
|
|
|
16
16
|
'Replaces semantic radius prop values (inner, content, element, container) with numeric equivalents (0, 1, 2, 3).',
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
+
/** @type {Record<string, number>} */
|
|
19
20
|
const RADIUS_MAP = {
|
|
20
21
|
inner: 0,
|
|
21
22
|
content: 1,
|
|
@@ -23,6 +24,11 @@ const RADIUS_MAP = {
|
|
|
23
24
|
container: 3,
|
|
24
25
|
};
|
|
25
26
|
|
|
27
|
+
/**
|
|
28
|
+
* @param {import('../../../types/codemod').AstryxCodemodFile} file
|
|
29
|
+
* @param {import('../../../types/codemod').CodemodTransformApi} api
|
|
30
|
+
* @returns {string | null | undefined}
|
|
31
|
+
*/
|
|
26
32
|
export default function transformer(file, api) {
|
|
27
33
|
const j = api.jscodeshift;
|
|
28
34
|
const root = j(file.source);
|
|
@@ -32,7 +38,7 @@ export default function transformer(file, api) {
|
|
|
32
38
|
.find(j.JSXOpeningElement, {
|
|
33
39
|
name: {name: 'XDSSkeleton'},
|
|
34
40
|
})
|
|
35
|
-
.forEach((path) => {
|
|
41
|
+
.forEach((/** @type {any} */ path) => {
|
|
36
42
|
const attrs = path.node.attributes;
|
|
37
43
|
for (const attr of attrs) {
|
|
38
44
|
if (attr.type !== 'JSXAttribute') continue;
|
|
@@ -66,6 +66,7 @@ export const meta = {
|
|
|
66
66
|
|
|
67
67
|
// Ordered longest-first to prevent partial matches
|
|
68
68
|
// (e.g. --color-educational-deemphasized must match before --color-educational)
|
|
69
|
+
/** @type {Record<string, string>} */
|
|
69
70
|
const TOKEN_MAP = {
|
|
70
71
|
'--color-educational-deemphasized': '--color-info-muted',
|
|
71
72
|
'--color-divider-high-contrast': '--color-border-strong',
|
|
@@ -114,17 +115,22 @@ const OLD_TOKENS_PATTERN = new RegExp(
|
|
|
114
115
|
'g',
|
|
115
116
|
);
|
|
116
117
|
|
|
117
|
-
function replaceTokens(str) {
|
|
118
|
-
return str.replace(OLD_TOKENS_PATTERN, (match) => TOKEN_MAP[match] || match);
|
|
118
|
+
function replaceTokens(/** @type {any} */ str) {
|
|
119
|
+
return str.replace(OLD_TOKENS_PATTERN, (/** @type {any} */ match) => TOKEN_MAP[match] || match);
|
|
119
120
|
}
|
|
120
121
|
|
|
122
|
+
/**
|
|
123
|
+
* @param {import('../../../types/codemod').AstryxCodemodFile} file
|
|
124
|
+
* @param {import('../../../types/codemod').CodemodTransformApi} api
|
|
125
|
+
* @returns {string | null | undefined}
|
|
126
|
+
*/
|
|
121
127
|
export default function transformer(file, api) {
|
|
122
128
|
const j = api.jscodeshift;
|
|
123
129
|
const root = j(file.source);
|
|
124
130
|
let hasChanges = false;
|
|
125
131
|
|
|
126
132
|
// Replace in string literals (StringLiteral or Literal with string value)
|
|
127
|
-
const replaceInStringNode = (path) => {
|
|
133
|
+
const replaceInStringNode = (/** @type {any} */ path) => {
|
|
128
134
|
if (typeof path.node.value !== 'string') return;
|
|
129
135
|
const original = path.node.value;
|
|
130
136
|
const replaced = replaceTokens(original);
|
|
@@ -135,14 +141,14 @@ export default function transformer(file, api) {
|
|
|
135
141
|
};
|
|
136
142
|
|
|
137
143
|
root.find(j.StringLiteral).forEach(replaceInStringNode);
|
|
138
|
-
root.find(j.Literal).forEach((path) => {
|
|
144
|
+
root.find(j.Literal).forEach((/** @type {any} */ path) => {
|
|
139
145
|
if (typeof path.node.value === 'string') {
|
|
140
146
|
replaceInStringNode(path);
|
|
141
147
|
}
|
|
142
148
|
});
|
|
143
149
|
|
|
144
150
|
// Replace in template literal quasis
|
|
145
|
-
root.find(j.TemplateLiteral).forEach((path) => {
|
|
151
|
+
root.find(j.TemplateLiteral).forEach((/** @type {any} */ path) => {
|
|
146
152
|
for (const quasi of path.node.quasis) {
|
|
147
153
|
const original = quasi.value.raw;
|
|
148
154
|
const replaced = replaceTokens(original);
|
|
@@ -20,6 +20,11 @@ export const meta = {
|
|
|
20
20
|
pr: '#814',
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* @param {import('../../../types/codemod').AstryxCodemodFile} file
|
|
25
|
+
* @param {import('../../../types/codemod').CodemodTransformApi} api
|
|
26
|
+
* @returns {string | null | undefined}
|
|
27
|
+
*/
|
|
23
28
|
export default function transformer(file, api) {
|
|
24
29
|
const j = api.jscodeshift;
|
|
25
30
|
const root = j(file.source);
|
|
@@ -30,8 +35,8 @@ export default function transformer(file, api) {
|
|
|
30
35
|
.find(j.JSXOpeningElement, {
|
|
31
36
|
name: {name: 'XDSBanner'},
|
|
32
37
|
})
|
|
33
|
-
.forEach((path) => {
|
|
34
|
-
path.node.attributes.forEach((attr) => {
|
|
38
|
+
.forEach((/** @type {any} */ path) => {
|
|
39
|
+
path.node.attributes.forEach((/** @type {any} */ attr) => {
|
|
35
40
|
if (attr.type === 'JSXAttribute' && attr.name.name === 'variant') {
|
|
36
41
|
attr.name.name = 'container';
|
|
37
42
|
hasChanges = true;
|
|
@@ -40,7 +45,7 @@ export default function transformer(file, api) {
|
|
|
40
45
|
});
|
|
41
46
|
|
|
42
47
|
// 2. Rename type references: XDSBannerVariant → XDSBannerContainer
|
|
43
|
-
root.find(j.Identifier, {name: 'XDSBannerVariant'}).forEach((path) => {
|
|
48
|
+
root.find(j.Identifier, {name: 'XDSBannerVariant'}).forEach((/** @type {any} */ path) => {
|
|
44
49
|
path.node.name = 'XDSBannerContainer';
|
|
45
50
|
hasChanges = true;
|
|
46
51
|
});
|
|
@@ -50,6 +50,7 @@ export const meta = {
|
|
|
50
50
|
// Token string renames (CSS custom property names)
|
|
51
51
|
// =============================================================================
|
|
52
52
|
|
|
53
|
+
/** @type {Record<string, string>} */
|
|
53
54
|
const TOKEN_MAP = {
|
|
54
55
|
// Color — Core Semantic
|
|
55
56
|
'--color-secondary': '--color-neutral',
|
|
@@ -195,6 +196,7 @@ const TOKEN_MAP = {
|
|
|
195
196
|
// JS identifier renames (import names, variable references)
|
|
196
197
|
// =============================================================================
|
|
197
198
|
|
|
199
|
+
/** @type {Record<string, string>} */
|
|
198
200
|
const IDENTIFIER_MAP = {
|
|
199
201
|
lineHeightVars: 'typeScaleVars',
|
|
200
202
|
lineHeightDefaults: 'typeScaleDefaults',
|
|
@@ -213,21 +215,26 @@ const OLD_TOKENS_PATTERN = new RegExp(
|
|
|
213
215
|
'g',
|
|
214
216
|
);
|
|
215
217
|
|
|
216
|
-
function replaceTokens(str) {
|
|
217
|
-
return str.replace(OLD_TOKENS_PATTERN, (match) => TOKEN_MAP[match] || match);
|
|
218
|
+
function replaceTokens(/** @type {any} */ str) {
|
|
219
|
+
return str.replace(OLD_TOKENS_PATTERN, (/** @type {any} */ match) => TOKEN_MAP[match] || match);
|
|
218
220
|
}
|
|
219
221
|
|
|
220
222
|
// =============================================================================
|
|
221
223
|
// Transformer
|
|
222
224
|
// =============================================================================
|
|
223
225
|
|
|
226
|
+
/**
|
|
227
|
+
* @param {import('../../../types/codemod').AstryxCodemodFile} file
|
|
228
|
+
* @param {import('../../../types/codemod').CodemodTransformApi} api
|
|
229
|
+
* @returns {string | null | undefined}
|
|
230
|
+
*/
|
|
224
231
|
export default function transformer(file, api) {
|
|
225
232
|
const j = api.jscodeshift;
|
|
226
233
|
const root = j(file.source);
|
|
227
234
|
let hasChanges = false;
|
|
228
235
|
|
|
229
236
|
// --- Pass 1: Rename token strings in string literals ---
|
|
230
|
-
const replaceInStringNode = (path) => {
|
|
237
|
+
const replaceInStringNode = (/** @type {any} */ path) => {
|
|
231
238
|
if (typeof path.node.value !== 'string') return;
|
|
232
239
|
const original = path.node.value;
|
|
233
240
|
const replaced = replaceTokens(original);
|
|
@@ -238,14 +245,14 @@ export default function transformer(file, api) {
|
|
|
238
245
|
};
|
|
239
246
|
|
|
240
247
|
root.find(j.StringLiteral).forEach(replaceInStringNode);
|
|
241
|
-
root.find(j.Literal).forEach((path) => {
|
|
248
|
+
root.find(j.Literal).forEach((/** @type {any} */ path) => {
|
|
242
249
|
if (typeof path.node.value === 'string') {
|
|
243
250
|
replaceInStringNode(path);
|
|
244
251
|
}
|
|
245
252
|
});
|
|
246
253
|
|
|
247
254
|
// --- Pass 2: Rename token strings in template literals ---
|
|
248
|
-
root.find(j.TemplateLiteral).forEach((path) => {
|
|
255
|
+
root.find(j.TemplateLiteral).forEach((/** @type {any} */ path) => {
|
|
249
256
|
for (const quasi of path.node.quasis) {
|
|
250
257
|
const original = quasi.value.raw;
|
|
251
258
|
const replaced = replaceTokens(original);
|
|
@@ -263,7 +270,7 @@ export default function transformer(file, api) {
|
|
|
263
270
|
// Special handling for imports: if the target name already exists as an import
|
|
264
271
|
// specifier in the same declaration, remove the old specifier instead of renaming
|
|
265
272
|
// it (avoids duplicate identifier declarations).
|
|
266
|
-
root.find(j.ImportSpecifier).forEach((importPath) => {
|
|
273
|
+
root.find(j.ImportSpecifier).forEach((/** @type {any} */ importPath) => {
|
|
267
274
|
const oldName = importPath.node.imported.name;
|
|
268
275
|
if (!Object.hasOwn(IDENTIFIER_MAP, oldName)) return;
|
|
269
276
|
|
|
@@ -271,7 +278,7 @@ export default function transformer(file, api) {
|
|
|
271
278
|
const declaration = importPath.parent.node;
|
|
272
279
|
const siblings = declaration.specifiers || [];
|
|
273
280
|
const targetExists = siblings.some(
|
|
274
|
-
(s) =>
|
|
281
|
+
(/** @type {any} */ s) =>
|
|
275
282
|
s !== importPath.node &&
|
|
276
283
|
s.type === 'ImportSpecifier' &&
|
|
277
284
|
s.imported.name === newName,
|
|
@@ -295,7 +302,7 @@ export default function transformer(file, api) {
|
|
|
295
302
|
});
|
|
296
303
|
|
|
297
304
|
// Rename remaining non-import identifier references
|
|
298
|
-
root.find(j.Identifier).forEach((path) => {
|
|
305
|
+
root.find(j.Identifier).forEach((/** @type {any} */ path) => {
|
|
299
306
|
if (!Object.hasOwn(IDENTIFIER_MAP, path.node.name)) return;
|
|
300
307
|
// Skip import specifiers (already handled above)
|
|
301
308
|
if (path.parent.node.type === 'ImportSpecifier') return;
|
|
@@ -23,13 +23,18 @@ export const meta = {
|
|
|
23
23
|
pr: '#895',
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* @param {import('../../../types/codemod').AstryxCodemodFile} file
|
|
28
|
+
* @param {import('../../../types/codemod').CodemodTransformApi} api
|
|
29
|
+
* @returns {string | null | undefined}
|
|
30
|
+
*/
|
|
26
31
|
export default function transformer(file, api) {
|
|
27
32
|
const j = api.jscodeshift;
|
|
28
33
|
const root = j(file.source);
|
|
29
34
|
let hasChanges = false;
|
|
30
35
|
|
|
31
36
|
// 1. Rename JSX prop: <XDSButton endSlot={...} /> → <XDSButton endContent={...} />
|
|
32
|
-
root.find(j.JSXAttribute, {name: {name: 'endSlot'}}).forEach((path) => {
|
|
37
|
+
root.find(j.JSXAttribute, {name: {name: 'endSlot'}}).forEach((/** @type {any} */ path) => {
|
|
33
38
|
path.node.name.name = 'endContent';
|
|
34
39
|
hasChanges = true;
|
|
35
40
|
});
|
|
@@ -37,7 +42,7 @@ export default function transformer(file, api) {
|
|
|
37
42
|
// 2. Rename in all Identifier nodes named 'endSlot' that are object keys
|
|
38
43
|
// This covers both Property and ObjectProperty (parser-dependent),
|
|
39
44
|
// object literals, destructuring patterns, etc.
|
|
40
|
-
root.find(j.Identifier, {name: 'endSlot'}).forEach((path) => {
|
|
45
|
+
root.find(j.Identifier, {name: 'endSlot'}).forEach((/** @type {any} */ path) => {
|
|
41
46
|
const parent = path.parent.node;
|
|
42
47
|
|
|
43
48
|
// Object property key: { endSlot: value } or { endSlot } (shorthand)
|
package/{src/codemods → codemods}/transforms/v0.1.0/__tests__/drop-xds-prefix-imports.test.mjs
RENAMED
|
@@ -166,15 +166,50 @@ describe('drop-xds-prefix-imports', () => {
|
|
|
166
166
|
expect(output).toContain('export const other = Card;');
|
|
167
167
|
});
|
|
168
168
|
|
|
169
|
-
it('un-prefixes
|
|
169
|
+
it('un-prefixes override keys inside an @xds/core mock factory', async () => {
|
|
170
170
|
const input = [
|
|
171
|
-
`
|
|
172
|
-
`
|
|
171
|
+
`vi.mock('@xds/core/Text', async orig => ({`,
|
|
172
|
+
` ...(await orig<typeof import('@xds/core/Text')>()),`,
|
|
173
|
+
` useXDSTruncation: () => ({ref: vi.fn(), isTruncated: true, fullText: ''}),`,
|
|
174
|
+
`}));`,
|
|
173
175
|
].join('\n');
|
|
174
176
|
const output = await applyTransform(input);
|
|
175
|
-
expect(output).toContain('
|
|
176
|
-
expect(output).toContain('
|
|
177
|
-
|
|
178
|
-
|
|
177
|
+
expect(output).toContain('useTruncation:');
|
|
178
|
+
expect(output).not.toContain('useXDSTruncation');
|
|
179
|
+
// This codemod does not touch the module-path string (that is the
|
|
180
|
+
// module-specifiers codemod's job); the @xds/core/Text path stays here.
|
|
181
|
+
expect(output).toContain(`vi.mock('@xds/core/Text'`);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it('un-prefixes component override keys inside a bare @xds/core jest.mock factory', async () => {
|
|
185
|
+
const input = [
|
|
186
|
+
`jest.mock('@xds/core', () => ({`,
|
|
187
|
+
` XDSButton: () => null,`,
|
|
188
|
+
` useXDSToast: () => ({}),`,
|
|
189
|
+
`}));`,
|
|
190
|
+
].join('\n');
|
|
191
|
+
const output = await applyTransform(input);
|
|
192
|
+
expect(output).toContain('Button:');
|
|
193
|
+
expect(output).toContain('useToast:');
|
|
194
|
+
expect(output).not.toContain('XDSButton');
|
|
195
|
+
expect(output).not.toContain('useXDSToast');
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it('does NOT touch mock factory keys for a non-@xds package', async () => {
|
|
199
|
+
const input = [
|
|
200
|
+
`vi.mock('some-other-pkg', () => ({`,
|
|
201
|
+
` useXDSFoo: () => 1,`,
|
|
202
|
+
`}));`,
|
|
203
|
+
].join('\n');
|
|
204
|
+
const output = await applyTransform(input);
|
|
205
|
+
expect(output).toBe(input);
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it('does NOT touch useXDS keys in an unrelated object literal (not a mock factory)', async () => {
|
|
209
|
+
const input = [`const config = {`, ` useXDSWhatever: true,`, `};`].join(
|
|
210
|
+
'\n',
|
|
211
|
+
);
|
|
212
|
+
const output = await applyTransform(input);
|
|
213
|
+
expect(output).toBe(input);
|
|
179
214
|
});
|
|
180
215
|
});
|
package/{src/codemods → codemods}/transforms/v0.1.0/__tests__/migrate-xds-module-specifiers.test.mjs
RENAMED
|
@@ -89,4 +89,47 @@ describe('migrate-xds-module-specifiers', () => {
|
|
|
89
89
|
expect(output).not.toContain('defaultTheme');
|
|
90
90
|
expect(output).not.toContain('neutralTheme as');
|
|
91
91
|
});
|
|
92
|
+
|
|
93
|
+
it('rewrites the mocked module path in vi.mock (including the inline import() type arg)', async () => {
|
|
94
|
+
const input = [
|
|
95
|
+
"vi.mock('@xds/core/Text', async orig => ({",
|
|
96
|
+
" ...(await orig<typeof import('@xds/core/Text')>()),",
|
|
97
|
+
'}));',
|
|
98
|
+
].join('\n');
|
|
99
|
+
const output = await applyTransform(input);
|
|
100
|
+
expect(output).toMatch(/vi\.mock\(['"]@astryxdesign\/core\/Text['"]/);
|
|
101
|
+
// The inline dynamic import() type argument is rewritten too.
|
|
102
|
+
expect(output).toMatch(/import\(['"]@astryxdesign\/core\/Text['"]\)/);
|
|
103
|
+
expect(output).not.toContain('@xds/');
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('rewrites the mocked module path in jest.mock (bare @xds/core)', async () => {
|
|
107
|
+
const output = await applyTransform(
|
|
108
|
+
"jest.mock('@xds/core', () => ({}));",
|
|
109
|
+
'test.ts',
|
|
110
|
+
);
|
|
111
|
+
expect(output).toMatch(/jest\.mock\(['"]@astryxdesign\/core['"]/);
|
|
112
|
+
expect(output).not.toContain('@xds/');
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('rewrites vi.doMock / jest.doMock and a bare mock() call', async () => {
|
|
116
|
+
const output = await applyTransform(
|
|
117
|
+
[
|
|
118
|
+
"vi.doMock('@xds/lab/Thing', () => ({}));",
|
|
119
|
+
"jest.doMock('@xds/core/Text', () => ({}));",
|
|
120
|
+
"mock('@xds/core', () => ({}));",
|
|
121
|
+
].join('\n'),
|
|
122
|
+
'test.ts',
|
|
123
|
+
);
|
|
124
|
+
expect(output).toMatch(/vi\.doMock\(['"]@astryxdesign\/lab\/Thing['"]/);
|
|
125
|
+
expect(output).toMatch(/jest\.doMock\(['"]@astryxdesign\/core\/Text['"]/);
|
|
126
|
+
expect(output).toMatch(/[^.]mock\(['"]@astryxdesign\/core['"]/);
|
|
127
|
+
expect(output).not.toContain('@xds/');
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('does NOT rewrite the mock path for a non-@xds package', async () => {
|
|
131
|
+
const input = "vi.mock('some-other-pkg', () => ({useXDSFoo: () => 1}));";
|
|
132
|
+
const output = await applyTransform(input);
|
|
133
|
+
expect(output).toBe(input);
|
|
134
|
+
});
|
|
92
135
|
});
|
|
@@ -35,11 +35,19 @@
|
|
|
35
35
|
* including type references in generic type-argument positions such as
|
|
36
36
|
* `useMemo<XDSTableColumn<Issue>[]>(...)`
|
|
37
37
|
* 3. Re-exports from @xds/core: export {XDSButton} from '@xds/core/Button'
|
|
38
|
+
* 4. Object-property keys inside a test-framework mock factory for an
|
|
39
|
+
* `@xds/core` module: the partial-mock override in
|
|
40
|
+
* `vi.mock('@xds/core/Text', async orig => ({...await orig(),
|
|
41
|
+
* useXDSTruncation: () => ...}))` must be un-prefixed to `useTruncation`,
|
|
42
|
+
* otherwise the key targets a name the renamed module no longer exports and
|
|
43
|
+
* the mock silently overrides nothing.
|
|
38
44
|
*
|
|
39
45
|
* Does NOT touch:
|
|
40
46
|
* - import source paths (`@xds/core/Button` stays -- subpath dirs are unchanged
|
|
41
47
|
* by the prefix migration)
|
|
42
48
|
* - identifiers not bound to an @xds/core import
|
|
49
|
+
* - object-property keys outside an `@xds/core` mock factory (an unrelated
|
|
50
|
+
* `{useXDSFoo: ...}` literal, or a mock of some other package, is untouched)
|
|
43
51
|
* - the `XDSBaseProps`-style names only when they are NOT imported from core
|
|
44
52
|
*/
|
|
45
53
|
|
|
@@ -48,7 +56,8 @@ export const meta = {
|
|
|
48
56
|
description:
|
|
49
57
|
'Rewrites @xds/core imports and their usages from the prefixed names ' +
|
|
50
58
|
'(XDSButton, useXDSTheme, XDSIconRegistry, XDSButtonProps) to their bare ' +
|
|
51
|
-
'names (Button, useTheme, IconRegistry, ButtonProps)
|
|
59
|
+
'names (Button, useTheme, IconRegistry, ButtonProps), including override ' +
|
|
60
|
+
'keys in a vi.mock/jest.mock factory for an @xds/core module. Only renames ' +
|
|
52
61
|
'bindings imported from @xds/core, leaving unrelated identifiers untouched.',
|
|
53
62
|
pr: '#2880',
|
|
54
63
|
};
|
|
@@ -59,7 +68,7 @@ const XDS_CORE_SOURCE = /^@xds\/core(\/.*)?$/;
|
|
|
59
68
|
* Compute the bare (unprefixed) name for an XDS-prefixed identifier.
|
|
60
69
|
* Returns null if the name is not XDS-prefixed in a renameable way.
|
|
61
70
|
*/
|
|
62
|
-
function bareName(name) {
|
|
71
|
+
function bareName(/** @type {any} */ name) {
|
|
63
72
|
if (name.startsWith('useXDS') && name.length > 'useXDS'.length) {
|
|
64
73
|
return 'use' + name.slice('useXDS'.length);
|
|
65
74
|
}
|
|
@@ -74,6 +83,86 @@ function bareName(name) {
|
|
|
74
83
|
return null;
|
|
75
84
|
}
|
|
76
85
|
|
|
86
|
+
// A test-framework mock of an `@xds/core` module (`vi.mock('@xds/core/Text',
|
|
87
|
+
// factory)`). We only rewrite override keys inside such a factory, so scope the
|
|
88
|
+
// detection tightly: callee must be `vi.mock`/`vi.doMock`/`jest.mock`/
|
|
89
|
+
// `jest.doMock` (or a bare `mock`) AND the first argument must be a string
|
|
90
|
+
// literal that resolves to `@xds/core` (bare or subpath).
|
|
91
|
+
const MOCK_METHOD_NAMES = new Set(['mock', 'doMock']);
|
|
92
|
+
const MOCK_OBJECT_NAMES = new Set(['vi', 'jest']);
|
|
93
|
+
|
|
94
|
+
function isMockCallee(/** @type {any} */ callee) {
|
|
95
|
+
if (
|
|
96
|
+
callee.type === 'MemberExpression' &&
|
|
97
|
+
!callee.computed &&
|
|
98
|
+
callee.object.type === 'Identifier' &&
|
|
99
|
+
MOCK_OBJECT_NAMES.has(callee.object.name) &&
|
|
100
|
+
callee.property.type === 'Identifier' &&
|
|
101
|
+
MOCK_METHOD_NAMES.has(callee.property.name)
|
|
102
|
+
) {
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
return callee.type === 'Identifier' && callee.name === 'mock';
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function isXdsCoreMockCall(/** @type {any} */ node) {
|
|
109
|
+
if (node.type !== 'CallExpression' || !isMockCallee(node.callee))
|
|
110
|
+
return false;
|
|
111
|
+
const [arg] = node.arguments;
|
|
112
|
+
const value =
|
|
113
|
+
arg && (arg.type === 'StringLiteral' || arg.type === 'Literal')
|
|
114
|
+
? arg.value
|
|
115
|
+
: null;
|
|
116
|
+
return typeof value === 'string' && XDS_CORE_SOURCE.test(value);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Rename XDS-prefixed object-property KEYS (not values, not nested objects)
|
|
120
|
+
// within the given AST subtree. Used only on a recognized @xds/core mock
|
|
121
|
+
// factory, so the scope guard lives at the call site.
|
|
122
|
+
function renameMockFactoryKeys(/** @type {any} */ node, /** @type {any} */ seen, /** @type {any} */ onChange) {
|
|
123
|
+
if (!node || typeof node !== 'object') return;
|
|
124
|
+
if (Array.isArray(node)) {
|
|
125
|
+
for (const child of node) renameMockFactoryKeys(child, seen, onChange);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if (seen.has(node)) return;
|
|
129
|
+
seen.add(node);
|
|
130
|
+
|
|
131
|
+
if (
|
|
132
|
+
(node.type === 'ObjectProperty' || node.type === 'Property') &&
|
|
133
|
+
!node.computed &&
|
|
134
|
+
node.key &&
|
|
135
|
+
node.key.type === 'Identifier'
|
|
136
|
+
) {
|
|
137
|
+
const bare = bareName(node.key.name);
|
|
138
|
+
if (bare && bare !== node.key.name) {
|
|
139
|
+
node.key.name = bare;
|
|
140
|
+
onChange();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
for (const key of Object.keys(node)) {
|
|
145
|
+
if (
|
|
146
|
+
key === 'loc' ||
|
|
147
|
+
key === 'start' ||
|
|
148
|
+
key === 'end' ||
|
|
149
|
+
key === 'range' ||
|
|
150
|
+
key === 'comments' ||
|
|
151
|
+
key === 'leadingComments' ||
|
|
152
|
+
key === 'trailingComments' ||
|
|
153
|
+
key === 'tokens'
|
|
154
|
+
) {
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
renameMockFactoryKeys(node[key], seen, onChange);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* @param {import('../../../types/codemod').AstryxCodemodFile} file
|
|
163
|
+
* @param {import('../../../types/codemod').CodemodTransformApi} api
|
|
164
|
+
* @returns {string | null | undefined}
|
|
165
|
+
*/
|
|
77
166
|
export default function transformer(file, api) {
|
|
78
167
|
const j = api.jscodeshift;
|
|
79
168
|
const root = j(file.source);
|
|
@@ -92,12 +181,12 @@ export default function transformer(file, api) {
|
|
|
92
181
|
// declaration. We gather: import locals, and top-level function/class/var
|
|
93
182
|
// declaration names (the realistic collision sources for component wrappers).
|
|
94
183
|
const existingBindings = new Set();
|
|
95
|
-
root.find(j.ImportDeclaration).forEach(path => {
|
|
184
|
+
root.find(j.ImportDeclaration).forEach((/** @type {any} */ path) => {
|
|
96
185
|
for (const spec of path.node.specifiers || []) {
|
|
97
186
|
if (spec.local && spec.local.name) existingBindings.add(spec.local.name);
|
|
98
187
|
}
|
|
99
188
|
});
|
|
100
|
-
const collectDeclName = node => {
|
|
189
|
+
const collectDeclName = (/** @type {any} */ node) => {
|
|
101
190
|
if (!node) return;
|
|
102
191
|
if (
|
|
103
192
|
(node.type === 'FunctionDeclaration' ||
|
|
@@ -111,7 +200,7 @@ export default function transformer(file, api) {
|
|
|
111
200
|
}
|
|
112
201
|
}
|
|
113
202
|
};
|
|
114
|
-
root.find(j.Program).forEach(path => {
|
|
203
|
+
root.find(j.Program).forEach((/** @type {any} */ path) => {
|
|
115
204
|
for (const stmt of path.node.body) {
|
|
116
205
|
collectDeclName(stmt);
|
|
117
206
|
// Unwrap `export function X` / `export const X`.
|
|
@@ -125,11 +214,11 @@ export default function transformer(file, api) {
|
|
|
125
214
|
});
|
|
126
215
|
|
|
127
216
|
// 1. Rewrite import specifiers from @xds/core
|
|
128
|
-
root.find(j.ImportDeclaration).forEach(path => {
|
|
217
|
+
root.find(j.ImportDeclaration).forEach((/** @type {any} */ path) => {
|
|
129
218
|
const source = path.node.source.value;
|
|
130
219
|
if (typeof source !== 'string' || !XDS_CORE_SOURCE.test(source)) return;
|
|
131
220
|
|
|
132
|
-
path.node.specifiers = (path.node.specifiers || []).map(spec => {
|
|
221
|
+
path.node.specifiers = (path.node.specifiers || []).map((/** @type {any} */ spec) => {
|
|
133
222
|
if (spec.type !== 'ImportSpecifier') return spec; // default/namespace
|
|
134
223
|
const importedName = spec.imported.name;
|
|
135
224
|
const bare = bareName(importedName);
|
|
@@ -169,7 +258,7 @@ export default function transformer(file, api) {
|
|
|
169
258
|
});
|
|
170
259
|
|
|
171
260
|
// 2. Rewrite re-exports from @xds/core
|
|
172
|
-
root.find(j.ExportNamedDeclaration).forEach(path => {
|
|
261
|
+
root.find(j.ExportNamedDeclaration).forEach((/** @type {any} */ path) => {
|
|
173
262
|
if (!path.node.source) return;
|
|
174
263
|
const source = path.node.source.value;
|
|
175
264
|
if (typeof source !== 'string' || !XDS_CORE_SOURCE.test(source)) return;
|
|
@@ -190,13 +279,28 @@ export default function transformer(file, api) {
|
|
|
190
279
|
}
|
|
191
280
|
});
|
|
192
281
|
|
|
282
|
+
// 3. Un-prefix override keys inside @xds/core mock factories. Independent of
|
|
283
|
+
// the import bindings above: the override key is a factory object property,
|
|
284
|
+
// not a reference to an imported binding, so it must match the renamed export
|
|
285
|
+
// name of the mocked module regardless of what the file imports.
|
|
286
|
+
const seenMockNodes = new Set();
|
|
287
|
+
root.find(j.CallExpression).forEach((/** @type {any} */ path) => {
|
|
288
|
+
if (!isXdsCoreMockCall(path.node)) return;
|
|
289
|
+
// Only walk the factory argument(s), never the module-path string.
|
|
290
|
+
for (const arg of path.node.arguments.slice(1)) {
|
|
291
|
+
renameMockFactoryKeys(arg, seenMockNodes, () => {
|
|
292
|
+
hasChanges = true;
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
|
|
193
297
|
if (localRenames.size === 0) {
|
|
194
298
|
return hasChanges ? root.toSource() : undefined;
|
|
195
299
|
}
|
|
196
300
|
|
|
197
|
-
//
|
|
301
|
+
// 4. Rename references to renamed local bindings
|
|
198
302
|
// Identifiers (type refs, value refs, etc.)
|
|
199
|
-
root.find(j.Identifier).forEach(path => {
|
|
303
|
+
root.find(j.Identifier).forEach((/** @type {any} */ path) => {
|
|
200
304
|
const newName = localRenames.get(path.node.name);
|
|
201
305
|
if (!newName) return;
|
|
202
306
|
// Skip object property keys like `{ XDSButton: ... }` (not a reference to
|
|
@@ -223,7 +327,7 @@ export default function transformer(file, api) {
|
|
|
223
327
|
});
|
|
224
328
|
|
|
225
329
|
// JSX element names: <XDSButton> -> <Button>
|
|
226
|
-
root.find(j.JSXIdentifier).forEach(path => {
|
|
330
|
+
root.find(j.JSXIdentifier).forEach((/** @type {any} */ path) => {
|
|
227
331
|
const newName = localRenames.get(path.node.name);
|
|
228
332
|
if (newName) {
|
|
229
333
|
path.node.name = newName;
|
|
@@ -231,7 +335,7 @@ export default function transformer(file, api) {
|
|
|
231
335
|
}
|
|
232
336
|
});
|
|
233
337
|
|
|
234
|
-
//
|
|
338
|
+
// 5. Rename TS type references in generic type-argument positions.
|
|
235
339
|
//
|
|
236
340
|
// `j.find(j.Identifier)` (and `j.find(j.TSTypeReference)`) do NOT visit
|
|
237
341
|
// identifiers nested inside generic type arguments with the tsx/babel parser
|
|
@@ -245,7 +349,7 @@ export default function transformer(file, api) {
|
|
|
245
349
|
// renamed binding. Renaming already-bare names is a no-op, so re-visiting a
|
|
246
350
|
// node the earlier passes handled is harmless.
|
|
247
351
|
const seenTypeNodes = new Set();
|
|
248
|
-
const renameTypeReferences = node => {
|
|
352
|
+
const renameTypeReferences = (/** @type {any} */ node) => {
|
|
249
353
|
if (!node || typeof node !== 'object') return;
|
|
250
354
|
if (Array.isArray(node)) {
|
|
251
355
|
for (const child of node) renameTypeReferences(child);
|