@oclif/core 3.21.2 → 3.22.0
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/config.js
CHANGED
|
@@ -10,6 +10,11 @@ type LoadOpts = {
|
|
|
10
10
|
force?: boolean;
|
|
11
11
|
rootPlugin: IPlugin;
|
|
12
12
|
userPlugins?: boolean;
|
|
13
|
+
pluginAdditions?: {
|
|
14
|
+
core?: string[];
|
|
15
|
+
dev?: string[];
|
|
16
|
+
path?: string;
|
|
17
|
+
};
|
|
13
18
|
};
|
|
14
19
|
type PluginsMap = Map<string, IPlugin>;
|
|
15
20
|
export default class PluginLoader {
|
|
@@ -23,6 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const minimatch_1 = require("minimatch");
|
|
26
27
|
const node_path_1 = require("node:path");
|
|
27
28
|
const performance_1 = require("../performance");
|
|
28
29
|
const fs_1 = require("../util/fs");
|
|
@@ -31,6 +32,9 @@ const Plugin = __importStar(require("./plugin"));
|
|
|
31
32
|
const util_2 = require("./util");
|
|
32
33
|
// eslint-disable-next-line new-cap
|
|
33
34
|
const debug = (0, util_2.Debug)();
|
|
35
|
+
function findMatchingDependencies(dependencies, patterns) {
|
|
36
|
+
return Object.keys(dependencies).filter((p) => patterns.some((w) => (0, minimatch_1.minimatch)(p, w)));
|
|
37
|
+
}
|
|
34
38
|
class PluginLoader {
|
|
35
39
|
options;
|
|
36
40
|
errors = [];
|
|
@@ -75,8 +79,23 @@ class PluginLoader {
|
|
|
75
79
|
return rootPlugin;
|
|
76
80
|
}
|
|
77
81
|
async loadCorePlugins(opts) {
|
|
78
|
-
|
|
79
|
-
|
|
82
|
+
const { plugins: corePlugins } = opts.rootPlugin.pjson.oclif;
|
|
83
|
+
if (corePlugins) {
|
|
84
|
+
const plugins = findMatchingDependencies(opts.rootPlugin.pjson.dependencies ?? {}, corePlugins);
|
|
85
|
+
await this.loadPlugins(opts.rootPlugin.root, 'core', plugins);
|
|
86
|
+
}
|
|
87
|
+
const { core: pluginAdditionsCore, path } = opts.pluginAdditions ?? { core: [] };
|
|
88
|
+
if (pluginAdditionsCore) {
|
|
89
|
+
if (path) {
|
|
90
|
+
// If path is provided, load plugins from the path
|
|
91
|
+
const pjson = await (0, fs_1.readJson)((0, node_path_1.join)(path, 'package.json'));
|
|
92
|
+
const plugins = findMatchingDependencies(pjson.dependencies ?? {}, pluginAdditionsCore);
|
|
93
|
+
await this.loadPlugins(path, 'core', plugins);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
const plugins = findMatchingDependencies(opts.rootPlugin.pjson.dependencies ?? {}, pluginAdditionsCore);
|
|
97
|
+
await this.loadPlugins(opts.rootPlugin.root, 'core', plugins);
|
|
98
|
+
}
|
|
80
99
|
}
|
|
81
100
|
}
|
|
82
101
|
async loadDevPlugins(opts) {
|
|
@@ -86,8 +105,26 @@ class PluginLoader {
|
|
|
86
105
|
return;
|
|
87
106
|
try {
|
|
88
107
|
const { devPlugins } = opts.rootPlugin.pjson.oclif;
|
|
89
|
-
if (devPlugins)
|
|
90
|
-
|
|
108
|
+
if (devPlugins) {
|
|
109
|
+
const allDeps = { ...opts.rootPlugin.pjson.dependencies, ...opts.rootPlugin.pjson.devDependencies };
|
|
110
|
+
const plugins = findMatchingDependencies(allDeps ?? {}, devPlugins);
|
|
111
|
+
await this.loadPlugins(opts.rootPlugin.root, 'dev', plugins);
|
|
112
|
+
}
|
|
113
|
+
const { dev: pluginAdditionsDev, path } = opts.pluginAdditions ?? { core: [] };
|
|
114
|
+
if (pluginAdditionsDev) {
|
|
115
|
+
if (path) {
|
|
116
|
+
// If path is provided, load plugins from the path
|
|
117
|
+
const pjson = await (0, fs_1.readJson)((0, node_path_1.join)(path, 'package.json'));
|
|
118
|
+
const allDeps = { ...pjson.dependencies, ...pjson.devDependencies };
|
|
119
|
+
const plugins = findMatchingDependencies(allDeps ?? {}, pluginAdditionsDev);
|
|
120
|
+
await this.loadPlugins(path, 'dev', plugins);
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
const allDeps = { ...opts.rootPlugin.pjson.dependencies, ...opts.rootPlugin.pjson.devDependencies };
|
|
124
|
+
const plugins = findMatchingDependencies(allDeps ?? {}, pluginAdditionsDev);
|
|
125
|
+
await this.loadPlugins(opts.rootPlugin.root, 'dev', plugins);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
91
128
|
}
|
|
92
129
|
catch (error) {
|
|
93
130
|
process.emitWarning(error);
|
|
@@ -136,7 +173,13 @@ class PluginLoader {
|
|
|
136
173
|
parent.children = [];
|
|
137
174
|
parent.children.push(instance);
|
|
138
175
|
}
|
|
139
|
-
|
|
176
|
+
if (instance.pjson.oclif.plugins) {
|
|
177
|
+
const allDeps = type === 'dev'
|
|
178
|
+
? { ...instance.pjson.dependencies, ...instance.pjson.devDependencies }
|
|
179
|
+
: instance.pjson.dependencies;
|
|
180
|
+
const plugins = findMatchingDependencies(allDeps ?? {}, instance.pjson.oclif.plugins);
|
|
181
|
+
await this.loadPlugins(instance.root, type, plugins, instance);
|
|
182
|
+
}
|
|
140
183
|
}
|
|
141
184
|
catch (error) {
|
|
142
185
|
this.errors.push(error);
|
|
@@ -22,6 +22,11 @@ export interface Options extends PluginOptions {
|
|
|
22
22
|
enablePerf?: boolean;
|
|
23
23
|
jitPlugins?: boolean;
|
|
24
24
|
pjson?: PJSON.Plugin;
|
|
25
|
+
pluginAdditions?: {
|
|
26
|
+
core?: string[];
|
|
27
|
+
dev?: string[];
|
|
28
|
+
path?: string;
|
|
29
|
+
};
|
|
25
30
|
plugins?: Map<string, Plugin>;
|
|
26
31
|
userPlugins?: boolean;
|
|
27
32
|
version?: string;
|
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.
|
|
4
|
+
"version": "3.22.0",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"bugs": "https://github.com/oclif/core/issues",
|
|
7
7
|
"dependencies": {
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"indent-string": "^4.0.0",
|
|
22
22
|
"is-wsl": "^2.2.0",
|
|
23
23
|
"js-yaml": "^3.14.1",
|
|
24
|
+
"minimatch": "^9.0.3",
|
|
24
25
|
"natural-orderby": "^2.0.3",
|
|
25
26
|
"object-treeify": "^1.1.33",
|
|
26
27
|
"password-prompt": "^1.1.3",
|