@oclif/core 3.26.6 → 4.0.0-beta.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/args.d.ts +4 -4
- package/lib/cache.d.ts +3 -3
- package/lib/cache.js +1 -1
- package/lib/command.d.ts +18 -18
- package/lib/command.js +12 -21
- package/lib/config/config.d.ts +14 -40
- package/lib/config/config.js +120 -153
- package/lib/config/plugin-loader.d.ts +6 -6
- package/lib/config/plugin-loader.js +4 -28
- package/lib/config/plugin.d.ts +3 -3
- package/lib/config/plugin.js +7 -11
- package/lib/config/ts-path.d.ts +1 -1
- package/lib/config/ts-path.js +1 -2
- package/lib/config/util.d.ts +1 -1
- package/lib/config/util.js +5 -21
- package/lib/errors/error.js +5 -8
- package/lib/errors/errors/cli.d.ts +5 -5
- package/lib/errors/errors/cli.js +5 -5
- package/lib/errors/errors/pretty-print.d.ts +2 -2
- package/lib/errors/errors/pretty-print.js +2 -2
- package/lib/errors/exit.d.ts +1 -0
- package/lib/errors/exit.js +8 -0
- package/lib/errors/handle.js +4 -11
- package/lib/errors/index.d.ts +1 -3
- package/lib/errors/index.js +5 -12
- package/lib/errors/warn.d.ts +5 -0
- package/lib/errors/warn.js +10 -5
- package/lib/execute.js +1 -1
- package/lib/flags.d.ts +4 -4
- package/lib/{cli-ux/flush.js → flush.js} +2 -2
- package/lib/help/command.js +6 -5
- package/lib/help/formatter.d.ts +3 -3
- package/lib/help/formatter.js +8 -9
- package/lib/help/index.d.ts +1 -0
- package/lib/help/index.js +23 -17
- package/lib/help/root.js +3 -3
- package/lib/index.d.ts +6 -7
- package/lib/index.js +8 -12
- package/lib/interfaces/config.d.ts +9 -20
- package/lib/interfaces/errors.d.ts +5 -5
- package/lib/interfaces/flags.d.ts +2 -2
- package/lib/interfaces/index.d.ts +2 -1
- package/lib/interfaces/logger.d.ts +9 -0
- package/lib/interfaces/parser.d.ts +6 -6
- package/lib/interfaces/pjson.d.ts +217 -151
- package/lib/interfaces/plugin.d.ts +26 -24
- package/lib/interfaces/theme.d.ts +30 -19
- package/lib/interfaces/theme.js +2 -19
- package/lib/interfaces/topic.d.ts +2 -2
- package/lib/logger.d.ts +14 -0
- package/lib/logger.js +90 -0
- package/lib/main.js +5 -3
- package/lib/parser/errors.d.ts +1 -1
- package/lib/parser/errors.js +5 -5
- package/lib/parser/help.js +2 -2
- package/lib/parser/parse.js +2 -1
- package/lib/performance.js +3 -2
- package/lib/settings.d.ts +5 -11
- package/lib/util/determine-priority.d.ts +21 -0
- package/lib/util/determine-priority.js +55 -0
- package/lib/util/find-root.d.ts +1 -0
- package/lib/util/find-root.js +19 -19
- package/lib/util/fs.js +12 -0
- package/lib/util/ids.d.ts +1 -1
- package/lib/util/read-pjson.d.ts +7 -0
- package/lib/util/read-pjson.js +60 -0
- package/lib/util/read-tsconfig.js +3 -8
- package/lib/{cli-ux → ux}/action/base.d.ts +5 -7
- package/lib/{cli-ux → ux}/action/base.js +0 -3
- package/lib/{cli-ux → ux}/action/spinner.d.ts +5 -4
- package/lib/{cli-ux → ux}/action/spinner.js +16 -39
- package/lib/ux/action/types.d.ts +5 -0
- package/lib/ux/action/types.js +2 -0
- package/lib/ux/colorize-json.d.ts +28 -0
- package/lib/ux/colorize-json.js +67 -0
- package/lib/ux/index.d.ts +69 -0
- package/lib/ux/index.js +88 -0
- package/lib/{cli-ux → ux}/list.d.ts +1 -1
- package/lib/{cli-ux → ux}/list.js +1 -2
- package/lib/ux/theme.d.ts +9 -0
- package/lib/ux/theme.js +43 -0
- package/lib/ux/write.d.ts +2 -0
- package/lib/ux/write.js +22 -0
- package/package.json +37 -42
- package/flush.d.ts +0 -3
- package/flush.js +0 -1
- package/handle.js +0 -1
- package/lib/cli-ux/action/spinners.d.ts +0 -251
- package/lib/cli-ux/action/spinners.js +0 -374
- package/lib/cli-ux/action/types.d.ts +0 -5
- package/lib/cli-ux/config.d.ts +0 -25
- package/lib/cli-ux/config.js +0 -52
- package/lib/cli-ux/exit.d.ts +0 -8
- package/lib/cli-ux/exit.js +0 -16
- package/lib/cli-ux/index.d.ts +0 -133
- package/lib/cli-ux/index.js +0 -183
- package/lib/cli-ux/prompt.d.ts +0 -32
- package/lib/cli-ux/prompt.js +0 -185
- package/lib/cli-ux/stream.d.ts +0 -23
- package/lib/cli-ux/stream.js +0 -43
- package/lib/cli-ux/styled/index.d.ts +0 -4
- package/lib/cli-ux/styled/index.js +0 -36
- package/lib/cli-ux/styled/object.d.ts +0 -1
- package/lib/cli-ux/styled/object.js +0 -39
- package/lib/cli-ux/styled/progress.d.ts +0 -2
- package/lib/cli-ux/styled/progress.js +0 -8
- package/lib/cli-ux/styled/table.d.ts +0 -45
- package/lib/cli-ux/styled/table.js +0 -345
- package/lib/cli-ux/styled/tree.d.ts +0 -9
- package/lib/cli-ux/styled/tree.js +0 -37
- package/lib/cli-ux/theme.d.ts +0 -11
- package/lib/cli-ux/theme.js +0 -61
- package/lib/cli-ux/wait.d.ts +0 -2
- package/lib/cli-ux/wait.js +0 -5
- package/lib/cli-ux/write.d.ts +0 -8
- package/lib/cli-ux/write.js +0 -15
- package/lib/errors/config.d.ts +0 -6
- package/lib/errors/config.js +0 -38
- package/lib/errors/logger.d.ts +0 -8
- package/lib/errors/logger.js +0 -45
- /package/lib/{cli-ux/flush.d.ts → flush.d.ts} +0 -0
- /package/lib/{cli-ux/action/types.js → interfaces/logger.js} +0 -0
- /package/lib/{cli-ux → ux}/action/simple.d.ts +0 -0
- /package/lib/{cli-ux → ux}/action/simple.js +0 -0
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.table = void 0;
|
|
30
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
31
|
-
const js_yaml_1 = require("js-yaml");
|
|
32
|
-
const natural_orderby_1 = require("natural-orderby");
|
|
33
|
-
const node_util_1 = require("node:util");
|
|
34
|
-
const slice_ansi_1 = __importDefault(require("slice-ansi"));
|
|
35
|
-
const string_width_1 = __importDefault(require("string-width"));
|
|
36
|
-
const F = __importStar(require("../../flags"));
|
|
37
|
-
const screen_1 = require("../../screen");
|
|
38
|
-
const util_1 = require("../../util/util");
|
|
39
|
-
const write_1 = __importDefault(require("../write"));
|
|
40
|
-
/**
|
|
41
|
-
* @deprecated `ux` will be removed in the next major. See https://github.com/oclif/core/discussions/999
|
|
42
|
-
*/
|
|
43
|
-
class Table {
|
|
44
|
-
data;
|
|
45
|
-
columns;
|
|
46
|
-
options;
|
|
47
|
-
constructor(data, columns, options = {}) {
|
|
48
|
-
this.data = data;
|
|
49
|
-
// assign columns
|
|
50
|
-
this.columns = Object.keys(columns).map((key) => {
|
|
51
|
-
const col = columns[key];
|
|
52
|
-
const extended = col.extended ?? false;
|
|
53
|
-
// turn null and undefined into empty strings by default
|
|
54
|
-
const get = col.get ?? ((row) => row[key] ?? '');
|
|
55
|
-
const header = typeof col.header === 'string' ? col.header : (0, util_1.capitalize)(key.replaceAll('_', ' '));
|
|
56
|
-
const minWidth = Math.max(col.minWidth ?? 0, (0, string_width_1.default)(header) + 1);
|
|
57
|
-
return {
|
|
58
|
-
extended,
|
|
59
|
-
get,
|
|
60
|
-
header,
|
|
61
|
-
key,
|
|
62
|
-
minWidth,
|
|
63
|
-
};
|
|
64
|
-
});
|
|
65
|
-
// assign options
|
|
66
|
-
const { columns: cols, csv, extended, filter, output, printLine, sort, title } = options;
|
|
67
|
-
this.options = {
|
|
68
|
-
columns: cols,
|
|
69
|
-
extended,
|
|
70
|
-
filter,
|
|
71
|
-
'no-header': options['no-header'] ?? false,
|
|
72
|
-
'no-truncate': options['no-truncate'] ?? false,
|
|
73
|
-
output: csv ? 'csv' : output,
|
|
74
|
-
printLine: printLine ?? ((s) => write_1.default.stdout(s + '\n')),
|
|
75
|
-
rowStart: ' ',
|
|
76
|
-
sort,
|
|
77
|
-
title,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
display() {
|
|
81
|
-
// build table rows from input array data
|
|
82
|
-
let rows = this.data.map((d) => {
|
|
83
|
-
const row = {};
|
|
84
|
-
for (const col of this.columns) {
|
|
85
|
-
let val = col.get(d);
|
|
86
|
-
if (typeof val !== 'string')
|
|
87
|
-
val = (0, node_util_1.inspect)(val, { breakLength: Number.POSITIVE_INFINITY });
|
|
88
|
-
row[col.key] = val;
|
|
89
|
-
}
|
|
90
|
-
return row;
|
|
91
|
-
});
|
|
92
|
-
// filter rows
|
|
93
|
-
if (this.options.filter) {
|
|
94
|
-
let [header, regex] = this.options.filter.split('=');
|
|
95
|
-
const isNot = header[0] === '-';
|
|
96
|
-
if (isNot)
|
|
97
|
-
header = header.slice(1);
|
|
98
|
-
const col = this.findColumnFromHeader(header);
|
|
99
|
-
if (!col || !regex)
|
|
100
|
-
throw new Error('Filter flag has an invalid value');
|
|
101
|
-
rows = rows.filter((d) => {
|
|
102
|
-
const re = new RegExp(regex);
|
|
103
|
-
const val = d[col.key];
|
|
104
|
-
const match = val.match(re);
|
|
105
|
-
return isNot ? !match : match;
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
// sort rows
|
|
109
|
-
if (this.options.sort) {
|
|
110
|
-
const sorters = this.options.sort.split(',');
|
|
111
|
-
const sortHeaders = sorters.map((k) => (k[0] === '-' ? k.slice(1) : k));
|
|
112
|
-
const sortKeys = this.filterColumnsFromHeaders(sortHeaders).map((c) => (v) => v[c.key]);
|
|
113
|
-
const sortKeysOrder = sorters.map((k) => (k[0] === '-' ? 'desc' : 'asc'));
|
|
114
|
-
rows = (0, natural_orderby_1.orderBy)(rows, sortKeys, sortKeysOrder);
|
|
115
|
-
}
|
|
116
|
-
// and filter columns
|
|
117
|
-
if (this.options.columns) {
|
|
118
|
-
const filters = this.options.columns.split(',');
|
|
119
|
-
this.columns = this.filterColumnsFromHeaders(filters);
|
|
120
|
-
}
|
|
121
|
-
else if (!this.options.extended) {
|
|
122
|
-
// show extended columns/properties
|
|
123
|
-
this.columns = this.columns.filter((c) => !c.extended);
|
|
124
|
-
}
|
|
125
|
-
this.data = rows;
|
|
126
|
-
switch (this.options.output) {
|
|
127
|
-
case 'csv': {
|
|
128
|
-
this.outputCSV();
|
|
129
|
-
break;
|
|
130
|
-
}
|
|
131
|
-
case 'json': {
|
|
132
|
-
this.outputJSON();
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
case 'yaml': {
|
|
136
|
-
this.outputYAML();
|
|
137
|
-
break;
|
|
138
|
-
}
|
|
139
|
-
default: {
|
|
140
|
-
this.outputTable();
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
filterColumnsFromHeaders(filters) {
|
|
145
|
-
// unique
|
|
146
|
-
filters = [...new Set(filters)];
|
|
147
|
-
const cols = [];
|
|
148
|
-
for (const f of filters) {
|
|
149
|
-
const c = this.columns.find((c) => c.header.toLowerCase() === f.toLowerCase());
|
|
150
|
-
if (c)
|
|
151
|
-
cols.push(c);
|
|
152
|
-
}
|
|
153
|
-
return cols;
|
|
154
|
-
}
|
|
155
|
-
findColumnFromHeader(header) {
|
|
156
|
-
return this.columns.find((c) => c.header.toLowerCase() === header.toLowerCase());
|
|
157
|
-
}
|
|
158
|
-
getCSVRow(d) {
|
|
159
|
-
const values = this.columns.map((col) => d[col.key] || '');
|
|
160
|
-
const lineToBeEscaped = values.find((e) => e.includes('"') || e.includes('\n') || e.includes('\r\n') || e.includes('\r') || e.includes(','));
|
|
161
|
-
return values.map((e) => (lineToBeEscaped ? `"${e.replaceAll('"', '""')}"` : e));
|
|
162
|
-
}
|
|
163
|
-
outputCSV() {
|
|
164
|
-
const { columns, data, options } = this;
|
|
165
|
-
if (!options['no-header']) {
|
|
166
|
-
options.printLine(columns.map((c) => c.header).join(','));
|
|
167
|
-
}
|
|
168
|
-
for (const d of data) {
|
|
169
|
-
const row = this.getCSVRow(d);
|
|
170
|
-
options.printLine(row.join(','));
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
outputJSON() {
|
|
174
|
-
this.options.printLine(JSON.stringify(this.resolveColumnsToObjectArray(), undefined, 2));
|
|
175
|
-
}
|
|
176
|
-
outputTable() {
|
|
177
|
-
const { data, options } = this;
|
|
178
|
-
// column truncation
|
|
179
|
-
//
|
|
180
|
-
// find max width for each column
|
|
181
|
-
const columns = this.columns.map((c) => {
|
|
182
|
-
const maxWidth = Math.max((0, string_width_1.default)('.'.padEnd(c.minWidth - 1)), (0, string_width_1.default)(c.header), getWidestColumnWith(data, c.key)) + 1;
|
|
183
|
-
return {
|
|
184
|
-
...c,
|
|
185
|
-
maxWidth,
|
|
186
|
-
width: maxWidth,
|
|
187
|
-
};
|
|
188
|
-
});
|
|
189
|
-
// terminal width
|
|
190
|
-
const maxWidth = screen_1.stdtermwidth - 2;
|
|
191
|
-
// truncation logic
|
|
192
|
-
const shouldShorten = () => {
|
|
193
|
-
// don't shorten if full mode
|
|
194
|
-
if (options['no-truncate'] || (!process.stdout.isTTY && !process.env.CLI_UX_SKIP_TTY_CHECK))
|
|
195
|
-
return;
|
|
196
|
-
// don't shorten if there is enough screen width
|
|
197
|
-
const dataMaxWidth = (0, util_1.sumBy)(columns, (c) => c.width);
|
|
198
|
-
const overWidth = dataMaxWidth - maxWidth;
|
|
199
|
-
if (overWidth <= 0)
|
|
200
|
-
return;
|
|
201
|
-
// not enough room, short all columns to minWidth
|
|
202
|
-
for (const col of columns) {
|
|
203
|
-
col.width = col.minWidth;
|
|
204
|
-
}
|
|
205
|
-
// if sum(minWidth's) is greater than term width
|
|
206
|
-
// nothing can be done so
|
|
207
|
-
// display all as minWidth
|
|
208
|
-
const dataMinWidth = (0, util_1.sumBy)(columns, (c) => c.minWidth);
|
|
209
|
-
if (dataMinWidth >= maxWidth)
|
|
210
|
-
return;
|
|
211
|
-
// some wiggle room left, add it back to "needy" columns
|
|
212
|
-
let wiggleRoom = maxWidth - dataMinWidth;
|
|
213
|
-
const needyCols = columns
|
|
214
|
-
.map((c) => ({ key: c.key, needs: c.maxWidth - c.width }))
|
|
215
|
-
.sort((a, b) => a.needs - b.needs);
|
|
216
|
-
for (const { key, needs } of needyCols) {
|
|
217
|
-
if (!needs)
|
|
218
|
-
continue;
|
|
219
|
-
const col = columns.find((c) => key === c.key);
|
|
220
|
-
if (!col)
|
|
221
|
-
continue;
|
|
222
|
-
if (wiggleRoom > needs) {
|
|
223
|
-
col.width = col.width + needs;
|
|
224
|
-
wiggleRoom -= needs;
|
|
225
|
-
}
|
|
226
|
-
else if (wiggleRoom) {
|
|
227
|
-
col.width = col.width + wiggleRoom;
|
|
228
|
-
wiggleRoom = 0;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
};
|
|
232
|
-
shouldShorten();
|
|
233
|
-
// print table title
|
|
234
|
-
if (options.title) {
|
|
235
|
-
options.printLine(options.title);
|
|
236
|
-
// print title divider
|
|
237
|
-
options.printLine(''.padEnd(columns.reduce((sum, col) => sum + col.width, 1), '='));
|
|
238
|
-
options.rowStart = '| ';
|
|
239
|
-
}
|
|
240
|
-
// print headers
|
|
241
|
-
if (!options['no-header']) {
|
|
242
|
-
let headers = options.rowStart;
|
|
243
|
-
for (const col of columns) {
|
|
244
|
-
const header = col.header;
|
|
245
|
-
headers += header.padEnd(col.width);
|
|
246
|
-
}
|
|
247
|
-
options.printLine(chalk_1.default.bold(headers));
|
|
248
|
-
// print header dividers
|
|
249
|
-
let dividers = options.rowStart;
|
|
250
|
-
for (const col of columns) {
|
|
251
|
-
const divider = ''.padEnd(col.width - 1, '─') + ' ';
|
|
252
|
-
dividers += divider.padEnd(col.width);
|
|
253
|
-
}
|
|
254
|
-
options.printLine(chalk_1.default.bold(dividers));
|
|
255
|
-
}
|
|
256
|
-
// print rows
|
|
257
|
-
for (const row of data) {
|
|
258
|
-
// find max number of lines
|
|
259
|
-
// for all cells in a row
|
|
260
|
-
// with multi-line strings
|
|
261
|
-
let numOfLines = 1;
|
|
262
|
-
for (const col of columns) {
|
|
263
|
-
const d = row[col.key];
|
|
264
|
-
const lines = d.split('\n').length;
|
|
265
|
-
if (lines > numOfLines)
|
|
266
|
-
numOfLines = lines;
|
|
267
|
-
}
|
|
268
|
-
// eslint-disable-next-line unicorn/no-new-array
|
|
269
|
-
const linesIndexess = [...new Array(numOfLines).keys()];
|
|
270
|
-
// print row
|
|
271
|
-
// including multi-lines
|
|
272
|
-
for (const i of linesIndexess) {
|
|
273
|
-
let l = options.rowStart;
|
|
274
|
-
for (const col of columns) {
|
|
275
|
-
const width = col.width;
|
|
276
|
-
let d = row[col.key];
|
|
277
|
-
d = d.split('\n')[i] || '';
|
|
278
|
-
const visualWidth = (0, string_width_1.default)(d);
|
|
279
|
-
const colorWidth = d.length - visualWidth;
|
|
280
|
-
let cell = d.padEnd(width + colorWidth);
|
|
281
|
-
if (cell.length - colorWidth > width || visualWidth === width) {
|
|
282
|
-
// truncate the cell, preserving ANSI escape sequences, and keeping
|
|
283
|
-
// into account the width of fullwidth unicode characters
|
|
284
|
-
cell = (0, slice_ansi_1.default)(cell, 0, width - 2) + '… ';
|
|
285
|
-
// pad with spaces; this is necessary in case the original string
|
|
286
|
-
// contained fullwidth characters which cannot be split
|
|
287
|
-
cell += ' '.repeat(width - (0, string_width_1.default)(cell));
|
|
288
|
-
}
|
|
289
|
-
l += cell;
|
|
290
|
-
}
|
|
291
|
-
options.printLine(l);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
outputYAML() {
|
|
296
|
-
this.options.printLine((0, js_yaml_1.safeDump)(this.resolveColumnsToObjectArray()));
|
|
297
|
-
}
|
|
298
|
-
resolveColumnsToObjectArray() {
|
|
299
|
-
const { columns, data } = this;
|
|
300
|
-
return data.map((d) => Object.fromEntries(columns.map((col) => [col.key, d[col.key] ?? ''])));
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
function table(data, columns, options = {}) {
|
|
304
|
-
new Table(data, columns, options).display();
|
|
305
|
-
}
|
|
306
|
-
exports.table = table;
|
|
307
|
-
(function (table) {
|
|
308
|
-
table.Flags = {
|
|
309
|
-
columns: F.string({ description: 'only show provided columns (comma-separated)', exclusive: ['extended'] }),
|
|
310
|
-
csv: F.boolean({ description: 'output is csv format [alias: --output=csv]', exclusive: ['no-truncate'] }),
|
|
311
|
-
extended: F.boolean({ char: 'x', description: 'show extra columns', exclusive: ['columns'] }),
|
|
312
|
-
filter: F.string({ description: 'filter property by partial string matching, ex: name=foo' }),
|
|
313
|
-
'no-header': F.boolean({ description: 'hide table header from output', exclusive: ['csv'] }),
|
|
314
|
-
'no-truncate': F.boolean({ description: 'do not truncate output to fit screen', exclusive: ['csv'] }),
|
|
315
|
-
output: F.string({
|
|
316
|
-
description: 'output in a more machine friendly format',
|
|
317
|
-
exclusive: ['no-truncate', 'csv'],
|
|
318
|
-
options: ['csv', 'json', 'yaml'],
|
|
319
|
-
}),
|
|
320
|
-
sort: F.string({ description: "property to sort by (prepend '-' for descending)" }),
|
|
321
|
-
};
|
|
322
|
-
function flags(opts) {
|
|
323
|
-
if (opts) {
|
|
324
|
-
const f = {};
|
|
325
|
-
const o = (opts.only && typeof opts.only === 'string' ? [opts.only] : opts.only) || Object.keys(table.Flags);
|
|
326
|
-
const e = (opts.except && typeof opts.except === 'string' ? [opts.except] : opts.except) || [];
|
|
327
|
-
for (const key of o) {
|
|
328
|
-
if (!e.includes(key)) {
|
|
329
|
-
;
|
|
330
|
-
f[key] = table.Flags[key];
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
return f;
|
|
334
|
-
}
|
|
335
|
-
return table.Flags;
|
|
336
|
-
}
|
|
337
|
-
table.flags = flags;
|
|
338
|
-
})(table || (exports.table = table = {}));
|
|
339
|
-
const getWidestColumnWith = (data, columnKey) => data.reduce((previous, current) => {
|
|
340
|
-
const d = current[columnKey];
|
|
341
|
-
// convert multi-line cell to single longest line
|
|
342
|
-
// for width calculations
|
|
343
|
-
const manyLines = d.split('\n');
|
|
344
|
-
return Math.max(previous, manyLines.length > 1 ? Math.max(...manyLines.map((r) => (0, string_width_1.default)(r))) : (0, string_width_1.default)(d));
|
|
345
|
-
}, 0);
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Tree = void 0;
|
|
4
|
-
const treeify = require('object-treeify');
|
|
5
|
-
class Tree {
|
|
6
|
-
nodes = {};
|
|
7
|
-
display(logger = console.log) {
|
|
8
|
-
const addNodes = function (nodes) {
|
|
9
|
-
const tree = {};
|
|
10
|
-
for (const p of Object.keys(nodes)) {
|
|
11
|
-
tree[p] = addNodes(nodes[p].nodes);
|
|
12
|
-
}
|
|
13
|
-
return tree;
|
|
14
|
-
};
|
|
15
|
-
const tree = addNodes(this.nodes);
|
|
16
|
-
logger(treeify(tree));
|
|
17
|
-
}
|
|
18
|
-
insert(child, value = new Tree()) {
|
|
19
|
-
this.nodes[child] = value;
|
|
20
|
-
return this;
|
|
21
|
-
}
|
|
22
|
-
search(key) {
|
|
23
|
-
for (const child of Object.keys(this.nodes)) {
|
|
24
|
-
if (child === key) {
|
|
25
|
-
return this.nodes[child];
|
|
26
|
-
}
|
|
27
|
-
const c = this.nodes[child].search(key);
|
|
28
|
-
if (c)
|
|
29
|
-
return c;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.Tree = Tree;
|
|
34
|
-
function tree() {
|
|
35
|
-
return new Tree();
|
|
36
|
-
}
|
|
37
|
-
exports.default = tree;
|
package/lib/cli-ux/theme.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { StandardChalk, Theme } from '../interfaces/theme';
|
|
2
|
-
/**
|
|
3
|
-
* Add color to text.
|
|
4
|
-
* @param color color to use. Can be hex code (e.g. `#ff0000`), rgb (e.g. `rgb(255, 255, 255)`) or a chalk color (e.g. `red`)
|
|
5
|
-
* @param text string to colorize
|
|
6
|
-
* @returns colorized string
|
|
7
|
-
*/
|
|
8
|
-
export declare function colorize(color: string | StandardChalk | undefined, text: string): string;
|
|
9
|
-
export declare function parseTheme(theme: Record<string, string>): Theme;
|
|
10
|
-
export declare function getColor(color: string): string;
|
|
11
|
-
export declare function getColor(color: StandardChalk): StandardChalk;
|
package/lib/cli-ux/theme.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.getColor = exports.parseTheme = exports.colorize = void 0;
|
|
30
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
31
|
-
const Color = __importStar(require("color"));
|
|
32
|
-
const theme_1 = require("../interfaces/theme");
|
|
33
|
-
function isStandardChalk(color) {
|
|
34
|
-
return theme_1.STANDARD_CHALK.includes(color);
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Add color to text.
|
|
38
|
-
* @param color color to use. Can be hex code (e.g. `#ff0000`), rgb (e.g. `rgb(255, 255, 255)`) or a chalk color (e.g. `red`)
|
|
39
|
-
* @param text string to colorize
|
|
40
|
-
* @returns colorized string
|
|
41
|
-
*/
|
|
42
|
-
function colorize(color, text) {
|
|
43
|
-
if (isStandardChalk(color))
|
|
44
|
-
return chalk_1.default[color](text);
|
|
45
|
-
return color ? chalk_1.default.hex(color)(text) : text;
|
|
46
|
-
}
|
|
47
|
-
exports.colorize = colorize;
|
|
48
|
-
function parseTheme(theme) {
|
|
49
|
-
return Object.fromEntries(Object.entries(theme)
|
|
50
|
-
.map(([key, value]) => [key, getColor(value)])
|
|
51
|
-
.filter(([_, value]) => value));
|
|
52
|
-
}
|
|
53
|
-
exports.parseTheme = parseTheme;
|
|
54
|
-
function getColor(color) {
|
|
55
|
-
try {
|
|
56
|
-
// eslint-disable-next-line new-cap
|
|
57
|
-
return isStandardChalk(color) ? color : new Color.default(color).hex();
|
|
58
|
-
}
|
|
59
|
-
catch { }
|
|
60
|
-
}
|
|
61
|
-
exports.getColor = getColor;
|
package/lib/cli-ux/wait.d.ts
DELETED
package/lib/cli-ux/wait.js
DELETED
package/lib/cli-ux/write.d.ts
DELETED
package/lib/cli-ux/write.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const stdout = (msg) => {
|
|
4
|
-
process.stdout.write(msg);
|
|
5
|
-
};
|
|
6
|
-
const stderr = (msg) => {
|
|
7
|
-
process.stderr.write(msg);
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* @deprecated `ux` will be removed in the next major. See https://github.com/oclif/core/discussions/999
|
|
11
|
-
*/
|
|
12
|
-
exports.default = {
|
|
13
|
-
stderr,
|
|
14
|
-
stdout,
|
|
15
|
-
};
|
package/lib/errors/config.d.ts
DELETED
package/lib/errors/config.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.config = void 0;
|
|
4
|
-
const settings_1 = require("../settings");
|
|
5
|
-
const logger_1 = require("./logger");
|
|
6
|
-
function displayWarnings() {
|
|
7
|
-
if (process.listenerCount('warning') > 1)
|
|
8
|
-
return;
|
|
9
|
-
process.on('warning', (warning) => {
|
|
10
|
-
console.error(warning.stack);
|
|
11
|
-
if (warning.detail)
|
|
12
|
-
console.error(warning.detail);
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
exports.config = {
|
|
16
|
-
get debug() {
|
|
17
|
-
return Boolean(settings_1.settings.debug);
|
|
18
|
-
},
|
|
19
|
-
set debug(enabled) {
|
|
20
|
-
settings_1.settings.debug = enabled;
|
|
21
|
-
if (enabled)
|
|
22
|
-
displayWarnings();
|
|
23
|
-
},
|
|
24
|
-
get errlog() {
|
|
25
|
-
return settings_1.settings.errlog;
|
|
26
|
-
},
|
|
27
|
-
set errlog(errlog) {
|
|
28
|
-
if (errlog) {
|
|
29
|
-
this.errorLogger = new logger_1.Logger(errlog);
|
|
30
|
-
settings_1.settings.errlog = errlog;
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
delete this.errorLogger;
|
|
34
|
-
delete settings_1.settings.errlog;
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
errorLogger: undefined,
|
|
38
|
-
};
|
package/lib/errors/logger.d.ts
DELETED
package/lib/errors/logger.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Logger = void 0;
|
|
4
|
-
const promises_1 = require("node:fs/promises");
|
|
5
|
-
const node_path_1 = require("node:path");
|
|
6
|
-
const stripAnsi = require("strip-ansi");
|
|
7
|
-
const timestamp = () => new Date().toISOString();
|
|
8
|
-
let timer;
|
|
9
|
-
const wait = (ms) => new Promise((resolve) => {
|
|
10
|
-
if (timer)
|
|
11
|
-
timer.unref();
|
|
12
|
-
timer = setTimeout(() => resolve(null), ms);
|
|
13
|
-
});
|
|
14
|
-
function chomp(s) {
|
|
15
|
-
if (s.endsWith('\n'))
|
|
16
|
-
return s.replace(/\n$/, '');
|
|
17
|
-
return s;
|
|
18
|
-
}
|
|
19
|
-
class Logger {
|
|
20
|
-
file;
|
|
21
|
-
buffer = [];
|
|
22
|
-
flushing = Promise.resolve();
|
|
23
|
-
constructor(file) {
|
|
24
|
-
this.file = file;
|
|
25
|
-
}
|
|
26
|
-
async flush(waitForMs = 0) {
|
|
27
|
-
await wait(waitForMs);
|
|
28
|
-
this.flushing = this.flushing.then(async () => {
|
|
29
|
-
if (this.buffer.length === 0)
|
|
30
|
-
return;
|
|
31
|
-
const mylines = this.buffer;
|
|
32
|
-
this.buffer = [];
|
|
33
|
-
await (0, promises_1.mkdir)((0, node_path_1.dirname)(this.file), { recursive: true });
|
|
34
|
-
await (0, promises_1.appendFile)(this.file, mylines.join('\n') + '\n');
|
|
35
|
-
});
|
|
36
|
-
await this.flushing;
|
|
37
|
-
}
|
|
38
|
-
log(msg) {
|
|
39
|
-
msg = stripAnsi(chomp(msg));
|
|
40
|
-
const lines = msg.split('\n').map((l) => `${timestamp()} ${l}`.trimEnd());
|
|
41
|
-
this.buffer.push(...lines);
|
|
42
|
-
this.flush(50).catch(console.error);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
exports.Logger = Logger;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|