UNPKG

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