@oclif/table 0.4.7 → 0.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/table.js +3 -3
- package/lib/utils.d.ts +0 -1
- package/lib/utils.js +1 -9
- package/package.json +3 -3
package/lib/table.js
CHANGED
|
@@ -8,7 +8,7 @@ import React from 'react';
|
|
|
8
8
|
import stripAnsi from 'strip-ansi';
|
|
9
9
|
import wrapAnsi from 'wrap-ansi';
|
|
10
10
|
import { BORDER_SKELETONS } from './skeletons.js';
|
|
11
|
-
import { allKeysInCollection, determineConfiguredWidth, determineWidthOfWrappedText, getColumns,
|
|
11
|
+
import { allKeysInCollection, determineConfiguredWidth, determineWidthOfWrappedText, getColumns, getHeadings, intersperse, maybeStripAnsi, shouldUsePlainTable, sortData, } from './utils.js';
|
|
12
12
|
/**
|
|
13
13
|
* Determine the width to use for the table.
|
|
14
14
|
*
|
|
@@ -286,7 +286,7 @@ const createStdout = () => {
|
|
|
286
286
|
// https://github.com/vadimdemedes/ink/blob/v5.0.1/src/ink.tsx#L174
|
|
287
287
|
// This might be a bad idea but it works.
|
|
288
288
|
stdout.rows = 10_000;
|
|
289
|
-
stdout.columns =
|
|
289
|
+
stdout.columns = process.stdout.columns ?? 80;
|
|
290
290
|
const frames = [];
|
|
291
291
|
stdout.write = (data) => {
|
|
292
292
|
frames.push(data);
|
|
@@ -396,7 +396,7 @@ export function printTables(tables, options) {
|
|
|
396
396
|
const output = new Output();
|
|
397
397
|
const leftMargin = options?.marginLeft ?? options?.margin ?? 0;
|
|
398
398
|
const rightMargin = options?.marginRight ?? options?.margin ?? 0;
|
|
399
|
-
const columns =
|
|
399
|
+
const columns = process.stdout.columns - (leftMargin + rightMargin);
|
|
400
400
|
const processed = tables.map((table) => ({
|
|
401
401
|
...table,
|
|
402
402
|
// adjust maxWidth to account for margin and columnGap
|
package/lib/utils.d.ts
CHANGED
|
@@ -11,7 +11,6 @@ export declare function intersperse<T, I>(intersperser: (index: number) => I, el
|
|
|
11
11
|
export declare function sortData<T extends Record<string, unknown>>(data: T[], sort?: Sort<T> | undefined): T[];
|
|
12
12
|
export declare function allKeysInCollection<T extends Record<string, unknown>>(data: T[]): (keyof T)[];
|
|
13
13
|
export declare function determineWidthOfWrappedText(text: string): number;
|
|
14
|
-
export declare function getColumnWidth(): number;
|
|
15
14
|
/**
|
|
16
15
|
* Determines the configured width based on the provided width value.
|
|
17
16
|
* If no width is provided, it returns the width of the current terminal.
|
package/lib/utils.js
CHANGED
|
@@ -42,14 +42,6 @@ export function determineWidthOfWrappedText(text) {
|
|
|
42
42
|
const lines = text.split('\n');
|
|
43
43
|
return lines.reduce((max, line) => Math.max(max, line.length), 0);
|
|
44
44
|
}
|
|
45
|
-
// In certain systems, `process.stdout.columns` can be 0
|
|
46
|
-
// The column width is calculated by:
|
|
47
|
-
// 1. The value of `OCLIF_TABLE_COLUMN_OVERRIDE` (if set)
|
|
48
|
-
// 2. The value of `process.stdout.columns`
|
|
49
|
-
// 3. If `process.stdout.columns` is 0, use 80
|
|
50
|
-
export function getColumnWidth() {
|
|
51
|
-
return Number.parseInt(process.env.OCLIF_TABLE_COLUMN_OVERRIDE || '0', 10) || process.stdout.columns || 80;
|
|
52
|
-
}
|
|
53
45
|
/**
|
|
54
46
|
* Determines the configured width based on the provided width value.
|
|
55
47
|
* If no width is provided, it returns the width of the current terminal.
|
|
@@ -60,7 +52,7 @@ export function getColumnWidth() {
|
|
|
60
52
|
* @param providedWidth - The width value provided.
|
|
61
53
|
* @returns The determined configured width.
|
|
62
54
|
*/
|
|
63
|
-
export function determineConfiguredWidth(providedWidth, columns =
|
|
55
|
+
export function determineConfiguredWidth(providedWidth, columns = process.stdout.columns) {
|
|
64
56
|
if (!providedWidth)
|
|
65
57
|
return columns;
|
|
66
58
|
const num = typeof providedWidth === 'string' && providedWidth.endsWith('%')
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oclif/table",
|
|
3
3
|
"description": "Display table in terminal",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.8",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"bugs": "https://github.com/oclif/table/issues",
|
|
7
7
|
"dependencies": {
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"chai": "^4.5.0",
|
|
31
31
|
"commitlint": "^19",
|
|
32
32
|
"eslint": "^9.24.0",
|
|
33
|
-
"eslint-config-oclif": "^6.0.
|
|
34
|
-
"eslint-config-prettier": "^10.1.
|
|
33
|
+
"eslint-config-oclif": "^6.0.42",
|
|
34
|
+
"eslint-config-prettier": "^10.1.2",
|
|
35
35
|
"eslint-config-xo": "^0.46.0",
|
|
36
36
|
"eslint-config-xo-react": "^0.28.0",
|
|
37
37
|
"eslint-plugin-react": "^7.37.5",
|