paratext
Recipes

Incremental migration

Move from ansi-escapes, terminal-link and term-img one import at a time — each is one changed specifier, file paths included.

Each drop-in is graded on its own, so a program can move one import at a time and ship in between.

One import at a time

- import ansiEscapes, { cursorTo, eraseLines, link } from 'ansi-escapes';
+ import ansiEscapes, { cursorTo, eraseLines, link } from 'paratext';
- import terminalLink from 'terminal-link';
+ import terminalLink from 'paratext/terminal-link';
- import terminalImage from 'term-img';
+ import terminalImage from 'paratext/term-img';

Or let the codemod do it: npx burgee migrate --dry-run lists every import it would rewrite — only drop-ins graded level with their incumbent, which all three are — and npx burgee migrate rewrites them (Migrate).

term-img: paths stay paths

paratext/term-img reads a file path as term-img does, so terminalImage('logo.png') needs no change. Bytes work as before.

What changes after the move

The ansi-escapes CSI calls are byte-for-byte what they were. link, image and setCwd now write their text form on a pipe instead of escape bytes, which is the reason to move (Compatibility). terminal-link and term-img keep their incumbents' detection and fallbacks.

Checking each step

npm uninstall ansi-escapes terminal-link term-img
npm ls ansi-escapes

npm ls shows what still pulls ansi-escapes in transitively — log-update and terminal-link both depend on it.

On this page