"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var child_process_1=require("child_process"),fs_1=require("fs"),glob_1=require("glob"),path_1=require("path"),utils_1=require("../../lib/utils");function default_1(e){var r=utils_1.getRuntime(),t=r.workspaceRoot,i=r.workspaceConfig;if(!t)throw Error("请在 NgCortex 工程目录中操作！");var a=e.options||{};if(0<function(e,r){e=e.replace(/^(\^|~)/,""),r=r.replace(/^(\^|~)/,"");var t=e.split("."),i=r.split(".");if(i.length<t.length)return-1;if(i.length>t.length)return 1;for(var a=0;a<t.length;a++){if(parseInt(i[a])<parseInt(t[a]))return-1;if(parseInt(i[a])>parseInt(t[a]))return 1}return r<e?-1:e<r?1:0}(i.devDependencies["@ng-cortex/cli"],require("../../package.json").version)){var s=utils_1.getContentText(fs_1.readFileSync(t+"/environments/environment.ts")),n=s.match(/(?<=coreService\: *["'])[^"']+/g)[0],r=s.match(/(?<=titleSuffix\: *["'])[^"']+/g)[0],c=require(t+"/portal"+"/angular.json"),o=void 0;try{o=c.projects.portal.prefix||c.schematics["@schematics/angular:component"].prefix||c.schematics["@schematics/angular:directive"].prefix}catch(e){}var o=o||"app",e=glob_1.glob.sync(t+"/frontends/*/nc-application").join().replace(/\/nc-application$/,""),s=e.replace(/^.*\/(?=[^\/]+$)/,""),l=require(e+"/angular.json"),p=void 0;try{p=l.schematics["@schematics/angular:component"].prefix||l.schematics["@schematics/angular:directive"].prefix}catch(e){}p=p||"lib",r={getPascalCase:utils_1.getPascalCase,getSeparatorCase:utils_1.getSeparatorCase,name:i.name,version:i.version,serviceName:n,frontendName:s,title:r,portalPrefix:o,frontendPrefix:p};utils_1.src("./**/*",{base:path_1.join(__dirname,"../new/files")}).pipe(utils_1.ejs(r)).pipe(utils_1.dest(t,{workspaceRoot:t,log:!0})).subscribe(function(){try{child_process_1.execSync((a.packageManager||"npm")+" install",{cwd:t,stdio:"inherit",windowsHide:!0})}catch(e){process.exit()}})}else process.stdout.write("当前已是最新版本\n")}exports.default=default_1;
