← Public packages
@kentcdodds/codemod-runner
Run codemods over your own saved packages: scan, dry-run with real publish checks and diffs, apply, and revert.
src/dry-run.ts
25 lines · 819 B · TypeScriptimport { requireCodemod, runStep, type StepInput } from './step.ts'
import { transformPackage } from './process-package.ts'
/**
* Transforms your packages in throwaway repo sessions, runs the real
* publish checks on the transformed trees, and returns per-package diffs —
* without publishing anything. Also verifies the codemod is idempotent.
* Run this (and read the diffs) before `apply`. Paged: keep calling with
* the returned runId + cursor until nextCursor is null.
*/
export default async function dryRun(input: StepInput = {}) {
requireCodemod(input)
return await runStep({
mode: 'dry-run',
step: input,
defaults: { limit: 1, max: 2 },
processPackage: async (run, pkg) =>
await transformPackage({
mode: 'dry-run',
runId: run.id,
pkg,
codemod: input.codemod!,
}),
})
}