UNPKG

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