Skip to content

Commit ba73f1b

Browse files
iclantonclaude
andauthored
[terminal] Add TerminalTable class; [rush-lib] remove cli-table dependency (#5785)
* [terminal] Add TerminalTable; [rush-lib] replace cli-table dependency 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> * Add changefiles for terminal-table PR Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fixup! Add changefiles for terminal-table PR * Rush update. * fixup! [terminal] Add TerminalTable; [rush-lib] replace cli-table dependency * Add a borderless option. * [terminal] Redesign TerminalTable API: camelCase border names, borderless 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> * fixup! [terminal] Redesign TerminalTable API: camelCase border names, borderless option, getLines() * fixup! Add changefiles for terminal-table PR --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent ea11482 commit ba73f1b

File tree

15 files changed

+503
-79
lines changed

15 files changed

+503
-79
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@microsoft/rush",
5+
"comment": "Replace `cli-table` dependency with `TerminalTable` from `@rushstack/terminal`.",
6+
"type": "patch"
7+
}
8+
],
9+
"packageName": "@microsoft/rush"
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@rushstack/terminal",
5+
"comment": "Add `TerminalTable` class for rendering fixed-column tables in terminal output, with correct handling of ANSI escape sequences when calculating column widths.",
6+
"type": "minor"
7+
}
8+
],
9+
"packageName": "@rushstack/terminal"
10+
}

common/config/rush/nonbrowser-approved-packages.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -614,10 +614,6 @@
614614
"name": "chokidar",
615615
"allowedCategories": [ "libraries" ]
616616
},
617-
{
618-
"name": "cli-table",
619-
"allowedCategories": [ "libraries" ]
620-
},
621617
{
622618
"name": "compression",
623619
"allowedCategories": [ "libraries" ]

common/config/subspaces/build-tests-subspace/pnpm-lock.yaml

Lines changed: 5 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// DO NOT MODIFY THIS FILE MANUALLY BUT DO COMMIT IT. It is generated and used by Rush.
22
{
3-
"pnpmShrinkwrapHash": "67e1e1974c3a01231385fd6e8e3b892a4f3729dd",
3+
"pnpmShrinkwrapHash": "72fae9b780cca1f45b7c807b24a587a13f1719e6",
44
"preferredVersionsHash": "550b4cee0bef4e97db6c6aad726df5149d20e7d9",
5-
"packageJsonInjectedDependenciesHash": "157a943794dbd83c14beb27a57db03705eb04aa6"
5+
"packageJsonInjectedDependenciesHash": "258293487508f4a9172933cb6d0c90a02599bd8d"
66
}

common/config/subspaces/default/pnpm-lock.yaml

Lines changed: 0 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// DO NOT MODIFY THIS FILE MANUALLY BUT DO COMMIT IT. It is generated and used by Rush.
22
{
3-
"pnpmShrinkwrapHash": "e329020e3621437b0039842e5440d019c5315c14",
3+
"pnpmShrinkwrapHash": "f41b01db5e94d65ef640cb5e6eb9dce1780f93c6",
44
"preferredVersionsHash": "029c99bd6e65c5e1f25e2848340509811ff9753c"
55
}

common/reviews/api/terminal.api.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,33 @@ export interface ITerminalStreamWritableOptions {
246246
writableOptions?: WritableOptions;
247247
}
248248

249+
// @public
250+
export interface ITerminalTableChars {
251+
bottom: string;
252+
bottomCenter: string;
253+
bottomLeft: string;
254+
bottomRight: string;
255+
centerCenter: string;
256+
horizontalCenter: string;
257+
left: string;
258+
leftCenter: string;
259+
right: string;
260+
rightCenter: string;
261+
top: string;
262+
topCenter: string;
263+
topLeft: string;
264+
topRight: string;
265+
verticalCenter: string;
266+
}
267+
268+
// @public
269+
export interface ITerminalTableOptions {
270+
borderCharacters?: Partial<ITerminalTableChars>;
271+
borderless?: boolean;
272+
colWidths?: number[];
273+
head?: string[];
274+
}
275+
249276
// @public
250277
export interface ITerminalTransformOptions extends ITerminalWritableOptions {
251278
destination: TerminalWritable;
@@ -459,6 +486,15 @@ export class TerminalStreamWritable extends Writable {
459486
_write(chunk: string | Buffer | Uint8Array, encoding: string, callback: (error?: Error | null) => void): void;
460487
}
461488

489+
// @public
490+
export class TerminalTable {
491+
constructor(options?: ITerminalTableOptions);
492+
// (undocumented)
493+
getLines(): string[];
494+
push(...rows: string[][]): void;
495+
toString(): string;
496+
}
497+
462498
// @public
463499
export abstract class TerminalTransform extends TerminalWritable {
464500
constructor(options: ITerminalTransformOptions);

libraries/rush-lib/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
"@rushstack/ts-command-line": "workspace:*",
5959
"@yarnpkg/lockfile": "~1.0.2",
6060
"builtin-modules": "~3.1.0",
61-
"cli-table": "~0.3.1",
6261
"dependency-path": "~9.2.8",
6362
"dotenv": "~16.4.7",
6463
"fast-glob": "~3.3.1",
@@ -91,7 +90,6 @@
9190
"@rushstack/operation-graph": "workspace:*",
9291
"@rushstack/webpack-deep-imports-plugin": "workspace:*",
9392
"@rushstack/webpack-preserve-dynamic-require-plugin": "workspace:*",
94-
"@types/cli-table": "0.3.0",
9593
"@types/js-yaml": "4.0.9",
9694
"@types/npm-package-arg": "6.1.0",
9795
"@types/object-hash": "~3.0.6",

libraries/rush-lib/src/cli/actions/ListAction.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// See LICENSE in the project root for license information.
33

44
import { Sort } from '@rushstack/node-core-library';
5-
import { ConsoleTerminalProvider, Terminal } from '@rushstack/terminal';
5+
import { ConsoleTerminalProvider, Terminal, TerminalTable } from '@rushstack/terminal';
66
import type { CommandLineFlagParameter } from '@rushstack/ts-command-line';
77

88
import { BaseRushAction } from './BaseRushAction';
@@ -220,8 +220,7 @@ export class ListAction extends BaseRushAction {
220220
tableHeader.push('Tags');
221221
}
222222

223-
const { default: CliTable } = await import('cli-table');
224-
const table: import('cli-table') = new CliTable({
223+
const table: TerminalTable = new TerminalTable({
225224
head: tableHeader
226225
});
227226

0 commit comments

Comments
 (0)