@oclif/table 0.4.9 → 0.4.10
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 +22 -5
- package/package.json +7 -7
package/lib/table.js
CHANGED
|
@@ -330,11 +330,12 @@ function renderPlainTable(props) {
|
|
|
330
330
|
console.log(headerString);
|
|
331
331
|
console.log('-'.repeat(headerString.length));
|
|
332
332
|
for (const row of processedData) {
|
|
333
|
-
|
|
333
|
+
// Process all columns and get their formatted text
|
|
334
|
+
const columnTexts = columns.map((column) => {
|
|
334
335
|
const { horizontalAlignment, overflow, padding, width } = column;
|
|
335
336
|
const value = row[column.column];
|
|
336
337
|
if (value === undefined || value === null) {
|
|
337
|
-
return
|
|
338
|
+
return [' '.repeat(width)]; // Single line of spaces
|
|
338
339
|
}
|
|
339
340
|
const { marginLeft, marginRight, text } = formatTextWithMargins({
|
|
340
341
|
horizontalAlignment,
|
|
@@ -343,9 +344,25 @@ function renderPlainTable(props) {
|
|
|
343
344
|
value,
|
|
344
345
|
width,
|
|
345
346
|
});
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
347
|
+
// Split the formatted text into lines
|
|
348
|
+
const lines = text.split('\n');
|
|
349
|
+
return lines.map((line) => `${' '.repeat(marginLeft)}${line.trimStart()}${' '.repeat(marginRight)}`);
|
|
350
|
+
});
|
|
351
|
+
// Find the maximum number of lines in any column
|
|
352
|
+
const maxLines = Math.max(...columnTexts.map((col) => col.length));
|
|
353
|
+
// Pad all columns to have the same number of lines
|
|
354
|
+
const paddedColumns = columnTexts.map((col, colIndex) => {
|
|
355
|
+
const column = columns[colIndex];
|
|
356
|
+
while (col.length < maxLines) {
|
|
357
|
+
col.push(' '.repeat(column.width)); // Add empty lines
|
|
358
|
+
}
|
|
359
|
+
return col;
|
|
360
|
+
});
|
|
361
|
+
// Print each line of the row
|
|
362
|
+
for (let lineIndex = 0; lineIndex < maxLines; lineIndex++) {
|
|
363
|
+
const lineToPrint = paddedColumns.map((col) => col[lineIndex]).join('');
|
|
364
|
+
console.log(lineToPrint);
|
|
365
|
+
}
|
|
349
366
|
}
|
|
350
367
|
console.log();
|
|
351
368
|
}
|
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.10",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"bugs": "https://github.com/oclif/table/issues",
|
|
7
7
|
"dependencies": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@commitlint/config-conventional": "^19",
|
|
20
|
-
"@eslint/compat": "^1.3.
|
|
20
|
+
"@eslint/compat": "^1.3.1",
|
|
21
21
|
"@oclif/core": "^4",
|
|
22
22
|
"@oclif/prettier-config": "^0.2.1",
|
|
23
23
|
"@oclif/test": "^4.1.13",
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"ansis": "^3.17.0",
|
|
30
30
|
"chai": "^4.5.0",
|
|
31
31
|
"commitlint": "^19",
|
|
32
|
-
"eslint": "^9.
|
|
33
|
-
"eslint-config-oclif": "^6.0.
|
|
34
|
-
"eslint-config-prettier": "^10.1.
|
|
35
|
-
"eslint-config-xo": "^0.
|
|
32
|
+
"eslint": "^9.32.0",
|
|
33
|
+
"eslint-config-oclif": "^6.0.87",
|
|
34
|
+
"eslint-config-prettier": "^10.1.8",
|
|
35
|
+
"eslint-config-xo": "^0.48.0",
|
|
36
36
|
"eslint-config-xo-react": "^0.28.0",
|
|
37
37
|
"eslint-plugin-react": "^7.37.5",
|
|
38
38
|
"eslint-plugin-react-hooks": "^4.6.2",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"ink-testing-library": "^4.0.0",
|
|
41
41
|
"lint-staged": "^15",
|
|
42
42
|
"mocha": "^10.8.2",
|
|
43
|
-
"prettier": "^3.
|
|
43
|
+
"prettier": "^3.6.2",
|
|
44
44
|
"shx": "^0.4.0",
|
|
45
45
|
"sinon": "^18",
|
|
46
46
|
"terminal-link": "^3.0.0",
|