@breezr/core
v1.0.0-alpha.1
Published
aliyun build system
Downloads
7
Readme
Breezr core service
插件开发
插件本质上是一个 JS 的模块, 你需要在这个 JS 模块中导出一个方法
export default (api: PluginAPI, opts) => {
};
插件 API
API 是个 PluginAPI 实例, 具体代码参见 src/PluginAPI.ts
系统 API
api.getCwd()
获取当前的工作路径,也就是项目所在的根目录
api.hasPlugin(id: string): boolean
判断当前是不是存在了某个plugin, 主要业务插件用来判断判断他依赖的插件是否存在
id - 插件的名字, 可以忽略 (@breezr/|breezr-|@scope/breezr)-plugin-这些前缀
api.registerCommand(name: string, opts: CommandOption, fn: CommandCallback)
注册一个命令, 这个命令最终会变成 CLI 的命令作为透出
name: 注册 cli 的名字
opts: command 选项
- description: 命令的描述
- usage: 命令用法介绍
- details? : 更详细的信息(可选)
- options: 配置参数 如 { '--xxx': '描述', '-x': '描述'}
fn: 命令被调用之后的回调方法
api.registerAPI(name: string, fn: PluginAPIMethod)
注册一个插件 API, 注册之后可以被其他的插件调用如:
api.registerAPI('log', (msg) => {
console.log(msg)
})
api.log('show log');
name: string - 注册方法名字
fn: (...args: any) => void; - 方法被调用时候的回调方法.
api.on(lifecycleName: string, fn: PluginLifeCycelMethod)
注册一个生命周期
name: string - 注册生命周期的名字
fn: (...args: any) => void; - 生命周期被触发后的回调.
emit(lifecycleName: string, ...args: Array)
api.registerPlugin
在插件内部注册其他的 API
插件 API
TODO