From 19395b720ab850c31ede83735ab7bd065c259eb3 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 9 Jun 2021 20:52:32 +0200 Subject: [PATCH] codemods: update README with new apply/list commands Signed-off-by: Patrik Oldsberg --- packages/codemods/README.md | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/codemods/README.md b/packages/codemods/README.md index 017aace3f0..c40e9a8dcc 100644 --- a/packages/codemods/README.md +++ b/packages/codemods/README.md @@ -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 .