UNPKG

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