@oclif/core 4.1.1 → 4.2.1
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/interfaces/hooks.d.ts +11 -0
- package/lib/main.js +12 -11
- package/package.json +2 -2
|
@@ -33,6 +33,13 @@ export interface Hooks {
|
|
|
33
33
|
};
|
|
34
34
|
return: unknown;
|
|
35
35
|
};
|
|
36
|
+
finally: {
|
|
37
|
+
options: {
|
|
38
|
+
argv: string[];
|
|
39
|
+
id: string;
|
|
40
|
+
};
|
|
41
|
+
return: void;
|
|
42
|
+
};
|
|
36
43
|
init: {
|
|
37
44
|
options: {
|
|
38
45
|
argv: string[];
|
|
@@ -105,6 +112,10 @@ export type Hook<T extends keyof P, P extends Hooks = Hooks> = (this: Hook.Conte
|
|
|
105
112
|
context: Context;
|
|
106
113
|
}) => Promise<P[T]['return']>;
|
|
107
114
|
export declare namespace Hook {
|
|
115
|
+
/**
|
|
116
|
+
* Runs at the end of the CLI lifecycle - regardless of success or failure.
|
|
117
|
+
*/
|
|
118
|
+
type Finally = Hook<'finally'>;
|
|
108
119
|
/**
|
|
109
120
|
* Runs when the CLI is initialized before a command is executed.
|
|
110
121
|
*/
|
package/lib/main.js
CHANGED
|
@@ -37,13 +37,6 @@ exports.versionAddition = versionAddition;
|
|
|
37
37
|
async function run(argv, options) {
|
|
38
38
|
const marker = performance_1.Performance.mark(performance_1.OCLIF_MARKER_OWNER, 'main.run');
|
|
39
39
|
const initMarker = performance_1.Performance.mark(performance_1.OCLIF_MARKER_OWNER, 'main.run#init');
|
|
40
|
-
const collectPerf = async () => {
|
|
41
|
-
marker?.stop();
|
|
42
|
-
if (!initMarker?.stopped)
|
|
43
|
-
initMarker?.stop();
|
|
44
|
-
await performance_1.Performance.collect();
|
|
45
|
-
performance_1.Performance.debug();
|
|
46
|
-
};
|
|
47
40
|
const showHelp = async (argv) => {
|
|
48
41
|
const Help = await (0, help_1.loadHelpClass)(config);
|
|
49
42
|
const help = new Help(config, config.pjson.oclif.helpOptions ?? config.pjson.helpOptions);
|
|
@@ -66,18 +59,26 @@ async function run(argv, options) {
|
|
|
66
59
|
argv = [symbols_1.SINGLE_COMMAND_CLI_SYMBOL, ...argv];
|
|
67
60
|
}
|
|
68
61
|
const [id, ...argvSlice] = (0, help_1.normalizeArgv)(config, argv);
|
|
62
|
+
const runFinally = async () => {
|
|
63
|
+
marker?.stop();
|
|
64
|
+
if (!initMarker?.stopped)
|
|
65
|
+
initMarker?.stop();
|
|
66
|
+
await performance_1.Performance.collect();
|
|
67
|
+
performance_1.Performance.debug();
|
|
68
|
+
await config.runHook('finally', { argv: argvSlice, id });
|
|
69
|
+
};
|
|
69
70
|
// run init hook
|
|
70
71
|
await config.runHook('init', { argv: argvSlice, id });
|
|
71
72
|
// display version if applicable
|
|
72
73
|
if ((0, exports.versionAddition)(argv, config)) {
|
|
73
74
|
ux_1.ux.stdout(config.userAgent);
|
|
74
|
-
await
|
|
75
|
+
await runFinally();
|
|
75
76
|
return;
|
|
76
77
|
}
|
|
77
78
|
// display help version if applicable
|
|
78
79
|
if ((0, exports.helpAddition)(argv, config)) {
|
|
79
80
|
await showHelp(argv);
|
|
80
|
-
await
|
|
81
|
+
await runFinally();
|
|
81
82
|
return;
|
|
82
83
|
}
|
|
83
84
|
// find & run command
|
|
@@ -86,7 +87,7 @@ async function run(argv, options) {
|
|
|
86
87
|
const topic = config.flexibleTaxonomy ? null : config.findTopic(id);
|
|
87
88
|
if (topic) {
|
|
88
89
|
await showHelp([id]);
|
|
89
|
-
await
|
|
90
|
+
await runFinally();
|
|
90
91
|
return;
|
|
91
92
|
}
|
|
92
93
|
}
|
|
@@ -95,6 +96,6 @@ async function run(argv, options) {
|
|
|
95
96
|
return await config.runCommand(id, argvSlice, cmd);
|
|
96
97
|
}
|
|
97
98
|
finally {
|
|
98
|
-
await
|
|
99
|
+
await runFinally();
|
|
99
100
|
}
|
|
100
101
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oclif/core",
|
|
3
3
|
"description": "base library for oclif CLIs",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.2.1",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"bugs": "https://github.com/oclif/core/issues",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"ansi-escapes": "^4.3.2",
|
|
9
|
-
"ansis": "^3.
|
|
9
|
+
"ansis": "^3.5.2",
|
|
10
10
|
"clean-stack": "^3.0.1",
|
|
11
11
|
"cli-spinners": "^2.9.2",
|
|
12
12
|
"debug": "^4.4.0",
|