@oclif/core 3.20.0 → 3.20.1-dev.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/cache.d.ts +8 -0
- package/lib/cache.js +23 -0
- package/lib/cli-ux/config.js +3 -2
- package/lib/command.js +2 -2
- package/lib/config/config.d.ts +1 -0
- package/lib/config/config.js +19 -7
- package/lib/config/plugin-loader.d.ts +4 -1
- package/lib/config/plugin-loader.js +2 -2
- package/lib/config/plugin.d.ts +7 -2
- package/lib/config/plugin.js +141 -39
- package/lib/execute.d.ts +1 -1
- package/lib/execute.js +4 -0
- package/lib/help/docopts.js +1 -1
- package/lib/help/index.js +9 -2
- package/lib/interfaces/config.d.ts +1 -0
- package/lib/interfaces/pjson.d.ts +88 -2
- package/lib/interfaces/plugin.d.ts +4 -2
- package/lib/main.js +7 -11
- package/lib/symbols.d.ts +1 -0
- package/lib/symbols.js +4 -0
- package/lib/util/fs.d.ts +0 -1
- package/lib/util/fs.js +1 -6
- package/package.json +1 -3
package/lib/cache.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
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'];
|
|
9
|
+
'@oclif/core': OclifCoreInfo;
|
|
5
10
|
};
|
|
6
11
|
type ValueOf<T> = T[keyof T];
|
|
7
12
|
/**
|
|
@@ -9,8 +14,11 @@ type ValueOf<T> = T[keyof T];
|
|
|
9
14
|
*/
|
|
10
15
|
export default class Cache extends Map<keyof CacheContents, ValueOf<CacheContents>> {
|
|
11
16
|
static instance: Cache;
|
|
17
|
+
constructor();
|
|
12
18
|
static getInstance(): Cache;
|
|
19
|
+
get(key: '@oclif/core'): OclifCoreInfo;
|
|
13
20
|
get(key: 'rootPlugin'): Plugin | undefined;
|
|
14
21
|
get(key: 'exitCodes'): PJSON.Plugin['oclif']['exitCodes'] | undefined;
|
|
22
|
+
private getOclifCoreMeta;
|
|
15
23
|
}
|
|
16
24
|
export {};
|
package/lib/cache.js
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const node_fs_1 = require("node:fs");
|
|
4
|
+
const node_path_1 = require("node:path");
|
|
3
5
|
/**
|
|
4
6
|
* A simple cache for storing values that need to be accessed globally.
|
|
5
7
|
*/
|
|
6
8
|
class Cache extends Map {
|
|
7
9
|
static instance;
|
|
10
|
+
constructor() {
|
|
11
|
+
super();
|
|
12
|
+
this.set('@oclif/core', this.getOclifCoreMeta());
|
|
13
|
+
}
|
|
8
14
|
static getInstance() {
|
|
9
15
|
if (!Cache.instance) {
|
|
10
16
|
Cache.instance = new Cache();
|
|
@@ -14,5 +20,22 @@ class Cache extends Map {
|
|
|
14
20
|
get(key) {
|
|
15
21
|
return super.get(key);
|
|
16
22
|
}
|
|
23
|
+
getOclifCoreMeta() {
|
|
24
|
+
try {
|
|
25
|
+
// eslint-disable-next-line node/no-extraneous-require
|
|
26
|
+
return { name: '@oclif/core', version: require('@oclif/core/package.json').version };
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
try {
|
|
30
|
+
return {
|
|
31
|
+
name: '@oclif/core',
|
|
32
|
+
version: JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(__dirname, '..', 'package.json'), 'utf8')),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return { name: '@oclif/core', version: 'unknown' };
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
17
40
|
}
|
|
18
41
|
exports.default = Cache;
|
package/lib/cli-ux/config.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.config = exports.Config = void 0;
|
|
7
|
-
const
|
|
7
|
+
const cache_1 = __importDefault(require("../cache"));
|
|
8
8
|
const simple_1 = __importDefault(require("./action/simple"));
|
|
9
9
|
const spinner_1 = __importDefault(require("./action/spinner"));
|
|
10
10
|
const g = global;
|
|
@@ -35,7 +35,8 @@ class Config {
|
|
|
35
35
|
}
|
|
36
36
|
exports.Config = Config;
|
|
37
37
|
function fetch() {
|
|
38
|
-
const
|
|
38
|
+
const core = cache_1.default.getInstance().get('@oclif/core');
|
|
39
|
+
const major = core?.version.split('.')[0] || 'unknown';
|
|
39
40
|
if (globals[major])
|
|
40
41
|
return globals[major];
|
|
41
42
|
globals[major] = new Config();
|
package/lib/command.js
CHANGED
|
@@ -30,16 +30,16 @@ exports.Command = void 0;
|
|
|
30
30
|
const chalk_1 = __importDefault(require("chalk"));
|
|
31
31
|
const node_url_1 = require("node:url");
|
|
32
32
|
const node_util_1 = require("node:util");
|
|
33
|
+
const cache_1 = __importDefault(require("./cache"));
|
|
33
34
|
const cli_ux_1 = require("./cli-ux");
|
|
34
35
|
const config_1 = require("./config");
|
|
35
36
|
const Errors = __importStar(require("./errors"));
|
|
36
37
|
const util_1 = require("./help/util");
|
|
37
38
|
const Parser = __importStar(require("./parser"));
|
|
38
39
|
const aggregate_flags_1 = require("./util/aggregate-flags");
|
|
39
|
-
const fs_1 = require("./util/fs");
|
|
40
40
|
const ids_1 = require("./util/ids");
|
|
41
41
|
const util_2 = require("./util/util");
|
|
42
|
-
const pjson = (
|
|
42
|
+
const pjson = cache_1.default.getInstance().get('@oclif/core');
|
|
43
43
|
/**
|
|
44
44
|
* swallows stdout epipe errors
|
|
45
45
|
* this occurs when stdout closes such as when piping to head
|
package/lib/config/config.d.ts
CHANGED
package/lib/config/config.js
CHANGED
|
@@ -48,7 +48,7 @@ const ts_path_1 = require("./ts-path");
|
|
|
48
48
|
const util_3 = require("./util");
|
|
49
49
|
// eslint-disable-next-line new-cap
|
|
50
50
|
const debug = (0, util_3.Debug)();
|
|
51
|
-
const _pjson = (
|
|
51
|
+
const _pjson = cache_1.default.getInstance().get('@oclif/core');
|
|
52
52
|
const BASE = `${_pjson.name}@${_pjson.version}`;
|
|
53
53
|
function channelFromVersion(version) {
|
|
54
54
|
const m = version.match(/[^-]+(?:-([^.]+))?/);
|
|
@@ -98,6 +98,7 @@ class Config {
|
|
|
98
98
|
errlog;
|
|
99
99
|
flexibleTaxonomy;
|
|
100
100
|
home;
|
|
101
|
+
isSingleCommandCLI = false;
|
|
101
102
|
name;
|
|
102
103
|
npmRegistry;
|
|
103
104
|
nsisCustomization;
|
|
@@ -262,7 +263,7 @@ class Config {
|
|
|
262
263
|
(settings_1.settings.performanceEnabled === undefined ? this.options.enablePerf : settings_1.settings.performanceEnabled) ?? false;
|
|
263
264
|
const marker = performance_1.Performance.mark(performance_1.OCLIF_MARKER_OWNER, 'config.load');
|
|
264
265
|
this.pluginLoader = new plugin_loader_1.default({ plugins: this.options.plugins, root: this.options.root });
|
|
265
|
-
this.rootPlugin = await this.pluginLoader.loadRoot();
|
|
266
|
+
this.rootPlugin = await this.pluginLoader.loadRoot({ pjson: this.options.pjson });
|
|
266
267
|
// Cache the root plugin so that we can reference it later when determining if
|
|
267
268
|
// we should skip ts-node registration for an ESM plugin.
|
|
268
269
|
const cache = cache_1.default.getInstance();
|
|
@@ -328,6 +329,10 @@ class Config {
|
|
|
328
329
|
...(s3.templates && s3.templates.vanilla),
|
|
329
330
|
},
|
|
330
331
|
};
|
|
332
|
+
this.isSingleCommandCLI = Boolean(this.pjson.oclif.default ||
|
|
333
|
+
(typeof this.pjson.oclif.commands !== 'string' &&
|
|
334
|
+
this.pjson.oclif.commands?.strategy === 'single' &&
|
|
335
|
+
this.pjson.oclif.commands?.target));
|
|
331
336
|
await this.loadPluginsAndCommands();
|
|
332
337
|
debug('config done');
|
|
333
338
|
marker?.addDetails({
|
|
@@ -482,14 +487,21 @@ class Config {
|
|
|
482
487
|
};
|
|
483
488
|
const hooks = p.hooks[event] || [];
|
|
484
489
|
for (const hook of hooks) {
|
|
485
|
-
const marker = performance_1.Performance.mark(performance_1.OCLIF_MARKER_OWNER, `config.runHook#${p.name}(${hook})`);
|
|
490
|
+
const marker = performance_1.Performance.mark(performance_1.OCLIF_MARKER_OWNER, `config.runHook#${p.name}(${hook.target})`);
|
|
486
491
|
try {
|
|
487
492
|
/* eslint-disable no-await-in-loop */
|
|
488
|
-
const { filePath, isESM, module } = await (0, module_loader_1.loadWithData)(p, await (0, ts_path_1.tsPath)(p.root, hook, p));
|
|
493
|
+
const { filePath, isESM, module } = await (0, module_loader_1.loadWithData)(p, await (0, ts_path_1.tsPath)(p.root, hook.target, p));
|
|
489
494
|
debug('start', isESM ? '(import)' : '(require)', filePath);
|
|
495
|
+
// If no hook is found using the identifier, then we should `search` for the hook but only if the hook identifier is 'default'
|
|
496
|
+
// A named identifier (e.g. MY_HOOK) that isn't found indicates that the hook isn't implemented in the plugin.
|
|
497
|
+
const hookFn = module[hook.identifier] ?? (hook.identifier === 'default' ? search(module) : undefined);
|
|
498
|
+
if (!hookFn) {
|
|
499
|
+
debug('No hook found for hook definition:', hook);
|
|
500
|
+
continue;
|
|
501
|
+
}
|
|
490
502
|
const result = timeout
|
|
491
|
-
? await withTimeout(timeout,
|
|
492
|
-
: await
|
|
503
|
+
? await withTimeout(timeout, hookFn.call(context, { ...opts, config: this, context }))
|
|
504
|
+
: await hookFn.call(context, { ...opts, config: this, context });
|
|
493
505
|
final.successes.push({ plugin: p, result });
|
|
494
506
|
if (p.name === '@oclif/plugin-legacy' && event === 'init') {
|
|
495
507
|
this.insertLegacyPlugins(result);
|
|
@@ -511,7 +523,7 @@ class Config {
|
|
|
511
523
|
}
|
|
512
524
|
marker?.addDetails({
|
|
513
525
|
event,
|
|
514
|
-
hook,
|
|
526
|
+
hook: hook.target,
|
|
515
527
|
plugin: p.name,
|
|
516
528
|
});
|
|
517
529
|
marker?.stop();
|
|
@@ -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.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Command } from '../command';
|
|
2
2
|
import { Manifest } from '../interfaces/manifest';
|
|
3
|
-
import { PJSON } from '../interfaces/pjson';
|
|
3
|
+
import { HookOptions, PJSON } from '../interfaces/pjson';
|
|
4
4
|
import { Plugin as IPlugin, PluginOptions } from '../interfaces/plugin';
|
|
5
5
|
import { Topic } from '../interfaces/topic';
|
|
6
6
|
export declare class Plugin implements IPlugin {
|
|
@@ -13,7 +13,7 @@ export declare class Plugin implements IPlugin {
|
|
|
13
13
|
commandsDir: string | undefined;
|
|
14
14
|
hasManifest: boolean;
|
|
15
15
|
hooks: {
|
|
16
|
-
[
|
|
16
|
+
[key: string]: HookOptions[];
|
|
17
17
|
};
|
|
18
18
|
isRoot: boolean;
|
|
19
19
|
manifest: Manifest;
|
|
@@ -29,6 +29,8 @@ export declare class Plugin implements IPlugin {
|
|
|
29
29
|
protected warned: boolean;
|
|
30
30
|
_base: string;
|
|
31
31
|
protected _debug: (..._: any) => void;
|
|
32
|
+
private commandCache;
|
|
33
|
+
private commandDiscoveryOpts;
|
|
32
34
|
private flexibleTaxonomy;
|
|
33
35
|
constructor(options: PluginOptions);
|
|
34
36
|
get topics(): Topic[];
|
|
@@ -42,6 +44,9 @@ export declare class Plugin implements IPlugin {
|
|
|
42
44
|
private _manifest;
|
|
43
45
|
private addErrorScope;
|
|
44
46
|
private getCommandIDs;
|
|
47
|
+
private getCommandIdsFromPattern;
|
|
48
|
+
private getCommandIdsFromTarget;
|
|
45
49
|
private getCommandsDir;
|
|
50
|
+
private loadCommandsFromTarget;
|
|
46
51
|
private warn;
|
|
47
52
|
}
|
package/lib/config/plugin.js
CHANGED
|
@@ -7,16 +7,18 @@ exports.Plugin = void 0;
|
|
|
7
7
|
const globby_1 = __importDefault(require("globby"));
|
|
8
8
|
const node_path_1 = require("node:path");
|
|
9
9
|
const node_util_1 = require("node:util");
|
|
10
|
+
const cache_1 = __importDefault(require("../cache"));
|
|
10
11
|
const errors_1 = require("../errors");
|
|
11
12
|
const module_loader_1 = require("../module-loader");
|
|
12
13
|
const performance_1 = require("../performance");
|
|
14
|
+
const symbols_1 = require("../symbols");
|
|
13
15
|
const cache_command_1 = require("../util/cache-command");
|
|
14
16
|
const find_root_1 = require("../util/find-root");
|
|
15
17
|
const fs_1 = require("../util/fs");
|
|
16
18
|
const util_1 = require("../util/util");
|
|
17
19
|
const ts_path_1 = require("./ts-path");
|
|
18
20
|
const util_2 = require("./util");
|
|
19
|
-
const _pjson = (
|
|
21
|
+
const _pjson = cache_1.default.getInstance().get('@oclif/core');
|
|
20
22
|
function topicsToArray(input, base) {
|
|
21
23
|
if (!input)
|
|
22
24
|
return [];
|
|
@@ -30,13 +32,17 @@ function topicsToArray(input, base) {
|
|
|
30
32
|
});
|
|
31
33
|
}
|
|
32
34
|
const cachedCommandCanBeUsed = (manifest, id) => Boolean(manifest?.commands[id] && 'isESM' in manifest.commands[id] && 'relativePath' in manifest.commands[id]);
|
|
33
|
-
const
|
|
35
|
+
const searchForCommandClass = (cmd) => {
|
|
34
36
|
if (typeof cmd.run === 'function')
|
|
35
37
|
return cmd;
|
|
36
38
|
if (cmd.default && cmd.default.run)
|
|
37
39
|
return cmd.default;
|
|
38
40
|
return Object.values(cmd).find((cmd) => typeof cmd.run === 'function');
|
|
39
41
|
};
|
|
42
|
+
const ensureCommandClass = (cmd) => {
|
|
43
|
+
if (cmd && typeof cmd.run === 'function')
|
|
44
|
+
return cmd;
|
|
45
|
+
};
|
|
40
46
|
const GLOB_PATTERNS = [
|
|
41
47
|
'**/*.+(js|cjs|mjs|ts|tsx|mts|cts)',
|
|
42
48
|
'!**/*.+(d.ts|test.ts|test.js|spec.ts|spec.js|d.mts|d.cts)?(x)',
|
|
@@ -47,9 +53,34 @@ function processCommandIds(files) {
|
|
|
47
53
|
const topics = p.dir.split('/');
|
|
48
54
|
const command = p.name !== 'index' && p.name;
|
|
49
55
|
const id = [...topics, command].filter(Boolean).join(':');
|
|
50
|
-
return id === '' ?
|
|
56
|
+
return id === '' ? symbols_1.SINGLE_COMMAND_CLI_SYMBOL : id;
|
|
51
57
|
});
|
|
52
58
|
}
|
|
59
|
+
function determineCommandDiscoveryOptions(commandDiscovery, defaultCmdId) {
|
|
60
|
+
if (!commandDiscovery)
|
|
61
|
+
return;
|
|
62
|
+
if (typeof commandDiscovery === 'string' && defaultCmdId) {
|
|
63
|
+
return { strategy: 'single', target: commandDiscovery };
|
|
64
|
+
}
|
|
65
|
+
if (typeof commandDiscovery === 'string') {
|
|
66
|
+
return { globPatterns: GLOB_PATTERNS, strategy: 'pattern', target: commandDiscovery };
|
|
67
|
+
}
|
|
68
|
+
if (!commandDiscovery.target)
|
|
69
|
+
throw new errors_1.CLIError('`oclif.commandDiscovery.target` is required.');
|
|
70
|
+
if (!commandDiscovery.strategy)
|
|
71
|
+
throw new errors_1.CLIError('`oclif.commandDiscovery.strategy` is required.');
|
|
72
|
+
if (commandDiscovery.strategy === 'explicit' && !commandDiscovery.identifier) {
|
|
73
|
+
commandDiscovery.identifier = 'default';
|
|
74
|
+
}
|
|
75
|
+
return commandDiscovery;
|
|
76
|
+
}
|
|
77
|
+
function determineHookOptions(hook) {
|
|
78
|
+
if (typeof hook === 'string')
|
|
79
|
+
return { identifier: 'default', target: hook };
|
|
80
|
+
if (!hook.identifier)
|
|
81
|
+
return { ...hook, identifier: 'default' };
|
|
82
|
+
return hook;
|
|
83
|
+
}
|
|
53
84
|
class Plugin {
|
|
54
85
|
options;
|
|
55
86
|
alias;
|
|
@@ -76,6 +107,8 @@ class Plugin {
|
|
|
76
107
|
_base = `${_pjson.name}@${_pjson.version}`;
|
|
77
108
|
// eslint-disable-next-line new-cap
|
|
78
109
|
_debug = (0, util_2.Debug)();
|
|
110
|
+
commandCache;
|
|
111
|
+
commandDiscoveryOpts;
|
|
79
112
|
flexibleTaxonomy;
|
|
80
113
|
constructor(options) {
|
|
81
114
|
this.options = options;
|
|
@@ -89,32 +122,43 @@ class Plugin {
|
|
|
89
122
|
plugin: this.name,
|
|
90
123
|
});
|
|
91
124
|
const fetch = async () => {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
125
|
+
if (this.commandDiscoveryOpts?.strategy === 'pattern') {
|
|
126
|
+
const commandsDir = await this.getCommandsDir();
|
|
127
|
+
if (!commandsDir)
|
|
128
|
+
return;
|
|
129
|
+
let module;
|
|
130
|
+
let isESM;
|
|
131
|
+
let filePath;
|
|
132
|
+
try {
|
|
133
|
+
;
|
|
134
|
+
({ filePath, isESM, module } = cachedCommandCanBeUsed(this.manifest, id)
|
|
135
|
+
? await (0, module_loader_1.loadWithDataFromManifest)(this.manifest.commands[id], this.root)
|
|
136
|
+
: await (0, module_loader_1.loadWithData)(this, (0, node_path_1.join)(commandsDir ?? this.pjson.oclif.commands, ...id.split(':'))));
|
|
137
|
+
this._debug(isESM ? '(import)' : '(require)', filePath);
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
if (!opts.must && error.code === 'MODULE_NOT_FOUND')
|
|
141
|
+
return;
|
|
142
|
+
throw error;
|
|
143
|
+
}
|
|
144
|
+
const cmd = searchForCommandClass(module);
|
|
145
|
+
if (!cmd)
|
|
146
|
+
return;
|
|
147
|
+
cmd.id = id;
|
|
148
|
+
cmd.plugin = this;
|
|
149
|
+
cmd.isESM = isESM;
|
|
150
|
+
cmd.relativePath = (0, node_path_1.relative)(this.root, filePath || '').split(node_path_1.sep);
|
|
151
|
+
return cmd;
|
|
104
152
|
}
|
|
105
|
-
|
|
106
|
-
|
|
153
|
+
if (this.commandDiscoveryOpts?.strategy === 'single' || this.commandDiscoveryOpts?.strategy === 'explicit') {
|
|
154
|
+
const commandCache = await this.loadCommandsFromTarget();
|
|
155
|
+
const cmd = ensureCommandClass(commandCache?.[id]);
|
|
156
|
+
if (!cmd)
|
|
107
157
|
return;
|
|
108
|
-
|
|
158
|
+
cmd.id = id;
|
|
159
|
+
cmd.plugin = this;
|
|
160
|
+
return cmd;
|
|
109
161
|
}
|
|
110
|
-
const cmd = search(module);
|
|
111
|
-
if (!cmd)
|
|
112
|
-
return;
|
|
113
|
-
cmd.id = id;
|
|
114
|
-
cmd.plugin = this;
|
|
115
|
-
cmd.isESM = isESM;
|
|
116
|
-
cmd.relativePath = (0, node_path_1.relative)(this.root, filePath || '').split(node_path_1.sep);
|
|
117
|
-
return cmd;
|
|
118
162
|
};
|
|
119
163
|
const cmd = await fetch();
|
|
120
164
|
if (!cmd && opts.must)
|
|
@@ -131,19 +175,22 @@ class Plugin {
|
|
|
131
175
|
// Linked plugins already have a root so there's no need to search for it.
|
|
132
176
|
// However there could be child plugins nested inside the linked plugin, in which
|
|
133
177
|
// case we still need to search for the child plugin's root.
|
|
134
|
-
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);
|
|
135
183
|
if (!root)
|
|
136
184
|
throw new errors_1.CLIError(`could not find package.json with ${(0, node_util_1.inspect)(this.options)}`);
|
|
137
185
|
this.root = root;
|
|
138
186
|
this._debug(`loading ${this.type} plugin from ${root}`);
|
|
139
|
-
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')));
|
|
140
188
|
this.flexibleTaxonomy = this.options?.flexibleTaxonomy || this.pjson.oclif?.flexibleTaxonomy || false;
|
|
141
189
|
this.moduleType = this.pjson.type === 'module' ? 'module' : 'commonjs';
|
|
142
190
|
this.name = this.pjson.name;
|
|
143
191
|
this.alias = this.options.name ?? this.pjson.name;
|
|
144
|
-
const pjsonPath = (0, node_path_1.join)(root, 'package.json');
|
|
145
192
|
if (!this.name)
|
|
146
|
-
throw new errors_1.CLIError(`no name in ${
|
|
193
|
+
throw new errors_1.CLIError(`no name in package.json (${root})`);
|
|
147
194
|
// eslint-disable-next-line new-cap
|
|
148
195
|
this._debug = (0, util_2.Debug)(this.name);
|
|
149
196
|
this.version = this.pjson.version;
|
|
@@ -153,7 +200,12 @@ class Plugin {
|
|
|
153
200
|
else {
|
|
154
201
|
this.pjson.oclif = this.pjson['cli-engine'] || {};
|
|
155
202
|
}
|
|
156
|
-
this.hooks = Object.fromEntries(Object.entries(this.pjson.oclif.hooks ?? {}).map(([k, v]) => [
|
|
203
|
+
this.hooks = Object.fromEntries(Object.entries(this.pjson.oclif.hooks ?? {}).map(([k, v]) => [
|
|
204
|
+
k,
|
|
205
|
+
(0, util_1.castArray)(v).map((v) => determineHookOptions(v)),
|
|
206
|
+
]));
|
|
207
|
+
this.commandDiscoveryOpts = determineCommandDiscoveryOptions(this.pjson.oclif?.commands, this.pjson.oclif?.default);
|
|
208
|
+
this._debug('command discovery options', this.commandDiscoveryOpts);
|
|
157
209
|
this.manifest = await this._manifest();
|
|
158
210
|
this.commands = Object.entries(this.manifest.commands)
|
|
159
211
|
.map(([id, c]) => ({
|
|
@@ -205,7 +257,13 @@ class Plugin {
|
|
|
205
257
|
const manifest = {
|
|
206
258
|
commands: (await Promise.all(this.commandIDs.map(async (id) => {
|
|
207
259
|
try {
|
|
208
|
-
const
|
|
260
|
+
const found = await this.findCommand(id, { must: true });
|
|
261
|
+
const cached = await (0, cache_command_1.cacheCommand)(found, this, respectNoCacheDefault);
|
|
262
|
+
// Ensure that id is set to the id being processed
|
|
263
|
+
// This is necessary because the id is set by findCommand but if there
|
|
264
|
+
// are multiple instances of a Command, then the id will be set to the
|
|
265
|
+
// last one found.
|
|
266
|
+
cached.id = id;
|
|
209
267
|
if (this.flexibleTaxonomy) {
|
|
210
268
|
const permutations = (0, util_2.getCommandIdPermutations)(id);
|
|
211
269
|
const aliasPermutations = cached.aliases.flatMap((a) => (0, util_2.getCommandIdPermutations)(a));
|
|
@@ -246,24 +304,68 @@ class Plugin {
|
|
|
246
304
|
return err;
|
|
247
305
|
}
|
|
248
306
|
async getCommandIDs() {
|
|
249
|
-
const commandsDir = await this.getCommandsDir();
|
|
250
|
-
if (!commandsDir)
|
|
251
|
-
return [];
|
|
252
307
|
const marker = performance_1.Performance.mark(performance_1.OCLIF_MARKER_OWNER, `plugin.getCommandIDs#${this.name}`, { plugin: this.name });
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
308
|
+
let ids;
|
|
309
|
+
switch (this.commandDiscoveryOpts?.strategy) {
|
|
310
|
+
case 'explicit': {
|
|
311
|
+
ids = (await this.getCommandIdsFromTarget()) ?? [];
|
|
312
|
+
break;
|
|
313
|
+
}
|
|
314
|
+
case 'pattern': {
|
|
315
|
+
ids = await this.getCommandIdsFromPattern();
|
|
316
|
+
break;
|
|
317
|
+
}
|
|
318
|
+
case 'single': {
|
|
319
|
+
ids = (await this.getCommandIdsFromTarget()) ?? [];
|
|
320
|
+
break;
|
|
321
|
+
}
|
|
322
|
+
default: {
|
|
323
|
+
ids = [];
|
|
324
|
+
}
|
|
325
|
+
}
|
|
256
326
|
this._debug('found commands', ids);
|
|
257
327
|
marker?.addDetails({ count: ids.length });
|
|
258
328
|
marker?.stop();
|
|
259
329
|
return ids;
|
|
260
330
|
}
|
|
331
|
+
async getCommandIdsFromPattern() {
|
|
332
|
+
const commandsDir = await this.getCommandsDir();
|
|
333
|
+
if (!commandsDir)
|
|
334
|
+
return [];
|
|
335
|
+
this._debug(`loading IDs from ${commandsDir}`);
|
|
336
|
+
const files = await (0, globby_1.default)(this.commandDiscoveryOpts?.globPatterns ?? GLOB_PATTERNS, { cwd: commandsDir });
|
|
337
|
+
return processCommandIds(files);
|
|
338
|
+
}
|
|
339
|
+
async getCommandIdsFromTarget() {
|
|
340
|
+
const commandsFromExport = await this.loadCommandsFromTarget();
|
|
341
|
+
if (commandsFromExport) {
|
|
342
|
+
return Object.entries((await this.loadCommandsFromTarget()) ?? [])
|
|
343
|
+
.filter(([, cmd]) => ensureCommandClass(cmd))
|
|
344
|
+
.map(([id]) => id);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
261
347
|
async getCommandsDir() {
|
|
262
348
|
if (this.commandsDir)
|
|
263
349
|
return this.commandsDir;
|
|
264
|
-
this.commandsDir = await (0, ts_path_1.tsPath)(this.root, this.
|
|
350
|
+
this.commandsDir = await (0, ts_path_1.tsPath)(this.root, this.commandDiscoveryOpts?.target, this);
|
|
265
351
|
return this.commandsDir;
|
|
266
352
|
}
|
|
353
|
+
async loadCommandsFromTarget() {
|
|
354
|
+
if (this.commandCache)
|
|
355
|
+
return this.commandCache;
|
|
356
|
+
if (this.commandDiscoveryOpts?.strategy === 'explicit' && this.commandDiscoveryOpts.target) {
|
|
357
|
+
const filePath = await (0, ts_path_1.tsPath)(this.root, this.commandDiscoveryOpts.target, this);
|
|
358
|
+
const module = await (0, module_loader_1.load)(this, filePath);
|
|
359
|
+
this.commandCache = module[this.commandDiscoveryOpts?.identifier ?? 'default'] ?? {};
|
|
360
|
+
return this.commandCache;
|
|
361
|
+
}
|
|
362
|
+
if (this.commandDiscoveryOpts?.strategy === 'single' && this.commandDiscoveryOpts.target) {
|
|
363
|
+
const filePath = await (0, ts_path_1.tsPath)(this.root, this.commandDiscoveryOpts?.target ?? this.root, this);
|
|
364
|
+
const module = await (0, module_loader_1.load)(this, filePath);
|
|
365
|
+
this.commandCache = { [symbols_1.SINGLE_COMMAND_CLI_SYMBOL]: searchForCommandClass(module) };
|
|
366
|
+
return this.commandCache;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
267
369
|
warn(err, scope) {
|
|
268
370
|
if (this.warned)
|
|
269
371
|
return;
|
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';
|
package/lib/help/docopts.js
CHANGED
|
@@ -77,7 +77,7 @@ class DocOpts {
|
|
|
77
77
|
return new DocOpts(cmd).toString();
|
|
78
78
|
}
|
|
79
79
|
toString() {
|
|
80
|
-
const opts =
|
|
80
|
+
const opts = ['<%= command.id %>'];
|
|
81
81
|
if (this.cmd.args) {
|
|
82
82
|
const a = Object.values((0, ensure_arg_object_1.ensureArgObject)(this.cmd.args)).map((arg) => arg.required ? arg.name.toUpperCase() : `[${arg.name.toUpperCase()}]`) || [];
|
|
83
83
|
opts.push(...a);
|
package/lib/help/index.js
CHANGED
|
@@ -10,6 +10,7 @@ const theme_1 = require("../cli-ux/theme");
|
|
|
10
10
|
const write_1 = __importDefault(require("../cli-ux/write"));
|
|
11
11
|
const errors_1 = require("../errors");
|
|
12
12
|
const module_loader_1 = require("../module-loader");
|
|
13
|
+
const symbols_1 = require("../symbols");
|
|
13
14
|
const cache_default_value_1 = require("../util/cache-default-value");
|
|
14
15
|
const ids_1 = require("../util/ids");
|
|
15
16
|
const util_1 = require("../util/util");
|
|
@@ -189,8 +190,8 @@ class Help extends HelpBase {
|
|
|
189
190
|
argv = (0, util_2.standardizeIDFromArgv)(argv, this.config);
|
|
190
191
|
const subject = getHelpSubject(argv, this.config);
|
|
191
192
|
if (!subject) {
|
|
192
|
-
if (this.config.
|
|
193
|
-
const rootCmd = this.config.findCommand(
|
|
193
|
+
if (this.config.isSingleCommandCLI) {
|
|
194
|
+
const rootCmd = this.config.findCommand(symbols_1.SINGLE_COMMAND_CLI_SYMBOL);
|
|
194
195
|
if (rootCmd) {
|
|
195
196
|
await this.showCommandHelp(rootCmd);
|
|
196
197
|
return;
|
|
@@ -201,6 +202,12 @@ class Help extends HelpBase {
|
|
|
201
202
|
}
|
|
202
203
|
const command = this.config.findCommand(subject);
|
|
203
204
|
if (command) {
|
|
205
|
+
if (command.id === symbols_1.SINGLE_COMMAND_CLI_SYMBOL) {
|
|
206
|
+
// If the command is the root command of a single command CLI,
|
|
207
|
+
// then set the command id to an empty string to prevent the
|
|
208
|
+
// the SINGLE_COMMAND_CLI_SYMBOL from being displayed in the help output.
|
|
209
|
+
command.id = '';
|
|
210
|
+
}
|
|
204
211
|
if (command.hasDynamicHelp && command.pluginType !== 'jit') {
|
|
205
212
|
const loaded = await command.load();
|
|
206
213
|
for (const [name, flag] of Object.entries(loaded.flags ?? {})) {
|
|
@@ -16,6 +16,86 @@ export interface PJSON {
|
|
|
16
16
|
};
|
|
17
17
|
version: string;
|
|
18
18
|
}
|
|
19
|
+
export type CommandDiscovery = {
|
|
20
|
+
/**
|
|
21
|
+
* The strategy to use for loading commands.
|
|
22
|
+
*
|
|
23
|
+
* - `pattern` will use glob patterns to find command files in the specified `target`.
|
|
24
|
+
* - `explicit` will use `import` (or `require` for CJS) to load the commands from the
|
|
25
|
+
* specified `target`.
|
|
26
|
+
* - `single` will use the `target` which should export a command class. This is for CLIs that
|
|
27
|
+
* only have a single command.
|
|
28
|
+
*
|
|
29
|
+
* In both cases, the `oclif.manifest.json` file will be used to find the commands if it exists.
|
|
30
|
+
*/
|
|
31
|
+
strategy: 'pattern' | 'explicit' | 'single';
|
|
32
|
+
/**
|
|
33
|
+
* If the `strategy` is `pattern`, this is the **directory** to use to find command files.
|
|
34
|
+
*
|
|
35
|
+
* If the `strategy` is `explicit`, this is the **file** that exports the commands.
|
|
36
|
+
* - This export must be an object with keys that are the command names and values that are the command classes.
|
|
37
|
+
* - Unless `identifier` is specified, the default export will be used.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* // in src/commands.ts
|
|
42
|
+
* import {Command} from '@oclif/core'
|
|
43
|
+
* import Hello from './commands/hello/index.js'
|
|
44
|
+
* import HelloWorld from './commands/hello/world.js'
|
|
45
|
+
*
|
|
46
|
+
* export default {
|
|
47
|
+
* hello: Hello,
|
|
48
|
+
* 'hello:world': HelloWorld,
|
|
49
|
+
* } satisfies Record<string, Command.Class>
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
target: string;
|
|
53
|
+
/**
|
|
54
|
+
* The glob patterns to use to find command files when no `oclif.manifest.json` is present.
|
|
55
|
+
* This is only used when `strategy` is `pattern`.
|
|
56
|
+
*/
|
|
57
|
+
globPatterns?: string[];
|
|
58
|
+
/**
|
|
59
|
+
* The name of the export to used when loading the command object from the `target` file. Only
|
|
60
|
+
* used when `strategy` is `explicit`. Defaults to `default`.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* // in src/commands.ts
|
|
65
|
+
* import {Command} from '@oclif/core'
|
|
66
|
+
* import Hello from './commands/hello/index.js'
|
|
67
|
+
* import HelloWorld from './commands/hello/world.js'
|
|
68
|
+
*
|
|
69
|
+
* export const MY_COMMANDS = {
|
|
70
|
+
* hello: Hello,
|
|
71
|
+
* 'hello:world': HelloWorld,
|
|
72
|
+
* } satisfies Record<string, Command.Class>
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* In the package.json:
|
|
76
|
+
* ```json
|
|
77
|
+
* {
|
|
78
|
+
* "oclif": {
|
|
79
|
+
* "commands": {
|
|
80
|
+
* "strategy": "explicit",
|
|
81
|
+
* "target": "./dist/index.js",
|
|
82
|
+
* "identifier": "MY_COMMANDS"
|
|
83
|
+
* }
|
|
84
|
+
* }
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
identifier?: string;
|
|
88
|
+
};
|
|
89
|
+
export type HookOptions = {
|
|
90
|
+
/**
|
|
91
|
+
* The file path containing hook.
|
|
92
|
+
*/
|
|
93
|
+
target: string;
|
|
94
|
+
/**
|
|
95
|
+
* The name of the export to use when loading the hook function from the `target` file. Defaults to `default`.
|
|
96
|
+
*/
|
|
97
|
+
identifier: string;
|
|
98
|
+
};
|
|
19
99
|
export declare namespace PJSON {
|
|
20
100
|
interface Plugin extends PJSON {
|
|
21
101
|
name: string;
|
|
@@ -25,7 +105,13 @@ export declare namespace PJSON {
|
|
|
25
105
|
aliases?: {
|
|
26
106
|
[name: string]: null | string;
|
|
27
107
|
};
|
|
28
|
-
commands?: string;
|
|
108
|
+
commands?: string | CommandDiscovery;
|
|
109
|
+
/**
|
|
110
|
+
* Default command id when no command is found. This is used to support single command CLIs.
|
|
111
|
+
* Only supported value is "."
|
|
112
|
+
*
|
|
113
|
+
* @deprecated Use `commands.strategy: 'single'` instead.
|
|
114
|
+
*/
|
|
29
115
|
default?: string;
|
|
30
116
|
description?: string;
|
|
31
117
|
devPlugins?: string[];
|
|
@@ -42,7 +128,7 @@ export declare namespace PJSON {
|
|
|
42
128
|
helpClass?: string;
|
|
43
129
|
helpOptions?: HelpOptions;
|
|
44
130
|
hooks?: {
|
|
45
|
-
[name: string]: string | string[];
|
|
131
|
+
[name: string]: string | string[] | HookOptions | HookOptions[];
|
|
46
132
|
};
|
|
47
133
|
jitPlugins?: Record<string, string>;
|
|
48
134
|
macos?: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Command } from '../command';
|
|
2
|
-
import { PJSON } from './pjson';
|
|
2
|
+
import { HookOptions, PJSON } from './pjson';
|
|
3
3
|
import { Topic } from './topic';
|
|
4
4
|
export interface PluginOptions {
|
|
5
5
|
children?: Plugin[];
|
|
@@ -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;
|
|
@@ -44,7 +46,7 @@ export interface Plugin {
|
|
|
44
46
|
}): Promise<Command.Class> | undefined;
|
|
45
47
|
readonly hasManifest: boolean;
|
|
46
48
|
hooks: {
|
|
47
|
-
[
|
|
49
|
+
[key: string]: HookOptions[];
|
|
48
50
|
};
|
|
49
51
|
/**
|
|
50
52
|
* True if the plugin is the root plugin.
|
package/lib/main.js
CHANGED
|
@@ -6,9 +6,10 @@ const cli_ux_1 = require("./cli-ux");
|
|
|
6
6
|
const config_1 = require("./config");
|
|
7
7
|
const help_1 = require("./help");
|
|
8
8
|
const performance_1 = require("./performance");
|
|
9
|
+
const symbols_1 = require("./symbols");
|
|
9
10
|
const debug = require('debug')('oclif:main');
|
|
10
11
|
const helpAddition = (argv, config) => {
|
|
11
|
-
if (argv.length === 0 && !config.
|
|
12
|
+
if (argv.length === 0 && !config.isSingleCommandCLI)
|
|
12
13
|
return true;
|
|
13
14
|
const mergedHelpFlags = (0, help_1.getHelpFlagAdditions)(config);
|
|
14
15
|
for (const arg of argv) {
|
|
@@ -52,7 +53,11 @@ async function run(argv, options) {
|
|
|
52
53
|
options = (0, node_url_1.fileURLToPath)(options);
|
|
53
54
|
}
|
|
54
55
|
const config = await config_1.Config.load(options ?? require.main?.filename ?? __dirname);
|
|
55
|
-
|
|
56
|
+
// If this is a single command CLI, then insert the SINGLE_COMMAND_CLI_SYMBOL into the argv array to serve as the command id.
|
|
57
|
+
if (config.isSingleCommandCLI) {
|
|
58
|
+
argv = [symbols_1.SINGLE_COMMAND_CLI_SYMBOL, ...argv];
|
|
59
|
+
}
|
|
60
|
+
const [id, ...argvSlice] = (0, help_1.normalizeArgv)(config, argv);
|
|
56
61
|
// run init hook
|
|
57
62
|
await config.runHook('init', { argv: argvSlice, id });
|
|
58
63
|
// display version if applicable
|
|
@@ -76,17 +81,8 @@ async function run(argv, options) {
|
|
|
76
81
|
await collectPerf();
|
|
77
82
|
return;
|
|
78
83
|
}
|
|
79
|
-
if (config.pjson.oclif.default) {
|
|
80
|
-
id = config.pjson.oclif.default;
|
|
81
|
-
argvSlice = argv;
|
|
82
|
-
}
|
|
83
84
|
}
|
|
84
85
|
initMarker?.stop();
|
|
85
|
-
// If the the default command is '.' (signifying that the CLI is a single command CLI) and '.' is provided
|
|
86
|
-
// as an argument, we need to add back the '.' to argv since it was stripped out earlier as part of the
|
|
87
|
-
// command id.
|
|
88
|
-
if (config.pjson.oclif.default === '.' && id === '.' && argv[0] === '.')
|
|
89
|
-
argvSlice = ['.', ...argvSlice];
|
|
90
86
|
try {
|
|
91
87
|
return await config.runCommand(id, argvSlice, cmd);
|
|
92
88
|
}
|
package/lib/symbols.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SINGLE_COMMAND_CLI_SYMBOL: string;
|
package/lib/symbols.js
ADDED
package/lib/util/fs.d.ts
CHANGED
package/lib/util/fs.js
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.existsSync = exports.safeReadJson = exports.readJsonSync = exports.readJson = exports.fileExists = exports.dirExists =
|
|
3
|
+
exports.existsSync = exports.safeReadJson = exports.readJsonSync = 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
|
-
const node_path_1 = require("node:path");
|
|
7
|
-
function requireJson(...pathParts) {
|
|
8
|
-
return JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(...pathParts), 'utf8'));
|
|
9
|
-
}
|
|
10
|
-
exports.requireJson = requireJson;
|
|
11
6
|
/**
|
|
12
7
|
* Parser for Args.directory and Flags.directory. Checks that the provided path
|
|
13
8
|
* exists and is a directory.
|
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.20.
|
|
4
|
+
"version": "3.20.1-dev.1",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"bugs": "https://github.com/oclif/core/issues",
|
|
7
7
|
"dependencies": {
|
|
@@ -114,7 +114,6 @@
|
|
|
114
114
|
"access": "public"
|
|
115
115
|
},
|
|
116
116
|
"scripts": {
|
|
117
|
-
"build:dev": "shx rm -rf lib && tsc --sourceMap",
|
|
118
117
|
"build": "shx rm -rf lib && tsc",
|
|
119
118
|
"commitlint": "commitlint",
|
|
120
119
|
"compile": "tsc",
|
|
@@ -129,7 +128,6 @@
|
|
|
129
128
|
"test:integration": "mocha --forbid-only \"test/**/*.integration.ts\" --parallel --timeout 1200000",
|
|
130
129
|
"test:interoperability": "cross-env DEBUG=integration:* ts-node test/integration/interop.ts",
|
|
131
130
|
"test:perf": "ts-node test/perf/parser.perf.ts",
|
|
132
|
-
"test:dev": "nyc mocha \"test/**/*.test.ts\"",
|
|
133
131
|
"test": "nyc mocha --forbid-only \"test/**/*.test.ts\""
|
|
134
132
|
},
|
|
135
133
|
"types": "lib/index.d.ts"
|