@oclif/core 4.0.0-beta.6 → 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.
@@ -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.CLI;
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 PJSON.S3.Templates, options?: Config.s3Key.Options): string;
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<PJSON.CLI['oclif']['update']>;
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';
@@ -8,10 +8,10 @@ export type ArgOutput = {
8
8
  };
9
9
  export type CLIParseErrorOptions = {
10
10
  parse: {
11
- input?: ParserInput;
12
- output?: ParserOutput;
11
+ input?: ParserInput | undefined;
12
+ output?: ParserOutput | undefined;
13
13
  };
14
- exit?: number;
14
+ exit?: number | undefined;
15
15
  };
16
16
  export type OutputArgs<T extends ParserInput['args']> = {
17
17
  [P in keyof T]: any;
@@ -431,7 +431,7 @@ export type Input<TFlags extends FlagOutput, BFlags extends FlagOutput, AFlags e
431
431
  baseFlags?: FlagInput<BFlags>;
432
432
  enableJsonFlag?: true | false;
433
433
  args?: ArgInput<AFlags>;
434
- strict?: boolean;
434
+ strict?: boolean | undefined;
435
435
  context?: ParserContext;
436
436
  '--'?: boolean;
437
437
  };
@@ -441,10 +441,10 @@ export type ParserInput = {
441
441
  args: ArgInput<any>;
442
442
  strict: boolean;
443
443
  context: ParserContext | undefined;
444
- '--'?: boolean;
444
+ '--'?: boolean | undefined;
445
445
  };
446
446
  export type ParserContext = Command & {
447
- token?: FlagToken | ArgToken;
447
+ token?: FlagToken | ArgToken | undefined;
448
448
  };
