"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var ansi_colors_1=require("ansi-colors"),fs_1=require("fs"),path_1=require("path"),rxjs_1=require("rxjs"),operators_1=require("rxjs/operators"),utils_1=require("../../../../lib/utils");function default_1(e){var r,t=e.params||{},i=e.options||{},e=utils_1.getEnvironment(),s=e.workspaceRoot,o=e.frontendRoot,a=e.frontendName,n=e.angularJSON;if(!s)throw Error("请在 NgCortex 工程目录中操作！");if(!o)throw new Error("请在前端项目目录中操作！");try{r=n.schematics["@schematics/angular:component"].prefix||n.schematics["@schematics/angular:directive"].prefix||"lib"}catch(e){r="lib"}var l={getPascalCase:utils_1.getPascalCase,getSeparatorCase:utils_1.getSeparatorCase,microFrontendName:a,name:t.name,prefix:i.prefix||r};process.chdir(__dirname),rxjs_1.zip(utils_1.src("./**/*",{base:"./files"}).pipe(utils_1.transform(function(e){e.path="frontends/"+a+"/"+e.path})),utils_1.src("./**/*",{base:"./mock-files"}).pipe(utils_1.transform(function(e){e.path="mock/"+a+"/"+e.path}))).pipe(operators_1.map(function(e){return[].concat.apply([],e)})).pipe(utils_1.ejs(l)).pipe(utils_1.dest(s,{workspaceRoot:s,log:!0})).subscribe(function(){var e=utils_1.getSeparatorCase(t.name),r={projectType:"library",root:e,sourceRoot:e+"/src",prefix:l.prefix,architect:{build:{builder:"@angular-devkit/build-angular:ng-packagr",options:{tsConfig:e+"/tsconfig.lib.json",project:e+"/ng-package.json"},configurations:{production:{tsConfig:e+"/tsconfig.lib.prod.json"}}},lint:{builder:"@angular-devkit/build-angular:tslint",options:{tsConfig:[e+"/tsconfig.lib.json"],exclude:["**/node_modules/**"]}}}};n.projects[e]=r;e=path_1.join(o,"angular.json"),r=JSON.stringify(n,null,"  ")+"\n";fs_1.writeFileSync(e,r),utils_1.changeFileLog(ansi_colors_1.cyan("已更新"),e,s)})}exports.default=default_1;
