This guide will walk you through the steps needed to publish codemods to Codemod Registry.

There are three ways to publish codemods to Codemod Registry:

  1. publishing a codemod package
  2. publishing from source file
  3. publishing with Codemod Studio

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

Publishing codemods

Creating and publishing a Codemod-compatible package brings an enhanced codemod running experience.

1

Build a codemod package

To publish a codemod to Codemod Registry, the codemod package needs to be compatible with Codemod platform. To learn how to build Codemod-compatible codemods, please refer to the building codemods guide.

2

Login to Codemod platform

If you are not already logged in, login to Codemod platform using:

codemod login
3

Publish codemod

Move to your codemod package directory and run:

codemod publish

Option 2: Publishing a codemod from source file

1

Login to Codemod platform

If you are not already logged in, login to Codemod platform using:

codemod login
2

Publish codemod

Publish the codemod from source path:

To generate a Codemod-compatible package, Codemod CLI will ask you a few questions about your codemod to generate the codemodrc.json configuration file automatically for you.

If you want to use ESM-specific features like top-level await or import.meta, you can rename it to use .mjs or .mts extension or specify --esm flag to treat the source file as ESM package explicitly.
codemod publish [path] --source

Option 3: Publishing with Codemod Studio

After building a codemod with Codemod Studio, you can instantly publish it to your private registry to quickly run it over your local project(s).

To do so, you can click Run with CLI. After publishing the codemod, you will be able to run the codemod using Codemod CLI while being logged in with the same user used on Codemod Studio.

To run the codemod, you can simply copy the exported command in the pop-up modal and run the command on any local codebase of your choice.

Unpublishing codemods

To unpublish a codemod from Codemod Registry, you can use the codemod unpublish command.