449
449
  export type FlagInput<T extends FlagOutput = {
450
450
  [flag: string]: any;
@@ -1,21 +1,5 @@
1
1
  import { HelpOptions } from './help';
2
- export interface PJSON {
3
- [k: string]: any;
4
- dependencies?: {
5
- [name: string]: string;
6
- };
7
- devDependencies?: {
8
- [name: string]: string;
9
- };
10
- oclif: {
11
- bin?: string;
12
- dirname?: string;
13
- hooks?: Record<string, string | string[]>;
14
- plugins?: string[];
15
- schema?: number;
16
- };
17
- version: string;
18
- }
2
+ import { Theme } from './theme';
19
3
  export type CommandDiscovery = {
20
4
  /**
21
5
  * The strategy to use for loading commands.
@@ -96,141 +80,222 @@ export type HookOptions = {
96
80
  */
97
81
  identifier: string;
98
82
  };
99
- export declare namespace PJSON {
100
- interface Plugin extends PJSON {
101
- name: string;
102
- oclif: PJSON['oclif'] & {
103
- additionalHelpFlags?: string[];
104
- additionalVersionFlags?: string[];
105
- aliases?: {
106
- [name: string]: null | string;
107
- };
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
- */
115
- default?: string;
83
+ export type HelpLocationOptions = {
84
+ /**
85
+ * The file path containing help class.
86
+ */
87
+ target: string;
88
+ /**
89
+ * The name of the export to use when loading the help class from the `target` file. Defaults to `default`.
90
+ */
91
+ identifier: string;
92
+ };
93
+ export type S3Templates = {
94
+ baseDir?: string;
95
+ manifest?: string;
96
+ unversioned?: string;
97
+ versioned?: string;
98
+ };
99
+ export type S3 = {
100
+ acl?: string | undefined;
101
+ bucket?: string | undefined;
102
+ folder?: string | undefined;
103
+ gz?: boolean | undefined;
104
+ host?: string | undefined;
105
+ templates?: {
106
+ target: S3Templates;
107
+ vanilla: S3Templates;
108
+ } | undefined;
109
+ xz?: boolean | undefined;
110
+ };
111
+ export type Configuration = {
112
+ /**
113
+ * Flags in addition to --help that should trigger help output.
114
+ */
115
+ additionalHelpFlags?: string[];
116
+ /**
117
+ * Flags in addition to --version that should trigger version output.
118
+ */
119
+ additionalVersionFlags?: string[];
120
+ /**
121
+ * Plugin aliases.
122
+ */
123
+ aliases?: {
124
+ [name: string]: null | string;
125
+ };
126
+ /**
127
+ * The name of the executable.
128
+ */
129
+ bin?: string;
130
+ /**
131
+ * Aliases for the executable.
132
+ */
133
+ binAliases?: string[];
134
+ commands?: string | CommandDiscovery;
135
+ /**
136
+ * Your CLI's description. Overrides the description in the package.json.
137
+ */
138
+ description?: string | undefined;
139
+ /**
140
+ * Plugins to load when in development mode.
141
+ */
142
+ devPlugins?: string[];
143
+ /**
144
+ * The directory name to use when determining the cache, config, and data directories.
145
+ */
146
+ dirname?: string;
147
+ /**
148
+ * Example plugin to use in @oclif/plugin-plugin's help output.
149
+ */
150
+ examplePlugin?: string;
151
+ /**
152
+ * Customize the exit codes for the CLI.
153
+ */
154
+ exitCodes?: {
155
+ default?: number;
156
+ failedFlagParsing?: number;
157
+ failedFlagValidation?: number;
158
+ invalidArgsSpec?: number;
159
+ nonExistentFlag?: number;
160
+ requiredArgs?: number;
161
+ unexpectedArgs?: number;
162
+ };
163
+ /**
164
+ * Enable flexible taxonomy for commands.
165
+ */
166
+ flexibleTaxonomy?: boolean;
167
+ /**
168
+ * The location of your custom help class.
169
+ */
170
+ helpClass?: string | HelpLocationOptions;
171
+ /**
172
+ * Options for the help output.
173
+ */
174
+ helpOptions?: HelpOptions;
175
+ /**
176
+ * Register hooks to run at various points in the CLI lifecycle.
177
+ */
178
+ hooks?: {
179
+ [name: string]: string | string[] | HookOptions | HookOptions[];
180
+ };
181
+ /**
182
+ * Plugins that can be installed just-in-time.
183
+ */
184
+ jitPlugins?: Record<string, string>;
185
+ macos?: {
186
+ identifier?: string;
187
+ sign?: string;
188
+ };
189
+ /**
190
+ * Use a private or alternate npm registry.
191
+ */
192
+ npmRegistry?: string;
193
+ /**
194
+ * Script to run during postinstall on windows.
195
+ */
196
+ nsisCustomization?: string;
197
+ /**
198
+ * Plugin prefix to use when working with plugins with @oclif/plugin-plugins.
199
+ *
200
+ * Defaults to `plugin-`.
201
+ */
202
+ pluginPrefix?: string;
203
+ /**
204
+ * Plugins to load.
205
+ */
206
+ plugins?: string[];
207
+ /**
208
+ * Template string used to build links to source code in CLI's README (when using `oclif readme`).
209
+ */
210
+ repositoryPrefix?: string;
211
+ schema?: number;
212
+ /**
213
+ * The namespace to be used for plugins of your CLI, e.g. `@salesforce`.
214
+ */
215
+ scope?: string;
216
+ /**
217
+ * State of your CLI
218
+ *
219
+ * - `beta` - will show message to user that command or CLI is in beta
220
+ * - `deprecated` - will show message to user that command or CLI is deprecated
221
+ */
222
+ state?: 'beta' | 'deprecated' | string;
223
+ /**
224
+ * The theme to ship with the CLI.
225
+ *
226
+ * Can be a path to a JSON file or a Theme object.
227
+ */
228
+ theme?: string | Theme;
229
+ /**
230
+ * Separator to use for your CLI. Can be `:` or ` `.
231
+ */
232
+ topicSeparator?: ' ' | ':';
233
+ /**
234
+ * Customize the topics in the CLI.
235
+ */
236
+ topics?: {
237
+ [k: string]: {
116
238
  description?: string;
117
- devPlugins?: string[];
118
- exitCodes?: {
119
- default?: number;
120
- failedFlagParsing?: number;
121
- failedFlagValidation?: number;
122
- invalidArgsSpec?: number;
123
- nonExistentFlag?: number;
124
- requiredArgs?: number;
125
- unexpectedArgs?: number;
126
- };
127
- flexibleTaxonomy?: boolean;
128
- helpClass?: string;
129
- helpOptions?: HelpOptions;
130
- hooks?: {
131
- [name: string]: string | string[] | HookOptions | HookOptions[];
132
- };
133
- jitPlugins?: Record<string, string>;
134
- macos?: {
135
- identifier?: string;
136
- sign?: string;
137
- };
138
- plugins?: string[];
139
- repositoryPrefix?: string;
140
- schema?: number;
141
- state?: 'beta' | 'deprecated' | string;
142
- theme?: string;
143
- topicSeparator?: ' ' | ':';
144
- topics?: {
145
- [k: string]: {
146
- description?: string;
147
- hidden?: boolean;
148
- subtopics?: Plugin['oclif']['topics'];
149
- };
150
- };
151
- update?: {
152
- autoupdate?: {
153
- debounce?: number;
154
- rollout?: number;
155
- };
156
- disableNpmLookup?: boolean;
157
- node: {
158
- targets?: string[];
159
- version?: string;
160
- options?: string | string[];
161
- };
162
- s3: S3;
163
- };
164
- windows?: {
165
- homepage?: string;
166
- keypath?: string;
167
- name?: string;
168
- };
169
- };
170
- version: string;
171
- }
172
- interface S3 {
173
- acl?: string;
174
- bucket?: string;
175
- folder?: string;
176
- gz?: boolean;
177
- host?: string;
178
- templates: {
179
- target: S3.Templates;
180
- vanilla: S3.Templates;
239
+ hidden?: boolean;
240
+ subtopics?: Configuration['topics'];
181
241
  };
182
- xz?: boolean;
183
- }
184
- namespace S3 {
185
- interface Templates {
186
- baseDir?: string;
187
- manifest?: string;
188
- unversioned?: string;
189
- versioned?: string;
190
- }
191
- }
192
- interface CLI extends Plugin {
193
- oclif: Plugin['oclif'] & {
194
- bin?: string;
195
- binAliases?: string[];
196
- dirname?: string;
197
- flexibleTaxonomy?: boolean;
198
- jitPlugins?: Record<string, string>;
199
- npmRegistry?: string;
200
- nsisCustomization?: string;
201
- schema?: number;
202
- scope?: string;
203
- pluginPrefix?: string;
204
- 'warn-if-update-available'?: {
205
- authorization: string;
206
- message: string;
207
- registry: string;
208
- timeoutInDays: number;
209
- frequency: number;
210
- frequencyUnit: 'days' | 'hours' | 'minutes' | 'seconds' | 'milliseconds';
211
- };
242
+ };
243
+ update?: {
244
+ autoupdate?: {
245
+ debounce?: number;
246
+ rollout?: number;
212
247
  };
213
- }
214
- interface User extends PJSON {
215
- oclif: PJSON['oclif'] & {
216
- plugins?: (PluginTypes.Link | PluginTypes.User | string)[];
248
+ disableNpmLookup?: boolean;
249
+ node: {
250
+ targets?: string[];
251
+ version?: string;
252
+ options?: string | string[];
217
253
  };
218
- private?: boolean;
219
- }
220
- type PluginTypes = {
221
- root: string;
222
- } | PluginTypes.Link | PluginTypes.User;
223
- namespace PluginTypes {
224
- interface User {
225
- name: string;
226
- tag?: string;
227
- type: 'user';
228
- url?: string;
229
- }
230
- interface Link {
231
- name: string;
232
- root: string;
233
- type: 'link';
234
- }
235
- }
236
- }
254
+ s3: S3;
255
+ };
256
+ 'warn-if-update-available'?: {
257
+ authorization?: string;
258
+ message?: string;
259
+ registry?: string;
260
+ timeoutInDays?: number;
261
+ frequency?: number;
262
+ frequencyUnit?: 'days' | 'hours' | 'minutes' | 'seconds' | 'milliseconds';
263
+ };
264
+ windows?: {
265
+ homepage?: string;
266
+ keypath?: string;
267
+ name?: string;
268
+ };
269
+ };
270
+ export type UserPlugin = {
271
+ name: string;
272
+ tag?: string;
273
+ type: 'user';
274
+ url?: string;
275
+ };
276
+ export type LinkedPlugin = {
277
+ name: string;
278
+ root: string;
279
+ type: 'link';
280
+ };
281
+ export type PluginTypes = {
282
+ root: string;
283
+ } | UserPlugin | LinkedPlugin;
284
+ export type UserPJSON = {
285
+ oclif: {
286
+ plugins?: PluginTypes[];
287
+ };
288
+ private?: boolean;
289
+ };
290
+ export type PJSON = {
291
+ [k: string]: any;
292
+ dependencies?: {
293
+ [name: string]: string;
294
+ };
295
+ devDependencies?: {
296
+ [name: string]: string;
297
+ };
298
+ name: string;
299
+ oclif: Configuration;
300
+ version: string;
301
+ };
@@ -3,35 +3,35 @@ import { Logger } from './logger';
3
3
  import { HookOptions, PJSON } from './pjson';
4
4
  import { Topic } from './topic';
5
5
  export interface PluginOptions {
6
- children?: Plugin[];
7
- errorOnManifestCreate?: boolean;
8
- flexibleTaxonomy?: boolean;
9
- ignoreManifest?: boolean;
10
- isRoot?: boolean;
11
- name?: string;
12
- parent?: Plugin;
13
- pjson?: PJSON.Plugin;
14
- respectNoCacheDefault?: boolean;
6
+ children?: Plugin[] | undefined;
7
+ errorOnManifestCreate?: boolean | undefined;
8
+ flexibleTaxonomy?: boolean | undefined;
9
+ ignoreManifest?: boolean | undefined;
10
+ isRoot?: boolean | undefined;
11
+ name?: string | undefined;
12
+ parent?: Plugin | undefined;
13
+ pjson?: PJSON | undefined;
14
+ respectNoCacheDefault?: boolean | undefined;
15
15
  root: string;
16
- tag?: string;
17
- type?: string;
18
- url?: string;
16
+ tag?: string | undefined;
17
+ type?: string | undefined;
18
+ url?: string | undefined;
19
19
  }
20
20
  export interface Options extends PluginOptions {
21
- channel?: string;
22
- devPlugins?: boolean;
23
- enablePerf?: boolean;
24
- jitPlugins?: boolean;
25
- logger?: Logger;
26
- pjson?: PJSON.Plugin;
21
+ channel?: string | undefined;
22
+ devPlugins?: boolean | undefined;
23
+ enablePerf?: boolean | undefined;
24
+ jitPlugins?: boolean | undefined;
25
+ logger?: Logger | undefined;
26
+ pjson?: PJSON | undefined;
27
27
  pluginAdditions?: {
28
28
  core?: string[];
29
29
  dev?: string[];
30
30
  path?: string;
31
- };
32
- plugins?: Map<string, Plugin>;
33
- userPlugins?: boolean;
34
- version?: string;
31
+ } | undefined;
32
+ plugins?: Map<string, Plugin> | undefined;
33
+ userPlugins?: boolean | undefined;
34
+ version?: string | undefined;
35
35
  }
36
36
  export interface Plugin {
37
37
  /**
@@ -69,13 +69,13 @@ export interface Plugin {
69
69
  */
70
70
  name: string;
71
71
  readonly options: Options;
72
- parent?: Plugin;
72
+ parent?: Plugin | undefined;
73
73
  /**
74
74
  * full package.json
75
75
  *
76
76
  * parsed with read-pkg
77
77
  */
78
- pjson: PJSON.CLI | PJSON.Plugin;
78
+ pjson: PJSON;
79
79
  /**
80
80
  * base path of plugin
81
81
  */
@@ -84,7 +84,7 @@ export interface Plugin {
84
84
  * npm dist-tag of plugin
85
85
  * only used for user plugins
86
86
  */
87
- tag?: string;
87
+ tag?: string | undefined;
88
88
  readonly topics: Topic[];
89
89
  /**
90
90
  * used to tell the user how the plugin was installed
@@ -1,5 +1,5 @@
1
1
  export interface Topic {
2
- description?: string;
3
- hidden?: boolean;
2
+ description?: string | undefined;
3
+ hidden?: boolean | undefined;
4
4
  name: string;
5
5
  }
package/lib/main.js CHANGED
@@ -11,7 +11,7 @@ const help_1 = require("./help");
11
11
  const logger_1 = require("./logger");
12
12
  const performance_1 = require("./performance");
13
13
  const symbols_1 = require("./symbols");
14
- const ux_1 = __importDefault(require("./ux"));
14
+ const ux_1 = require("./ux");
15
15
  const helpAddition = (argv, config) => {
16
16
  if (argv.length === 0 && !config.isSingleCommandCLI)
17
17
  return true;
@@ -69,7 +69,7 @@ async function run(argv, options) {
69
69
  await config.runHook('init', { argv: argvSlice, id });
70
70
  // display version if applicable
71
71
  if ((0, exports.versionAddition)(argv, config)) {
72
- ux_1.default.stdout(config.userAgent);
72
+ ux_1.ux.stdout(config.userAgent);
73
73
  await collectPerf();
74
74
  return;
75
75
  }
@@ -3,7 +3,7 @@ import { Arg, ArgInput, CLIParseErrorOptions, OptionFlag } from '../interfaces/p
3
3
  export { CLIError } from '../errors';
4
4
  export type Validation = {
5
5
  name: string;
6
- reason?: string;
6
+ reason?: string | undefined;
7
7
  status: 'failed' | 'success';
8
8
  validationFn: string;
9
9
  };
package/lib/settings.d.ts CHANGED
@@ -5,19 +5,19 @@ export type Settings = {
5
5
  * Environment Variable:
6
6
  * OCLIF_COLUMNS=80
7
7
  */
8
- columns?: number;
8
+ columns?: number | undefined;
9
9
  /**
10
10
  * Show additional debug output without DEBUG. Mainly shows stackstraces.
11
11
  *
12
12
  * Useful to set in the ./bin/dev.js script.
13
13
  * oclif.settings.debug = true;
14
14
  */
15
- debug?: boolean;
15
+ debug?: boolean | undefined;
16
16
  /**
17
17
  * Enable performance tracking. Resulting data is available in the `perf` property of the `Config` class.
18
18
  * This will be overridden by the `enablePerf` property passed into Config constructor.
19
19
  */
20
- performanceEnabled?: boolean;
20
+ performanceEnabled?: boolean | undefined;
21
21
  /**
22
22
  * Try to use ts-node to load typescript source files instead of javascript files.
23
23
  * Defaults to true in development and test environments (e.g. using bin/dev.js or
@@ -25,12 +25,12 @@ export type Settings = {
25
25
  *
26
26
  * @deprecated use enableAutoTranspile instead.
27
27
  */
28
- tsnodeEnabled?: boolean;
28
+ tsnodeEnabled?: boolean | undefined;
29
29
  /**
30
30
  * Enable automatic transpilation of TypeScript files to JavaScript.
31
31
  *
32
32
  * Defaults to true in development and test environments (e.g. using bin/dev.js or NODE_ENV=development or NODE_ENV=test).
33
33
  */
34
- enableAutoTranspile?: boolean;
34
+ enableAutoTranspile?: boolean | undefined;
35
35
  };
36
36
  export declare const settings: Settings;
package/lib/util/ids.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { Config } from '../interfaces';
1
+ import { type Config } from '../interfaces/config';
2
2
  export declare function toStandardizedId(commandID: string, config: Config): string;
3
3
  export declare function toConfiguredId(commandID: string, config: Config): string;
@@ -4,4 +4,4 @@ import { PJSON } from '../interfaces';
4
4
  *
5
5
  * We can assume that the package.json file exists because the plugin root has already been loaded at this point.
6
6
  */
7
- export declare function readPjson(path: string): Promise<PJSON.Plugin>;
7
+ export declare function readPjson(path: string): Promise<PJSON>;