@oclif/core 3.0.2 → 3.0.4

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/command.d.ts CHANGED
@@ -117,13 +117,28 @@ export declare abstract class Command {
117
117
  abstract run(): Promise<any>;
118
118
  }
119
119
  export declare namespace Command {
120
+ /**
121
+ * The Command class exported by a command file.
122
+ */
120
123
  type Class = typeof Command & {
121
124
  id: string;
122
125
  run(argv?: string[], config?: LoadOptions): Promise<any>;
123
126
  };
124
- interface Loadable extends Cached {
127
+ /**
128
+ * A cached command that's had a `load` method attached to it.
129
+ *
130
+ * The `Plugin` class loads the commands from the manifest (if it exists) or requires and caches
131
+ * the commands directly from the commands directory inside the plugin. At this point the plugin
132
+ * is working with `Command.Cached`. It then appends a `load` method to each one. If the a command
133
+ * is executed then the `load` method is used to require the command class.
134
+ */
135
+ type Loadable = Cached & {
125
136
  load(): Promise<Command.Class>;
126
- }
137
+ };
138
+ /**
139
+ * A cached version of the command. This is created by the cachedCommand utility and
140
+ * stored in the oclif.manifest.json.
141
+ */
127
142
  type Cached = {
128
143
  [key: string]: unknown;
129
144
  aliasPermutations?: string[];
@@ -131,6 +146,7 @@ export declare namespace Command {
131
146
  args: {
132
147
  [name: string]: Arg.Cached;
133
148
  };
149
+ deprecateAliases?: boolean;
134
150
  deprecationOptions?: Deprecation;
135
151
  description?: string;
136
152
  examples?: Example[];
package/lib/execute.d.ts CHANGED
@@ -8,19 +8,23 @@ import { LoadOptions } from './interfaces';
8
8
  * @example For ESM dev.js
9
9
  * ```
10
10
  * #!/usr/bin/env ts-node
11
- * void (async () => {
11
+ * async function main() {
12
12
  * const oclif = await import('@oclif/core')
13
13
  * await oclif.execute({development: true, dir: import.meta.url})
14
- * })()
14
+ * }
15
+ *
16
+ * await main()
15
17
  * ```
16
18
  *
17
19
  * @example For ESM run.js
18
20
  * ```
19
21
  * #!/usr/bin/env node
20
- * void (async () => {
22
+ * async function main() {
21
23
  * const oclif = await import('@oclif/core')
22
24
  * await oclif.execute({dir: import.meta.url})
23
- * })()
25
+ * }
26
+ *
27
+ * await main()
24
28
  * ```
25
29
  *
26
30
  * @example For CJS dev.js
package/lib/execute.js CHANGED
@@ -14,19 +14,23 @@ const settings_1 = require("./settings");
14
14
  * @example For ESM dev.js
15
15
  * ```
16
16
  * #!/usr/bin/env ts-node
17
- * void (async () => {
17
+ * async function main() {
18
18
  * const oclif = await import('@oclif/core')
19
19
  * await oclif.execute({development: true, dir: import.meta.url})
20
- * })()
20
+ * }
21
+ *
22
+ * await main()
21
23
  * ```
22
24
  *
23
25
  * @example For ESM run.js
24
26
  * ```
25
27
  * #!/usr/bin/env node
26
- * void (async () => {
28
+ * async function main() {
27
29
  * const oclif = await import('@oclif/core')
28
30
  * await oclif.execute({dir: import.meta.url})
29
- * })()
31
+ * }
32
+ *
33
+ * await main()
30
34
  * ```
31
35
  *
32
36
  * @example For CJS dev.js
package/lib/flags.d.ts CHANGED
@@ -76,31 +76,31 @@ export declare const string: FlagDefinition<string, CustomOptions, {
76
76
  }>;
77
77
  export declare const version: (opts?: Partial<BooleanFlag<boolean>>) => BooleanFlag<void>;
78
78
  export declare const help: (opts?: Partial<BooleanFlag<boolean>>) => BooleanFlag<void>;
79
- type ElementType<T extends ReadonlyArray<unknown>> = T[number];
80
- export declare function option<T extends readonly string[], P extends CustomOptions>(defaults: Partial<OptionFlag<ElementType<T>[], P>> & {
79
+ type ReadonlyElementOf<T extends ReadonlyArray<unknown>> = T[number];
80
+ export declare function option<T extends readonly string[], P extends CustomOptions>(defaults: Partial<OptionFlag<ReadonlyElementOf<T>[], P>> & {
81
81
  multiple: true;
82
82
  options: T;
83
83
  } & ({
84
- default: OptionFlag<ElementType<T>[], P>['default'] | undefined;
84
+ default: OptionFlag<ReadonlyElementOf<T>[], P>['default'] | undefined;
85
85
  } | {
86
86
  required: true;
87
87
  })): FlagDefinition<(typeof defaults.options)[number], P, {
88
88
  multiple: true;
89
89
  requiredOrDefaulted: true;
90
90
  }>;
91
- export declare function option<T extends readonly string[], P extends CustomOptions>(defaults: Partial<OptionFlag<ElementType<T>, P>> & {
91
+ export declare function option<T extends readonly string[], P extends CustomOptions>(defaults: Partial<OptionFlag<ReadonlyElementOf<T>, P>> & {
92
92
  multiple?: false | undefined;
93
93
  options: T;
94
94
  } & ({
95
- default: OptionFlag<ElementType<T>, P>['default'];
95
+ default: OptionFlag<ReadonlyElementOf<T>, P>['default'];
96
96
  } | {
97
97
  required: true;
98
98
  })): FlagDefinition<(typeof defaults.options)[number], P, {
99
99
  multiple: false;
100
100
  requiredOrDefaulted: true;
101
101
  }>;
102
- export declare function option<T extends readonly string[], P extends CustomOptions>(defaults: Partial<OptionFlag<ElementType<T>, P>> & {
103
- default?: OptionFlag<ElementType<T>, P>['default'] | undefined;
102
+ export declare function option<T extends readonly string[], P extends CustomOptions>(defaults: Partial<OptionFlag<ReadonlyElementOf<T>, P>> & {
103
+ default?: OptionFlag<ReadonlyElementOf<T>, P>['default'] | undefined;
104
104
  multiple?: false | undefined;
105
105
  options: T;
106
106
  required?: false | undefined;
@@ -108,8 +108,8 @@ export declare function option<T extends readonly string[], P extends CustomOpti
108
108
  multiple: false;
109
109
  requiredOrDefaulted: false;
110
110
  }>;
111
- export declare function option<T extends readonly string[], P extends CustomOptions>(defaults: Partial<OptionFlag<ElementType<T>[], P>> & {
112
- default?: OptionFlag<ElementType<T>[], P>['default'] | undefined;
111
+ export declare function option<T extends readonly string[], P extends CustomOptions>(defaults: Partial<OptionFlag<ReadonlyElementOf<T>[], P>> & {
112
+ default?: OptionFlag<ReadonlyElementOf<T>[], P>['default'] | undefined;
113
113
  multiple: true;
114
114
  options: T;
115
115
  required?: false | undefined;
@@ -2,10 +2,10 @@ import { Command } from '../command';
2
2
  import * as Interfaces from '../interfaces';
3
3
  import { HelpFormatter, HelpSectionRenderer } from './formatter';
4
4
  export declare class CommandHelp extends HelpFormatter {
5
- command: Command.Cached | Command.Class | Command.Loadable;
5
+ command: Command.Loadable;
6
6
  config: Interfaces.Config;
7
7
  opts: Interfaces.HelpOptions;
8
- constructor(command: Command.Cached | Command.Class | Command.Loadable, config: Interfaces.Config, opts: Interfaces.HelpOptions);
8
+ constructor(command: Command.Loadable, config: Interfaces.Config, opts: Interfaces.HelpOptions);
9
9
  private formatIfCommand;
10
10
  private isCommand;
11
11
  protected aliases(aliases: string[] | undefined): string | undefined;
@@ -10,7 +10,7 @@ export type HelpSection = {
10
10
  } | undefined;
11
11
  export type HelpSectionRenderer = (data: {
12
12
  args: Command.Arg.Any[];
13
- cmd: Command.Cached | Command.Class | Command.Loadable;
13
+ cmd: Command.Loadable;
14
14
  flags: Command.Flag.Any[];
15
15
  }, header: string) => HelpSection | HelpSection[] | string | undefined;
16
16
  export declare class HelpFormatter {
@@ -11,7 +11,7 @@ export declare abstract class HelpBase extends HelpFormatter {
11
11
  * @param command
12
12
  * @param topics
13
13
  */
14
- abstract showCommandHelp(command: Command.Class, topics: Interfaces.Topic[]): Promise<void>;
14
+ abstract showCommandHelp(command: Command.Loadable, topics: Interfaces.Topic[]): Promise<void>;
15
15
  /**
16
16
  * Show help, used in multi-command CLIs
17
17
  * @param args passed into your command, useful for determining which type of help to display
@@ -22,20 +22,20 @@ export declare class Help extends HelpBase {
22
22
  protected CommandHelpClass: typeof CommandHelp;
23
23
  constructor(config: Interfaces.Config, opts?: Partial<Interfaces.HelpOptions>);
24
24
  private get _topics();
25
- protected command(command: Command.Class): string;
26
- protected description(c: Command.Cached | Command.Class | Command.Loadable): string;
27
- protected formatCommand(command: Command.Cached | Command.Class | Command.Loadable): string;
28
- protected formatCommands(commands: Array<Command.Cached | Command.Class | Command.Loadable>): string;
25
+ protected command(command: Command.Loadable): string;
26
+ protected description(c: Command.Loadable): string;
27
+ protected formatCommand(command: Command.Loadable): string;
28
+ protected formatCommands(commands: Array<Command.Loadable>): string;
29
29
  protected formatRoot(): string;
30
30
  protected formatTopic(topic: Interfaces.Topic): string;
31
31
  protected formatTopics(topics: Interfaces.Topic[]): string;
32
- protected getCommandHelpClass(command: Command.Cached | Command.Class | Command.Loadable): CommandHelp;
32
+ protected getCommandHelpClass(command: Command.Loadable): CommandHelp;
33
33
  protected log(...args: string[]): void;
34
- showCommandHelp(command: Command.Cached | Command.Class | Command.Loadable): Promise<void>;
34
+ showCommandHelp(command: Command.Loadable): Promise<void>;
35
35
  showHelp(argv: string[]): Promise<void>;
36
36
  protected showRootHelp(): Promise<void>;
37
37
  protected showTopicHelp(topic: Interfaces.Topic): Promise<void>;
38
- protected summary(c: Command.Cached | Command.Class | Command.Loadable): string | undefined;
38
+ protected summary(c: Command.Loadable): string | undefined;
39
39
  protected get sortedCommands(): Command.Loadable[];
40
40
  protected get sortedTopics(): Interfaces.Topic[];
41
41
  }
@@ -210,7 +210,8 @@ export type OptionFlagProps = FlagProps & {
210
210
  export type FlagParserContext = Command & {
211
211
  token: FlagToken;
212
212
  };
213
- export type FlagParser<T, I extends string | boolean, P = CustomOptions> = (input: I, context: FlagParserContext, opts: P & OptionFlag<T, P>) => T extends Array<infer U> ? Promise<U | undefined> : Promise<T | undefined>;
213
+ type NonNullableElementOf<T> = [NonNullable<T>] extends [Array<infer U>] ? U : T;
214
+ export type FlagParser<T, I extends string | boolean, P = CustomOptions> = (input: I, context: FlagParserContext, opts: P & OptionFlag<T, P>) => Promise<NonNullableElementOf<T> | undefined>;
214
215
  export type ArgParserContext = Command & {
215
216
  token: ArgToken;
216
217
  };
@@ -40,6 +40,11 @@ export declare namespace PJSON {
40
40
  identifier?: string;
41
41
  sign?: string;
42
42
  };
43
+ windows?: {
44
+ homepage?: string;
45
+ keypath?: string;
46
+ name?: string;
47
+ };
43
48
  plugins?: string[];
44
49
  repositoryPrefix?: string;
45
50
  schema?: number;
@@ -69,6 +74,7 @@ export declare namespace PJSON {
69
74
  interface S3 {
70
75
  acl?: string;
71
76
  bucket?: string;
77
+ folder?: string;
72
78
  gz?: boolean;
73
79
  host?: string;
74
80
  templates: {
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.0.2",
4
+ "version": "3.0.4",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/oclif/core/issues",
7
7
  "dependencies": {