Skip to content

Commit b944419

Browse files
committed
chore: move to Ink 8 and drop the ink patch script
- ink 6.8 -> 8.0, react / @types/react ~19.2 -> ~19.3 (ink 8 ships react-reconciler 0.34, which requires react ^19.3). engines.node is now >=22 because ink 8 requires Node 22. Release binaries are unaffected (oclif pack bundles Node); CI already runs on Node 22. - Delete scripts/patch-ink.ts and its postinstall, pkg.ts and build-npm.ts steps. Ink 8 natively provides suspendTerminal() (flush + erase frame, release raw mode and the stdin 'readable' listener, forced redraw on resume) and fixes the stale <Static> node bug the reconciler patch backported. - DefaultReporter hands the terminal to PTY sessions via suspendTerminal(), captured from useApp() in DefaultComponent. Verified in a PTY on Node 22 and Node 24 (which previously needed the kState workaround). Ink now restores raw mode itself on resume, which also fixes keypresses being line-buffered after a stdin handoff. - wrap='middle' -> 'wrap' in PromptPressKeyToContinue: 'middle' was never a valid value (ink 5 silently skipped wrapping), and ink 8 rejects it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016QnBk1T9WChsm317yyQKmh
1 parent e4acec8 commit b944419

8 files changed

Lines changed: 191 additions & 410 deletions

File tree

‎package-lock.json‎

Lines changed: 150 additions & 102 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"detect-indent": "^7.0.1",
2222
"diff": "^8.0.3",
2323
"express": "^5.1.0",
24-
"ink": "^6.8.0",
24+
"ink": "^8.0.0",
2525
"ink-big-text": "^2.0.0",
2626
"ink-gradient": "^4.0.1",
2727
"ink-select-input": "^6.0.0",
@@ -38,7 +38,7 @@
3838
"node-pty": "1.2.0-beta.15",
3939
"open": "^10.1.2",
4040
"parse-json": "^8.1.0",
41-
"react": "~19.2.0",
41+
"react": "~19.3.0",
4242
"uuid": "^10.0.0",
4343
"ws": "^8.18.3"
4444
},
@@ -56,7 +56,7 @@
5656
"@types/json5": "^2.2.0",
5757
"@types/mocha": "^10.0.10",
5858
"@types/node": "^20",
59-
"@types/react": "~19.2.0",
59+
"@types/react": "~19.3.0",
6060
"@types/semver": "^7.8.0",
6161
"@types/strip-ansi": "^5.2.1",
6262
"@types/uuid": "^10.0.0",
@@ -82,7 +82,7 @@
8282
}
8383
},
8484
"engines": {
85-
"node": ">=20.0.0"
85+
"node": ">=22.0.0"
8686
},
8787
"files": [
8888
"/bin",
@@ -128,7 +128,7 @@
128128
},
129129
"repository": "codifycli/codify",
130130
"scripts": {
131-
"postinstall": "[ -f node_modules/oclif/lib/tarballs/bin.js ] && tsx scripts/patch-oclif.ts || true; [ -f dist/patch-ink.mjs ] && node dist/patch-ink.mjs || true",
131+
"postinstall": "[ -f node_modules/oclif/lib/tarballs/bin.js ] && tsx scripts/patch-oclif.ts || true",
132132
"build": "shx rm -rf dist && tsc -b",
133133
"build:release": "npm run pkg && ./scripts/notarize.sh",
134134
"lint": "tsc",

‎scripts/build-npm.ts‎

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,15 @@
11
// npm-publish prep. Runs from `prepublishOnly` (after `npm run build`).
22
//
3-
// Two npm-specific concerns the plain `tsc` build doesn't handle:
4-
//
5-
// 1. dist/patch-ink.mjs — the postinstall hook runs `node dist/patch-ink.mjs`
6-
// to patch node_modules/ink at the user's install time (needed for the raw-PTY
7-
// handoff, e.g. `gh auth login` — see scripts/patch-ink.ts). `tsc -b` only
8-
// compiles src/**/*, so this file is otherwise absent from the npm tarball and
9-
// the postinstall guard silently skips it. Compile it here (same command as
10-
// scripts/pkg.ts uses for the binary build).
11-
//
12-
// 2. README.md — npm should show a "migrated and re-purposed" blurb that the
13-
// git-tracked README must NOT carry. README.npm.md holds ONLY the blurb; we
14-
// back up the real README and prepend the blurb to it (so the body is never
15-
// duplicated). `npm run restore-npm` (via postpublish, and defensively on
16-
// failure) restores it from the backup.
3+
// The plain `tsc` build doesn't handle the README: npm should show a "migrated and
4+
// re-purposed" blurb that the git-tracked README must NOT carry. README.npm.md holds
5+
// ONLY the blurb; we back up the real README and prepend the blurb to it (so the body
6+
// is never duplicated). `npm run restore-npm` (via postpublish, and defensively on
7+
// failure) restores it from the backup.
178
//
189
// The backup file (README.md.orig) is the single source of truth for restoration,
1910
// so a failed publish never leaves README.md dirty.
2011

2112
import chalk from 'chalk'
22-
import { execSync } from 'node:child_process'
2313
import { existsSync } from 'node:fs'
2414
import fs from 'node:fs/promises'
2515

@@ -30,15 +20,7 @@ const README_BLURB = 'README.npm.md'
3020
// allowlist, and this backup is just build scratch that shouldn't ship.
3121
const README_BACKUP = '.npm-readme-backup.md'
3222

33-
// ── 1. Compile patch-ink.ts → dist/patch-ink.mjs ─────────────────────────────
34-
console.log(chalk.magenta('Compiling patch-ink.ts to dist/patch-ink.mjs'))
35-
execSync(
36-
'tsc --module nodenext --moduleResolution nodenext --target es2022 --outDir dist scripts/patch-ink.ts',
37-
{ shell: 'zsh' },
38-
)
39-
await fs.rename('dist/patch-ink.js', 'dist/patch-ink.mjs')
40-
41-
// ── 2. Prepend the npm blurb to README.md ────────────────────────────────────
23+
// ── Prepend the npm blurb to README.md ────────────────────────────────────
4224
// README.npm.md holds ONLY the blurb; we prepend it to the real README so the
4325
// body never has to be duplicated/kept in sync. `npm run restore-npm` puts the
4426
// original README.md back from the backup.

‎scripts/patch-ink.ts‎

Lines changed: 0 additions & 250 deletions
This file was deleted.

‎scripts/pkg.ts‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@ await Promise.all([
2626
fs.cp('README.md', './.build/README.md'),
2727
]);
2828

29-
console.log(chalk.magenta('Compiling patch-ink.ts to .build/dist/patch-ink.mjs'))
30-
execSync(
31-
'tsc --module nodenext --moduleResolution nodenext --target es2022 --outDir .build/dist scripts/patch-ink.ts',
32-
{ shell: 'zsh' }
33-
);
34-
await fs.rename('./.build/dist/patch-ink.js', './.build/dist/patch-ink.mjs');
35-
3629
console.log(chalk.magenta('Esbuild src'))
3730
execSync('tsx esbuild.ts', { shell: 'zsh' })
3831

‎src/ui/components/default-component.tsx‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Box, Static, Text, useStdout } from 'ink';
1+
import { Box, Static, type SuspendTerminal, Text, useApp, useStdout } from 'ink';
22
import SelectInput from 'ink-select-input';
33
import { useAtom } from 'jotai';
44
import { EventEmitter } from 'node:events';
@@ -26,9 +26,11 @@ import { TextInput } from './widgets/TextInput.js';
2626

