@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
|
@@ -9,19 +9,18 @@
|
|
|
9
9
|
* consumer CSS that targeted those surfaces is now broken.
|
|
10
10
|
*
|
|
11
11
|
* This transform performs precise, targeted string replacements on CSS/SCSS
|
|
12
|
-
* files for the documented surfaces only
|
|
12
|
+
* files for the documented surfaces only (selectors, layer names, and package
|
|
13
|
+
* stylesheet imports):
|
|
13
14
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* astryx.css file rename and the theme-default /
|
|
24
|
-
* theme-daily -> theme-neutral collapse)
|
|
15
|
+
* - `.xds-*` class-name prefix in selectors (matched only after a `.` so it is
|
|
16
|
+
* a class selector).
|
|
17
|
+
* - `[data-xds-theme`, `[data-xds-theme-prose`, `[data-xds-media` attribute
|
|
18
|
+
* selectors.
|
|
19
|
+
* - `\@layer xds-theme` / `\@layer xds-base` cascade layer names, including
|
|
20
|
+
* comma-separated `\@layer a, b;` statement lists and nested blocks.
|
|
21
|
+
* - `\@import '\@xds/...'` package stylesheet imports: scope rewrite, plus the
|
|
22
|
+
* `\@xds/core/xds.css` -> `\@astryxdesign/core/astryx.css` file rename and the
|
|
23
|
+
* `theme-default` / `theme-daily` -> `theme-neutral` collapse.
|
|
25
24
|
*
|
|
26
25
|
* It deliberately does NOT blindly replace every `xds` substring: a bare
|
|
27
26
|
* `xds` in a comment, a custom-property value, or an unrelated identifier is
|
|
@@ -51,8 +50,8 @@ const XDS_LAYER_NAMES = new Map([
|
|
|
51
50
|
['xds-base', 'astryx-base'],
|
|
52
51
|
]);
|
|
53
52
|
|
|
54
|
-
function rewriteLayerPrelude(prelude) {
|
|
55
|
-
return prelude.replace(/\bxds-(?:theme|base)\b/g, name =>
|
|
53
|
+
function rewriteLayerPrelude(/** @type {any} */ prelude) {
|
|
54
|
+
return prelude.replace(/\bxds-(?:theme|base)\b/g, (/** @type {any} */ name) =>
|
|
56
55
|
XDS_LAYER_NAMES.get(name) ?? name,
|
|
57
56
|
);
|
|
58
57
|
}
|
|
@@ -64,7 +63,7 @@ function rewriteLayerPrelude(prelude) {
|
|
|
64
63
|
// @xds/theme-default/* -> @astryxdesign/theme-neutral/* (collapse)
|
|
65
64
|
// @xds/theme-daily/* -> @astryxdesign/theme-neutral/* (collapse)
|
|
66
65
|
// Returns the original value unchanged if it is not an @xds/* specifier.
|
|
67
|
-
function rewriteImportSpecifier(spec) {
|
|
66
|
+
function rewriteImportSpecifier(/** @type {any} */ spec) {
|
|
68
67
|
if (!spec.startsWith('@xds/')) return spec;
|
|
69
68
|
// Theme package collapse (default/daily -> neutral).
|
|
70
69
|
let next = spec
|
|
@@ -85,6 +84,7 @@ function rewriteImportSpecifier(spec) {
|
|
|
85
84
|
|
|
86
85
|
// Ordered, non-overlapping replacements. Each pattern is intentionally narrow
|
|
87
86
|
// so we never touch a bare `xds` substring outside these surfaces.
|
|
87
|
+
/** @type {Array<{re: RegExp, to: any}>} */
|
|
88
88
|
const REPLACEMENTS = [
|
|
89
89
|
// Class-name prefix: only when preceded by a `.` (a class selector).
|
|
90
90
|
{re: /\.xds-/g, to: '.astryx-'},
|
|
@@ -92,18 +92,22 @@ const REPLACEMENTS = [
|
|
|
92
92
|
{re: /\[data-xds-/g, to: '[data-astryx-'},
|
|
93
93
|
// Cascade-layer preludes: `@layer <names>` up to the block `{` or `;`.
|
|
94
94
|
// Rewrite only the recognized xds-* layer tokens inside the prelude.
|
|
95
|
-
{re: /@layer\b[^{;]*/g, to: match => rewriteLayerPrelude(match)},
|
|
95
|
+
{re: /@layer\b[^{;]*/g, to: (/** @type {any} */ match) => rewriteLayerPrelude(match)},
|
|
96
96
|
// Package stylesheet imports: `@import '@xds/...'` or `@import url('@xds/...')`.
|
|
97
97
|
// Rewrite only the quoted @xds/* specifier, preserving the quote style.
|
|
98
98
|
{
|
|
99
99
|
re: /@import\s+(?:url\(\s*)?(['"])(@xds\/[^'"]+)\1/g,
|
|
100
|
-
to: (match, quote, spec) => {
|
|
100
|
+
to: (/** @type {any} */ match, /** @type {any} */ quote, /** @type {any} */ spec) => {
|
|
101
101
|
const next = rewriteImportSpecifier(spec);
|
|
102
102
|
return next === spec ? match : match.replace(spec, next);
|
|
103
103
|
},
|
|
104
104
|
},
|
|
105
105
|
];
|
|
106
106
|
|
|
107
|
+
/**
|
|
108
|
+
* @param {import('../../../types/codemod').AstryxCodemodFile} file
|
|
109
|
+
* @returns {string | null | undefined}
|
|
110
|
+
*/
|
|
107
111
|
export default function transformer(file /*, api */) {
|
|
108
112
|
const source = file.source;
|
|
109
113
|
if (typeof source !== 'string') return undefined;
|
|
@@ -48,7 +48,7 @@ const PACKAGE_RENAMES = new Map([
|
|
|
48
48
|
['@xds/theme-y2k', '@astryxdesign/theme-y2k'],
|
|
49
49
|
]);
|
|
50
50
|
|
|
51
|
-
function renamePackageSpecifier(value) {
|
|
51
|
+
function renamePackageSpecifier(/** @type {any} */ value) {
|
|
52
52
|
if (typeof value !== 'string') return value;
|
|
53
53
|
for (const [from, to] of PACKAGE_RENAMES) {
|
|
54
54
|
if (value === from) return to;
|
|
@@ -57,12 +57,17 @@ function renamePackageSpecifier(value) {
|
|
|
57
57
|
return value;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
/**
|
|
61
|
+
* @param {import('../../../types/codemod').AstryxCodemodFile} file
|
|
62
|
+
* @param {import('../../../types/codemod').CodemodTransformApi} api
|
|
63
|
+
* @returns {string | null | undefined}
|
|
64
|
+
*/
|
|
60
65
|
export default function transformer(file, api) {
|
|
61
66
|
const j = api.jscodeshift;
|
|
62
67
|
const root = j(file.source);
|
|
63
68
|
let hasChanges = false;
|
|
64
69
|
|
|
65
|
-
root.find(j.TSModuleDeclaration).forEach(path => {
|
|
70
|
+
root.find(j.TSModuleDeclaration).forEach((/** @type {any} */ path) => {
|
|
66
71
|
const id = path.node.id;
|
|
67
72
|
// Module augmentations name the module with a string literal id; a
|
|
68
73
|
// `namespace Foo {}` uses an Identifier id, which we ignore.
|
|
@@ -12,8 +12,9 @@
|
|
|
12
12
|
export const meta = {
|
|
13
13
|
title: 'Migrate module specifiers from @xds/* to @astryxdesign/*',
|
|
14
14
|
description:
|
|
15
|
-
'Updates JS/TS import, export, dynamic import,
|
|
16
|
-
'
|
|
15
|
+
'Updates JS/TS import, export, dynamic import, require, TS import-type, ' +
|
|
16
|
+
'and test-framework mock (vi.mock / jest.mock) module specifiers from ' +
|
|
17
|
+
'@xds/* to the @astryxdesign/* packages used by Astryx v0.1.0.',
|
|
17
18
|
pr: '#3092',
|
|
18
19
|
fileExtensions: ['.js', '.jsx', '.ts', '.tsx', '.mjs', '.cjs'],
|
|
19
20
|
};
|
|
@@ -34,7 +35,7 @@ const PACKAGE_RENAMES = new Map([
|
|
|
34
35
|
['@xds/theme-y2k', '@astryxdesign/theme-y2k'],
|
|
35
36
|
]);
|
|
36
37
|
|
|
37
|
-
function renamePackageSpecifier(value) {
|
|
38
|
+
function renamePackageSpecifier(/** @type {any} */ value) {
|
|
38
39
|
if (typeof value !== 'string') return value;
|
|
39
40
|
for (const [from, to] of PACKAGE_RENAMES) {
|
|
40
41
|
if (value === from) return to;
|
|
@@ -43,7 +44,7 @@ function renamePackageSpecifier(value) {
|
|
|
43
44
|
return value;
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
function rewriteLiteral(node) {
|
|
47
|
+
function rewriteLiteral(/** @type {any} */ node) {
|
|
47
48
|
if (!node || typeof node.value !== 'string') return false;
|
|
48
49
|
const next = renamePackageSpecifier(node.value);
|
|
49
50
|
if (next === node.value) return false;
|
|
@@ -65,7 +66,7 @@ const COLLAPSED_THEME_SOURCES = new Set([
|
|
|
65
66
|
'@xds/theme-daily',
|
|
66
67
|
]);
|
|
67
68
|
|
|
68
|
-
function isCollapsedThemeSource(value) {
|
|
69
|
+
function isCollapsedThemeSource(/** @type {any} */ value) {
|
|
69
70
|
if (typeof value !== 'string') return false;
|
|
70
71
|
for (const src of COLLAPSED_THEME_SOURCES) {
|
|
71
72
|
if (value === src || value.startsWith(src + '/')) return true;
|
|
@@ -73,9 +74,33 @@ function isCollapsedThemeSource(value) {
|
|
|
73
74
|
return false;
|
|
74
75
|
}
|
|
75
76
|
|
|
76
|
-
|
|
77
|
+
// Test-framework mock calls take the mocked module path as their first
|
|
78
|
+
// argument (`vi.mock('@xds/core/Text', factory)`). That path is a plain string
|
|
79
|
+
// literal -- not an ImportDeclaration source -- so it slips past the import/
|
|
80
|
+
// export handlers and, left unrewritten, the mock would target the stale
|
|
81
|
+
// `@xds/*` path and stop intercepting the renamed `@astryxdesign/*` import.
|
|
82
|
+
// Recognized callees: `vi.mock`, `vi.doMock`, `jest.mock`, `jest.doMock`, and
|
|
83
|
+
// a bare `mock(...)` (destructured from the test runner).
|
|
84
|
+
const MOCK_METHOD_NAMES = new Set(['mock', 'doMock']);
|
|
85
|
+
const MOCK_OBJECT_NAMES = new Set(['vi', 'jest']);
|
|
86
|
+
|
|
87
|
+
function isMockCall(/** @type {any} */ callee) {
|
|
88
|
+
if (
|
|
89
|
+
callee.type === 'MemberExpression' &&
|
|
90
|
+
!callee.computed &&
|
|
91
|
+
callee.object.type === 'Identifier' &&
|
|
92
|
+
MOCK_OBJECT_NAMES.has(callee.object.name) &&
|
|
93
|
+
callee.property.type === 'Identifier' &&
|
|
94
|
+
MOCK_METHOD_NAMES.has(callee.property.name)
|
|
95
|
+
) {
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
return callee.type === 'Identifier' && callee.name === 'mock';
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function remapThemeExportNames(/** @type {any} */ importPath, /** @type {any} */ j) {
|
|
77
102
|
let changed = false;
|
|
78
|
-
importPath.node.specifiers = (importPath.node.specifiers || []).map(spec => {
|
|
103
|
+
importPath.node.specifiers = (importPath.node.specifiers || []).map((/** @type {any} */ spec) => {
|
|
79
104
|
if (spec.type !== 'ImportSpecifier') return spec;
|
|
80
105
|
const importedName = spec.imported.name;
|
|
81
106
|
const renamed = THEME_EXPORT_RENAMES.get(importedName);
|
|
@@ -91,12 +116,17 @@ function remapThemeExportNames(importPath, j) {
|
|
|
91
116
|
return changed;
|
|
92
117
|
}
|
|
93
118
|
|
|
119
|
+
/**
|
|
120
|
+
* @param {import('../../../types/codemod').AstryxCodemodFile} file
|
|
121
|
+
* @param {import('../../../types/codemod').CodemodTransformApi} api
|
|
122
|
+
* @returns {string | null | undefined}
|
|
123
|
+
*/
|
|
94
124
|
export default function transformer(file, api) {
|
|
95
125
|
const j = api.jscodeshift;
|
|
96
126
|
const root = j(file.source);
|
|
97
127
|
let hasChanges = false;
|
|
98
128
|
|
|
99
|
-
root.find(j.ImportDeclaration).forEach(path => {
|
|
129
|
+
root.find(j.ImportDeclaration).forEach((/** @type {any} */ path) => {
|
|
100
130
|
// Remap collapsed-theme export names BEFORE rewriting the source specifier
|
|
101
131
|
// (the check keys off the original @xds/theme-default|daily path).
|
|
102
132
|
if (isCollapsedThemeSource(path.node.source.value)) {
|
|
@@ -105,25 +135,66 @@ export default function transformer(file, api) {
|
|
|
105
135
|
hasChanges = rewriteLiteral(path.node.source) || hasChanges;
|
|
106
136
|
});
|
|
107
137
|
|
|
108
|
-
root.find(j.ExportNamedDeclaration).forEach(path => {
|
|
138
|
+
root.find(j.ExportNamedDeclaration).forEach((/** @type {any} */ path) => {
|
|
109
139
|
hasChanges = rewriteLiteral(path.node.source) || hasChanges;
|
|
110
140
|
});
|
|
111
141
|
|
|
112
|
-
root.find(j.ExportAllDeclaration).forEach(path => {
|
|
142
|
+
root.find(j.ExportAllDeclaration).forEach((/** @type {any} */ path) => {
|
|
113
143
|
hasChanges = rewriteLiteral(path.node.source) || hasChanges;
|
|
114
144
|
});
|
|
115
145
|
|
|
116
|
-
root.find(j.CallExpression).forEach(path => {
|
|
146
|
+
root.find(j.CallExpression).forEach((/** @type {any} */ path) => {
|
|
117
147
|
const isDynamicImport = path.node.callee.type === 'Import';
|
|
118
148
|
const isRequire =
|
|
119
149
|
path.node.callee.type === 'Identifier' &&
|
|
120
150
|
path.node.callee.name === 'require';
|
|
121
|
-
if (
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
151
|
+
if (isDynamicImport || isRequire || isMockCall(path.node.callee)) {
|
|
152
|
+
const [arg] = path.node.arguments;
|
|
153
|
+
if (arg?.type === 'StringLiteral' || arg?.type === 'Literal') {
|
|
154
|
+
hasChanges = rewriteLiteral(arg) || hasChanges;
|
|
155
|
+
}
|
|
125
156
|
}
|
|
126
157
|
});
|
|
127
158
|
|
|
159
|
+
// TS `import(...)` TYPE specifiers -- e.g. the `import('@xds/core/Text')` in
|
|
160
|
+
// `typeof import('@xds/core/Text')` -- parse to a `TSImportType` node, not a
|
|
161
|
+
// dynamic-import CallExpression, so the handler above never reaches them.
|
|
162
|
+
// ast-types' traversal also doesn't descend into a `TSImportType` nested in a
|
|
163
|
+
// generic type-argument position (e.g. `orig<typeof import('@xds/core/Text')>()`),
|
|
164
|
+
// so `j.find(j.TSImportType)` misses it. Walk the raw AST to cover every
|
|
165
|
+
// position. Re-visiting a node the loop above handled is harmless: the
|
|
166
|
+
// literal is already rewritten, so the second pass is a no-op.
|
|
167
|
+
const seenTypeImportNodes = new Set();
|
|
168
|
+
const rewriteTSImportTypes = (/** @type {any} */ node) => {
|
|
169
|
+
if (!node || typeof node !== 'object') return;
|
|
170
|
+
if (Array.isArray(node)) {
|
|
171
|
+
for (const child of node) rewriteTSImportTypes(child);
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
if (seenTypeImportNodes.has(node)) return;
|
|
175
|
+
seenTypeImportNodes.add(node);
|
|
176
|
+
|
|
177
|
+
if (node.type === 'TSImportType' && node.argument) {
|
|
178
|
+
hasChanges = rewriteLiteral(node.argument) || hasChanges;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
for (const key of Object.keys(node)) {
|
|
182
|
+
if (
|
|
183
|
+
key === 'loc' ||
|
|
184
|
+
key === 'start' ||
|
|
185
|
+
key === 'end' ||
|
|
186
|
+
key === 'range' ||
|
|
187
|
+
key === 'comments' ||
|
|
188
|
+
key === 'leadingComments' ||
|
|
189
|
+
key === 'trailingComments' ||
|
|
190
|
+
key === 'tokens'
|
|
191
|
+
) {
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
rewriteTSImportTypes(node[key]);
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
rewriteTSImportTypes(root.get().node);
|
|
198
|
+
|
|
128
199
|
return hasChanges ? root.toSource() : undefined;
|
|
129
200
|
}
|
|
@@ -40,13 +40,18 @@ const NEW_VALUE = 'accent';
|
|
|
40
40
|
/** Components whose `color` prop accepts a TextColor value. */
|
|
41
41
|
const TARGET_COMPONENTS = new Set(['Text', 'Heading', 'Link', 'Timestamp']);
|
|
42
42
|
|
|
43
|
+
/**
|
|
44
|
+
* @param {import('../../../types/codemod').AstryxCodemodFile} file
|
|
45
|
+
* @param {import('../../../types/codemod').CodemodTransformApi} api
|
|
46
|
+
* @returns {string | null | undefined}
|
|
47
|
+
*/
|
|
43
48
|
export default function transformer(file, api) {
|
|
44
49
|
const j = api.jscodeshift;
|
|
45
50
|
const root = j(file.source);
|
|
46
51
|
let hasChanges = false;
|
|
47
52
|
|
|
48
53
|
/** Rewrite a string-literal node when it equals the old value. */
|
|
49
|
-
function renameStringLiteral(node) {
|
|
54
|
+
function renameStringLiteral(/** @type {any} */ node) {
|
|
50
55
|
if (!node) return false;
|
|
51
56
|
if (
|
|
52
57
|
(node.type === 'StringLiteral' || node.type === 'Literal') &&
|
|
@@ -60,7 +65,8 @@ export default function transformer(file, api) {
|
|
|
60
65
|
}
|
|
61
66
|
|
|
62
67
|
/** Recursively rewrite the old value inside ternary/logical expressions. */
|
|
63
|
-
|
|
68
|
+
/** @returns {boolean} */
|
|
69
|
+
function renameInExpression(/** @type {any} */ node) {
|
|
64
70
|
if (!node) return false;
|
|
65
71
|
let changed = false;
|
|
66
72
|
if (node.type === 'StringLiteral' || node.type === 'Literal') {
|
|
@@ -79,12 +85,12 @@ export default function transformer(file, api) {
|
|
|
79
85
|
}
|
|
80
86
|
|
|
81
87
|
// --- 1. JSX attribute: color="active" / color={'active'} on target components ---
|
|
82
|
-
root.find(j.JSXOpeningElement).forEach(path => {
|
|
88
|
+
root.find(j.JSXOpeningElement).forEach((/** @type {any} */ path) => {
|
|
83
89
|
const name = path.node.name;
|
|
84
90
|
const componentName = name.type === 'JSXIdentifier' ? name.name : null;
|
|
85
91
|
if (!componentName || !TARGET_COMPONENTS.has(componentName)) return;
|
|
86
92
|
|
|
87
|
-
path.node.attributes.forEach(attr => {
|
|
93
|
+
path.node.attributes.forEach((/** @type {any} */ attr) => {
|
|
88
94
|
if (attr.type !== 'JSXAttribute') return;
|
|
89
95
|
if (!attr.name || attr.name.name !== 'color') return;
|
|
90
96
|
|
|
@@ -104,27 +110,27 @@ export default function transformer(file, api) {
|
|
|
104
110
|
const importsTarget =
|
|
105
111
|
root
|
|
106
112
|
.find(j.ImportSpecifier)
|
|
107
|
-
.filter(p => TARGET_COMPONENTS.has(p.node.imported?.name))
|
|
113
|
+
.filter((/** @type {any} */ p) => TARGET_COMPONENTS.has(p.node.imported?.name))
|
|
108
114
|
.size() > 0;
|
|
109
115
|
|
|
110
116
|
if (importsTarget) {
|
|
111
117
|
const PropertyType = j.ObjectProperty ?? j.Property;
|
|
112
118
|
|
|
113
119
|
// --- 2. Object property: { color: 'active' } / { color: 'active' as const } ---
|
|
114
|
-
root.find(PropertyType, {key: {name: 'color'}}).forEach(path => {
|
|
120
|
+
root.find(PropertyType, {key: {name: 'color'}}).forEach((/** @type {any} */ path) => {
|
|
115
121
|
if (renameInExpression(path.node.value)) hasChanges = true;
|
|
116
122
|
});
|
|
117
123
|
|
|
118
124
|
// --- 3. Storybook argTypes: color: { options: [..., 'active', ...] } ---
|
|
119
|
-
root.find(PropertyType, {key: {name: 'color'}}).forEach(path => {
|
|
125
|
+
root.find(PropertyType, {key: {name: 'color'}}).forEach((/** @type {any} */ path) => {
|
|
120
126
|
const value = path.node.value;
|
|
121
127
|
if (!value || value.type !== 'ObjectExpression') return;
|
|
122
128
|
|
|
123
129
|
const optionsProp = value.properties.find(
|
|
124
|
-
p => p.key && (p.key.name === 'options' || p.key.value === 'options'),
|
|
130
|
+
(/** @type {any} */ p) => p.key && (p.key.name === 'options' || p.key.value === 'options'),
|
|
125
131
|
);
|
|
126
132
|
if (optionsProp && optionsProp.value.type === 'ArrayExpression') {
|
|
127
|
-
optionsProp.value.elements.forEach(el => {
|
|
133
|
+
optionsProp.value.elements.forEach((/** @type {any} */ el) => {
|
|
128
134
|
if (renameStringLiteral(el)) hasChanges = true;
|
|
129
135
|
});
|
|
130
136
|
}
|
package/{src/codemods → codemods}/transforms/v0.1.3/migrate-layout-components-to-experimental.mjs
RENAMED
|
@@ -58,6 +58,11 @@ const MANUAL =
|
|
|
58
58
|
* @param {{jscodeshift: Function}} api
|
|
59
59
|
* @returns {string|null}
|
|
60
60
|
*/
|
|
61
|
+
/**
|
|
62
|
+
* @param {import('../../../types/codemod').AstryxCodemodFile} file
|
|
63
|
+
* @param {import('../../../types/codemod').CodemodTransformApi} api
|
|
64
|
+
* @returns {string | null | undefined}
|
|
65
|
+
*/
|
|
61
66
|
export default function transformer(file, api) {
|
|
62
67
|
const j = api.jscodeshift;
|
|
63
68
|
const root = j(file.source);
|
|
@@ -105,7 +110,7 @@ export default function transformer(file, api) {
|
|
|
105
110
|
// `components` was the only documented `layout` key. Anything else is
|
|
106
111
|
// unexpected and we cannot safely guess intent.
|
|
107
112
|
const otherLayoutKeys = layoutProp.value.properties.filter(
|
|
108
|
-
p => p !== componentsProp,
|
|
113
|
+
(/** @type {any} */ p) => p !== componentsProp,
|
|
109
114
|
);
|
|
110
115
|
if (otherLayoutKeys.length > 0) {
|
|
111
116
|
throw new Error(
|
|
@@ -148,7 +153,7 @@ export default function transformer(file, api) {
|
|
|
148
153
|
// Remove the migrated data from `layout`. Since `components` was the only
|
|
149
154
|
// key (asserted above), remove the entire `layout` property.
|
|
150
155
|
configObject.properties = configObject.properties.filter(
|
|
151
|
-
p => p !== layoutProp,
|
|
156
|
+
(/** @type {any} */ p) => p !== layoutProp,
|
|
152
157
|
);
|
|
153
158
|
|
|
154
159
|
return root.toSource();
|
|
@@ -157,9 +162,9 @@ export default function transformer(file, api) {
|
|
|
157
162
|
/**
|
|
158
163
|
* Resolve the wrapped config object literal from a default-export declaration.
|
|
159
164
|
* Handles `{ ... }` and `createConfig({ ... })`.
|
|
160
|
-
* @returns {
|
|
165
|
+
* @returns {any} the ObjectExpression node, or null if not analyzable
|
|
161
166
|
*/
|
|
162
|
-
function resolveConfigObject(j, declaration) {
|
|
167
|
+
function resolveConfigObject(/** @type {any} */ j, /** @type {any} */ declaration) {
|
|
163
168
|
if (!declaration) return null;
|
|
164
169
|
if (j.ObjectExpression.check(declaration)) {
|
|
165
170
|
return declaration;
|
|
@@ -177,10 +182,10 @@ function resolveConfigObject(j, declaration) {
|
|
|
177
182
|
/**
|
|
178
183
|
* Find a (non-computed, non-spread) property on an object literal by key name.
|
|
179
184
|
* Supports Identifier and string-literal keys.
|
|
180
|
-
* @returns {
|
|
185
|
+
* @returns {any} the property node
|
|
181
186
|
*/
|
|
182
|
-
function findObjectProperty(j, objectExpression, name) {
|
|
183
|
-
return objectExpression.properties.find(prop => {
|
|
187
|
+
function findObjectProperty(/** @type {any} */ j, /** @type {any} */ objectExpression, /** @type {any} */ name) {
|
|
188
|
+
return objectExpression.properties.find((/** @type {any} */ prop) => {
|
|
184
189
|
if (
|
|
185
190
|
!j.ObjectProperty.check(prop) &&
|
|
186
191
|
!j.Property.check(prop)
|
|
@@ -200,8 +205,8 @@ function findObjectProperty(j, objectExpression, name) {
|
|
|
200
205
|
* Build the migrated `components` ObjectExpression from the old one.
|
|
201
206
|
* @returns {object} ObjectExpression
|
|
202
207
|
*/
|
|
203
|
-
function buildMigratedComponents(j, oldComponents) {
|
|
204
|
-
const newProps = oldComponents.properties.map(prop => {
|
|
208
|
+
function buildMigratedComponents(/** @type {any} */ j, /** @type {any} */ oldComponents) {
|
|
209
|
+
const newProps = oldComponents.properties.map((/** @type {any} */ prop) => {
|
|
205
210
|
if (
|
|
206
211
|
(!j.ObjectProperty.check(prop) && !j.Property.check(prop)) ||
|
|
207
212
|
prop.computed
|
|
@@ -239,14 +244,14 @@ function buildMigratedComponents(j, oldComponents) {
|
|
|
239
244
|
}
|
|
240
245
|
|
|
241
246
|
/** Build `{ components: <obj> }` for `experimental.xle`. */
|
|
242
|
-
function buildXleObject(j, migratedComponents) {
|
|
247
|
+
function buildXleObject(/** @type {any} */ j, /** @type {any} */ migratedComponents) {
|
|
243
248
|
return j.objectExpression([
|
|
244
249
|
j.objectProperty(j.identifier('components'), migratedComponents),
|
|
245
250
|
]);
|
|
246
251
|
}
|
|
247
252
|
|
|
248
253
|
/** Clone a property key node so we don't reuse a node across the tree. */
|
|
249
|
-
function cloneKey(j, key) {
|
|
254
|
+
function cloneKey(/** @type {any} */ j, /** @type {any} */ key) {
|
|
250
255
|
if (j.Identifier.check(key)) return j.identifier(key.name);
|
|
251
256
|
if (j.StringLiteral.check(key)) return j.stringLiteral(key.value);
|
|
252
257
|
if (j.Literal.check(key)) return j.literal(key.value);
|
|
@@ -254,7 +259,7 @@ function cloneKey(j, key) {
|
|
|
254
259
|
}
|
|
255
260
|
|
|
256
261
|
/** Build a fresh string literal preserving the original raw quoting if possible. */
|
|
257
|
-
function cloneStringLiteral(j, value) {
|
|
262
|
+
function cloneStringLiteral(/** @type {any} */ j, /** @type {any} */ value) {
|
|
258
263
|
if (j.StringLiteral.check(value)) return j.stringLiteral(value.value);
|
|
259
264
|
return j.literal(value.value);
|
|
260
265
|
}
|
package/{src/codemods → codemods}/transforms/v0.1.5/rename-switch-label-spacing-default-to-hug.mjs
RENAMED
|
@@ -44,13 +44,18 @@ const TARGET_PROP = 'labelSpacing';
|
|
|
44
44
|
/** Components whose `labelSpacing` prop accepts a SwitchLabelSpacing value. */
|
|
45
45
|
const TARGET_COMPONENTS = new Set(['Switch']);
|
|
46
46
|
|
|
47
|
+
/**
|
|
48
|
+
* @param {import('../../../types/codemod').AstryxCodemodFile} file
|
|
49
|
+
* @param {import('../../../types/codemod').CodemodTransformApi} api
|
|
50
|
+
* @returns {string | null | undefined}
|
|
51
|
+
*/
|
|
47
52
|
export default function transformer(file, api) {
|
|
48
53
|
const j = api.jscodeshift;
|
|
49
54
|
const root = j(file.source);
|
|
50
55
|
let hasChanges = false;
|
|
51
56
|
|
|
52
57
|
/** Rewrite a string-literal node when it equals the old value. */
|
|
53
|
-
function renameStringLiteral(node) {
|
|
58
|
+
function renameStringLiteral(/** @type {any} */ node) {
|
|
54
59
|
if (!node) return false;
|
|
55
60
|
if (
|
|
56
61
|
(node.type === 'StringLiteral' || node.type === 'Literal') &&
|
|
@@ -64,7 +69,8 @@ export default function transformer(file, api) {
|
|
|
64
69
|
}
|
|
65
70
|
|
|
66
71
|
/** Recursively rewrite the old value inside ternary/logical expressions. */
|
|
67
|
-
|
|
72
|
+
/** @returns {boolean} */
|
|
73
|
+
function renameInExpression(/** @type {any} */ node) {
|
|
68
74
|
if (!node) return false;
|
|
69
75
|
let changed = false;
|
|
70
76
|
if (node.type === 'StringLiteral' || node.type === 'Literal') {
|
|
@@ -83,12 +89,12 @@ export default function transformer(file, api) {
|
|
|
83
89
|
}
|
|
84
90
|
|
|
85
91
|
// --- 1. JSX attribute: labelSpacing="default" / labelSpacing={'default'} on Switch ---
|
|
86
|
-
root.find(j.JSXOpeningElement).forEach(path => {
|
|
92
|
+
root.find(j.JSXOpeningElement).forEach((/** @type {any} */ path) => {
|
|
87
93
|
const name = path.node.name;
|
|
88
94
|
const componentName = name.type === 'JSXIdentifier' ? name.name : null;
|
|
89
95
|
if (!componentName || !TARGET_COMPONENTS.has(componentName)) return;
|
|
90
96
|
|
|
91
|
-
path.node.attributes.forEach(attr => {
|
|
97
|
+
path.node.attributes.forEach((/** @type {any} */ attr) => {
|
|
92
98
|
if (attr.type !== 'JSXAttribute') return;
|
|
93
99
|
if (!attr.name || attr.name.name !== TARGET_PROP) return;
|
|
94
100
|
|
|
@@ -108,27 +114,27 @@ export default function transformer(file, api) {
|
|
|
108
114
|
const importsTarget =
|
|
109
115
|
root
|
|
110
116
|
.find(j.ImportSpecifier)
|
|
111
|
-
.filter(p => TARGET_COMPONENTS.has(p.node.imported?.name))
|
|
117
|
+
.filter((/** @type {any} */ p) => TARGET_COMPONENTS.has(p.node.imported?.name))
|
|
112
118
|
.size() > 0;
|
|
113
119
|
|
|
114
120
|
if (importsTarget) {
|
|
115
121
|
const PropertyType = j.ObjectProperty ?? j.Property;
|
|
116
122
|
|
|
117
123
|
// --- 2. Object property: { labelSpacing: 'default' } / 'default' as const ---
|
|
118
|
-
root.find(PropertyType, {key: {name: TARGET_PROP}}).forEach(path => {
|
|
124
|
+
root.find(PropertyType, {key: {name: TARGET_PROP}}).forEach((/** @type {any} */ path) => {
|
|
119
125
|
if (renameInExpression(path.node.value)) hasChanges = true;
|
|
120
126
|
});
|
|
121
127
|
|
|
122
128
|
// --- 3. Storybook argTypes: labelSpacing: { options: [..., 'default', ...] } ---
|
|
123
|
-
root.find(PropertyType, {key: {name: TARGET_PROP}}).forEach(path => {
|
|
129
|
+
root.find(PropertyType, {key: {name: TARGET_PROP}}).forEach((/** @type {any} */ path) => {
|
|
124
130
|
const value = path.node.value;
|
|
125
131
|
if (!value || value.type !== 'ObjectExpression') return;
|
|
126
132
|
|
|
127
133
|
const optionsProp = value.properties.find(
|
|
128
|
-
p => p.key && (p.key.name === 'options' || p.key.value === 'options'),
|
|
134
|
+
(/** @type {any} */ p) => p.key && (p.key.name === 'options' || p.key.value === 'options'),
|
|
129
135
|
);
|
|
130
136
|
if (optionsProp && optionsProp.value.type === 'ArrayExpression') {
|
|
131
|
-
optionsProp.value.elements.forEach(el => {
|
|
137
|
+
optionsProp.value.elements.forEach((/** @type {any} */ el) => {
|
|
132
138
|
if (renameStringLiteral(el)) hasChanges = true;
|
|
133
139
|
});
|
|
134
140
|
}
|
package/{src/codemods → codemods}/transforms/v0.1.7/migrate-table-tableprops-to-direct-props.mjs
RENAMED
|
@@ -54,7 +54,7 @@ const TODO_COMMENT =
|
|
|
54
54
|
* property is not a simple liftable entry (spread, computed key, method,
|
|
55
55
|
* getter/setter, non-string literal key).
|
|
56
56
|
*/
|
|
57
|
-
function getPropertyKeyName(prop) {
|
|
57
|
+
function getPropertyKeyName(/** @type {any} */ prop) {
|
|
58
58
|
if (prop.type !== 'ObjectProperty' && prop.type !== 'Property') return null;
|
|
59
59
|
// espree-style Property nodes: skip methods and accessors
|
|
60
60
|
if (prop.method || (prop.kind != null && prop.kind !== 'init')) return null;
|
|
@@ -70,6 +70,11 @@ function getPropertyKeyName(prop) {
|
|
|
70
70
|
return null;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
/**
|
|
74
|
+
* @param {import('../../../types/codemod').AstryxCodemodFile} file
|
|
75
|
+
* @param {import('../../../types/codemod').CodemodTransformApi} api
|
|
76
|
+
* @returns {string | null | undefined}
|
|
77
|
+
*/
|
|
73
78
|
export default function transformer(file, api) {
|
|
74
79
|
const j = api.jscodeshift;
|
|
75
80
|
const root = j(file.source);
|
|
@@ -77,7 +82,7 @@ export default function transformer(file, api) {
|
|
|
77
82
|
|
|
78
83
|
// --- 1. Track local names for the Table import (alias-aware) ---
|
|
79
84
|
const tableLocals = new Set();
|
|
80
|
-
root.find(j.ImportDeclaration).forEach((path) => {
|
|
85
|
+
root.find(j.ImportDeclaration).forEach((/** @type {any} */ path) => {
|
|
81
86
|
if (!TABLE_IMPORT_SOURCES.has(path.node.source.value)) return;
|
|
82
87
|
for (const spec of path.node.specifiers ?? []) {
|
|
83
88
|
if (spec.type === 'ImportSpecifier' && spec.imported.name === 'Table') {
|
|
@@ -88,14 +93,14 @@ export default function transformer(file, api) {
|
|
|
88
93
|
|
|
89
94
|
if (tableLocals.size === 0) return undefined;
|
|
90
95
|
|
|
91
|
-
function attachTodo(attr) {
|
|
96
|
+
function attachTodo(/** @type {any} */ attr) {
|
|
92
97
|
if (!attr.comments) attr.comments = [];
|
|
93
|
-
if (attr.comments.some((c) => c.value === TODO_COMMENT)) return;
|
|
98
|
+
if (attr.comments.some((/** @type {any} */ c) => c.value === TODO_COMMENT)) return;
|
|
94
99
|
attr.comments.push(j.commentBlock(TODO_COMMENT, false, true));
|
|
95
100
|
hasChanges = true;
|
|
96
101
|
}
|
|
97
102
|
|
|
98
|
-
function buildAttributeValue(valueNode) {
|
|
103
|
+
function buildAttributeValue(/** @type {any} */ valueNode) {
|
|
99
104
|
if (
|
|
100
105
|
valueNode.type === 'StringLiteral' ||
|
|
101
106
|
(valueNode.type === 'Literal' && typeof valueNode.value === 'string')
|
|
@@ -106,14 +111,14 @@ export default function transformer(file, api) {
|
|
|
106
111
|
}
|
|
107
112
|
|
|
108
113
|
// --- 2. Rewrite tableProps on tracked <Table> elements ---
|
|
109
|
-
root.find(j.JSXOpeningElement).forEach((path) => {
|
|
114
|
+
root.find(j.JSXOpeningElement).forEach((/** @type {any} */ path) => {
|
|
110
115
|
const name = path.node.name;
|
|
111
116
|
const componentName = name.type === 'JSXIdentifier' ? name.name : null;
|
|
112
117
|
if (!componentName || !tableLocals.has(componentName)) return;
|
|
113
118
|
|
|
114
119
|
const attrs = path.node.attributes;
|
|
115
120
|
const tablePropsAttr = attrs.find(
|
|
116
|
-
(a) => a.type === 'JSXAttribute' && a.name?.name === 'tableProps',
|
|
121
|
+
(/** @type {any} */ a) => a.type === 'JSXAttribute' && a.name?.name === 'tableProps',
|
|
117
122
|
);
|
|
118
123
|
if (!tablePropsAttr) return;
|
|
119
124
|
|
|
@@ -135,22 +140,24 @@ export default function transformer(file, api) {
|
|
|
135
140
|
// Objects containing spreads, computed keys, or methods are treated
|
|
136
141
|
// as dynamic: no partial lift, just the TODO comment.
|
|
137
142
|
const allSimple = obj.properties.every(
|
|
138
|
-
(prop) => getPropertyKeyName(prop) !== null,
|
|
143
|
+
(/** @type {any} */ prop) => getPropertyKeyName(prop) !== null,
|
|
139
144
|
);
|
|
140
145
|
if (!allSimple) {
|
|
141
146
|
attachTodo(tablePropsAttr);
|
|
142
147
|
return;
|
|
143
148
|
}
|
|
144
149
|
|
|
150
|
+
/** @type {any[]} */
|
|
145
151
|
const lifted = [];
|
|
152
|
+
/** @type {any[]} */
|
|
146
153
|
const kept = [];
|
|
147
154
|
for (const prop of obj.properties) {
|
|
148
155
|
const keyName = getPropertyKeyName(prop);
|
|
149
156
|
const collidesWithSibling = attrs.some(
|
|
150
|
-
(a) => a.type === 'JSXAttribute' && a.name?.name === keyName,
|
|
157
|
+
(/** @type {any} */ a) => a.type === 'JSXAttribute' && a.name?.name === keyName,
|
|
151
158
|
);
|
|
152
159
|
const collidesWithLifted = lifted.some(
|
|
153
|
-
(a) => a.name.name === keyName,
|
|
160
|
+
(/** @type {any} */ a) => a.name.name === keyName,
|
|
154
161
|
);
|
|
155
162
|
if (
|
|
156
163
|
!LIFTABLE_KEY_RE.test(keyName) ||
|