Publishing Codemods
Learn how to publish your codemods to the Codemod Registry and share them with the world.
You can easily share your codemods with thousands of people around the world by adding them to the 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.
├── dist
│ ├── index.cjs # this is the default path for the built codemod file. when someone runs your codemod, this file will be executed.
├── src
│ ├── index.ts # this is the default path for the codemod's entry point file.
│ ├── ...
├── .codemodrc.json # contains the codemod configuration
└── README.md # must contain a short description and examples, such as in the example at the bottom of this page
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.
Login to Codemod platform
Login to Codemod platform by using:
codemod login
You will be redirected to the Codemod platform login page. Upon successful login, our CLI will automatically authenticate you.
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
Publish your codemod
Publish your codemod by using the following command inside your project’s directory:
codemod publish
Was this page helpful?