2727
export function DefaultComponent(props: {
2828
emitter: EventEmitter
29+
onSuspendTerminalReady?: (suspendTerminal: SuspendTerminal) => void
2930
onWriteReady?: (write: (data: string) => void) => void
3031
}) {
31-
const { emitter, onWriteReady } = props
32+
const { emitter, onSuspendTerminalReady, onWriteReady } = props
33+
const { suspendTerminal } = useApp();
3234
const [renderState] = useAtom(store.renderState);
3335
const { status: renderStatus, data: renderData } = renderState;
3436
const { write } = useStdout();
@@ -42,6 +44,10 @@ export function DefaultComponent(props: {
4244
onWriteReady?.(write);
4345
}, []);
4446

47+
useLayoutEffect(() => {
48+
onSuspendTerminalReady?.(suspendTerminal);
49+
}, [suspendTerminal]);
50+
4551
return <Box flexDirection="column" marginTop={1}>
4652
{
4753
renderStatus === RenderStatus.DISPLAY_MESSAGE && (

‎src/ui/components/widgets/PromptPressKeyToContinue.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export function PromptPressKeyToContinue(props: {
1111

1212
return <Static items={[{}]} style={{ width: '100%' }}>{
1313
(item, idx) => (<Box flexDirection='column' key={idx} marginTop={1}>
14-
{ props.message && (<Text wrap='middle'>{props.message}</Text>) }
14+
{ props.message && (<Text wrap='wrap'>{props.message}</Text>) }
1515
<Text> </Text>
1616
<Text color='gray' dimColor>{'<Press any key to continue>'}</Text>
1717
</Box>)

0 commit comments

Comments
 (0)