Skip to content
← 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/runs.ts

21 lines · 599 B · TypeScript
import { getRun, listRunSummaries } from './ledger.ts'

export type RunsInput = {
	/** Omit to list recent runs; pass a run id for the full record with items and diffs. */
	runId?: string
}

/**
 * Reads the codemod run ledger: recent run summaries, or one run's full
 * record (per-package statuses, findings, failed checks, and diffs).
 */
export default async function runs(input: RunsInput = {}) {
	if (input.runId) {
		const run = await getRun(input.runId)
		if (!run) {
			throw new Error(`Run "${input.runId}" was not found.`)
		}
		return run
	}
	return { runs: await listRunSummaries() }
}