@oclif/core 2.5.0 → 2.5.2
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/config/plugin.d.ts +1 -0
- package/lib/config/plugin.js +5 -2
- package/lib/config/ts-node.d.ts +4 -4
- package/lib/config/ts-node.js +45 -4
- package/lib/performance.d.ts +1 -0
- package/lib/performance.js +7 -0
- package/package.json +3 -3
package/lib/config/plugin.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export declare class Plugin implements IPlugin {
|
|
|
24
24
|
parent: Plugin | undefined;
|
|
25
25
|
children: Plugin[];
|
|
26
26
|
hasManifest: boolean;
|
|
27
|
+
private _commandsDir;
|
|
27
28
|
protected _debug: (..._: any) => void;
|
|
28
29
|
protected warned: boolean;
|
|
29
30
|
constructor(options: PluginOptions);
|
package/lib/config/plugin.js
CHANGED
|
@@ -141,7 +141,10 @@ class Plugin {
|
|
|
141
141
|
return topicsToArray(this.pjson.oclif.topics || {});
|
|
142
142
|
}
|
|
143
143
|
get commandsDir() {
|
|
144
|
-
|
|
144
|
+
if (this._commandsDir)
|
|
145
|
+
return this._commandsDir;
|
|
146
|
+
this._commandsDir = (0, ts_node_1.tsPath)(this.root, this.pjson.oclif.commands, this.type);
|
|
147
|
+
return this._commandsDir;
|
|
145
148
|
}
|
|
146
149
|
get commandIDs() {
|
|
147
150
|
if (!this.commandsDir)
|
|
@@ -179,7 +182,7 @@ class Plugin {
|
|
|
179
182
|
};
|
|
180
183
|
let m;
|
|
181
184
|
try {
|
|
182
|
-
const p = path.join(this.pjson.oclif.commands, ...id.split(':'));
|
|
185
|
+
const p = path.join(this.commandsDir ?? this.pjson.oclif.commands, ...id.split(':'));
|
|
183
186
|
const { isESM, module, filePath } = await module_loader_1.default.loadWithData(this, p);
|
|
184
187
|
this._debug(isESM ? '(import)' : '(require)', filePath);
|
|
185
188
|
m = module;
|
package/lib/config/ts-node.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Convert a path from the compiled ./lib files to the ./src typescript source
|
|
3
3
|
* this is for developing typescript plugins/CLIs
|
|
4
|
-
* if there is a tsconfig and the original sources exist, it attempts to require ts-
|
|
4
|
+
* if there is a tsconfig and the original sources exist, it attempts to require ts-node
|
|
5
5
|
*/
|
|
6
|
-
export declare function tsPath(root: string, orig: string): string;
|
|
7
|
-
export declare function tsPath(root: string, orig: string | undefined): string | undefined;
|
|
6
|
+
export declare function tsPath(root: string, orig: string, type?: string): string;
|
|
7
|
+
export declare function tsPath(root: string, orig: string | undefined, type?: string): string | undefined;
|
package/lib/config/ts-node.js
CHANGED
|
@@ -8,6 +8,8 @@ const util_1 = require("../util");
|
|
|
8
8
|
const util_2 = require("./util");
|
|
9
9
|
// eslint-disable-next-line new-cap
|
|
10
10
|
const debug = (0, util_2.Debug)('ts-node');
|
|
11
|
+
const TYPE_ROOTS = [`${__dirname}/../node_modules/@types`];
|
|
12
|
+
const ROOT_DIRS = [];
|
|
11
13
|
function loadTSConfig(root) {
|
|
12
14
|
const tsconfigPath = path.join(root, 'tsconfig.json');
|
|
13
15
|
let typescript;
|
|
@@ -29,19 +31,58 @@ function loadTSConfig(root) {
|
|
|
29
31
|
return tsconfig;
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
|
-
function
|
|
34
|
+
function registerTSNode(root) {
|
|
35
|
+
const tsconfig = loadTSConfig(root);
|
|
36
|
+
if (!tsconfig)
|
|
37
|
+
return;
|
|
38
|
+
debug('registering ts-node at', root);
|
|
39
|
+
const tsNodePath = require.resolve('ts-node', { paths: [root, __dirname] });
|
|
40
|
+
const tsNode = require(tsNodePath);
|
|
41
|
+
TYPE_ROOTS.push(`${root}/node_modules/@types`);
|
|
42
|
+
if (tsconfig.compilerOptions.rootDirs) {
|
|
43
|
+
ROOT_DIRS.push(...tsconfig.compilerOptions.rootDirs.map(r => path.join(root, r)));
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
ROOT_DIRS.push(`${root}/src`);
|
|
47
|
+
}
|
|
48
|
+
const cwd = process.cwd();
|
|
49
|
+
try {
|
|
50
|
+
process.chdir(root);
|
|
51
|
+
tsNode.register({
|
|
52
|
+
skipProject: true,
|
|
53
|
+
transpileOnly: true,
|
|
54
|
+
compilerOptions: {
|
|
55
|
+
esModuleInterop: tsconfig.compilerOptions.esModuleInterop,
|
|
56
|
+
target: tsconfig.compilerOptions.target || 'es2017',
|
|
57
|
+
experimentalDecorators: tsconfig.compilerOptions.experimentalDecorators || false,
|
|
58
|
+
emitDecoratorMetadata: tsconfig.compilerOptions.emitDecoratorMetadata || false,
|
|
59
|
+
module: 'commonjs',
|
|
60
|
+
sourceMap: true,
|
|
61
|
+
rootDirs: ROOT_DIRS,
|
|
62
|
+
typeRoots: TYPE_ROOTS,
|
|
63
|
+
jsx: 'react',
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
return tsconfig;
|
|
67
|
+
}
|
|
68
|
+
finally {
|
|
69
|
+
process.chdir(cwd);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function tsPath(root, orig, type) {
|
|
33
73
|
if (!orig)
|
|
34
74
|
return orig;
|
|
35
|
-
orig = path.join(root, orig);
|
|
75
|
+
orig = orig.startsWith(root) ? orig : path.join(root, orig);
|
|
36
76
|
const skipTSNode =
|
|
37
77
|
// the CLI specifically turned it off
|
|
38
78
|
(settings_1.settings.tsnodeEnabled === false) ||
|
|
39
79
|
// the CLI didn't specify ts-node and it is production
|
|
40
80
|
(settings_1.settings.tsnodeEnabled === undefined && (0, util_1.isProd)());
|
|
41
|
-
|
|
81
|
+
// We always want to load the tsconfig for linked plugins.
|
|
82
|
+
if (skipTSNode && type !== 'link')
|
|
42
83
|
return orig;
|
|
43
84
|
try {
|
|
44
|
-
const tsconfig = loadTSConfig(root);
|
|
85
|
+
const tsconfig = type === 'link' ? registerTSNode(root) : loadTSConfig(root);
|
|
45
86
|
if (!tsconfig)
|
|
46
87
|
return orig;
|
|
47
88
|
const { rootDir, rootDirs, outDir } = tsconfig.compilerOptions;
|
package/lib/performance.d.ts
CHANGED
package/lib/performance.js
CHANGED
|
@@ -7,6 +7,7 @@ class Marker {
|
|
|
7
7
|
constructor(name, details = {}) {
|
|
8
8
|
this.name = name;
|
|
9
9
|
this.details = details;
|
|
10
|
+
this.stopped = false;
|
|
10
11
|
this.startMarker = `${this.name}-start`;
|
|
11
12
|
this.stopMarker = `${this.name}-stop`;
|
|
12
13
|
const [caller, scope] = name.split('#');
|
|
@@ -20,6 +21,7 @@ class Marker {
|
|
|
20
21
|
this.details = { ...this.details, ...details };
|
|
21
22
|
}
|
|
22
23
|
stop() {
|
|
24
|
+
this.stopped = true;
|
|
23
25
|
perf_hooks_1.performance.mark(this.stopMarker);
|
|
24
26
|
}
|
|
25
27
|
measure() {
|
|
@@ -65,6 +67,11 @@ class Performance {
|
|
|
65
67
|
static async collect() {
|
|
66
68
|
if (!Performance.enabled)
|
|
67
69
|
return;
|
|
70
|
+
if (Performance._results.length > 0)
|
|
71
|
+
return;
|
|
72
|
+
for (const marker of Object.values(Performance.markers).filter(m => !m.stopped)) {
|
|
73
|
+
marker.stop();
|
|
74
|
+
}
|
|
68
75
|
return new Promise(resolve => {
|
|
69
76
|
const perfObserver = new perf_hooks_1.PerformanceObserver(items => {
|
|
70
77
|
for (const entry of items.getEntries()) {
|
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": "2.5.
|
|
4
|
+
"version": "2.5.2",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"bugs": "https://github.com/oclif/core/issues",
|
|
7
7
|
"dependencies": {
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"strip-ansi": "^6.0.1",
|
|
30
30
|
"supports-color": "^8.1.1",
|
|
31
31
|
"supports-hyperlinks": "^2.2.0",
|
|
32
|
+
"ts-node": "^10.9.1",
|
|
32
33
|
"tslib": "^2.5.0",
|
|
33
34
|
"widest-line": "^3.1.0",
|
|
34
35
|
"wordwrap": "^1.0.0",
|
|
@@ -36,7 +37,7 @@
|
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
39
|
"@commitlint/config-conventional": "^12.1.4",
|
|
39
|
-
"@oclif/plugin-help": "^5.2.
|
|
40
|
+
"@oclif/plugin-help": "^5.2.7",
|
|
40
41
|
"@oclif/plugin-plugins": "^2.3.2",
|
|
41
42
|
"@oclif/test": "^2.3.7",
|
|
42
43
|
"@types/ansi-styles": "^3.2.1",
|
|
@@ -73,7 +74,6 @@
|
|
|
73
74
|
"shelljs": "^0.8.5",
|
|
74
75
|
"shx": "^0.3.4",
|
|
75
76
|
"sinon": "^11.1.2",
|
|
76
|
-
"ts-node": "^10.9.1",
|
|
77
77
|
"tsd": "^0.25.0",
|
|
78
78
|
"typescript": "^4.9.5"
|
|
79
79
|
},
|