@oclif/core 3.0.0-beta.15 → 3.0.0-beta.17
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/cli-ux/action/base.d.ts +2 -4
- package/lib/cli-ux/action/base.js +2 -2
- package/lib/cli-ux/action/simple.js +11 -15
- package/lib/cli-ux/action/spinner.d.ts +4 -2
- package/lib/cli-ux/action/spinner.js +13 -7
- package/lib/cli-ux/action/types.d.ts +5 -0
- package/lib/cli-ux/action/types.js +2 -0
- package/lib/config/ts-node.js +14 -2
- package/package.json +3 -3
|
@@ -1,12 +1,10 @@
|
|
|
1
|
+
import { Options } from './types';
|
|
1
2
|
export interface ITask {
|
|
2
3
|
action: string;
|
|
3
4
|
status: string | undefined;
|
|
4
5
|
active: boolean;
|
|
5
6
|
}
|
|
6
7
|
export type ActionType = 'spinner' | 'simple' | 'debug';
|
|
7
|
-
export interface Options {
|
|
8
|
-
stdout?: boolean;
|
|
9
|
-
}
|
|
10
8
|
export declare class ActionBase {
|
|
11
9
|
type: ActionType;
|
|
12
10
|
std: 'stdout' | 'stderr';
|
|
@@ -24,7 +22,7 @@ export declare class ActionBase {
|
|
|
24
22
|
set status(status: string | undefined);
|
|
25
23
|
pauseAsync<T>(fn: () => Promise<T>, icon?: string): Promise<T>;
|
|
26
24
|
pause(fn: () => any, icon?: string): Promise<any>;
|
|
27
|
-
protected _start(): void;
|
|
25
|
+
protected _start(_opts: Options): void;
|
|
28
26
|
protected _stop(_: string): void;
|
|
29
27
|
protected _resume(): void;
|
|
30
28
|
protected _pause(_?: string): void;
|
|
@@ -16,7 +16,7 @@ class ActionBase {
|
|
|
16
16
|
this.std = opts.stdout ? 'stdout' : 'stderr';
|
|
17
17
|
const task = { action, status, active: Boolean(this.task && this.task.active) };
|
|
18
18
|
this.task = task;
|
|
19
|
-
this._start();
|
|
19
|
+
this._start(opts);
|
|
20
20
|
task.active = true;
|
|
21
21
|
this._stdout(true);
|
|
22
22
|
}
|
|
@@ -93,7 +93,7 @@ class ActionBase {
|
|
|
93
93
|
}
|
|
94
94
|
return ret;
|
|
95
95
|
}
|
|
96
|
-
_start() {
|
|
96
|
+
_start(_opts) {
|
|
97
97
|
throw new Error('not implemented');
|
|
98
98
|
}
|
|
99
99
|
_stop(_) {
|
|
@@ -7,10 +7,9 @@ class SimpleAction extends base_1.ActionBase {
|
|
|
7
7
|
this.type = 'simple';
|
|
8
8
|
}
|
|
9
9
|
_start() {
|
|
10
|
-
|
|
11
|
-
if (!task)
|
|
10
|
+
if (!this.task)
|
|
12
11
|
return;
|
|
13
|
-
this._render(task.action, task.status);
|
|
12
|
+
this._render(this.task.action, this.task.status);
|
|
14
13
|
}
|
|
15
14
|
_pause(icon) {
|
|
16
15
|
if (icon)
|
|
@@ -22,29 +21,26 @@ class SimpleAction extends base_1.ActionBase {
|
|
|
22
21
|
// Not implemented
|
|
23
22
|
}
|
|
24
23
|
_updateStatus(status, prevStatus, newline = false) {
|
|
25
|
-
|
|
26
|
-
if (!task)
|
|
24
|
+
if (!this.task)
|
|
27
25
|
return;
|
|
28
|
-
if (task.active && !prevStatus)
|
|
29
|
-
this._write(std, ` ${status}`);
|
|
26
|
+
if (this.task.active && !prevStatus)
|
|
27
|
+
this._write(this.std, ` ${status}`);
|
|
30
28
|
else
|
|
31
|
-
this._write(std, `${task.action}... ${status}`);
|
|
29
|
+
this._write(this.std, `${this.task.action}... ${status}`);
|
|
32
30
|
if (newline || !prevStatus)
|
|
33
31
|
this._flush();
|
|
34
32
|
}
|
|
35
33
|
_stop(status) {
|
|
36
|
-
|
|
37
|
-
if (!task)
|
|
34
|
+
if (!this.task)
|
|
38
35
|
return;
|
|
39
|
-
this._updateStatus(status, task.status, true);
|
|
36
|
+
this._updateStatus(status, this.task.status, true);
|
|
40
37
|
}
|
|
41
38
|
_render(action, status) {
|
|
42
|
-
|
|
43
|
-
if (!task)
|
|
39
|
+
if (!this.task)
|
|
44
40
|
return;
|
|
45
|
-
if (task.active)
|
|
41
|
+
if (this.task.active)
|
|
46
42
|
this._flush();
|
|
47
|
-
this._write(std, status ? `${action}... ${status}` : `${action}...`);
|
|
43
|
+
this._write(this.std, status ? `${action}... ${status}` : `${action}...`);
|
|
48
44
|
}
|
|
49
45
|
_flush() {
|
|
50
46
|
this._write(this.std, '\n');
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { ActionBase, ActionType } from './base';
|
|
3
|
+
import { Options } from './types';
|
|
3
4
|
export default class SpinnerAction extends ActionBase {
|
|
4
5
|
type: ActionType;
|
|
5
6
|
spinner?: NodeJS.Timeout;
|
|
6
|
-
frames:
|
|
7
|
+
frames: string[];
|
|
7
8
|
frameIndex: number;
|
|
8
9
|
constructor();
|
|
9
|
-
protected _start(): void;
|
|
10
|
+
protected _start(opts: Options): void;
|
|
10
11
|
protected _stop(status: string): void;
|
|
11
12
|
protected _pause(icon?: string): void;
|
|
12
13
|
protected _frame(): string;
|
|
14
|
+
private getFrames;
|
|
13
15
|
private _render;
|
|
14
16
|
private _reset;
|
|
15
17
|
private _lines;
|
|
@@ -18,10 +18,12 @@ class SpinnerAction extends base_1.ActionBase {
|
|
|
18
18
|
constructor() {
|
|
19
19
|
super();
|
|
20
20
|
this.type = 'spinner';
|
|
21
|
-
this.frames =
|
|
21
|
+
this.frames = this.getFrames();
|
|
22
22
|
this.frameIndex = 0;
|
|
23
23
|
}
|
|
24
|
-
_start() {
|
|
24
|
+
_start(opts) {
|
|
25
|
+
if (opts.style)
|
|
26
|
+
this.frames = this.getFrames(opts);
|
|
25
27
|
this._reset();
|
|
26
28
|
if (this.spinner)
|
|
27
29
|
clearInterval(this.spinner);
|
|
@@ -51,16 +53,20 @@ class SpinnerAction extends base_1.ActionBase {
|
|
|
51
53
|
this.frameIndex = ++this.frameIndex % this.frames.length;
|
|
52
54
|
return color(frame);
|
|
53
55
|
}
|
|
56
|
+
getFrames(opts) {
|
|
57
|
+
if (opts?.style)
|
|
58
|
+
return spinners_1.default[process.platform === 'win32' ? 'line' : opts.style].frames;
|
|
59
|
+
return spinners_1.default[process.platform === 'win32' ? 'line' : 'dots2'].frames;
|
|
60
|
+
}
|
|
54
61
|
_render(icon) {
|
|
55
|
-
|
|
56
|
-
if (!task)
|
|
62
|
+
if (!this.task)
|
|
57
63
|
return;
|
|
58
64
|
this._reset();
|
|
59
65
|
this._flushStdout();
|
|
60
66
|
const frame = icon === 'spinner' ? ` ${this._frame()}` : icon || '';
|
|
61
|
-
const status = task.status ? ` ${task.status}` : '';
|
|
62
|
-
this.output = `${task.action}...${frame}${status}\n`;
|
|
63
|
-
this._write(std, output);
|
|
67
|
+
const status = this.task.status ? ` ${this.task.status}` : '';
|
|
68
|
+
this.output = `${this.task.action}...${frame}${status}\n`;
|
|
69
|
+
this._write(this.std, this.output);
|
|
64
70
|
}
|
|
65
71
|
_reset() {
|
|
66
72
|
if (!this.output)
|
package/lib/config/ts-node.js
CHANGED
|
@@ -24,7 +24,11 @@ function loadTSConfig(root) {
|
|
|
24
24
|
try {
|
|
25
25
|
typescript = require((0, node_path_1.join)(root, 'node_modules', 'typescript'));
|
|
26
26
|
}
|
|
27
|
-
catch {
|
|
27
|
+
catch {
|
|
28
|
+
debug(`Could not find typescript dependency. Skipping ts-node registration for ${root}.`);
|
|
29
|
+
(0, errors_1.memoizedWarn)('Could not find typescript. Please ensure that typescript is a devDependency. Falling back to compiled source.');
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
28
32
|
}
|
|
29
33
|
if ((0, node_fs_1.existsSync)(tsconfigPath) && typescript) {
|
|
30
34
|
const tsconfig = typescript.parseConfigFileTextToJson(tsconfigPath, (0, util_1.readJsonSync)(tsconfigPath, false)).config;
|
|
@@ -45,7 +49,15 @@ function registerTSNode(root) {
|
|
|
45
49
|
debug('registering ts-node at', root);
|
|
46
50
|
const tsNodePath = require.resolve('ts-node', { paths: [root, __dirname] });
|
|
47
51
|
debug('ts-node path:', tsNodePath);
|
|
48
|
-
|
|
52
|
+
let tsNode;
|
|
53
|
+
try {
|
|
54
|
+
tsNode = require(tsNodePath);
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
debug(`Could not find ts-node at ${tsNodePath}. Skipping ts-node registration for ${root}.`);
|
|
58
|
+
(0, errors_1.memoizedWarn)(`Could not find ts-node at ${tsNodePath}. Please ensure that ts-node is a devDependency. Falling back to compiled source.`);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
49
61
|
const typeRoots = [
|
|
50
62
|
(0, node_path_1.join)(root, 'node_modules', '@types'),
|
|
51
63
|
];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oclif/core",
|
|
3
3
|
"description": "base library for oclif CLIs",
|
|
4
|
-
"version": "3.0.0-beta.
|
|
4
|
+
"version": "3.0.0-beta.17",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"bugs": "https://github.com/oclif/core/issues",
|
|
7
7
|
"dependencies": {
|
|
@@ -28,8 +28,6 @@
|
|
|
28
28
|
"strip-ansi": "^6.0.1",
|
|
29
29
|
"supports-color": "^8.1.1",
|
|
30
30
|
"supports-hyperlinks": "^2.2.0",
|
|
31
|
-
"ts-node": "^10.9.1",
|
|
32
|
-
"tslib": "^2.5.0",
|
|
33
31
|
"widest-line": "^3.1.0",
|
|
34
32
|
"wordwrap": "^1.0.0",
|
|
35
33
|
"wrap-ansi": "^7.0.0"
|
|
@@ -72,6 +70,8 @@
|
|
|
72
70
|
"shx": "^0.3.4",
|
|
73
71
|
"sinon": "^11.1.2",
|
|
74
72
|
"tsd": "^0.29.0",
|
|
73
|
+
"ts-node": "^10.9.1",
|
|
74
|
+
"tslib": "^2.5.0",
|
|
75
75
|
"typescript": "^5"
|
|
76
76
|
},
|
|
77
77
|
"engines": {
|