packages/turbo-codemod/src/transforms/README.md
@turbo/codemod TransformersAdd new transformers using the plopjs template by running:
pnpm add-transformer
New Transformers will be automatically surfaced to the transform CLI command and used by the migrate CLI command when appropriate.
Transformers are loaded automatically from the src/transforms/ directory via the loadTransforms function.
All new transformers must contain a default export that matches the Transformer type:
export type Transformer = {
name: string;
description: string;
introducedIn: string;
transformer: (args: TransformerArgs) => TransformerResults;
};
Transforms are run using the TransformRunner. This class is designed to make writing transforms as simple as possible by abstracting away all of the boilerplate that determines what should be logged, saved, or output as a result.
To use the TransformRunner:
TransformRunner takes care of this depending on the options passed in by the user), and pass to TransformRunner.modifyFile method.TransformRunner.abortTransform method.TransformRunner.modifyFile, call TransformRunner.finish method to write the files to disk (when not running in dry mode) and log the results.