import { BaseAPI, BaseService, Plugin, PluginInfo } from '@mpflow/service-core';
import { AsyncSeriesHook, AsyncSeriesWaterfallHook } from 'tapable';
import { GeneratorOptions } from './Generator';
export declare class CreatorAPI
= Creator
> extends BaseAPI
{
exec(command: string, args?: string[]): Promise;
installNodeModules(modules?: string[], options?: {
saveDev?: boolean;
}): Promise;
installPlugins(pluginNames: string[]): Promise;
tapPrepare(handler: (infos: {
projectName: string;
appId: string;
templateName: string;
}) => Promise<{
projectName: string;
appId: string;
templateName: string;
}>): void;
tapResolveTemplate(handler: (templateName: string) => Promise): void;
tapRender(handler: (infos: {
projectName: string;
appId: string;
templatePath: string;
}) => Promise<{
projectName: string;
appId: string;
templatePath: string;
}>): void;
tapBeforeEmit(handler: () => Promise): void;
tapEmit(handler: () => Promise): void;
tapInit(handler: (context: string, infos: {
projectName: string;
appId: string;
templatePath: string;
}) => Promise): void;
tapAfterInit(handler: (context: string, infos: {
projectName: string;
appId: string;
templatePath: string;
}) => Promise): void;
}
export interface CreatorPlugin extends Plugin {
creator?: (api: CreatorAPI) => void;
}
export interface CreatorOptions extends GeneratorOptions {
templateName?: string;
projectName?: string;
appId?: string;
}
export declare class Creator extends BaseService
{
/**
* 模板目录
*/
templateName?: string;
/**
* 项目名称
*/
projectName?: string;
/**
* 项目 APP id
*/
appId?: string;
/**
*
*/
hooks: {
/**
* 准备阶段, 收集必要的创建信息
*/
prepare: AsyncSeriesWaterfallHook<{
projectName: string;
appId: string;
templateName: string;
}, never, never>;
/**
* 解析输入的 template 模板
*/
resolveTemplate: AsyncSeriesWaterfallHook;
/**
* 将模板渲染到内存中的虚拟文件系统
*/
render: AsyncSeriesHook<{
projectName: string;
appId: string;
templatePath: string;
}, Record, never>;
/**
* 将渲染模板输出前回调
*/
beforeEmit: AsyncSeriesHook, any, any>;
/**
* 将渲染模板真正输出到目录
*/
emit: AsyncSeriesHook, any>;
/**
* 初始化项目
*/
init: AsyncSeriesHook;
/**
* 初始化结束后
*/
afterInit: AsyncSeriesHook;
};
constructor(context: string, { templateName, projectName, appId, ...options }: CreatorOptions);
/**
* 根据传入的 templateName, 下载包或者使用本地包, 返回下载解压后的所在目录
* @param templateName
*/
getTemplatePath(templateName: string): Promise;
create(): Promise;
/**
* 安装插件到项目
* @param pluginNames
*/
installPlugin(pluginNames: string[]): Promise;
/**
* 获取所有插件
* @param inlinePlugins
* @param config
*/
resolvePluginInfos(inlinePlugins?: PluginInfo[]): PluginInfo
[];
/**
* 执行所有的插件 generator
*/
initPlugins(): Promise;
}