Skip to content

[terminal] Add TerminalTable class; [rush-lib] remove cli-table dependency#5785

Merged
iclanton merged 9 commits intomicrosoft:mainfrom
iclanton:terminal-table
Apr 18, 2026
Merged

[terminal] Add TerminalTable class; [rush-lib] remove cli-table dependency#5785
iclanton merged 9 commits intomicrosoft:mainfrom
iclanton:terminal-table

Conversation

@iclanton
Copy link
Copy Markdown
Member

Summary

Adds a new TerminalTable class to @rushstack/terminal for rendering fixed-column tables in terminal output, then uses it in @microsoft/rush to eliminate the cli-table npm dependency.

The new class correctly handles ANSI escape sequences when calculating column widths (the existing cli-table package inflates column widths when cells contain colored text).

Details

@rushstack/terminal — new TerminalTable class:

  • Constructor accepts head, colWidths, borderless, and borderCharacters options
  • borderless: true suppresses all border lines (convenient for inquirer-style choice lists)
  • borderCharacters accepts partial overrides of individual border characters
  • getLines(): string[] and toString(): string render methods
  • Uses AnsiEscape.removeCodes() for ANSI-aware visual width calculation
  • Unicode box-drawing characters as defaults

@microsoft/rush — removes cli-table dependency:

  • InteractiveUpgradeUI.ts: replaces CliTable with TerminalTable({ borderless: true, ... })
  • ListAction.ts: replaces dynamic import('cli-table') with TerminalTable
  • Removes cli-table and @types/cli-table from rush-lib/package.json
  • Removes cli-table from nonbrowser-approved-packages.json

How it was tested

Unit tests added for TerminalTable covering: header + rows, no header, auto-sized columns, fixed colWidths, borderless mode, single-line-per-row behavior in borderless mode, borderCharacters overrides on top of borderless, ANSI stripping, and empty table.

iclanton and others added 9 commits April 17, 2026 17:36
Add TerminalTable to @rushstack/terminal as a drop-in replacement for
the cli-table and cli-table3 npm packages. Handles ANSI escape sequences
when calculating column widths, and matches the chars/head/colWidths
constructor API used by both packages.

Replace cli-table usage in rush-lib (ListAction, InteractiveUpgradeUI)
with TerminalTable, and remove the cli-table dependency.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…less option, getLines()

- Rename all ITerminalTableChars members from kebab-case to camelCase
- Rename `chars` option to `borderCharacters`
- Add `borderless: true` shorthand (replaces verbose empty-string chars override)
- Add `getLines(): string[]` method
- Add JSDoc to ITerminalTableChars members with visual reference diagram
- Update tests and snapshots

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@octogonz octogonz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@iclanton iclanton merged commit ba73f1b into microsoft:main Apr 18, 2026
6 checks passed
@github-project-automation github-project-automation bot moved this from Needs triage to Closed in Bug Triage Apr 18, 2026
@iclanton iclanton deleted the terminal-table branch April 18, 2026 01:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

2 participants