import { Command } from './command'; import { Hooks } from './hooks'; import { Manifest } from './manifest'; import { PJSON } from './pjson'; import { Topic } from './topic'; export interface Options { root: string; name?: string; type?: string; tag?: string; ignoreManifest?: boolean; } export interface IPlugin { /** * @anycli/config version */ _base: string; /** * name from package.json */ name: string; /** * version from package.json * * example: 1.2.3 */ version: string; /** * full package.json * * parsed with read-pkg */ pjson: PJSON.Plugin | PJSON.CLI; /** * used to tell the user how the plugin was installed * examples: core, link, user, dev */ type: string; /** * base path of plugin */ root: string; /** * npm dist-tag of plugin * only used for user plugins */ tag?: string; /** * subplugins of this plugin */ plugins: IPlugin[]; /** * if it appears to be an npm package but does not look like it's really a CLI plugin, this is set to false */ valid: boolean; readonly commands: Command.Plugin[]; readonly commandIDs: string[]; readonly topics: Topic[]; findCommand(id: string, opts: { must: true; }): Command.Plugin; findCommand(id: string, opts?: { must: boolean; }): Command.Plugin | undefined; findTopic(id: string, opts: { must: true; }): Topic; findTopic(id: string, opts?: { must: boolean; }): Topic | undefined; runHook(event: K, opts: T[K]): Promise; } export declare class Plugin implements IPlugin { static loadedPlugins: { [name: string]: Plugin; }; _base: string; name: string; version: string; pjson: PJSON.Plugin; type: string; root: string; tag?: string; manifest: Manifest; _topics: Topic[]; plugins: IPlugin[]; hooks: { [k: string]: string[]; }; valid: boolean; ignoreManifest: boolean; alreadyLoaded: boolean; constructor(opts: Options); readonly commandsDir: string | undefined; readonly topics: Topic[]; readonly commands: { load: () => Command.Class; id: string; hidden: boolean; aliases: string[]; description?: string | undefined; title?: string | undefined; usage?: string | string[] | undefined; examples?: string[] | undefined; type?: string | undefined; flags: { [name: string]: Command.Flag; }; args: { name: string; description?: string | undefined; required?: boolean | undefined; hidden?: boolean | undefined; default?: string | undefined; options?: string[] | undefined; }[]; }[]; readonly commandIDs: string[]; findCommand(id: string, opts: { must: true; }): Command.Plugin; findCommand(id: string, opts?: { must: boolean; }): Command.Plugin | undefined; _findCommand(id: string): Command.Class; findTopic(id: string, opts: { must: true; }): Topic; findTopic(id: string, opts?: { must: boolean; }): Topic | undefined; runHook(event: K, opts: T[K]): Promise; protected _manifest(): Manifest; protected loadPlugins(root: string, plugins: (string | PJSON.Plugin)[]): (string | PJSON.Plugin)[] | undefined; }