UNPKG

3.45 kBTypeScriptView Raw
1import * as Config from '.';
2export interface Options {
3 root: string;
4 name?: string;
5 type?: string;
6 tag?: string;
7 ignoreManifest?: boolean;
8}
9export interface IPlugin {
10 /**
11 * @anycli/config version
12 */
13 _base: string;
14 /**
15 * name from package.json
16 */
17 name: string;
18 /**
19 * version from package.json
20 *
21 * example: 1.2.3
22 */
23 version: string;
24 /**
25 * full package.json
26 *
27 * parsed with read-pkg
28 */
29 pjson: Config.PJSON;
30 /**
31 * used to tell the user how the plugin was installed
32 * examples: core, link, user, dev
33 */
34 type: string;
35 /**
36 * base path of plugin
37 */
38 root: string;
39 /**
40 * npm dist-tag of plugin
41 * only used for user plugins
42 */
43 tag?: string;
44 /**
45 * subplugins of this plugin
46 */
47 plugins: IPlugin[];
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 readonly commands: Config.Command.Plugin[];
53 readonly commandIDs: string[];
54 readonly topics: Config.Topic[];
55 findCommand(id: string, opts: {
56 must: true;
57 }): Config.Command.Plugin;
58 findCommand(id: string, opts?: {
59 must: boolean;
60 }): Config.Command.Plugin | undefined;
61 findTopic(id: string, opts: {
62 must: true;
63 }): Config.Topic;
64 findTopic(id: string, opts?: {
65 must: boolean;
66 }): Config.Topic | undefined;
67 runHook<T extends {}>(event: string, opts?: T): Promise<void>;
68}
69export declare class Plugin implements IPlugin {
70 _base: string;
71 name: string;
72 version: string;
73 pjson: Config.PJSON;
74 type: string;
75 root: string;
76 tag?: string;
77 manifest: Config.Manifest;
78 _topics: Config.Topic[];
79 plugins: IPlugin[];
80 hooks: {
81 [k: string]: string[];
82 };
83 valid: boolean;
84 ignoreManifest: boolean;
85 constructor(opts: Options);
86 readonly commandsDir: string | undefined;
87 readonly topics: Config.Topic[];
88 readonly commands: {
89 load: () => Config.Command.Full;
90 id: string;
91 hidden: boolean;
92 aliases: string[];
93 description?: string | undefined;
94 title?: string | undefined;
95 usage?: string | string[] | undefined;
96 examples?: string[] | undefined;
97 type?: string | undefined;
98 flags: {
99 [name: string]: Config.Command.Flag.Boolean | Config.Command.Flag.Option;
100 };
101 args: {
102 name: string;
103 description?: string | undefined;
104 required?: boolean | undefined;
105 hidden?: boolean | undefined;
106 default?: string | undefined;
107 options?: string[] | undefined;
108 }[];
109 }[];
110 readonly commandIDs: string[];
111 findCommand(id: string, opts: {
112 must: true;
113 }): Config.Command.Plugin;
114 findCommand(id: string, opts?: {
115 must: boolean;
116 }): Config.Command.Plugin | undefined;
117 _findCommand(id: string): Config.Command.Full;
118 findTopic(id: string, opts: {
119 must: true;
120 }): Config.Topic;
121 findTopic(id: string, opts?: {
122 must: boolean;
123 }): Config.Topic | undefined;
124 runHook<T extends {}>(event: string, opts?: T): Promise<void>;
125 protected _manifest(): Config.Manifest;
126 protected loadPlugins(...plugins: Config.PJSON.Plugin[]): Config.PJSON.Plugin[] | undefined;
127}