Codemod Registry hero banner

You can easily share your codemods with thousands of people around the world by adding them to Codemod Registry. Once added, they will automatically integrate with Codemod platform. This simplifies codemod discovery and distribution, and offers a better running codemods experience.

Publishing codemods to the registry is especially useful for framework/library builders. With features like shareable codemod deep links and Codemod CLI & IDE extenion, your users can adopt your latest releases with one click, straight from your migration doc.

Supported codemod engines

Codemod platform currently supports the following codemod engines: ast-grep, filemod, jscodeshift, ts-morph, and piranha.

Required codemod package structure

To make your codemod package compatible with Codemod platform, it needs to have a .codemodrc.json configuration file in the project root and conform to one of the structures, depending on the codemod engine used.

├── dist
│   ├── index.cjs # built codemod file. when someone runs your codemod, this file will be executed.
├── src
│   ├── index.ts # the default path for the codemod's entry point file.
│   ├── ...
├── .codemodrc.json # contains the codemod configuration
└── README.md # contain a short description and examples, such as in the example at the bottom of this page
{
"$schema": "https://codemod-utils.s3.us-west-1.amazonaws.com/configuration_schema.json",
"version": "1.0.0",
"private": false,
"name": "framework/version/codemod-name",
"description": "example codemod description",
"engine": "jscodeshift/ts-morph/filemod",
"meta": {
  "tags": ["framework", "migration", "etc"],
    "git": "https://github.com/user/repo"
},
"applicability": {
  "from": [["framework", "<=", "version"]],
  "to": [["framework", "=", "version"]]
  }
}

Publish with Codemod CLI

Once your codemod package is compatible with Codemod platform, you can use Codemod CLI to publish a local codemod to the codemod registry.

1

Login to Codemod platform

Login to Codemod platform by using:

codemod login

You will be redirected to Codemod platform login page. Upon successful login, our CLI will automatically authenticate you.

2

Build your local project

This will build a JavaScript project using esbuild and create a dist directory in your project root. If your codemod is not using a JavaScript engine, you can skip this step.

If your local project is not already built, you can build it using codemod CLI:

codemod build
3

Publish your codemod

Publish your codemod by using the following command inside your project’s directory:

codemod publish

Was this page helpful?