Running codemods is made simple through our CLI tool, @hypermod/cli.
@hypermod/cli is responsible for running the provided transform against your entire codebase. Under the hood, it is a wrapper of jscodeshift's cli, which provides additional functionality
For usage please refer to the @hypermod/cli API reference.
How to run Community codemods
To run a hypermod package, install and use the
npm install -g @hypermod/clior
yarn global add @hypermod/cli
For example, say we want to run transforms for
@mylib/button and migrate from version 13 to the latest version 14, we could run the following:
codemod-cli --packages @firstname.lastname@example.org project/path/to/src
The following sequence of events will follow:
@hypermod/cliwill then attempt to download a Hypermod package for the
@mylib/buttonpackage matching version
- Download the package from NPM
- Locate the
- Attempt to find a
- Run the transform against the path
Run codemods in sequence
It's also possible to run a series of codemods, one after the other, to migrate your usage of
@mylib/button across multiple major versions, from say v14, v15 and finally v16. Assuming codemods for those versions exist.
This is done my providing the
-s) flag to
codemod-cli --packages @email@example.com --sequence project/path/to/src
This time around, we use the provided version (14.0.0) as the start of a semver range between
We then fetch all codemods that match and run them one after another.
Running local transforms
For local transform files, not published to the community repo, you can supply your own transform the same way you would with jscodeshift.
codemod-cli --transform path/to/transform.ts project/path/to/src
Parsing TypeScript & Flow
@hypermod/cli will use
babel as the default parser and only transform files with a
If your repo depends on flow or typescript, it's important to remember to specify
flow as the
--parser and or
jsx, ts, tsx as
--extensions to make sure jscodeshift can interpret the files properly.
Please refer to the @hypermod/cli API reference for more information.