@oclif/core 3.20.1-dev.0 → 3.21.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/cache.d.ts +4 -4
- package/lib/cli-ux/styled/table.js +1 -1
- package/lib/config/config.js +1 -1
- package/lib/config/plugin-loader.d.ts +4 -1
- package/lib/config/plugin-loader.js +2 -2
- package/lib/config/plugin.js +7 -5
- package/lib/execute.d.ts +1 -1
- package/lib/execute.js +4 -0
- package/lib/interfaces/plugin.d.ts +2 -0
- package/package.json +3 -3
package/lib/cache.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { PJSON, Plugin } from './interfaces';
|
|
2
|
+
type OclifCoreInfo = {
|
|
3
|
+
name: string;
|
|
4
|
+
version: string;
|
|
5
|
+
};
|
|
2
6
|
type CacheContents = {
|
|
3
7
|
rootPlugin: Plugin;
|
|
4
8
|
exitCodes: PJSON.Plugin['oclif']['exitCodes'];
|
|
5
9
|
'@oclif/core': OclifCoreInfo;
|
|
6
10
|
};
|
|
7
11
|
type ValueOf<T> = T[keyof T];
|
|
8
|
-
type OclifCoreInfo = {
|
|
9
|
-
name: string;
|
|
10
|
-
version: string;
|
|
11
|
-
};
|
|
12
12
|
/**
|
|
13
13
|
* A simple cache for storing values that need to be accessed globally.
|
|
14
14
|
*/
|
|
@@ -155,7 +155,7 @@ class Table {
|
|
|
155
155
|
getCSVRow(d) {
|
|
156
156
|
const values = this.columns.map((col) => d[col.key] || '');
|
|
157
157
|
const lineToBeEscaped = values.find((e) => e.includes('"') || e.includes('\n') || e.includes('\r\n') || e.includes('\r') || e.includes(','));
|
|
158
|
-
return values.map((e) => (lineToBeEscaped ? `"${e.
|
|
158
|
+
return values.map((e) => (lineToBeEscaped ? `"${e.replaceAll('"', '""')}"` : e));
|
|
159
159
|
}
|
|
160
160
|
outputCSV() {
|
|
161
161
|
const { columns, data, options } = this;
|
package/lib/config/config.js
CHANGED
|
@@ -263,7 +263,7 @@ class Config {
|
|
|
263
263
|
(settings_1.settings.performanceEnabled === undefined ? this.options.enablePerf : settings_1.settings.performanceEnabled) ?? false;
|
|
264
264
|
const marker = performance_1.Performance.mark(performance_1.OCLIF_MARKER_OWNER, 'config.load');
|
|
265
265
|
this.pluginLoader = new plugin_loader_1.default({ plugins: this.options.plugins, root: this.options.root });
|
|
266
|
-
this.rootPlugin = await this.pluginLoader.loadRoot();
|
|
266
|
+
this.rootPlugin = await this.pluginLoader.loadRoot({ pjson: this.options.pjson });
|
|
267
267
|
// Cache the root plugin so that we can reference it later when determining if
|
|
268
268
|
// we should skip ts-node registration for an ESM plugin.
|
|
269
269
|
const cache = cache_1.default.getInstance();
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PJSON } from '../interfaces';
|
|
1
2
|
import { Plugin as IPlugin } from '../interfaces/plugin';
|
|
2
3
|
type PluginLoaderOptions = {
|
|
3
4
|
plugins?: IPlugin[] | PluginsMap;
|
|
@@ -21,7 +22,9 @@ export default class PluginLoader {
|
|
|
21
22
|
errors: (Error | string)[];
|
|
22
23
|
plugins: PluginsMap;
|
|
23
24
|
}>;
|
|
24
|
-
loadRoot(
|
|
25
|
+
loadRoot({ pjson }: {
|
|
26
|
+
pjson?: PJSON.Plugin;
|
|
27
|
+
}): Promise<IPlugin>;
|
|
25
28
|
private loadCorePlugins;
|
|
26
29
|
private loadDevPlugins;
|
|
27
30
|
private loadPlugins;
|
|
@@ -51,7 +51,7 @@ class PluginLoader {
|
|
|
51
51
|
}
|
|
52
52
|
return { errors: this.errors, plugins: this.plugins };
|
|
53
53
|
}
|
|
54
|
-
async loadRoot() {
|
|
54
|
+
async loadRoot({ pjson }) {
|
|
55
55
|
let rootPlugin;
|
|
56
56
|
if (this.pluginsProvided) {
|
|
57
57
|
const plugins = [...this.plugins.values()];
|
|
@@ -59,7 +59,7 @@ class PluginLoader {
|
|
|
59
59
|
}
|
|
60
60
|
else {
|
|
61
61
|
const marker = performance_1.Performance.mark(performance_1.OCLIF_MARKER_OWNER, 'plugin.load#root');
|
|
62
|
-
rootPlugin = new Plugin.Plugin({ isRoot: true, root: this.options.root });
|
|
62
|
+
rootPlugin = new Plugin.Plugin({ isRoot: true, pjson, root: this.options.root });
|
|
63
63
|
await rootPlugin.load();
|
|
64
64
|
marker?.addDetails({
|
|
65
65
|
commandCount: rootPlugin.commands.length,
|
package/lib/config/plugin.js
CHANGED
|
@@ -175,19 +175,22 @@ class Plugin {
|
|
|
175
175
|
// Linked plugins already have a root so there's no need to search for it.
|
|
176
176
|
// However there could be child plugins nested inside the linked plugin, in which
|
|
177
177
|
// case we still need to search for the child plugin's root.
|
|
178
|
-
const root = this.
|
|
178
|
+
const root = this.options.pjson && this.options.isRoot
|
|
179
|
+
? this.options.root
|
|
180
|
+
: this.type === 'link' && !this.parent
|
|
181
|
+
? this.options.root
|
|
182
|
+
: await (0, find_root_1.findRoot)(this.options.name, this.options.root);
|
|
179
183
|
if (!root)
|
|
180
184
|
throw new errors_1.CLIError(`could not find package.json with ${(0, node_util_1.inspect)(this.options)}`);
|
|
181
185
|
this.root = root;
|
|
182
186
|
this._debug(`loading ${this.type} plugin from ${root}`);
|
|
183
|
-
this.pjson = await (0, fs_1.readJson)((0, node_path_1.join)(root, 'package.json'));
|
|
187
|
+
this.pjson = this.options.pjson ?? (await (0, fs_1.readJson)((0, node_path_1.join)(root, 'package.json')));
|
|
184
188
|
this.flexibleTaxonomy = this.options?.flexibleTaxonomy || this.pjson.oclif?.flexibleTaxonomy || false;
|
|
185
189
|
this.moduleType = this.pjson.type === 'module' ? 'module' : 'commonjs';
|
|
186
190
|
this.name = this.pjson.name;
|
|
187
191
|
this.alias = this.options.name ?? this.pjson.name;
|
|
188
|
-
const pjsonPath = (0, node_path_1.join)(root, 'package.json');
|
|
189
192
|
if (!this.name)
|
|
190
|
-
throw new errors_1.CLIError(`no name in ${
|
|
193
|
+
throw new errors_1.CLIError(`no name in package.json (${root})`);
|
|
191
194
|
// eslint-disable-next-line new-cap
|
|
192
195
|
this._debug = (0, util_2.Debug)(this.name);
|
|
193
196
|
this.version = this.pjson.version;
|
|
@@ -364,7 +367,6 @@ class Plugin {
|
|
|
364
367
|
}
|
|
365
368
|
}
|
|
366
369
|
warn(err, scope) {
|
|
367
|
-
console.trace();
|
|
368
370
|
if (this.warned)
|
|
369
371
|
return;
|
|
370
372
|
if (typeof err === 'string')
|
package/lib/execute.d.ts
CHANGED
package/lib/execute.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.execute = void 0;
|
|
4
4
|
const flush_1 = require("./cli-ux/flush");
|
|
5
|
+
const errors_1 = require("./errors");
|
|
5
6
|
const handle_1 = require("./errors/handle");
|
|
6
7
|
const main_1 = require("./main");
|
|
7
8
|
const settings_1 = require("./settings");
|
|
@@ -46,6 +47,9 @@ const settings_1 = require("./settings");
|
|
|
46
47
|
* ```
|
|
47
48
|
*/
|
|
48
49
|
async function execute(options) {
|
|
50
|
+
if (!options.dir && !options.loadOptions) {
|
|
51
|
+
throw new errors_1.CLIError('dir or loadOptions is required.');
|
|
52
|
+
}
|
|
49
53
|
if (options.development) {
|
|
50
54
|
// In dev mode -> use ts-node and dev plugins
|
|
51
55
|
process.env.NODE_ENV = 'development';
|
|
@@ -9,6 +9,7 @@ export interface PluginOptions {
|
|
|
9
9
|
isRoot?: boolean;
|
|
10
10
|
name?: string;
|
|
11
11
|
parent?: Plugin;
|
|
12
|
+
pjson?: PJSON.Plugin;
|
|
12
13
|
respectNoCacheDefault?: boolean;
|
|
13
14
|
root: string;
|
|
14
15
|
tag?: string;
|
|
@@ -20,6 +21,7 @@ export interface Options extends PluginOptions {
|
|
|
20
21
|
devPlugins?: boolean;
|
|
21
22
|
enablePerf?: boolean;
|
|
22
23
|
jitPlugins?: boolean;
|
|
24
|
+
pjson?: PJSON.Plugin;
|
|
23
25
|
plugins?: Map<string, Plugin>;
|
|
24
26
|
userPlugins?: boolean;
|
|
25
27
|
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.21.0",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"bugs": "https://github.com/oclif/core/issues",
|
|
7
7
|
"dependencies": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@oclif/plugin-help": "^6",
|
|
39
39
|
"@oclif/plugin-plugins": "^4",
|
|
40
40
|
"@oclif/prettier-config": "^0.2.1",
|
|
41
|
-
"@oclif/test": "^3.1
|
|
41
|
+
"@oclif/test": "^3.2.1",
|
|
42
42
|
"@types/ansi-styles": "^3.2.1",
|
|
43
43
|
"@types/benchmark": "^2.1.5",
|
|
44
44
|
"@types/chai": "^4.3.11",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"chai-as-promised": "^7.1.1",
|
|
64
64
|
"commitlint": "^17.8.1",
|
|
65
65
|
"cross-env": "^7.0.3",
|
|
66
|
-
"eslint": "^8.
|
|
66
|
+
"eslint": "^8.57.0",
|
|
67
67
|
"eslint-config-oclif": "^5.0.2",
|
|
68
68
|
"eslint-config-oclif-typescript": "^3.0.48",
|
|
69
69
|
"eslint-config-prettier": "^9.1.0",
|