You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: website/docs/api/codeshift-cli.mdx
+38-1Lines changed: 38 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,7 +31,44 @@ and run with:
31
31
32
32
`$ codeshift` or `$ codeshift-cli`
33
33
34
-
## Options
34
+
## default
35
+
36
+
The default CLI command (when no subcommand is specified,) will attempt to download and run transform(s) against the specified file path.
37
+
38
+
In the majority of cases you want to be sure to either provide the `--packages` flag for running remote codemods, or the `--transform, -t` flag to run a local transform file.
39
+
40
+
For running codemods as an end-user it's recommend to use the `--packages` flag, which accepts the following format: `--packages [package-name]@[semver-version]`. For example, running the codemod to migrate your codebase to `react` version `18.0.0` you would specify the following `--packages react@18.0.0`.
41
+
42
+
In special cases, codeshift package authors may choose to also expose codemod "presets", which can be considered as utility codemods for that package. Presets are also run via the `--packages` flag like so: `--packages react#remove-spread-props`.
43
+
Notice that we have switched to a hash `#` here to denote that we want to run a preset.
44
+
45
+
Codeshift will then attempt to locate codemods from both the [community folder](https://github.com/CodeshiftCommunity/CodeshiftCommunity/tree/main/community) and the primary npm package ie [React – NPM](https://www.npmjs.com/package/react).
46
+
(Note: Some packages wont have any codemods, you can use the [list](#list) subcommand to check if they exist.)
47
+
48
+
Lastly, when authoring a package, it's possible to test your transforms by omitting both the `--packages` and `--transform` flags. In this interactive mode, the `codeshift/cli` will attempt to locate
49
+
a local `codeshift.config.js` from the current or parent directories and present an interactive prompt for you to choose from.
50
+
51
+
**example:**
52
+
53
+
Run a transform for "@mylib/button" version 3.0.0 only
0 commit comments