"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var fs_1=require("fs"),inquirer=require("inquirer"),path_1=require("path"),utils_1=require("../../../../lib/utils");function default_1(e){var t=utils_1.getRuntime();if(!t.workspaceRoot)throw Error("请在 NgCortex 工程目录中操作！");var o=e.params||{};Promise.resolve().then(function(){if(t.portalRoot||t.frontendRoot)return Promise.resolve();var r=[{type:"list",message:"请选择项目:",name:"cwd",choices:[]}];if(r[0].choices.push({name:"portal",value:t.workspaceRoot+"/portal"}),fs_1.readdirSync(t.workspaceRoot+"/frontends").forEach(function(e){r[0].choices.push({name:e,value:t.workspaceRoot+"/frontends/"+e})}),0===r[0].choices.length)throw new Error("暂无项目可操作");return inquirer.prompt(r).then(function(e){t=utils_1.getRuntime(e.cwd)})}).then(function(){if(!t.frontendRoot||t.libraryRoot)return Promise.resolve();var r=[{type:"list",message:"请选择库项目:",name:"cwd",choices:[]}];if(Object.keys(t.frontendConfig.projects).forEach(function(e){r[0].choices.push({name:e,value:t.frontendRoot+"/"+e})}),0===r[0].choices.length)throw new Error("暂无库项目可操作");return inquirer.prompt(r).then(function(e){t=utils_1.getRuntime(e.cwd)})}).then(function(){var e;e=t.portalRoot?(e=process.cwd().split(/[\/\\]+/).join("/"),r=t.portalRoot+"/src",e.slice(0,r.length)===r?e:r):t.libraryRoot+"/src";var r={name:utils_1.getPascalCase(o.name),alias:utils_1.getPascalCase(o.name),fileName:utils_1.getSeparatorCase(o.name)};utils_1.src("./**/*",{base:path_1.join(__dirname,"./files")}).pipe(utils_1.ejs(r)).pipe(utils_1.dest(e,{workspaceRoot:t.workspaceRoot,log:!0})).subscribe()})}exports.default=default_1;
