diff --git a/lib/create.js b/lib/create.js index e5736e5..814e71c 100644 --- a/lib/create.js +++ b/lib/create.js @@ -35,12 +35,19 @@ const prompt = [ type: 'confirm', message: 'add oak-general-business into dependency?', default: true, - }, { + }, + { name: 'moreDeps', type: 'input', message: 'do you have more dependent oak-family libraries? type their names, use comma as separator.', default: '', - } + }, + { + name: 'example', + type: 'confirm', + message: 'load an initial example about personal blog? It will load correspond Entities/Pages/Components/Checkers and etc.', + default: true, + }, ]; /** * 将项目的依赖关系加入 @@ -152,7 +159,7 @@ async function create(dirName, cmd) { prompt.unshift(nameOption, titleOption); const isDev = cmd.dev ? true : false; const isModule = cmd.module ? true : false; - const { name, version, title, description, useOgb, moreDeps } = await inquirer_1.default.prompt(prompt); + const { name, version, title, description, useOgb, moreDeps, example } = await inquirer_1.default.prompt(prompt); // 获取tsconfig.json内容 const tsconfigJson = (0, template_1.tsConfigJsonContent)(); const tsConfigBuildJson = (0, template_1.tsConfigBuildJsonContent)(); @@ -244,6 +251,9 @@ async function create(dirName, cmd) { // 创建package.json (0, file_handle_1.checkFileExistsAndCreate)(packageJsonPath, packageJson, enum_1.checkFileExistsAndCreateType.FILE); (0, rename_1.renameProject)(rootPath, name, title, DEFAULT_PROJECT_NAME, DEFAULT_PROJECT_TITLE); + if (example) { + // todo: copy template example files + } (0, tip_style_1.Success)(`${(0, tip_style_1.success)(`Ok, type 'npm install' to install libs, then start!`)}`); } catch (err) { diff --git a/lib/interface.d.ts b/lib/interface.d.ts index 87b833f..93464ae 100644 --- a/lib/interface.d.ts +++ b/lib/interface.d.ts @@ -24,6 +24,7 @@ export interface PromptInput { description: string; title: string; useOgb: boolean; + example: boolean; moreDeps: string; } /** diff --git a/src/create.ts b/src/create.ts index 89d7751..3e80caf 100644 --- a/src/create.ts +++ b/src/create.ts @@ -66,12 +66,19 @@ const prompt = [ type: 'confirm', message: 'add oak-general-business into dependency?', default: true, - }, { + }, + { name: 'moreDeps', type: 'input', message: 'do you have more dependent oak-family libraries? type their names, use comma as separator.', default: '', - } + }, + { + name: 'example', + type: 'confirm', + message: 'load an initial example about personal blog? It will load correspond Entities/Pages/Components/Checkers and etc.', + default: true, + }, ]; /** @@ -236,7 +243,7 @@ export async function create(dirName: string, cmd: any) { const isDev = cmd.dev ? true : false; const isModule = cmd.module ? true : false; - const { name, version, title, description, useOgb, moreDeps }: PromptInput = await inquirer.prompt( + const { name, version, title, description, useOgb, moreDeps, example }: PromptInput = await inquirer.prompt( prompt ); @@ -380,6 +387,11 @@ export async function create(dirName: string, cmd: any) { ); renameProject(rootPath, name, title, DEFAULT_PROJECT_NAME, DEFAULT_PROJECT_TITLE); + + if (example) { + // todo: copy template example files + + } Success( `${success( `Ok, type 'npm install' to install libs, then start!` diff --git a/src/interface.ts b/src/interface.ts index 885e7e8..6e70f18 100644 --- a/src/interface.ts +++ b/src/interface.ts @@ -27,6 +27,7 @@ export interface PromptInput { description: string, title: string, useOgb: boolean; + example: boolean; moreDeps: string; }