|
| 1 | +> **REMOVE THIS SECTION ONCE THE REPO IS SET UP.** |
| 2 | +> |
| 3 | +> Framework/SDK maintainers: This template includes setup guides, utilities, and a GitHub Action to help you and your community build and publish codemods with ease. |
| 4 | +> |
| 5 | +> ## One-time setup |
| 6 | +> NOTE: You need repo creation privileges in your org and permission to install GitHub apps on repos. If you don’t, you can request access from your org admin during setup. |
| 7 | +> 1. Use this template and create a codemods repo in your org. |
| 8 | +> 2. Sign up at [Codemod](https://app.codemod.com) with your GitHub account. |
| 9 | +> 3. Install the Codemod GitHub app: |
| 10 | +> 1. Click your profile photo (top left) and select "Add organization" |
| 11 | +> 2. Pick GitHub, choose your org and the new codemods repo. This installs the Codemod GitHub App and reserves a **scope** with your org name. |
| 12 | +> - Benefit: Only members of your org can publish codemods with a name that starts wihh your scope. |
| 13 | +> - **Important**: In `codemod.yaml`, the name must start with your scope, otherwise it won’t appear when users filter for your scope in the registry. |
| 14 | +> 4. In Codemod, switch from personal account to org account and generate a [Codemod API key](https://app.codemod.com/api-keys). |
| 15 | +> 5. In your GitHub repo: **Settings → Secrets & variables → actions** |
| 16 | +> 1. Create a repository secret. |
| 17 | +> - Name: `CODEMOD_API_KEY` |
| 18 | +> - Value: the key from step 1. |
| 19 | +> |
| 20 | +> ✅ Done! After a codemod PR is merged, you can trigger the GitHub Action to auto-publish it to the [Codemod Registry](https://app.codemod.com/registry) under your org scope. See [Node.js codemods](https://codemod.link/nodejs-official) for an example. |
| 21 | +> |
| 22 | +> To build a codemod, clone your new repo locally and use [Codemod MCP](https://docs.codemod.com/more-resources/codemod-mcp) in your IDE to replace the boilerplate with a codemod generated using AI. You can also run `npx codemod@latest init` for the initial scaffolding, or use [Codemod Studio](https://codemod.studio) for its live codemod runner and AST viewer. |
| 23 | +
|
| 24 | +--- |
| 25 | +Official <FRAMEWORK_OR_SDK_OR_ORG> codemods to help users adopt new features and handle breaking changes with ease. |
| 26 | + |
| 27 | +Community contributions are welcome and appreciated! Check open issues for codemods to build, or open a new one if something’s missing. See the [contribution guide](./CONTRIBUTING.md) for details. |
| 28 | + |
| 29 | +## Running codemods |
| 30 | +> [!CAUTION] |
| 31 | +> Codemods modify code! Run them only on Git-tracked files, and commit or stash changes first. |
| 32 | +
|
| 33 | +### From the registry |
| 34 | +Recommended for the best UX. This downloads the package from the [Registry](https://app.codemod.com/registry). |
| 35 | + |
| 36 | +```bash |
| 37 | +npx codemod@latest <codemod-name> |
| 38 | +``` |
| 39 | + |
| 40 | +For example: |
| 41 | + |
| 42 | +```bash |
| 43 | +npx codemod@latest @nodejs/tmpDir-to-tmpdir |
| 44 | +``` |
| 45 | + |
| 46 | +### From source |
| 47 | + |
| 48 | +```bash |
| 49 | +npx codemod workflow run -w /path/to/folder/containing/workflow.yaml |
| 50 | +``` |
| 51 | + |
| 52 | +> [!NOTE] |
| 53 | +> By default, codemods run in the current folder. Add `-t /target/path` to change it. |
| 54 | +
|
| 55 | +See the [Codemod docs](https://go.codemod.com/cli-docs) for all CLI commands and options. |
| 56 | + |
| 57 | +## License |
| 58 | + |
| 59 | +MIT |
0 commit comments