@oclif/core 4.0.5 → 4.0.7
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-loader.js +2 -1
- package/lib/help/index.js +3 -0
- package/lib/util/fs.d.ts +20 -4
- package/lib/util/fs.js +23 -17
- package/package.json +4 -4
|
@@ -169,7 +169,8 @@ class PluginLoader {
|
|
|
169
169
|
try {
|
|
170
170
|
const userPJSONPath = (0, node_path_1.join)(opts.dataDir, 'package.json');
|
|
171
171
|
debug('reading user plugins pjson %s', userPJSONPath);
|
|
172
|
-
|
|
172
|
+
// ignore cache because the file might have changed within the same process (e.g. during a JIT plugin install)
|
|
173
|
+
const pjson = await (0, fs_1.readJson)(userPJSONPath, false);
|
|
173
174
|
if (!pjson.oclif)
|
|
174
175
|
pjson.oclif = { schema: 1 };
|
|
175
176
|
if (!pjson.oclif.plugins)
|
package/lib/help/index.js
CHANGED
|
@@ -195,6 +195,9 @@ class Help extends HelpBase {
|
|
|
195
195
|
if (this.config.isSingleCommandCLI) {
|
|
196
196
|
const rootCmd = this.config.findCommand(symbols_1.SINGLE_COMMAND_CLI_SYMBOL);
|
|
197
197
|
if (rootCmd) {
|
|
198
|
+
// set the command id to an empty string to prevent the
|
|
199
|
+
// SINGLE_COMMAND_CLI_SYMBOL from being displayed in the help output
|
|
200
|
+
rootCmd.id = '';
|
|
198
201
|
await this.showCommandHelp(rootCmd);
|
|
199
202
|
return;
|
|
200
203
|
}
|
package/lib/util/fs.d.ts
CHANGED
|
@@ -12,8 +12,24 @@ export declare const dirExists: (input: string) => Promise<string>;
|
|
|
12
12
|
* @returns Promise<string>
|
|
13
13
|
*/
|
|
14
14
|
export declare const fileExists: (input: string) => Promise<string>;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Read a file from disk and cache its contents if in production environment.
|
|
17
|
+
*
|
|
18
|
+
* Will throw an error if the file does not exist.
|
|
19
|
+
*
|
|
20
|
+
* @param path file path of JSON file
|
|
21
|
+
* @param useCache if false, ignore cache and read file from disk
|
|
22
|
+
* @returns <T>
|
|
23
|
+
*/
|
|
24
|
+
export declare function readJson<T = unknown>(path: string, useCache?: boolean): Promise<T>;
|
|
25
|
+
/**
|
|
26
|
+
* Safely read a file from disk and cache its contents if in production environment.
|
|
27
|
+
*
|
|
28
|
+
* Will return undefined if the file does not exist.
|
|
29
|
+
*
|
|
30
|
+
* @param path file path of JSON file
|
|
31
|
+
* @param useCache if false, ignore cache and read file from disk
|
|
32
|
+
* @returns <T> or undefined
|
|
33
|
+
*/
|
|
34
|
+
export declare function safeReadJson<T>(path: string, useCache?: boolean): Promise<T | undefined>;
|
|
19
35
|
export declare function existsSync(path: string): boolean;
|
package/lib/util/fs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.existsSync = exports.safeReadJson = exports.
|
|
3
|
+
exports.existsSync = exports.safeReadJson = exports.readJson = exports.fileExists = exports.dirExists = void 0;
|
|
4
4
|
const node_fs_1 = require("node:fs");
|
|
5
5
|
const promises_1 = require("node:fs/promises");
|
|
6
6
|
const util_1 = require("./util");
|
|
@@ -53,8 +53,17 @@ class ProdOnlyCache extends Map {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
const cache = new ProdOnlyCache();
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Read a file from disk and cache its contents if in production environment.
|
|
58
|
+
*
|
|
59
|
+
* Will throw an error if the file does not exist.
|
|
60
|
+
*
|
|
61
|
+
* @param path file path of JSON file
|
|
62
|
+
* @param useCache if false, ignore cache and read file from disk
|
|
63
|
+
* @returns <T>
|
|
64
|
+
*/
|
|
65
|
+
async function readJson(path, useCache = true) {
|
|
66
|
+
if (useCache && cache.has(path)) {
|
|
58
67
|
return JSON.parse(cache.get(path));
|
|
59
68
|
}
|
|
60
69
|
const contents = await (0, promises_1.readFile)(path, 'utf8');
|
|
@@ -62,21 +71,18 @@ async function readJson(path) {
|
|
|
62
71
|
return JSON.parse(contents);
|
|
63
72
|
}
|
|
64
73
|
exports.readJson = readJson;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
async function safeReadJson(path) {
|
|
75
|
-
if (cache.has(path)) {
|
|
76
|
-
return JSON.parse(cache.get(path));
|
|
77
|
-
}
|
|
74
|
+
/**
|
|
75
|
+
* Safely read a file from disk and cache its contents if in production environment.
|
|
76
|
+
*
|
|
77
|
+
* Will return undefined if the file does not exist.
|
|
78
|
+
*
|
|
79
|
+
* @param path file path of JSON file
|
|
80
|
+
* @param useCache if false, ignore cache and read file from disk
|
|
81
|
+
* @returns <T> or undefined
|
|
82
|
+
*/
|
|
83
|
+
async function safeReadJson(path, useCache = true) {
|
|
78
84
|
try {
|
|
79
|
-
return await readJson(path);
|
|
85
|
+
return await readJson(path, useCache);
|
|
80
86
|
}
|
|
81
87
|
catch { }
|
|
82
88
|
}
|
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": "4.0.
|
|
4
|
+
"version": "4.0.7",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"bugs": "https://github.com/oclif/core/issues",
|
|
7
7
|
"dependencies": {
|
|
@@ -50,18 +50,18 @@
|
|
|
50
50
|
"cross-env": "^7.0.3",
|
|
51
51
|
"eslint": "^8.57.0",
|
|
52
52
|
"eslint-config-oclif": "^5.2.0",
|
|
53
|
-
"eslint-config-oclif-typescript": "^3.1.
|
|
53
|
+
"eslint-config-oclif-typescript": "^3.1.8",
|
|
54
54
|
"eslint-config-prettier": "^9.1.0",
|
|
55
55
|
"husky": "^9",
|
|
56
56
|
"lint-staged": "^15",
|
|
57
57
|
"madge": "^6.1.0",
|
|
58
58
|
"mocha": "^10.4.0",
|
|
59
59
|
"nyc": "^15.1.0",
|
|
60
|
-
"prettier": "^3.2
|
|
60
|
+
"prettier": "^3.3.2",
|
|
61
61
|
"shx": "^0.3.4",
|
|
62
62
|
"sinon": "^18",
|
|
63
63
|
"ts-node": "^10.9.2",
|
|
64
|
-
"tsd": "^0.31.
|
|
64
|
+
"tsd": "^0.31.1",
|
|
65
65
|
"typescript": "^5"
|
|
66
66
|
},
|
|
67
67
|
"engines": {
|