Applies a codemod to all source files
Recipe ID
org.openrewrite.codemods.ApplyCodemodArtifact
org.openrewrite.recipe:rewrite-codemodsApplies a codemod represented by an NPM package to all source files.
Usage
You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe org.openrewrite.codemods.ApplyCodemod --recipe-option "transform=-t path/to/transform/optimus-prime" --recipe-option "fileFilter=**/*.(j|t)sx"If the recipe isn’t available locally, install it with:
mod config recipes jar install org.openrewrite.recipe:rewrite-codemods:0.27.2Options
| Name | Type | Description |
|---|---|---|
transformrequired | String | Transform to be applied using the executable. e.g. -t path/to/transform/optimus-prime |
executable | String | Path to the codemod executable relative to the NPM directory. Defaults to jscodeshift/bin/jscodeshift.js.e.g. @next/codemod/bin/next-codemod.js |
fileFilterrequired | String | Optional glob pattern to filter files to apply the codemod to. Defaults to all files. Note: not all codemods support file glob filtering. e.g. **/*.(j|t)sx |
codemodArgs | List | Arguments which get passed to the codemod command. e.g. --force --jscodeshift='--parser=${parser}' |
Data tables
Structured output this recipe can produce.
- Source files that had resultsSource files that were modified by the recipe run.
org.openrewrite.table.SourcesFileResults - Source files that had search resultsSearch results that were found during the recipe run.
org.openrewrite.table.SearchResults - Source files that errored on a recipeThe details of all errors produced by a recipe run.
org.openrewrite.table.SourcesFileErrors - Recipe performanceStatistics used in analyzing the performance of recipes.
org.openrewrite.table.RecipeRunStats