@oclif/core 3.0.1 → 3.0.3

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[];
@@ -527,6 +527,13 @@ class Config {
527
527
  const command = await c.load();
528
528
  await this.runHook('prerun', { Command: command, argv });
529
529
  const result = (await command.run(argv, this));
530
+ // If plugins:uninstall was run, we need to remove all the uninstalled plugins
531
+ // from this.plugins so that the postrun hook doesn't attempt to run any
532
+ // hooks that might have existed in the uninstalled plugins.
533
+ if (c.id === 'plugins:uninstall') {
534
+ for (const arg of argv)
535
+ this.plugins.delete(arg);
536
+ }
530
537
  await this.runHook('postrun', { Command: command, argv, result });
531
538
  marker?.addDetails({ command: id, plugin: c.pluginName });
532
539
  marker?.stop();
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
@@ -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
  }
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.1",
4
+ "version": "3.0.3",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/oclif/core/issues",
7
7
  "dependencies": {