UNPKG

1.34 kBJavaScriptView Raw
1"use strict";exports.__esModule=!0;var tslib_1=require("tslib"),HttpClient_1=require("@kemao/lark/Server/Http/HttpClient/HttpClient"),LarkLogger_1=require("@kemao/lark/Server/Log/LarkLogger/LarkLogger"),LarkEJSON_1=require("@kemao/lark/Server/Utils/LarkEJSON/LarkEJSON"),fs=require("fs-extra"),logger=new LarkLogger_1.LarkLogger("ProjectTools/ProjectPort"),ProjectPort=function(){function r(){}return r.prototype.run=function(){return tslib_1.__awaiter(this,void 0,void 0,function(){return tslib_1.__generator(this,function(r){switch(r.label){case 0:return[4,this.generateProjectPort()];case 1:return r.sent(),logger.log("已完成端口对齐"),[2]}})})},r.prototype.generateProjectPort=function(){return tslib_1.__awaiter(this,void 0,void 0,function(){var e,t,o,n;return tslib_1.__generator(this,function(r){switch(r.label){case 0:return e=fs.readFileSync("./package.json"),[4,HttpClient_1.HttpClient.post("https://lark.51kemao.com/project/port.ejson",e)];case 1:return t=r.sent(),o=LarkEJSON_1.LarkEJSON.decode(t.toString()),logger.log("generateProjectPort",o),n=null,fs.existsSync("./config/web.json")?((n=fs.readJSONSync("./config/web.json")).PORT=o.port,n.SSL_PORT=o.sslPort):n={PORT:o.port,SSL_PORT:o.sslPort},fs.ensureDirSync("./config"),fs.writeJSONSync("./config/web.json",n,{spaces:2}),[2]}})})},r}();exports.ProjectPort=ProjectPort;
\No newline at end of file