@oclif/core 1.24.0 → 2.0.0-beta.4
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 +5 -5
- package/lib/args.d.ts +39 -0
- package/lib/args.js +62 -0
- package/lib/cli-ux/action/base.d.ts +1 -1
- package/lib/cli-ux/action/pride-spinner.js +0 -1
- package/lib/cli-ux/action/spinner.js +10 -11
- package/lib/cli-ux/action/spinners.d.ts +251 -0
- package/lib/cli-ux/action/spinners.js +2 -1
- package/lib/cli-ux/config.d.ts +1 -1
- package/lib/cli-ux/config.js +7 -5
- package/lib/cli-ux/index.d.ts +27 -32
- package/lib/cli-ux/index.js +67 -24
- package/lib/cli-ux/list.js +3 -4
- package/lib/cli-ux/prompt.js +9 -8
- package/lib/cli-ux/styled/header.js +1 -1
- package/lib/cli-ux/styled/index.d.ts +7 -0
- package/lib/cli-ux/styled/index.js +15 -0
- package/lib/cli-ux/styled/json.d.ts +1 -1
- package/lib/cli-ux/styled/json.js +2 -3
- package/lib/cli-ux/styled/object.js +1 -1
- package/lib/cli-ux/styled/progress.d.ts +2 -1
- package/lib/cli-ux/styled/progress.js +1 -5
- package/lib/cli-ux/styled/table.js +1 -3
- package/lib/cli-ux/styled/tree.js +0 -1
- package/lib/cli-ux/wait.d.ts +1 -1
- package/lib/cli-ux/wait.js +0 -1
- package/lib/command.d.ts +77 -26
- package/lib/command.js +46 -43
- package/lib/config/config.d.ts +18 -17
- package/lib/config/config.js +46 -22
- package/lib/config/index.js +0 -5
- package/lib/config/plugin.d.ts +3 -2
- package/lib/config/plugin.js +4 -13
- package/lib/config/util.js +2 -2
- package/lib/errors/index.js +0 -1
- package/lib/errors/logger.js +2 -4
- package/lib/flags.d.ts +46 -18
- package/lib/flags.js +71 -29
- package/lib/help/command.d.ts +12 -12
- package/lib/help/command.js +6 -6
- package/lib/help/docopts.d.ts +3 -3
- package/lib/help/docopts.js +2 -3
- package/lib/help/formatter.d.ts +4 -3
- package/lib/help/index.d.ts +10 -14
- package/lib/help/index.js +0 -5
- package/lib/help/util.d.ts +3 -3
- package/lib/help/util.js +1 -1
- package/lib/index.d.ts +5 -4
- package/lib/index.js +10 -8
- package/lib/interfaces/args.d.ts +22 -0
- package/lib/interfaces/{command.js → args.js} +0 -0
- package/lib/interfaces/config.d.ts +1 -2
- package/lib/interfaces/flags.d.ts +2 -2
- package/lib/interfaces/hooks.d.ts +1 -1
- package/lib/interfaces/index.d.ts +2 -2
- package/lib/interfaces/manifest.d.ts +2 -2
- package/lib/interfaces/parser.d.ts +96 -81
- package/lib/interfaces/plugin.d.ts +1 -1
- package/lib/main.d.ts +54 -1
- package/lib/main.js +70 -6
- package/lib/parser/errors.d.ts +15 -8
- package/lib/parser/errors.js +17 -14
- package/lib/parser/help.d.ts +1 -1
- package/lib/parser/help.js +4 -9
- package/lib/parser/index.d.ts +2 -9
- package/lib/parser/index.js +5 -26
- package/lib/parser/parse.d.ts +4 -11
- package/lib/parser/parse.js +108 -72
- package/lib/parser/validate.d.ts +1 -1
- package/lib/parser/validate.js +6 -3
- package/lib/util.d.ts +8 -0
- package/lib/util.js +44 -1
- package/package.json +4 -4
- package/lib/cli-ux/deps.d.ts +0 -22
- package/lib/cli-ux/deps.js +0 -47
- package/lib/cli-ux/open.d.ts +0 -6
- package/lib/cli-ux/open.js +0 -69
- package/lib/help/_test-help-class.d.ts +0 -6
- package/lib/help/_test-help-class.js +0 -19
- package/lib/interfaces/command.d.ts +0 -110
- package/lib/parser/args.d.ts +0 -5
- package/lib/parser/args.js +0 -11
- package/lib/parser/deps.d.ts +0 -4
- package/lib/parser/deps.js +0 -17
- package/lib/parser/flags.d.ts +0 -60
- package/lib/parser/flags.js +0 -107
- package/lib/parser/list.d.ts +0 -2
- package/lib/parser/list.js +0 -29
- package/lib/parser/util.d.ts +0 -7
- package/lib/parser/util.js +0 -50
package/README.md
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
base library for oclif CLIs
|
|
5
5
|
|
|
6
6
|
[](https://npmjs.org/package/@oclif/core)
|
|
7
|
-
[](https://circleci.com/gh/oclif/core/tree/main)
|
|
8
7
|
[](https://npmjs.org/package/@oclif/core)
|
|
9
8
|
[](https://github.com/oclif/core/blob/main/package.json)
|
|
10
9
|
|
|
@@ -12,11 +11,12 @@ base library for oclif CLIs
|
|
|
12
11
|
Migrating
|
|
13
12
|
=====
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
See the [migration guide](./MIGRATION.md) for an overview of breaking changes that occurred between v1 and v2.
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
CLI UX
|
|
17
|
+
=====
|
|
18
|
+
|
|
19
|
+
The [ux README](./src/cli-ux/README.md) contains detailed usage examples of using the `ux` export.
|
|
20
20
|
|
|
21
21
|
Usage
|
|
22
22
|
=====
|
package/lib/args.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { URL } from 'url';
|
|
3
|
+
import { Arg, ArgDefinition } from './interfaces/parser';
|
|
4
|
+
/**
|
|
5
|
+
* Create a custom arg.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* type Id = string
|
|
9
|
+
* type IdOpts = { startsWith: string; length: number };
|
|
10
|
+
*
|
|
11
|
+
* export const myArg = custom<Id, IdOpts>({
|
|
12
|
+
* parse: async (input, opts) => {
|
|
13
|
+
* if (input.startsWith(opts.startsWith) && input.length === opts.length) {
|
|
14
|
+
* return input
|
|
15
|
+
* }
|
|
16
|
+
*
|
|
17
|
+
* throw new Error('Invalid id')
|
|
18
|
+
* },
|
|
19
|
+
* })
|
|
20
|
+
*/
|
|
21
|
+
export declare function custom<T = string, P = Record<string, unknown>>(defaults: Partial<Arg<T, P>>): ArgDefinition<T, P>;
|
|
22
|
+
export declare const boolean: ArgDefinition<boolean, Record<string, unknown>>;
|
|
23
|
+
export declare const integer: ArgDefinition<number, {
|
|
24
|
+
min?: number | undefined;
|
|
25
|
+
max?: number | undefined;
|
|
26
|
+
}>;
|
|
27
|
+
export declare const directory: ArgDefinition<string, {
|
|
28
|
+
exists?: boolean | undefined;
|
|
29
|
+
}>;
|
|
30
|
+
export declare const file: ArgDefinition<string, {
|
|
31
|
+
exists?: boolean | undefined;
|
|
32
|
+
}>;
|
|
33
|
+
/**
|
|
34
|
+
* Initializes a string as a URL. Throws an error
|
|
35
|
+
* if the string is not a valid URL.
|
|
36
|
+
*/
|
|
37
|
+
export declare const url: ArgDefinition<URL, Record<string, unknown>>;
|
|
38
|
+
declare const stringArg: ArgDefinition<string, Record<string, unknown>>;
|
|
39
|
+
export { stringArg as string };
|
package/lib/args.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.string = exports.url = exports.file = exports.directory = exports.integer = exports.boolean = exports.custom = void 0;
|
|
4
|
+
const url_1 = require("url");
|
|
5
|
+
const util_1 = require("./util");
|
|
6
|
+
function custom(defaults) {
|
|
7
|
+
return (options = {}) => {
|
|
8
|
+
return {
|
|
9
|
+
parse: async (i, _context, _opts) => i,
|
|
10
|
+
...defaults,
|
|
11
|
+
...options,
|
|
12
|
+
input: [],
|
|
13
|
+
type: 'option',
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
exports.custom = custom;
|
|
18
|
+
exports.boolean = custom({
|
|
19
|
+
parse: async (b) => Boolean(b) && (0, util_1.isNotFalsy)(b),
|
|
20
|
+
});
|
|
21
|
+
exports.integer = custom({
|
|
22
|
+
parse: async (input, _, opts) => {
|
|
23
|
+
if (!/^-?\d+$/.test(input))
|
|
24
|
+
throw new Error(`Expected an integer but received: ${input}`);
|
|
25
|
+
const num = Number.parseInt(input, 10);
|
|
26
|
+
if (opts.min !== undefined && num < opts.min)
|
|
27
|
+
throw new Error(`Expected an integer greater than or equal to ${opts.min} but received: ${input}`);
|
|
28
|
+
if (opts.max !== undefined && num > opts.max)
|
|
29
|
+
throw new Error(`Expected an integer less than or equal to ${opts.max} but received: ${input}`);
|
|
30
|
+
return num;
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
exports.directory = custom({
|
|
34
|
+
parse: async (input, _, opts) => {
|
|
35
|
+
if (opts.exists)
|
|
36
|
+
return (0, util_1.dirExists)(input);
|
|
37
|
+
return input;
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
exports.file = custom({
|
|
41
|
+
parse: async (input, _, opts) => {
|
|
42
|
+
if (opts.exists)
|
|
43
|
+
return (0, util_1.fileExists)(input);
|
|
44
|
+
return input;
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
/**
|
|
48
|
+
* Initializes a string as a URL. Throws an error
|
|
49
|
+
* if the string is not a valid URL.
|
|
50
|
+
*/
|
|
51
|
+
exports.url = custom({
|
|
52
|
+
parse: async (input) => {
|
|
53
|
+
try {
|
|
54
|
+
return new url_1.URL(input);
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
throw new Error(`Expected a valid url but received: ${input}`);
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
const stringArg = custom({});
|
|
62
|
+
exports.string = stringArg;
|
|
@@ -23,7 +23,7 @@ export declare class ActionBase {
|
|
|
23
23
|
get status(): string | undefined;
|
|
24
24
|
set status(status: string | undefined);
|
|
25
25
|
pauseAsync<T extends any>(fn: () => Promise<T>, icon?: string): Promise<T>;
|
|
26
|
-
pause(fn: () => any, icon?: string): any
|
|
26
|
+
pause(fn: () => any, icon?: string): Promise<any>;
|
|
27
27
|
protected _start(): void;
|
|
28
28
|
protected _stop(_: string): void;
|
|
29
29
|
protected _resume(): void;
|
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// tslint:disable restrict-plus-operands
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
const chalk = require("chalk");
|
|
5
4
|
const supportsColor = require("supports-color");
|
|
6
|
-
const
|
|
5
|
+
const stripAnsi = require('strip-ansi');
|
|
6
|
+
const ansiStyles = require('ansi-styles');
|
|
7
|
+
const ansiEscapes = require('ansi-escapes');
|
|
8
|
+
const screen_1 = require("../../screen");
|
|
9
|
+
const spinners_1 = require("./spinners");
|
|
7
10
|
const base_1 = require("./base");
|
|
8
|
-
/* eslint-disable-next-line node/no-missing-require */
|
|
9
|
-
const spinners = require('./spinners');
|
|
10
11
|
function color(s) {
|
|
11
12
|
if (!supportsColor)
|
|
12
13
|
return s;
|
|
13
14
|
const has256 = supportsColor.stdout ? supportsColor.stdout.has256 : (process.env.TERM || '').includes('256');
|
|
14
|
-
return has256 ? `\u001B[38;5;104m${s}${
|
|
15
|
+
return has256 ? `\u001B[38;5;104m${s}${ansiStyles.reset.open}` : chalk.magenta(s);
|
|
15
16
|
}
|
|
16
17
|
class SpinnerAction extends base_1.ActionBase {
|
|
17
18
|
constructor() {
|
|
18
19
|
super();
|
|
19
20
|
this.type = 'spinner';
|
|
20
|
-
this.frames =
|
|
21
|
+
this.frames = spinners_1.default[process.platform === 'win32' ? 'line' : 'dots2'].frames;
|
|
21
22
|
this.frameIndex = 0;
|
|
22
23
|
}
|
|
23
24
|
_start() {
|
|
@@ -65,14 +66,12 @@ class SpinnerAction extends base_1.ActionBase {
|
|
|
65
66
|
if (!this.output)
|
|
66
67
|
return;
|
|
67
68
|
const lines = this._lines(this.output);
|
|
68
|
-
this._write(this.std,
|
|
69
|
+
this._write(this.std, ansiEscapes.cursorLeft + ansiEscapes.cursorUp(lines) + ansiEscapes.eraseDown);
|
|
69
70
|
this.output = undefined;
|
|
70
71
|
}
|
|
71
72
|
_lines(s) {
|
|
72
|
-
return
|
|
73
|
-
.
|
|
74
|
-
.split('\n')
|
|
75
|
-
.map(l => Math.ceil(l.length / deps_1.default.screen.errtermwidth))
|
|
73
|
+
return stripAnsi(s).split('\n')
|
|
74
|
+
.map(l => Math.ceil(l.length / screen_1.errtermwidth))
|
|
76
75
|
.reduce((c, i) => c + i, 0);
|
|
77
76
|
}
|
|
78
77
|
}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
hexagon: {
|
|
3
|
+
interval: number;
|
|
4
|
+
frames: string[];
|
|
5
|
+
};
|
|
6
|
+
dots: {
|
|
7
|
+
interval: number;
|
|
8
|
+
frames: string[];
|
|
9
|
+
};
|
|
10
|
+
dots2: {
|
|
11
|
+
interval: number;
|
|
12
|
+
frames: string[];
|
|
13
|
+
};
|
|
14
|
+
dots3: {
|
|
15
|
+
interval: number;
|
|
16
|
+
frames: string[];
|
|
17
|
+
};
|
|
18
|
+
dots4: {
|
|
19
|
+
interval: number;
|
|
20
|
+
frames: string[];
|
|
21
|
+
};
|
|
22
|
+
dots5: {
|
|
23
|
+
interval: number;
|
|
24
|
+
frames: string[];
|
|
25
|
+
};
|
|
26
|
+
dots6: {
|
|
27
|
+
interval: number;
|
|
28
|
+
frames: string[];
|
|
29
|
+
};
|
|
30
|
+
dots7: {
|
|
31
|
+
interval: number;
|
|
32
|
+
frames: string[];
|
|
33
|
+
};
|
|
34
|
+
dots8: {
|
|
35
|
+
interval: number;
|
|
36
|
+
frames: string[];
|
|
37
|
+
};
|
|
38
|
+
dots9: {
|
|
39
|
+
interval: number;
|
|
40
|
+
frames: string[];
|
|
41
|
+
};
|
|
42
|
+
dots10: {
|
|
43
|
+
interval: number;
|
|
44
|
+
frames: string[];
|
|
45
|
+
};
|
|
46
|
+
dots11: {
|
|
47
|
+
interval: number;
|
|
48
|
+
frames: string[];
|
|
49
|
+
};
|
|
50
|
+
line: {
|
|
51
|
+
interval: number;
|
|
52
|
+
frames: string[];
|
|
53
|
+
};
|
|
54
|
+
line2: {
|
|
55
|
+
interval: number;
|
|
56
|
+
frames: string[];
|
|
57
|
+
};
|
|
58
|
+
pipe: {
|
|
59
|
+
interval: number;
|
|
60
|
+
frames: string[];
|
|
61
|
+
};
|
|
62
|
+
simpleDots: {
|
|
63
|
+
interval: number;
|
|
64
|
+
frames: string[];
|
|
65
|
+
};
|
|
66
|
+
simpleDotsScrolling: {
|
|
67
|
+
interval: number;
|
|
68
|
+
frames: string[];
|
|
69
|
+
};
|
|
70
|
+
star: {
|
|
71
|
+
interval: number;
|
|
72
|
+
frames: string[];
|
|
73
|
+
};
|
|
74
|
+
star2: {
|
|
75
|
+
interval: number;
|
|
76
|
+
frames: string[];
|
|
77
|
+
};
|
|
78
|
+
flip: {
|
|
79
|
+
interval: number;
|
|
80
|
+
frames: string[];
|
|
81
|
+
};
|
|
82
|
+
hamburger: {
|
|
83
|
+
interval: number;
|
|
84
|
+
frames: string[];
|
|
85
|
+
};
|
|
86
|
+
growVertical: {
|
|
87
|
+
interval: number;
|
|
88
|
+
frames: string[];
|
|
89
|
+
};
|
|
90
|
+
growHorizontal: {
|
|
91
|
+
interval: number;
|
|
92
|
+
frames: string[];
|
|
93
|
+
};
|
|
94
|
+
balloon: {
|
|
95
|
+
interval: number;
|
|
96
|
+
frames: string[];
|
|
97
|
+
};
|
|
98
|
+
balloon2: {
|
|
99
|
+
interval: number;
|
|
100
|
+
frames: string[];
|
|
101
|
+
};
|
|
102
|
+
noise: {
|
|
103
|
+
interval: number;
|
|
104
|
+
frames: string[];
|
|
105
|
+
};
|
|
106
|
+
bounce: {
|
|
107
|
+
interval: number;
|
|
108
|
+
frames: string[];
|
|
109
|
+
};
|
|
110
|
+
boxBounce: {
|
|
111
|
+
interval: number;
|
|
112
|
+
frames: string[];
|
|
113
|
+
};
|
|
114
|
+
boxBounce2: {
|
|
115
|
+
interval: number;
|
|
116
|
+
frames: string[];
|
|
117
|
+
};
|
|
118
|
+
triangle: {
|
|
119
|
+
interval: number;
|
|
120
|
+
frames: string[];
|
|
121
|
+
};
|
|
122
|
+
arc: {
|
|
123
|
+
interval: number;
|
|
124
|
+
frames: string[];
|
|
125
|
+
};
|
|
126
|
+
circle: {
|
|
127
|
+
interval: number;
|
|
128
|
+
frames: string[];
|
|
129
|
+
};
|
|
130
|
+
squareCorners: {
|
|
131
|
+
interval: number;
|
|
132
|
+
frames: string[];
|
|
133
|
+
};
|
|
134
|
+
circleQuarters: {
|
|
135
|
+
interval: number;
|
|
136
|
+
frames: string[];
|
|
137
|
+
};
|
|
138
|
+
circleHalves: {
|
|
139
|
+
interval: number;
|
|
140
|
+
frames: string[];
|
|
141
|
+
};
|
|
142
|
+
squish: {
|
|
143
|
+
interval: number;
|
|
144
|
+
frames: string[];
|
|
145
|
+
};
|
|
146
|
+
toggle: {
|
|
147
|
+
interval: number;
|
|
148
|
+
frames: string[];
|
|
149
|
+
};
|
|
150
|
+
toggle2: {
|
|
151
|
+
interval: number;
|
|
152
|
+
frames: string[];
|
|
153
|
+
};
|
|
154
|
+
toggle3: {
|
|
155
|
+
interval: number;
|
|
156
|
+
frames: string[];
|
|
157
|
+
};
|
|
158
|
+
toggle4: {
|
|
159
|
+
interval: number;
|
|
160
|
+
frames: string[];
|
|
161
|
+
};
|
|
162
|
+
toggle5: {
|
|
163
|
+
interval: number;
|
|
164
|
+
frames: string[];
|
|
165
|
+
};
|
|
166
|
+
toggle6: {
|
|
167
|
+
interval: number;
|
|
168
|
+
frames: string[];
|
|
169
|
+
};
|
|
170
|
+
toggle7: {
|
|
171
|
+
interval: number;
|
|
172
|
+
frames: string[];
|
|
173
|
+
};
|
|
174
|
+
toggle8: {
|
|
175
|
+
interval: number;
|
|
176
|
+
frames: string[];
|
|
177
|
+
};
|
|
178
|
+
toggle9: {
|
|
179
|
+
interval: number;
|
|
180
|
+
frames: string[];
|
|
181
|
+
};
|
|
182
|
+
toggle10: {
|
|
183
|
+
interval: number;
|
|
184
|
+
frames: string[];
|
|
185
|
+
};
|
|
186
|
+
toggle11: {
|
|
187
|
+
interval: number;
|
|
188
|
+
frames: string[];
|
|
189
|
+
};
|
|
190
|
+
toggle12: {
|
|
191
|
+
interval: number;
|
|
192
|
+
frames: string[];
|
|
193
|
+
};
|
|
194
|
+
toggle13: {
|
|
195
|
+
interval: number;
|
|
196
|
+
frames: string[];
|
|
197
|
+
};
|
|
198
|
+
arrow: {
|
|
199
|
+
interval: number;
|
|
200
|
+
frames: string[];
|
|
201
|
+
};
|
|
202
|
+
arrow2: {
|
|
203
|
+
interval: number;
|
|
204
|
+
frames: string[];
|
|
205
|
+
};
|
|
206
|
+
arrow3: {
|
|
207
|
+
interval: number;
|
|
208
|
+
frames: string[];
|
|
209
|
+
};
|
|
210
|
+
bouncingBar: {
|
|
211
|
+
interval: number;
|
|
212
|
+
frames: string[];
|
|
213
|
+
};
|
|
214
|
+
bouncingBall: {
|
|
215
|
+
interval: number;
|
|
216
|
+
frames: string[];
|
|
217
|
+
};
|
|
218
|
+
smiley: {
|
|
219
|
+
interval: number;
|
|
220
|
+
frames: string[];
|
|
221
|
+
};
|
|
222
|
+
monkey: {
|
|
223
|
+
interval: number;
|
|
224
|
+
frames: string[];
|
|
225
|
+
};
|
|
226
|
+
hearts: {
|
|
227
|
+
interval: number;
|
|
228
|
+
frames: string[];
|
|
229
|
+
};
|
|
230
|
+
clock: {
|
|
231
|
+
interval: number;
|
|
232
|
+
frames: string[];
|
|
233
|
+
};
|
|
234
|
+
earth: {
|
|
235
|
+
interval: number;
|
|
236
|
+
frames: string[];
|
|
237
|
+
};
|
|
238
|
+
moon: {
|
|
239
|
+
interval: number;
|
|
240
|
+
frames: string[];
|
|
241
|
+
};
|
|
242
|
+
runner: {
|
|
243
|
+
interval: number;
|
|
244
|
+
frames: string[];
|
|
245
|
+
};
|
|
246
|
+
pong: {
|
|
247
|
+
interval: number;
|
|
248
|
+
frames: string[];
|
|
249
|
+
};
|
|
250
|
+
};
|
|
251
|
+
export default _default;
|
package/lib/cli-ux/config.d.ts
CHANGED
package/lib/cli-ux/config.js
CHANGED
|
@@ -2,17 +2,19 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.config = exports.Config = void 0;
|
|
4
4
|
const semver = require("semver");
|
|
5
|
-
const
|
|
5
|
+
const util_1 = require("../util");
|
|
6
|
+
const spinner_1 = require("./action/spinner");
|
|
7
|
+
const spinner_2 = require("./action/spinner");
|
|
8
|
+
const pride_spinner_1 = require("./action/pride-spinner");
|
|
9
|
+
const version = semver.parse((0, util_1.requireJson)(__dirname, '..', '..', 'package.json').version);
|
|
6
10
|
const g = global;
|
|
7
11
|
const globals = g['cli-ux'] || (g['cli-ux'] = {});
|
|
8
12
|
const actionType = (Boolean(process.stderr.isTTY) &&
|
|
9
13
|
!process.env.CI &&
|
|
10
14
|
!['dumb', 'emacs-color'].includes(process.env.TERM) &&
|
|
11
15
|
'spinner') || 'simple';
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
const PrideAction = actionType === 'spinner' ? require('./action/pride-spinner').default : require('./action/simple').default;
|
|
15
|
-
/* eslint-enable node/no-missing-require */
|
|
16
|
+
const Action = actionType === 'spinner' ? spinner_1.default : spinner_2.default;
|
|
17
|
+
const PrideAction = actionType === 'spinner' ? pride_spinner_1.default : spinner_2.default;
|
|
16
18
|
class Config {
|
|
17
19
|
constructor() {
|
|
18
20
|
this.outputLevel = 'info';
|
package/lib/cli-ux/index.d.ts
CHANGED
|
@@ -3,35 +3,30 @@ import { ActionBase } from './action/base';
|
|
|
3
3
|
import { config, Config } from './config';
|
|
4
4
|
import { ExitError } from './exit';
|
|
5
5
|
import { IPromptOptions } from './prompt';
|
|
6
|
-
import * as
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
url(text: string, uri: string, params?: {}): void;
|
|
34
|
-
annotation(text: string, annotation: string): void;
|
|
35
|
-
flush(ms?: number): Promise<void>;
|
|
36
|
-
};
|
|
37
|
-
export { config, ActionBase, Config, ExitError, IPromptOptions, Table, };
|
|
6
|
+
import * as styled from './styled';
|
|
7
|
+
import { Table } from './styled';
|
|
8
|
+
import * as uxPrompt from './prompt';
|
|
9
|
+
declare const action: ActionBase;
|
|
10
|
+
declare const annotation: (text: string, annotation: string) => void;
|
|
11
|
+
declare const anykey: typeof uxPrompt.anykey;
|
|
12
|
+
declare const confirm: typeof uxPrompt.confirm;
|
|
13
|
+
declare const debug: (format: string, ...args: string[]) => void;
|
|
14
|
+
declare const done: () => Promise<void>;
|
|
15
|
+
declare const error: typeof Errors.error;
|
|
16
|
+
declare const exit: typeof Errors.exit;
|
|
17
|
+
declare const flush: (ms?: number) => Promise<void>;
|
|
18
|
+
declare const info: (format: string, ...args: string[]) => void;
|
|
19
|
+
declare const log: (format?: string, ...args: string[]) => void;
|
|
20
|
+
declare const prideAction: ActionBase;
|
|
21
|
+
declare const progress: typeof styled.progress;
|
|
22
|
+
declare const prompt: typeof uxPrompt.prompt;
|
|
23
|
+
declare const styledHeader: typeof styled.styledHeader;
|
|
24
|
+
declare const styledJSON: typeof styled.styledJSON;
|
|
25
|
+
declare const styledObject: (obj: any, keys?: string[]) => void;
|
|
26
|
+
declare const table: typeof styled.Table.table;
|
|
27
|
+
declare const trace: (format: string, ...args: string[]) => void;
|
|
28
|
+
declare const tree: typeof styled.tree;
|
|
29
|
+
declare const url: (text: string, uri: string, params?: {}) => void;
|
|
30
|
+
declare const wait: (ms?: number) => Promise<void>;
|
|
31
|
+
declare const warn: typeof Errors.warn;
|
|
32
|
+
export { action, ActionBase, annotation, anykey, config, Config, confirm, debug, done, error, exit, ExitError, flush, info, IPromptOptions, log, prideAction, progress, prompt, styledHeader, styledJSON, styledObject, table, Table, trace, tree, url, wait, warn, };
|