@alipay-inc/mpaas-ide-openapi-common
Advanced tools
Comparing version 1.0.11-alpha.2 to 1.0.11-alpha.3
@@ -1,1 +0,1 @@ | ||
"use strict";var _exportNames={uuid:!0,delay:!0,getConfigType:!0,getUserInfo:!0,setUserInfo:!0,login:!0,defaultTinyappConfig:!0,getDefaultTinyappConfig:!0,getTmpDirRoot:!0,getTmpDir:!0,cleanCache:!0,getVersion:!0,getUUID:!0,getZipFile:!0,getZipFromTar:!0,logger:!0,getPackageType:!0,looseJsonParse:!0,downloadFile:!0,appInfoToVariables:!0,variablesToappInfo:!0,parseDebugURL:!0,getUploadResult:!0,transformPluginParams:!0};var _getUploadData=require("./getUploadData");var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault"),_typeof3=require("@babel/runtime/helpers/typeof");Object.defineProperty(exports,"__esModule",{value:!0});exports.variablesToappInfo=exports.uuid=exports.transformPluginParams=exports.setUserInfo=exports.parseDebugURL=exports.looseJsonParse=exports.login=exports.logger=exports.getZipFromTar=exports.getZipFile=exports.getVersion=exports.getUserInfo=exports.getUploadResult=exports.getUUID=exports.getTmpDirRoot=exports.getTmpDir=exports.getPackageType=exports.getDefaultTinyappConfig=exports.getConfigType=exports.downloadFile=exports.delay=exports.defaultTinyappConfig=exports.cleanCache=exports.appInfoToVariables=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator")),_typeof2=_interopRequireDefault(require("@babel/runtime/helpers/typeof")),_toConsumableArray2=_interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")),_slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")),_defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty")),_objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")),_asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")),_superagent=_interopRequireDefault(require("superagent")),_tar=_interopRequireDefault(require("tar")),_archiver=_interopRequireDefault(require("archiver")),_os=require("os"),_path=_interopRequireDefault(require("path")),_isElectron=_interopRequireDefault(require("is-electron")),_progress=_interopRequireDefault(require("progress")),_queryString=_interopRequireDefault(require("query-string")),_fsExtra=_interopRequireWildcard(require("fs-extra")),_cloudBuild=require("./cloudBuild");Object.keys(_cloudBuild).forEach(function(a){"default"===a||"__esModule"===a||Object.prototype.hasOwnProperty.call(_exportNames,a)||a in exports&&exports[a]===_cloudBuild[a]||Object.defineProperty(exports,a,{enumerable:!0,get:function get(){return _cloudBuild[a]}})});Object.keys(_getUploadData).forEach(function(a){"default"===a||"__esModule"===a||Object.prototype.hasOwnProperty.call(_exportNames,a)||a in exports&&exports[a]===_getUploadData[a]||Object.defineProperty(exports,a,{enumerable:!0,get:function get(){return _getUploadData[a]}})});var _log4js=_interopRequireDefault(require("log4js")),_excluded=["config"],_excluded2=["data"];function _getRequireWildcardCache(a){if("function"!=typeof WeakMap)return null;var b=new WeakMap,c=new WeakMap;return(_getRequireWildcardCache=function(a){return a?c:b})(a)}function _interopRequireWildcard(a,b){if(!b&&a&&a.__esModule)return a;if(null===a||"object"!==_typeof3(a)&&"function"!=typeof a)return{default:a};var c=_getRequireWildcardCache(b);if(c&&c.has(a))return c.get(a);var d={},e=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var f in a)if("default"!=f&&Object.prototype.hasOwnProperty.call(a,f)){var g=e?Object.getOwnPropertyDescriptor(a,f):null;g&&(g.get||g.set)?Object.defineProperty(d,f,g):d[f]=a[f]}return d["default"]=a,c&&c.set(a,d),d}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){(0,_defineProperty2["default"])(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}var uuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=0|16*Math.random(),c="x"==a?b:8|3&b;return c.toString(16)})};exports.uuid=uuid;var tmpdirRoot="".concat((0,_os.tmpdir)(),"/.mpaas_ide_openapi"),delay=function(a){return new Promise(function(b){return setTimeout(b,a)})};exports.delay=delay;var getConfigType=function(a){var b="",c=a.openapi;if(!c)b="classic";else{var d=c.type;"aliyun"===d?b="aliyun":"antfin"===d&&(b="antfin")}return{data:b,success:!0}};exports.getConfigType=getConfigType;var userInfo={},getUserInfo=function(){return userInfo};exports.getUserInfo=getUserInfo;var setUserInfo=function(a){var b=a.id;a.userId=b,userInfo=a};exports.setUserInfo=setUserInfo;var login=function(){var a=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function b(a){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;return _regenerator["default"].wrap(function(b){for(;;)switch(b.prev=b.next){case 0:c=a.config,d=(0,_objectWithoutProperties2["default"])(a,_excluded),b.prev=1,e=getConfigType(c),f=e.data,g={},b.t0=f,b.next="classic"===b.t0?7:23;break;case 7:return h=c.login_url,i=d.username,j=d.password,k=c.sign,l={loginName:i.toLowerCase(),password:j,sign:k,config:JSON.stringify(c)},b.next=13,_superagent["default"].post(h).field(l).accept("json");case 13:if(m=b.sent,n=m.body,o=void 0===n?{}:n,g=o.data,p=g,q=p.success,r=p.data,s=p.message,q){b.next=20;break}throw new Error(s);case 20:return r.userId=r.userId||r.id,setUserInfo(r),b.abrupt("break",29);case 23:return t=c.openapi,t=void 0===t?{}:t,u=t.userId,g={data:{id:u,loginName:u,nickName:u,realName:u,userId:u},success:!0},setUserInfo(g.data),b.abrupt("break",29);case 29:return b.abrupt("return",g);case 32:throw b.prev=32,b.t1=b["catch"](1),new Error(b.t1.message);case 35:case"end":return b.stop();}},b,null,[[1,32]])}));return function(){return a.apply(this,arguments)}}();exports.login=login;var defaultTinyappConfig={appCode:"",autoInstall:1,clientVersionMax:"",clientVersionMin:"0.0.0.0;0.0.0.0",downloadUrl:"",debugUrl:"",extendInfo:"",extraData:"{\"enableKeepAlive\":\"0\",\"enableOptionMenu\":\"1\",\"enableTabBar\":\"0\",\"iconUrl\":\"\",\"resourceType\":\"4\"}",fallbackBaseUrl:"",fileSize:"",gmtCreate:"",gmtModified:"",h5Version:"1.0.0.0",installType:1,lazyLoad:0,mainUrl:"/index.html#pages/index/index",md5:"",memo:"",modifier:"success",platform:"all",publishPeriod:5,releaseVersion:"",resourceType:"4",status:1};exports.defaultTinyappConfig=defaultTinyappConfig;var getDefaultTinyappConfig=function(a){return{data:_objectSpread(_objectSpread({},defaultTinyappConfig),a),success:!0}};exports.getDefaultTinyappConfig=getDefaultTinyappConfig;var getTmpDirRoot=function(){var a=(0,_fsExtra.existsSync)(tmpdirRoot);return a||(0,_fsExtra.mkdirSync)(tmpdirRoot),tmpdirRoot};exports.getTmpDirRoot=getTmpDirRoot;var getTmpDir=function(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"appid",b=getTmpDirRoot(),c="".concat(b,"/").concat(a,"_").concat(new Date().valueOf(),"_").concat(uuid()),d=(0,_fsExtra.existsSync)(c);return d||(0,_fsExtra.mkdirSync)(c),c};exports.getTmpDir=getTmpDir;var cleanCache=function(){try{var a=getTmpDirRoot();return(0,_fsExtra.emptydirSync)(a),{data:"OK",success:!0}}catch(a){throw new Error(a.message)}};exports.cleanCache=cleanCache;var getVersion=function(a){try{var b=a.split("."),c=(0,_slicedToArray2["default"])(b,4),d=c[0],e=c[1],f=c[2],g=c[3],h=void 0===g?0:g,i=[d,e,f,h].join("."),j=[d,e,1*f+1,0].join("."),k=[d,e,f,1*h+1].join(".");return{data:{current:i,nextProd:j,nextDev:k},success:!0}}catch(a){throw new Error(a)}};exports.getVersion=getVersion;var getUUID=function(){var a=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function b(a){var c,d,e;return _regenerator["default"].wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return c=a.uuid_url,b.prev=1,b.next=4,_superagent["default"].get(c);case 4:return b.next=6,b.sent;case 6:return d=b.sent,e=d.text,b.abrupt("return",{data:e,success:!0});case 11:throw b.prev=11,b.t0=b["catch"](1),new Error(b.t0);case 14:case"end":return b.stop();}},b,null,[[1,11]])}));return function(){return a.apply(this,arguments)}}();exports.getUUID=getUUID;var getZipFile=function(){var a=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function b(a){var c,d,e,f;return _regenerator["default"].wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return c=a.pathname,d=a.version,e=a.h5Id,f=a.files,b.abrupt("return",new Promise(function(a,b){var g=getTmpDir();(0,_fsExtra.ensureDirSync)(g);try{var h="".concat(g,"/").concat(e,".zip");d&&(h="".concat(g,"/").concat(e,"_").concat(d.replace(/\./ig,"_"),".zip"));var i=(0,_fsExtra.createWriteStream)(h),j=(0,_archiver["default"])("zip",{zlib:{level:9}});j.pipe(i),i.on("close",function(){a(h)}),j.on("error",function(a){b(a)}),c?j.directory("".concat(c),e):f.forEach(function(a){j.append(_fsExtra["default"].createReadStream(a),{name:_path["default"].basename(a)})}),j.finalize()}catch(a){(0,_fsExtra.removeSync)(g),b(a)}}));case 2:case"end":return b.stop();}},b)}));return function(){return a.apply(this,arguments)}}();exports.getZipFile=getZipFile;var getZipFromTar=function(){var a=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function a(){var b,c,d,e,f,g,h=arguments;return _regenerator["default"].wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return b=0<h.length&&void 0!==h[0]?h[0]:{},c=b.tarFilePath,d=b.h5Id,e=getTmpDir(),f=_path["default"].join(e,d),(0,_fsExtra.ensureDirSync)(f),a.prev=4,a.next=7,_tar["default"].x({file:_path["default"].resolve(c),cwd:f});case 7:return a.next=9,getZipFile({pathname:f,h5Id:d});case 9:return g=a.sent,a.abrupt("return",{data:g,success:!0});case 13:throw a.prev=13,a.t0=a["catch"](4),new Error(a.t0.message);case 16:return a.prev=16,(0,_fsExtra.removeSync)(e),a.finish(16);case 19:case"end":return a.stop();}},a,null,[[4,13,16,19]])}));return function(){return a.apply(this,arguments)}}();exports.getZipFromTar=getZipFromTar;var printLog=function(){for(var a,b=arguments.length,c=Array(b),d=0;d<b;d++)c[d]=arguments[d];var e=c,f=["%c[mpaas_ide_openapi]","color: blue;"];if(Array.isArray(c))try{f[0]="".concat(f[0]," %c").concat(c[0]),f.push("color: red;"),e=c.slice(1)}catch(a){console.log(a)}(a=console).log.apply(a,f.concat((0,_toConsumableArray2["default"])(e)))},showLog=function(a,b,c){if(c){var d=(0,_isElectron["default"])(),e=null!==c&&void 0!==c&&c.root?_path["default"].resolve(c.root):_path["default"].resolve((0,_os.homedir)(),".mpaas_log");(0,_fsExtra.ensureDirSync)(e);var f=d?"mpaas_ide":"mpaas_ide_openapi",g=_path["default"].resolve(e,f);_log4js["default"].configure({appenders:{"[mpaas_ide_openapi]":{type:"dateFile",filename:g,pattern:"yyyy-MM-dd.log",alwaysIncludePattern:!0,category:"normal"}},categories:{default:{appenders:["[mpaas_ide_openapi]"],level:"trace"}}}),_log4js["default"].getLogger("[mpaas_ide_openapi]")[a](JSON.stringify(b)),printLog.apply(void 0,(0,_toConsumableArray2["default"])(b))}},logger={trace:function trace(){for(var a,b,c=arguments.length,d=Array(c),e=0;e<c;e++)d[e]=arguments[e];return showLog("trace",d,null===(a=global)||void 0===a||null===(b=a.mpaasOpenApi)||void 0===b?void 0:b.log)},info:function info(){for(var a,b,c=arguments.length,d=Array(c),e=0;e<c;e++)d[e]=arguments[e];return showLog("info",d,null===(a=global)||void 0===a||null===(b=a.mpaasOpenApi)||void 0===b?void 0:b.log)},warn:function warn(){for(var a,b,c=arguments.length,d=Array(c),e=0;e<c;e++)d[e]=arguments[e];return showLog("warn",d,null===(a=global)||void 0===a||null===(b=a.mpaasOpenApi)||void 0===b?void 0:b.log)},error:function error(){for(var a,b,c=arguments.length,d=Array(c),e=0;e<c;e++)d[e]=arguments[e];return showLog("error",d,null===(a=global)||void 0===a||null===(b=a.mpaasOpenApi)||void 0===b?void 0:b.log)},debug:function debug(){for(var a,b,c=arguments.length,d=Array(c),e=0;e<c;e++)d[e]=arguments[e];return showLog("debug",d,null===(a=global)||void 0===a||null===(b=a.mpaasOpenApi)||void 0===b?void 0:b.log)}};exports.logger=logger;var getPackageType=function(a){return{data:["1","2",1,2].includes(a)?"production":"development",success:!0}};exports.getPackageType=getPackageType;var looseJsonParse=function(a){try{return{data:Function("\"use strict\";return (".concat(a,")"))(),success:!0}}catch(b){return{data:JSON.parse(a.replace(/"/ig,"\"")),success:!0}}};exports.looseJsonParse=looseJsonParse;var downloadFile=function(){var a=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function b(a){var c,d,e,f,g,h;return _regenerator["default"].wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(c=a.url,d=a.target,b.prev=1,b.t0=d,b.t0){b.next=7;break}return b.next=6,getTmpDir();case 6:b.t0=b.sent;case 7:return e=b.t0,f="".concat(uuid()).concat(_path["default"].extname(new URL(c).pathname)),g=_path["default"].join(e,f),b.next=12,_superagent["default"].get(c);case 12:return h=b.sent,b.next=15,(0,_fsExtra.writeFileSync)(g,h.body,"binary");case 15:return b.abrupt("return",{data:g,success:!0});case 18:throw b.prev=18,b.t1=b["catch"](1),new Error(b.t1.message);case 21:case"end":return b.stop();}},b,null,[[1,18]])}));return function(){return a.apply(this,arguments)}}();exports.downloadFile=downloadFile;var appInfoToVariables=function(a){var b=a.h5Id,c=a.platform,d=a.clientVersionMin,e=a.clientVersionMax,f=a.mainUrl,g=void 0===f?"/index.html#pages/index/index":f,h=a.extraData,i=a.extendInfo,j=a.autoInstall,k=void 0===j?"0":j,l=a.installType,m=void 0===l?"0":l,n=a.iconFile,o=h&&looseJsonParse(h.replace(/"|&quot;/gi,"\"")),p=o.data;p=void 0===p?{}:p;var q,r,s,t,u,v,w=p.iconUrl,x=void 0===w?"":w,y=p.enableTabBar,z=void 0===y?"1":y,A=p.enableOptionMenu,B=void 0===A?"1":A,C=d&&d.split(";"),D=e&&e.split(";");switch(c){case"all":q=!0,r=!0,s=C&&C[0],t=D&&D[0],u=C&&C[1],v=D&&D[1];break;case"iOS":q=!0,r=!1,s=C&&C[0],t=D&&D[0];break;case"android":q=!1,r=!0,u=C&&C[1],v=D&&D[1];break;default:q=!1,r=!1;}return{h5Id:b,mainUrl:g,autoInstall:k,installType:m,iconFile:n,extendInfo:i.replace(/"|&quot;/gi,"\""),iconUrl:x,enableTabBar:z,enableOptionMenu:B,enableKeepAlive:"0",platformIOS:q,platformAndroid:r,iosMinVersion:s,iosMaxVersion:t,androidMinVersion:u,androidMaxVersion:v}};exports.appInfoToVariables=appInfoToVariables;var variablesToappInfo=function(a){var b,c,d,e=a.h5Id,f=a.h5Name,g=a.mainUrl,h=a.subUrl,i=void 0===h?"":h,j=a.iconFile,k=void 0===j?"":j,l=a.resourceType,m=a.platformIOS,n=a.platformAndroid,o=a.iosMinVersion,p=void 0===o?"":o,q=a.iosMaxVersion,r=void 0===q?"":q,s=a.androidMinVersion,t=void 0===s?"":s,u=a.androidMaxVersion,v=void 0===u?"":u,w=a.autoInstall,x=a.installType,y=a.enableKeepAlive,z=a.enableOptionMenu,A=a.enableTabBar,B=a.extendInfo,C=a.iconUrl,D=a.vhost;return m&&n?(b="all",c="".concat(p).concat(t?";".concat(t):""),d="".concat(r).concat(v?";".concat(v):"")):m?(b="iOS",c="".concat(p),d="".concat(r)):n&&(b="android",c="".concat(t?";".concat(t):""),d="".concat(v?";".concat(v):"")),{h5Id:e,h5Name:f,mainUrl:g,iconFile:k,subUrl:i,vhost:D,enableKeepAlive:y,enableOptionMenu:z,enableTabBar:A,iconUrl:C,resourceType:l,autoInstall:w,installType:x,extendInfo:B,platform:b,clientVersionMin:c,clientVersionMax:d}};exports.variablesToappInfo=variablesToappInfo;var parseDebugURL=function(a){var b;try{b=a.data.replace(/&/ig,"&"),b=looseJsonParse(b)}catch(c){b=a}return b};exports.parseDebugURL=parseDebugURL;var getUploadResult=function(a){var b=a.res,c=a.h5Version,d=a.req;try{var e=parseDebugURL(b),f=e.data,g=(0,_objectWithoutProperties2["default"])(e,_excluded2);"object"!==(0,_typeof2["default"])(f)&&(f={projectId:f}),f=_objectSpread(_objectSpread({},f),{},{h5Version:c,gmtCreate:new Date().valueOf()});var h=d.packageType,i=d.buildTarget;if(0==h-3&&"RemoteBoatman"===i){var j=f,k=j.debugUrl;k=decodeURIComponent(k);var l=k.match(/mpaas.*?scheme=mpaas:\/\/platformapi\/startapp\?/gi)[0],m=k.replace(l,"");m=_queryString["default"].parse(m),delete m.enablePolyfillWorker,delete m.isRemoteDebug,m.tyroId=m.channelId,m.isRemoteX=!0,m=_queryString["default"].stringify(m),m=encodeURIComponent(m),k=l+m,f.debugUrl=k}return _objectSpread(_objectSpread({},g),{},{data:f,originData:e})}catch(a){throw new Error(a.message)}};exports.getUploadResult=getUploadResult;var transformPluginParams=function(a){var b=a.h5Id,c=a.h5Name,d=a.h5Version,e=a.miniPluginName,f=a.miniPluginId,g=a.miniPluginVersion,h=_objectSpread({},a);return b&&(h.miniPluginId=b),c&&(h.miniPluginName=c),d&&(h.miniPluginVersion=d),f&&(h.h5Id=f),e&&(h.h5Name=e),g&&(h.h5Version=g),h};exports.transformPluginParams=transformPluginParams; | ||
"use strict";var _exportNames={uuid:!0,delay:!0,getConfigType:!0,getUserInfo:!0,setUserInfo:!0,login:!0,defaultTinyappConfig:!0,getDefaultTinyappConfig:!0,getDefaultPluginConfig:!0,getTmpDirRoot:!0,getTmpDir:!0,cleanCache:!0,getVersion:!0,getUUID:!0,getZipFile:!0,getZipFromTar:!0,logger:!0,getPackageType:!0,looseJsonParse:!0,downloadFile:!0,appInfoToVariables:!0,variablesToappInfo:!0,parseDebugURL:!0,getUploadResult:!0,transformPluginParams:!0};var _getUploadData=require("./getUploadData");var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault"),_typeof3=require("@babel/runtime/helpers/typeof");Object.defineProperty(exports,"__esModule",{value:!0});exports.variablesToappInfo=exports.uuid=exports.transformPluginParams=exports.setUserInfo=exports.parseDebugURL=exports.looseJsonParse=exports.login=exports.logger=exports.getZipFromTar=exports.getZipFile=exports.getVersion=exports.getUserInfo=exports.getUploadResult=exports.getUUID=exports.getTmpDirRoot=exports.getTmpDir=exports.getPackageType=exports.getDefaultTinyappConfig=exports.getDefaultPluginConfig=exports.getConfigType=exports.downloadFile=exports.delay=exports.defaultTinyappConfig=exports.cleanCache=exports.appInfoToVariables=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator")),_typeof2=_interopRequireDefault(require("@babel/runtime/helpers/typeof")),_toConsumableArray2=_interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")),_slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")),_defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty")),_objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")),_asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")),_superagent=_interopRequireDefault(require("superagent")),_tar=_interopRequireDefault(require("tar")),_archiver=_interopRequireDefault(require("archiver")),_os=require("os"),_path=_interopRequireDefault(require("path")),_isElectron=_interopRequireDefault(require("is-electron")),_progress=_interopRequireDefault(require("progress")),_queryString=_interopRequireDefault(require("query-string")),_fsExtra=_interopRequireWildcard(require("fs-extra")),_cloudBuild=require("./cloudBuild");Object.keys(_cloudBuild).forEach(function(a){"default"===a||"__esModule"===a||Object.prototype.hasOwnProperty.call(_exportNames,a)||a in exports&&exports[a]===_cloudBuild[a]||Object.defineProperty(exports,a,{enumerable:!0,get:function get(){return _cloudBuild[a]}})});Object.keys(_getUploadData).forEach(function(a){"default"===a||"__esModule"===a||Object.prototype.hasOwnProperty.call(_exportNames,a)||a in exports&&exports[a]===_getUploadData[a]||Object.defineProperty(exports,a,{enumerable:!0,get:function get(){return _getUploadData[a]}})});var _log4js=_interopRequireDefault(require("log4js")),_excluded=["config"],_excluded2=["data"];function _getRequireWildcardCache(a){if("function"!=typeof WeakMap)return null;var b=new WeakMap,c=new WeakMap;return(_getRequireWildcardCache=function(a){return a?c:b})(a)}function _interopRequireWildcard(a,b){if(!b&&a&&a.__esModule)return a;if(null===a||"object"!==_typeof3(a)&&"function"!=typeof a)return{default:a};var c=_getRequireWildcardCache(b);if(c&&c.has(a))return c.get(a);var d={},e=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var f in a)if("default"!=f&&Object.prototype.hasOwnProperty.call(a,f)){var g=e?Object.getOwnPropertyDescriptor(a,f):null;g&&(g.get||g.set)?Object.defineProperty(d,f,g):d[f]=a[f]}return d["default"]=a,c&&c.set(a,d),d}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){(0,_defineProperty2["default"])(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}var uuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=0|16*Math.random(),c="x"==a?b:8|3&b;return c.toString(16)})};exports.uuid=uuid;var tmpdirRoot="".concat((0,_os.tmpdir)(),"/.mpaas_ide_openapi"),delay=function(a){return new Promise(function(b){return setTimeout(b,a)})};exports.delay=delay;var getConfigType=function(a){var b="",c=a.openapi;if(!c)b="classic";else{var d=c.type;"aliyun"===d?b="aliyun":"antfin"===d&&(b="antfin")}return{data:b,success:!0}};exports.getConfigType=getConfigType;var userInfo={},getUserInfo=function(){return userInfo};exports.getUserInfo=getUserInfo;var setUserInfo=function(a){var b=a.id;a.userId=b,userInfo=a};exports.setUserInfo=setUserInfo;var login=function(){var a=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function b(a){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;return _regenerator["default"].wrap(function(b){for(;;)switch(b.prev=b.next){case 0:c=a.config,d=(0,_objectWithoutProperties2["default"])(a,_excluded),b.prev=1,e=getConfigType(c),f=e.data,g={},b.t0=f,b.next="classic"===b.t0?7:23;break;case 7:return h=c.login_url,i=d.username,j=d.password,k=c.sign,l={loginName:i.toLowerCase(),password:j,sign:k,config:JSON.stringify(c)},b.next=13,_superagent["default"].post(h).field(l).accept("json");case 13:if(m=b.sent,n=m.body,o=void 0===n?{}:n,g=o.data,p=g,q=p.success,r=p.data,s=p.message,q){b.next=20;break}throw new Error(s);case 20:return r.userId=r.userId||r.id,setUserInfo(r),b.abrupt("break",29);case 23:return t=c.openapi,t=void 0===t?{}:t,u=t.userId,g={data:{id:u,loginName:u,nickName:u,realName:u,userId:u},success:!0},setUserInfo(g.data),b.abrupt("break",29);case 29:return b.abrupt("return",g);case 32:throw b.prev=32,b.t1=b["catch"](1),new Error(b.t1.message);case 35:case"end":return b.stop();}},b,null,[[1,32]])}));return function(){return a.apply(this,arguments)}}();exports.login=login;var defaultTinyappConfig={appCode:"",autoInstall:1,clientVersionMax:"",clientVersionMin:"0.0.0.0;0.0.0.0",downloadUrl:"",debugUrl:"",extendInfo:"",extraData:"{\"enableKeepAlive\":\"0\",\"enableOptionMenu\":\"1\",\"enableTabBar\":\"0\",\"iconUrl\":\"\",\"resourceType\":\"4\"}",fallbackBaseUrl:"",fileSize:"",gmtCreate:"",gmtModified:"",h5Version:"1.0.0.0",installType:1,lazyLoad:0,mainUrl:"/index.html#pages/index/index",md5:"",memo:"",modifier:"success",platform:"all",publishPeriod:5,releaseVersion:"",resourceType:"4",status:1};exports.defaultTinyappConfig=defaultTinyappConfig;var getDefaultTinyappConfig=function(a){return{data:_objectSpread(_objectSpread({},defaultTinyappConfig),a),success:!0}};exports.getDefaultTinyappConfig=getDefaultTinyappConfig;var getDefaultPluginConfig=function(a){var b=a.data,c=a.req;return{data:_objectSpread(_objectSpread({h5Version:"1.0.0.0"},c),b),success:!0}};exports.getDefaultPluginConfig=getDefaultPluginConfig;var getTmpDirRoot=function(){var a=(0,_fsExtra.existsSync)(tmpdirRoot);return a||(0,_fsExtra.mkdirSync)(tmpdirRoot),tmpdirRoot};exports.getTmpDirRoot=getTmpDirRoot;var getTmpDir=function(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"appid",b=getTmpDirRoot(),c="".concat(b,"/").concat(a,"_").concat(new Date().valueOf(),"_").concat(uuid()),d=(0,_fsExtra.existsSync)(c);return d||(0,_fsExtra.mkdirSync)(c),c};exports.getTmpDir=getTmpDir;var cleanCache=function(){try{var a=getTmpDirRoot();return(0,_fsExtra.emptydirSync)(a),{data:"OK",success:!0}}catch(a){throw new Error(a.message)}};exports.cleanCache=cleanCache;var getVersion=function(a){try{var b=a.split("."),c=(0,_slicedToArray2["default"])(b,4),d=c[0],e=c[1],f=c[2],g=c[3],h=void 0===g?0:g,i=[d,e,f,h].join("."),j=[d,e,1*f+1,0].join("."),k=[d,e,f,1*h+1].join(".");return{data:{current:i,nextProd:j,nextDev:k},success:!0}}catch(a){throw new Error(a)}};exports.getVersion=getVersion;var getUUID=function(){var a=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function b(a){var c,d,e;return _regenerator["default"].wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return c=a.uuid_url,b.prev=1,b.next=4,_superagent["default"].get(c);case 4:return b.next=6,b.sent;case 6:return d=b.sent,e=d.text,b.abrupt("return",{data:e,success:!0});case 11:throw b.prev=11,b.t0=b["catch"](1),new Error(b.t0);case 14:case"end":return b.stop();}},b,null,[[1,11]])}));return function(){return a.apply(this,arguments)}}();exports.getUUID=getUUID;var getZipFile=function(){var a=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function b(a){var c,d,e,f;return _regenerator["default"].wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return c=a.pathname,d=a.version,e=a.h5Id,f=a.files,b.abrupt("return",new Promise(function(a,b){var g=getTmpDir();(0,_fsExtra.ensureDirSync)(g);try{var h="".concat(g,"/").concat(e,".zip");d&&(h="".concat(g,"/").concat(e,"_").concat(d.replace(/\./ig,"_"),".zip"));var i=(0,_fsExtra.createWriteStream)(h),j=(0,_archiver["default"])("zip",{zlib:{level:9}});j.pipe(i),i.on("close",function(){a(h)}),j.on("error",function(a){b(a)}),c?j.directory("".concat(c),e):f.forEach(function(a){j.append(_fsExtra["default"].createReadStream(a),{name:_path["default"].basename(a)})}),j.finalize()}catch(a){(0,_fsExtra.removeSync)(g),b(a)}}));case 2:case"end":return b.stop();}},b)}));return function(){return a.apply(this,arguments)}}();exports.getZipFile=getZipFile;var getZipFromTar=function(){var a=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function a(){var b,c,d,e,f,g,h=arguments;return _regenerator["default"].wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return b=0<h.length&&void 0!==h[0]?h[0]:{},c=b.tarFilePath,d=b.h5Id,e=getTmpDir(),f=_path["default"].join(e,d),(0,_fsExtra.ensureDirSync)(f),a.prev=4,a.next=7,_tar["default"].x({file:_path["default"].resolve(c),cwd:f});case 7:return a.next=9,getZipFile({pathname:f,h5Id:d});case 9:return g=a.sent,a.abrupt("return",{data:g,success:!0});case 13:throw a.prev=13,a.t0=a["catch"](4),new Error(a.t0.message);case 16:return a.prev=16,(0,_fsExtra.removeSync)(e),a.finish(16);case 19:case"end":return a.stop();}},a,null,[[4,13,16,19]])}));return function(){return a.apply(this,arguments)}}();exports.getZipFromTar=getZipFromTar;var printLog=function(){for(var a,b=arguments.length,c=Array(b),d=0;d<b;d++)c[d]=arguments[d];var e=c,f=["%c[mpaas_ide_openapi]","color: blue;"];if(Array.isArray(c))try{f[0]="".concat(f[0]," %c").concat(c[0]),f.push("color: red;"),e=c.slice(1)}catch(a){console.log(a)}(a=console).log.apply(a,f.concat((0,_toConsumableArray2["default"])(e)))},showLog=function(a,b,c){if(c){var d=(0,_isElectron["default"])(),e=null!==c&&void 0!==c&&c.root?_path["default"].resolve(c.root):_path["default"].resolve((0,_os.homedir)(),".mpaas_log");(0,_fsExtra.ensureDirSync)(e);var f=d?"mpaas_ide":"mpaas_ide_openapi",g=_path["default"].resolve(e,f);_log4js["default"].configure({appenders:{"[mpaas_ide_openapi]":{type:"dateFile",filename:g,pattern:"yyyy-MM-dd.log",alwaysIncludePattern:!0,category:"normal"}},categories:{default:{appenders:["[mpaas_ide_openapi]"],level:"trace"}}}),_log4js["default"].getLogger("[mpaas_ide_openapi]")[a](JSON.stringify(b)),printLog.apply(void 0,(0,_toConsumableArray2["default"])(b))}},logger={trace:function trace(){for(var a,b,c=arguments.length,d=Array(c),e=0;e<c;e++)d[e]=arguments[e];return showLog("trace",d,null===(a=global)||void 0===a||null===(b=a.mpaasOpenApi)||void 0===b?void 0:b.log)},info:function info(){for(var a,b,c=arguments.length,d=Array(c),e=0;e<c;e++)d[e]=arguments[e];return showLog("info",d,null===(a=global)||void 0===a||null===(b=a.mpaasOpenApi)||void 0===b?void 0:b.log)},warn:function warn(){for(var a,b,c=arguments.length,d=Array(c),e=0;e<c;e++)d[e]=arguments[e];return showLog("warn",d,null===(a=global)||void 0===a||null===(b=a.mpaasOpenApi)||void 0===b?void 0:b.log)},error:function error(){for(var a,b,c=arguments.length,d=Array(c),e=0;e<c;e++)d[e]=arguments[e];return showLog("error",d,null===(a=global)||void 0===a||null===(b=a.mpaasOpenApi)||void 0===b?void 0:b.log)},debug:function debug(){for(var a,b,c=arguments.length,d=Array(c),e=0;e<c;e++)d[e]=arguments[e];return showLog("debug",d,null===(a=global)||void 0===a||null===(b=a.mpaasOpenApi)||void 0===b?void 0:b.log)}};exports.logger=logger;var getPackageType=function(a){return{data:["1","2",1,2].includes(a)?"production":"development",success:!0}};exports.getPackageType=getPackageType;var looseJsonParse=function(a){try{return{data:Function("\"use strict\";return (".concat(a,")"))(),success:!0}}catch(b){return{data:JSON.parse(a.replace(/"/ig,"\"")),success:!0}}};exports.looseJsonParse=looseJsonParse;var downloadFile=function(){var a=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function b(a){var c,d,e,f,g,h;return _regenerator["default"].wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(c=a.url,d=a.target,b.prev=1,b.t0=d,b.t0){b.next=7;break}return b.next=6,getTmpDir();case 6:b.t0=b.sent;case 7:return e=b.t0,f="".concat(uuid()).concat(_path["default"].extname(new URL(c).pathname)),g=_path["default"].join(e,f),b.next=12,_superagent["default"].get(c);case 12:return h=b.sent,b.next=15,(0,_fsExtra.writeFileSync)(g,h.body,"binary");case 15:return b.abrupt("return",{data:g,success:!0});case 18:throw b.prev=18,b.t1=b["catch"](1),new Error(b.t1.message);case 21:case"end":return b.stop();}},b,null,[[1,18]])}));return function(){return a.apply(this,arguments)}}();exports.downloadFile=downloadFile;var appInfoToVariables=function(a){var b=a.h5Id,c=a.platform,d=a.clientVersionMin,e=a.clientVersionMax,f=a.mainUrl,g=void 0===f?"/index.html#pages/index/index":f,h=a.extraData,i=a.extendInfo,j=a.autoInstall,k=void 0===j?"0":j,l=a.installType,m=void 0===l?"0":l,n=a.iconFile,o=h&&looseJsonParse(h.replace(/"|&quot;/gi,"\"")),p=o.data;p=void 0===p?{}:p;var q,r,s,t,u,v,w=p.iconUrl,x=void 0===w?"":w,y=p.enableTabBar,z=void 0===y?"1":y,A=p.enableOptionMenu,B=void 0===A?"1":A,C=d&&d.split(";"),D=e&&e.split(";");switch(c){case"all":q=!0,r=!0,s=C&&C[0],t=D&&D[0],u=C&&C[1],v=D&&D[1];break;case"iOS":q=!0,r=!1,s=C&&C[0],t=D&&D[0];break;case"android":q=!1,r=!0,u=C&&C[1],v=D&&D[1];break;default:q=!1,r=!1;}return{h5Id:b,mainUrl:g,autoInstall:k,installType:m,iconFile:n,extendInfo:i.replace(/"|&quot;/gi,"\""),iconUrl:x,enableTabBar:z,enableOptionMenu:B,enableKeepAlive:"0",platformIOS:q,platformAndroid:r,iosMinVersion:s,iosMaxVersion:t,androidMinVersion:u,androidMaxVersion:v}};exports.appInfoToVariables=appInfoToVariables;var variablesToappInfo=function(a){var b,c,d,e=a.h5Id,f=a.h5Name,g=a.mainUrl,h=a.subUrl,i=void 0===h?"":h,j=a.iconFile,k=void 0===j?"":j,l=a.resourceType,m=a.platformIOS,n=a.platformAndroid,o=a.iosMinVersion,p=void 0===o?"":o,q=a.iosMaxVersion,r=void 0===q?"":q,s=a.androidMinVersion,t=void 0===s?"":s,u=a.androidMaxVersion,v=void 0===u?"":u,w=a.autoInstall,x=a.installType,y=a.enableKeepAlive,z=a.enableOptionMenu,A=a.enableTabBar,B=a.extendInfo,C=a.iconUrl,D=a.vhost;return m&&n?(b="all",c="".concat(p).concat(t?";".concat(t):""),d="".concat(r).concat(v?";".concat(v):"")):m?(b="iOS",c="".concat(p),d="".concat(r)):n&&(b="android",c="".concat(t?";".concat(t):""),d="".concat(v?";".concat(v):"")),{h5Id:e,h5Name:f,mainUrl:g,iconFile:k,subUrl:i,vhost:D,enableKeepAlive:y,enableOptionMenu:z,enableTabBar:A,iconUrl:C,resourceType:l,autoInstall:w,installType:x,extendInfo:B,platform:b,clientVersionMin:c,clientVersionMax:d}};exports.variablesToappInfo=variablesToappInfo;var parseDebugURL=function(a){var b;try{b=a.data.replace(/&/ig,"&"),b=looseJsonParse(b)}catch(c){b=a}return b};exports.parseDebugURL=parseDebugURL;var getUploadResult=function(a){var b=a.res,c=a.h5Version,d=a.req;try{var e=parseDebugURL(b),f=e.data,g=(0,_objectWithoutProperties2["default"])(e,_excluded2);"object"!==(0,_typeof2["default"])(f)&&(f={projectId:f}),f=_objectSpread(_objectSpread({},f),{},{h5Version:c,gmtCreate:new Date().valueOf()});var h=d.packageType,i=d.buildTarget;if(0==h-3&&"RemoteBoatman"===i){var j=f,k=j.debugUrl;k=decodeURIComponent(k);var l=k.match(/mpaas.*?scheme=mpaas:\/\/platformapi\/startapp\?/gi)[0],m=k.replace(l,"");m=_queryString["default"].parse(m),delete m.enablePolyfillWorker,delete m.isRemoteDebug,m.tyroId=m.channelId,m.isRemoteX=!0,m=_queryString["default"].stringify(m),m=encodeURIComponent(m),k=l+m,f.debugUrl=k}return _objectSpread(_objectSpread({},g),{},{data:f,originData:e})}catch(a){throw new Error(a.message)}};exports.getUploadResult=getUploadResult;var transformPluginParams=function(a){var b=a.h5Id,c=a.h5Name,d=a.h5Version,e=a.miniPluginName,f=a.miniPluginId,g=a.miniPluginVersion,h=_objectSpread({},a);return b&&(h.miniPluginId=b),c&&(h.miniPluginName=c),d&&(h.miniPluginVersion=d),f&&(h.h5Id=f),e&&(h.h5Name=e),g&&(h.h5Version=g),h};exports.transformPluginParams=transformPluginParams; |
{ | ||
"name": "@alipay-inc/mpaas-ide-openapi-common", | ||
"version": "1.0.11-alpha.2", | ||
"version": "1.0.11-alpha.3", | ||
"main": "dist/index.js", | ||
@@ -34,3 +34,3 @@ "repository": "https://code.alipay.com/mPaaS-IDE-Adaptor/mPaaS-IDE-openAPI.git", | ||
}, | ||
"gitHead": "b485a10f29f08e598da86f47f451bca3f14223e6" | ||
"gitHead": "efec4bf21180a3862ef5e9aef74de73148ff37db" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39803