mirror of
https://github.com/stefanpejcic/openpanel
synced 2025-06-26 18:28:26 +00:00
packages
This commit is contained in:
176
packages/codemod/src/definitions/separated-imports/antd.ts
Normal file
176
packages/codemod/src/definitions/separated-imports/antd.ts
Normal file
@@ -0,0 +1,176 @@
|
||||
export const exported: string[] = [
|
||||
"Affix",
|
||||
"Anchor",
|
||||
"AutoComplete",
|
||||
"Alert",
|
||||
"Avatar",
|
||||
"BackTop",
|
||||
"Badge",
|
||||
"AntdBreadcrumb",
|
||||
"Button",
|
||||
"Calendar",
|
||||
"Card",
|
||||
"Collapse",
|
||||
"Carousel",
|
||||
"Cascader",
|
||||
"Checkbox",
|
||||
"Col",
|
||||
"ConfigProvider",
|
||||
"DatePicker",
|
||||
"Descriptions",
|
||||
"Divider",
|
||||
"Dropdown",
|
||||
"Drawer",
|
||||
"Empty",
|
||||
"FloatButton",
|
||||
"Form",
|
||||
"Grid",
|
||||
"Input",
|
||||
"Image",
|
||||
"InputNumber",
|
||||
"AntdLayout",
|
||||
"AntdList",
|
||||
"message",
|
||||
"Menu",
|
||||
"Mentions",
|
||||
"Modal",
|
||||
"Statistic",
|
||||
"notification",
|
||||
"Pagination",
|
||||
"Popconfirm",
|
||||
"Popover",
|
||||
"Progress",
|
||||
"Radio",
|
||||
"Rate",
|
||||
"Result",
|
||||
"Row",
|
||||
"Segmented",
|
||||
"Select",
|
||||
"Skeleton",
|
||||
"Slider",
|
||||
"Space",
|
||||
"Spin",
|
||||
"Steps",
|
||||
"Switch",
|
||||
"Table",
|
||||
"TimePicker",
|
||||
"Transfer",
|
||||
"Tree",
|
||||
"TreeSelect",
|
||||
"Tabs",
|
||||
"Tag",
|
||||
"Timeline",
|
||||
"Tooltip",
|
||||
"Tour",
|
||||
"Typography",
|
||||
"Upload",
|
||||
"version",
|
||||
"theme",
|
||||
"App",
|
||||
"QRCode",
|
||||
"Watermark",
|
||||
// types
|
||||
"AffixProps",
|
||||
"AnchorProps",
|
||||
"AnchorLinkProps",
|
||||
"AutoCompleteProps",
|
||||
"AlertProps",
|
||||
"AvatarProps",
|
||||
"BackTopProps",
|
||||
"BadgeProps",
|
||||
"AntdBreadcrumbProps",
|
||||
"BreadcrumbItemProps",
|
||||
"ButtonProps",
|
||||
"CalendarProps",
|
||||
"CardProps",
|
||||
"CollapseProps",
|
||||
"CollapsePanelProps",
|
||||
"CarouselProps",
|
||||
"CascaderProps",
|
||||
"CheckboxProps",
|
||||
"CheckboxOptionType",
|
||||
"ColProps",
|
||||
"DatePickerProps",
|
||||
"DescriptionsProps",
|
||||
"DividerProps",
|
||||
"DropDownProps",
|
||||
"DrawerProps",
|
||||
"EmptyProps",
|
||||
"FloatButtonProps",
|
||||
"FormInstance",
|
||||
"FormProps",
|
||||
"FormItemProps",
|
||||
"InputProps",
|
||||
"ImageProps",
|
||||
"InputNumberProps",
|
||||
"LayoutProps",
|
||||
"AntdListProps",
|
||||
"MessageArgsProps",
|
||||
"MentionProps",
|
||||
"MenuProps",
|
||||
"MenuTheme",
|
||||
"SubMenuProps",
|
||||
"MenuItemProps",
|
||||
"ModalProps",
|
||||
"ModalFuncProps",
|
||||
"StatisticProps",
|
||||
"PaginationProps",
|
||||
"PopconfirmProps",
|
||||
"PopoverProps",
|
||||
"ProgressProps",
|
||||
"RadioProps",
|
||||
"RadioChangeEvent",
|
||||
"RadioGroupProps",
|
||||
"RateProps",
|
||||
"ResultProps",
|
||||
"RowProps",
|
||||
"SelectProps",
|
||||
"SkeletonProps",
|
||||
"SliderSingleProps",
|
||||
"SpaceProps",
|
||||
"SpinProps",
|
||||
"StepProps",
|
||||
"StepsProps",
|
||||
"SwitchProps",
|
||||
"TableProps",
|
||||
"TablePaginationConfig",
|
||||
"TableColumnGroupType",
|
||||
"TableColumnType",
|
||||
"TableColumnProps",
|
||||
"TransferProps",
|
||||
"TreeSelectProps",
|
||||
"TreeProps",
|
||||
"TreeNodeProps",
|
||||
"TabsProps",
|
||||
"TabPaneProps",
|
||||
"TagProps",
|
||||
"TagType",
|
||||
"TimelineProps",
|
||||
"TimelineItemProps",
|
||||
"TooltipProps",
|
||||
"TourProps",
|
||||
"TypographyProps",
|
||||
"UploadProps",
|
||||
"WatermarkProps",
|
||||
"QRCodeProps",
|
||||
"QRPropsCanvas",
|
||||
"TitleProps",
|
||||
];
|
||||
|
||||
export const rename: { [key: string]: string } = {
|
||||
AntdBreadcrumb: "Breadcrumb",
|
||||
AntdLayout: "Layout",
|
||||
AntdList: "List",
|
||||
AntdBreadcrumbProps: "BreadcrumbProps",
|
||||
AntdListProps: "ListProps",
|
||||
};
|
||||
|
||||
export const renameToDefault: { [key: string]: string } = {
|
||||
Icon: "@ant-design/icons",
|
||||
};
|
||||
|
||||
export const other: { [key: string]: string } = {
|
||||
FilterDropdownProps: "antd/lib/table/interface",
|
||||
RcFile: "antd/lib/upload/interface",
|
||||
UploadFile: "antd/lib/upload/interface",
|
||||
};
|
||||
782
packages/codemod/src/definitions/separated-imports/chakra.ts
Normal file
782
packages/codemod/src/definitions/separated-imports/chakra.ts
Normal file
@@ -0,0 +1,782 @@
|
||||
export const exported: string[] = [
|
||||
"AbsoluteCenter",
|
||||
"Accordion",
|
||||
"AccordionButton",
|
||||
"AccordionIcon",
|
||||
"AccordionItem",
|
||||
"AccordionPanel",
|
||||
"AccordionProvider",
|
||||
"Alert",
|
||||
"AlertDescription",
|
||||
"AlertDialog",
|
||||
"AlertDialogBody",
|
||||
"AlertDialogCloseButton",
|
||||
"AlertDialogContent",
|
||||
"AlertDialogFooter",
|
||||
"AlertDialogHeader",
|
||||
"AlertDialogOverlay",
|
||||
"AlertIcon",
|
||||
"AlertTitle",
|
||||
"AspectRatio",
|
||||
"Avatar",
|
||||
"AvatarBadge",
|
||||
"AvatarGroup",
|
||||
"Badge",
|
||||
"Box",
|
||||
"Breadcrumb as ChakraBreadcrumb",
|
||||
"BreadcrumbItem",
|
||||
"BreadcrumbLink",
|
||||
"BreadcrumbSeparator",
|
||||
"Button",
|
||||
"ButtonGroup",
|
||||
"ButtonSpinner",
|
||||
"CSSPolyfill",
|
||||
"CSSReset",
|
||||
"CSSVars",
|
||||
"Center",
|
||||
"ChakraProvider",
|
||||
"Checkbox",
|
||||
"CheckboxGroup",
|
||||
"CheckboxIcon",
|
||||
"Circle",
|
||||
"CircularProgress",
|
||||
"CircularProgressLabel",
|
||||
"CloseButton",
|
||||
"Code",
|
||||
"Collapse",
|
||||
"ColorModeContext",
|
||||
"ColorModeProvider",
|
||||
"ColorModeScript",
|
||||
"Container",
|
||||
"ControlBox",
|
||||
"DarkMode",
|
||||
"Divider",
|
||||
"Drawer",
|
||||
"DrawerBody",
|
||||
"DrawerCloseButton",
|
||||
"DrawerContent",
|
||||
"DrawerFooter",
|
||||
"DrawerHeader",
|
||||
"DrawerOverlay",
|
||||
"EASINGS",
|
||||
"Editable",
|
||||
"EditableInput",
|
||||
"EditablePreview",
|
||||
"EditableTextarea",
|
||||
"EnvironmentProvider",
|
||||
"Fade",
|
||||
"Flex",
|
||||
"FormControl",
|
||||
"FormErrorIcon",
|
||||
"FormErrorMessage",
|
||||
"FormHelperText",
|
||||
"FormLabel",
|
||||
"GenericAvatarIcon",
|
||||
"GlobalStyle",
|
||||
"Grid",
|
||||
"GridItem",
|
||||
"HStack",
|
||||
"Heading",
|
||||
"Hide",
|
||||
"Highlight",
|
||||
"Icon",
|
||||
"IconButton",
|
||||
"Image",
|
||||
"Img",
|
||||
"Input",
|
||||
"InputAddon",
|
||||
"InputGroup",
|
||||
"InputLeftAddon",
|
||||
"InputLeftElement",
|
||||
"InputRightAddon",
|
||||
"InputRightElement",
|
||||
"Kbd",
|
||||
"LightMode",
|
||||
"Link",
|
||||
"LinkBox",
|
||||
"LinkOverlay",
|
||||
"List as ChakraList",
|
||||
"ListIcon",
|
||||
"ListItem",
|
||||
"Mark",
|
||||
"Menu",
|
||||
"MenuButton",
|
||||
"MenuCommand",
|
||||
"MenuDivider",
|
||||
"MenuGroup",
|
||||
"MenuIcon",
|
||||
"MenuItem",
|
||||
"MenuItemOption",
|
||||
"MenuList",
|
||||
"MenuOptionGroup",
|
||||
"Modal",
|
||||
"ModalBody",
|
||||
"ModalCloseButton",
|
||||
"ModalContent",
|
||||
"ModalContextProvider",
|
||||
"ModalFocusScope",
|
||||
"ModalFooter",
|
||||
"ModalHeader",
|
||||
"ModalOverlay",
|
||||
"NumberDecrementStepper",
|
||||
"NumberIncrementStepper",
|
||||
"NumberInput",
|
||||
"NumberInputField",
|
||||
"NumberInputStepper",
|
||||
"OrderedList",
|
||||
"PinInput",
|
||||
"PinInputDescendantsProvider",
|
||||
"PinInputField",
|
||||
"PinInputProvider",
|
||||
"Popover",
|
||||
"PopoverAnchor",
|
||||
"PopoverArrow",
|
||||
"PopoverBody",
|
||||
"PopoverCloseButton",
|
||||
"PopoverContent",
|
||||
"PopoverFooter",
|
||||
"PopoverHeader",
|
||||
"PopoverTrigger",
|
||||
"Portal",
|
||||
"PortalManager",
|
||||
"Progress",
|
||||
"ProgressLabel",
|
||||
"Radio",
|
||||
"RadioGroup",
|
||||
"RangeSlider",
|
||||
"RangeSliderFilledTrack",
|
||||
"RangeSliderMark",
|
||||
"RangeSliderProvider",
|
||||
"RangeSliderThumb",
|
||||
"RangeSliderTrack",
|
||||
"RequiredIndicator",
|
||||
"Select",
|
||||
"SelectField",
|
||||
"ScaleFade",
|
||||
"Show as ChakraShow",
|
||||
"SimpleGrid",
|
||||
"Skeleton",
|
||||
"SkeletonCircle",
|
||||
"SkeletonText",
|
||||
"Slide",
|
||||
"SlideFade",
|
||||
"Slider",
|
||||
"SliderFilledTrack",
|
||||
"SliderMark",
|
||||
"SliderProvider",
|
||||
"SliderThumb",
|
||||
"SliderTrack",
|
||||
"Spacer",
|
||||
"Spinner",
|
||||
"Square",
|
||||
"Stack",
|
||||
"StackDivider",
|
||||
"StackItem",
|
||||
"Stat",
|
||||
"StatArrow",
|
||||
"StatDownArrow",
|
||||
"StatGroup",
|
||||
"StatHelpText",
|
||||
"StatLabel",
|
||||
"StatNumber",
|
||||
"StatUpArrow",
|
||||
"Switch",
|
||||
"Tab",
|
||||
"TabIndicator",
|
||||
"TabList",
|
||||
"TabPanel",
|
||||
"TabPanels",
|
||||
"Table",
|
||||
"TableCaption",
|
||||
"TableContainer",
|
||||
"Tabs",
|
||||
"TabsDescendantsProvider",
|
||||
"TabsProvider",
|
||||
"Tag",
|
||||
"TagCloseButton",
|
||||
"TagLabel",
|
||||
"TagLeftIcon",
|
||||
"TagRightIcon",
|
||||
"Tbody",
|
||||
"Td",
|
||||
"Text",
|
||||
"Textarea",
|
||||
"Tfoot",
|
||||
"Th",
|
||||
"Thead",
|
||||
"ThemeProvider",
|
||||
"Toast",
|
||||
"ToastProvider",
|
||||
"Tooltip",
|
||||
"Tr",
|
||||
"UnorderedList",
|
||||
"VStack",
|
||||
"VisuallyHidden",
|
||||
"VisuallyHiddenInput",
|
||||
"Wrap",
|
||||
"WrapItem",
|
||||
"useAccordion",
|
||||
"useAccordionContext",
|
||||
"useAccordionItem",
|
||||
"useAccordionItemState",
|
||||
"useAccordionStyles",
|
||||
"useAlertStyles",
|
||||
"useAnimationState",
|
||||
"useAvatarStyles",
|
||||
"useBoolean",
|
||||
"useBreadcrumbStyles",
|
||||
"useBreakpoint",
|
||||
"useBreakpointValue",
|
||||
"useButtonGroup",
|
||||
"useCallbackRef",
|
||||
"useChakra",
|
||||
"useCheckbox",
|
||||
"useCheckboxGroup",
|
||||
"useClipboard",
|
||||
"useColorMode",
|
||||
"useColorModePreference",
|
||||
"useColorModeValue",
|
||||
"useComponentStyles__unstable",
|
||||
"useConst",
|
||||
"useControllableProp",
|
||||
"useControllableState",
|
||||
"useCounter",
|
||||
"useDisclosure",
|
||||
"useDrawerContext",
|
||||
"useEditable",
|
||||
"useEditableControls",
|
||||
"useEditableState",
|
||||
"useEditableStyles",
|
||||
"useEnvironment",
|
||||
"useEventListener",
|
||||
"useEventListenerMap",
|
||||
"useFocusOnHide",
|
||||
"addPrefix",
|
||||
"assignRef",
|
||||
"background",
|
||||
"border",
|
||||
"calc",
|
||||
"chakra",
|
||||
"color",
|
||||
"cookieStorageManager",
|
||||
"cookieStorageManagerSSR",
|
||||
"createCookieStorageManager",
|
||||
"createIcon",
|
||||
"createLocalStorageManager",
|
||||
"createMultiStyleConfigHelpers",
|
||||
"createRenderToast",
|
||||
"createStandaloneToast",
|
||||
"createStylesContext",
|
||||
"createToastFn",
|
||||
"css",
|
||||
"cssVar",
|
||||
"defineStyle",
|
||||
"defineStyleConfig",
|
||||
"effect",
|
||||
"extendTheme",
|
||||
"fadeConfig",
|
||||
"filter",
|
||||
"flatten",
|
||||
"flattenTokens",
|
||||
"flexbox",
|
||||
"forwardRef",
|
||||
"getCSSVar",
|
||||
"getCss",
|
||||
"getScriptSrc",
|
||||
"getSlideTransition",
|
||||
"getToastPlacement",
|
||||
"getToken",
|
||||
"grid",
|
||||
"interactivity",
|
||||
"isChakraTheme",
|
||||
"isStyleProp",
|
||||
"keyframes",
|
||||
"layout",
|
||||
"layoutPropNames",
|
||||
"list",
|
||||
"localStorageManager",
|
||||
"mergeThemeOverride",
|
||||
"omitThemingProps",
|
||||
"others",
|
||||
"popperCSSVars",
|
||||
"position",
|
||||
"propNames",
|
||||
"pseudoPropNames",
|
||||
"pseudoSelectors",
|
||||
"requiredChakraThemeKeys",
|
||||
"resolveStyleConfig",
|
||||
"ring",
|
||||
"scaleFadeConfig",
|
||||
"scroll",
|
||||
"shouldForwardProp",
|
||||
"slideFadeConfig",
|
||||
"space",
|
||||
"styled",
|
||||
"systemProps",
|
||||
"textDecoration",
|
||||
"theme",
|
||||
"toCSSObject",
|
||||
"toCSSVar",
|
||||
"toVarDefinition",
|
||||
"toVarReference",
|
||||
"tokenToCSSVar",
|
||||
"transform",
|
||||
"transition",
|
||||
"typography",
|
||||
"useFocusEffect",
|
||||
"useFocusOnPointerDown",
|
||||
"useFocusOnShow",
|
||||
"useForceUpdate",
|
||||
"useFormControl",
|
||||
"useFormControlContext",
|
||||
"useFormControlProps",
|
||||
"useFormControlStyles",
|
||||
"useFormErrorStyles",
|
||||
"useHighlight",
|
||||
"useId",
|
||||
"useIds",
|
||||
"useImage",
|
||||
"useInputGroupStyles",
|
||||
"useInterval",
|
||||
"useLatestRef",
|
||||
"useListStyles",
|
||||
"useMediaQuery",
|
||||
"useMenu",
|
||||
"useMenuButton",
|
||||
"useMenuContext",
|
||||
"useMenuItem",
|
||||
"useMenuList",
|
||||
"useMenuOption",
|
||||
"useMenuOptionGroup",
|
||||
"useMenuPositioner",
|
||||
"useMenuState",
|
||||
"useMenuStyles",
|
||||
"useMergeRefs",
|
||||
"useModal",
|
||||
"useModalContext",
|
||||
"useModalStyles",
|
||||
"useMouseDownRef",
|
||||
"useMultiStyleConfig",
|
||||
"useNumberInput",
|
||||
"useNumberInputStyles",
|
||||
"useOptionalPart",
|
||||
"useOutsideClick",
|
||||
"usePanGesture",
|
||||
"usePinInput",
|
||||
"usePinInputContext",
|
||||
"usePinInputField",
|
||||
"usePointerEvent",
|
||||
"usePopover",
|
||||
"usePopoverContext",
|
||||
"usePopoverStyles",
|
||||
"usePopper",
|
||||
"usePortalManager",
|
||||
"usePrefersReducedMotion",
|
||||
"usePrevious",
|
||||
"useProgressStyles",
|
||||
"useQuery",
|
||||
"useRadio",
|
||||
"useRadioGroup",
|
||||
"useRadioGroupContext",
|
||||
"useRangeSlider",
|
||||
"useRangeSliderContext",
|
||||
"useRangeSliderStyles",
|
||||
"useSafeLayoutEffect",
|
||||
"useShortcut",
|
||||
"useSlider",
|
||||
"useSliderContext",
|
||||
"useSliderStyles",
|
||||
"useStatStyles",
|
||||
"useStyleConfig",
|
||||
"useStyles",
|
||||
"useTab",
|
||||
"useTabIndicator",
|
||||
"useTabList",
|
||||
"useTabPanel",
|
||||
"useTabPanels",
|
||||
"useTableStyles",
|
||||
"useTabs",
|
||||
"useTabsContext",
|
||||
"useTabsStyles",
|
||||
"useTagStyles",
|
||||
"useTheme",
|
||||
"useTimeout",
|
||||
"useToast",
|
||||
"useToken",
|
||||
"useTooltip",
|
||||
"useUnmountEffect",
|
||||
"useUpdateEffect",
|
||||
"useWhyDidYouUpdate",
|
||||
"visuallyHiddenStyle",
|
||||
"withDefaultColorScheme",
|
||||
"withDefaultProps",
|
||||
"withDefaultSize",
|
||||
"withDefaultVariant",
|
||||
"withDelay",
|
||||
// types
|
||||
"AbsoluteCenterProps",
|
||||
"AccordionButtonProps",
|
||||
"AccordionItemProps",
|
||||
"AccordionPanelProps",
|
||||
"AccordionProps",
|
||||
"AlertDescriptionProps",
|
||||
"AlertDialogProps",
|
||||
"AlertIconProps",
|
||||
"AlertProps",
|
||||
"AlertTitleProps",
|
||||
"AvatarBadgeProps",
|
||||
"AspectRatioProps",
|
||||
"AvatarGroupProps",
|
||||
"AvatarProps",
|
||||
"BackgroundProps",
|
||||
"BadgeProps",
|
||||
"BorderProps",
|
||||
"BoxProps",
|
||||
"BreadcrumbItemProps",
|
||||
"BreadcrumbLinkProps",
|
||||
"BreadcrumbProps as ChakraBreadcrumbProps",
|
||||
"BreadcrumbSeparatorProps",
|
||||
"ButtonGroupProps",
|
||||
"ButtonProps",
|
||||
"CSSVarsProps",
|
||||
"CenterProps",
|
||||
"ChakraProps",
|
||||
"ChakraProviderProps",
|
||||
"CheckboxGroupProps",
|
||||
"CheckboxIconProps",
|
||||
"CheckboxProps",
|
||||
"CircularProgressLabelProps",
|
||||
"CircularProgressProps",
|
||||
"CloseButtonProps",
|
||||
"CodeProps",
|
||||
"CollapseProps",
|
||||
"ColorModeProviderProps",
|
||||
"ColorModeScriptProps",
|
||||
"ColorProps",
|
||||
"ComponentDefaultProps",
|
||||
"ContainerProps",
|
||||
"ControlBoxProps",
|
||||
"DividerProps",
|
||||
"DrawerContentProps",
|
||||
"DrawerProps",
|
||||
"EditableInputProps",
|
||||
"EditablePreviewProps",
|
||||
"EditableProps",
|
||||
"EditableTextareaProps",
|
||||
"EffectProps",
|
||||
"EnvironmentProviderProps",
|
||||
"FadeProps",
|
||||
"FilterProps",
|
||||
"FlexProps",
|
||||
"FlexboxProps",
|
||||
"FormControlProps",
|
||||
"FormErrorMessageProps",
|
||||
"FormLabelProps",
|
||||
"GridItemProps",
|
||||
"GridProps",
|
||||
"HTMLChakraProps",
|
||||
"HeadingProps",
|
||||
"HideProps",
|
||||
"HighlightProps",
|
||||
"IconButtonProps",
|
||||
"IconProps",
|
||||
"ImageProps",
|
||||
"ImgProps",
|
||||
"InputAddonProps",
|
||||
"InputElementProps",
|
||||
"InputGroupProps",
|
||||
"InputProps",
|
||||
"InteractivityProps",
|
||||
"KbdProps",
|
||||
"LayoutProps",
|
||||
"LinkBoxProps",
|
||||
"LinkOverlayProps",
|
||||
"LinkProps",
|
||||
"ListItemProps",
|
||||
"ListProps as ChakraListProps",
|
||||
"MarkProps",
|
||||
"MenuButtonProps",
|
||||
"MenuCommandProps",
|
||||
"MenuDividerProps",
|
||||
"MenuGroupProps",
|
||||
"MenuItemOptionProps",
|
||||
"MenuItemProps",
|
||||
"MenuListProps",
|
||||
"MenuOptionGroupProps",
|
||||
"MenuProps",
|
||||
"ModalBodyProps",
|
||||
"ModalContentProps",
|
||||
"ModalFooterProps",
|
||||
"ModalHeaderProps",
|
||||
"ModalOverlayProps",
|
||||
"ModalProps",
|
||||
"NumberDecrementStepperProps",
|
||||
"NumberIncrementStepperProps",
|
||||
"NumberInputFieldProps",
|
||||
"NumberInputProps",
|
||||
"NumberInputStepperProps",
|
||||
"OmitCommonProps",
|
||||
"OtherProps",
|
||||
"PinInputFieldProps",
|
||||
"PinInputProps",
|
||||
"PopoverArrowProps",
|
||||
"PopoverBodyProps",
|
||||
"PopoverCloseButtonProps",
|
||||
"PopoverContentProps",
|
||||
"PopoverFooterProps",
|
||||
"PopoverHeaderProps",
|
||||
"PopoverProps",
|
||||
"PortalManagerProps",
|
||||
"PortalProps",
|
||||
"PositionProps",
|
||||
"ProgressFilledTrackProps",
|
||||
"ProgressLabelProps",
|
||||
"ProgressProps",
|
||||
"ProgressTrackProps",
|
||||
"RadioGroupProps",
|
||||
"RadioProps",
|
||||
"RangeSliderInnerTrackProps",
|
||||
"RangeSliderMarkProps",
|
||||
"RangeSliderProps",
|
||||
"RangeSliderThumbProps",
|
||||
"RangeSliderTrackProps",
|
||||
"RequiredIndicatorProps",
|
||||
"RightJoinProps",
|
||||
"RingProps",
|
||||
"ScaleFadeProps",
|
||||
"ScrollProps",
|
||||
"SelectFieldProps",
|
||||
"SelectProps",
|
||||
"ShowProps as ChakraShowProps",
|
||||
"SimpleGridProps",
|
||||
"SkeletonProps",
|
||||
"SkeletonTextProps",
|
||||
"SlideFadeProps",
|
||||
"SlideProps",
|
||||
"SliderInnerTrackProps",
|
||||
"SliderMarkProps",
|
||||
"SliderProps",
|
||||
"SliderThumbProps",
|
||||
"SliderTrackProps",
|
||||
"SpaceProps",
|
||||
"SpacerProps",
|
||||
"SpinnerProps",
|
||||
"SquareProps",
|
||||
"StackDividerProps",
|
||||
"StackProps",
|
||||
"StatArrowProps",
|
||||
"StatGroupProps",
|
||||
"StatHelpTextProps",
|
||||
"StatLabelProps",
|
||||
"StatNumberProps",
|
||||
"StatProps",
|
||||
"StyleFunctionProps",
|
||||
"StyleProps",
|
||||
"SwitchProps",
|
||||
"SystemProps",
|
||||
"TabIndicatorProps",
|
||||
"TabListProps",
|
||||
"TabPanelProps",
|
||||
"TabPanelsProps",
|
||||
"TabProps",
|
||||
"TableBodyProps",
|
||||
"TableCaptionProps",
|
||||
"TableCellProps",
|
||||
"TableColumnHeaderProps",
|
||||
"TableContainerProps",
|
||||
"TableFooterProps",
|
||||
"TableHeadProps",
|
||||
"TableProps",
|
||||
"TableRowProps",
|
||||
"TabsProps",
|
||||
"TagCloseButtonProps",
|
||||
"TagLabelProps",
|
||||
"TagProps",
|
||||
"TextDecorationProps",
|
||||
"TextProps",
|
||||
"TextareaProps",
|
||||
"ThemeComponentProps",
|
||||
"ThemeProviderProps",
|
||||
"ThemingProps",
|
||||
"ToastProps",
|
||||
"ToastProviderProps",
|
||||
"TooltipProps",
|
||||
"TransformProps",
|
||||
"TransitionProps",
|
||||
"TypographyProps",
|
||||
"UseAccordionItemProps",
|
||||
"UseAccordionProps",
|
||||
"UseAnimationStateProps",
|
||||
"UseCheckboxGroupProps",
|
||||
"UseCheckboxProps",
|
||||
"UseControllableStateProps",
|
||||
"UseCounterProps",
|
||||
"UseDisclosureProps",
|
||||
"UseEditableProps",
|
||||
"UseFocusOnMouseDownProps",
|
||||
"UseFormControlProps",
|
||||
"UseImageProps",
|
||||
"UseMenuButtonProps",
|
||||
"UseMenuItemProps",
|
||||
"UseMenuListProps",
|
||||
"UseMenuOptionGroupProps",
|
||||
"UseMenuOptionProps",
|
||||
"UseMenuProps",
|
||||
"UseModalProps",
|
||||
"UseNumberInputProps",
|
||||
"UseOutsideClickProps",
|
||||
"UsePanGestureProps",
|
||||
"UsePinInputFieldProps",
|
||||
"UsePinInputProps",
|
||||
"UsePopoverProps",
|
||||
"UsePopperProps",
|
||||
"UseQueryProps",
|
||||
"UseRadioGroupProps",
|
||||
"UseRadioProps",
|
||||
"UseRangeSliderProps",
|
||||
"UseShortcutProps",
|
||||
"UseSliderProps",
|
||||
"UseTabListProps",
|
||||
"UseTabPanelsProps",
|
||||
"UseTabProps",
|
||||
"UseTabsProps",
|
||||
"UseTooltipProps",
|
||||
"WrapItemProps",
|
||||
"WrapProps",
|
||||
"AlertStatus",
|
||||
"As",
|
||||
"BaseThemeTypings",
|
||||
"BaseThemeWithExtensions",
|
||||
"BreadcrumbOptions",
|
||||
"ButtonOptions",
|
||||
"CSSWithMultiValues",
|
||||
"ChakraComponent",
|
||||
"ChakraStyledOptions",
|
||||
"ChakraTheme",
|
||||
"CheckboxGroupContext",
|
||||
"CheckboxState",
|
||||
"CollapseOptions",
|
||||
"ColorHues",
|
||||
"ColorMode",
|
||||
"ColorModeContextType",
|
||||
"ColorModeWithSystem",
|
||||
"Colors",
|
||||
"ComponentMultiStyleConfig",
|
||||
"ComponentSingleStyleConfig",
|
||||
"ComponentStyleConfig",
|
||||
"ComponentWithAs",
|
||||
"ControlBoxOptions",
|
||||
"CreateStandAloneToastParam",
|
||||
"CreateStandaloneToastReturn",
|
||||
"CreateStyleContextReturn",
|
||||
"CreateToastFnReturn",
|
||||
"CreateToastOptions",
|
||||
"CustomThemeTypings",
|
||||
"DeepPartial",
|
||||
"EventListenerEnv",
|
||||
"FlatToken",
|
||||
"FlatTokens",
|
||||
"FlattenTokensParam",
|
||||
"FormControlOptions",
|
||||
"FunctionCSSInterpolation",
|
||||
"HTMLChakraComponents",
|
||||
"ICollapse",
|
||||
"Interpolation",
|
||||
"LogicalToastPosition",
|
||||
"MergeWithAs",
|
||||
"MultiStyleConfig",
|
||||
"OmitSpaceXY",
|
||||
"Operand",
|
||||
"PartsStyleFunction",
|
||||
"PartsStyleInterpolation",
|
||||
"PartsStyleObject",
|
||||
"PinInputContext",
|
||||
"Placement",
|
||||
"PlacementWithLogical",
|
||||
"PlainToken",
|
||||
"PropsOf",
|
||||
"Pseudos",
|
||||
"RadioGroupContext",
|
||||
"RecursiveCSSObject",
|
||||
"RecursiveCSSSelector",
|
||||
"RecursiveObject",
|
||||
"RecursiveProperty",
|
||||
"RecursivePseudo",
|
||||
"ResponsiveArray",
|
||||
"ResponsiveObject",
|
||||
"ResponsiveValue",
|
||||
"SkeletonOptions",
|
||||
"SlideDirection",
|
||||
"SlideOptions",
|
||||
"StackDirection",
|
||||
"StyleConfig",
|
||||
"StyleObjectOrFn",
|
||||
"SystemCSSProperties",
|
||||
"SystemStyleFunction",
|
||||
"SystemStyleInterpolation",
|
||||
"SystemStyleObject",
|
||||
"SystemStyleObjectRecord",
|
||||
"TableOptions",
|
||||
"Theme",
|
||||
"ThemeComponentFunction",
|
||||
"ThemeComponents",
|
||||
"ThemeConfig",
|
||||
"ThemeDirection",
|
||||
"ThemeExtension",
|
||||
"ThemeOverride",
|
||||
"ThemeScale",
|
||||
"ThemeThunk",
|
||||
"ThemeTransitions",
|
||||
"ThemeTypings",
|
||||
"ThemingPropsThunk",
|
||||
"ToastId",
|
||||
"ToastMessage",
|
||||
"ToastMethods",
|
||||
"ToastOptions",
|
||||
"ToastPosition",
|
||||
"ToastPositionWithLogical",
|
||||
"ToastState",
|
||||
"TransitionProperties",
|
||||
"UseAccordionItemReturn",
|
||||
"UseAccordionReturn",
|
||||
"UseBreakpointOptions",
|
||||
"UseCheckboxGroupReturn",
|
||||
"UseCheckboxReturn",
|
||||
"UseClipboardOptions",
|
||||
"UseCounterReturn",
|
||||
"UseDisclosureReturn",
|
||||
"UseEditableReturn",
|
||||
"UseFocusEffectOptions",
|
||||
"UseFocusOnHideOptions",
|
||||
"UseFocusOnShowOptions",
|
||||
"UseImageReturn",
|
||||
"UseMediaQueryOptions",
|
||||
"UseMenuOptionOptions",
|
||||
"UseMenuReturn",
|
||||
"UseModalReturn",
|
||||
"UseNumberInputReturn",
|
||||
"UsePinInputReturn",
|
||||
"UsePopoverReturn",
|
||||
"UsePopperReturn",
|
||||
"UseRadioGroupReturn",
|
||||
"UseRadioReturn",
|
||||
"UseRangeSliderReturn",
|
||||
"UseSliderReturn",
|
||||
"UseTabListReturn",
|
||||
"UseTabOptions",
|
||||
"UseTabsReturn",
|
||||
"UseToastOptions",
|
||||
"UseTooltipReturn",
|
||||
"WithCSSVar",
|
||||
"SemanticToken",
|
||||
"SemanticValue",
|
||||
];
|
||||
|
||||
export const rename: { [key: string]: string } = {
|
||||
ChakraBreadcrumb: "Breadcrumb",
|
||||
ChakraList: "List",
|
||||
ChakraShow: "Show",
|
||||
ChakraBreadcrumbProps: "BreadcrumbProps",
|
||||
ChakraListProps: "ListProps",
|
||||
ChakraShowProps: "ShowProps",
|
||||
};
|
||||
536
packages/codemod/src/definitions/separated-imports/mantine.ts
Normal file
536
packages/codemod/src/definitions/separated-imports/mantine.ts
Normal file
@@ -0,0 +1,536 @@
|
||||
export const exported: string[] = [
|
||||
"AVAILABLE_TRANSITIONS",
|
||||
"Accordion",
|
||||
"ActionIcon",
|
||||
"Affix",
|
||||
"Alert",
|
||||
"AlphaSlider",
|
||||
"Anchor",
|
||||
"AppShell",
|
||||
"Aside",
|
||||
"AspectRatio",
|
||||
"Autocomplete",
|
||||
"Avatar",
|
||||
"BackgroundImage",
|
||||
"Badge",
|
||||
"Blockquote",
|
||||
"Box",
|
||||
"Breadcrumbs",
|
||||
"Burger",
|
||||
"Button",
|
||||
"COLOR_PICKER_SIZES",
|
||||
"Card",
|
||||
"CardSection",
|
||||
"Center",
|
||||
"CheckIcon",
|
||||
"Checkbox",
|
||||
"CheckboxIcon",
|
||||
"ChevronIcon",
|
||||
"Chip",
|
||||
"CloseButton",
|
||||
"Code",
|
||||
"Collapse",
|
||||
"Col",
|
||||
"ColorInput",
|
||||
"ColorPicker",
|
||||
// "ColorSchemeProvider",
|
||||
"ColorSwatch",
|
||||
"Container",
|
||||
"CopyButton",
|
||||
// "DEFAULT_THEME",
|
||||
"Dialog",
|
||||
"Divider",
|
||||
"Drawer",
|
||||
"FileButton",
|
||||
"FileInput",
|
||||
"FocusTrap",
|
||||
"Footer",
|
||||
"Global",
|
||||
"GlobalStyles",
|
||||
"Grid",
|
||||
"Group",
|
||||
"GroupedTransition",
|
||||
"MantineHeader",
|
||||
"Highlight",
|
||||
"HoverCard",
|
||||
"HueSlider",
|
||||
"INPUT_SIZES",
|
||||
"Image",
|
||||
"Indicator",
|
||||
"Input",
|
||||
"InputBase",
|
||||
"JsonInput",
|
||||
"Kbd",
|
||||
"MantineList",
|
||||
"Loader",
|
||||
"LoadingOverlay",
|
||||
// "MANTINE_COLORS",
|
||||
// "MANTINE_SIZES",
|
||||
"MantineProvider",
|
||||
"Mark",
|
||||
"MediaQuery",
|
||||
"Menu",
|
||||
"Modal",
|
||||
"MultiSelect",
|
||||
"NativeSelect",
|
||||
"NavLink",
|
||||
"Navbar",
|
||||
// "NormalizeCSS",
|
||||
"Notification",
|
||||
"NumberInput",
|
||||
"OptionalPortal",
|
||||
"Overlay",
|
||||
"Pagination",
|
||||
"Paper",
|
||||
"PasswordInput",
|
||||
"Popover",
|
||||
"Portal",
|
||||
"Progress",
|
||||
"Radio",
|
||||
"RangeSlider",
|
||||
"RingProgress",
|
||||
"ScrollArea",
|
||||
"SegmentedControl",
|
||||
"Select",
|
||||
"SelectChevronIcon",
|
||||
"SimpleGrid",
|
||||
"Skeleton",
|
||||
"Slider",
|
||||
"Space",
|
||||
"Spoiler",
|
||||
"Stack",
|
||||
"Step",
|
||||
"Stepper",
|
||||
"Switch",
|
||||
"Table",
|
||||
"Tabs",
|
||||
"Text",
|
||||
"TextInput",
|
||||
"Textarea",
|
||||
"ThemeIcon",
|
||||
"Timeline",
|
||||
"TimelineItem",
|
||||
"Title",
|
||||
"Tooltip",
|
||||
"TransferList",
|
||||
"Transition",
|
||||
"TypographyStylesProvider",
|
||||
"UnstyledButton",
|
||||
// "clsx",
|
||||
// "createEmotionCache",
|
||||
"createPolymorphicComponent",
|
||||
// "createStyles",
|
||||
// "defaultMantineEmotionCache",
|
||||
"extractSystemStyles",
|
||||
// "getDefaultZIndex",
|
||||
"getSortedBreakpoints",
|
||||
// "keyframes",
|
||||
"packSx",
|
||||
// "useComponentDefaultProps",
|
||||
// "useCss",
|
||||
// "useEmotionCache",
|
||||
"useInputProps",
|
||||
"useMantineColorScheme",
|
||||
// "useMantineTheme",
|
||||
"validateJson",
|
||||
// types
|
||||
"AccordionControlProps",
|
||||
"AccordionItemProps",
|
||||
"AccordionPanelProps",
|
||||
"AccordionProps",
|
||||
"AccordionStylesNames",
|
||||
"AccordionStylesParams",
|
||||
"ActionIconProps",
|
||||
"ActionIconStylesNames",
|
||||
"ActionIconStylesParams",
|
||||
"ActionIconVariant",
|
||||
"AffixProps",
|
||||
"AlertProps",
|
||||
"AlertStylesNames",
|
||||
"AlertStylesParams",
|
||||
"AlphaSliderProps",
|
||||
"AnchorProps",
|
||||
"AppShellProps",
|
||||
"AppShellStylesNames",
|
||||
"AppShellStylesParams",
|
||||
"AsideProps",
|
||||
"AspectRatioProps",
|
||||
"AspectRatioStylesParams",
|
||||
"AutocompleteItem",
|
||||
"AutocompleteProps",
|
||||
"AutocompleteStylesNames",
|
||||
"AvatarProps",
|
||||
"AvatarStylesNames",
|
||||
"AvatarStylesParams",
|
||||
"BackgroundImageProps",
|
||||
"BadgeProps",
|
||||
"BadgeStylesNames",
|
||||
"BadgeStylesParams",
|
||||
"BadgeVariant",
|
||||
"BaseSelectProps",
|
||||
"BlockquoteProps",
|
||||
"BlockquoteStylesNames",
|
||||
"BlockquoteStylesParams",
|
||||
"BoxProps",
|
||||
"BreadcrumbsProps",
|
||||
"BreadcrumbsStylesNames",
|
||||
"BurgerProps",
|
||||
"BurgerStylesNames",
|
||||
"BurgerStylesParams",
|
||||
"ButtonGroupProps",
|
||||
"ButtonGroupStylesParams",
|
||||
"ButtonProps",
|
||||
"ButtonStylesNames",
|
||||
"ButtonStylesParams",
|
||||
"ButtonVariant",
|
||||
"CSSObject",
|
||||
"CardProps",
|
||||
"CardSectionProps",
|
||||
"CenterProps",
|
||||
"CheckboxGroupProps",
|
||||
"CheckboxGroupStylesNames",
|
||||
"CheckboxIconProps",
|
||||
"CheckboxProps",
|
||||
"CheckboxStylesNames",
|
||||
"CheckboxStylesParams",
|
||||
"ChipGroupProps",
|
||||
"ChipProps",
|
||||
"ChipStylesNames",
|
||||
"ChipStylesParams",
|
||||
"ClassNames",
|
||||
"CloseButtonProps",
|
||||
"CodeProps",
|
||||
"CodeStylesParams",
|
||||
"ColProps",
|
||||
"CollapseProps",
|
||||
"ColorInputProps",
|
||||
"ColorInputStylesNames",
|
||||
"ColorPickerBaseProps",
|
||||
"ColorPickerProps",
|
||||
"ColorPickerStylesNames",
|
||||
"ColorPickerStylesParams",
|
||||
"ColorScheme",
|
||||
"ColorSwatchProps",
|
||||
"ColorSwatchStylesNames",
|
||||
"ColorSwatchStylesParams",
|
||||
"ContainerProps",
|
||||
"ContainerStylesParams",
|
||||
"CopyButtonProps",
|
||||
"DefaultMantineColor",
|
||||
"DefaultProps",
|
||||
"DialogProps",
|
||||
"DialogStylesNames",
|
||||
"DialogStylesParams",
|
||||
"DividerProps",
|
||||
"DividerStylesNames",
|
||||
"DividerStylesParams",
|
||||
"DrawerPosition",
|
||||
"DrawerProps",
|
||||
"DrawerStylesNames",
|
||||
"DrawerStylesParams",
|
||||
"EmotionCache",
|
||||
"FileButtonProps",
|
||||
"FileInputProps",
|
||||
"FileInputStylesNames",
|
||||
"FocusTrapProps",
|
||||
"FooterProps",
|
||||
"GridProps",
|
||||
"GroupProps",
|
||||
"GroupedTransitionProps",
|
||||
"HighlightProps",
|
||||
"MatineHeaderProps",
|
||||
"HoverCardDropdownProps",
|
||||
"HoverCardTargetProps",
|
||||
"HoverCardProps",
|
||||
"HueSliderProps",
|
||||
"ImageProps",
|
||||
"ImageStylesNames",
|
||||
"ImageStylesParams",
|
||||
"IndicatorProps",
|
||||
"IndicatorStylesNames",
|
||||
"IndicatorStylesParams",
|
||||
"InputBaseProps",
|
||||
"InputBaseStylesNames",
|
||||
"InputDescriptionProps",
|
||||
"InputDescriptionStylesNames",
|
||||
"InputErrorProps",
|
||||
"InputErrorStylesNames",
|
||||
"InputLabelProps",
|
||||
"InputLabelStylesNames",
|
||||
"InputProps",
|
||||
"InputSharedProps",
|
||||
"InputStylesNames",
|
||||
"InputStylesParams",
|
||||
"InputVariant",
|
||||
"InputWrapperBaseProps",
|
||||
"InputWrapperProps",
|
||||
"InputWrapperStylesNames",
|
||||
"JsonInputProps",
|
||||
"JsonInputStylesNames",
|
||||
"JsonInputStylesParams",
|
||||
"KbdProps",
|
||||
"ListItemProps",
|
||||
"MantineListProps",
|
||||
"ListStylesNames",
|
||||
"ListItemStylesNames",
|
||||
"ListStylesParams",
|
||||
"LoaderProps",
|
||||
"LoadingOverlayProps",
|
||||
"MantineColor",
|
||||
"MantineGradient",
|
||||
"MantineNumberSize",
|
||||
"MantineProviderProps",
|
||||
"MantineShadow",
|
||||
"MantineSize",
|
||||
"MantineSizes",
|
||||
"MantineStyleSystemProps",
|
||||
"MantineStyleSystemSize",
|
||||
"MantineTheme",
|
||||
"MantineThemeBase",
|
||||
"MantineThemeColors",
|
||||
"MantineThemeColorsOverride",
|
||||
"MantineThemeOther",
|
||||
"MantineThemeOverride",
|
||||
"MantineTransition",
|
||||
"MarkProps",
|
||||
"MarkStylesParams",
|
||||
"MediaQueryProps",
|
||||
"MediaQueryStylesParams",
|
||||
"MenuDividerProps",
|
||||
"MenuDropdownProps",
|
||||
"MenuItemProps",
|
||||
"MenuLabelProps",
|
||||
"MenuProps",
|
||||
"MenuStylesNames",
|
||||
"MenuTargetProps",
|
||||
"ModalProps",
|
||||
"ModalStylesNames",
|
||||
"ModalStylesParams",
|
||||
"MultiSelectProps",
|
||||
"MultiSelectStylesNames",
|
||||
"MultiSelectStylesParams",
|
||||
"MultiSelectValueProps",
|
||||
"NativeSelectProps",
|
||||
"NativeSelectStylesNames",
|
||||
"NavLinkProps",
|
||||
"NavLinkStylesNames",
|
||||
"NavLinkStylesParams",
|
||||
"NavbarProps",
|
||||
"NotificationProps",
|
||||
"NotificationStylesNames",
|
||||
"NotificationStylesParams",
|
||||
"NumberInputHandlers",
|
||||
"NumberInputProps",
|
||||
"NumberInputStylesNames",
|
||||
"NumberInputStylesParams",
|
||||
"OptionalPortalProps",
|
||||
"OverlayProps",
|
||||
"PaginationItemProps",
|
||||
"PaginationProps",
|
||||
"PaginationStylesNames",
|
||||
"PaginationStylesParams",
|
||||
"PaperProps",
|
||||
"PaperStylesParams",
|
||||
"PasswordInputProps",
|
||||
"PasswordInputStylesNames",
|
||||
"PasswordInputStylesParams",
|
||||
"PopoverBaseProps",
|
||||
"PopoverDropdownProps",
|
||||
"PopoverProps",
|
||||
"PopoverStylesNames",
|
||||
"PopoverStylesParams",
|
||||
"PopoverTargetProps",
|
||||
"PortalProps",
|
||||
"ProgressProps",
|
||||
"ProgressStylesNames",
|
||||
"ProgressStylesParams",
|
||||
"RadioGroupProps",
|
||||
"RadioGroupStylesNames",
|
||||
"RadioProps",
|
||||
"RadioStylesNames",
|
||||
"RadioStylesParams",
|
||||
"RangeSliderProps",
|
||||
"RingProgressProps",
|
||||
"RingProgressStylesNames",
|
||||
"ScrollAreaProps",
|
||||
"ScrollAreaStylesNames",
|
||||
"ScrollAreaStylesParams",
|
||||
"SegmentedControlItem",
|
||||
"SegmentedControlProps",
|
||||
"SegmentedControlStylesNames",
|
||||
"SegmentedControlStylesParams",
|
||||
"SelectItem",
|
||||
"SelectItemProps",
|
||||
"SelectProps",
|
||||
"SelectStylesNames",
|
||||
"Selectors",
|
||||
"SimpleGridBreakpoint",
|
||||
"SimpleGridProps",
|
||||
"SimpleGridStylesParams",
|
||||
"SkeletonProps",
|
||||
"SkeletonStylesParams",
|
||||
"SliderProps",
|
||||
"SliderStylesNames",
|
||||
"SpaceProps",
|
||||
"SpoilerProps",
|
||||
"SpoilerStylesNames",
|
||||
"SpoilerStylesParams",
|
||||
"StackProps",
|
||||
"StackStylesParams",
|
||||
"StepProps",
|
||||
"StepStylesParams",
|
||||
"StepperProps",
|
||||
"StepperStylesNames",
|
||||
"StepperStylesParams",
|
||||
"Styles",
|
||||
"SwitchProps",
|
||||
"SwitchStylesNames",
|
||||
"SwitchStylesParams",
|
||||
"Sx",
|
||||
"TabProps",
|
||||
"TableProps",
|
||||
"TableStylesParams",
|
||||
"TabsListProps",
|
||||
"TabsOrientation",
|
||||
"TabsPanelProps",
|
||||
"TabsProps",
|
||||
"TabsStylesNames",
|
||||
"TabsStylesParams",
|
||||
"TabsValue",
|
||||
"TabsVariant",
|
||||
"TextInputProps",
|
||||
"TextInputStylesNames",
|
||||
"TextProps",
|
||||
"TextStylesParams",
|
||||
"TextareaProps",
|
||||
"ThemeIconProps",
|
||||
"ThemeIconStylesParams",
|
||||
"ThemeIconVariant",
|
||||
"TimelineItemProps",
|
||||
"TimelineItemStylesNames",
|
||||
"TimelineProps",
|
||||
"TitleOrder",
|
||||
"TitleProps",
|
||||
"TitleStylesParams",
|
||||
"TooltipFloatingProps",
|
||||
"TooltipGroupProps",
|
||||
"TooltipProps",
|
||||
"TooltipStylesNames",
|
||||
"TooltipStylesParams",
|
||||
"TransferListData",
|
||||
"TransferListItem",
|
||||
"TransferListItemComponent",
|
||||
"TransferListItemComponentProps",
|
||||
"TransferListProps",
|
||||
"TransferListStylesNames",
|
||||
"TransitionProps",
|
||||
"Tuple",
|
||||
"TypographyStylesProviderProps",
|
||||
"UnstyledButtonProps",
|
||||
"UseStylesOptions",
|
||||
];
|
||||
|
||||
export const rename: { [key: string]: string } = {
|
||||
MantineHeader: "Header",
|
||||
MantineList: "List",
|
||||
MatineHeaderProps: "HeaderProps",
|
||||
MantineListProps: "ListProps",
|
||||
};
|
||||
|
||||
export const other: { [key: string]: string } = {
|
||||
NotificationsProvider: "@mantine/notifications",
|
||||
cleanNotifications: "@mantine/notifications",
|
||||
cleanNotificationsQueue: "@mantine/notifications",
|
||||
hideNotification: "@mantine/notifications",
|
||||
showNotification: "@mantine/notifications",
|
||||
updateNotification: "@mantine/notifications",
|
||||
useNotifications: "@mantine/notifications",
|
||||
//
|
||||
assignRef: "@mantine/hooks",
|
||||
clamp: "@mantine/hooks",
|
||||
clampUseMovePosition: "@mantine/hooks",
|
||||
getHotkeyHandler: "@mantine/hooks",
|
||||
lowerFirst: "@mantine/hooks",
|
||||
mergeRefs: "@mantine/hooks",
|
||||
randomId: "@mantine/hooks",
|
||||
range: "@mantine/hooks",
|
||||
shallowEqual: "@mantine/hooks",
|
||||
upperFirst: "@mantine/hooks",
|
||||
useClickOutside: "@mantine/hooks",
|
||||
useClipboard: "@mantine/hooks",
|
||||
useColorScheme: "@mantine/hooks",
|
||||
useCounter: "@mantine/hooks",
|
||||
useDebouncedState: "@mantine/hooks",
|
||||
useDebouncedValue: "@mantine/hooks",
|
||||
useDidUpdate: "@mantine/hooks",
|
||||
useDisclosure: "@mantine/hooks",
|
||||
useDocumentTitle: "@mantine/hooks",
|
||||
useDocumentVisibility: "@mantine/hooks",
|
||||
useElementSize: "@mantine/hooks",
|
||||
useEventListener: "@mantine/hooks",
|
||||
useEyeDropper: "@mantine/hooks",
|
||||
useFavicon: "@mantine/hooks",
|
||||
useFocusReturn: "@mantine/hooks",
|
||||
useFocusTrap: "@mantine/hooks",
|
||||
useFocusWithin: "@mantine/hooks",
|
||||
useForceUpdate: "@mantine/hooks",
|
||||
useFullscreen: "@mantine/hooks",
|
||||
useHash: "@mantine/hooks",
|
||||
useHotkeys: "@mantine/hooks",
|
||||
useHover: "@mantine/hooks",
|
||||
useId: "@mantine/hooks",
|
||||
useIdle: "@mantine/hooks",
|
||||
useInputState: "@mantine/hooks",
|
||||
useIntersection: "@mantine/hooks",
|
||||
useInterval: "@mantine/hooks",
|
||||
useIsomorphicEffect: "@mantine/hooks",
|
||||
useListState: "@mantine/hooks",
|
||||
useLocalStorage: "@mantine/hooks",
|
||||
useLogger: "@mantine/hooks",
|
||||
useMediaQuery: "@mantine/hooks",
|
||||
useMergedRef: "@mantine/hooks",
|
||||
useMouse: "@mantine/hooks",
|
||||
useMove: "@mantine/hooks",
|
||||
useNetwork: "@mantine/hooks",
|
||||
useOs: "@mantine/hooks",
|
||||
usePageLeave: "@mantine/hooks",
|
||||
usePagination: "@mantine/hooks",
|
||||
usePrevious: "@mantine/hooks",
|
||||
useQueue: "@mantine/hooks",
|
||||
useReducedMotion: "@mantine/hooks",
|
||||
useResizeObserver: "@mantine/hooks",
|
||||
useScrollIntoView: "@mantine/hooks",
|
||||
useScrollLock: "@mantine/hooks",
|
||||
useSessionStorage: "@mantine/hooks",
|
||||
useSetState: "@mantine/hooks",
|
||||
useShallowEffect: "@mantine/hooks",
|
||||
useTextSelection: "@mantine/hooks",
|
||||
useTimeout: "@mantine/hooks",
|
||||
useToggle: "@mantine/hooks",
|
||||
useUncontrolled: "@mantine/hooks",
|
||||
useValidatedState: "@mantine/hooks",
|
||||
useViewportSize: "@mantine/hooks",
|
||||
useWindowEvent: "@mantine/hooks",
|
||||
useWindowScroll: "@mantine/hooks",
|
||||
//
|
||||
ColorSchemeProvider: "@mantine/styles",
|
||||
DEFAULT_THEME: "@mantine/styles",
|
||||
// Global: "@mantine/styles",
|
||||
// GlobalStyles: "@mantine/styles",
|
||||
MANTINE_COLORS: "@mantine/styles",
|
||||
MANTINE_SIZES: "@mantine/styles",
|
||||
// MantineProvider: "@mantine/styles",
|
||||
NormalizeCSS: "@mantine/styles",
|
||||
clsx: "@mantine/styles",
|
||||
createEmotionCache: "@mantine/styles",
|
||||
createStyles: "@mantine/styles",
|
||||
defaultMantineEmotionCache: "@mantine/styles",
|
||||
filterProps: "@mantine/styles",
|
||||
getDefaultZIndex: "@mantine/styles",
|
||||
keyframes: "@mantine/styles",
|
||||
useComponentDefaultProps: "@mantine/styles",
|
||||
useCss: "@mantine/styles",
|
||||
useEmotionCache: "@mantine/styles",
|
||||
// useMantineColorScheme: "@mantine/styles",
|
||||
useMantineTheme: "@mantine/styles",
|
||||
};
|
||||
1207
packages/codemod/src/definitions/separated-imports/mui.ts
Normal file
1207
packages/codemod/src/definitions/separated-imports/mui.ts
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,138 @@
|
||||
export const exported: string[] = [
|
||||
"BatchFieldArrayUpdate",
|
||||
"ChangeHandler",
|
||||
"Control",
|
||||
"ControllerFieldState",
|
||||
"ControllerProps",
|
||||
"ControllerRenderProps",
|
||||
"CriteriaMode",
|
||||
"CustomElement",
|
||||
"DeepMap",
|
||||
"DeepPartial",
|
||||
"DeepPartialSkipArrayKey",
|
||||
"DefaultValues",
|
||||
"DelayCallback",
|
||||
"EmptyObject",
|
||||
"ErrorOption",
|
||||
"EventType",
|
||||
"Field",
|
||||
"FieldArray",
|
||||
"FieldArrayMethodProps",
|
||||
"FieldArrayWithId",
|
||||
"FieldElement",
|
||||
"FieldError",
|
||||
"FieldErrors",
|
||||
"FieldName",
|
||||
"FieldNamesMarkedBoolean",
|
||||
"FieldRefs",
|
||||
"FieldValue",
|
||||
"FieldValues",
|
||||
"FormProviderProps",
|
||||
"FormState",
|
||||
"FormStateProxy",
|
||||
"FormStateSubjectRef",
|
||||
"GetIsDirty",
|
||||
"InternalFieldErrors",
|
||||
"InternalFieldName",
|
||||
"InternalNameSet",
|
||||
"IsAny",
|
||||
"IsFlatObject",
|
||||
"KeepStateOptions",
|
||||
"LiteralUnion",
|
||||
"Message",
|
||||
"Mode",
|
||||
"MultipleFieldErrors",
|
||||
"Names",
|
||||
"NativeFieldValue",
|
||||
"NestedValue",
|
||||
"NonUndefined",
|
||||
"Noop",
|
||||
"Primitive",
|
||||
"ReadFormState",
|
||||
"Ref",
|
||||
"RefCallBack",
|
||||
"RegisterOptions",
|
||||
"Resolver",
|
||||
"ResolverError",
|
||||
"ResolverOptions",
|
||||
"ResolverResult",
|
||||
"ResolverSuccess",
|
||||
"SetFieldValue",
|
||||
"SetValueConfig",
|
||||
"Subjects",
|
||||
"SubmitErrorHandler",
|
||||
"SubmitHandler",
|
||||
"TriggerConfig",
|
||||
"UnpackNestedValue",
|
||||
"UseControllerProps",
|
||||
"UseControllerReturn",
|
||||
"UseFieldArrayProps",
|
||||
"UseFieldArrayReturn",
|
||||
"UseFieldArrayReplace",
|
||||
"UseFormClearErrors",
|
||||
"UseFormGetValues",
|
||||
"UseFormHandleSubmit",
|
||||
"UseReactHookFormProps",
|
||||
"UseFormRegister",
|
||||
"UseFormRegisterReturn",
|
||||
"UseFormReset",
|
||||
"UseFormResetField",
|
||||
"UseFormReturn",
|
||||
"UseFormSetError",
|
||||
"UseFormSetFocus",
|
||||
"UseFormSetValue",
|
||||
"UseFormStateProps",
|
||||
"UseFormStateReturn",
|
||||
"UseFormTrigger",
|
||||
"UseFormUnregister",
|
||||
"UseFormWatch",
|
||||
"UseWatchProps",
|
||||
"Validate",
|
||||
"ValidateResult",
|
||||
"ValidationMode",
|
||||
"ValidationRule",
|
||||
"ValidationValue",
|
||||
"ValidationValueMessage",
|
||||
"WatchInternal",
|
||||
"WatchObserver",
|
||||
"ArrayPath",
|
||||
"FieldPath",
|
||||
"FieldPathValue",
|
||||
"FieldPathValues",
|
||||
"BrowserNativeObject",
|
||||
"DeepRequired",
|
||||
"FieldErrorsImpl",
|
||||
"IsNever",
|
||||
"Merge",
|
||||
"SetFocusOptions",
|
||||
"UseFieldArrayAppend",
|
||||
"UseFieldArrayInsert",
|
||||
"UseFieldArrayMove",
|
||||
"UseFieldArrayPrepend",
|
||||
"UseFieldArrayRemove",
|
||||
"UseFieldArraySwap",
|
||||
"UseFieldArrayUpdate",
|
||||
"UseFormGetFieldState",
|
||||
"FieldArrayPath",
|
||||
"FieldArrayPathValue",
|
||||
"FieldPathByValue",
|
||||
"PathString",
|
||||
"Path",
|
||||
"PathValue",
|
||||
"appendErrors",
|
||||
"get",
|
||||
"set",
|
||||
"useController",
|
||||
"useFieldArray",
|
||||
"useReactHookForm",
|
||||
"useFormContext",
|
||||
"useFormState",
|
||||
"useWatch",
|
||||
"Controller",
|
||||
"FormProvider",
|
||||
];
|
||||
|
||||
export const rename: { [key: string]: string } = {
|
||||
UseReactHookFormProps: "UseFormProps",
|
||||
useReactHookForm: "useForm",
|
||||
};
|
||||
@@ -0,0 +1,73 @@
|
||||
export const exported: string[] = [
|
||||
"CancelledError",
|
||||
"Hydrate",
|
||||
"InfiniteQueryObserver",
|
||||
"IsRestoringProvider",
|
||||
"MutationCache",
|
||||
"MutationObserver",
|
||||
"QueriesObserver",
|
||||
"QueryCache",
|
||||
"QueryClient",
|
||||
"QueryClientProvider",
|
||||
"QueryErrorResetBoundary",
|
||||
"QueryObserver",
|
||||
"defaultContext",
|
||||
"defaultShouldDehydrateMutation",
|
||||
"defaultShouldDehydrateQuery",
|
||||
"dehydrate",
|
||||
"focusManager",
|
||||
"hashQueryKey",
|
||||
"hydrate",
|
||||
"isCancelledError",
|
||||
"isError",
|
||||
"isServer",
|
||||
"notifyManager",
|
||||
"onlineManager",
|
||||
"parseFilterArgs",
|
||||
"parseMutationArgs",
|
||||
"parseMutationFilterArgs",
|
||||
"parseQueryArgs",
|
||||
"replaceEqualDeep",
|
||||
"useHydrate",
|
||||
"useInfiniteQuery",
|
||||
"useIsFetching",
|
||||
"useIsMutating",
|
||||
"useIsRestoring",
|
||||
"useMutation",
|
||||
"useQueries",
|
||||
"useQuery",
|
||||
"useQueryClient",
|
||||
"useQueryErrorResetBoundary",
|
||||
"DefaultedInfiniteQueryObserverOptions",
|
||||
"DefaultedQueryObserverOptions",
|
||||
"DefinedQueryObserverResult",
|
||||
"InfiniteQueryObserverResult",
|
||||
"DefinedUseBaseQueryResult",
|
||||
"DefinedUseQueryResult",
|
||||
"FetchStatus",
|
||||
"GetNextPageParamFunction",
|
||||
"InitialDataFunction",
|
||||
"GetPreviousPageParamFunction",
|
||||
"MutateFunction",
|
||||
"MutationFunction",
|
||||
"MutationKey",
|
||||
"MutationObserverResult",
|
||||
"MutationStatus",
|
||||
"NetworkMode",
|
||||
"NotifyEventType",
|
||||
"PlaceholderDataFunction",
|
||||
"QueryFunction",
|
||||
"QueryKey",
|
||||
"QueryKeyHashFunction",
|
||||
"QueryObserverResult",
|
||||
"QueryStatus",
|
||||
"UseBaseMutationResult",
|
||||
"UseBaseQueryResult",
|
||||
"UseErrorBoundary",
|
||||
"WithRequired",
|
||||
"UseMutateAsyncFunction",
|
||||
"UseInfiniteQueryResult",
|
||||
"UseQueryResult",
|
||||
"UseMutateFunction",
|
||||
"UseMutationResult",
|
||||
];
|
||||
@@ -0,0 +1,69 @@
|
||||
export const exported: string[] = [
|
||||
"Hash",
|
||||
"Location",
|
||||
"Path",
|
||||
"To",
|
||||
"MemoryRouterProps",
|
||||
"NavigateFunction",
|
||||
"NavigateOptions",
|
||||
"NavigateProps",
|
||||
"Navigator",
|
||||
"OutletProps",
|
||||
"Params",
|
||||
"PathMatch",
|
||||
"RouteMatch",
|
||||
"RouteObject",
|
||||
"RouteProps",
|
||||
"PathRouteProps",
|
||||
"LayoutRouteProps",
|
||||
"IndexRouteProps",
|
||||
"RouterProps",
|
||||
"Pathname",
|
||||
"Search",
|
||||
"RoutesProps",
|
||||
"UNSAFE_NavigationContext",
|
||||
"UNSAFE_LocationContext",
|
||||
"UNSAFE_RouteContext",
|
||||
"BrowserRouterProps",
|
||||
"BrowserRouter",
|
||||
"HashRouterProps",
|
||||
"HashRouter",
|
||||
"HistoryRouterProps",
|
||||
"HistoryRouter",
|
||||
"unstable_HistoryRouter",
|
||||
"LinkProps",
|
||||
"Link",
|
||||
"NavLinkProps",
|
||||
"NavLink",
|
||||
"useLinkClickHandler",
|
||||
"useSearchParams",
|
||||
"ParamKeyValuePair",
|
||||
"URLSearchParamsInit",
|
||||
"createSearchParams",
|
||||
"MemoryRouter",
|
||||
"Navigate",
|
||||
"Outlet",
|
||||
"Route",
|
||||
"Router",
|
||||
"Routes",
|
||||
"createRoutesFromChildren",
|
||||
"generatePath",
|
||||
"matchRoutes",
|
||||
"matchPath",
|
||||
"createPath",
|
||||
"parsePath",
|
||||
"renderMatches",
|
||||
"resolvePath",
|
||||
"useHref",
|
||||
"useInRouterContext",
|
||||
"useLocation",
|
||||
"useMatch",
|
||||
"useNavigate",
|
||||
"useNavigationType",
|
||||
"useOutlet",
|
||||
"useParams",
|
||||
"useResolvedPath",
|
||||
"useRoutes",
|
||||
"useOutletContext",
|
||||
"NavigationType",
|
||||
];
|
||||
@@ -0,0 +1,197 @@
|
||||
export const exported: string[] = [
|
||||
"ColumnSizing",
|
||||
"aggregationFns",
|
||||
"buildHeaderGroups",
|
||||
"createCell",
|
||||
"createColumn",
|
||||
"createColumnHelper",
|
||||
"createRow",
|
||||
"createTable",
|
||||
"defaultColumnSizing",
|
||||
"expandRows",
|
||||
"filterFns",
|
||||
"Filters",
|
||||
"flattenBy",
|
||||
"flexRender",
|
||||
"Expanding",
|
||||
"functionalUpdate",
|
||||
"getCoreRowModel",
|
||||
"getExpandedRowModel",
|
||||
"getFacetedMinMaxValues",
|
||||
"getFacetedRowModel",
|
||||
"getFacetedUniqueValues",
|
||||
"getFilteredRowModel",
|
||||
"getGroupedRowModel",
|
||||
"getPaginationRowModel",
|
||||
"getSortedRowModel",
|
||||
"isFunction",
|
||||
"isRowSelected",
|
||||
"isSubRowSelected",
|
||||
"Pinning",
|
||||
"makeStateUpdater",
|
||||
"memo",
|
||||
"noop",
|
||||
"Pagination",
|
||||
"RowSelection",
|
||||
"orderColumns",
|
||||
"Grouping",
|
||||
"passiveEventSupported",
|
||||
"Ordering",
|
||||
"reSplitAlphaNumeric",
|
||||
"selectRowsFn",
|
||||
"shouldAutoRemoveFilter",
|
||||
"sortingFns",
|
||||
"Headers",
|
||||
"Visibility",
|
||||
"Sorting",
|
||||
"useReactTable",
|
||||
|
||||
// types
|
||||
"AccessorColumnDef",
|
||||
"AccessorFn",
|
||||
"AccessorFnColumnDef",
|
||||
"AccessorKeyColumnDef",
|
||||
"AggregationFn",
|
||||
"AggregationFnOption",
|
||||
"AggregationFns",
|
||||
"AnyRender",
|
||||
"BuiltInAggregationFn",
|
||||
"BuiltInFilterFn",
|
||||
"BuiltInSortingFn",
|
||||
"Cell",
|
||||
"CellContext",
|
||||
"Column",
|
||||
"ColumnDef",
|
||||
"ColumnDefBase",
|
||||
"ColumnDefResolved",
|
||||
"ColumnDefTemplate",
|
||||
"ColumnDefaultOptions",
|
||||
"ColumnFilter",
|
||||
"ColumnFilterAutoRemoveTestFn",
|
||||
"ColumnFiltersState",
|
||||
"ColumnHelper",
|
||||
"ColumnMeta",
|
||||
"ColumnOrderDefaultOptions",
|
||||
"ColumnOrderInstance",
|
||||
"ColumnOrderOptions",
|
||||
"ColumnOrderState",
|
||||
"ColumnOrderTableState",
|
||||
"ColumnPinningColumn",
|
||||
"ColumnPinningColumnDef",
|
||||
"ColumnPinningDefaultOptions",
|
||||
"ColumnPinningInstance",
|
||||
"ColumnPinningOptions",
|
||||
"ColumnPinningPosition",
|
||||
"ColumnPinningRow",
|
||||
"ColumnPinningState",
|
||||
"ColumnPinningTableState",
|
||||
"ColumnResizeMode",
|
||||
"ColumnSizingColumn",
|
||||
"ColumnSizingColumnDef",
|
||||
"ColumnSizingDefaultOptions",
|
||||
"ColumnSizingHeader",
|
||||
"ColumnSizingInfoState",
|
||||
"ColumnSizingInstance",
|
||||
"ColumnSizingOptions",
|
||||
"ColumnSizingState",
|
||||
"ColumnSizingTableState",
|
||||
"ColumnSort",
|
||||
"CoreCell",
|
||||
"CoreColumn",
|
||||
"CoreHeader",
|
||||
"CoreHeaderGroup",
|
||||
"CoreRow",
|
||||
"CoreInstance",
|
||||
"CoreOptions",
|
||||
"CoreTableState",
|
||||
"CustomAggregationFns",
|
||||
"CustomFilterFns",
|
||||
"CustomSortingFns",
|
||||
"DeepKeys",
|
||||
"DeepValue",
|
||||
"DisplayColumnDef",
|
||||
"ExpandedInstance",
|
||||
"ExpandedOptions",
|
||||
"ExpandedState",
|
||||
"ExpandedRow",
|
||||
"ExpandedStateList",
|
||||
"ExpandedTableState",
|
||||
"FilterFn",
|
||||
"FilterFnOption",
|
||||
"FilterFns",
|
||||
"FilterMeta",
|
||||
"FiltersColumn",
|
||||
"FiltersColumnDef",
|
||||
"FiltersInstance",
|
||||
"FiltersOptions",
|
||||
"FiltersRow",
|
||||
"FiltersTableState",
|
||||
"Getter",
|
||||
"GroupColumnDef",
|
||||
"GroupingCell",
|
||||
"GroupingColumn",
|
||||
"GroupingColumnDef",
|
||||
"GroupingColumnMode",
|
||||
"GroupingInstance",
|
||||
"GroupingOptions",
|
||||
"GroupingRow",
|
||||
"GroupingState",
|
||||
"GroupingTableState",
|
||||
"Header",
|
||||
"HeaderContext",
|
||||
"HeaderGroup",
|
||||
"HeadersInstance",
|
||||
"IdentifiedColumnDef",
|
||||
"InitialTableState",
|
||||
"IsAny",
|
||||
"IsKnown",
|
||||
"NoInfer",
|
||||
"OnChangeFn",
|
||||
"Overwrite",
|
||||
"PaginationDefaultOptions",
|
||||
"PaginationInitialTableState",
|
||||
"PaginationInstance",
|
||||
"PaginationOptions",
|
||||
"PaginationState",
|
||||
"PaginationTableState",
|
||||
"PartialKeys",
|
||||
"Renderable",
|
||||
"RequiredKeys",
|
||||
"ResolvedColumnFilter",
|
||||
"Row",
|
||||
"RowData",
|
||||
"RowModel",
|
||||
"RowSelectionInstance",
|
||||
"RowSelectionOptions",
|
||||
"RowSelectionRow",
|
||||
"RowSelectionState",
|
||||
"RowSelectionTableState",
|
||||
"SortDirection",
|
||||
"SortingColumn",
|
||||
"SortingColumnDef",
|
||||
"SortingFn",
|
||||
"SortingFnOption",
|
||||
"SortingFns",
|
||||
"SortingInstance",
|
||||
"SortingOptions",
|
||||
"SortingState",
|
||||
"SortingTableState",
|
||||
"StringOrTemplateHeader",
|
||||
"Table",
|
||||
"TableFeature",
|
||||
"TableMeta",
|
||||
"TableOptions",
|
||||
"TableOptionsResolved",
|
||||
"TableState",
|
||||
"TransformFilterValueFn",
|
||||
"UnionToIntersection",
|
||||
"Updater",
|
||||
"VisibilityColumn",
|
||||
"VisibilityColumnDef",
|
||||
"VisibilityInstance",
|
||||
"VisibilityOptions",
|
||||
"VisibilityRow",
|
||||
"VisibilityState",
|
||||
"VisibilityTableState",
|
||||
"VisibilityDefaultOptions",
|
||||
];
|
||||
24
packages/codemod/src/helpers/check-antd-version-is-3x.ts
Normal file
24
packages/codemod/src/helpers/check-antd-version-is-3x.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import PackageJson from "@npmcli/package-json";
|
||||
import path from "path";
|
||||
import semver from "semver";
|
||||
|
||||
export const getAntdVersion = async () => {
|
||||
const rootDir = path.join(process.cwd());
|
||||
|
||||
const pkgJson = await PackageJson.load(rootDir);
|
||||
const dependencies = pkgJson.content.dependencies ?? {};
|
||||
const antd = dependencies["@pankod/refine-antd"];
|
||||
|
||||
return antd;
|
||||
};
|
||||
|
||||
export const checkAntdVersionIs3x = async () => {
|
||||
const antd = await getAntdVersion();
|
||||
|
||||
if (!antd) return false;
|
||||
|
||||
// remove ^, =, <, > and ~ from version
|
||||
const version = antd.replace(/[^\d\.]/g, "");
|
||||
|
||||
return semver.lt(version, "4.0.0");
|
||||
};
|
||||
16
packages/codemod/src/helpers/check-package-lock.ts
Normal file
16
packages/codemod/src/helpers/check-package-lock.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
export function checkPackageLock(
|
||||
root: string,
|
||||
): "package-lock.json" | "yarn.lock" {
|
||||
const yarnLockPath = path.join(root, "yarn.lock");
|
||||
|
||||
try {
|
||||
if (fs.existsSync(yarnLockPath)) {
|
||||
return "yarn.lock";
|
||||
}
|
||||
} catch (err) {
|
||||
return "package-lock.json";
|
||||
}
|
||||
}
|
||||
4
packages/codemod/src/helpers/index.ts
Normal file
4
packages/codemod/src/helpers/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export * from "./install";
|
||||
export * from "./temp-codemod-config";
|
||||
export * from "./check-package-lock";
|
||||
export * from "./separate-imports";
|
||||
184
packages/codemod/src/helpers/install.ts
Normal file
184
packages/codemod/src/helpers/install.ts
Normal file
@@ -0,0 +1,184 @@
|
||||
// https://github.com/vercel/next.js/blob/54ca8f41cee490989cdd8d5df8db96307075296c/packages/next-codemod/lib/install.ts
|
||||
|
||||
import chalk from "chalk";
|
||||
import spawn from "cross-spawn";
|
||||
|
||||
interface InstallArgs {
|
||||
/**
|
||||
* Indicate whether to install packages using Yarn.
|
||||
*/
|
||||
useYarn: boolean;
|
||||
/**
|
||||
* Indicate whether there is an active Internet connection.
|
||||
*/
|
||||
isOnline: boolean;
|
||||
/**
|
||||
* Indicate whether the given dependencies are devDependencies.
|
||||
*/
|
||||
devDependencies?: boolean;
|
||||
}
|
||||
|
||||
interface RemoveArgs {
|
||||
/**
|
||||
* Indicate whether to install packages using Yarn.
|
||||
*/
|
||||
useYarn: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Spawn a package manager installation with either Yarn or NPM.
|
||||
*
|
||||
* @returns A Promise that resolves once the installation is finished.
|
||||
*/
|
||||
export function install(
|
||||
root: string,
|
||||
dependencies: string[] | null,
|
||||
{ useYarn, isOnline, devDependencies }: InstallArgs,
|
||||
): Promise<void> {
|
||||
/**
|
||||
* NPM-specific command-line flags.
|
||||
*/
|
||||
const npmFlags: string[] = ["--force"];
|
||||
/**
|
||||
* Yarn-specific command-line flags.
|
||||
*/
|
||||
const yarnFlags: string[] = [];
|
||||
/**
|
||||
* Return a Promise that resolves once the installation is finished.
|
||||
*/
|
||||
return new Promise((resolve, reject) => {
|
||||
let args: string[];
|
||||
const command: string = useYarn ? "yarnpkg" : "npm";
|
||||
|
||||
if (dependencies?.length) {
|
||||
/**
|
||||
* If there are dependencies, run a variation of `{displayCommand} add`.
|
||||
*/
|
||||
if (useYarn) {
|
||||
/**
|
||||
* Call `yarn add --exact (--offline)? (-D)? ...`.
|
||||
*/
|
||||
args = ["add"];
|
||||
if (!isOnline) args.push("--offline");
|
||||
args.push("--cwd", root);
|
||||
if (devDependencies) args.push("--dev");
|
||||
args.push(...dependencies);
|
||||
} else {
|
||||
/**
|
||||
* Call `npm install [--save|--save-dev] ...`.
|
||||
*/
|
||||
args = ["install"];
|
||||
args.push(devDependencies ? "--save-dev" : "--save");
|
||||
args.push(...dependencies);
|
||||
}
|
||||
} else {
|
||||
/**
|
||||
* If there are no dependencies, run a variation of `{displayCommand}
|
||||
* install`.
|
||||
*/
|
||||
args = ["install"];
|
||||
if (useYarn) {
|
||||
if (!isOnline) {
|
||||
console.log(chalk.yellow("You appear to be offline."));
|
||||
console.log(chalk.yellow("Falling back to the local Yarn cache."));
|
||||
console.log();
|
||||
args.push("--offline");
|
||||
}
|
||||
} else {
|
||||
if (!isOnline) {
|
||||
console.log(chalk.yellow("You appear to be offline."));
|
||||
console.log();
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Add any package manager-specific flags.
|
||||
*/
|
||||
if (useYarn) {
|
||||
args.push(...yarnFlags);
|
||||
} else {
|
||||
args.push(...npmFlags);
|
||||
}
|
||||
/**
|
||||
* Spawn the installation process.
|
||||
*/
|
||||
const child = spawn(command, args, {
|
||||
stdio: "inherit",
|
||||
env: { ...process.env, ADBLOCK: "1", DISABLE_OPENCOLLECTIVE: "1" },
|
||||
});
|
||||
child.on("close", (code) => {
|
||||
if (code !== 0) {
|
||||
reject({ command: `${command} ${args.join(" ")}` });
|
||||
return;
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Spawn a package manager removing with either Yarn or NPM.
|
||||
*
|
||||
* @returns A Promise that resolves once the removing is finished.
|
||||
*/
|
||||
export function remove(
|
||||
root: string,
|
||||
dependencies: string[] | null,
|
||||
{ useYarn }: RemoveArgs,
|
||||
): Promise<void> {
|
||||
/**
|
||||
* NPM-specific command-line flags.
|
||||
*/
|
||||
const npmFlags: string[] = [];
|
||||
/**
|
||||
* Yarn-specific command-line flags.
|
||||
*/
|
||||
const yarnFlags: string[] = [];
|
||||
/**
|
||||
* Return a Promise that resolves once the installation is finished.
|
||||
*/
|
||||
return new Promise((resolve, reject) => {
|
||||
let args: string[];
|
||||
const command: string = useYarn ? "yarnpkg" : "npm";
|
||||
|
||||
if (dependencies?.length) {
|
||||
/**
|
||||
* If there are dependencies, run a variation of `{displayCommand} remove`.
|
||||
*/
|
||||
if (useYarn) {
|
||||
/**
|
||||
* Call `yarn remove --exact (--offline)? (-D)? ...`.
|
||||
*/
|
||||
args = ["remove"];
|
||||
} else {
|
||||
/**
|
||||
* Call `npm remove [--save|--save-dev] ...`.
|
||||
*/
|
||||
args = ["remove", "--save"];
|
||||
args.push(...dependencies);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Add any package manager-specific flags.
|
||||
*/
|
||||
if (useYarn) {
|
||||
args.push(...yarnFlags);
|
||||
} else {
|
||||
args.push(...npmFlags);
|
||||
}
|
||||
/**
|
||||
* Spawn the installation process.
|
||||
*/
|
||||
const child = spawn(command, args, {
|
||||
stdio: "inherit",
|
||||
env: { ...process.env, ADBLOCK: "1", DISABLE_OPENCOLLECTIVE: "1" },
|
||||
});
|
||||
child.on("close", (code) => {
|
||||
if (code !== 0) {
|
||||
reject({ command: `${command} ${args.join(" ")}` });
|
||||
return;
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
159
packages/codemod/src/helpers/separate-imports.ts
Normal file
159
packages/codemod/src/helpers/separate-imports.ts
Normal file
@@ -0,0 +1,159 @@
|
||||
import type { Collection, ImportSpecifier, JSCodeshift } from "jscodeshift";
|
||||
|
||||
/**
|
||||
* Separate imports from currentLibName to nextLibName
|
||||
* import { Create, Button, Form } from "@pankod/refine-antd";
|
||||
* to
|
||||
* import { Create } from "@pankod/refine-antd";
|
||||
* import { Button, Form } from "antd";
|
||||
*/
|
||||
export function separateImports(payload: {
|
||||
j: JSCodeshift;
|
||||
source: Collection<any>;
|
||||
imports: string[];
|
||||
renameImports: { [key: string]: string };
|
||||
renameToDefault?: { [key: string]: string };
|
||||
otherImports: { [key: string]: string };
|
||||
currentLibName: string;
|
||||
nextLibName: string;
|
||||
}) {
|
||||
const {
|
||||
j,
|
||||
source,
|
||||
imports,
|
||||
renameImports,
|
||||
renameToDefault = {},
|
||||
otherImports,
|
||||
currentLibName,
|
||||
nextLibName,
|
||||
} = payload;
|
||||
const nextLibImports: ImportSpecifier[] = [];
|
||||
const otherImportItems: ImportSpecifier[] = [];
|
||||
|
||||
const refineImport = source.find(j.ImportDeclaration, {
|
||||
source: {
|
||||
value: currentLibName,
|
||||
},
|
||||
});
|
||||
|
||||
refineImport.replaceWith((path) => {
|
||||
for (const item of path.node.specifiers) {
|
||||
if (renameToDefault[(item as ImportSpecifier)?.imported?.name]) {
|
||||
// means the imported element is going to be converted to default import from a package (value of renameToDefault)
|
||||
const pkg = renameToDefault[(item as ImportSpecifier)?.imported?.name];
|
||||
|
||||
const localName = (item as ImportSpecifier)?.local?.name;
|
||||
|
||||
// remove
|
||||
path.node.specifiers = path.node.specifiers.filter((p) => p !== item);
|
||||
|
||||
// insert
|
||||
j(path)
|
||||
.at(0)
|
||||
.insertAfter(
|
||||
j.importDeclaration(
|
||||
[j.importDefaultSpecifier(j.identifier(localName))],
|
||||
j.stringLiteral(pkg),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
// also checking for imported name which is actually the correct one to check for renamed ones
|
||||
if (imports.includes((item as ImportSpecifier)?.imported?.name)) {
|
||||
nextLibImports.push(item as ImportSpecifier);
|
||||
}
|
||||
|
||||
if (otherImports[(item as ImportSpecifier)?.imported?.name]) {
|
||||
otherImportItems.push(item as ImportSpecifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
path.node.specifiers = path.node.specifiers
|
||||
.filter((p) => !nextLibImports.includes(p as ImportSpecifier))
|
||||
.filter((p) => !otherImportItems.includes(p as ImportSpecifier));
|
||||
|
||||
return path.node;
|
||||
});
|
||||
|
||||
if (nextLibImports.length > 0) {
|
||||
// rename imports
|
||||
nextLibImports.forEach((item) => {
|
||||
if (renameImports[item.imported.name]) {
|
||||
// if imported and local names are different, then means its renamed. we can continue to do our swap
|
||||
// if imported and local are same, means we're changing the imported elements name, then we need to change the local name as well
|
||||
if (item.imported.name !== item.local.name) {
|
||||
// if the renamed name is the same as local name, then we don't need to rename it
|
||||
if (item.local.name === renameImports[item.imported.name]) {
|
||||
item.imported.name = renameImports[item.imported.name];
|
||||
item.local = undefined;
|
||||
} else {
|
||||
item.imported.name = renameImports[item.imported.name];
|
||||
}
|
||||
} else if (item.imported.name === item.local.name) {
|
||||
item.imported.name = `${renameImports[item.imported.name]} as ${
|
||||
item.imported.name
|
||||
}`;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
source
|
||||
.find(j.ImportDeclaration, {
|
||||
source: {
|
||||
value: currentLibName,
|
||||
},
|
||||
})
|
||||
.forEach((path, i) => {
|
||||
if (i === 0) {
|
||||
path.insertAfter(
|
||||
j.importDeclaration(nextLibImports, j.literal(nextLibName)),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// add other imports
|
||||
if (otherImportItems.length > 0) {
|
||||
const otherImportPaths: { [key: string]: ImportSpecifier[] } = {};
|
||||
otherImportItems.forEach((item) => {
|
||||
// find import path
|
||||
const importPath =
|
||||
otherImports[(item as ImportSpecifier)?.imported?.name];
|
||||
|
||||
if (otherImportPaths[importPath]) {
|
||||
otherImportPaths[importPath].push(item);
|
||||
} else {
|
||||
otherImportPaths[importPath] = [item];
|
||||
}
|
||||
});
|
||||
|
||||
Object.keys(otherImportPaths).forEach((importPath) => {
|
||||
source
|
||||
.find(j.ImportDeclaration, {
|
||||
source: {
|
||||
value: currentLibName,
|
||||
},
|
||||
})
|
||||
.forEach((path, i) => {
|
||||
if (i === 0) {
|
||||
path.insertAfter(
|
||||
j.importDeclaration(
|
||||
otherImportPaths[importPath],
|
||||
j.literal(importPath),
|
||||
),
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// remove empty imports
|
||||
source
|
||||
.find(j.ImportDeclaration, {
|
||||
source: {
|
||||
value: currentLibName,
|
||||
},
|
||||
})
|
||||
.filter((path) => path.node.specifiers.length === 0)
|
||||
.remove();
|
||||
}
|
||||
75
packages/codemod/src/helpers/temp-codemod-config.ts
Normal file
75
packages/codemod/src/helpers/temp-codemod-config.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
import fs from "fs";
|
||||
|
||||
type ConfigFileSchema = {
|
||||
install: {
|
||||
[packageName: string]: string;
|
||||
};
|
||||
uninstall: string[];
|
||||
};
|
||||
|
||||
const empty: ConfigFileSchema = {
|
||||
install: {},
|
||||
uninstall: [],
|
||||
};
|
||||
|
||||
export const CONFIG_FILE_NAME = ".refine-codemod.json";
|
||||
|
||||
export class CodemodConfig {
|
||||
filename: string;
|
||||
|
||||
constructor(filename: string) {
|
||||
this.filename = filename;
|
||||
}
|
||||
|
||||
private readFile(): ConfigFileSchema {
|
||||
try {
|
||||
const file = fs.readFileSync(this.filename, "utf8");
|
||||
if (file) {
|
||||
return JSON.parse(file) as ConfigFileSchema;
|
||||
}
|
||||
try {
|
||||
fs.writeFileSync(this.filename, JSON.stringify(empty));
|
||||
} catch (_error) {}
|
||||
|
||||
return empty;
|
||||
} catch (error) {
|
||||
return empty;
|
||||
}
|
||||
}
|
||||
|
||||
private updateFile(data: ConfigFileSchema): void {
|
||||
try {
|
||||
fs.writeFileSync(this.filename, JSON.stringify(data));
|
||||
} catch (error) {}
|
||||
}
|
||||
|
||||
addPackage(packageName: string, version?: string): void {
|
||||
const file = this.readFile();
|
||||
|
||||
file.install[packageName] = version ?? "latest";
|
||||
|
||||
this.updateFile(file);
|
||||
}
|
||||
|
||||
removePackage(packageName: string): void {
|
||||
const file = this.readFile();
|
||||
|
||||
file.uninstall.push(packageName);
|
||||
|
||||
this.updateFile(file);
|
||||
}
|
||||
|
||||
getInstalls(): { [packageName: string]: string } {
|
||||
return this.readFile().install;
|
||||
}
|
||||
|
||||
getUninstalls(): string[] {
|
||||
return this.readFile().uninstall;
|
||||
}
|
||||
|
||||
destroy(): void {
|
||||
try {
|
||||
fs.unlinkSync(this.filename);
|
||||
} catch (error) {}
|
||||
}
|
||||
}
|
||||
254
packages/codemod/src/index.ts
Normal file
254
packages/codemod/src/index.ts
Normal file
@@ -0,0 +1,254 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Copyright 2015-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
// Based on https://github.com/vercel/next.js/blob/canary/packages/next-codemod/bin/cli.ts
|
||||
// and https://github.com/reactjs/react-codemod/blob/dd8671c9a470a2c342b221ec903c574cf31e9f57/bin/cli.js
|
||||
// @refinedev/codemod name-of-transform optional/path/to/src [...options]
|
||||
|
||||
import chalk from "chalk";
|
||||
import execa from "execa";
|
||||
import globby from "globby";
|
||||
import inquirer from "inquirer";
|
||||
import isGitClean from "is-git-clean";
|
||||
import meow from "meow";
|
||||
import path from "path";
|
||||
import { checkAntdVersionIs3x } from "./helpers/check-antd-version-is-3x";
|
||||
|
||||
export const jscodeshiftExecutable = require.resolve(".bin/jscodeshift");
|
||||
export const transformerDirectory = path.join(
|
||||
__dirname,
|
||||
"../",
|
||||
"dist/transformations",
|
||||
);
|
||||
|
||||
const transformsWithPostTransform = [
|
||||
"refine1-to-refine2",
|
||||
"refine2-to-refine3",
|
||||
"refine3-to-refine4",
|
||||
];
|
||||
|
||||
export function checkGitStatus(force) {
|
||||
let clean = false;
|
||||
let errorMessage = "Unable to determine if git directory is clean";
|
||||
try {
|
||||
clean = isGitClean.sync(process.cwd());
|
||||
errorMessage = "Git directory is not clean";
|
||||
} catch (err) {
|
||||
if (err?.stderr && err.stderr.indexOf("Not a git repository") >= 0) {
|
||||
clean = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!clean) {
|
||||
if (force) {
|
||||
console.log(`WARNING: ${errorMessage}. Forcibly continuing.`);
|
||||
} else {
|
||||
console.log("Thank you for using @refinedev/codemod!");
|
||||
console.log(
|
||||
chalk.yellow(
|
||||
"\nBut before we continue, please stash or commit your git changes.",
|
||||
),
|
||||
);
|
||||
console.log(
|
||||
"\nYou may use the --force flag to override this safety check.",
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function runTransform({ files, flags, transformer }) {
|
||||
const transformerPath = path.join(transformerDirectory, `${transformer}.js`);
|
||||
|
||||
let args = [];
|
||||
|
||||
const { dry, print, runInBand } = flags;
|
||||
|
||||
if (dry) {
|
||||
args.push("--dry");
|
||||
}
|
||||
if (print) {
|
||||
args.push("--print");
|
||||
}
|
||||
if (runInBand) {
|
||||
args.push("--run-in-band");
|
||||
}
|
||||
|
||||
args.push("--verbose=2");
|
||||
|
||||
args.push("--ignore-pattern=**/node_modules/**");
|
||||
args.push("--ignore-pattern=**/build/**");
|
||||
args.push("--ignore-pattern=**/.next/**");
|
||||
args.push("--ignore-pattern=**/dist/**");
|
||||
args.push("--ignore-pattern=**/.cache/**");
|
||||
args.push("--ignore-pattern=theme.d.ts");
|
||||
|
||||
args.push("--extensions=tsx,ts,jsx,js");
|
||||
args.push("--parser=tsx");
|
||||
|
||||
args = args.concat(["--transform", transformerPath]);
|
||||
|
||||
if (flags.jscodeshift) {
|
||||
args = args.concat(flags.jscodeshift);
|
||||
}
|
||||
|
||||
args = args.concat(files);
|
||||
|
||||
console.log(`Executing command: jscodeshift ${args.join(" ")}`);
|
||||
|
||||
const result = execa.sync(jscodeshiftExecutable, args, {
|
||||
stdio: "inherit",
|
||||
stripFinalNewline: false,
|
||||
});
|
||||
|
||||
if (result.failed) {
|
||||
throw new Error(`jscodeshift exited with code ${result.exitCode}`);
|
||||
}
|
||||
}
|
||||
|
||||
const TRANSFORMER_INQUIRER_CHOICES = [
|
||||
{
|
||||
name: "Rename deprecated names (queryResult, tableQueryResult, mutationResult) to (query, tableQuery, mutation).",
|
||||
value: "rename-query-and-mutation-result",
|
||||
},
|
||||
{
|
||||
name: "refine3-to-refine4: Transform from refine 3.x.x to at least 4.0.0",
|
||||
value: "refine3-to-refine4",
|
||||
},
|
||||
{
|
||||
name: "antd4-to-antd5: Transform from antd 4.x.x to at least 5.x.x",
|
||||
value: "antd4-to-antd5",
|
||||
},
|
||||
{
|
||||
name: "refine2-to-refine3: Transform from refine 2.x.x to at least 3.0.0",
|
||||
value: "refine2-to-refine3",
|
||||
},
|
||||
{
|
||||
name: "refine1-to-refine2: Transform from refine 1.x.x to at least 2.0.0",
|
||||
value: "refine1-to-refine2",
|
||||
},
|
||||
];
|
||||
|
||||
function expandFilePathsIfNeeded(filesBeforeExpansion) {
|
||||
const shouldExpandFiles = filesBeforeExpansion.some((file) =>
|
||||
file.includes("*"),
|
||||
);
|
||||
return shouldExpandFiles
|
||||
? globby.sync(filesBeforeExpansion)
|
||||
: filesBeforeExpansion;
|
||||
}
|
||||
|
||||
export async function run(): Promise<void> {
|
||||
const cli = meow({
|
||||
description: "Codemods for updating refine apps.",
|
||||
help: `
|
||||
Usage
|
||||
$ npx @refinedev/codemod <transform> <path> <...options>
|
||||
path Files or directory to transform. Can be a glob like pages/**.js
|
||||
Options
|
||||
--force Bypass Git safety checks and forcibly run codemods
|
||||
--dry Dry run (no changes are made to files)
|
||||
--print Print transformed files to your terminal
|
||||
--jscodeshift (Advanced) Pass options directly to jscodeshift
|
||||
`,
|
||||
flags: {
|
||||
boolean: ["force", "dry", "print", "help"],
|
||||
string: ["_"],
|
||||
alias: {
|
||||
h: "help",
|
||||
},
|
||||
},
|
||||
} as meow.Options<meow.AnyFlags>);
|
||||
|
||||
if (!cli.flags.dry) {
|
||||
checkGitStatus(cli.flags.force);
|
||||
}
|
||||
|
||||
if (
|
||||
cli.input[0] &&
|
||||
!TRANSFORMER_INQUIRER_CHOICES.find((x) => x.value === cli.input[0])
|
||||
) {
|
||||
console.error("Invalid transform choice, pick one of:");
|
||||
console.error(
|
||||
TRANSFORMER_INQUIRER_CHOICES.map((x) => `- ${x.value}`).join("\n"),
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const { files, transformer } = await inquirer.prompt([
|
||||
{
|
||||
type: "input",
|
||||
name: "files",
|
||||
message: "On which files or directory should the codemods be applied?",
|
||||
when: !cli.input[1],
|
||||
default: ".",
|
||||
filter: (files) => files.trim(),
|
||||
},
|
||||
{
|
||||
type: "list",
|
||||
name: "transformer",
|
||||
message: "Which transform would you like to apply?",
|
||||
when: !cli.input[0],
|
||||
pageSize: TRANSFORMER_INQUIRER_CHOICES.length,
|
||||
choices: TRANSFORMER_INQUIRER_CHOICES,
|
||||
},
|
||||
]);
|
||||
|
||||
const filesBeforeExpansion = cli.input[1] || files;
|
||||
const filesExpanded = expandFilePathsIfNeeded([filesBeforeExpansion]);
|
||||
|
||||
const selectedTransformer = cli.input[0] || transformer;
|
||||
|
||||
if (selectedTransformer === "refine3-to-refine4") {
|
||||
const isAntdVersion3x = await checkAntdVersionIs3x();
|
||||
|
||||
if (isAntdVersion3x) {
|
||||
console.log();
|
||||
|
||||
console.log(
|
||||
"Uppss!, we encountered an issue that prevents us from upgrading your project to refine@4",
|
||||
);
|
||||
console.log(
|
||||
"You are using version 4 of Ant Design. refine@4 uses version 5 of Ant Design.",
|
||||
);
|
||||
console.log(
|
||||
`Before upgrading your project to refine@4, please upgrade your Ant Design to version 5. Don't worry, we have codemod support for this upgrade 🎉.`,
|
||||
);
|
||||
console.log(
|
||||
`To upgrade now, visit Migration Guide document > ${chalk.green(
|
||||
"https://refine.dev/docs/api-reference/antd/migration-guide/v4-to-v5/",
|
||||
)}`,
|
||||
);
|
||||
|
||||
process.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (!filesExpanded.length) {
|
||||
console.log(`No files found matching ${filesBeforeExpansion.join(" ")}`);
|
||||
return null;
|
||||
}
|
||||
|
||||
await runTransform({
|
||||
files: filesExpanded,
|
||||
flags: cli.flags,
|
||||
transformer: selectedTransformer,
|
||||
});
|
||||
|
||||
if (transformsWithPostTransform.includes(selectedTransformer)) {
|
||||
const transformerPath = path.join(
|
||||
transformerDirectory,
|
||||
`${selectedTransformer}.js`,
|
||||
);
|
||||
|
||||
await require(transformerPath).postTransform(filesExpanded, cli.flags);
|
||||
}
|
||||
}
|
||||
|
||||
run();
|
||||
62
packages/codemod/src/transformations/antd4-to-antd5.ts
Normal file
62
packages/codemod/src/transformations/antd4-to-antd5.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
import type { API, Collection, FileInfo, JSCodeshift } from "jscodeshift";
|
||||
|
||||
export const parser = "tsx";
|
||||
|
||||
const updateStyles = (j: JSCodeshift, root: Collection<any>) => {
|
||||
const styleMinCssImport = root.find(j.ImportDeclaration, {
|
||||
source: {
|
||||
value: "@pankod/refine-antd/dist/styles.min.css",
|
||||
},
|
||||
});
|
||||
|
||||
styleMinCssImport.replaceWith((path) => {
|
||||
path.node.source.value = "@pankod/refine-antd/dist/reset.css";
|
||||
|
||||
return path.node;
|
||||
});
|
||||
};
|
||||
|
||||
const updateActionButtonsPropstoHeaderButtons = (
|
||||
j: JSCodeshift,
|
||||
root: Collection<any>,
|
||||
) => {
|
||||
const components = ["Show", "Edit", "List", "Create"];
|
||||
const changedProps = {
|
||||
actionButtons: "headerButtons",
|
||||
pageHeaderProps: "headerProps",
|
||||
};
|
||||
|
||||
components.forEach((name) => {
|
||||
const element = root.find(j.JSXElement, {
|
||||
openingElement: {
|
||||
name: {
|
||||
name,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Object.keys(changedProps).forEach((prop) => {
|
||||
const jsxAttribute = element.find(j.JSXAttribute, {
|
||||
name: {
|
||||
name: prop,
|
||||
},
|
||||
});
|
||||
|
||||
if (jsxAttribute.length > 0) {
|
||||
jsxAttribute.forEach((path) => {
|
||||
path.node.name.name = changedProps[prop];
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export default function transformer(file: FileInfo, api: API): string {
|
||||
const j = api.jscodeshift;
|
||||
const source = j(file.source);
|
||||
|
||||
updateStyles(j, source);
|
||||
updateActionButtonsPropstoHeaderButtons(j, source);
|
||||
|
||||
return source.toSource();
|
||||
}
|
||||
296
packages/codemod/src/transformations/refine1-to-refine2.ts
Normal file
296
packages/codemod/src/transformations/refine1-to-refine2.ts
Normal file
@@ -0,0 +1,296 @@
|
||||
import type { API, JSCodeshift, Collection, FileInfo } from "jscodeshift";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import { install } from "../helpers";
|
||||
import { checkPackageLock } from "../helpers";
|
||||
|
||||
export const parser = "tsx";
|
||||
|
||||
function addRouterProvider(j: JSCodeshift, root: Collection<any>) {
|
||||
const routerProviderImports = root.find(j.ImportDeclaration, {
|
||||
source: {
|
||||
value: "@pankod/refine-react-router",
|
||||
},
|
||||
});
|
||||
|
||||
if (routerProviderImports.length === 0) {
|
||||
// Import route provider
|
||||
root
|
||||
.find(j.ImportDeclaration, {
|
||||
source: {
|
||||
value: "@pankod/refine",
|
||||
},
|
||||
})
|
||||
.insertAfter(
|
||||
j.importDeclaration(
|
||||
[j.importDefaultSpecifier(j.identifier("routerProvider"))],
|
||||
j.literal("@pankod/refine-react-router"),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
console.log(
|
||||
"WARNING: A router provider from @pankod/refine-react-router is already imported. This tool will not make any migration for router provider.",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const refineRoots = root.find(j.JSXElement, {
|
||||
openingElement: {
|
||||
name: {
|
||||
name: "Refine",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
refineRoots.replaceWith((path) => {
|
||||
const openingElement = path.node.openingElement;
|
||||
|
||||
let routesExpression: any;
|
||||
|
||||
const routesAttributeIndex = openingElement.attributes?.findIndex(
|
||||
(attribute) =>
|
||||
attribute.type === "JSXAttribute" &&
|
||||
attribute.name.type === "JSXIdentifier" &&
|
||||
attribute.name.name === "routes",
|
||||
);
|
||||
|
||||
const routerProviderAttributeIndex = openingElement.attributes?.findIndex(
|
||||
(attribute) =>
|
||||
attribute.type === "JSXAttribute" &&
|
||||
attribute.name.type === "JSXIdentifier" &&
|
||||
attribute.name.name === "routerProvider",
|
||||
);
|
||||
|
||||
if (routerProviderAttributeIndex > -1) {
|
||||
console.log(
|
||||
"WARNING: There is already a `routerProvider` attribute on Refine component. This tool will not make any migration for router provider.",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (routesAttributeIndex > -1) {
|
||||
const routesAttribute = openingElement.attributes?.[routesAttributeIndex];
|
||||
|
||||
if (routesAttribute?.type === "JSXAttribute") {
|
||||
const attributeValue = routesAttribute.value;
|
||||
|
||||
if (attributeValue?.type === "JSXExpressionContainer") {
|
||||
routesExpression = attributeValue.expression;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (routesExpression) {
|
||||
openingElement.attributes?.push(
|
||||
j.jsxAttribute(
|
||||
j.jsxIdentifier("routerProvider"),
|
||||
j.jsxExpressionContainer(
|
||||
j.objectExpression([
|
||||
j.spreadElement(j.identifier("routerProvider")),
|
||||
j.property("init", j.identifier("routes"), routesExpression),
|
||||
]),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if (routesAttributeIndex > -1) {
|
||||
openingElement.attributes?.splice(routesAttributeIndex, 1);
|
||||
}
|
||||
} else {
|
||||
openingElement.attributes?.push(
|
||||
j.jsxAttribute(
|
||||
j.jsxIdentifier("routerProvider"),
|
||||
j.jsxExpressionContainer(j.identifier("routerProvider")),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return path.node;
|
||||
});
|
||||
}
|
||||
|
||||
const moveResources = (j: JSCodeshift, root: Collection<any>) => {
|
||||
const newResources: { [key: string]: any }[] = [];
|
||||
|
||||
const resourceElements = root.find(j.JSXElement, {
|
||||
openingElement: {
|
||||
name: {
|
||||
name: "Resource",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const rootElements = root.find(j.JSXElement, {
|
||||
openingElement: {
|
||||
name: {
|
||||
name: "Refine",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const resourceImportSpecifiers = root.find(j.ImportSpecifier, {
|
||||
imported: {
|
||||
name: "Resource",
|
||||
},
|
||||
});
|
||||
|
||||
if (resourceElements.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get resources data
|
||||
resourceElements.forEach((resources) => {
|
||||
const newResource: { [key: string]: any } = {};
|
||||
|
||||
resources.node.openingElement.attributes?.forEach((resource) => {
|
||||
if (
|
||||
resource.type === "JSXAttribute" &&
|
||||
resource.name.type === "JSXIdentifier" &&
|
||||
resource.value
|
||||
) {
|
||||
newResource[resource.name.name] = resource.value;
|
||||
}
|
||||
});
|
||||
|
||||
newResources.push(newResource);
|
||||
});
|
||||
|
||||
// Construct a resources attribute with the resources data
|
||||
const newAttributes = j.jsxAttribute(
|
||||
j.jsxIdentifier("resources"),
|
||||
j.jsxExpressionContainer(
|
||||
j.arrayExpression(
|
||||
newResources.map((resource) => {
|
||||
const newValue = j.objectExpression(
|
||||
Object.entries(resource).map(([key, value]) => {
|
||||
const valueToPut = value.expression ? value.expression : value;
|
||||
return j.property("init", j.identifier(key), valueToPut as any);
|
||||
}),
|
||||
);
|
||||
|
||||
return newValue;
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Add resources attribute
|
||||
rootElements.replaceWith((path) => {
|
||||
const attributes = path.node.openingElement.attributes;
|
||||
|
||||
const resourcesAttributeIndex = attributes.findIndex(
|
||||
(attribute) =>
|
||||
attribute.type === "JSXAttribute" &&
|
||||
attribute.name.name === "resources",
|
||||
);
|
||||
|
||||
if (resourcesAttributeIndex !== -1) {
|
||||
console.log(
|
||||
"WARNING: There is already a 'resources' attribute on Refine component. This tool will not touch it.",
|
||||
);
|
||||
|
||||
return path.node;
|
||||
}
|
||||
|
||||
attributes?.push(newAttributes);
|
||||
|
||||
return path.node;
|
||||
});
|
||||
|
||||
resourceElements.remove();
|
||||
resourceImportSpecifiers.remove();
|
||||
|
||||
// Clear the body of Refine component
|
||||
rootElements.replaceWith((path) => {
|
||||
const openingElement = path.node.openingElement;
|
||||
|
||||
path.node.closingElement = null;
|
||||
openingElement.selfClosing = true;
|
||||
|
||||
return path.node;
|
||||
});
|
||||
};
|
||||
|
||||
const packagesToUpdate = [
|
||||
"@pankod/refine-airtable",
|
||||
"@pankod/refine-graphql",
|
||||
"@pankod/refine-hasura",
|
||||
"@pankod/refine-nestjsx-crud",
|
||||
"@pankod/refine-nextjs-router",
|
||||
"@pankod/refine-react-router",
|
||||
"@pankod/refine-simple-rest",
|
||||
"@pankod/refine-strapi",
|
||||
"@pankod/refine-strapi-graphql",
|
||||
"@pankod/refine-supabase",
|
||||
];
|
||||
|
||||
export async function postTransform(files: any, flags: any) {
|
||||
const rootDir = path.join(process.cwd(), files[0]);
|
||||
const packageJsonPath = path.join(rootDir, "package.json");
|
||||
const useYarn = checkPackageLock(rootDir) === "yarn.lock";
|
||||
let packageJsonData;
|
||||
|
||||
try {
|
||||
packageJsonData = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
||||
} catch (err) {
|
||||
console.error(
|
||||
`Error: failed to load package.json from ${packageJsonPath}, ensure provided directory is root.`,
|
||||
);
|
||||
}
|
||||
|
||||
const dependenciesToInstall: Array<{
|
||||
name: string;
|
||||
version: string;
|
||||
}> = [
|
||||
{
|
||||
name: "@pankod/refine",
|
||||
version: "2.x.x",
|
||||
},
|
||||
{
|
||||
name: "@pankod/refine-react-router",
|
||||
version: "2.x.x",
|
||||
},
|
||||
];
|
||||
|
||||
for (const key of Object.keys(packageJsonData.dependencies)) {
|
||||
if (packagesToUpdate.includes(key)) {
|
||||
dependenciesToInstall.push({
|
||||
name: key,
|
||||
version: "2.x.x",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (!flags.dry) {
|
||||
await install(
|
||||
rootDir,
|
||||
dependenciesToInstall.map((dep) => `${dep.name}@${dep.version}`),
|
||||
{
|
||||
useYarn,
|
||||
isOnline: true,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default function transformer(file: FileInfo, api: API): string {
|
||||
const j = api.jscodeshift;
|
||||
const source = j(file.source);
|
||||
|
||||
const rootElement = source.find(j.JSXElement, {
|
||||
openingElement: {
|
||||
name: {
|
||||
name: "Refine",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (rootElement.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
addRouterProvider(j, source);
|
||||
moveResources(j, source);
|
||||
|
||||
return source.toSource();
|
||||
}
|
||||
678
packages/codemod/src/transformations/refine2-to-refine3.ts
Normal file
678
packages/codemod/src/transformations/refine2-to-refine3.ts
Normal file
@@ -0,0 +1,678 @@
|
||||
import type {
|
||||
API,
|
||||
JSCodeshift,
|
||||
Collection,
|
||||
FileInfo,
|
||||
ImportSpecifier,
|
||||
JSXExpressionContainer,
|
||||
ObjectExpression,
|
||||
ObjectProperty,
|
||||
Identifier,
|
||||
} from "jscodeshift";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import { install, remove } from "../helpers";
|
||||
import { checkPackageLock } from "../helpers";
|
||||
|
||||
export const parser = "tsx";
|
||||
|
||||
const availableCoreImports = [
|
||||
"Authenticated",
|
||||
"AuthenticatedProps",
|
||||
"CanAccess",
|
||||
"CanAccessProps",
|
||||
"Refine",
|
||||
"RefineProps",
|
||||
"LayoutWrapperProps",
|
||||
"LayoutWrapper",
|
||||
"LayoutProps",
|
||||
"DefaultLayout",
|
||||
"RouteChangeHandler",
|
||||
"UndoableQueue",
|
||||
"defaultAccessControlContext",
|
||||
"AccessControlContext",
|
||||
"AccessControlContextProvider",
|
||||
"CanParams",
|
||||
"CanReturnType",
|
||||
"IAccessControlContext",
|
||||
"TLogoutVariables",
|
||||
"TLogoutData",
|
||||
"IAuthContext",
|
||||
"Pagination",
|
||||
"Search",
|
||||
"CrudOperators",
|
||||
"CrudFilter",
|
||||
"CrudSort",
|
||||
"CrudFilters",
|
||||
"CrudSorting",
|
||||
"CustomResponse",
|
||||
"GetListResponse",
|
||||
"CreateResponse",
|
||||
"CreateManyResponse",
|
||||
"UpdateResponse",
|
||||
"UpdateManyResponse",
|
||||
"GetOneResponse",
|
||||
"GetManyResponse",
|
||||
"DeleteOneResponse",
|
||||
"DeleteManyResponse",
|
||||
"IDataContext",
|
||||
"IDataContextProvider",
|
||||
"defaultDataProvider",
|
||||
"DataProvider",
|
||||
"DataContext",
|
||||
"DataContextProvider",
|
||||
"ILiveContext",
|
||||
"ILiveContextProvider",
|
||||
"LiveContext",
|
||||
"LiveContextProvider",
|
||||
"defaultNotificationProvider",
|
||||
"NotificationContext",
|
||||
"NotificationContextProvider",
|
||||
"RefineContext",
|
||||
"RefineContextProvider",
|
||||
"ResourceContext",
|
||||
"ResourceContextProvider",
|
||||
"IResourceContext",
|
||||
"OptionsProps",
|
||||
"ResourceProps",
|
||||
"IResourceComponentsProps",
|
||||
"IResourceComponents",
|
||||
"IResourceItem",
|
||||
"RouterContext",
|
||||
"RouterContextProvider",
|
||||
"IRouterProvider",
|
||||
"IRouterContext",
|
||||
"PromptProps",
|
||||
"TranslationContext",
|
||||
"TranslationContextProvider",
|
||||
"Translate",
|
||||
"I18nProvider",
|
||||
"ITranslationContext",
|
||||
"UnsavedWarnContext",
|
||||
"UnsavedWarnContextProvider",
|
||||
"IUnsavedWarnContext",
|
||||
"importCSVMapper",
|
||||
"userFriendlyResourceName",
|
||||
"userFriendlySecond",
|
||||
"parseTableParams",
|
||||
"parseTableParamsFromQuery",
|
||||
"stringifyTableParams",
|
||||
"compareFilters",
|
||||
"unionFilters",
|
||||
"setInitialFilters",
|
||||
"file2Base64",
|
||||
"UseCanProps",
|
||||
"useCan",
|
||||
"useCanWithoutCache",
|
||||
"useAuthenticated",
|
||||
"useCheckError",
|
||||
"useGetIdentity",
|
||||
"useIsAuthenticated",
|
||||
"UseLoginReturnType",
|
||||
"useLogin",
|
||||
"useLogout",
|
||||
"usePermissions",
|
||||
"useIsExistAuthentication",
|
||||
"unionFilters",
|
||||
"useApiUrl",
|
||||
"UseCreateReturnType",
|
||||
"useCreate",
|
||||
"UseCreateManyReturnType",
|
||||
"useCreateMany",
|
||||
"UseCustomProps",
|
||||
"useCustom",
|
||||
"useDelete",
|
||||
"useDeleteMany",
|
||||
"UseListProps",
|
||||
"useList",
|
||||
"UseManyProps",
|
||||
"useMany",
|
||||
"UseOneProps",
|
||||
"useOne",
|
||||
"UseUpdateReturnType",
|
||||
"useUpdate",
|
||||
"useUpdateMany",
|
||||
"CSVDownloadProps",
|
||||
"LabelKeyObject",
|
||||
"useExport",
|
||||
"Authenticated",
|
||||
"CanAccess",
|
||||
"LayoutWrapper",
|
||||
"Refine",
|
||||
"RouteChangeHandler",
|
||||
"UndoableQueue",
|
||||
"file2Base64",
|
||||
"importCSVMapper",
|
||||
"parseTableParams",
|
||||
"parseTableParamsFromQuery",
|
||||
"setInitialFilters",
|
||||
"stringifyTableParams",
|
||||
"unionFilters",
|
||||
"useApiUrl",
|
||||
"useAuthenticated",
|
||||
"useCacheQueries",
|
||||
"useCan",
|
||||
"useCanWithoutCache",
|
||||
"useCancelNotification",
|
||||
"useCheckError",
|
||||
"useCreate",
|
||||
"useCreateMany",
|
||||
"useCustom",
|
||||
"useDelete",
|
||||
"useDeleteMany",
|
||||
"useExport",
|
||||
"useGetIdentity",
|
||||
"useGetLocale",
|
||||
"useGetManyQueries",
|
||||
"useGetOneQueries",
|
||||
"useHandleNotification",
|
||||
"useIsAuthenticated",
|
||||
"useIsExistAuthentication",
|
||||
"useList",
|
||||
"useListResourceQueries",
|
||||
"useLiveMode",
|
||||
"useLogin",
|
||||
"useLogout",
|
||||
"useMany",
|
||||
"useMutationMode",
|
||||
"useNavigation",
|
||||
"useNotification",
|
||||
"useOne",
|
||||
"usePermissions",
|
||||
"usePublish",
|
||||
"useRedirectionAfterSubmission",
|
||||
"useRefineContext",
|
||||
"useResource",
|
||||
"useResourceSubscription",
|
||||
"useResourceWithRoute",
|
||||
"useRouterContext",
|
||||
"useSetLocale",
|
||||
"useShow",
|
||||
"useSubscription",
|
||||
"useSyncWithLocation",
|
||||
"useTitle",
|
||||
"useTranslate",
|
||||
"useUpdate",
|
||||
"useUpdateMany",
|
||||
"useWarnAboutChange",
|
||||
"userFriendlyResourceName",
|
||||
"AuthenticatedProps",
|
||||
"CanAccessProps",
|
||||
"RefineProps",
|
||||
"LayoutWrapperProps",
|
||||
"LiveModeProps",
|
||||
"UseResourceSubscriptionProps",
|
||||
"PublishType",
|
||||
"UseSubscriptionProps",
|
||||
"LiveEvent",
|
||||
"HistoryType",
|
||||
"UseRedirectionAfterSubmissionType",
|
||||
"UseWarnAboutChangeType",
|
||||
"UseMutationModeType",
|
||||
"useRefineContext",
|
||||
"UseSyncWithLocationType",
|
||||
"TitleProps",
|
||||
"UseResourceType",
|
||||
"useResourceWithRoute",
|
||||
"useShowReturnType",
|
||||
"useShowProps",
|
||||
"UseGetLocaleType",
|
||||
"Fields",
|
||||
"NestedField",
|
||||
"QueryBuilderOptions",
|
||||
"MetaDataQuery",
|
||||
"VariableOptions",
|
||||
"HttpError",
|
||||
"BaseRecord",
|
||||
"Option",
|
||||
"MapDataFn",
|
||||
"MutationMode",
|
||||
"IUndoableQueue",
|
||||
"RedirectionTypes",
|
||||
"ResourceErrorRouterParams",
|
||||
"ResourceRouterParams",
|
||||
"SuccessErrorNotification",
|
||||
"OpenNotificationParams",
|
||||
"AuthProvider",
|
||||
];
|
||||
|
||||
function updateRefineImports(j: JSCodeshift, root: Collection<any>) {
|
||||
const refineCoreImports = root.find(j.ImportDeclaration, {
|
||||
source: {
|
||||
value: "@pankod/refine-core",
|
||||
},
|
||||
});
|
||||
|
||||
if (refineCoreImports.length === 0) {
|
||||
const coreImports: ImportSpecifier[] = [];
|
||||
const antdImports: ImportSpecifier[] = [];
|
||||
|
||||
const refineImport = root.find(j.ImportDeclaration, {
|
||||
source: {
|
||||
value: "@pankod/refine",
|
||||
},
|
||||
});
|
||||
|
||||
refineImport.replaceWith((path) => {
|
||||
for (const item of path.node.specifiers) {
|
||||
if (availableCoreImports.includes(item.local.name)) {
|
||||
coreImports.push(item as ImportSpecifier);
|
||||
} else {
|
||||
antdImports.push(item as ImportSpecifier);
|
||||
}
|
||||
}
|
||||
|
||||
path.node.specifiers = path.node.specifiers.filter(
|
||||
(p) => !antdImports.includes(p as ImportSpecifier),
|
||||
);
|
||||
|
||||
path.node.source.value = "@pankod/refine-core";
|
||||
|
||||
return path.node;
|
||||
});
|
||||
|
||||
const refineElement = root.find(j.JSXElement, {
|
||||
openingElement: {
|
||||
name: {
|
||||
name: "Refine",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (refineElement.length > 0) {
|
||||
const notificationProviderJSXAttribute = root.find(j.JSXAttribute, {
|
||||
name: {
|
||||
name: "notificationProvider",
|
||||
},
|
||||
});
|
||||
|
||||
if (notificationProviderJSXAttribute.length === 0) {
|
||||
antdImports.push(
|
||||
j.importSpecifier(j.identifier("notificationProvider")),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (antdImports.length > 0) {
|
||||
root
|
||||
.find(j.ImportDeclaration, {
|
||||
source: {
|
||||
value: "@pankod/refine-core",
|
||||
},
|
||||
})
|
||||
.insertAfter(
|
||||
j.importDeclaration(antdImports, j.literal("@pankod/refine-antd")),
|
||||
);
|
||||
}
|
||||
|
||||
if (coreImports.length === 0) {
|
||||
refineImport.remove();
|
||||
}
|
||||
|
||||
const refineCSSImport = root.find(j.ImportDeclaration, {
|
||||
source: {
|
||||
value: "@pankod/refine/dist/styles.min.css",
|
||||
},
|
||||
});
|
||||
|
||||
refineCSSImport.forEach((refineCSSImport) => {
|
||||
refineCSSImport.value.source.value =
|
||||
"@pankod/refine-antd/dist/styles.min.css";
|
||||
});
|
||||
} else {
|
||||
console.log(
|
||||
"WARNING: A refine core package from @pankod/refine-core is already imported. This tool will not make any migration for refine core.",
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const moveConfigProvider = (j: JSCodeshift, root: Collection<any>) => {
|
||||
const refineElement = root.find(j.JSXElement, {
|
||||
openingElement: {
|
||||
name: {
|
||||
name: "Refine",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (refineElement.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const notificationProviderJSXAttribute = root.find(j.JSXAttribute, {
|
||||
name: {
|
||||
name: "notificationProvider",
|
||||
},
|
||||
});
|
||||
|
||||
if (notificationProviderJSXAttribute.length === 0) {
|
||||
refineElement.forEach((path) => {
|
||||
path.node.openingElement.attributes.push(
|
||||
j.jsxAttribute(
|
||||
j.jsxIdentifier("notificationProvider"),
|
||||
j.jsxExpressionContainer(j.identifier("notificationProvider")),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
const configProviderJSXAttribute = root.find(j.JSXAttribute, {
|
||||
name: {
|
||||
name: "configProviderProps",
|
||||
},
|
||||
});
|
||||
|
||||
if (configProviderJSXAttribute.length > 0) {
|
||||
// Import ConfigProvider from @pankod/refine-antd
|
||||
const refineAntdImport = root.find(j.ImportDeclaration, {
|
||||
source: {
|
||||
value: "@pankod/refine-antd",
|
||||
},
|
||||
});
|
||||
|
||||
if (refineAntdImport.length > 0) {
|
||||
refineAntdImport.forEach((path) => {
|
||||
path.node.specifiers.push(
|
||||
j.importSpecifier(j.identifier("ConfigProvider")),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
const configProviderValue = (
|
||||
(configProviderJSXAttribute.nodes()[0].value as JSXExpressionContainer)
|
||||
.expression as ObjectExpression
|
||||
).properties;
|
||||
|
||||
const newConfigProviderElement = j.jsxElement(
|
||||
j.jsxOpeningElement(
|
||||
j.jsxIdentifier("ConfigProvider"),
|
||||
configProviderValue.map((p: ObjectProperty) =>
|
||||
j.jsxAttribute(
|
||||
j.jsxIdentifier((p.key as Identifier).name),
|
||||
j.jsxExpressionContainer(p.value as any),
|
||||
),
|
||||
),
|
||||
),
|
||||
j.jsxClosingElement(j.jsxIdentifier("ConfigProvider")),
|
||||
refineElement.nodes(),
|
||||
);
|
||||
|
||||
refineElement.replaceWith(newConfigProviderElement);
|
||||
|
||||
configProviderJSXAttribute.remove();
|
||||
}
|
||||
};
|
||||
|
||||
const defaultLoginPage = (j: JSCodeshift, root: Collection<any>) => {
|
||||
const refineElement = root.find(j.JSXElement, {
|
||||
openingElement: {
|
||||
name: {
|
||||
name: "Refine",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (refineElement.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const authProviderJSXAttribute = root.find(j.JSXAttribute, {
|
||||
name: {
|
||||
name: "authProvider",
|
||||
},
|
||||
});
|
||||
|
||||
const loginPageJSXAttribute = root.find(j.JSXAttribute, {
|
||||
name: {
|
||||
name: "LoginPage",
|
||||
},
|
||||
});
|
||||
|
||||
if (
|
||||
authProviderJSXAttribute.length > 0 &&
|
||||
loginPageJSXAttribute.length === 0
|
||||
) {
|
||||
refineElement.forEach((path) => {
|
||||
path.node.openingElement.attributes.push(
|
||||
j.jsxAttribute(
|
||||
j.jsxIdentifier("LoginPage"),
|
||||
j.jsxExpressionContainer(j.identifier("LoginPage")),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
const refineAntdImport = root.find(j.ImportDeclaration, {
|
||||
source: {
|
||||
value: "@pankod/refine-antd",
|
||||
},
|
||||
});
|
||||
|
||||
if (refineAntdImport.length > 0) {
|
||||
refineAntdImport.forEach((path) => {
|
||||
path.node.specifiers.push(j.importSpecifier(j.identifier("LoginPage")));
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const defaultLayout = (j: JSCodeshift, root: Collection<any>) => {
|
||||
const refineElement = root.find(j.JSXElement, {
|
||||
openingElement: {
|
||||
name: {
|
||||
name: "Refine",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (refineElement.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const layoutJSXAttribute = root.find(j.JSXAttribute, {
|
||||
name: {
|
||||
name: "Layout",
|
||||
},
|
||||
});
|
||||
|
||||
if (layoutJSXAttribute.length === 0) {
|
||||
refineElement.forEach((path) => {
|
||||
path.node.openingElement.attributes.push(
|
||||
j.jsxAttribute(
|
||||
j.jsxIdentifier("Layout"),
|
||||
j.jsxExpressionContainer(j.identifier("Layout")),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
const refineAntdImport = root.find(j.ImportDeclaration, {
|
||||
source: {
|
||||
value: "@pankod/refine-antd",
|
||||
},
|
||||
});
|
||||
|
||||
if (refineAntdImport.length > 0) {
|
||||
refineAntdImport.forEach((path) => {
|
||||
path.node.specifiers.push(j.importSpecifier(j.identifier("Layout")));
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const defaultCatchAllPage = (j: JSCodeshift, root: Collection<any>) => {
|
||||
const refineElement = root.find(j.JSXElement, {
|
||||
openingElement: {
|
||||
name: {
|
||||
name: "Refine",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (refineElement.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const catchAllJSXAttribute = root.find(j.JSXAttribute, {
|
||||
name: {
|
||||
name: "catchAll",
|
||||
},
|
||||
});
|
||||
|
||||
if (catchAllJSXAttribute.length > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
refineElement.forEach((path) => {
|
||||
path.node.openingElement.attributes.push(
|
||||
j.jsxAttribute(
|
||||
j.jsxIdentifier("catchAll"),
|
||||
j.jsxExpressionContainer(
|
||||
j.jsxElement(
|
||||
j.jsxOpeningElement(j.jsxIdentifier("ErrorComponent"), [], true),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
const refineAntdImport = root.find(j.ImportDeclaration, {
|
||||
source: {
|
||||
value: "@pankod/refine-antd",
|
||||
},
|
||||
});
|
||||
|
||||
if (refineAntdImport.length > 0) {
|
||||
refineAntdImport.forEach((path) => {
|
||||
path.node.specifiers.push(
|
||||
j.importSpecifier(j.identifier("ErrorComponent")),
|
||||
);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const updateSetEditIdToSetId = (j: JSCodeshift, root: Collection<any>) => {
|
||||
const updatedFormHooks = [
|
||||
"useEditableTable",
|
||||
"useModalForm",
|
||||
"useDrawerForm",
|
||||
];
|
||||
|
||||
for (const formHook of updatedFormHooks) {
|
||||
const useEditableTableHook = root.find(j.CallExpression, {
|
||||
callee: {
|
||||
name: formHook,
|
||||
},
|
||||
});
|
||||
|
||||
useEditableTableHook.forEach((path) => {
|
||||
const setEditIdProperty = path.parentPath.node.id.properties.find(
|
||||
(p) => p.value.name === "setEditId",
|
||||
);
|
||||
|
||||
if (setEditIdProperty) {
|
||||
setEditIdProperty.value.name = "setId: setEditId";
|
||||
}
|
||||
|
||||
const editIdProperty = path.parentPath.node.id.properties.find(
|
||||
(p) => p.value.name === "editId",
|
||||
);
|
||||
|
||||
if (editIdProperty) {
|
||||
editIdProperty.value.name = "id: editId";
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const packagesToUpdate = [
|
||||
"@pankod/refine-airtable",
|
||||
"@pankod/refine-graphql",
|
||||
"@pankod/refine-hasura",
|
||||
"@pankod/refine-nestjsx-crud",
|
||||
"@pankod/refine-nextjs-router",
|
||||
"@pankod/refine-react-router",
|
||||
"@pankod/refine-simple-rest",
|
||||
"@pankod/refine-strapi",
|
||||
"@pankod/refine-strapi-graphql",
|
||||
"@pankod/refine-supabase",
|
||||
"@pankod/refine-appwrite",
|
||||
"@pankod/refine-ably",
|
||||
"@pankod/@pankod/refine-strapi-v4",
|
||||
];
|
||||
|
||||
export async function postTransform(files: any, flags: any) {
|
||||
const rootDir = path.join(process.cwd(), files[0]);
|
||||
const packageJsonPath = path.join(rootDir, "package.json");
|
||||
const useYarn = checkPackageLock(rootDir) === "yarn.lock";
|
||||
let packageJsonData;
|
||||
|
||||
try {
|
||||
packageJsonData = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
||||
} catch (err) {
|
||||
console.error(
|
||||
`Error: failed to load package.json from ${packageJsonPath}, ensure provided directory is root.`,
|
||||
);
|
||||
}
|
||||
|
||||
const dependenciesToInstall: Array<{
|
||||
name: string;
|
||||
version: string;
|
||||
}> = [
|
||||
{
|
||||
name: "@pankod/refine-core",
|
||||
version: "3.x.x",
|
||||
},
|
||||
{
|
||||
name: "@pankod/refine-antd",
|
||||
version: "3.x.x",
|
||||
},
|
||||
];
|
||||
|
||||
for (const key of Object.keys(packageJsonData.dependencies)) {
|
||||
if (packagesToUpdate.includes(key)) {
|
||||
dependenciesToInstall.push({
|
||||
name: key,
|
||||
version: "3.x.x",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (!flags.dry) {
|
||||
await install(
|
||||
rootDir,
|
||||
dependenciesToInstall.map((dep) => `${dep.name}@${dep.version}`),
|
||||
{
|
||||
useYarn,
|
||||
isOnline: true,
|
||||
},
|
||||
);
|
||||
|
||||
await remove(rootDir, ["@pankod/refine"], {
|
||||
useYarn,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default function transformer(file: FileInfo, api: API): string {
|
||||
const j = api.jscodeshift;
|
||||
const source = j(file.source);
|
||||
|
||||
const refineImports = source.find(j.ImportDeclaration, {
|
||||
source: {
|
||||
value: "@pankod/refine",
|
||||
},
|
||||
});
|
||||
|
||||
if (refineImports.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
updateRefineImports(j, source);
|
||||
moveConfigProvider(j, source);
|
||||
updateSetEditIdToSetId(j, source);
|
||||
defaultLoginPage(j, source);
|
||||
defaultLayout(j, source);
|
||||
defaultCatchAllPage(j, source);
|
||||
|
||||
return source.toSource();
|
||||
}
|
||||
124
packages/codemod/src/transformations/refine3-to-refine4.ts
Normal file
124
packages/codemod/src/transformations/refine3-to-refine4.ts
Normal file
@@ -0,0 +1,124 @@
|
||||
import path from "path";
|
||||
import type { API, FileInfo } from "jscodeshift";
|
||||
import PackageJson from "@npmcli/package-json";
|
||||
|
||||
import { addV3LegacyAuthProviderCompatibleTrueToAuthHooks } from "./v4/add-v3LegacyAuthProviderCompatible-true-to-auth-hooks";
|
||||
import { authProviderToLegacyAuthProvider } from "./v4/authProvider-to-legacyAuthProvider";
|
||||
import { metaDataToMeta } from "./v4/metadata-to-meta";
|
||||
import { moveDeprecatedAccessControlProps } from "./v4/move-deprecated-access-control";
|
||||
import { routerToLegacyRouter } from "./v4/router-to-legacy-router";
|
||||
import { resourceNameToResourceForButtons } from "./v4/resourceName-to-resource";
|
||||
import { separateImportsAntD } from "./v4/separate-imports-antd";
|
||||
import { separateImportsChakra } from "./v4/separate-imports-chakra";
|
||||
import { separateImportsMantine } from "./v4/separate-imports-mantine";
|
||||
import { separateImportsMUI } from "./v4/separate-imports-mui";
|
||||
import { separateImportsReactHookForm } from "./v4/separate-imports-react-hook-form";
|
||||
import { separateImportsReactQuery } from "./v4/separate-imports-react-query";
|
||||
import { separateImportsReactTable } from "./v4/separate-imports-react-table";
|
||||
import { useMenuToCore } from "./v4/use-menu-to-core";
|
||||
import { separateImportsReactRouterV6 } from "./v4/separate-imports-react-router-v6";
|
||||
import { fixV4Deprecations } from "./v4/fix-v4-deprecations";
|
||||
import { replacePankodImportsWithRefineDev } from "./v4/replace-pankod-imports-with-refinedev";
|
||||
import {
|
||||
CONFIG_FILE_NAME,
|
||||
CodemodConfig,
|
||||
install,
|
||||
checkPackageLock,
|
||||
} from "../helpers";
|
||||
|
||||
export async function postTransform(files: any, flags: any) {
|
||||
const config = new CodemodConfig(CONFIG_FILE_NAME);
|
||||
|
||||
if (flags.dry) {
|
||||
config.destroy();
|
||||
return;
|
||||
}
|
||||
|
||||
const rootDir = path.join(process.cwd(), files[0]);
|
||||
|
||||
const pkgJson = await PackageJson.load(rootDir);
|
||||
|
||||
const hasPankodCLIInDependencies =
|
||||
!!pkgJson.content.dependencies?.["@pankod/refine-cli"];
|
||||
|
||||
const hasPankodCLIInDevDependencies =
|
||||
!!pkgJson.content.devDependencies?.["@pankod/refine-cli"];
|
||||
|
||||
const dependencies = {
|
||||
...pkgJson.content.dependencies,
|
||||
...config.getInstalls(),
|
||||
};
|
||||
|
||||
const devDependencies = {
|
||||
...pkgJson.content.devDependencies,
|
||||
};
|
||||
|
||||
for (const packageName of [...config.getUninstalls(), "@pankod/refine-cli"]) {
|
||||
delete dependencies[packageName];
|
||||
}
|
||||
|
||||
if (hasPankodCLIInDependencies || hasPankodCLIInDevDependencies) {
|
||||
dependencies["@refinedev/cli"] = "latest";
|
||||
}
|
||||
|
||||
if (hasPankodCLIInDevDependencies) {
|
||||
delete devDependencies["@pankod/refine-cli"];
|
||||
}
|
||||
|
||||
Object.keys(dependencies).forEach((dep) => {
|
||||
if (
|
||||
dep.startsWith("@pankod") &&
|
||||
![
|
||||
"@pankod/refine-react-location",
|
||||
"@pankod/refine-react-router",
|
||||
].includes(dep)
|
||||
) {
|
||||
delete dependencies[dep];
|
||||
|
||||
const isMUI = dep.includes("@pankod/refine-mui");
|
||||
const migratableMUIVersion = "^4.18.2";
|
||||
|
||||
dependencies[dep.replace("@pankod/refine-", "@refinedev/")] = isMUI
|
||||
? migratableMUIVersion
|
||||
: "latest";
|
||||
}
|
||||
});
|
||||
|
||||
pkgJson.update({
|
||||
dependencies,
|
||||
devDependencies,
|
||||
});
|
||||
|
||||
await pkgJson.save();
|
||||
|
||||
const useYarn = checkPackageLock(rootDir) === "yarn.lock";
|
||||
|
||||
await install(rootDir, null, { useYarn, isOnline: true });
|
||||
|
||||
config.destroy();
|
||||
}
|
||||
|
||||
export default function transformer(file: FileInfo, api: API): string {
|
||||
const j = api.jscodeshift;
|
||||
const source = j(file.source);
|
||||
|
||||
fixV4Deprecations(j, source);
|
||||
separateImportsReactRouterV6(j, source);
|
||||
addV3LegacyAuthProviderCompatibleTrueToAuthHooks(j, source);
|
||||
authProviderToLegacyAuthProvider(j, source);
|
||||
metaDataToMeta(j, source);
|
||||
moveDeprecatedAccessControlProps(j, source);
|
||||
resourceNameToResourceForButtons(j, source);
|
||||
routerToLegacyRouter(j, source);
|
||||
separateImportsAntD(j, source);
|
||||
separateImportsChakra(j, source);
|
||||
separateImportsMantine(j, source);
|
||||
separateImportsMUI(j, source);
|
||||
separateImportsReactHookForm(j, source);
|
||||
separateImportsReactQuery(j, source);
|
||||
separateImportsReactTable(j, source);
|
||||
useMenuToCore(j, source);
|
||||
replacePankodImportsWithRefineDev(j, source);
|
||||
|
||||
return source.toSource();
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import type { API, FileInfo } from "jscodeshift";
|
||||
import { renameUseFormQueryResultAndMutationResult } from "./rename-query-and-mutation-result/use-form-query-and-mutation-result";
|
||||
import { renameUseSelectQueryResult } from "./rename-query-and-mutation-result/use-select-query-result";
|
||||
import { renameUseShowQueryResult } from "./rename-query-and-mutation-result/use-show-query-result";
|
||||
import { renameUseSimpleListQueryResult } from "./rename-query-and-mutation-result/use-simple-list-query-result";
|
||||
import { renameUseTableQueryResult } from "./rename-query-and-mutation-result/use-table-query-result";
|
||||
|
||||
export const parser = "tsx";
|
||||
|
||||
export default function transformer(file: FileInfo, api: API) {
|
||||
const j = api.jscodeshift;
|
||||
const source = j(file.source);
|
||||
|
||||
renameUseFormQueryResultAndMutationResult(j, source);
|
||||
renameUseSelectQueryResult(j, source);
|
||||
renameUseShowQueryResult(j, source);
|
||||
renameUseSimpleListQueryResult(j, source);
|
||||
renameUseTableQueryResult(j, source);
|
||||
|
||||
return source.toSource();
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
import type { Collection, JSCodeshift } from "jscodeshift";
|
||||
|
||||
// ```diff
|
||||
// - const { queryResult, mutationResult } = useForm();
|
||||
// + const { query, mutation} = useSelect();
|
||||
// ```
|
||||
export const renameUseFormQueryResultAndMutationResult = (
|
||||
j: JSCodeshift,
|
||||
source: Collection,
|
||||
) => {
|
||||
const renameProperties = (prop) => {
|
||||
// just a type guard
|
||||
if ("shorthand" in prop && "key" in prop && "name" in prop.key) {
|
||||
const renameMap = {
|
||||
queryResult: "query",
|
||||
mutationResult: "mutation",
|
||||
};
|
||||
const newName = renameMap[prop.key.name];
|
||||
if (newName) {
|
||||
prop.key.name = newName;
|
||||
|
||||
if (prop.shorthand) {
|
||||
prop.shorthand = false;
|
||||
prop.value = j.identifier(
|
||||
prop.key.name === "query" ? "queryResult" : "mutationResult",
|
||||
);
|
||||
} else {
|
||||
if (prop.key.name === prop?.value?.name) {
|
||||
prop.shorthand = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
source
|
||||
.find(j.VariableDeclarator, {
|
||||
id: { type: "ObjectPattern" },
|
||||
init: { callee: { name: "useForm" } },
|
||||
})
|
||||
.forEach((path) => {
|
||||
if ("properties" in path.node.id) {
|
||||
path.node.id.properties.forEach((prop) => {
|
||||
// just a type guard
|
||||
if ("shorthand" in prop && "key" in prop && "name" in prop.key) {
|
||||
switch (prop.key.name) {
|
||||
case "refineCore":
|
||||
if ("properties" in prop.value) {
|
||||
prop.value.properties.forEach(renameProperties);
|
||||
}
|
||||
return;
|
||||
|
||||
default:
|
||||
renameProperties(prop);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,57 @@
|
||||
import type { Collection, JSCodeshift } from "jscodeshift";
|
||||
|
||||
// ```diff
|
||||
// - const { queryResult, defaultValueQueryResult } = useSelect();
|
||||
// + const { query, defaultValueQuery } = useSelect();
|
||||
// ```
|
||||
export const renameUseSelectQueryResult = (
|
||||
j: JSCodeshift,
|
||||
source: Collection,
|
||||
) => {
|
||||
const renameProperties = (prop) => {
|
||||
// just a type guard
|
||||
if ("shorthand" in prop && "key" in prop && "name" in prop.key) {
|
||||
const renameMap = {
|
||||
queryResult: "query",
|
||||
defaultValueQueryResult: "defaultValueQuery",
|
||||
};
|
||||
const newName = renameMap[prop.key.name];
|
||||
if (newName) {
|
||||
prop.key.name = newName;
|
||||
|
||||
if (prop.shorthand) {
|
||||
prop.shorthand = false;
|
||||
prop.value = j.identifier(
|
||||
prop.key.name === "query"
|
||||
? "queryResult"
|
||||
: "defaultValueQueryResult",
|
||||
);
|
||||
} else {
|
||||
if (prop.key.name === prop?.value?.name) {
|
||||
prop.shorthand = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
["useSelect", "useAutocomplete", "useCheckboxGroup", "useRadioGroup"].forEach(
|
||||
(hookName) => {
|
||||
source
|
||||
.find(j.VariableDeclarator, {
|
||||
id: { type: "ObjectPattern" },
|
||||
init: { callee: { name: hookName } },
|
||||
})
|
||||
.forEach((path) => {
|
||||
if ("properties" in path.node.id) {
|
||||
path.node.id.properties.forEach((prop) => {
|
||||
// just a type guard
|
||||
if ("shorthand" in prop && "key" in prop && "name" in prop.key) {
|
||||
renameProperties(prop);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,44 @@
|
||||
import type { Collection, JSCodeshift } from "jscodeshift";
|
||||
|
||||
// ```diff
|
||||
// - const { queryResult } = useShow();
|
||||
// + const { query } = useShow();
|
||||
// ```
|
||||
export const renameUseShowQueryResult = (
|
||||
j: JSCodeshift,
|
||||
source: Collection,
|
||||
) => {
|
||||
const renameProperties = (prop) => {
|
||||
// just a type guard
|
||||
if ("shorthand" in prop && "key" in prop && "name" in prop.key) {
|
||||
if (prop.key.name === "queryResult") {
|
||||
prop.key.name = "query";
|
||||
|
||||
if (prop.shorthand) {
|
||||
prop.shorthand = false;
|
||||
prop.value = j.identifier("queryResult");
|
||||
} else {
|
||||
if (prop.key.name === prop?.value?.name) {
|
||||
prop.shorthand = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
source
|
||||
.find(j.VariableDeclarator, {
|
||||
id: { type: "ObjectPattern" },
|
||||
init: { callee: { name: "useShow" } },
|
||||
})
|
||||
.forEach((path) => {
|
||||
if ("properties" in path.node.id) {
|
||||
path.node.id.properties.forEach((prop) => {
|
||||
// just a type guard
|
||||
if ("shorthand" in prop && "key" in prop && "name" in prop.key) {
|
||||
renameProperties(prop);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,52 @@
|
||||
import type { Collection, JSCodeshift } from "jscodeshift";
|
||||
// ```diff
|
||||
// - const { queryResult } = useSimpleList();
|
||||
// + const { query } = useSimpleList();
|
||||
// ```
|
||||
export const renameUseSimpleListQueryResult = (
|
||||
j: JSCodeshift,
|
||||
source: Collection,
|
||||
) => {
|
||||
const renameProperties = (prop) => {
|
||||
// just a type guard
|
||||
if ("shorthand" in prop && "key" in prop && "name" in prop.key) {
|
||||
if (prop.key.name === "queryResult") {
|
||||
prop.key.name = "query";
|
||||
|
||||
if (prop.shorthand) {
|
||||
prop.shorthand = false;
|
||||
prop.value = j.identifier("queryResult");
|
||||
} else {
|
||||
if (prop.key.name === prop?.value?.name) {
|
||||
prop.shorthand = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
source
|
||||
.find(j.VariableDeclarator, {
|
||||
id: { type: "ObjectPattern" },
|
||||
init: { callee: { name: "useSimpleList" } },
|
||||
})
|
||||
.forEach((path) => {
|
||||
if ("properties" in path.node.id) {
|
||||
path.node.id.properties.forEach((prop) => {
|
||||
// just a type guard
|
||||
if ("shorthand" in prop && "key" in prop && "name" in prop.key) {
|
||||
switch (prop.key.name) {
|
||||
case "refineCore":
|
||||
if ("properties" in prop.value) {
|
||||
prop.value.properties.forEach(renameProperties);
|
||||
}
|
||||
return;
|
||||
|
||||
default:
|
||||
renameProperties(prop);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,55 @@
|
||||
import type { Collection, JSCodeshift } from "jscodeshift";
|
||||
|
||||
// ```diff
|
||||
// - const { tableQueryResult } = useTable();
|
||||
// + const { tableQuery } = useTable();
|
||||
// ```
|
||||
export const renameUseTableQueryResult = (
|
||||
j: JSCodeshift,
|
||||
source: Collection,
|
||||
) => {
|
||||
const renameProperties = (prop) => {
|
||||
// just a type guard
|
||||
if ("shorthand" in prop && "key" in prop && "name" in prop.key) {
|
||||
if (prop.key.name === "tableQueryResult") {
|
||||
prop.key.name = "tableQuery";
|
||||
|
||||
if (prop.shorthand) {
|
||||
prop.shorthand = false;
|
||||
prop.value = j.identifier("tableQueryResult");
|
||||
} else {
|
||||
if (prop.key.name === prop?.value?.name) {
|
||||
prop.shorthand = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
["useTable", "useDataGrid"].forEach((hookName) => {
|
||||
source
|
||||
.find(j.VariableDeclarator, {
|
||||
id: { type: "ObjectPattern" },
|
||||
init: { callee: { name: hookName } },
|
||||
})
|
||||
.forEach((path) => {
|
||||
if ("properties" in path.node.id) {
|
||||
path.node.id.properties.forEach((prop) => {
|
||||
// just a type guard
|
||||
if ("shorthand" in prop && "key" in prop && "name" in prop.key) {
|
||||
switch (prop.key.name) {
|
||||
case "refineCore":
|
||||
if ("properties" in prop.value) {
|
||||
prop.value.properties.forEach(renameProperties);
|
||||
}
|
||||
return;
|
||||
|
||||
default:
|
||||
renameProperties(prop);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
104
packages/codemod/src/transformations/use-data-grid-columns.ts
Normal file
104
packages/codemod/src/transformations/use-data-grid-columns.ts
Normal file
@@ -0,0 +1,104 @@
|
||||
import type {
|
||||
API,
|
||||
JSCodeshift,
|
||||
Collection,
|
||||
FileInfo,
|
||||
ObjectExpression,
|
||||
Identifier,
|
||||
Property,
|
||||
JSXAttribute,
|
||||
} from "jscodeshift";
|
||||
|
||||
export const parser = "tsx";
|
||||
|
||||
const removeColumnsOnUseDataGrid = (j: JSCodeshift, root: Collection<any>) => {
|
||||
const useDataGridHook = root.find(j.CallExpression, {
|
||||
callee: {
|
||||
name: "useDataGrid",
|
||||
},
|
||||
});
|
||||
|
||||
useDataGridHook.replaceWith((p) => {
|
||||
if (p.node.arguments.length === 0) {
|
||||
return p.node;
|
||||
}
|
||||
|
||||
const propertiesWithoutColumns = (
|
||||
p.node.arguments[0] as unknown as ObjectExpression
|
||||
).properties.filter(
|
||||
(p: Property) => (p.key as Identifier).name !== "columns",
|
||||
);
|
||||
|
||||
if (propertiesWithoutColumns.length === 0) {
|
||||
p.node.arguments = [];
|
||||
|
||||
return p.node;
|
||||
}
|
||||
|
||||
(p.node.arguments[0] as unknown as ObjectExpression).properties =
|
||||
propertiesWithoutColumns;
|
||||
|
||||
return p.node;
|
||||
});
|
||||
};
|
||||
|
||||
const addColumnsToUseDataGrid = (j: JSCodeshift, root: Collection<any>) => {
|
||||
const dataGridElement = root.find(j.JSXElement, {
|
||||
openingElement: {
|
||||
name: {
|
||||
name: "DataGrid",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (dataGridElement.length === 0) {
|
||||
console.warn(
|
||||
"If you use `useDataGrid` hook, you need to use `DataGrid` element.",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
dataGridElement.forEach((path) => {
|
||||
const hasColumnsAttribute = path.node.openingElement.attributes.find(
|
||||
(attribute) => (attribute as JSXAttribute).name?.name === "columns",
|
||||
);
|
||||
|
||||
if (hasColumnsAttribute) {
|
||||
return;
|
||||
}
|
||||
|
||||
path.node.openingElement.attributes.push(
|
||||
j.jsxAttribute(
|
||||
j.jsxIdentifier("columns"),
|
||||
j.jsxExpressionContainer(j.identifier("columns")),
|
||||
),
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
export default function transformer(file: FileInfo, api: API): string {
|
||||
const j = api.jscodeshift;
|
||||
const source = j(file.source);
|
||||
|
||||
const refineMuiUseDataGridImports = source.find(j.ImportDeclaration, {
|
||||
source: {
|
||||
value: "@pankod/refine-mui",
|
||||
},
|
||||
specifiers: [
|
||||
{
|
||||
imported: {
|
||||
name: "useDataGrid",
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
if (refineMuiUseDataGridImports.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
removeColumnsOnUseDataGrid(j, source);
|
||||
addColumnsToUseDataGrid(j, source);
|
||||
|
||||
return source.toSource();
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
import type { Collection, JSCodeshift } from "jscodeshift";
|
||||
|
||||
const authHookNames = [
|
||||
"useForgotPassword",
|
||||
"useGetIdentity",
|
||||
"useIsAuthenticated",
|
||||
"useAuthenticated",
|
||||
"useLogin",
|
||||
"useLogout",
|
||||
"useOnError",
|
||||
"useCheckError",
|
||||
"usePermission",
|
||||
"useRegister",
|
||||
"useUpdatePassword",
|
||||
"usePermissions",
|
||||
];
|
||||
|
||||
export const addV3LegacyAuthProviderCompatibleTrueToAuthHooks = (
|
||||
j: JSCodeshift,
|
||||
root: Collection<any>,
|
||||
) => {
|
||||
const authHooks = root.find(j.CallExpression, {
|
||||
callee: {
|
||||
name: (name: string) => authHookNames.includes(name),
|
||||
},
|
||||
});
|
||||
|
||||
authHooks.forEach((authHook) => {
|
||||
const args = authHook.value.arguments;
|
||||
|
||||
if (args.length === 0) {
|
||||
args.push(
|
||||
j.objectExpression([
|
||||
j.objectProperty(
|
||||
j.identifier("v3LegacyAuthProviderCompatible"),
|
||||
j.booleanLiteral(true),
|
||||
),
|
||||
]),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length === 1) {
|
||||
const arg = args[0];
|
||||
if (arg.type === "ObjectExpression") {
|
||||
const legacyProp = arg.properties.find(
|
||||
(property) =>
|
||||
property["key"]?.name === "v3LegacyAuthProviderCompatible",
|
||||
);
|
||||
|
||||
if (legacyProp) {
|
||||
return;
|
||||
}
|
||||
|
||||
arg.properties.push(
|
||||
j.objectProperty(
|
||||
j.identifier("v3LegacyAuthProviderCompatible"),
|
||||
j.booleanLiteral(true),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (arg.type === "Identifier") {
|
||||
// turn to spread syntax and add v3LegacyAuthProviderCompatible
|
||||
const newArg = j.objectExpression([
|
||||
j.spreadElement(arg),
|
||||
j.objectProperty(
|
||||
j.identifier("v3LegacyAuthProviderCompatible"),
|
||||
j.booleanLiteral(true),
|
||||
),
|
||||
]);
|
||||
|
||||
args[0] = newArg;
|
||||
}
|
||||
return;
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,41 @@
|
||||
import type { Collection, JSCodeshift } from "jscodeshift";
|
||||
|
||||
const REFINE_CORE_PATH = "@pankod/refine-core";
|
||||
|
||||
export const authProviderToLegacyAuthProvider = (
|
||||
j: JSCodeshift,
|
||||
root: Collection<any>,
|
||||
) => {
|
||||
const refineCorePath = root
|
||||
.find(j.ImportDeclaration)
|
||||
.filter((path) => path.node.source.value === REFINE_CORE_PATH)
|
||||
.find(j.ImportSpecifier);
|
||||
|
||||
const authProviderImport = refineCorePath.filter(
|
||||
(path) => path.node.imported.name === "AuthProvider",
|
||||
);
|
||||
|
||||
// change AuthProvider to LegacyAuthProvider as AuthProvider
|
||||
authProviderImport.forEach((authProvider) => {
|
||||
j(authProvider).replaceWith(
|
||||
j.importSpecifier(j.identifier("LegacyAuthProvider as AuthProvider")),
|
||||
);
|
||||
});
|
||||
|
||||
// find <Refine>
|
||||
root.findJSXElements("Refine").forEach((path) => {
|
||||
const attributes = path.node.openingElement.attributes;
|
||||
|
||||
// find <Refine authProvider={}>
|
||||
const authProviderAttribute = attributes.find(
|
||||
(attribute) =>
|
||||
attribute.type === "JSXAttribute" &&
|
||||
attribute.name.name === "authProvider",
|
||||
);
|
||||
|
||||
if (!authProviderAttribute) return;
|
||||
|
||||
// change authProvider={} to legacyAuthProvider={}
|
||||
authProviderAttribute["name"]["name"] = "legacyAuthProvider";
|
||||
});
|
||||
};
|
||||
927
packages/codemod/src/transformations/v4/fix-v4-deprecations.ts
Normal file
927
packages/codemod/src/transformations/v4/fix-v4-deprecations.ts
Normal file
@@ -0,0 +1,927 @@
|
||||
import type {
|
||||
JSCodeshift,
|
||||
Collection,
|
||||
ObjectExpression,
|
||||
Property,
|
||||
Identifier,
|
||||
ObjectProperty,
|
||||
BooleanLiteral,
|
||||
JSXAttribute,
|
||||
JSXExpressionContainer,
|
||||
ArrayExpression,
|
||||
} from "jscodeshift";
|
||||
|
||||
export const parser = "tsx";
|
||||
|
||||
const configToSpreadConfig = (j: JSCodeshift, source: Collection) => {
|
||||
const useListHooks = source.find(j.CallExpression, {
|
||||
callee: {
|
||||
name: "useList",
|
||||
},
|
||||
});
|
||||
|
||||
useListHooks.replaceWith((p) => {
|
||||
const configProperty = (
|
||||
p.node.arguments[0] as unknown as ObjectExpression
|
||||
).properties.find((p: Property) => (p.key as Identifier).name === "config");
|
||||
|
||||
if (!configProperty) {
|
||||
return p.node;
|
||||
}
|
||||
|
||||
const propertiesWithoutConfig = (
|
||||
p.node.arguments[0] as unknown as ObjectExpression
|
||||
).properties.filter(
|
||||
(p: Property) => (p.key as Identifier).name !== "config",
|
||||
);
|
||||
|
||||
const configProperties = (
|
||||
(configProperty as ObjectProperty).value as ObjectExpression
|
||||
).properties;
|
||||
|
||||
p.node.arguments = [
|
||||
j.objectExpression([...propertiesWithoutConfig, ...configProperties]),
|
||||
];
|
||||
|
||||
return p.node;
|
||||
});
|
||||
};
|
||||
|
||||
const sortToSorters = (j: JSCodeshift, source: Collection) => {
|
||||
const willCheckHooks = [
|
||||
"useCheckboxGroup",
|
||||
"useRadioGroup",
|
||||
"useSelect",
|
||||
"useAutocomplete",
|
||||
"useList",
|
||||
];
|
||||
|
||||
willCheckHooks.forEach((hookName) => {
|
||||
const useListHooks = source.find(j.CallExpression, {
|
||||
callee: {
|
||||
name: hookName,
|
||||
},
|
||||
});
|
||||
|
||||
useListHooks.replaceWith((p) => {
|
||||
if (p.node.arguments.length === 0) {
|
||||
return p.node;
|
||||
}
|
||||
|
||||
const sortProperty = (
|
||||
p.node.arguments[0] as unknown as ObjectExpression
|
||||
).properties.find((p: Property) => (p.key as Identifier).name === "sort");
|
||||
|
||||
if (!sortProperty) {
|
||||
return p.node;
|
||||
}
|
||||
|
||||
const propertiesWithoutSort = (
|
||||
p.node.arguments[0] as unknown as ObjectExpression
|
||||
).properties.filter(
|
||||
(p: Property) => (p.key as Identifier).name !== "sort",
|
||||
);
|
||||
|
||||
p.node.arguments = [
|
||||
j.objectExpression([
|
||||
...propertiesWithoutSort,
|
||||
j.objectProperty(
|
||||
j.identifier("sorters"),
|
||||
(sortProperty as any).value,
|
||||
),
|
||||
]),
|
||||
];
|
||||
|
||||
return p.node;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const sorterToSorters = (j: JSCodeshift, source: Collection) => {
|
||||
const willCheckHooks = ["useExport"];
|
||||
|
||||
willCheckHooks.forEach((hookName) => {
|
||||
const useListHooks = source.find(j.CallExpression, {
|
||||
callee: {
|
||||
name: hookName,
|
||||
},
|
||||
});
|
||||
|
||||
useListHooks.replaceWith((p) => {
|
||||
if (p.node.arguments.length === 0) {
|
||||
return p.node;
|
||||
}
|
||||
|
||||
const sortProperty = (
|
||||
p.node.arguments[0] as unknown as ObjectExpression
|
||||
).properties.find(
|
||||
(p: Property) => (p.key as Identifier).name === "sorter",
|
||||
);
|
||||
|
||||
if (!sortProperty) {
|
||||
return p.node;
|
||||
}
|
||||
|
||||
const propertiesWithoutSort = (
|
||||
p.node.arguments[0] as unknown as ObjectExpression
|
||||
).properties.filter(
|
||||
(p: Property) => (p.key as Identifier).name !== "sorter",
|
||||
);
|
||||
|
||||
p.node.arguments = [
|
||||
j.objectExpression([
|
||||
...propertiesWithoutSort,
|
||||
j.objectProperty(
|
||||
j.identifier("sorters"),
|
||||
(sortProperty as any).value,
|
||||
),
|
||||
]),
|
||||
];
|
||||
|
||||
return p.node;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const resourceNametoResource = (j: JSCodeshift, source: Collection) => {
|
||||
const willCheckHooks = ["useExport", "useImport"];
|
||||
|
||||
willCheckHooks.forEach((hookName) => {
|
||||
const useListHooks = source.find(j.CallExpression, {
|
||||
callee: {
|
||||
name: hookName,
|
||||
},
|
||||
});
|
||||
|
||||
useListHooks.replaceWith((p) => {
|
||||
if (p.node.arguments.length === 0) {
|
||||
return p.node;
|
||||
}
|
||||
|
||||
const resourceNameProperty = (
|
||||
p.node.arguments[0] as unknown as ObjectExpression
|
||||
).properties.find(
|
||||
(p: Property) => (p.key as Identifier).name === "resourceName",
|
||||
);
|
||||
|
||||
if (!resourceNameProperty) {
|
||||
return p.node;
|
||||
}
|
||||
|
||||
const propertiesWithoutResourceName = (
|
||||
p.node.arguments[0] as unknown as ObjectExpression
|
||||
).properties.filter(
|
||||
(p: Property) => (p.key as Identifier).name !== "resourceName",
|
||||
);
|
||||
|
||||
p.node.arguments = [
|
||||
j.objectExpression([
|
||||
...propertiesWithoutResourceName,
|
||||
j.objectProperty(
|
||||
j.identifier("resource"),
|
||||
(resourceNameProperty as any).value,
|
||||
),
|
||||
]),
|
||||
];
|
||||
|
||||
return p.node;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const deprecatedUseTablePaginationProps = [
|
||||
"initialCurrent",
|
||||
"initialPageSize",
|
||||
"hasPagination",
|
||||
];
|
||||
|
||||
const deprecatedUseTableFiltersProps = [
|
||||
"initialFilter",
|
||||
"permanentFilter",
|
||||
"defaultSetFilterBehavior",
|
||||
];
|
||||
|
||||
const deprecatedUseTableSortersProps = ["initialSorter", "permanentSorter"];
|
||||
|
||||
const fixDeprecatedReactTableProps = (j: JSCodeshift, source: Collection) => {
|
||||
const refineReactTableImports = source.find(j.ImportDeclaration, {
|
||||
source: {
|
||||
value: "@pankod/refine-react-table",
|
||||
},
|
||||
specifiers: [
|
||||
{
|
||||
imported: {
|
||||
name: "useTable",
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
if (refineReactTableImports.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const useTableHooks = source.find(j.CallExpression, {
|
||||
callee: {
|
||||
name: "useTable",
|
||||
},
|
||||
});
|
||||
|
||||
useTableHooks.replaceWith((p) => {
|
||||
if (p.node.arguments.length === 0) {
|
||||
return p.node;
|
||||
}
|
||||
|
||||
const hasRefineCoreProps = (
|
||||
p.node.arguments[0] as ObjectExpression
|
||||
).properties.find(
|
||||
(p: Property) => (p.key as Identifier).name === "refineCoreProps",
|
||||
);
|
||||
|
||||
if (!hasRefineCoreProps) {
|
||||
return p.node;
|
||||
}
|
||||
|
||||
const otherProperties = (
|
||||
p.node.arguments[0] as ObjectExpression
|
||||
).properties.filter(
|
||||
(p: Property) => (p.key as Identifier).name !== "refineCoreProps",
|
||||
);
|
||||
|
||||
const paginationProperties = deprecatedUseTablePaginationProps.map(
|
||||
(prop) => {
|
||||
const property = (
|
||||
(hasRefineCoreProps as ObjectProperty).value as ObjectExpression
|
||||
).properties.find((p: Property) => (p.key as Identifier).name === prop);
|
||||
|
||||
if (!property) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (prop === "hasPagination") {
|
||||
return j.property(
|
||||
"init",
|
||||
j.identifier("mode"),
|
||||
j.literal(
|
||||
((property as ObjectProperty).value as BooleanLiteral).value
|
||||
? "server"
|
||||
: "off",
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (prop === "initialCurrent") {
|
||||
return j.property(
|
||||
"init",
|
||||
j.identifier("current"),
|
||||
(property as ObjectProperty).value,
|
||||
);
|
||||
}
|
||||
|
||||
if (prop === "initialPageSize") {
|
||||
return j.property(
|
||||
"init",
|
||||
j.identifier("pageSize"),
|
||||
(property as ObjectProperty).value,
|
||||
);
|
||||
}
|
||||
|
||||
return;
|
||||
},
|
||||
);
|
||||
|
||||
const paginationProperty = j.property(
|
||||
"init",
|
||||
j.identifier("pagination"),
|
||||
j.objectExpression(paginationProperties.filter(Boolean)),
|
||||
);
|
||||
|
||||
const filtersProperties = deprecatedUseTableFiltersProps.map((prop) => {
|
||||
const property = (
|
||||
(hasRefineCoreProps as ObjectProperty).value as ObjectExpression
|
||||
).properties.find((p: Property) => (p.key as Identifier).name === prop);
|
||||
|
||||
if (!property) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (prop === "initialFilter") {
|
||||
return j.property(
|
||||
"init",
|
||||
j.identifier("initial"),
|
||||
(property as ObjectProperty).value,
|
||||
);
|
||||
}
|
||||
|
||||
if (prop === "permanentFilter") {
|
||||
return j.property(
|
||||
"init",
|
||||
j.identifier("permanent"),
|
||||
(property as ObjectProperty).value,
|
||||
);
|
||||
}
|
||||
|
||||
if (prop === "defaultSetFilterBehavior") {
|
||||
return j.property(
|
||||
"init",
|
||||
j.identifier("defaultBehavior"),
|
||||
(property as ObjectProperty).value,
|
||||
);
|
||||
}
|
||||
|
||||
return;
|
||||
});
|
||||
|
||||
const filtersProperty = j.property(
|
||||
"init",
|
||||
j.identifier("filters"),
|
||||
j.objectExpression(filtersProperties.filter(Boolean)),
|
||||
);
|
||||
|
||||
const sortersProperties = deprecatedUseTableSortersProps.map((prop) => {
|
||||
const property = (
|
||||
(hasRefineCoreProps as ObjectProperty).value as ObjectExpression
|
||||
).properties.find((p: Property) => (p.key as Identifier).name === prop);
|
||||
|
||||
if (!property) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (prop === "initialSorter") {
|
||||
return j.property(
|
||||
"init",
|
||||
j.identifier("initial"),
|
||||
(property as ObjectProperty).value,
|
||||
);
|
||||
}
|
||||
|
||||
if (prop === "permanentSorter") {
|
||||
return j.property(
|
||||
"init",
|
||||
j.identifier("permanent"),
|
||||
(property as ObjectProperty).value,
|
||||
);
|
||||
}
|
||||
|
||||
return;
|
||||
});
|
||||
|
||||
const sortersProperty = j.property(
|
||||
"init",
|
||||
j.identifier("sorters"),
|
||||
j.objectExpression(sortersProperties.filter(Boolean)),
|
||||
);
|
||||
|
||||
const otherRefineCoreProps = (
|
||||
(hasRefineCoreProps as ObjectProperty).value as ObjectExpression
|
||||
).properties.filter(
|
||||
(p: Property) =>
|
||||
![
|
||||
...deprecatedUseTablePaginationProps,
|
||||
...deprecatedUseTableSortersProps,
|
||||
...deprecatedUseTableFiltersProps,
|
||||
].includes((p.key as Identifier).name),
|
||||
);
|
||||
|
||||
const refineCorePropsProperty = j.property(
|
||||
"init",
|
||||
j.identifier("refineCoreProps"),
|
||||
j.objectExpression(
|
||||
[
|
||||
...otherRefineCoreProps,
|
||||
(paginationProperty.value as ObjectExpression).properties.length > 0
|
||||
? paginationProperty
|
||||
: null,
|
||||
(filtersProperty.value as ObjectExpression).properties.length > 0
|
||||
? filtersProperty
|
||||
: null,
|
||||
(sortersProperty.value as ObjectExpression).properties.length > 0
|
||||
? sortersProperty
|
||||
: null,
|
||||
].filter(Boolean),
|
||||
),
|
||||
);
|
||||
|
||||
p.node.arguments = [
|
||||
j.objectExpression([...otherProperties, refineCorePropsProperty]),
|
||||
];
|
||||
|
||||
return p.node;
|
||||
});
|
||||
};
|
||||
|
||||
const fixDeprecatedUseTableProps = (j: JSCodeshift, source: Collection) => {
|
||||
const willCheckImports = ["useTable", "useDataGrid"];
|
||||
|
||||
willCheckImports.forEach((hook) => {
|
||||
const useTableHooks = source.find(j.CallExpression, {
|
||||
callee: {
|
||||
name: hook,
|
||||
},
|
||||
});
|
||||
|
||||
useTableHooks.replaceWith((p) => {
|
||||
if (p.node.arguments.length === 0) {
|
||||
return p.node;
|
||||
}
|
||||
|
||||
const otherProperties = (
|
||||
p.node.arguments[0] as ObjectExpression
|
||||
).properties.filter(
|
||||
(p: Property) =>
|
||||
![
|
||||
...deprecatedUseTablePaginationProps,
|
||||
...deprecatedUseTableSortersProps,
|
||||
...deprecatedUseTableFiltersProps,
|
||||
].includes((p.key as Identifier).name),
|
||||
);
|
||||
|
||||
const paginationProperties = deprecatedUseTablePaginationProps.map(
|
||||
(prop) => {
|
||||
const property = (
|
||||
p.node.arguments[0] as ObjectExpression
|
||||
).properties.find(
|
||||
(p: Property) => (p.key as Identifier).name === prop,
|
||||
);
|
||||
|
||||
if (!property) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (prop === "hasPagination") {
|
||||
return j.property(
|
||||
"init",
|
||||
j.identifier("mode"),
|
||||
j.literal(
|
||||
((property as ObjectProperty).value as BooleanLiteral).value
|
||||
? "server"
|
||||
: "off",
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (prop === "initialCurrent") {
|
||||
return j.property(
|
||||
"init",
|
||||
j.identifier("current"),
|
||||
(property as ObjectProperty).value,
|
||||
);
|
||||
}
|
||||
|
||||
if (prop === "initialPageSize") {
|
||||
return j.property(
|
||||
"init",
|
||||
j.identifier("pageSize"),
|
||||
(property as ObjectProperty).value,
|
||||
);
|
||||
}
|
||||
|
||||
return;
|
||||
},
|
||||
);
|
||||
|
||||
const paginationProperty = j.property(
|
||||
"init",
|
||||
j.identifier("pagination"),
|
||||
j.objectExpression(paginationProperties.filter(Boolean)),
|
||||
);
|
||||
|
||||
const filtersProperties = deprecatedUseTableFiltersProps.map((prop) => {
|
||||
const property = (
|
||||
p.node.arguments[0] as ObjectExpression
|
||||
).properties.find((p: Property) => (p.key as Identifier).name === prop);
|
||||
|
||||
if (!property) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (prop === "initialFilter") {
|
||||
return j.property(
|
||||
"init",
|
||||
j.identifier("initial"),
|
||||
(property as ObjectProperty).value,
|
||||
);
|
||||
}
|
||||
|
||||
if (prop === "permanentFilter") {
|
||||
return j.property(
|
||||
"init",
|
||||
j.identifier("permanent"),
|
||||
(property as ObjectProperty).value,
|
||||
);
|
||||
}
|
||||
|
||||
if (prop === "defaultSetFilterBehavior") {
|
||||
return j.property(
|
||||
"init",
|
||||
j.identifier("defaultBehavior"),
|
||||
(property as ObjectProperty).value,
|
||||
);
|
||||
}
|
||||
|
||||
return;
|
||||
});
|
||||
|
||||
const filtersProperty = j.property(
|
||||
"init",
|
||||
j.identifier("filters"),
|
||||
j.objectExpression(filtersProperties.filter(Boolean)),
|
||||
);
|
||||
|
||||
const sortersProperties = deprecatedUseTableSortersProps.map((prop) => {
|
||||
const property = (
|
||||
p.node.arguments[0] as ObjectExpression
|
||||
).properties.find((p: Property) => (p.key as Identifier).name === prop);
|
||||
|
||||
if (!property) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (prop === "initialSorter") {
|
||||
return j.property(
|
||||
"init",
|
||||
j.identifier("initial"),
|
||||
(property as ObjectProperty).value,
|
||||
);
|
||||
}
|
||||
|
||||
if (prop === "permanentSorter") {
|
||||
return j.property(
|
||||
"init",
|
||||
j.identifier("permanent"),
|
||||
(property as ObjectProperty).value,
|
||||
);
|
||||
}
|
||||
|
||||
return;
|
||||
});
|
||||
|
||||
const sortersProperty = j.property(
|
||||
"init",
|
||||
j.identifier("sorters"),
|
||||
j.objectExpression(sortersProperties.filter(Boolean)),
|
||||
);
|
||||
|
||||
p.node.arguments = [
|
||||
j.objectExpression(
|
||||
[
|
||||
...otherProperties,
|
||||
(paginationProperty.value as ObjectExpression).properties.length > 0
|
||||
? paginationProperty
|
||||
: null,
|
||||
(filtersProperty.value as ObjectExpression).properties.length > 0
|
||||
? filtersProperty
|
||||
: null,
|
||||
(sortersProperty.value as ObjectExpression).properties.length > 0
|
||||
? sortersProperty
|
||||
: null,
|
||||
].filter(Boolean),
|
||||
),
|
||||
];
|
||||
|
||||
return p.node;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const fixUseListHasPaginationToPaginationMode = (
|
||||
j: JSCodeshift,
|
||||
source: Collection,
|
||||
) => {
|
||||
const useListHooks = source.find(j.CallExpression, {
|
||||
callee: {
|
||||
name: "useList",
|
||||
},
|
||||
});
|
||||
|
||||
useListHooks.replaceWith((p) => {
|
||||
if (p.node.arguments.length === 0) {
|
||||
return p.node;
|
||||
}
|
||||
|
||||
const hasPaginationProperty = (
|
||||
p.node.arguments[0] as ObjectExpression
|
||||
).properties.find(
|
||||
(p: Property) => (p.key as Identifier).name === "hasPagination",
|
||||
);
|
||||
|
||||
if (!hasPaginationProperty) {
|
||||
return p.node;
|
||||
}
|
||||
|
||||
const paginationProperty = (
|
||||
p.node.arguments[0] as ObjectExpression
|
||||
).properties.find(
|
||||
(p: Property) => (p.key as Identifier).name === "pagination",
|
||||
);
|
||||
|
||||
if (paginationProperty) {
|
||||
(paginationProperty as any).value.properties.push(
|
||||
j.property(
|
||||
"init",
|
||||
j.identifier("mode"),
|
||||
j.literal(
|
||||
((hasPaginationProperty as ObjectProperty).value as BooleanLiteral)
|
||||
.value
|
||||
? "server"
|
||||
: "off",
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
(p.node.arguments[0] as ObjectExpression).properties.push(
|
||||
j.property(
|
||||
"init",
|
||||
j.identifier("pagination"),
|
||||
j.objectExpression([
|
||||
j.property(
|
||||
"init",
|
||||
j.identifier("mode"),
|
||||
j.literal(
|
||||
(
|
||||
(hasPaginationProperty as ObjectProperty)
|
||||
.value as BooleanLiteral
|
||||
).value
|
||||
? "server"
|
||||
: "off",
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
(p.node.arguments[0] as ObjectExpression).properties = (
|
||||
p.node.arguments[0] as ObjectExpression
|
||||
).properties.filter(
|
||||
(p: Property) => (p.key as Identifier).name !== "hasPagination",
|
||||
);
|
||||
|
||||
return p.node;
|
||||
});
|
||||
};
|
||||
|
||||
const fixUseSelectHasPaginationToPaginationMode = (
|
||||
j: JSCodeshift,
|
||||
source: Collection,
|
||||
) => {
|
||||
const useSelectHooks = source.find(j.CallExpression, {
|
||||
callee: {
|
||||
name: "useSelect",
|
||||
},
|
||||
});
|
||||
|
||||
useSelectHooks.replaceWith((p) => {
|
||||
const hasPaginationProperty = (
|
||||
p.node.arguments[0] as ObjectExpression
|
||||
).properties.find(
|
||||
(p: Property) => (p.key as Identifier).name === "hasPagination",
|
||||
);
|
||||
|
||||
const paginationProperty = (
|
||||
p.node.arguments[0] as ObjectExpression
|
||||
).properties.find(
|
||||
(p: Property) => (p.key as Identifier).name === "pagination",
|
||||
);
|
||||
|
||||
const hasMode = (
|
||||
paginationProperty as unknown as any
|
||||
)?.value?.properties?.find((p) => p["name"] === "mode");
|
||||
|
||||
if (hasPaginationProperty && !hasMode) {
|
||||
if (paginationProperty) {
|
||||
(paginationProperty as any).value.properties.push(
|
||||
j.property(
|
||||
"init",
|
||||
j.identifier("mode"),
|
||||
j.literal(
|
||||
(
|
||||
(hasPaginationProperty as ObjectProperty)
|
||||
.value as BooleanLiteral
|
||||
).value
|
||||
? "server"
|
||||
: "off",
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
(p.node.arguments[0] as ObjectExpression).properties.push(
|
||||
j.property(
|
||||
"init",
|
||||
j.identifier("pagination"),
|
||||
j.objectExpression([
|
||||
j.property(
|
||||
"init",
|
||||
j.identifier("mode"),
|
||||
j.literal(
|
||||
(
|
||||
(hasPaginationProperty as ObjectProperty)
|
||||
.value as BooleanLiteral
|
||||
).value
|
||||
? "server"
|
||||
: "off",
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasPaginationProperty && !hasMode) {
|
||||
if (paginationProperty) {
|
||||
(paginationProperty as any).value.properties.push(
|
||||
j.property("init", j.identifier("mode"), j.stringLiteral("server")),
|
||||
);
|
||||
} else {
|
||||
(p.node.arguments[0] as ObjectExpression).properties.push(
|
||||
j.property(
|
||||
"init",
|
||||
j.identifier("pagination"),
|
||||
j.objectExpression([
|
||||
j.property(
|
||||
"init",
|
||||
j.identifier("mode"),
|
||||
j.stringLiteral("server"),
|
||||
),
|
||||
]),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
(p.node.arguments[0] as ObjectExpression).properties = (
|
||||
p.node.arguments[0] as ObjectExpression
|
||||
).properties.filter(
|
||||
(p: Property) => (p.key as Identifier).name !== "hasPagination",
|
||||
);
|
||||
|
||||
return p.node;
|
||||
});
|
||||
};
|
||||
|
||||
const useCustomConfigSortToSorters = (j: JSCodeshift, source: Collection) => {
|
||||
const useCustomHooks = source.find(j.CallExpression, {
|
||||
callee: {
|
||||
name: "useCustom",
|
||||
},
|
||||
});
|
||||
|
||||
useCustomHooks.replaceWith((p) => {
|
||||
if (p.node.arguments.length === 0) {
|
||||
return p.node;
|
||||
}
|
||||
|
||||
const configProperty = (
|
||||
p.node.arguments[0] as ObjectExpression
|
||||
).properties.find((p: Property) => (p.key as Identifier).name === "config");
|
||||
|
||||
if (!configProperty) {
|
||||
return p.node;
|
||||
}
|
||||
|
||||
const sortProperty = (
|
||||
(configProperty as ObjectProperty).value as any
|
||||
).properties.find((p: Property) => (p.key as Identifier).name === "sort");
|
||||
|
||||
if (!sortProperty) {
|
||||
return p.node;
|
||||
}
|
||||
|
||||
((configProperty as ObjectProperty).value as any).properties.push(
|
||||
j.property(
|
||||
"init",
|
||||
j.identifier("sorters"),
|
||||
(sortProperty as ObjectProperty).value,
|
||||
),
|
||||
);
|
||||
|
||||
((configProperty as ObjectProperty).value as any).properties = (
|
||||
(configProperty as ObjectProperty).value as any
|
||||
).properties.filter((p: Property) => (p.key as Identifier).name !== "sort");
|
||||
|
||||
return p.node;
|
||||
});
|
||||
};
|
||||
|
||||
const setSortertoSetSorters = (j: JSCodeshift, source: Collection) => {
|
||||
const willCheckHooks = ["useTable", "useDataGrid"];
|
||||
|
||||
willCheckHooks.forEach((hook) => {
|
||||
const updatedHooks = source.find(j.CallExpression, {
|
||||
callee: {
|
||||
name: hook,
|
||||
},
|
||||
});
|
||||
|
||||
if (updatedHooks.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
updatedHooks.forEach((path) => {
|
||||
const setSorterProperty = path.parentPath.node.id.properties.find(
|
||||
(p) => p.value.name === "setSorter",
|
||||
);
|
||||
|
||||
if (setSorterProperty) {
|
||||
setSorterProperty.value.name = "setSorters: setSorter";
|
||||
}
|
||||
|
||||
const sorterPropery = path.parentPath.node.id.properties.find(
|
||||
(p) => p.value.name === "sorter",
|
||||
);
|
||||
|
||||
if (sorterPropery) {
|
||||
sorterPropery.value.name = "sorters: sorter";
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const addCommentToUseSimpleList = (j: JSCodeshift, source: Collection) => {
|
||||
const useSimpleListHooks = source.find(j.CallExpression, {
|
||||
callee: {
|
||||
name: "useSimpleList",
|
||||
},
|
||||
});
|
||||
|
||||
useSimpleListHooks.forEach((path) => {
|
||||
const comment = j.commentLine(
|
||||
"`useSimpleList` does not accept all of Ant Design's `List` component props anymore. You can directly use `List` component instead.",
|
||||
false,
|
||||
true,
|
||||
);
|
||||
|
||||
path.parentPath.insertBefore(comment);
|
||||
});
|
||||
};
|
||||
|
||||
const resourceOptionstoMeta = (j: JSCodeshift, source: Collection) => {
|
||||
const refineElement = source.find(j.JSXElement, {
|
||||
openingElement: {
|
||||
name: {
|
||||
name: "Refine",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (refineElement.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
refineElement.forEach((path) => {
|
||||
const resources = path.node.openingElement.attributes.find(
|
||||
(p) => (p as JSXAttribute).name?.name === "resources",
|
||||
);
|
||||
|
||||
if (!resources) {
|
||||
return;
|
||||
}
|
||||
|
||||
const options = (
|
||||
((resources as JSXAttribute).value as JSXExpressionContainer)
|
||||
.expression as ArrayExpression
|
||||
).elements.filter((p) => {
|
||||
const properties = (p as ObjectExpression).properties;
|
||||
|
||||
return (
|
||||
properties.find(
|
||||
(p) => ((p as ObjectProperty).key as Identifier).name === "options",
|
||||
) !== undefined
|
||||
);
|
||||
});
|
||||
|
||||
if (options.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
options.forEach((p) => {
|
||||
const properties = (p as ObjectExpression).properties;
|
||||
|
||||
const optionsProperty = properties.find(
|
||||
(p) => ((p as ObjectProperty).key as Identifier).name === "options",
|
||||
);
|
||||
|
||||
if (!optionsProperty) {
|
||||
return;
|
||||
}
|
||||
|
||||
(optionsProperty as ObjectProperty).key = j.identifier("meta");
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const fixV4Deprecations = async (j: JSCodeshift, source: Collection) => {
|
||||
configToSpreadConfig(j, source);
|
||||
sortToSorters(j, source);
|
||||
sorterToSorters(j, source);
|
||||
resourceNametoResource(j, source);
|
||||
fixDeprecatedReactTableProps(j, source);
|
||||
fixDeprecatedUseTableProps(j, source);
|
||||
fixUseListHasPaginationToPaginationMode(j, source);
|
||||
fixUseSelectHasPaginationToPaginationMode(j, source);
|
||||
useCustomConfigSortToSorters(j, source);
|
||||
setSortertoSetSorters(j, source);
|
||||
addCommentToUseSimpleList(j, source);
|
||||
resourceOptionstoMeta(j, source);
|
||||
};
|
||||
53
packages/codemod/src/transformations/v4/metadata-to-meta.ts
Normal file
53
packages/codemod/src/transformations/v4/metadata-to-meta.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import type { JSCodeshift, Collection } from "jscodeshift";
|
||||
|
||||
export const metaDataToMeta = (j: JSCodeshift, source: Collection) => {
|
||||
// find all JSX elements
|
||||
source.find(j.JSXElement).forEach((path) => {
|
||||
const attributes = path.node.openingElement.attributes;
|
||||
if (!attributes) return;
|
||||
|
||||
// if they have a meta attribute, skip them.
|
||||
const hasMeta = attributes.some(
|
||||
(attribute) => attribute?.["name"]?.["name"] === "meta",
|
||||
);
|
||||
if (hasMeta) return;
|
||||
|
||||
// if they have a metaData change it to meta.
|
||||
path.node.openingElement.attributes.forEach((attribute) => {
|
||||
if (attribute?.["name"]?.["name"] === "metaData") {
|
||||
attribute["name"]["name"] = "meta";
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// find all call expressions
|
||||
source.find(j.CallExpression).forEach((path) => {
|
||||
// find all arguments
|
||||
path.node.arguments.forEach((argument) => {
|
||||
const properties = argument["properties"];
|
||||
if (!properties) return;
|
||||
|
||||
// if they have a meta argument, skip them.
|
||||
const hasMeta = properties.some(
|
||||
(property) => property?.["key"]?.["name"] === "meta",
|
||||
);
|
||||
if (hasMeta) return;
|
||||
|
||||
// if they have a metaData change it to meta.
|
||||
properties.forEach((property) => {
|
||||
if (
|
||||
property?.["shorthand"] &&
|
||||
property?.["key"]?.["name"] === "metaData"
|
||||
) {
|
||||
property["key"]["name"] = "meta";
|
||||
property["value"]["name"] === "metaData";
|
||||
property["shorthand"] = false;
|
||||
} else {
|
||||
if (property?.["key"]?.["name"] === "metaData") {
|
||||
property["key"]["name"] = "meta";
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
import type { JSCodeshift, Collection } from "jscodeshift";
|
||||
|
||||
const deprecatedPropName = "ignoreAccessControlProvider";
|
||||
const newName = "accessControl";
|
||||
const newProperty = "enabled";
|
||||
|
||||
export const moveDeprecatedAccessControlProps = (
|
||||
j: JSCodeshift,
|
||||
source: Collection,
|
||||
) => {
|
||||
source.find(j.JSXElement).forEach((path) => {
|
||||
const attributes = path.node.openingElement.attributes;
|
||||
if (!attributes) return;
|
||||
|
||||
const hasAccessControl = attributes.some(
|
||||
(attribute) => attribute?.["name"]?.["name"] === "accessControl",
|
||||
);
|
||||
|
||||
if (hasAccessControl) return;
|
||||
|
||||
const oldProp = path.node.openingElement.attributes.find((attribute) => {
|
||||
return attribute?.["name"]?.["name"] === deprecatedPropName;
|
||||
});
|
||||
|
||||
if (oldProp) {
|
||||
const oldValue = oldProp?.["value"]?.["expression"]?.["value"];
|
||||
const newValue = !oldValue;
|
||||
|
||||
oldProp["name"]["name"] = newName;
|
||||
|
||||
oldProp["value"]["expression"] = j.objectExpression([
|
||||
j.objectProperty(j.identifier(newProperty), j.booleanLiteral(newValue)),
|
||||
]);
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,100 @@
|
||||
import type { Collection, JSCodeshift } from "jscodeshift";
|
||||
import { CONFIG_FILE_NAME, CodemodConfig } from "../../helpers";
|
||||
|
||||
export const parser = "tsx";
|
||||
|
||||
const previousScope = "@pankod/refine-";
|
||||
const newScope = "@refinedev/";
|
||||
|
||||
const deprecatedPackages = [
|
||||
"@pankod/refine-react-location",
|
||||
"@pankod/refine-react-router",
|
||||
];
|
||||
|
||||
const getOldPackageName = (oldName: string) => {
|
||||
return `${previousScope}${oldName.replace(previousScope, "").split("/")[0]}`;
|
||||
};
|
||||
|
||||
const getNewPackageName = (oldName: string) => {
|
||||
return `${newScope}${oldName.replace(previousScope, "").split("/")[0]}`;
|
||||
};
|
||||
|
||||
const getNewImportValue = (oldValue: string) => {
|
||||
return oldValue.replace(previousScope, newScope);
|
||||
};
|
||||
|
||||
const renameImports = (j: JSCodeshift, source: Collection) => {
|
||||
const config = new CodemodConfig(CONFIG_FILE_NAME);
|
||||
|
||||
source
|
||||
.find(j.ImportDeclaration)
|
||||
.filter(
|
||||
(path) =>
|
||||
path.node.source.value?.toString()?.startsWith(previousScope) &&
|
||||
!deprecatedPackages.includes(path.node.source.value?.toString() ?? ""),
|
||||
)
|
||||
.forEach((path) => {
|
||||
// for example import line is: @pankod/refine-antd/dist/style.css
|
||||
const oldImportValue = path.node.source.value?.toString() ?? "";
|
||||
|
||||
// getOldPackageName will return @pankod/refine-antd
|
||||
const oldName = getOldPackageName(oldImportValue);
|
||||
|
||||
// getNewPackageName will return @refinedev/antd
|
||||
const newName = getNewPackageName(oldName);
|
||||
|
||||
// getNewImportValue will return @refinedev/antd/dist/style.css
|
||||
const newImportValue = getNewImportValue(oldImportValue);
|
||||
|
||||
config.addPackage(newName);
|
||||
config.removePackage(oldName);
|
||||
|
||||
j(path).replaceWith(
|
||||
j.importDeclaration(path.node.specifiers, j.literal(newImportValue)),
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
const renameExports = (j: JSCodeshift, source: Collection) => {
|
||||
const config = new CodemodConfig(CONFIG_FILE_NAME);
|
||||
|
||||
source
|
||||
.find(j.ExportNamedDeclaration)
|
||||
.filter(
|
||||
(path) =>
|
||||
path.node.source?.value?.toString()?.startsWith(previousScope) &&
|
||||
!deprecatedPackages.includes(path.node.source.value?.toString() ?? ""),
|
||||
)
|
||||
.forEach((path) => {
|
||||
// for example import line is: @pankod/refine-antd/dist/style.css
|
||||
const oldImportValue = path.node.source.value?.toString() ?? "";
|
||||
|
||||
// getOldPackageName will return @pankod/refine-antd
|
||||
const oldName = getOldPackageName(oldImportValue);
|
||||
|
||||
// getNewPackageName will return @refinedev/antd
|
||||
const newName = getNewPackageName(oldName);
|
||||
|
||||
// getNewImportValue will return @refinedev/antd/dist/style.css
|
||||
const newImportValue = getNewImportValue(oldImportValue);
|
||||
|
||||
config.addPackage(newName);
|
||||
config.removePackage(oldName);
|
||||
|
||||
j(path).replaceWith(
|
||||
j.exportNamedDeclaration(
|
||||
path.node.declaration,
|
||||
path.node.specifiers,
|
||||
j.literal(newImportValue),
|
||||
),
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
export const replacePankodImportsWithRefineDev = async (
|
||||
j: JSCodeshift,
|
||||
source: Collection,
|
||||
) => {
|
||||
renameImports(j, source);
|
||||
renameExports(j, source);
|
||||
};
|
||||
@@ -0,0 +1,48 @@
|
||||
import type { Collection, JSCodeshift } from "jscodeshift";
|
||||
|
||||
const COMPONENT_NAMES = [
|
||||
"ShowButton",
|
||||
"EditButton",
|
||||
"DeleteButton",
|
||||
"CloneButton",
|
||||
"ListButton",
|
||||
"RefreshButton",
|
||||
"CreateButton",
|
||||
];
|
||||
|
||||
const DEPRECATED_PROP_NAMES = ["resourceName", "resourceNameOrRouteName"];
|
||||
const NEW_PROP_NAME = "resource";
|
||||
|
||||
export const resourceNameToResourceForButtons = (
|
||||
j: JSCodeshift,
|
||||
source: Collection,
|
||||
) => {
|
||||
// find all JSX elements that are named in COMPONENT_NAMES
|
||||
const elements = source.find(j.JSXElement, {
|
||||
openingElement: {
|
||||
name: {
|
||||
name: (name: string) => COMPONENT_NAMES.includes(name),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
elements.forEach((path) => {
|
||||
const attributes = path.node.openingElement.attributes;
|
||||
if (!attributes) return;
|
||||
|
||||
// if they have a NEW_PROP_NAME attribute, skip them.
|
||||
const hasNewAttribute = attributes.some(
|
||||
(attribute) => attribute?.["name"]?.["name"] === NEW_PROP_NAME,
|
||||
);
|
||||
|
||||
if (hasNewAttribute) return;
|
||||
|
||||
// if they have a metaData change it to meta.
|
||||
path.node.openingElement.attributes.forEach((attribute) => {
|
||||
if (DEPRECATED_PROP_NAMES.includes(attribute?.["name"]?.["name"])) {
|
||||
attribute["name"]["name"] = NEW_PROP_NAME;
|
||||
return;
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,85 @@
|
||||
import type { JSCodeshift, Collection, JSXAttribute } from "jscodeshift";
|
||||
|
||||
const legacyMap = {
|
||||
"@pankod/refine-react-router-v6": "@pankod/refine-react-router-v6/legacy",
|
||||
"@pankod/refine-nextjs-router": "@pankod/refine-nextjs-router/legacy",
|
||||
"@pankod/refine-nextjs-router/app": "@pankod/refine-nextjs-router/legacy-app",
|
||||
"@pankod/refine-nextjs-router/pages":
|
||||
"@pankod/refine-nextjs-router/legacy-pages",
|
||||
"@pankod/refine-remix-router": "@pankod/refine-remix-router/legacy",
|
||||
};
|
||||
|
||||
const oldRouterProp = "routerProvider";
|
||||
const newRouterProp = "legacyRouterProvider";
|
||||
|
||||
const renameImport = (
|
||||
j: JSCodeshift,
|
||||
source: Collection,
|
||||
from: string,
|
||||
to: string,
|
||||
) => {
|
||||
source
|
||||
.find(j.ImportDeclaration)
|
||||
.filter((path) => path.node.source.value === from)
|
||||
.forEach((path) => {
|
||||
j(path).replaceWith(
|
||||
j.importDeclaration(path.node.specifiers, j.literal(to)),
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
const renameExport = (
|
||||
j: JSCodeshift,
|
||||
source: Collection,
|
||||
from: string,
|
||||
to: string,
|
||||
) => {
|
||||
source
|
||||
.find(j.ExportNamedDeclaration)
|
||||
.filter((path) => path.node.source && path.node.source.value === from)
|
||||
.forEach((path) => {
|
||||
j(path).replaceWith(
|
||||
j.exportNamedDeclaration(
|
||||
path.node.declaration,
|
||||
path.node.specifiers,
|
||||
j.literal(to),
|
||||
),
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
const renameProp = (
|
||||
j: JSCodeshift,
|
||||
source: Collection,
|
||||
from: string,
|
||||
to: string,
|
||||
) => {
|
||||
source
|
||||
.find(j.JSXOpeningElement, { name: { name: "Refine" } })
|
||||
.forEach((path) => {
|
||||
const props = path.node.attributes;
|
||||
|
||||
const propIndex = props.findIndex(
|
||||
(prop) => (prop as JSXAttribute)?.name?.name === from,
|
||||
);
|
||||
|
||||
if (propIndex !== -1) {
|
||||
const prop = props[propIndex];
|
||||
|
||||
if ((prop as JSXAttribute)?.name) {
|
||||
if ("name" in prop) {
|
||||
prop.name.name = to;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const routerToLegacyRouter = (j: JSCodeshift, source: Collection) => {
|
||||
Object.entries(legacyMap).forEach(([from, to]) => {
|
||||
renameImport(j, source, from, to);
|
||||
renameExport(j, source, from, to);
|
||||
});
|
||||
|
||||
renameProp(j, source, oldRouterProp, newRouterProp);
|
||||
};
|
||||
118
packages/codemod/src/transformations/v4/separate-imports-antd.ts
Normal file
118
packages/codemod/src/transformations/v4/separate-imports-antd.ts
Normal file
@@ -0,0 +1,118 @@
|
||||
import type { Collection, JSCodeshift } from "jscodeshift";
|
||||
import { CONFIG_FILE_NAME, CodemodConfig } from "../../helpers";
|
||||
import { separateImports } from "../../helpers";
|
||||
import {
|
||||
exported,
|
||||
rename,
|
||||
renameToDefault,
|
||||
other,
|
||||
} from "../../definitions/separated-imports/antd";
|
||||
|
||||
const REFINE_ANTD_PATH = "@pankod/refine-antd";
|
||||
const ANTD_PATH = "antd";
|
||||
const ANTD_VERSION = "^5.0.5";
|
||||
const ANTD_ICONS_PATH = "@ant-design/icons";
|
||||
const ANTD_ICONS_VERSION = "^5.0.1";
|
||||
|
||||
export const separateImportsAntD = (j: JSCodeshift, source: Collection) => {
|
||||
const config = new CodemodConfig(CONFIG_FILE_NAME);
|
||||
|
||||
separateImports({
|
||||
j,
|
||||
source,
|
||||
imports: exported,
|
||||
renameImports: rename,
|
||||
renameToDefault: renameToDefault,
|
||||
otherImports: other,
|
||||
currentLibName: REFINE_ANTD_PATH,
|
||||
nextLibName: ANTD_PATH,
|
||||
});
|
||||
|
||||
let addIcons = false;
|
||||
|
||||
const addAntd =
|
||||
source.find(j.ImportDeclaration, {
|
||||
source: {
|
||||
value: ANTD_PATH,
|
||||
},
|
||||
}).length > 0;
|
||||
|
||||
// check Icons import
|
||||
const refineImport = source.find(j.ImportDeclaration, {
|
||||
source: {
|
||||
value: REFINE_ANTD_PATH,
|
||||
},
|
||||
});
|
||||
|
||||
refineImport.replaceWith((p) => {
|
||||
for (const item of p.node.specifiers) {
|
||||
if (item.local.name === "Icons") {
|
||||
// flag for adding `@antd-design/icons` dependency
|
||||
addIcons = true;
|
||||
|
||||
// add new icon namespace import
|
||||
source
|
||||
.find(j.ImportDeclaration, {
|
||||
source: {
|
||||
value: REFINE_ANTD_PATH,
|
||||
},
|
||||
})
|
||||
.forEach((path, i) => {
|
||||
if (i === 0) {
|
||||
path.insertAfter(
|
||||
j.importDeclaration(
|
||||
[j.importNamespaceSpecifier(j.identifier("Icons"))],
|
||||
j.literal(ANTD_ICONS_PATH),
|
||||
),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
p.node.specifiers = p.node.specifiers.filter(
|
||||
(p) => p.local.name !== "Icons",
|
||||
);
|
||||
|
||||
return p.node;
|
||||
});
|
||||
|
||||
if (addIcons) {
|
||||
config.addPackage(ANTD_ICONS_PATH, ANTD_ICONS_VERSION);
|
||||
|
||||
// add comment to antd-icons import
|
||||
source
|
||||
|
||||
.find(j.ImportDeclaration, {
|
||||
source: {
|
||||
value: ANTD_ICONS_PATH,
|
||||
},
|
||||
})
|
||||
.forEach((path) => {
|
||||
path.node.comments = [
|
||||
{
|
||||
type: "CommentLine",
|
||||
value:
|
||||
" It is recommended to use explicit import as seen below to reduce bundle size.",
|
||||
},
|
||||
{
|
||||
type: "CommentLine",
|
||||
value: ` import { IconName } from "@ant-design/icons";`,
|
||||
},
|
||||
];
|
||||
});
|
||||
}
|
||||
if (addAntd) {
|
||||
config.addPackage(ANTD_PATH, ANTD_VERSION);
|
||||
}
|
||||
|
||||
// remove empty imports
|
||||
source
|
||||
.find(j.ImportDeclaration, {
|
||||
source: {
|
||||
value: REFINE_ANTD_PATH,
|
||||
},
|
||||
})
|
||||
.filter((path) => path.node.specifiers.length === 0)
|
||||
.remove();
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
import type { Collection, JSCodeshift } from "jscodeshift";
|
||||
import {
|
||||
CONFIG_FILE_NAME,
|
||||
CodemodConfig,
|
||||
separateImports,
|
||||
} from "../../helpers";
|
||||
import { exported, rename } from "../../definitions/separated-imports/chakra";
|
||||
|
||||
export const separateImportsChakra = (j: JSCodeshift, source: Collection) => {
|
||||
const config = new CodemodConfig(CONFIG_FILE_NAME);
|
||||
|
||||
if (
|
||||
source.find(j.ImportDeclaration, {
|
||||
source: { value: "@pankod/refine-chakra-ui" },
|
||||
}).length > 0
|
||||
) {
|
||||
config.addPackage("@chakra-ui/react", "^2.5.1");
|
||||
}
|
||||
|
||||
separateImports({
|
||||
j,
|
||||
source,
|
||||
imports: exported,
|
||||
renameImports: rename,
|
||||
otherImports: {},
|
||||
currentLibName: "@pankod/refine-chakra-ui",
|
||||
nextLibName: "@chakra-ui/react",
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
import type { Collection, JSCodeshift } from "jscodeshift";
|
||||
import {
|
||||
CONFIG_FILE_NAME,
|
||||
CodemodConfig,
|
||||
separateImports,
|
||||
} from "../../helpers";
|
||||
import {
|
||||
exported,
|
||||
rename,
|
||||
other,
|
||||
} from "../../definitions/separated-imports/mantine";
|
||||
|
||||
export const separateImportsMantine = (j: JSCodeshift, source: Collection) => {
|
||||
const config = new CodemodConfig(CONFIG_FILE_NAME);
|
||||
|
||||
if (
|
||||
source.find(j.ImportDeclaration, {
|
||||
source: { value: "@pankod/refine-mantine" },
|
||||
}).length > 0
|
||||
) {
|
||||
config.addPackage("@mantine/core", "^5.10.4");
|
||||
config.addPackage("@mantine/hooks", "^5.10.4");
|
||||
config.addPackage("@mantine/form", "^5.10.4");
|
||||
config.addPackage("@mantine/notifications", "^5.10.4");
|
||||
config.addPackage("@emotion/react", "^11.8.2");
|
||||
}
|
||||
|
||||
separateImports({
|
||||
j,
|
||||
source,
|
||||
imports: exported,
|
||||
renameImports: rename,
|
||||
otherImports: other,
|
||||
currentLibName: "@pankod/refine-mantine",
|
||||
nextLibName: "@mantine/core",
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
import type { Collection, JSCodeshift } from "jscodeshift";
|
||||
import { exported } from "../../definitions/separated-imports/mui";
|
||||
import {
|
||||
CONFIG_FILE_NAME,
|
||||
CodemodConfig,
|
||||
separateImports,
|
||||
} from "../../helpers";
|
||||
|
||||
export const separateImportsMUI = (j: JSCodeshift, source: Collection) => {
|
||||
const config = new CodemodConfig(CONFIG_FILE_NAME);
|
||||
|
||||
if (
|
||||
source.find(j.ImportDeclaration, {
|
||||
source: { value: "@pankod/refine-mui" },
|
||||
}).length > 0
|
||||
) {
|
||||
config.addPackage("@emotion/react", "^11.8.2");
|
||||
config.addPackage("@emotion/styled", "^11.8.1");
|
||||
config.addPackage("@mui/lab", "^5.0.0-alpha.85");
|
||||
config.addPackage("@mui/material", "^5.8.6");
|
||||
config.addPackage("@mui/x-data-grid", "^5.12.1");
|
||||
}
|
||||
|
||||
separateImports({
|
||||
j,
|
||||
source,
|
||||
imports: ["MuiList"],
|
||||
renameImports: {
|
||||
MuiList: "List",
|
||||
},
|
||||
otherImports: exported,
|
||||
currentLibName: "@pankod/refine-mui",
|
||||
nextLibName: "@mui/material",
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
import type { Collection, JSCodeshift } from "jscodeshift";
|
||||
import { exported } from "../../definitions/separated-imports/react-hook-form";
|
||||
import {
|
||||
CONFIG_FILE_NAME,
|
||||
CodemodConfig,
|
||||
separateImports,
|
||||
} from "../../helpers";
|
||||
|
||||
const REFINE_LIB_PATH = "@pankod/refine-react-hook-form";
|
||||
const REACT_HOOK_FORM_PATH = "react-hook-form";
|
||||
const REACT_HOOK_FORM_VERSION = "^7.43.5";
|
||||
|
||||
export const separateImportsReactHookForm = (
|
||||
j: JSCodeshift,
|
||||
source: Collection,
|
||||
) => {
|
||||
const config = new CodemodConfig(CONFIG_FILE_NAME);
|
||||
|
||||
separateImports({
|
||||
j,
|
||||
source,
|
||||
imports: exported,
|
||||
renameImports: {},
|
||||
otherImports: {},
|
||||
currentLibName: REFINE_LIB_PATH,
|
||||
nextLibName: REACT_HOOK_FORM_PATH,
|
||||
});
|
||||
|
||||
// if use `react-hook-form` add package.json
|
||||
const reactQuery = source.find(j.ImportDeclaration, {
|
||||
source: {
|
||||
value: REACT_HOOK_FORM_PATH,
|
||||
},
|
||||
});
|
||||
|
||||
if (reactQuery.length) {
|
||||
config.addPackage(REACT_HOOK_FORM_PATH, REACT_HOOK_FORM_VERSION);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
import type { Collection, JSCodeshift } from "jscodeshift";
|
||||
import { exported } from "../../definitions/separated-imports/react-query";
|
||||
import {
|
||||
CONFIG_FILE_NAME,
|
||||
CodemodConfig,
|
||||
separateImports,
|
||||
} from "../../helpers";
|
||||
|
||||
const REFINE_LIB_PATH = "@pankod/refine-core";
|
||||
const REACT_QUERY_PATH = "@tanstack/react-query";
|
||||
const REACT_QUERY_VERSION = "^4.10.1";
|
||||
|
||||
export const separateImportsReactQuery = (
|
||||
j: JSCodeshift,
|
||||
source: Collection,
|
||||
) => {
|
||||
const config = new CodemodConfig(CONFIG_FILE_NAME);
|
||||
|
||||
separateImports({
|
||||
j,
|
||||
source,
|
||||
imports: exported,
|
||||
renameImports: {},
|
||||
otherImports: {},
|
||||
currentLibName: REFINE_LIB_PATH,
|
||||
nextLibName: REACT_QUERY_PATH,
|
||||
});
|
||||
|
||||
// if use `@tanstack/react-query` add package.json
|
||||
const reactQuery = source.find(j.ImportDeclaration, {
|
||||
source: {
|
||||
value: REACT_QUERY_PATH,
|
||||
},
|
||||
});
|
||||
|
||||
if (reactQuery.length) {
|
||||
config.addPackage(REACT_QUERY_PATH, REACT_QUERY_VERSION);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
import type { Collection, JSCodeshift } from "jscodeshift";
|
||||
import { exported } from "../../definitions/separated-imports/react-router-v6";
|
||||
import {
|
||||
CONFIG_FILE_NAME,
|
||||
CodemodConfig,
|
||||
separateImports,
|
||||
} from "../../helpers";
|
||||
|
||||
export const separateImportsReactRouterV6 = (
|
||||
j: JSCodeshift,
|
||||
source: Collection,
|
||||
) => {
|
||||
const config = new CodemodConfig(CONFIG_FILE_NAME);
|
||||
|
||||
if (
|
||||
source.find(j.ImportDeclaration, {
|
||||
source: { value: "@pankod/refine-react-router-v6" },
|
||||
}).length > 0
|
||||
) {
|
||||
config.addPackage("react-router-dom", "^6.8.1");
|
||||
}
|
||||
|
||||
separateImports({
|
||||
j,
|
||||
source,
|
||||
imports: exported,
|
||||
renameImports: {},
|
||||
otherImports: {},
|
||||
currentLibName: "@pankod/refine-react-router-v6",
|
||||
nextLibName: "react-router-dom",
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
import type { Collection, JSCodeshift } from "jscodeshift";
|
||||
import { exported } from "../../definitions/separated-imports/react-table";
|
||||
import {
|
||||
CONFIG_FILE_NAME,
|
||||
CodemodConfig,
|
||||
separateImports,
|
||||
} from "../../helpers";
|
||||
|
||||
export const separateImportsReactTable = (
|
||||
j: JSCodeshift,
|
||||
source: Collection,
|
||||
) => {
|
||||
const config = new CodemodConfig(CONFIG_FILE_NAME);
|
||||
|
||||
if (
|
||||
source.find(j.ImportDeclaration, {
|
||||
source: { value: "@pankod/refine-react-table" },
|
||||
}).length > 0
|
||||
) {
|
||||
config.addPackage("@tanstack/react-table", "^8.2.6");
|
||||
}
|
||||
|
||||
separateImports({
|
||||
j,
|
||||
source,
|
||||
imports: exported,
|
||||
renameImports: {},
|
||||
otherImports: {},
|
||||
currentLibName: "@pankod/refine-react-table",
|
||||
nextLibName: "@tanstack/react-table",
|
||||
});
|
||||
};
|
||||
94
packages/codemod/src/transformations/v4/use-menu-to-core.ts
Normal file
94
packages/codemod/src/transformations/v4/use-menu-to-core.ts
Normal file
@@ -0,0 +1,94 @@
|
||||
import type { JSCodeshift, Collection } from "jscodeshift";
|
||||
|
||||
const REFINE_ANTD_PATH = "@pankod/refine-antd";
|
||||
const REFINE_MUI_PATH = "@pankod/refine-mui";
|
||||
const REFINE_CORE_PATH = "@pankod/refine-core";
|
||||
|
||||
const ANTD_IMPORTS_TO_MOVE_CORE = ["useMenu"];
|
||||
const MUI_IMPORTS_TO_MOVE_CORE = ["useMenu"];
|
||||
|
||||
const moveImports = (
|
||||
j: JSCodeshift,
|
||||
source: Collection,
|
||||
importNamesToMove: string[],
|
||||
fromModule: string,
|
||||
toModule: string,
|
||||
) => {
|
||||
importNamesToMove.forEach((importName) => {
|
||||
// get the import declaration to be moved
|
||||
const importsFromModule = source
|
||||
.find(j.ImportDeclaration)
|
||||
.filter((path) => path.node.source.value === fromModule)
|
||||
.find(j.ImportSpecifier);
|
||||
|
||||
// filter the imports to be moved
|
||||
const importsToBeMoved = importsFromModule.filter(
|
||||
(path) =>
|
||||
path.node.imported.name === importName ||
|
||||
path.node.local?.name === importName,
|
||||
);
|
||||
|
||||
if (!importsToBeMoved?.length) return;
|
||||
|
||||
importsToBeMoved.forEach((importToMove) => {
|
||||
// get the import declaration of the import to move
|
||||
const importsToModule = source
|
||||
.find(j.ImportDeclaration)
|
||||
.filter((path) => path.node.source.value === toModule);
|
||||
|
||||
// if there is no import declaration for the import to move, create import declaration and add it to the top of the file.
|
||||
if (!importsToModule?.length) {
|
||||
source
|
||||
.get()
|
||||
.node.program.body.unshift(
|
||||
j.importDeclaration(
|
||||
[importToMove.get().node],
|
||||
j.stringLiteral(toModule),
|
||||
),
|
||||
);
|
||||
|
||||
// remove the moved import
|
||||
j(importToMove).remove();
|
||||
return;
|
||||
}
|
||||
|
||||
// add new import from importsToBeMoved to the existing import declaration.
|
||||
// we select the first import declaration if there are multiple import declarations.
|
||||
const importTo = importsToModule.at(0).paths().at(0).get();
|
||||
j(importTo).replaceWith(
|
||||
j.importDeclaration(
|
||||
[...importTo.node.specifiers, importToMove.get().node],
|
||||
importTo.node.source,
|
||||
),
|
||||
);
|
||||
|
||||
// remove the moved import
|
||||
j(importToMove).remove();
|
||||
});
|
||||
});
|
||||
|
||||
// remove empty import declarations after moving imports e.g. import { } from "@pankod/refine-antd"
|
||||
source
|
||||
.find(j.ImportDeclaration)
|
||||
.filter((path) => path.node.source.value === fromModule)
|
||||
.filter((path) => !path.node.specifiers?.length)
|
||||
.forEach((path) => j(path).remove());
|
||||
};
|
||||
|
||||
export const useMenuToCore = (j: JSCodeshift, source: Collection) => {
|
||||
moveImports(
|
||||
j,
|
||||
source,
|
||||
ANTD_IMPORTS_TO_MOVE_CORE,
|
||||
REFINE_ANTD_PATH,
|
||||
REFINE_CORE_PATH,
|
||||
);
|
||||
|
||||
moveImports(
|
||||
j,
|
||||
source,
|
||||
MUI_IMPORTS_TO_MOVE_CORE,
|
||||
REFINE_MUI_PATH,
|
||||
REFINE_CORE_PATH,
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user