@chakra-ui/codemod

1.2.0 • Public • Published

Chakra UI Codemod

Chakra UI provides Codemod transformations to help upgrade your Chakra UI codebase when a component is updated or deprecated.

Codemods are transformations that run on your codebase programmatically. This allows for a large amount of changes to be applied without having to manually go through every file.

Usage

If you're using a monorepo, you'll need to cd into the specific package that has Chakra UI installed. Otherwise, you can run these at the root of your project.

npx @chakra-ui/codemod [path]

The codemod will ask you a few questions:

  • Which files or directory should the codemods be applied? [text]
  • Which codemod(s) would like to apply? [select]

Flags

  • --dry: Pass if you want to perform a dry run?
  • --print: Pass if you want to print the modified files

If you are running this command in a git repository, please commit or stash your changes first

Chakra V1 Codemods

Status

  • [x] Update color to colorScheme
  • [x] Update import from @chakra-ui/core to @chakra-ui/react
  • [ ] Rename size prop for Box or PseudoBox to w and h
  • [x] Update Slider JSX structure
  • [x] Rename ThemeProvider to ChakraProvider
  • [x] Update component Imports to reflect updates
  • [x] Update useDisclosure signature
  • [x] Change v0 Icons to v1 Icons
  • [x] Replace string icon prop to Button and IconButton to icon elements from @chakra-ui/icons

Development

To watch and build TS files run:

yarn watch

Link this package in your global node_modules by running:

npm link

To execute the command run:

# no path
chakra-codemod
> Run chakra codemod in: <current-directory>

# relative path
chakra-codemod my-app
> Run chakra codemod in: <current-directory>/my-app

# absolute path
chakra-codemod /Users/you/development/my-app
> Run chakra codemod in: /Users/you/development/my-app

# absolute path with tranformer name
chakra-codemod /Users/you/development/my-app core-to-react
> Run chakra core-to-react codemod in: /Users/you/development/my-app

References

Todo

Write transforms for:

Readme

Keywords

none

Package Sidebar

Install

npm i @chakra-ui/codemod

Weekly Downloads

0

Version

1.2.0

License

MIT

Unpacked Size

28 kB

Total Files

15

Last publish

Collaborators

  • segunadebayo
  • _codebender828