chore(cli): replace Ink + React with smaller-tree CLI libraries#264
Open
X-Guardian wants to merge 10 commits into
Open
chore(cli): replace Ink + React with smaller-tree CLI libraries#264X-Guardian wants to merge 10 commits into
X-Guardian wants to merge 10 commits into
Conversation
11edeb1 to
1cc4ab6
Compare
1cc4ab6 to
07fc7d6
Compare
added 3 commits
June 23, 2026 16:00
a78cb20 to
0001b46
Compare
60f3555 to
7cc694c
Compare
Contributor
|
this looks awesome, but certainly feels like it needs to soak a bit and as we are close to cutting a release - can we merge this after cutting the release? 2 concerns raised by an automated review:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issue
Fixes #263
Description
Implements the Ink + React replacement proposed in the linked issue: swaps the Ink/React UI layer for
@inquirer/prompts+cli-spinners+cli-table3+ansi-escapes+cli-cursor. Same commands, flags, approval prompts, and--auto-approvesemantics.Improvements
Measured result:
bundle/bin/cmds/handlers.js)What changes:
packages/cdktn-cli/src/bin/cmds/helper/:tty-stream.ts—StreamRendererclass. Log-above / bar-below pattern with a dots spinner (cli-spinners), wrap-aware row counting (viastrip-ansi+out.columnsso the erase/repaint doesn't cannibalise scrollback when the bar wraps), paused-state log buffering during interactive prompts, and a leading blank row above the bar that only paints once logs are streaming (so spinner-only commands stay single-spaced). Painting is gated onstdout.isTTY && !isCI(is-ci), so the bar suppresses itself for piped/redirected output and for CI runners whether or not they allocate a TTY.project-runner.ts—runCdktfProject, replaces theuseCdktfProjectReact hook by subscribing toCdktfProject's existing event callbacks. Maps cli-core'sProjectUpdateevents to a discriminatedStatusunion the UI consumes.prompts.ts—promptApprove,promptOverride, and therequireTty/isNonTtyErrorhelpers that let callers fall back tostatus.stop()cleanly when no TTY is present.format.ts— pure render functions for outputs, stack list (Stack-name column sized to 40% of terminal width for stable column positions across runs), provider table, execution counter, watch state..ts(no JSX):get,provider-list,synth,list,output,deploy,destroy,diff,watch.ui/components/(bottom-bars, stream-view, outputs),ui/hooks/cdktf-project.ts,helper/render-ink.tsx,src/test/ui/deploy.test.tsx(Ink-specific).packages/cdktn-cli/package.json: removedreact,@types/react,ink,ink-select-input,ink-spinner,ink-table,ink-testing-library,yoga-layout-prebuilt. Added@inquirer/prompts@6.0.0(was a devDep at 2.3.1; now a runtime dep at the latest CJS-compatible major),cli-spinners@2.9.2,cli-table3@0.6.5,ansi-escapes@4.3.2,cli-cursor@3.1.0,is-ci@^4.1.0. Versions are pinned to the latest CJS-compatible releases since the cdktn-cli bundle is CJS — bumping to the ESM-only majors is a separate ESM-output migration.packages/cdktn-cli/build.ts: droppedyoga-layout-prebuiltfrom esbuild externals.packages/cdktn-cli/tsconfig.json: droppedjsx: "react"and the explicitdeploy.test.tsxinclude/exclude entries.knip.jsonc: dropped the deadyoga-layout-prebuiltignore for cdktn-cli, narrowed itsprojectglob from*.{ts,tsx}to*.ts.jsx: "react"(and*.test.tsxexcludes where present) from the 7@cdktn/*sibling tsconfigs; removed'tsx'from cli-core's jestmoduleFileExtensions; reduced cdktn-cli'seslint.config.mjsfrom React-plugin-laden to a one-line spread of root config; removedeslint-plugin-reactandeslint-plugin-react-hooksfrom root devDeps (cdktn-cli was the only consumer).Manual verification
UI commands (TTY behaviour):
cdktn synth— spinner ticks → "Generated Terraform code for the stacks: …" line (no streaming logs in the common case)cdktn list— spinner → columned stack list (no streaming logs in the common case)cdktn get— spinner → language/output messagecdktn provider list— cli-table3 bordered outputcdktn diff— logs scroll above pinned spinner bar; bar repaints without artefacts even when wider than the terminalcdktn deploy— inquirer takes over stdin at approval; Approve / Dismiss / Stop route correctlycdktn deploy --auto-approve— fully unattended; no promptcdktn destroy— same approve flow as deploycdktn watch --auto-approve— "Waiting for changes…" (spinner) → execution counter on file change; Ctrl-C tears down (cursor returns)cdktn diff | cat— stdout is a pipe → no ANSI escapes leak; no spinner; one line per log; no hangcdktn deploy | cat— stdout is a pipe but stdin is still the TTY → arrow-key prompt still works (matches old Ink behaviour)echo "" \| cdktn deploy(or any context where stdin is piped / detached) — stderr line "Approval required but stdin is not a TTY. … Stopping." then clean exitChecklist