codemods: update README with new apply/list commands

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2021-06-09 20:52:32 +02:00
parent fa69ab7512
commit 19395b720a
+15 -3
View File
@@ -6,15 +6,27 @@ A collection of codemods for use with Backstage projects. They are intended to i
This package is a wrapper around [`jscodeshift`](https://github.com/facebook/jscodeshift) with some included transforms. The transforms can either be executed via the included CLI or directly via `jscodeshift`.
To run the `core-imports` codemod towards all source files in a package, run the following:
To run the `core-imports` codemod towards all source files in the current directory, run the following:
```sh
npx @backstage/codemods core-imports .
npx @backstage/codemods apply core-imports
```
Note that this will modify the source files directly, but it's possible to do a dry-run by adding the `--dry` flag.
The transforms are located within the `transforms/` directory in this package, so running directly with `jscodeshift` looks like this:
By passing a list of paths the codemod will only be applied to those paths:
```sh
npx @backstage/codemods apply core-imports plugins/my-plugin-a plugins/my-plugin-b
```
To print a list of all available transforms you use the `list` command:
```sh
npx @backstage/codemods list
```
You can also apply the transforms manually using `jscodeshift`. The transforms are located within the `transforms/` directory in this package, so running directly with `jscodeshift` looks like this:
```sh
npx jscodeshift --parser=tsx --extensions=tsx,js,ts,tsx --transform=node_modules/@backstage/codemods/transforms/core-imports.js .