← All recipes
Moderne licensed

Applies a codemod to all source files

Recipe IDorg.openrewrite.codemods.ApplyCodemod
Artifactorg.openrewrite.recipe:rewrite-codemods

Applies a codemod represented by an NPM package to all source files.

Single recipeMSAL

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.2

Options

NameTypeDescription
transformrequiredStringTransform to be applied using the executable.
e.g. -t path/to/transform/optimus-prime
executableStringPath to the codemod executable relative to the NPM directory. Defaults to jscodeshift/bin/jscodeshift.js.
e.g. @next/codemod/bin/next-codemod.js
fileFilterrequiredStringOptional 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
codemodArgsListArguments 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