UNPKG

2.4 kBTypeScriptView Raw
1import { Command } from './command';
2import { Manifest } from './manifest';
3import { PJSON } from './pjson';
4import { Topic } from './topic';
5export interface Options {
6 root: string;
7 name?: string;
8 type?: string;
9 tag?: string;
10 ignoreManifest?: boolean;
11 errorOnManifestCreate?: boolean;
12}
13export interface IPlugin {
14 /**
15 * @oclif/config version
16 */
17 _base: string;
18 /**
19 * name from package.json
20 */
21 name: string;
22 /**
23 * version from package.json
24 *
25 * example: 1.2.3
26 */
27 version: string;
28 /**
29 * full package.json
30 *
31 * parsed with read-pkg
32 */
33 pjson: PJSON.Plugin | PJSON.CLI;
34 /**
35 * used to tell the user how the plugin was installed
36 * examples: core, link, user, dev
37 */
38 type: string;
39 /**
40 * base path of plugin
41 */
42 root: string;
43 /**
44 * npm dist-tag of plugin
45 * only used for user plugins
46 */
47 tag?: string;
48 /**
49 * if it appears to be an npm package but does not look like it's really a CLI plugin, this is set to false
50 */
51 valid: boolean;
52 commands: Command.Plugin[];
53 hooks: {
54 [k: string]: string[];
55 };
56 readonly commandIDs: string[];
57 readonly topics: Topic[];
58 findCommand(id: string, opts: {
59 must: true;
60 }): Command.Class;
61 findCommand(id: string, opts?: {
62 must: boolean;
63 }): Command.Class | undefined;
64 load(): Promise<void>;
65}
66export declare class Plugin implements IPlugin {
67 options: Options;
68 _base: string;
69 name: string;
70 version: string;
71 pjson: PJSON.Plugin;
72 type: string;
73 root: string;
74 tag?: string;
75 manifest: Manifest;
76 commands: Command.Plugin[];
77 hooks: {
78 [k: string]: string[];
79 };
80 valid: boolean;
81 alreadyLoaded: boolean;
82 protected warned: boolean;
83 constructor(options: Options);
84 load(): Promise<void>;
85 readonly topics: Topic[];
86 readonly commandsDir: string | undefined;
87 readonly commandIDs: string[];
88 findCommand(id: string, opts: {
89 must: true;
90 }): Command.Class;
91 findCommand(id: string, opts?: {
92 must: boolean;
93 }): Command.Class | undefined;
94 protected _manifest(ignoreManifest: boolean, errorOnManifestCreate?: boolean): Promise<Manifest>;
95 protected warn(err: any, scope?: string): void;
96 private addErrorScope(err, scope?);
97}