@oclif/table 0.4.4 → 0.4.6
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 +9 -9
- package/lib/types.d.ts +1 -0
- package/lib/utils.js +9 -9
- package/package.json +11 -11
package/lib/table.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable react/prop-types */
|
|
2
2
|
import cliTruncate from 'cli-truncate';
|
|
3
|
-
import { Box,
|
|
3
|
+
import { Box, render, Text } from 'ink';
|
|
4
4
|
import { EventEmitter } from 'node:events';
|
|
5
5
|
import { env } from 'node:process';
|
|
6
6
|
import { sha1 } from 'object-hash';
|
|
@@ -20,15 +20,15 @@ function determineWidthToUse(columns, maxWidth, width) {
|
|
|
20
20
|
}
|
|
21
21
|
function determineTruncatePosition(overflow) {
|
|
22
22
|
switch (overflow) {
|
|
23
|
+
case 'truncate-end': {
|
|
24
|
+
return 'end';
|
|
25
|
+
}
|
|
23
26
|
case 'truncate-middle': {
|
|
24
27
|
return 'middle';
|
|
25
28
|
}
|
|
26
29
|
case 'truncate-start': {
|
|
27
30
|
return 'start';
|
|
28
31
|
}
|
|
29
|
-
case 'truncate-end': {
|
|
30
|
-
return 'end';
|
|
31
|
-
}
|
|
32
32
|
default: {
|
|
33
33
|
return 'end';
|
|
34
34
|
}
|
|
@@ -110,7 +110,7 @@ export function formatTextWithMargins({ horizontalAlignment, overflow, padding,
|
|
|
110
110
|
...calculateMargins(spaces),
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
|
-
function
|
|
113
|
+
function setupTable(props) {
|
|
114
114
|
const { data, filter, horizontalAlignment = 'left', maxWidth, noStyle = false, overflow = 'truncate', padding = 1, sort, title, verticalAlignment = 'top', width, } = props;
|
|
115
115
|
const headerOptions = noStyle ? {} : { bold: true, color: 'blue', ...props.headerOptions };
|
|
116
116
|
const borderStyle = noStyle ? 'none' : (props.borderStyle ?? 'all');
|
|
@@ -126,10 +126,10 @@ function setup(props) {
|
|
|
126
126
|
headerOptions,
|
|
127
127
|
horizontalAlignment,
|
|
128
128
|
maxWidth: tableWidth ?? determineConfiguredWidth(maxWidth),
|
|
129
|
-
width: tableWidth,
|
|
130
129
|
overflow,
|
|
131
130
|
padding,
|
|
132
131
|
verticalAlignment,
|
|
132
|
+
width: tableWidth,
|
|
133
133
|
};
|
|
134
134
|
const headings = getHeadings(config);
|
|
135
135
|
const columns = getColumns(config, headings);
|
|
@@ -193,9 +193,9 @@ function setup(props) {
|
|
|
193
193
|
};
|
|
194
194
|
}
|
|
195
195
|
export function Table(props) {
|
|
196
|
-
const { columns, config, dataComponent, footerComponent, headerComponent, headerFooterComponent, headingComponent, headings, processedData, separatorComponent, title, titleOptions, } =
|
|
196
|
+
const { columns, config, dataComponent, footerComponent, headerComponent, headerFooterComponent, headingComponent, headings, processedData, separatorComponent, title, titleOptions, } = setupTable(props);
|
|
197
197
|
return (React.createElement(Box, { flexDirection: "column", width: determineWidthToUse(columns, config.maxWidth, config.width) },
|
|
198
|
-
title
|
|
198
|
+
title ? React.createElement(Text, { ...titleOptions }, title) : null,
|
|
199
199
|
headerComponent({ columns, data: {}, key: 'header' }),
|
|
200
200
|
headingComponent({ columns, data: headings, key: 'heading' }),
|
|
201
201
|
headerFooterComponent({ columns, data: {}, key: 'footer' }),
|
|
@@ -310,7 +310,7 @@ class Output {
|
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
312
|
function renderPlainTable(props) {
|
|
313
|
-
const { columns, headings, processedData, title } =
|
|
313
|
+
const { columns, headings, processedData, title } = setupTable(props);
|
|
314
314
|
if (title)
|
|
315
315
|
console.log(title);
|
|
316
316
|
const headerString = columns.reduce((acc, column) => {
|
package/lib/types.d.ts
CHANGED
package/lib/utils.js
CHANGED
|
@@ -146,27 +146,27 @@ export function getHeadings(config) {
|
|
|
146
146
|
if (typeof formatter === 'function')
|
|
147
147
|
return formatter(header);
|
|
148
148
|
switch (formatter) {
|
|
149
|
-
case '
|
|
150
|
-
return
|
|
149
|
+
case 'camelCase': {
|
|
150
|
+
return camelCase(header);
|
|
151
151
|
}
|
|
152
152
|
case 'capitalCase': {
|
|
153
153
|
return capitalCase(header);
|
|
154
154
|
}
|
|
155
|
-
case '
|
|
156
|
-
return
|
|
157
|
-
}
|
|
158
|
-
case 'snakeCase': {
|
|
159
|
-
return snakeCase(header);
|
|
155
|
+
case 'constantCase': {
|
|
156
|
+
return constantCase(header);
|
|
160
157
|
}
|
|
161
158
|
case 'kebabCase': {
|
|
162
159
|
return kebabCase(header);
|
|
163
160
|
}
|
|
164
|
-
case '
|
|
165
|
-
return
|
|
161
|
+
case 'pascalCase': {
|
|
162
|
+
return pascalCase(header);
|
|
166
163
|
}
|
|
167
164
|
case 'sentenceCase': {
|
|
168
165
|
return sentenceCase(header);
|
|
169
166
|
}
|
|
167
|
+
case 'snakeCase': {
|
|
168
|
+
return snakeCase(header);
|
|
169
|
+
}
|
|
170
170
|
default: {
|
|
171
171
|
return header;
|
|
172
172
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oclif/table",
|
|
3
3
|
"description": "Display table in terminal",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.6",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"bugs": "https://github.com/oclif/table/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@oclif/core": "^4",
|
|
9
8
|
"@types/react": "^18.3.12",
|
|
10
9
|
"change-case": "^5.4.4",
|
|
11
10
|
"cli-truncate": "^4.0.0",
|
|
@@ -18,22 +17,23 @@
|
|
|
18
17
|
},
|
|
19
18
|
"devDependencies": {
|
|
20
19
|
"@commitlint/config-conventional": "^19",
|
|
20
|
+
"@eslint/compat": "^1.2.6",
|
|
21
|
+
"@oclif/core": "^4",
|
|
21
22
|
"@oclif/prettier-config": "^0.2.1",
|
|
22
|
-
"@oclif/test": "^4.1.
|
|
23
|
+
"@oclif/test": "^4.1.8",
|
|
23
24
|
"@types/chai": "^4.3.16",
|
|
24
25
|
"@types/mocha": "^10.0.10",
|
|
25
26
|
"@types/node": "^18",
|
|
26
27
|
"@types/object-hash": "^3.0.6",
|
|
27
28
|
"@types/sinon": "^17.0.3",
|
|
28
|
-
"ansis": "^3.
|
|
29
|
+
"ansis": "^3.10.0",
|
|
29
30
|
"chai": "^4.5.0",
|
|
30
31
|
"commitlint": "^19",
|
|
31
|
-
"eslint": "^
|
|
32
|
-
"eslint-config-oclif": "^
|
|
33
|
-
"eslint-config-
|
|
34
|
-
"eslint-config-
|
|
35
|
-
"eslint-config-xo": "^0.
|
|
36
|
-
"eslint-config-xo-react": "^0.27.0",
|
|
32
|
+
"eslint": "^9.19.0",
|
|
33
|
+
"eslint-config-oclif": "^6.0.0",
|
|
34
|
+
"eslint-config-prettier": "^10.0.1",
|
|
35
|
+
"eslint-config-xo": "^0.46.0",
|
|
36
|
+
"eslint-config-xo-react": "^0.28.0",
|
|
37
37
|
"eslint-plugin-react": "^7.37.4",
|
|
38
38
|
"eslint-plugin-react-hooks": "^4.6.2",
|
|
39
39
|
"husky": "^9.1.7",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"build": "shx rm -rf lib && tsc",
|
|
72
72
|
"compile": "tsc",
|
|
73
73
|
"format": "prettier --write \"+(src|test)/**/*.+(ts|js|json)\"",
|
|
74
|
-
"lint": "eslint
|
|
74
|
+
"lint": "eslint",
|
|
75
75
|
"posttest": "yarn lint",
|
|
76
76
|
"prepack": "yarn run build",
|
|
77
77
|
"prepare": "husky",
|