Skip to main content
userTourKit
Codemods

Codemods

Automated jscodeshift codemods to migrate from React Joyride, Shepherd.js, and Driver.js to Tour Kit using the tour-kit-migrate CLI.

domidex01Published

@tour-kit/codemods ships jscodeshift transforms that rewrite Joyride, Shepherd.js, and Driver.js call sites into their Tour Kit equivalents. They handle the mechanical parts of a migration — step-list reshaping, prop renames, import swaps — so you can focus on the parts that need product judgment.

The transforms are conservative by design: anything a codemod can't represent safely is kept in place and annotated with a // TODO: comment that links to the matching migration guide. A transform that mangles your code is worse than no transform.

When to use a codemod

  • You have a working tour in another library and want to evaluate Tour Kit without hand-rewriting every step list.
  • You're migrating a non-trivial app (10+ tours). Hand-edits scale badly.
  • You want a starting point. Codemods aren't a one-shot drop-in; expect to manually adjust the output. They get you past the boilerplate.

If your app has one tour with three steps, hand-editing is faster.

Install

Run it once with npx (no install), or add it as a dev dependency:

# One-off, no install
npx tour-kit-migrate --from shepherd --dry-run ./src

# Or add it to the project
pnpm add -D @tour-kit/codemods   # or: npm install -D / bun add -D

Always start with --dry-run to preview the diff, then re-run without it to write the changes:

npx tour-kit-migrate --from shepherd --dry-run ./src
npx tour-kit-migrate --from shepherd ./src

(Substitute --from driver or --from joyride as needed.)

Flags

FlagDefaultMeaning
--from <source>requiredOne of joyride, shepherd, driver
--parser <parser>tsxtsx / ts / babel
--dry-runoffPrint diffs, don't write files
--printoffWrite transformed source to stdout
--extensions <list>ts,tsx,js,jsxComma-separated extension list
--verboseoffLog every file action
--help, -hPrint usage and exit

Print the full reference any time:

npx tour-kit-migrate --help

Exit codes

CodeMeaning
0Success (or --help)
1Parse error during transform
2Bad CLI args
3No files matched

Available transforms

After running a codemod

  1. Review the diff. The transform comments every construct it can't migrate with a // TODO: that links to the matching migration guide — search the output for TODO.
  2. Run your tests. Codemods don't preserve runtime behavior for 100% of edge cases; the remainder is on you.
  3. Format the output (prettier --write or biome format --write).
  4. Open the matching guide for the library you migrated from (/docs/migration/shepherd, /docs/migration/driver, /docs/migration/joyride) for the hand-port context the codemod can't infer.

The codemod produces a Tour Kit tour shape — a { id, steps } object literal — but it does not decide where to mount <TourProvider> or wire imperative calls. You register the migrated tour at a <TourProvider> ancestor and call useTour() from a descendant. Those steps are flagged with // TODO: comments.

Limitations

Codemods operate on the AST. They cannot infer:

  • Dynamically constructed step lists (e.g. steps.push(...) driven by runtime data) — these are left as a // TODO:.
  • Custom themes / styles — port these manually against the Tour Kit theming setup.
  • Server-rendered tours (Next.js App Router) — add 'use client' to the migrated module yourself.

When in doubt, search the output for TODO markers.

Free & open source

Ship onboarding, not config.

npm i @tour-kit/core is MIT and free. The Pro packages work unlicensed too — a one-time $99 license removes the production watermark when you ship.

MIT-licensed — no signup, no credit card. Pay once, only when you ship.