"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var child_process_1=require("child_process"),inquirer=require("inquirer"),path_1=require("path"),utils_1=require("../../lib/utils");function default_1(e){var i=utils_1.getRuntime().workspaceRoot;if(i)throw Error("请在 NgCortex 工程目录外操作！");var r=e.params||{},s=e.options||{},t=[];s.directory||t.push({type:"input",message:"工程目录名称:",name:"directory",default:utils_1.getSeparatorCase(r.name),validate:function(e){return"string"==typeof e&&0<e.length||"请输入工程目录名称"}}),s.coreServiceName||t.push({type:"input",message:"主服务名称:",name:"coreServiceName",default:utils_1.getSeparatorCase(r.name)+"-service",validate:function(e){return"string"==typeof e&&0<e.length||"请输入主服务名称"}}),s.coreFrontendName||t.push({type:"input",message:"主前端名称:",name:"coreFrontendName",default:utils_1.getSeparatorCase(r.name)+"-frontend",validate:function(e){return"string"==typeof e&&0<e.length||"请输入主前端名称"}}),s.title||t.push({type:"input",message:"标题:",name:"title",default:utils_1.getPascalCase(r.name),validate:function(e){return"string"==typeof e&&0<e.length||"请输入标题"}}),Promise.resolve().then(function(){return 0<t.length?inquirer.prompt(t).then(function(e){Object.assign(s,e)}):Promise.resolve()}).then(function(){var e={getPascalCase:utils_1.getPascalCase,getSeparatorCase:utils_1.getSeparatorCase,name:r.name,version:"0.0.1",serviceName:s.coreServiceName,frontendName:s.coreFrontendName,title:s.title,portalPrefix:s.prefix||"app",frontendPrefix:s.prefix||"lib"},t=process.cwd();i=path_1.join(t,utils_1.getSeparatorCase(s.directory)),utils_1.src("./**/*",{base:path_1.join(__dirname,"./files")}).pipe(utils_1.ejs(e)).pipe(utils_1.dest(i,{workspaceRoot:t,log:!0})).subscribe(function(){try{child_process_1.execSync((s.packageManager||"npm")+" install",{cwd:i,stdio:"inherit",windowsHide:!0}),child_process_1.execSync("git init",{cwd:i,stdio:"ignore",windowsHide:!0}),child_process_1.execSync("git add .",{cwd:i,stdio:"ignore",windowsHide:!0}),child_process_1.execSync('git commit -m "初始化"',{cwd:i,stdio:"ignore",windowsHide:!0})}catch(e){process.exit()}})})}exports.default=default_1;
