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