@oclif/core 4.0.0-beta.7 → 4.0.0-beta.8
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/args.d.ts +4 -4
- package/lib/cache.d.ts +3 -3
- package/lib/command.d.ts +17 -17
- package/lib/command.js +5 -5
- package/lib/config/config.d.ts +10 -10
- package/lib/config/config.js +15 -11
- package/lib/config/plugin-loader.d.ts +6 -6
- package/lib/config/plugin.d.ts +3 -3
- package/lib/config/plugin.js +2 -5
- package/lib/config/ts-path.d.ts +1 -1
- package/lib/errors/errors/cli.d.ts +5 -5
- package/lib/errors/errors/pretty-print.d.ts +2 -2
- package/lib/flags.d.ts +4 -4
- package/lib/flush.js +2 -2
- package/lib/help/formatter.d.ts +3 -3
- package/lib/help/index.d.ts +1 -0
- package/lib/help/index.js +19 -10
- package/lib/index.d.ts +4 -5
- package/lib/index.js +1 -1
- package/lib/interfaces/config.d.ts +9 -9
- package/lib/interfaces/errors.d.ts +5 -5
- package/lib/interfaces/index.d.ts +1 -1
- package/lib/interfaces/parser.d.ts +6 -6
- package/lib/interfaces/pjson.d.ts +216 -151
- package/lib/interfaces/plugin.d.ts +25 -25
- package/lib/interfaces/topic.d.ts +2 -2
- package/lib/main.js +2 -2
- package/lib/parser/errors.d.ts +1 -1
- package/lib/settings.d.ts +5 -5
- package/lib/util/ids.d.ts +1 -1
- package/lib/util/read-pjson.d.ts +1 -1
- package/lib/ux/colorize-json.d.ts +2 -2
- package/lib/ux/index.d.ts +7 -2
- package/lib/ux/index.js +15 -3
- package/package.json +22 -6
- package/flush.d.ts +0 -3
- package/flush.js +0 -1
- package/handle.js +0 -1
package/lib/args.d.ts
CHANGED
|
@@ -21,14 +21,14 @@ import { Arg, ArgDefinition } from './interfaces/parser';
|
|
|
21
21
|
export declare function custom<T = string, P = Record<string, unknown>>(defaults: Partial<Arg<T, P>>): ArgDefinition<T, P>;
|
|
22
22
|
export declare const boolean: ArgDefinition<boolean, Record<string, unknown>>;
|
|
23
23
|
export declare const integer: ArgDefinition<number, {
|
|
24
|
-
max?: number
|
|
25
|
-
min?: number
|
|
24
|
+
max?: number;
|
|
25
|
+
min?: number;
|
|
26
26
|
}>;
|
|
27
27
|
export declare const directory: ArgDefinition<string, {
|
|
28
|
-
exists?: boolean
|
|
28
|
+
exists?: boolean;
|
|
29
29
|
}>;
|
|
30
30
|
export declare const file: ArgDefinition<string, {
|
|
31
|
-
exists?: boolean
|
|
31
|
+
exists?: boolean;
|
|
32
32
|
}>;
|
|
33
33
|
/**
|
|
34
34
|
* Initializes a string as a URL. Throws an error
|
package/lib/cache.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Config } from './config/config';
|
|
2
|
-
import {
|
|
2
|
+
import { Configuration, Plugin } from './interfaces';
|
|
3
3
|
type OclifCoreInfo = {
|
|
4
4
|
name: string;
|
|
5
5
|
version: string;
|
|
@@ -7,7 +7,7 @@ type OclifCoreInfo = {
|
|
|
7
7
|
type CacheContents = {
|
|
8
8
|
rootPlugin: Plugin;
|
|
9
9
|
config: Config;
|
|
10
|
-
exitCodes:
|
|
10
|
+
exitCodes: Configuration['exitCodes'];
|
|
11
11
|
'@oclif/core': OclifCoreInfo;
|
|
12
12
|
};
|
|
13
13
|
type ValueOf<T> = T[keyof T];
|
|
@@ -21,7 +21,7 @@ export default class Cache extends Map<keyof CacheContents, ValueOf<CacheContent
|
|
|
21
21
|
get(key: 'config'): Config | undefined;
|
|
22
22
|
get(key: '@oclif/core'): OclifCoreInfo;
|
|
23
23
|
get(key: 'rootPlugin'): Plugin | undefined;
|
|
24
|
-
get(key: 'exitCodes'):
|
|
24
|
+
get(key: 'exitCodes'): Configuration['exitCodes'] | undefined;
|
|
25
25
|
private getOclifCoreMeta;
|
|
26
26
|
}
|
|
27
27
|
export {};
|
package/lib/command.d.ts
CHANGED
|
@@ -143,15 +143,15 @@ export declare namespace Command {
|
|
|
143
143
|
*/
|
|
144
144
|
type Cached = {
|
|
145
145
|
[key: string]: unknown;
|
|
146
|
-
aliasPermutations?: string[];
|
|
146
|
+
aliasPermutations?: string[] | undefined;
|
|
147
147
|
aliases: string[];
|
|
148
148
|
args: {
|
|
149
149
|
[name: string]: Arg.Cached;
|
|
150
150
|
};
|
|
151
|
-
deprecateAliases?: boolean;
|
|
152
|
-
deprecationOptions?: Deprecation;
|
|
153
|
-
description?: string;
|
|
154
|
-
examples?: Example[];
|
|
151
|
+
deprecateAliases?: boolean | undefined;
|
|
152
|
+
deprecationOptions?: Deprecation | undefined;
|
|
153
|
+
description?: string | undefined;
|
|
154
|
+
examples?: Example[] | undefined;
|
|
155
155
|
flags: {
|
|
156
156
|
[name: string]: Flag.Cached;
|
|
157
157
|
};
|
|
@@ -159,22 +159,22 @@ export declare namespace Command {
|
|
|
159
159
|
hidden: boolean;
|
|
160
160
|
hiddenAliases: string[];
|
|
161
161
|
id: string;
|
|
162
|
-
isESM?: boolean;
|
|
163
|
-
permutations?: string[];
|
|
164
|
-
pluginAlias?: string;
|
|
165
|
-
pluginName?: string;
|
|
166
|
-
pluginType?: string;
|
|
167
|
-
relativePath?: string[];
|
|
168
|
-
state?: 'beta' | 'deprecated' | string;
|
|
169
|
-
strict?: boolean;
|
|
170
|
-
summary?: string;
|
|
171
|
-
type?: string;
|
|
172
|
-
usage?: string | string[];
|
|
162
|
+
isESM?: boolean | undefined;
|
|
163
|
+
permutations?: string[] | undefined;
|
|
164
|
+
pluginAlias?: string | undefined;
|
|
165
|
+
pluginName?: string | undefined;
|
|
166
|
+
pluginType?: string | undefined;
|
|
167
|
+
relativePath?: string[] | undefined;
|
|
168
|
+
state?: 'beta' | 'deprecated' | string | undefined;
|
|
169
|
+
strict?: boolean | undefined;
|
|
170
|
+
summary?: string | undefined;
|
|
171
|
+
type?: string | undefined;
|
|
172
|
+
usage?: string | string[] | undefined;
|
|
173
173
|
};
|
|
174
174
|
type Flag = IFlag<any>;
|
|
175
175
|
namespace Flag {
|
|
176
176
|
type Cached = Omit<Flag, 'input' | 'parse'> & (BooleanFlagProps | OptionFlagProps) & {
|
|
177
|
-
hasDynamicHelp?: boolean;
|
|
177
|
+
hasDynamicHelp?: boolean | undefined;
|
|
178
178
|
};
|
|
179
179
|
type Any = Cached | Flag;
|
|
180
180
|
}
|
package/lib/command.js
CHANGED
|
@@ -39,7 +39,7 @@ const Parser = __importStar(require("./parser"));
|
|
|
39
39
|
const aggregate_flags_1 = require("./util/aggregate-flags");
|
|
40
40
|
const ids_1 = require("./util/ids");
|
|
41
41
|
const util_2 = require("./util/util");
|
|
42
|
-
const ux_1 =
|
|
42
|
+
const ux_1 = require("./ux");
|
|
43
43
|
const pjson = cache_1.default.getInstance().get('@oclif/core');
|
|
44
44
|
/**
|
|
45
45
|
* swallows stdout epipe errors
|
|
@@ -168,7 +168,7 @@ class Command {
|
|
|
168
168
|
if (!err.message)
|
|
169
169
|
throw err;
|
|
170
170
|
try {
|
|
171
|
-
ux_1.
|
|
171
|
+
ux_1.ux.action.stop(ansis_1.default.bold.red('!'));
|
|
172
172
|
}
|
|
173
173
|
catch { }
|
|
174
174
|
throw err;
|
|
@@ -211,16 +211,16 @@ class Command {
|
|
|
211
211
|
log(message = '', ...args) {
|
|
212
212
|
if (!this.jsonEnabled()) {
|
|
213
213
|
message = typeof message === 'string' ? message : (0, node_util_1.inspect)(message);
|
|
214
|
-
ux_1.
|
|
214
|
+
ux_1.ux.stdout(message, ...args);
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
217
|
logJson(json) {
|
|
218
|
-
ux_1.
|
|
218
|
+
ux_1.ux.stdout(ux_1.ux.colorizeJson(json, { pretty: true, theme: this.config.theme?.json }));
|
|
219
219
|
}
|
|
220
220
|
logToStderr(message = '', ...args) {
|
|
221
221
|
if (!this.jsonEnabled()) {
|
|
222
222
|
message = typeof message === 'string' ? message : (0, node_util_1.inspect)(message);
|
|
223
|
-
ux_1.
|
|
223
|
+
ux_1.ux.stderr(message, ...args);
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
226
|
async parse(options, argv = this.argv) {
|
package/lib/config/config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Command } from '../command';
|
|
2
|
-
import { Hook, Hooks, PJSON, Topic } from '../interfaces';
|
|
2
|
+
import { Configuration, Hook, Hooks, PJSON, S3Templates, Topic, UserPJSON } from '../interfaces';
|
|
3
3
|
import { ArchTypes, Config as IConfig, LoadOptions, PlatformTypes, VersionDetails } from '../interfaces/config';
|
|
4
4
|
import { Plugin as IPlugin, Options } from '../interfaces/plugin';
|
|
5
5
|
import { Theme } from '../interfaces/theme';
|
|
@@ -7,8 +7,8 @@ export declare class Config implements IConfig {
|
|
|
7
7
|
options: Options;
|
|
8
8
|
arch: ArchTypes;
|
|
9
9
|
bin: string;
|
|
10
|
-
binAliases?: string[];
|
|
11
|
-
binPath?: string;
|
|
10
|
+
binAliases?: string[] | undefined;
|
|
11
|
+
binPath?: string | undefined;
|
|
12
12
|
cacheDir: string;
|
|
13
13
|
channel: string;
|
|
14
14
|
configDir: string;
|
|
@@ -18,18 +18,18 @@ export declare class Config implements IConfig {
|
|
|
18
18
|
home: string;
|
|
19
19
|
isSingleCommandCLI: boolean;
|
|
20
20
|
name: string;
|
|
21
|
-
npmRegistry?: string;
|
|
22
|
-
nsisCustomization?: string;
|
|
23
|
-
pjson: PJSON
|
|
21
|
+
npmRegistry?: string | undefined;
|
|
22
|
+
nsisCustomization?: string | undefined;
|
|
23
|
+
pjson: PJSON;
|
|
24
24
|
platform: PlatformTypes;
|
|
25
25
|
plugins: Map<string, IPlugin>;
|
|
26
26
|
root: string;
|
|
27
27
|
shell: string;
|
|
28
|
-
theme?: Theme;
|
|
28
|
+
theme?: Theme | undefined;
|
|
29
29
|
topicSeparator: ' ' | ':';
|
|
30
|
-
updateConfig: NonNullable<
|
|
30
|
+
updateConfig: NonNullable<Configuration['update']>;
|
|
31
31
|
userAgent: string;
|
|
32
|
-
userPJSON?:
|
|
32
|
+
userPJSON?: UserPJSON | undefined;
|
|
33
33
|
valid: boolean;
|
|
34
34
|
version: string;
|
|
35
35
|
protected warned: boolean;
|
|
@@ -96,7 +96,7 @@ export declare class Config implements IConfig {
|
|
|
96
96
|
protected macosCacheDir(): string | undefined;
|
|
97
97
|
runCommand<T = unknown>(id: string, argv?: string[], cachedCommand?: Command.Loadable | null): Promise<T>;
|
|
98
98
|
runHook<T extends keyof Hooks>(event: T, opts: Hooks[T]['options'], timeout?: number, captureErrors?: boolean): Promise<Hook.Result<Hooks[T]['return']>>;
|
|
99
|
-
s3Key(type: keyof
|
|
99
|
+
s3Key(type: keyof S3Templates, ext?: '.tar.gz' | '.tar.xz' | IConfig.s3Key.Options, options?: IConfig.s3Key.Options): string;
|
|
100
100
|
s3Url(key: string): string;
|
|
101
101
|
scopedEnvVar(k: string): string | undefined;
|
|
102
102
|
/**
|
package/lib/config/config.js
CHANGED
|
@@ -42,7 +42,7 @@ const settings_1 = require("../settings");
|
|
|
42
42
|
const fs_1 = require("../util/fs");
|
|
43
43
|
const os_1 = require("../util/os");
|
|
44
44
|
const util_2 = require("../util/util");
|
|
45
|
-
const ux_1 =
|
|
45
|
+
const ux_1 = require("../ux");
|
|
46
46
|
const theme_1 = require("../ux/theme");
|
|
47
47
|
const plugin_loader_1 = __importDefault(require("./plugin-loader"));
|
|
48
48
|
const ts_path_1 = require("./ts-path");
|
|
@@ -318,10 +318,9 @@ class Config {
|
|
|
318
318
|
node: this.pjson.oclif.update?.node ?? {},
|
|
319
319
|
s3: this.buildS3Config(),
|
|
320
320
|
};
|
|
321
|
-
this.isSingleCommandCLI = Boolean(this.pjson.oclif.
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
this.pjson.oclif.commands?.target));
|
|
321
|
+
this.isSingleCommandCLI = Boolean(typeof this.pjson.oclif.commands !== 'string' &&
|
|
322
|
+
this.pjson.oclif.commands?.strategy === 'single' &&
|
|
323
|
+
this.pjson.oclif.commands?.target);
|
|
325
324
|
this.maybeAdjustDebugSetting();
|
|
326
325
|
await this.loadPluginsAndCommands();
|
|
327
326
|
debug('config done');
|
|
@@ -358,12 +357,17 @@ class Config {
|
|
|
358
357
|
async loadTheme() {
|
|
359
358
|
if (this.scopedEnvVarTrue('DISABLE_THEME'))
|
|
360
359
|
return;
|
|
361
|
-
const defaultThemeFile = this.pjson.oclif.theme
|
|
362
|
-
? (0, node_path_1.resolve)(this.root, this.pjson.oclif.theme)
|
|
363
|
-
: this.pjson.oclif.theme;
|
|
364
360
|
const userThemeFile = (0, node_path_1.resolve)(this.configDir, 'theme.json');
|
|
361
|
+
const getDefaultTheme = async () => {
|
|
362
|
+
if (!this.pjson.oclif.theme)
|
|
363
|
+
return;
|
|
364
|
+
if (typeof this.pjson.oclif.theme === 'string') {
|
|
365
|
+
return (0, fs_1.safeReadJson)((0, node_path_1.resolve)(this.root, this.pjson.oclif.theme));
|
|
366
|
+
}
|
|
367
|
+
return this.pjson.oclif.theme;
|
|
368
|
+
};
|
|
365
369
|
const [defaultTheme, userTheme] = await Promise.all([
|
|
366
|
-
|
|
370
|
+
await getDefaultTheme(),
|
|
367
371
|
await (0, fs_1.safeReadJson)(userThemeFile),
|
|
368
372
|
]);
|
|
369
373
|
// Merge the default theme with the user theme, giving the user theme precedence.
|
|
@@ -468,7 +472,7 @@ class Config {
|
|
|
468
472
|
(0, errors_1.exit)(code);
|
|
469
473
|
},
|
|
470
474
|
log(message, ...args) {
|
|
471
|
-
ux_1.
|
|
475
|
+
ux_1.ux.stdout(message, ...args);
|
|
472
476
|
},
|
|
473
477
|
warn(message) {
|
|
474
478
|
(0, errors_1.warn)(message);
|
|
@@ -528,7 +532,7 @@ class Config {
|
|
|
528
532
|
options = ext;
|
|
529
533
|
else if (ext)
|
|
530
534
|
options.ext = ext;
|
|
531
|
-
const template = this.updateConfig.s3.templates[options.platform ? 'target' : 'vanilla'][type] ?? '';
|
|
535
|
+
const template = this.updateConfig.s3.templates?.[options.platform ? 'target' : 'vanilla'][type] ?? '';
|
|
532
536
|
return ejs.render(template, { ...this, ...options });
|
|
533
537
|
}
|
|
534
538
|
s3Url(key) {
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { PJSON } from '../interfaces';
|
|
2
2
|
import { Plugin as IPlugin } from '../interfaces/plugin';
|
|
3
3
|
type PluginLoaderOptions = {
|
|
4
|
-
plugins?: IPlugin[] | PluginsMap;
|
|
4
|
+
plugins?: IPlugin[] | PluginsMap | undefined;
|
|
5
5
|
root: string;
|
|
6
6
|
};
|
|
7
7
|
type LoadOpts = {
|
|
8
8
|
dataDir: string;
|
|
9
|
-
devPlugins?: boolean;
|
|
10
|
-
force?: boolean;
|
|
9
|
+
devPlugins?: boolean | undefined;
|
|
10
|
+
force?: boolean | undefined;
|
|
11
11
|
rootPlugin: IPlugin;
|
|
12
|
-
userPlugins?: boolean;
|
|
12
|
+
userPlugins?: boolean | undefined;
|
|
13
13
|
pluginAdditions?: {
|
|
14
14
|
core?: string[];
|
|
15
15
|
dev?: string[];
|
|
16
16
|
path?: string;
|
|
17
|
-
};
|
|
17
|
+
} | undefined;
|
|
18
18
|
};
|
|
19
19
|
type PluginsMap = Map<string, IPlugin>;
|
|
20
20
|
export default class PluginLoader {
|
|
@@ -28,7 +28,7 @@ export default class PluginLoader {
|
|
|
28
28
|
plugins: PluginsMap;
|
|
29
29
|
}>;
|
|
30
30
|
loadRoot({ pjson }: {
|
|
31
|
-
pjson?: PJSON
|
|
31
|
+
pjson?: PJSON | undefined;
|
|
32
32
|
}): Promise<IPlugin>;
|
|
33
33
|
private loadCorePlugins;
|
|
34
34
|
private loadDevPlugins;
|
package/lib/config/plugin.d.ts
CHANGED
|
@@ -19,10 +19,10 @@ export declare class Plugin implements IPlugin {
|
|
|
19
19
|
manifest: Manifest;
|
|
20
20
|
moduleType: 'commonjs' | 'module';
|
|
21
21
|
name: string;
|
|
22
|
-
parent
|
|
23
|
-
pjson: PJSON
|
|
22
|
+
parent?: Plugin | undefined;
|
|
23
|
+
pjson: PJSON;
|
|
24
24
|
root: string;
|
|
25
|
-
tag?: string;
|
|
25
|
+
tag?: string | undefined;
|
|
26
26
|
type: string;
|
|
27
27
|
valid: boolean;
|
|
28
28
|
version: string;
|
package/lib/config/plugin.js
CHANGED
|
@@ -57,12 +57,9 @@ function processCommandIds(files) {
|
|
|
57
57
|
return id === '' ? symbols_1.SINGLE_COMMAND_CLI_SYMBOL : id;
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
function determineCommandDiscoveryOptions(commandDiscovery
|
|
60
|
+
function determineCommandDiscoveryOptions(commandDiscovery) {
|
|
61
61
|
if (!commandDiscovery)
|
|
62
62
|
return;
|
|
63
|
-
if (typeof commandDiscovery === 'string' && defaultCmdId) {
|
|
64
|
-
return { strategy: 'single', target: commandDiscovery };
|
|
65
|
-
}
|
|
66
63
|
if (typeof commandDiscovery === 'string') {
|
|
67
64
|
return { globPatterns: GLOB_PATTERNS, strategy: 'pattern', target: commandDiscovery };
|
|
68
65
|
}
|
|
@@ -202,7 +199,7 @@ class Plugin {
|
|
|
202
199
|
k,
|
|
203
200
|
(0, util_1.castArray)(v).map((v) => determineHookOptions(v)),
|
|
204
201
|
]));
|
|
205
|
-
this.commandDiscoveryOpts = determineCommandDiscoveryOptions(this.pjson.oclif?.commands
|
|
202
|
+
this.commandDiscoveryOpts = determineCommandDiscoveryOptions(this.pjson.oclif?.commands);
|
|
206
203
|
this._debug('command discovery options', this.commandDiscoveryOpts);
|
|
207
204
|
this.manifest = await this._manifest();
|
|
208
205
|
this.commands = Object.entries(this.manifest.commands)
|
package/lib/config/ts-path.d.ts
CHANGED
|
@@ -6,4 +6,4 @@ export declare const TS_CONFIGS: Record<string, TSConfig | undefined>;
|
|
|
6
6
|
* if there is a tsconfig and the original sources exist, it attempts to require ts-node
|
|
7
7
|
*/
|
|
8
8
|
export declare function tsPath(root: string, orig: string, plugin: Plugin): Promise<string>;
|
|
9
|
-
export declare function tsPath(root: string, orig: string | undefined, plugin?: Plugin): Promise<string | undefined>;
|
|
9
|
+
export declare function tsPath(root: string, orig: string | undefined, plugin?: Plugin | undefined): Promise<string | undefined>;
|
|
@@ -3,15 +3,15 @@ import { OclifError, PrettyPrintableError } from '../../interfaces/errors';
|
|
|
3
3
|
* properties specific to internal oclif error handling
|
|
4
4
|
*/
|
|
5
5
|
export declare function addOclifExitCode(error: Record<string, any>, options?: {
|
|
6
|
-
exit?: false | number;
|
|
6
|
+
exit?: false | number | undefined;
|
|
7
7
|
}): OclifError;
|
|
8
8
|
export declare class CLIError extends Error implements OclifError {
|
|
9
|
-
code?: string;
|
|
9
|
+
code?: string | undefined;
|
|
10
10
|
oclif: OclifError['oclif'];
|
|
11
|
-
skipOclifErrorHandling?: boolean;
|
|
12
|
-
suggestions?: string[];
|
|
11
|
+
skipOclifErrorHandling?: boolean | undefined;
|
|
12
|
+
suggestions?: string[] | undefined;
|
|
13
13
|
constructor(error: Error | string, options?: {
|
|
14
|
-
exit?: false | number;
|
|
14
|
+
exit?: false | number | undefined;
|
|
15
15
|
} & PrettyPrintableError);
|
|
16
16
|
get bang(): string | undefined;
|
|
17
17
|
get stack(): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PrettyPrintableError } from '../../interfaces/errors';
|
|
2
2
|
type CLIErrorDisplayOptions = {
|
|
3
|
-
bang?: string;
|
|
4
|
-
name?: string;
|
|
3
|
+
bang?: string | undefined;
|
|
4
|
+
name?: string | undefined;
|
|
5
5
|
};
|
|
6
6
|
export declare function applyPrettyPrintOptions(error: Error, options: PrettyPrintableError): PrettyPrintableError;
|
|
7
7
|
export default function prettyPrint(error: Error & PrettyPrintableError & CLIErrorDisplayOptions): string | undefined;
|
package/lib/flags.d.ts
CHANGED
|
@@ -72,8 +72,8 @@ export declare function boolean<T = boolean>(options?: Partial<BooleanFlag<T>>):
|
|
|
72
72
|
* - `max` option allows to set a maximum value.
|
|
73
73
|
*/
|
|
74
74
|
export declare const integer: FlagDefinition<number, {
|
|
75
|
-
max?: number
|
|
76
|
-
min?: number
|
|
75
|
+
max?: number;
|
|
76
|
+
min?: number;
|
|
77
77
|
}, {
|
|
78
78
|
multiple: false;
|
|
79
79
|
requiredOrDefaulted: false;
|
|
@@ -84,7 +84,7 @@ export declare const integer: FlagDefinition<number, {
|
|
|
84
84
|
* - `exists` option allows you to throw an error if the directory does not exist.
|
|
85
85
|
*/
|
|
86
86
|
export declare const directory: FlagDefinition<string, {
|
|
87
|
-
exists?: boolean
|
|
87
|
+
exists?: boolean;
|
|
88
88
|
}, {
|
|
89
89
|
multiple: false;
|
|
90
90
|
requiredOrDefaulted: false;
|
|
@@ -95,7 +95,7 @@ export declare const directory: FlagDefinition<string, {
|
|
|
95
95
|
* - `exists` option allows you to throw an error if the file does not exist.
|
|
96
96
|
*/
|
|
97
97
|
export declare const file: FlagDefinition<string, {
|
|
98
|
-
exists?: boolean
|
|
98
|
+
exists?: boolean;
|
|
99
99
|
}, {
|
|
100
100
|
multiple: false;
|
|
101
101
|
requiredOrDefaulted: false;
|
package/lib/flush.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.flush = void 0;
|
|
4
|
-
const
|
|
4
|
+
const error_1 = require("./errors/error");
|
|
5
5
|
function timeout(p, ms) {
|
|
6
6
|
function wait(ms, unref = false) {
|
|
7
7
|
return new Promise((resolve) => {
|
|
@@ -10,7 +10,7 @@ function timeout(p, ms) {
|
|
|
10
10
|
t.unref();
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
|
-
return Promise.race([p, wait(ms, true).then(() => (0,
|
|
13
|
+
return Promise.race([p, wait(ms, true).then(() => (0, error_1.error)('timed out'))]);
|
|
14
14
|
}
|
|
15
15
|
async function _flush() {
|
|
16
16
|
const p = new Promise((resolve) => {
|
package/lib/help/formatter.d.ts
CHANGED
|
@@ -59,9 +59,9 @@ export declare class HelpFormatter {
|
|
|
59
59
|
indent(body: string, spacing?: number): string;
|
|
60
60
|
renderList(input: (string | undefined)[][], opts: {
|
|
61
61
|
indentation: number;
|
|
62
|
-
multiline?: boolean;
|
|
63
|
-
spacer?: string;
|
|
64
|
-
stripAnsi?: boolean;
|
|
62
|
+
multiline?: boolean | undefined;
|
|
63
|
+
spacer?: string | undefined;
|
|
64
|
+
stripAnsi?: boolean | undefined;
|
|
65
65
|
}): string;
|
|
66
66
|
section(header: string, body: [string, string | undefined][] | HelpSection | HelpSectionKeyValueTable | string): string;
|
|
67
67
|
/**
|
package/lib/help/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import * as Interfaces from '../interfaces';
|
|
|
3
3
|
import { CommandHelp } from './command';
|
|
4
4
|
import { HelpFormatter } from './formatter';
|
|
5
5
|
export { CommandHelp } from './command';
|
|
6
|
+
export { HelpFormatter, type HelpSection, type HelpSectionKeyValueTable, type HelpSectionRenderer } from './formatter';
|
|
6
7
|
export { getHelpFlagAdditions, normalizeArgv, standardizeIDFromArgv } from './util';
|
|
7
8
|
export declare abstract class HelpBase extends HelpFormatter {
|
|
8
9
|
constructor(config: Interfaces.Config, opts?: Partial<Interfaces.HelpOptions>);
|
package/lib/help/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.loadHelpClass = exports.Help = exports.HelpBase = exports.standardizeIDFromArgv = exports.normalizeArgv = exports.getHelpFlagAdditions = exports.CommandHelp = void 0;
|
|
6
|
+
exports.loadHelpClass = exports.Help = exports.HelpBase = exports.standardizeIDFromArgv = exports.normalizeArgv = exports.getHelpFlagAdditions = exports.HelpFormatter = exports.CommandHelp = void 0;
|
|
7
7
|
const ansis_1 = __importDefault(require("ansis"));
|
|
8
8
|
const ts_path_1 = require("../config/ts-path");
|
|
9
9
|
const error_1 = require("../errors/error");
|
|
@@ -12,7 +12,7 @@ const symbols_1 = require("../symbols");
|
|
|
12
12
|
const cache_default_value_1 = require("../util/cache-default-value");
|
|
13
13
|
const ids_1 = require("../util/ids");
|
|
14
14
|
const util_1 = require("../util/util");
|
|
15
|
-
const ux_1 =
|
|
15
|
+
const ux_1 = require("../ux");
|
|
16
16
|
const theme_1 = require("../ux/theme");
|
|
17
17
|
const command_1 = require("./command");
|
|
18
18
|
const formatter_1 = require("./formatter");
|
|
@@ -20,6 +20,8 @@ const root_1 = __importDefault(require("./root"));
|
|
|
20
20
|
const util_2 = require("./util");
|
|
21
21
|
var command_2 = require("./command");
|
|
22
22
|
Object.defineProperty(exports, "CommandHelp", { enumerable: true, get: function () { return command_2.CommandHelp; } });
|
|
23
|
+
var formatter_2 = require("./formatter");
|
|
24
|
+
Object.defineProperty(exports, "HelpFormatter", { enumerable: true, get: function () { return formatter_2.HelpFormatter; } });
|
|
23
25
|
var util_3 = require("./util");
|
|
24
26
|
Object.defineProperty(exports, "getHelpFlagAdditions", { enumerable: true, get: function () { return util_3.getHelpFlagAdditions; } });
|
|
25
27
|
Object.defineProperty(exports, "normalizeArgv", { enumerable: true, get: function () { return util_3.normalizeArgv; } });
|
|
@@ -144,7 +146,7 @@ class Help extends HelpBase {
|
|
|
144
146
|
return new this.CommandHelpClass(command, this.config, this.opts);
|
|
145
147
|
}
|
|
146
148
|
log(...args) {
|
|
147
|
-
this.opts.sendToStderr ? ux_1.
|
|
149
|
+
this.opts.sendToStderr ? ux_1.ux.stderr(args) : ux_1.ux.stdout(args);
|
|
148
150
|
}
|
|
149
151
|
async showCommandHelp(command) {
|
|
150
152
|
const name = command.id;
|
|
@@ -314,17 +316,24 @@ exports.Help = Help;
|
|
|
314
316
|
function extractClass(exported) {
|
|
315
317
|
return exported && exported.default ? exported.default : exported;
|
|
316
318
|
}
|
|
319
|
+
function determineLocation(helpClass) {
|
|
320
|
+
if (typeof helpClass === 'string')
|
|
321
|
+
return { identifier: 'default', target: helpClass };
|
|
322
|
+
if (!helpClass.identifier)
|
|
323
|
+
return { ...helpClass, identifier: 'default' };
|
|
324
|
+
return helpClass;
|
|
325
|
+
}
|
|
317
326
|
async function loadHelpClass(config) {
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
if (configuredClass) {
|
|
327
|
+
if (config.pjson.oclif?.helpClass) {
|
|
328
|
+
const { identifier, target } = determineLocation(config.pjson.oclif?.helpClass);
|
|
321
329
|
try {
|
|
322
|
-
const path = (await (0, ts_path_1.tsPath)(config.root,
|
|
323
|
-
const
|
|
324
|
-
|
|
330
|
+
const path = (await (0, ts_path_1.tsPath)(config.root, target)) ?? target;
|
|
331
|
+
const module = await (0, module_loader_1.load)(config, path);
|
|
332
|
+
const helpClass = module[identifier] ?? (identifier === 'default' ? extractClass(module) : undefined);
|
|
333
|
+
return extractClass(helpClass);
|
|
325
334
|
}
|
|
326
335
|
catch (error) {
|
|
327
|
-
throw new Error(`Unable to load configured help class "${
|
|
336
|
+
throw new Error(`Unable to load configured help class "${target}", failed with message:\n${error.message}`);
|
|
328
337
|
}
|
|
329
338
|
}
|
|
330
339
|
return Help;
|
package/lib/index.d.ts
CHANGED
|
@@ -6,15 +6,14 @@ export { handle } from './errors/handle';
|
|
|
6
6
|
export { execute } from './execute';
|
|
7
7
|
export * as Flags from './flags';
|
|
8
8
|
export { flush } from './flush';
|
|
9
|
-
export { CommandHelp, Help, HelpBase, loadHelpClass } from './help';
|
|
10
|
-
export { HelpSection, HelpSectionKeyValueTable, HelpSectionRenderer } from './help/formatter';
|
|
9
|
+
export { CommandHelp, Help, HelpBase, type HelpSection, type HelpSectionKeyValueTable, type HelpSectionRenderer, loadHelpClass, } from './help';
|
|
11
10
|
export * as Interfaces from './interfaces';
|
|
12
|
-
export { Hook } from './interfaces/hooks';
|
|
11
|
+
export { type Hook } from './interfaces/hooks';
|
|
13
12
|
export { getLogger } from './logger';
|
|
14
13
|
export { run } from './main';
|
|
15
14
|
export * as ModuleLoader from './module-loader';
|
|
16
15
|
export * as Parser from './parser';
|
|
17
16
|
export { Performance } from './performance';
|
|
18
|
-
export { Settings, settings } from './settings';
|
|
17
|
+
export { type Settings, settings } from './settings';
|
|
19
18
|
export { toConfiguredId, toStandardizedId } from './util/ids';
|
|
20
|
-
export {
|
|
19
|
+
export { ux } from './ux';
|
package/lib/index.js
CHANGED
|
@@ -69,4 +69,4 @@ var ids_1 = require("./util/ids");
|
|
|
69
69
|
Object.defineProperty(exports, "toConfiguredId", { enumerable: true, get: function () { return ids_1.toConfiguredId; } });
|
|
70
70
|
Object.defineProperty(exports, "toStandardizedId", { enumerable: true, get: function () { return ids_1.toStandardizedId; } });
|
|
71
71
|
var ux_1 = require("./ux");
|
|
72
|
-
Object.defineProperty(exports, "ux", { enumerable: true, get: function () { return ux_1.
|
|
72
|
+
Object.defineProperty(exports, "ux", { enumerable: true, get: function () { return ux_1.ux; } });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Command } from '../command';
|
|
3
3
|
import { Hook, Hooks } from './hooks';
|
|
4
|
-
import { PJSON } from './pjson';
|
|
4
|
+
import { Configuration, PJSON, S3Templates } from './pjson';
|
|
5
5
|
import { Options, Plugin } from './plugin';
|
|
6
6
|
import { Theme } from './theme';
|
|
7
7
|
import { Topic } from './topic';
|
|
@@ -34,8 +34,8 @@ export interface Config {
|
|
|
34
34
|
/**
|
|
35
35
|
* name of any bin aliases that will execute the cli
|
|
36
36
|
*/
|
|
37
|
-
readonly binAliases?: string[];
|
|
38
|
-
readonly binPath?: string;
|
|
37
|
+
readonly binAliases?: string[] | undefined;
|
|
38
|
+
readonly binPath?: string | undefined;
|
|
39
39
|
/**
|
|
40
40
|
* cache directory to use for CLI
|
|
41
41
|
*
|
|
@@ -89,9 +89,9 @@ export interface Config {
|
|
|
89
89
|
/**
|
|
90
90
|
* npm registry to use for installing plugins
|
|
91
91
|
*/
|
|
92
|
-
readonly npmRegistry?: string;
|
|
93
|
-
readonly nsisCustomization?: string;
|
|
94
|
-
readonly pjson: PJSON
|
|
92
|
+
readonly npmRegistry?: string | undefined;
|
|
93
|
+
readonly nsisCustomization?: string | undefined;
|
|
94
|
+
readonly pjson: PJSON;
|
|
95
95
|
/**
|
|
96
96
|
* process.platform
|
|
97
97
|
*/
|
|
@@ -101,7 +101,7 @@ export interface Config {
|
|
|
101
101
|
runCommand<T = unknown>(id: string, argv?: string[], cachedCommand?: Command.Loadable): Promise<T>;
|
|
102
102
|
runHook<T extends keyof Hooks>(event: T, opts: Hooks[T]['options'], timeout?: number, captureErrors?: boolean): Promise<Hook.Result<Hooks[T]['return']>>;
|
|
103
103
|
s3Key(type: 'unversioned' | 'versioned', ext: '.tar.gz' | '.tar.xz', options?: Config.s3Key.Options): string;
|
|
104
|
-
s3Key(type: keyof
|
|
104
|
+
s3Key(type: keyof S3Templates, options?: Config.s3Key.Options): string;
|
|
105
105
|
s3Url(key: string): string;
|
|
106
106
|
scopedEnvVar(key: string): string | undefined;
|
|
107
107
|
scopedEnvVarKey(key: string): string;
|
|
@@ -111,10 +111,10 @@ export interface Config {
|
|
|
111
111
|
* active shell
|
|
112
112
|
*/
|
|
113
113
|
readonly shell: string;
|
|
114
|
-
readonly theme?: Theme;
|
|
114
|
+
readonly theme?: Theme | undefined;
|
|
115
115
|
topicSeparator: ' ' | ':';
|
|
116
116
|
readonly topics: Topic[];
|
|
117
|
-
readonly updateConfig: NonNullable<
|
|
117
|
+
readonly updateConfig: NonNullable<Configuration['update']>;
|
|
118
118
|
/**
|
|
119
119
|
* user agent to use for http calls
|
|
120
120
|
*
|
|
@@ -3,25 +3,25 @@ export type CommandError = Error & {
|
|
|
3
3
|
};
|
|
4
4
|
export interface OclifError {
|
|
5
5
|
oclif: {
|
|
6
|
-
exit?: number;
|
|
6
|
+
exit?: number | undefined;
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
9
|
export interface PrettyPrintableError {
|
|
10
10
|
/**
|
|
11
11
|
* a unique error code for this error class
|
|
12
12
|
*/
|
|
13
|
-
code?: string;
|
|
13
|
+
code?: string | undefined;
|
|
14
14
|
/**
|
|
15
15
|
* message to display related to the error
|
|
16
16
|
*/
|
|
17
|
-
message?: string;
|
|
17
|
+
message?: string | undefined;
|
|
18
18
|
/**
|
|
19
19
|
* a url to find out more information related to this error
|
|
20
20
|
* or fixing the error
|
|
21
21
|
*/
|
|
22
|
-
ref?: string;
|
|
22
|
+
ref?: string | undefined;
|
|
23
23
|
/**
|
|
24
24
|
* a suggestion that may be useful or provide additional context
|
|
25
25
|
*/
|
|
26
|
-
suggestions?: string[];
|
|
26
|
+
suggestions?: string[] | undefined;
|
|
27
27
|
}
|
|
@@ -8,7 +8,7 @@ export type { Hook, Hooks } from './hooks';
|
|
|
8
8
|
export type { Logger } from './logger';
|
|
9
9
|
export type { Manifest } from './manifest';
|
|
10
10
|
export type { Arg, BooleanFlag, CustomOptions, Deprecation, Flag, FlagDefinition, OptionFlag } from './parser';
|
|
11
|
-
export type { PJSON } from './pjson';
|
|
11
|
+
export type { Configuration, PJSON, S3, S3Templates, UserPJSON } from './pjson';
|
|
12
12
|
export type { Options, Plugin, PluginOptions } from './plugin';
|
|
13
13
|
export type { S3Manifest } from './s3-manifest';
|
|
14
14
|
export type { Theme } from './theme';
|