@oclif/core 3.0.0-beta.12 → 3.0.0-beta.14
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/README.md +3 -1
- package/lib/args.d.ts +1 -1
- package/lib/args.js +13 -15
- package/lib/cli-ux/action/base.d.ts +1 -1
- package/lib/cli-ux/action/base.js +20 -15
- package/lib/cli-ux/action/simple.js +10 -8
- package/lib/cli-ux/action/spinner.js +11 -10
- package/lib/cli-ux/config.js +8 -7
- package/lib/cli-ux/flush.js +2 -3
- package/lib/cli-ux/index.d.ts +10 -28
- package/lib/cli-ux/index.js +26 -45
- package/lib/cli-ux/list.js +1 -1
- package/lib/cli-ux/prompt.js +24 -19
- package/lib/cli-ux/styled/index.d.ts +5 -6
- package/lib/cli-ux/styled/index.js +11 -11
- package/lib/cli-ux/styled/json.js +3 -2
- package/lib/cli-ux/styled/object.js +6 -8
- package/lib/cli-ux/styled/table.js +36 -45
- package/lib/cli-ux/wait.js +3 -5
- package/lib/command.d.ts +7 -5
- package/lib/command.js +35 -28
- package/lib/config/config.d.ts +2 -2
- package/lib/config/config.js +57 -43
- package/lib/config/plugin-loader.js +25 -11
- package/lib/config/plugin.d.ts +1 -1
- package/lib/config/plugin.js +66 -56
- package/lib/config/ts-node.d.ts +2 -1
- package/lib/config/ts-node.js +42 -46
- package/lib/config/util.d.ts +1 -5
- package/lib/config/util.js +5 -46
- package/lib/errors/config.js +1 -1
- package/lib/errors/errors/cli.d.ts +1 -1
- package/lib/errors/errors/cli.js +14 -13
- package/lib/errors/errors/exit.d.ts +0 -3
- package/lib/errors/errors/module-load.d.ts +0 -3
- package/lib/errors/errors/pretty-print.js +9 -8
- package/lib/errors/handle.d.ts +12 -2
- package/lib/errors/handle.js +23 -14
- package/lib/errors/index.d.ts +2 -2
- package/lib/errors/index.js +20 -19
- package/lib/errors/logger.js +4 -4
- package/lib/execute.d.ts +5 -5
- package/lib/execute.js +6 -5
- package/lib/flags.d.ts +102 -31
- package/lib/flags.js +75 -42
- package/lib/help/command.d.ts +2 -0
- package/lib/help/command.js +32 -32
- package/lib/help/docopts.js +2 -9
- package/lib/help/formatter.d.ts +1 -1
- package/lib/help/formatter.js +17 -17
- package/lib/help/index.d.ts +2 -2
- package/lib/help/index.js +22 -21
- package/lib/help/root.js +2 -2
- package/lib/help/util.d.ts +1 -1
- package/lib/help/util.js +9 -9
- package/lib/index.d.ts +19 -20
- package/lib/index.js +38 -42
- package/lib/interfaces/config.d.ts +5 -4
- package/lib/interfaces/errors.d.ts +1 -1
- package/lib/interfaces/parser.d.ts +168 -45
- package/lib/interfaces/plugin.d.ts +1 -0
- package/lib/main.d.ts +1 -1
- package/lib/main.js +16 -16
- package/lib/module-loader.d.ts +67 -77
- package/lib/module-loader.js +179 -149
- package/lib/parser/errors.d.ts +2 -2
- package/lib/parser/errors.js +4 -3
- package/lib/parser/help.js +3 -2
- package/lib/parser/parse.d.ts +3 -0
- package/lib/parser/parse.js +56 -52
- package/lib/parser/validate.js +9 -5
- package/lib/performance.d.ts +6 -2
- package/lib/performance.js +23 -12
- package/lib/util.d.ts +25 -1
- package/lib/util.js +93 -29
- package/package.json +10 -15
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
5
|
-
exports.
|
|
6
|
-
|
|
7
|
-
exports
|
|
8
|
-
|
|
9
|
-
exports.
|
|
10
|
-
|
|
11
|
-
exports
|
|
12
|
-
|
|
13
|
-
exports
|
|
3
|
+
exports.tree = exports.styledObject = exports.styledJSON = exports.progress = exports.Table = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
exports.Table = tslib_1.__importStar(require("./table"));
|
|
6
|
+
var progress_1 = require("./progress");
|
|
7
|
+
Object.defineProperty(exports, "progress", { enumerable: true, get: function () { return tslib_1.__importDefault(progress_1).default; } });
|
|
8
|
+
var json_1 = require("./json");
|
|
9
|
+
Object.defineProperty(exports, "styledJSON", { enumerable: true, get: function () { return tslib_1.__importDefault(json_1).default; } });
|
|
10
|
+
var object_1 = require("./object");
|
|
11
|
+
Object.defineProperty(exports, "styledObject", { enumerable: true, get: function () { return tslib_1.__importDefault(object_1).default; } });
|
|
12
|
+
var tree_1 = require("./tree");
|
|
13
|
+
Object.defineProperty(exports, "tree", { enumerable: true, get: function () { return tslib_1.__importDefault(tree_1).default; } });
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
4
5
|
const index_1 = require("../../index");
|
|
5
6
|
function styledJSON(obj) {
|
|
6
7
|
const json = JSON.stringify(obj, null, 2);
|
|
7
|
-
if (!
|
|
8
|
+
if (!chalk_1.default.level) {
|
|
8
9
|
index_1.ux.info(json);
|
|
9
10
|
return;
|
|
10
11
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
5
|
+
const node_util_1 = require("node:util");
|
|
6
6
|
function styledObject(obj, keys) {
|
|
7
7
|
const output = [];
|
|
8
8
|
const keyLengths = Object.keys(obj).map(key => key.toString().length);
|
|
@@ -12,14 +12,12 @@ function styledObject(obj, keys) {
|
|
|
12
12
|
return obj;
|
|
13
13
|
if (typeof obj === 'object') {
|
|
14
14
|
return Object.keys(obj)
|
|
15
|
-
.map(k => k + ': ' +
|
|
15
|
+
.map(k => k + ': ' + (0, node_util_1.inspect)(obj[k]))
|
|
16
16
|
.join(', ');
|
|
17
17
|
}
|
|
18
|
-
return
|
|
18
|
+
return (0, node_util_1.inspect)(obj);
|
|
19
19
|
}
|
|
20
|
-
const logKeyValue = (key, value) => {
|
|
21
|
-
return `${chalk.blue(key)}:` + ' '.repeat(maxKeyLength - key.length - 1) + pp(value);
|
|
22
|
-
};
|
|
20
|
+
const logKeyValue = (key, value) => `${chalk_1.default.blue(key)}:` + ' '.repeat(maxKeyLength - key.length - 1) + pp(value);
|
|
23
21
|
for (const key of keys || Object.keys(obj).sort()) {
|
|
24
22
|
const value = obj[key];
|
|
25
23
|
if (Array.isArray(value)) {
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.table = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const chalk = require("chalk");
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const F = tslib_1.__importStar(require("../../flags"));
|
|
7
6
|
const util_1 = require("../../util");
|
|
7
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
8
|
+
const node_util_1 = require("node:util");
|
|
9
|
+
const natural_orderby_1 = require("natural-orderby");
|
|
8
10
|
const js_yaml_1 = require("js-yaml");
|
|
9
|
-
const
|
|
11
|
+
const slice_ansi_1 = tslib_1.__importDefault(require("slice-ansi"));
|
|
10
12
|
const stream_1 = require("../stream");
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const sliceAnsi = require('slice-ansi');
|
|
13
|
+
const screen_1 = require("../../screen");
|
|
14
|
+
const string_width_1 = tslib_1.__importDefault(require("string-width"));
|
|
14
15
|
class Table {
|
|
15
16
|
constructor(data, columns, options = {}) {
|
|
16
17
|
this.data = data;
|
|
@@ -20,8 +21,8 @@ class Table {
|
|
|
20
21
|
const extended = col.extended ?? false;
|
|
21
22
|
// turn null and undefined into empty strings by default
|
|
22
23
|
const get = col.get ?? ((row) => row[key] ?? '');
|
|
23
|
-
const header = typeof col.header === 'string' ? col.header : (0, util_1.capitalize)(key.
|
|
24
|
-
const minWidth = Math.max(col.minWidth ?? 0,
|
|
24
|
+
const header = typeof col.header === 'string' ? col.header : (0, util_1.capitalize)(key.replaceAll('_', ' '));
|
|
25
|
+
const minWidth = Math.max(col.minWidth ?? 0, (0, string_width_1.default)(header) + 1);
|
|
25
26
|
return {
|
|
26
27
|
extended,
|
|
27
28
|
get,
|
|
@@ -52,14 +53,13 @@ class Table {
|
|
|
52
53
|
for (const col of this.columns) {
|
|
53
54
|
let val = col.get(d);
|
|
54
55
|
if (typeof val !== 'string')
|
|
55
|
-
val = (0,
|
|
56
|
+
val = (0, node_util_1.inspect)(val, { breakLength: Number.POSITIVE_INFINITY });
|
|
56
57
|
row[col.key] = val;
|
|
57
58
|
}
|
|
58
59
|
return row;
|
|
59
60
|
});
|
|
60
61
|
// filter rows
|
|
61
62
|
if (this.options.filter) {
|
|
62
|
-
/* eslint-disable-next-line prefer-const */
|
|
63
63
|
let [header, regex] = this.options.filter.split('=');
|
|
64
64
|
const isNot = header[0] === '-';
|
|
65
65
|
if (isNot)
|
|
@@ -78,11 +78,9 @@ class Table {
|
|
|
78
78
|
if (this.options.sort) {
|
|
79
79
|
const sorters = this.options.sort.split(',');
|
|
80
80
|
const sortHeaders = sorters.map(k => k[0] === '-' ? k.slice(1) : k);
|
|
81
|
-
const sortKeys = this.filterColumnsFromHeaders(sortHeaders).map(c =>
|
|
82
|
-
return ((v) => v[c.key]);
|
|
83
|
-
});
|
|
81
|
+
const sortKeys = this.filterColumnsFromHeaders(sortHeaders).map(c => ((v) => v[c.key]));
|
|
84
82
|
const sortKeysOrder = sorters.map(k => k[0] === '-' ? 'desc' : 'asc');
|
|
85
|
-
rows = orderBy(rows, sortKeys, sortKeysOrder);
|
|
83
|
+
rows = (0, natural_orderby_1.orderBy)(rows, sortKeys, sortKeysOrder);
|
|
86
84
|
}
|
|
87
85
|
// and filter columns
|
|
88
86
|
if (this.options.columns) {
|
|
@@ -95,17 +93,21 @@ class Table {
|
|
|
95
93
|
}
|
|
96
94
|
this.data = rows;
|
|
97
95
|
switch (this.options.output) {
|
|
98
|
-
case 'csv':
|
|
96
|
+
case 'csv': {
|
|
99
97
|
this.outputCSV();
|
|
100
98
|
break;
|
|
101
|
-
|
|
99
|
+
}
|
|
100
|
+
case 'json': {
|
|
102
101
|
this.outputJSON();
|
|
103
102
|
break;
|
|
104
|
-
|
|
103
|
+
}
|
|
104
|
+
case 'yaml': {
|
|
105
105
|
this.outputYAML();
|
|
106
106
|
break;
|
|
107
|
-
|
|
107
|
+
}
|
|
108
|
+
default: {
|
|
108
109
|
this.outputTable();
|
|
110
|
+
}
|
|
109
111
|
}
|
|
110
112
|
}
|
|
111
113
|
findColumnFromHeader(header) {
|
|
@@ -129,15 +131,7 @@ class Table {
|
|
|
129
131
|
}
|
|
130
132
|
resolveColumnsToObjectArray() {
|
|
131
133
|
const { data, columns } = this;
|
|
132
|
-
return data.map((d) =>
|
|
133
|
-
// eslint-disable-next-line unicorn/prefer-object-from-entries
|
|
134
|
-
return columns.reduce((obj, col) => {
|
|
135
|
-
return {
|
|
136
|
-
...obj,
|
|
137
|
-
[col.key]: d[col.key] ?? '',
|
|
138
|
-
};
|
|
139
|
-
}, {});
|
|
140
|
-
});
|
|
134
|
+
return data.map((d) => Object.fromEntries(columns.map(col => [col.key, d[col.key] ?? ''])));
|
|
141
135
|
}
|
|
142
136
|
outputJSON() {
|
|
143
137
|
this.options.printLine(JSON.stringify(this.resolveColumnsToObjectArray(), undefined, 2));
|
|
@@ -161,7 +155,7 @@ class Table {
|
|
|
161
155
|
//
|
|
162
156
|
// find max width for each column
|
|
163
157
|
const columns = this.columns.map(c => {
|
|
164
|
-
const maxWidth = Math.max(
|
|
158
|
+
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;
|
|
165
159
|
return {
|
|
166
160
|
...c,
|
|
167
161
|
maxWidth,
|
|
@@ -224,14 +218,14 @@ class Table {
|
|
|
224
218
|
const header = col.header;
|
|
225
219
|
headers += header.padEnd(col.width);
|
|
226
220
|
}
|
|
227
|
-
options.printLine(
|
|
221
|
+
options.printLine(chalk_1.default.bold(headers));
|
|
228
222
|
// print header dividers
|
|
229
223
|
let dividers = options.rowStart;
|
|
230
224
|
for (const col of columns) {
|
|
231
225
|
const divider = ''.padEnd(col.width - 1, '─') + ' ';
|
|
232
226
|
dividers += divider.padEnd(col.width);
|
|
233
227
|
}
|
|
234
|
-
options.printLine(
|
|
228
|
+
options.printLine(chalk_1.default.bold(dividers));
|
|
235
229
|
}
|
|
236
230
|
// print rows
|
|
237
231
|
for (const row of data) {
|
|
@@ -255,16 +249,16 @@ class Table {
|
|
|
255
249
|
const width = col.width;
|
|
256
250
|
let d = row[col.key];
|
|
257
251
|
d = d.split('\n')[i] || '';
|
|
258
|
-
const visualWidth =
|
|
252
|
+
const visualWidth = (0, string_width_1.default)(d);
|
|
259
253
|
const colorWidth = (d.length - visualWidth);
|
|
260
254
|
let cell = d.padEnd(width + colorWidth);
|
|
261
255
|
if ((cell.length - colorWidth) > width || visualWidth === width) {
|
|
262
256
|
// truncate the cell, preserving ANSI escape sequences, and keeping
|
|
263
257
|
// into account the width of fullwidth unicode characters
|
|
264
|
-
cell =
|
|
258
|
+
cell = (0, slice_ansi_1.default)(cell, 0, width - 2) + '… ';
|
|
265
259
|
// pad with spaces; this is necessary in case the original string
|
|
266
260
|
// contained fullwidth characters which cannot be split
|
|
267
|
-
cell += ' '.repeat(width -
|
|
261
|
+
cell += ' '.repeat(width - (0, string_width_1.default)(cell));
|
|
268
262
|
}
|
|
269
263
|
l += cell;
|
|
270
264
|
}
|
|
@@ -292,7 +286,6 @@ exports.table = table;
|
|
|
292
286
|
'no-truncate': F.boolean({ exclusive: ['csv'], description: 'do not truncate output to fit screen' }),
|
|
293
287
|
'no-header': F.boolean({ exclusive: ['csv'], description: 'hide table header from output' }),
|
|
294
288
|
};
|
|
295
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
296
289
|
function flags(opts) {
|
|
297
290
|
if (opts) {
|
|
298
291
|
const f = {};
|
|
@@ -308,13 +301,11 @@ exports.table = table;
|
|
|
308
301
|
return table.Flags;
|
|
309
302
|
}
|
|
310
303
|
table.flags = flags;
|
|
311
|
-
})(table
|
|
312
|
-
const getWidestColumnWith = (data, columnKey) => {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
}, 0);
|
|
320
|
-
};
|
|
304
|
+
})(table || (exports.table = table = {}));
|
|
305
|
+
const getWidestColumnWith = (data, columnKey) => data.reduce((previous, current) => {
|
|
306
|
+
const d = current[columnKey];
|
|
307
|
+
// convert multi-line cell to single longest line
|
|
308
|
+
// for width calculations
|
|
309
|
+
const manyLines = d.split('\n');
|
|
310
|
+
return Math.max(previous, manyLines.length > 1 ? Math.max(...manyLines.map((r) => (0, string_width_1.default)(r))) : (0, string_width_1.default)(d));
|
|
311
|
+
}, 0);
|
package/lib/cli-ux/wait.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = (ms = 1000) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
});
|
|
7
|
-
};
|
|
3
|
+
exports.default = (ms = 1000) => new Promise(resolve => {
|
|
4
|
+
setTimeout(resolve, ms);
|
|
5
|
+
});
|
package/lib/command.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { ArgInput, ArgOutput, ArgProps, BooleanFlagProps, Deprecation, FlagInput, FlagOutput, Arg as IArg, Flag as IFlag, Input, OptionFlagProps, ParserOutput } from './interfaces/parser';
|
|
2
|
+
import { CommandError } from './interfaces/errors';
|
|
1
3
|
import { Config } from './config';
|
|
2
|
-
import { PrettyPrintableError } from './errors';
|
|
3
|
-
import { BooleanFlagProps, CompletableFlag, Deprecation, Arg as IArg, ArgInput, FlagInput, FlagOutput, Input, ArgProps, OptionFlagProps, ParserOutput, ArgOutput } from './interfaces/parser';
|
|
4
|
-
import { Plugin } from './interfaces/plugin';
|
|
5
4
|
import { LoadOptions } from './interfaces/config';
|
|
6
|
-
import {
|
|
5
|
+
import { Plugin } from './interfaces/plugin';
|
|
6
|
+
import { PrettyPrintableError } from './errors';
|
|
7
7
|
/**
|
|
8
8
|
* An abstract class which acts as the base for each command
|
|
9
9
|
* in your project.
|
|
@@ -159,8 +159,10 @@ export declare namespace Command {
|
|
|
159
159
|
hasDynamicHelp?: boolean;
|
|
160
160
|
permutations?: string[];
|
|
161
161
|
aliasPermutations?: string[];
|
|
162
|
+
isESM?: boolean;
|
|
163
|
+
relativePath?: string[];
|
|
162
164
|
};
|
|
163
|
-
type Flag =
|
|
165
|
+
type Flag = IFlag<any>;
|
|
164
166
|
namespace Flag {
|
|
165
167
|
type Cached = Omit<Flag, 'parse' | 'input'> & (BooleanFlagProps | OptionFlagProps);
|
|
166
168
|
type Any = Flag | Cached;
|
package/lib/command.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Command = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const Errors = tslib_1.__importStar(require("./errors"));
|
|
6
|
+
const Parser = tslib_1.__importStar(require("./parser"));
|
|
7
|
+
const node_util_1 = require("node:util");
|
|
8
|
+
const util_1 = require("./help/util");
|
|
9
|
+
const util_2 = require("./util");
|
|
10
|
+
const stream_1 = require("./cli-ux/stream");
|
|
8
11
|
const config_1 = require("./config");
|
|
9
|
-
const Errors = require("./errors");
|
|
10
|
-
const Parser = require("./parser");
|
|
11
|
-
const util_2 = require("./help/util");
|
|
12
12
|
const flags_1 = require("./flags");
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
13
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
14
|
+
const node_url_1 = require("node:url");
|
|
15
|
+
const cli_ux_1 = require("./cli-ux");
|
|
16
|
+
const pjson = (0, util_2.requireJson)(__dirname, '..', 'package.json');
|
|
16
17
|
/**
|
|
17
18
|
* swallows stdout epipe errors
|
|
18
19
|
* this occurs when stdout closes such as when piping to head
|
|
@@ -69,7 +70,7 @@ class Command {
|
|
|
69
70
|
argv = process.argv.slice(2);
|
|
70
71
|
// Handle the case when a file URL string is passed in such as 'import.meta.url'; covert to file path.
|
|
71
72
|
if (typeof opts === 'string' && opts.startsWith('file://')) {
|
|
72
|
-
opts = (0,
|
|
73
|
+
opts = (0, node_url_1.fileURLToPath)(opts);
|
|
73
74
|
}
|
|
74
75
|
const config = await config_1.Config.load(opts || require.main?.filename || __dirname);
|
|
75
76
|
const cmd = new this(argv, config);
|
|
@@ -84,6 +85,7 @@ class Command {
|
|
|
84
85
|
return this._baseFlags;
|
|
85
86
|
}
|
|
86
87
|
static set baseFlags(flags) {
|
|
88
|
+
// eslint-disable-next-line prefer-object-spread
|
|
87
89
|
this._baseFlags = Object.assign({}, this.baseFlags, flags);
|
|
88
90
|
this.flags = {}; // force the flags setter to run
|
|
89
91
|
}
|
|
@@ -91,6 +93,7 @@ class Command {
|
|
|
91
93
|
return this._flags;
|
|
92
94
|
}
|
|
93
95
|
static set flags(flags) {
|
|
96
|
+
// eslint-disable-next-line prefer-object-spread
|
|
94
97
|
this._flags = Object.assign({}, this._flags ?? {}, this.baseFlags, flags);
|
|
95
98
|
}
|
|
96
99
|
constructor(argv, config) {
|
|
@@ -101,7 +104,9 @@ class Command {
|
|
|
101
104
|
this.debug = require('debug')(this.id ? `${this.config.bin}:${this.id}` : this.config.bin);
|
|
102
105
|
}
|
|
103
106
|
catch {
|
|
104
|
-
this.debug = () => {
|
|
107
|
+
this.debug = () => {
|
|
108
|
+
// noop
|
|
109
|
+
};
|
|
105
110
|
}
|
|
106
111
|
}
|
|
107
112
|
get ctor() {
|
|
@@ -140,14 +145,14 @@ class Command {
|
|
|
140
145
|
}
|
|
141
146
|
log(message = '', ...args) {
|
|
142
147
|
if (!this.jsonEnabled()) {
|
|
143
|
-
message = typeof message === 'string' ? message : (0,
|
|
144
|
-
stream_1.stdout.write((0,
|
|
148
|
+
message = typeof message === 'string' ? message : (0, node_util_1.inspect)(message);
|
|
149
|
+
stream_1.stdout.write((0, node_util_1.format)(message, ...args) + '\n');
|
|
145
150
|
}
|
|
146
151
|
}
|
|
147
152
|
logToStderr(message = '', ...args) {
|
|
148
153
|
if (!this.jsonEnabled()) {
|
|
149
|
-
message = typeof message === 'string' ? message : (0,
|
|
150
|
-
stream_1.stderr.write((0,
|
|
154
|
+
message = typeof message === 'string' ? message : (0, node_util_1.inspect)(message);
|
|
155
|
+
stream_1.stderr.write((0, node_util_1.format)(message, ...args) + '\n');
|
|
151
156
|
}
|
|
152
157
|
}
|
|
153
158
|
/**
|
|
@@ -183,32 +188,34 @@ class Command {
|
|
|
183
188
|
const flagDef = this.ctor.flags[flag];
|
|
184
189
|
const deprecated = flagDef?.deprecated;
|
|
185
190
|
if (deprecated) {
|
|
186
|
-
this.warn((0,
|
|
191
|
+
this.warn((0, util_1.formatFlagDeprecationWarning)(flag, deprecated));
|
|
187
192
|
}
|
|
188
193
|
const deprecateAliases = flagDef?.deprecateAliases;
|
|
189
|
-
|
|
190
|
-
|
|
194
|
+
if (deprecateAliases) {
|
|
195
|
+
const aliases = (0, util_2.uniq)([...flagDef?.aliases ?? [], ...flagDef?.charAliases ?? []]).map(a => a.length === 1 ? `-${a}` : `--${a}`);
|
|
196
|
+
if (aliases.length === 0)
|
|
197
|
+
return;
|
|
191
198
|
const foundAliases = aliases.filter(alias => this.argv.some(a => a.startsWith(alias)));
|
|
192
199
|
for (const alias of foundAliases) {
|
|
193
200
|
let preferredUsage = `--${flagDef?.name}`;
|
|
194
201
|
if (flagDef?.char) {
|
|
195
202
|
preferredUsage += ` | -${flagDef?.char}`;
|
|
196
203
|
}
|
|
197
|
-
this.warn((0,
|
|
204
|
+
this.warn((0, util_1.formatFlagDeprecationWarning)(alias, { to: preferredUsage }));
|
|
198
205
|
}
|
|
199
206
|
}
|
|
200
207
|
}
|
|
201
208
|
}
|
|
202
209
|
warnIfCommandDeprecated() {
|
|
203
|
-
const [id] = (0,
|
|
210
|
+
const [id] = (0, util_1.normalizeArgv)(this.config);
|
|
204
211
|
if (this.ctor.deprecateAliases && this.ctor.aliases.includes(id)) {
|
|
205
|
-
const cmdName = (0,
|
|
206
|
-
const aliasName = (0,
|
|
207
|
-
this.warn((0,
|
|
212
|
+
const cmdName = (0, util_1.toConfiguredId)(this.ctor.id, this.config);
|
|
213
|
+
const aliasName = (0, util_1.toConfiguredId)(id, this.config);
|
|
214
|
+
this.warn((0, util_1.formatCommandDeprecationWarning)(aliasName, { to: cmdName }));
|
|
208
215
|
}
|
|
209
216
|
if (this.ctor.state === 'deprecated') {
|
|
210
|
-
const cmdName = (0,
|
|
211
|
-
this.warn((0,
|
|
217
|
+
const cmdName = (0, util_1.toConfiguredId)(this.ctor.id, this.config);
|
|
218
|
+
this.warn((0, util_1.formatCommandDeprecationWarning)(cmdName, this.ctor.deprecationOptions));
|
|
212
219
|
}
|
|
213
220
|
}
|
|
214
221
|
async parse(options, argv = this.argv) {
|
|
@@ -231,7 +238,7 @@ class Command {
|
|
|
231
238
|
if (!err.message)
|
|
232
239
|
throw err;
|
|
233
240
|
try {
|
|
234
|
-
cli_ux_1.ux.action.stop(
|
|
241
|
+
cli_ux_1.ux.action.stop(chalk_1.default.bold.red('!'));
|
|
235
242
|
}
|
|
236
243
|
catch { }
|
|
237
244
|
throw err;
|
|
@@ -239,7 +246,7 @@ class Command {
|
|
|
239
246
|
}
|
|
240
247
|
async finally(_) {
|
|
241
248
|
try {
|
|
242
|
-
const config = Errors
|
|
249
|
+
const { config } = Errors;
|
|
243
250
|
if (config.errorLogger)
|
|
244
251
|
await config.errorLogger.flush();
|
|
245
252
|
}
|
package/lib/config/config.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Config as IConfig, ArchTypes, PlatformTypes, LoadOptions, VersionDetails } from '../interfaces/config';
|
|
1
|
+
import { ArchTypes, Config as IConfig, LoadOptions, PlatformTypes, VersionDetails } from '../interfaces/config';
|
|
3
2
|
import { Hook, Hooks, PJSON, Topic } from '../interfaces';
|
|
3
|
+
import { Plugin as IPlugin, Options } from '../interfaces/plugin';
|
|
4
4
|
import { Command } from '../command';
|
|
5
5
|
export declare class Config implements IConfig {
|
|
6
6
|
options: Options;
|