@oclif/core 3.0.0-beta.18 → 3.0.0-beta.19
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.js +4 -4
- package/lib/cli-ux/action/base.js +1 -0
- package/lib/cli-ux/action/spinner.js +3 -5
- package/lib/cli-ux/action/spinners.js +1 -1
- package/lib/cli-ux/config.js +7 -6
- package/lib/cli-ux/flush.js +2 -2
- package/lib/cli-ux/index.js +1 -1
- package/lib/cli-ux/list.js +3 -3
- package/lib/cli-ux/prompt.js +8 -3
- package/lib/cli-ux/styled/object.js +2 -2
- package/lib/cli-ux/styled/table.js +23 -20
- package/lib/cli-ux/wait.js +1 -1
- package/lib/command.js +9 -9
- package/lib/config/config.d.ts +8 -8
- package/lib/config/config.js +45 -39
- package/lib/config/plugin-loader.js +7 -7
- package/lib/config/plugin.js +26 -23
- package/lib/config/ts-node.js +8 -10
- package/lib/config/util.js +2 -2
- package/lib/errors/errors/cli.js +1 -0
- package/lib/errors/errors/pretty-print.js +2 -1
- package/lib/errors/handle.js +2 -1
- package/lib/errors/logger.js +2 -2
- package/lib/flags.d.ts +4 -4
- package/lib/flags.js +3 -3
- package/lib/help/command.js +43 -32
- package/lib/help/docopts.js +5 -5
- package/lib/help/formatter.js +7 -7
- package/lib/help/index.js +39 -42
- package/lib/help/root.js +2 -7
- package/lib/help/util.js +1 -1
- package/lib/interfaces/hooks.d.ts +3 -3
- package/lib/interfaces/index.d.ts +1 -1
- package/lib/interfaces/parser.d.ts +15 -15
- package/lib/interfaces/pjson.d.ts +1 -1
- package/lib/module-loader.d.ts +8 -8
- package/lib/module-loader.js +12 -9
- package/lib/parser/errors.d.ts +1 -1
- package/lib/parser/errors.js +9 -9
- package/lib/parser/help.js +2 -3
- package/lib/parser/parse.js +64 -43
- package/lib/parser/validate.js +37 -21
- package/lib/performance.js +9 -6
- package/lib/util/aggregate-flags.js +1 -3
- package/lib/util/cache-command.js +28 -20
- package/lib/util/index.js +4 -6
- package/package.json +13 -11
package/lib/args.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.string = exports.url = exports.file = exports.directory = exports.integer = exports.boolean = exports.custom = void 0;
|
|
4
|
-
const
|
|
4
|
+
const index_1 = require("./util/index");
|
|
5
5
|
const node_url_1 = require("node:url");
|
|
6
6
|
function custom(defaults) {
|
|
7
7
|
return (options = {}) => ({
|
|
@@ -14,7 +14,7 @@ function custom(defaults) {
|
|
|
14
14
|
}
|
|
15
15
|
exports.custom = custom;
|
|
16
16
|
exports.boolean = custom({
|
|
17
|
-
parse: async (b) => Boolean(b) && (0,
|
|
17
|
+
parse: async (b) => Boolean(b) && (0, index_1.isNotFalsy)(b),
|
|
18
18
|
});
|
|
19
19
|
exports.integer = custom({
|
|
20
20
|
async parse(input, _, opts) {
|
|
@@ -31,14 +31,14 @@ exports.integer = custom({
|
|
|
31
31
|
exports.directory = custom({
|
|
32
32
|
async parse(input, _, opts) {
|
|
33
33
|
if (opts.exists)
|
|
34
|
-
return (0,
|
|
34
|
+
return (0, index_1.dirExists)(input);
|
|
35
35
|
return input;
|
|
36
36
|
},
|
|
37
37
|
});
|
|
38
38
|
exports.file = custom({
|
|
39
39
|
async parse(input, _, opts) {
|
|
40
40
|
if (opts.exists)
|
|
41
|
-
return (0,
|
|
41
|
+
return (0, index_1.fileExists)(input);
|
|
42
42
|
return input;
|
|
43
43
|
},
|
|
44
44
|
});
|
|
@@ -8,6 +8,7 @@ const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
|
8
8
|
const screen_1 = require("../../screen");
|
|
9
9
|
const spinners_1 = tslib_1.__importDefault(require("./spinners"));
|
|
10
10
|
const strip_ansi_1 = tslib_1.__importDefault(require("strip-ansi"));
|
|
11
|
+
const ansiEscapes = require('ansi-escapes');
|
|
11
12
|
function color(s) {
|
|
12
13
|
if (!supportsColor)
|
|
13
14
|
return s;
|
|
@@ -31,7 +32,7 @@ class SpinnerAction extends base_1.ActionBase {
|
|
|
31
32
|
if (this.spinner)
|
|
32
33
|
clearInterval(this.spinner);
|
|
33
34
|
this._render();
|
|
34
|
-
this.spinner = setInterval(icon => this._render.bind(this)(icon), process.platform === 'win32' ? 500 : 100, 'spinner');
|
|
35
|
+
this.spinner = setInterval((icon) => this._render.bind(this)(icon), process.platform === 'win32' ? 500 : 100, 'spinner');
|
|
35
36
|
const interval = this.spinner;
|
|
36
37
|
interval.unref();
|
|
37
38
|
}
|
|
@@ -74,15 +75,12 @@ class SpinnerAction extends base_1.ActionBase {
|
|
|
74
75
|
_reset() {
|
|
75
76
|
if (!this.output)
|
|
76
77
|
return;
|
|
77
|
-
const ansiEscapes = require('ansi-escapes');
|
|
78
78
|
const lines = this._lines(this.output);
|
|
79
79
|
this._write(this.std, ansiEscapes.cursorLeft + ansiEscapes.cursorUp(lines) + ansiEscapes.eraseDown);
|
|
80
80
|
this.output = undefined;
|
|
81
81
|
}
|
|
82
82
|
_lines(s) {
|
|
83
|
-
return (0, strip_ansi_1.default)(s).split('\n')
|
|
84
|
-
.map(l => Math.ceil(l.length / screen_1.errtermwidth))
|
|
85
|
-
.reduce((c, i) => c + i, 0);
|
|
83
|
+
return (0, strip_ansi_1.default)(s).split('\n').map((l) => Math.ceil(l.length / screen_1.errtermwidth)).reduce((c, i) => c + i, 0);
|
|
86
84
|
}
|
|
87
85
|
}
|
|
88
86
|
exports.default = SpinnerAction;
|
package/lib/cli-ux/config.js
CHANGED
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.config = exports.Config = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const index_1 = require("../util/index");
|
|
6
6
|
const simple_1 = tslib_1.__importDefault(require("./action/simple"));
|
|
7
7
|
const spinner_1 = tslib_1.__importDefault(require("./action/spinner"));
|
|
8
8
|
const g = global;
|
|
9
9
|
const globals = g.ux || (g.ux = {});
|
|
10
|
-
const actionType = (Boolean(process.stderr.isTTY)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
const actionType = (Boolean(process.stderr.isTTY) &&
|
|
11
|
+
!process.env.CI &&
|
|
12
|
+
!['dumb', 'emacs-color'].includes(process.env.TERM) &&
|
|
13
|
+
'spinner') ||
|
|
14
|
+
'simple';
|
|
14
15
|
const Action = actionType === 'spinner' ? spinner_1.default : simple_1.default;
|
|
15
16
|
class Config {
|
|
16
17
|
outputLevel = 'info';
|
|
@@ -32,7 +33,7 @@ class Config {
|
|
|
32
33
|
}
|
|
33
34
|
exports.Config = Config;
|
|
34
35
|
function fetch() {
|
|
35
|
-
const major = (0,
|
|
36
|
+
const major = (0, index_1.requireJson)(__dirname, '..', '..', 'package.json').version.split('.')[0];
|
|
36
37
|
if (globals[major])
|
|
37
38
|
return globals[major];
|
|
38
39
|
globals[major] = new Config();
|
package/lib/cli-ux/flush.js
CHANGED
|
@@ -5,7 +5,7 @@ const errors_1 = require("../errors");
|
|
|
5
5
|
const stream_1 = require("./stream");
|
|
6
6
|
function timeout(p, ms) {
|
|
7
7
|
function wait(ms, unref = false) {
|
|
8
|
-
return new Promise(resolve => {
|
|
8
|
+
return new Promise((resolve) => {
|
|
9
9
|
const t = setTimeout(() => resolve(null), ms);
|
|
10
10
|
if (unref)
|
|
11
11
|
t.unref();
|
|
@@ -14,7 +14,7 @@ function timeout(p, ms) {
|
|
|
14
14
|
return Promise.race([p, wait(ms, true).then(() => (0, errors_1.error)('timed out'))]);
|
|
15
15
|
}
|
|
16
16
|
async function _flush() {
|
|
17
|
-
const p = new Promise(resolve => {
|
|
17
|
+
const p = new Promise((resolve) => {
|
|
18
18
|
stream_1.stdout.once('drain', () => resolve(null));
|
|
19
19
|
});
|
|
20
20
|
const flushed = stream_1.stdout.write('');
|
package/lib/cli-ux/index.js
CHANGED
|
@@ -128,7 +128,7 @@ const uxProcessExitHandler = async () => {
|
|
|
128
128
|
};
|
|
129
129
|
// to avoid MaxListenersExceededWarning
|
|
130
130
|
// only attach named listener once
|
|
131
|
-
const uxListener = process.listeners('exit').find(fn => fn.name === uxProcessExitHandler.name);
|
|
131
|
+
const uxListener = process.listeners('exit').find((fn) => fn.name === uxProcessExitHandler.name);
|
|
132
132
|
if (!uxListener) {
|
|
133
133
|
process.once('exit', uxProcessExitHandler);
|
|
134
134
|
}
|
package/lib/cli-ux/list.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.renderList = void 0;
|
|
4
|
-
const
|
|
4
|
+
const index_1 = require("../util/index");
|
|
5
5
|
const screen_1 = require("../screen");
|
|
6
6
|
const wordwrap = require('wordwrap');
|
|
7
7
|
function linewrap(length, s) {
|
|
@@ -13,8 +13,8 @@ function renderList(items) {
|
|
|
13
13
|
if (items.length === 0) {
|
|
14
14
|
return '';
|
|
15
15
|
}
|
|
16
|
-
const maxLength = (0,
|
|
17
|
-
const lines = items.map(i => {
|
|
16
|
+
const maxLength = (0, index_1.maxBy)(items, (item) => item[0].length)?.[0].length ?? 0;
|
|
17
|
+
const lines = items.map((i) => {
|
|
18
18
|
let left = i[0];
|
|
19
19
|
let right = i[1];
|
|
20
20
|
if (!right) {
|
package/lib/cli-ux/prompt.js
CHANGED
|
@@ -21,7 +21,7 @@ function normal(options, retries = 100) {
|
|
|
21
21
|
process.stdin.setEncoding('utf8');
|
|
22
22
|
stream_1.stderr.write(options.prompt);
|
|
23
23
|
process.stdin.resume();
|
|
24
|
-
process.stdin.once('data', b => {
|
|
24
|
+
process.stdin.once('data', (b) => {
|
|
25
25
|
if (timer)
|
|
26
26
|
clearTimeout(timer);
|
|
27
27
|
process.stdin.pause();
|
|
@@ -58,8 +58,13 @@ async function single(options) {
|
|
|
58
58
|
}
|
|
59
59
|
function replacePrompt(prompt) {
|
|
60
60
|
const ansiEscapes = require('ansi-escapes');
|
|
61
|
-
stream_1.stderr.write(ansiEscapes.cursorHide +
|
|
62
|
-
|
|
61
|
+
stream_1.stderr.write(ansiEscapes.cursorHide +
|
|
62
|
+
ansiEscapes.cursorUp(1) +
|
|
63
|
+
ansiEscapes.cursorLeft +
|
|
64
|
+
prompt +
|
|
65
|
+
ansiEscapes.cursorDown(1) +
|
|
66
|
+
ansiEscapes.cursorLeft +
|
|
67
|
+
ansiEscapes.cursorShow);
|
|
63
68
|
}
|
|
64
69
|
async function _prompt(name, inputOptions = {}) {
|
|
65
70
|
const prompt = getPrompt(name, inputOptions.type, inputOptions.default);
|
|
@@ -5,14 +5,14 @@ const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
|
5
5
|
const node_util_1 = require("node:util");
|
|
6
6
|
function styledObject(obj, keys) {
|
|
7
7
|
const output = [];
|
|
8
|
-
const keyLengths = Object.keys(obj).map(key => key.toString().length);
|
|
8
|
+
const keyLengths = Object.keys(obj).map((key) => key.toString().length);
|
|
9
9
|
const maxKeyLength = Math.max(...keyLengths) + 2;
|
|
10
10
|
function pp(obj) {
|
|
11
11
|
if (typeof obj === 'string' || typeof obj === 'number')
|
|
12
12
|
return obj;
|
|
13
13
|
if (typeof obj === 'object') {
|
|
14
14
|
return Object.keys(obj)
|
|
15
|
-
.map(k => k + ': ' + (0, node_util_1.inspect)(obj[k]))
|
|
15
|
+
.map((k) => k + ': ' + (0, node_util_1.inspect)(obj[k]))
|
|
16
16
|
.join(', ');
|
|
17
17
|
}
|
|
18
18
|
return (0, node_util_1.inspect)(obj);
|
|
@@ -51,7 +51,7 @@ class Table {
|
|
|
51
51
|
}
|
|
52
52
|
display() {
|
|
53
53
|
// build table rows from input array data
|
|
54
|
-
let rows = this.data.map(d => {
|
|
54
|
+
let rows = this.data.map((d) => {
|
|
55
55
|
const row = {};
|
|
56
56
|
for (const col of this.columns) {
|
|
57
57
|
let val = col.get(d);
|
|
@@ -80,9 +80,9 @@ class Table {
|
|
|
80
80
|
// sort rows
|
|
81
81
|
if (this.options.sort) {
|
|
82
82
|
const sorters = this.options.sort.split(',');
|
|
83
|
-
const sortHeaders = sorters.map(k => k[0] === '-' ? k.slice(1) : k);
|
|
84
|
-
const sortKeys = this.filterColumnsFromHeaders(sortHeaders).map(c => (
|
|
85
|
-
const sortKeysOrder = sorters.map(k => k[0] === '-' ? 'desc' : 'asc');
|
|
83
|
+
const sortHeaders = sorters.map((k) => (k[0] === '-' ? k.slice(1) : k));
|
|
84
|
+
const sortKeys = this.filterColumnsFromHeaders(sortHeaders).map((c) => (v) => v[c.key]);
|
|
85
|
+
const sortKeysOrder = sorters.map((k) => (k[0] === '-' ? 'desc' : 'asc'));
|
|
86
86
|
rows = (0, natural_orderby_1.orderBy)(rows, sortKeys, sortKeysOrder);
|
|
87
87
|
}
|
|
88
88
|
// and filter columns
|
|
@@ -92,7 +92,7 @@ class Table {
|
|
|
92
92
|
}
|
|
93
93
|
else if (!this.options.extended) {
|
|
94
94
|
// show extented columns/properties
|
|
95
|
-
this.columns = this.columns.filter(c => !c.extended);
|
|
95
|
+
this.columns = this.columns.filter((c) => !c.extended);
|
|
96
96
|
}
|
|
97
97
|
this.data = rows;
|
|
98
98
|
switch (this.options.output) {
|
|
@@ -114,27 +114,27 @@ class Table {
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
findColumnFromHeader(header) {
|
|
117
|
-
return this.columns.find(c => c.header.toLowerCase() === header.toLowerCase());
|
|
117
|
+
return this.columns.find((c) => c.header.toLowerCase() === header.toLowerCase());
|
|
118
118
|
}
|
|
119
119
|
filterColumnsFromHeaders(filters) {
|
|
120
120
|
// unique
|
|
121
|
-
filters = [...
|
|
121
|
+
filters = [...new Set(filters)];
|
|
122
122
|
const cols = [];
|
|
123
123
|
for (const f of filters) {
|
|
124
|
-
const c = this.columns.find(c => c.header.toLowerCase() === f.toLowerCase());
|
|
124
|
+
const c = this.columns.find((c) => c.header.toLowerCase() === f.toLowerCase());
|
|
125
125
|
if (c)
|
|
126
126
|
cols.push(c);
|
|
127
127
|
}
|
|
128
128
|
return cols;
|
|
129
129
|
}
|
|
130
130
|
getCSVRow(d) {
|
|
131
|
-
const values = this.columns.map(col => d[col.key] || '');
|
|
131
|
+
const values = this.columns.map((col) => d[col.key] || '');
|
|
132
132
|
const lineToBeEscaped = values.find((e) => e.includes('"') || e.includes('\n') || e.includes('\r\n') || e.includes('\r') || e.includes(','));
|
|
133
|
-
return values.map(e => lineToBeEscaped ? `"${e.replace('"', '""')}"` : e);
|
|
133
|
+
return values.map((e) => (lineToBeEscaped ? `"${e.replace('"', '""')}"` : e));
|
|
134
134
|
}
|
|
135
135
|
resolveColumnsToObjectArray() {
|
|
136
136
|
const { data, columns } = this;
|
|
137
|
-
return data.map((d) => Object.fromEntries(columns.map(col => [col.key, d[col.key] ?? ''])));
|
|
137
|
+
return data.map((d) => Object.fromEntries(columns.map((col) => [col.key, d[col.key] ?? ''])));
|
|
138
138
|
}
|
|
139
139
|
outputJSON() {
|
|
140
140
|
this.options.printLine(JSON.stringify(this.resolveColumnsToObjectArray(), undefined, 2));
|
|
@@ -145,7 +145,7 @@ class Table {
|
|
|
145
145
|
outputCSV() {
|
|
146
146
|
const { data, columns, options } = this;
|
|
147
147
|
if (!options['no-header']) {
|
|
148
|
-
options.printLine(columns.map(c => c.header).join(','));
|
|
148
|
+
options.printLine(columns.map((c) => c.header).join(','));
|
|
149
149
|
}
|
|
150
150
|
for (const d of data) {
|
|
151
151
|
const row = this.getCSVRow(d);
|
|
@@ -157,7 +157,7 @@ class Table {
|
|
|
157
157
|
// column truncation
|
|
158
158
|
//
|
|
159
159
|
// find max width for each column
|
|
160
|
-
const columns = this.columns.map(c => {
|
|
160
|
+
const columns = this.columns.map((c) => {
|
|
161
161
|
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;
|
|
162
162
|
return {
|
|
163
163
|
...c,
|
|
@@ -173,7 +173,7 @@ class Table {
|
|
|
173
173
|
if (options['no-truncate'] || (!stream_1.stdout.isTTY && !process.env.CLI_UX_SKIP_TTY_CHECK))
|
|
174
174
|
return;
|
|
175
175
|
// don't shorten if there is enough screen width
|
|
176
|
-
const dataMaxWidth = (0, util_1.sumBy)(columns, c => c.width);
|
|
176
|
+
const dataMaxWidth = (0, util_1.sumBy)(columns, (c) => c.width);
|
|
177
177
|
const overWidth = dataMaxWidth - maxWidth;
|
|
178
178
|
if (overWidth <= 0)
|
|
179
179
|
return;
|
|
@@ -184,16 +184,18 @@ class Table {
|
|
|
184
184
|
// if sum(minWidth's) is greater than term width
|
|
185
185
|
// nothing can be done so
|
|
186
186
|
// display all as minWidth
|
|
187
|
-
const dataMinWidth = (0, util_1.sumBy)(columns, c => c.minWidth);
|
|
187
|
+
const dataMinWidth = (0, util_1.sumBy)(columns, (c) => c.minWidth);
|
|
188
188
|
if (dataMinWidth >= maxWidth)
|
|
189
189
|
return;
|
|
190
190
|
// some wiggle room left, add it back to "needy" columns
|
|
191
191
|
let wiggleRoom = maxWidth - dataMinWidth;
|
|
192
|
-
const needyCols = columns
|
|
192
|
+
const needyCols = columns
|
|
193
|
+
.map((c) => ({ key: c.key, needs: c.maxWidth - c.width }))
|
|
194
|
+
.sort((a, b) => a.needs - b.needs);
|
|
193
195
|
for (const { key, needs } of needyCols) {
|
|
194
196
|
if (!needs)
|
|
195
197
|
continue;
|
|
196
|
-
const col = columns.find(c => key === c.key);
|
|
198
|
+
const col = columns.find((c) => key === c.key);
|
|
197
199
|
if (!col)
|
|
198
200
|
continue;
|
|
199
201
|
if (wiggleRoom > needs) {
|
|
@@ -253,9 +255,9 @@ class Table {
|
|
|
253
255
|
let d = row[col.key];
|
|
254
256
|
d = d.split('\n')[i] || '';
|
|
255
257
|
const visualWidth = (0, string_width_1.default)(d);
|
|
256
|
-
const colorWidth =
|
|
258
|
+
const colorWidth = d.length - visualWidth;
|
|
257
259
|
let cell = d.padEnd(width + colorWidth);
|
|
258
|
-
if (
|
|
260
|
+
if (cell.length - colorWidth > width || visualWidth === width) {
|
|
259
261
|
// truncate the cell, preserving ANSI escape sequences, and keeping
|
|
260
262
|
// into account the width of fullwidth unicode characters
|
|
261
263
|
cell = (0, slice_ansi_1.default)(cell, 0, width - 2) + '… ';
|
|
@@ -277,7 +279,7 @@ exports.table = table;
|
|
|
277
279
|
(function (table) {
|
|
278
280
|
table.Flags = {
|
|
279
281
|
columns: F.string({ exclusive: ['extended'], description: 'only show provided columns (comma-separated)' }),
|
|
280
|
-
sort: F.string({ description:
|
|
282
|
+
sort: F.string({ description: "property to sort by (prepend '-' for descending)" }),
|
|
281
283
|
filter: F.string({ description: 'filter property by partial string matching, ex: name=foo' }),
|
|
282
284
|
csv: F.boolean({ exclusive: ['no-truncate'], description: 'output is csv format [alias: --output=csv]' }),
|
|
283
285
|
output: F.string({
|
|
@@ -296,6 +298,7 @@ exports.table = table;
|
|
|
296
298
|
const e = (opts.except && typeof opts.except === 'string' ? [opts.except] : opts.except) || [];
|
|
297
299
|
for (const key of o) {
|
|
298
300
|
if (!e.includes(key)) {
|
|
301
|
+
;
|
|
299
302
|
f[key] = table.Flags[key];
|
|
300
303
|
}
|
|
301
304
|
}
|
package/lib/cli-ux/wait.js
CHANGED
package/lib/command.js
CHANGED
|
@@ -6,14 +6,14 @@ const Errors = tslib_1.__importStar(require("./errors"));
|
|
|
6
6
|
const Parser = tslib_1.__importStar(require("./parser"));
|
|
7
7
|
const node_util_1 = require("node:util");
|
|
8
8
|
const util_1 = require("./help/util");
|
|
9
|
-
const
|
|
9
|
+
const index_1 = require("./util/index");
|
|
10
10
|
const stream_1 = require("./cli-ux/stream");
|
|
11
11
|
const config_1 = require("./config");
|
|
12
12
|
const aggregate_flags_1 = require("./util/aggregate-flags");
|
|
13
13
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
14
14
|
const node_url_1 = require("node:url");
|
|
15
15
|
const cli_ux_1 = require("./cli-ux");
|
|
16
|
-
const pjson = (0,
|
|
16
|
+
const pjson = (0, index_1.requireJson)(__dirname, '..', 'package.json');
|
|
17
17
|
/**
|
|
18
18
|
* swallows stdout epipe errors
|
|
19
19
|
* this occurs when stdout closes such as when piping to head
|
|
@@ -188,10 +188,10 @@ class Command {
|
|
|
188
188
|
const passThroughIndex = this.argv.indexOf('--');
|
|
189
189
|
const jsonIndex = this.argv.indexOf('--json');
|
|
190
190
|
return passThroughIndex === -1
|
|
191
|
-
// If '--' is not present, then check for `--json` in this.argv
|
|
192
|
-
|
|
193
|
-
// If '--' is present, return true only the --json flag exists and is before the '--'
|
|
194
|
-
|
|
191
|
+
? // If '--' is not present, then check for `--json` in this.argv
|
|
192
|
+
jsonIndex > -1
|
|
193
|
+
: // If '--' is present, return true only the --json flag exists and is before the '--'
|
|
194
|
+
jsonIndex > -1 && jsonIndex < passThroughIndex;
|
|
195
195
|
}
|
|
196
196
|
async init() {
|
|
197
197
|
this.debug('init version: %s argv: %o', this.ctor._base, this.argv);
|
|
@@ -214,10 +214,10 @@ class Command {
|
|
|
214
214
|
}
|
|
215
215
|
const deprecateAliases = flagDef?.deprecateAliases;
|
|
216
216
|
if (deprecateAliases) {
|
|
217
|
-
const aliases = (0,
|
|
217
|
+
const aliases = (0, index_1.uniq)([...(flagDef?.aliases ?? []), ...(flagDef?.charAliases ?? [])]).map((a) => a.length === 1 ? `-${a}` : `--${a}`);
|
|
218
218
|
if (aliases.length === 0)
|
|
219
219
|
return;
|
|
220
|
-
const foundAliases = aliases.filter(alias => this.argv.some(a => a.startsWith(alias)));
|
|
220
|
+
const foundAliases = aliases.filter((alias) => this.argv.some((a) => a.startsWith(alias)));
|
|
221
221
|
for (const alias of foundAliases) {
|
|
222
222
|
let preferredUsage = `--${flagDef?.name}`;
|
|
223
223
|
if (flagDef?.char) {
|
|
@@ -294,7 +294,7 @@ class Command {
|
|
|
294
294
|
catch {
|
|
295
295
|
keys.push(this.config.scopedEnvVarKey(envVar));
|
|
296
296
|
}
|
|
297
|
-
keys.map(key => delete process.env[key]);
|
|
297
|
+
keys.map((key) => delete process.env[key]);
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
300
|
exports.Command = Command;
|
package/lib/config/config.d.ts
CHANGED
|
@@ -144,13 +144,13 @@ export declare class Config implements IConfig {
|
|
|
144
144
|
*/
|
|
145
145
|
private determinePriority;
|
|
146
146
|
/**
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
147
|
+
* Insert legacy plugins
|
|
148
|
+
*
|
|
149
|
+
* Replace invalid CLI plugins (cli-engine plugins, mostly Heroku) loaded via `this.loadPlugins`
|
|
150
|
+
* with oclif-compatible ones returned by @oclif/plugin-legacy init hook.
|
|
151
|
+
*
|
|
152
|
+
* @param plugins array of oclif-compatible plugins
|
|
153
|
+
* @returns void
|
|
154
|
+
*/
|
|
155
155
|
private insertLegacyPlugins;
|
|
156
156
|
}
|