Codemods, public or private, are preferred to reside in repositories owned by the main organization of their respective projects.
This repository serves as a template for codemod packages, allowing contributors to quickly whip up a repository for their published codemods.
This template repository comes pre-configured with a GitHub workflow that automatically publishes the latest version of your codemod, eliminating the need to manually publish codemods after making updates.
-
Click Use this template.
-
Select Create a new repository and enter your new repository details.
-
Login with Codemod CLI:
codemod login
. -
Generate a Codemod API key:
codemod api-keys:create
. -
Place your API key in a new repository secret under
Settings > Secrets and Variables > Actions
. -
Create or move your codemod package(s) under the
codemods
directory. Note that your codemods should conform to the required package structure. Additionally, make sure that yourcodemodrc.json
file is accurate (reference).
By doing so, any change made to the main
branch of your repository will automatically be published to Codemod Registry.
To run your codemods use codemod
command below:
$ npx codemod [codemod-name]
codemod-name
- name of transform. use the name of your codemod in Codemod Registry.
See the codemod CLI doc for a full list of available commands and options.
Important
After using this template, it's recommended that you update this README with:
- details about what your codemod does (e.g. before/after code snippets)
- a link to the published codemod in Codemod Registry
- the accurate run command.