|
| 1 | +# codemod-cli |
| 2 | + |
| 3 | +codemod-cli is a command line tool for generating, testing, and publishing codemods. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +``` |
| 8 | +npm install --global codemod-cli |
| 9 | +
|
| 10 | +# OR |
| 11 | +
|
| 12 | +yarn global add codemod-cli |
| 13 | +``` |
| 14 | + |
| 15 | +## Usage |
| 16 | + |
| 17 | +The `codemod-cli` workflow is focused on managing a group of codemods. |
| 18 | + |
| 19 | +To get started you first need a project. You can generate a new codemod-cli project via: |
| 20 | + |
| 21 | +``` |
| 22 | +codemod-cli new <project-name> |
| 23 | +``` |
| 24 | + |
| 25 | +This will create a small project structure (`README.md`, `package.json`, etc) which is |
| 26 | +ready to help you manage your codemods. |
| 27 | + |
| 28 | +Once you have a project, you can generate a new codemod: |
| 29 | + |
| 30 | +``` |
| 31 | +codemod-cli generate codemod <name of codemod> |
| 32 | +``` |
| 33 | + |
| 34 | +This will setup a new jscodeshift codemod within your project at `transforms/<name of codemod>/index.js` |
| 35 | +along with a test harness, README, and fixture directory. |
| 36 | + |
| 37 | +Now that we have a codemod, we can begin generating fixtures for it. We use fixtures as a convienient |
| 38 | +way to represent the expected output for a given input. To generate a new fixture, run the following: |
| 39 | + |
| 40 | +``` |
| 41 | +codemod-cli generate fixture <name of codemod> <name of fixture> |
| 42 | +``` |
| 43 | + |
| 44 | +This sets up two new files in `transforms/<name of codemod>/__testfixtures__/` using the fixture name |
| 45 | +you provided. These fixtures are used by the testing harness to verify that your codemod is working properly. |
| 46 | + |
| 47 | +Once you have tweaked your codemod and its fixtures to your liking, it is time to run your tests: |
| 48 | + |
| 49 | +``` |
| 50 | +codemod-cli test |
| 51 | +``` |
| 52 | + |
| 53 | +Contributing |
| 54 | +------------------------------------------------------------------------------ |
| 55 | + |
| 56 | +### Installation |
| 57 | + |
| 58 | +* `git clone [email protected]:rwjblue/codemod-cli.git` |
| 59 | +* `cd codemod-cli` |
| 60 | +* `yarn` |
| 61 | + |
| 62 | +### Linting |
| 63 | + |
| 64 | +* `yarn lint:js` |
| 65 | +* `yarn lint:js --fix` |
| 66 | + |
| 67 | +### Running tests |
| 68 | + |
| 69 | +* `yarn test` |
| 70 | + |
| 71 | +## License |
| 72 | + |
| 73 | +This project is licensed under the [MIT License](LICENSE.md). |
0 commit comments