Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@alipay-inc/mpaas-ide-openapi-common

Package Overview
Dependencies
Maintainers
4
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@alipay-inc/mpaas-ide-openapi-common - npm Package Compare versions

Comparing version 1.0.13-alpha.4 to 1.0.13-alpha.5

2

dist/cloudBuild.js

@@ -1,1 +0,1 @@

"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:!0}),exports.remoteFileToLocal=exports.pollBuildStatusPrivate=exports.pollBuildStatusAlipay=exports.getFile=exports.getCloudBuildData=exports.cloudBuildPrivate=exports.cloudBuildAlipay=exports.cloudBuild=void 0;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty")),_objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")),_regenerator=_interopRequireDefault(require("@babel/runtime/regenerator")),_asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")),_superagent=_interopRequireDefault(require("superagent")),_path2=_interopRequireDefault(require("path")),_fsExtra=_interopRequireDefault(require("fs-extra")),_=require("./"),_archiver=_interopRequireDefault(require("archiver")),_chalk=_interopRequireDefault(require("chalk")),_excluded=["file"];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 POLL_DELAY_TIME=4e3,IGNORE_DIR=[".idea",".vscode",".git",".DS_Store",".umi",".umi-production",".miniu",".node",".tea"],SUBPACAKGES_ARR=[],pollGetPackageFile=function(){var a=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function c(a,b){var d,e,f,g,h,j;return _regenerator["default"].wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(a--,!(0<=a)){c.next=11;break}return d=b[a],e=d.path,f=d.tarFilePath,g=e.split("/").join("_"),c.next=6,remoteFileToLocal({originFile:f,h5Id:g});case 6:return h=c.sent,j=h.file,SUBPACAKGES_ARR.push({file:j,name:g,path:e}),c.next=11,pollGetPackageFile(a,b);case 11:case"end":return c.stop();}},c)}));return function(){return a.apply(this,arguments)}}(),mergePackageFile=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;return _regenerator["default"].wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return c=a.zipFile,d=a.subPackages,e=a.h5Id,f=(0,_.getTmpDir)(),g=_path2["default"].join(f,e),h=_path2["default"].join(g,"subpackages"),i=_path2["default"].join(h,"subpackage.json"),_fsExtra["default"].existsSync(g)&&_fsExtra["default"].removeSync(g),_fsExtra["default"].ensureDirSync(g),_fsExtra["default"].ensureDirSync(h),b.prev=8,b.next=11,remoteFileToLocal({originFile:c,h5Id:e});case 11:if(j=b.sent,k=j.file,l=_path2["default"].join(g,_path2["default"].basename(k)),m={subpackageFlag:!1},!(d&&d.length)){b.next=32;break}return _fsExtra["default"].moveSync(k,l),m.subpackageFlag=!0,n=d.length,b.next=21,pollGetPackageFile(n,d);case 21:return o={},SUBPACAKGES_ARR.forEach(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:c=a.file,d=a.name,e=a.path,"main"!=d&&(o[d]=e),f=_path2["default"].join(h,_path2["default"].basename(c)),_fsExtra["default"].moveSync(c,f);case 4:case"end":return b.stop();}},b)}));return function(){return a.apply(this,arguments)}}()),_fsExtra["default"].writeJSONSync(i,o),p=_path2["default"].join(f,"".concat(e,".zip")),b.next=27,compressFile({resourceFile:g,targetFile:p,type:"directory"});case 27:console.log("SUBPACAKGES_ARR",SUBPACAKGES_ARR,o,i),m.file=p,m.originFile="",b.next=34;break;case 32:m.file=k,m.originFile=c;case 34:return console.log("get result:",m),SUBPACAKGES_ARR=[],b.abrupt("return",m);case 39:throw b.prev=39,b.t0=b["catch"](8),new Error(b.t0.message);case 42:case"end":return b.stop();}},b,null,[[8,39]])}));return function(){return a.apply(this,arguments)}}(),getCloudBuildData=function(a){var b=a.build_url,c=void 0===b?null:b;return c?{type:"private",CLOUD_BUILD_EXEC_URL:"".concat(c,"/miniApp/buildIdeMiniApp"),CLOUD_BUILD_POLL_URL:"".concat(c,"/miniApp/queryMiniAppBuildResult")}:{type:"alipay",CLOUD_BUILD_EXEC_URL:"https://hpmweb.alipay.com/tinyApp/cloudBuild/execute",CLOUD_BUILD_POLL_URL:"https://hpmweb.alipay.com/tinyApp/cloudBuild/result"}};exports.getCloudBuildData=getCloudBuildData;var cloudBuild=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:return _.logger.info("cloudBuild req",a),b.prev=1,c=a.config,d=a.file,e=(0,_objectWithoutProperties2["default"])(a,_excluded),f=getCloudBuildData(c),b.next=7,getFile({file:d,type:f.type});case 7:if(d=b.sent,g=_objectSpread(_objectSpread({},e),{},{file:d}),h={},"private"!==f.type){b.next=17;break}return _.logger.info("cloudBuild: private"),b.next=14,cloudBuildPrivate(g,a);case 14:h=b.sent,b.next=21;break;case 17:return _.logger.info("cloudBuild: alipay"),b.next=20,cloudBuildAlipay(g);case 20:h=b.sent;case 21:return _.logger.info("cloudBuild res",h),console.log(_chalk["default"].green("cloudBuild done")),b.abrupt("return",h);case 26:return b.prev=26,b.t0=b["catch"](1),_.logger.error("cloudBuild error",b.t0.message),b.next=31,(0,_.delay)(0);case 31:throw new Error(b.t0.message);case 32:case"end":return b.stop();}},b,null,[[1,26]])}));return function(){return a.apply(this,arguments)}}();exports.cloudBuild=cloudBuild;var compressFile=function(a){var b=a.resourceFile,c=a.targetFile,d=a.type;return new Promise(function(a,e){var f=_fsExtra["default"].createWriteStream(c),g=(0,_archiver["default"])("zip",{zlib:{level:9}});g.pipe(f),f.on("close",function(){a(c)}),g.on("error",function(a){e(a)}),"directory"===d?g.directory("".concat(b),""):g.file("".concat(b),{name:_path2["default"].basename(b)}),g.finalize()})},getFile=function(){var a=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function b(a){var c,d,e,f,g,h,i;return _regenerator["default"].wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(c=a.file,d=a.type,b.prev=1,_fsExtra["default"].existsSync(c)){b.next=4;break}throw new Error("\u6587\u4EF6\u4E0D\u5B58\u5728\uFF01");case 4:if(!_fsExtra["default"].lstatSync(c).isFile()){b.next=8;break}if(".amr"===_path2["default"].extname(c)){b.next=7;break}throw new Error("\u6587\u4EF6\u683C\u5F0F\u9519\u8BEF\uFF01");case 7:return b.abrupt("return",c);case 8:if(!_fsExtra["default"].lstatSync(c).isDirectory()){b.next=22;break}return e=(0,_.getTmpDir)(),f=(0,_.getTmpDir)(),_fsExtra["default"].copySync(c,e),b.next=14,compressFile({resourceFile:e,targetFile:_path2["default"].join(f,"dist.tar"),type:"directory"});case 14:if(g=b.sent,"alipay"!==d){b.next=17;break}return b.abrupt("return",g);case 17:return h=(0,_.getTmpDir)(),b.next=20,compressFile({resourceFile:_path2["default"].join(f,"dist.tar"),targetFile:_path2["default"].join(h,"dist.amr")});case 20:return i=b.sent,b.abrupt("return",i);case 22:return b.abrupt("return",c);case 25:throw b.prev=25,b.t0=b["catch"](1),new Error(b.t0.message);case 28:case"end":return b.stop();}},b,null,[[1,25]])}));return function(){return a.apply(this,arguments)}}();exports.getFile=getFile;var cloudBuildAlipay=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,v,w,x,y,z,A,B,C;return _regenerator["default"].wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.prev=0,c=a.file,d=a.config,e=void 0===d?{}:d,f=a.adaptorId,g=void 0===f?"mPaaS":f,h=a.h5Id,i=e.appId,j=getCloudBuildData(e),k=j.CLOUD_BUILD_EXEC_URL,l=j.CLOUD_BUILD_POLL_URL,m={params:"[\n \"--scriptName\",\n \"buildpack\",\n \"--ADAPTOR_NAME\",\n \"adaptor-mpaas-".concat(g,"\",\n \"--limitation\",\n \"--debug\"\n ]"),env:"{}",operationType:"build",extraInfo:JSON.stringify({appId:h,doneCommand:"pack",client:"IDE",scene:"IDE",fileFormat:"tar"})},n={value:_fsExtra["default"].readFileSync(c),options:{filename:"".concat(h,".tar"),contentType:"application/zip"}},_.logger.info("cloudBuild req",m),b.next=9,_superagent["default"].post(k).field(m).attach("file",n.value,n.options);case 9:if(o=b.sent,p=o.body,q=void 0===p?{}:p,_.logger.info("cloudBuild res",q),q.success){b.next=15;break}throw new Error(q.msg);case 15:return r=q.data.taskId,b.next=18,pollBuildStatusAlipay({CLOUD_BUILD_POLL_URL:l,taskId:r});case 18:return s=b.sent,t=s.data,t=void 0===t?{}:t,u=t.zipFile,v=t.subPackages,w=void 0===v?[]:v,x=t.plugin,x=void 0===x?{}:x,y=x.artifactUrl,z=t.uploadParams,z=void 0===z?{}:z,A=z.extendInfo,B=y||u,b.next=29,mergePackageFile({zipFile:B,subPackages:w,h5Id:h});case 29:return C=b.sent,_.logger.info("get mergePackageFileJSON:",C),b.abrupt("return",{data:_objectSpread(_objectSpread({},C),{},{appxVersion:(0,_.getAppxVersion)({extendInfo:A})}),succes:!0});case 34:throw b.prev=34,b.t0=b["catch"](0),new Error(b.t0.message);case 37:case"end":return b.stop();}},b,null,[[0,34]])}));return function(){return a.apply(this,arguments)}}();exports.cloudBuildAlipay=cloudBuildAlipay;var pollBuildStatusAlipay=function(){var a=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function b(a){var c,d,e,f,g;return _regenerator["default"].wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return c=a.CLOUD_BUILD_POLL_URL,d=a.taskId,b.prev=1,_.logger.info("pollBuildStatus req",d),b.next=5,_superagent["default"].get(c).query({taskId:d});case 5:if(e=b.sent,f=e.body,g=void 0===f?{}:f,_.logger.info("pollBuildStatus res",g),g.success){b.next=11;break}throw new Error(g.msg);case 11:if("COMPLETE"!==g.status){b.next=13;break}return b.abrupt("return",g);case 13:;return b.next=16,(0,_.delay)(POLL_DELAY_TIME);case 16:return b.next=18,pollBuildStatusAlipay({CLOUD_BUILD_POLL_URL:c,taskId:d});case 18:return b.abrupt("return",b.sent);case 21:throw b.prev=21,b.t0=b["catch"](1),new Error(b.t0.message);case 24:case"end":return b.stop();}},b,null,[[1,21]])}));return function(){return a.apply(this,arguments)}}();exports.pollBuildStatusAlipay=pollBuildStatusAlipay;var cloudBuildPrivate=function(){var a=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function c(a,b){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y;return _regenerator["default"].wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.prev=0,d=a.file,e=a.config,f=void 0===e?{}:e,g=a.h5Id,h=f.appId,i=f.workspaceId,j=f.tenantId,k=getCloudBuildData(f),l=k.CLOUD_BUILD_EXEC_URL,m=k.CLOUD_BUILD_POLL_URL,n={value:_fsExtra["default"].readFileSync(d),options:{filename:"".concat(h,".amr"),contentType:"application/zip"}},_.logger.info("cloudBuild req",{appId:h,workspaceId:i,tenantId:j}),c.next=8,_superagent["default"].post(l).field({appId:h,workspaceId:i,tenantId:j}).attach("file",n.value,n.options);case 8:if(o=c.sent,p=o.body,q=void 0===p?{}:p,_.logger.info("cloudBuild res",q),q.success){c.next=14;break}throw new Error(q.message);case 14:return c.next=16,pollBuildStatusPrivate({CLOUD_BUILD_POLL_URL:m,buildId:q.data});case 16:return r=c.sent,s=r.data,t=s.downloadUrl,u=s.pluginDownloadUrl,v=s.subPackages,w=void 0===v?[]:v,x=u||t,c.next=25,mergePackageFile({zipFile:x,subPackages:w,h5Id:g});case 25:return y=c.sent,c.abrupt("return",{data:_objectSpread(_objectSpread({},y),{},{appxVersion:(0,_.getAppxVersion)({rootPath:b.file})}),succes:!0});case 29:throw c.prev=29,c.t0=c["catch"](0),new Error(c.t0.message);case 32:case"end":return c.stop();}},c,null,[[0,29]])}));return function(){return a.apply(this,arguments)}}();exports.cloudBuildPrivate=cloudBuildPrivate;var pollBuildStatusPrivate=function(){var a=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function b(a){var c,d,e,f,g,h,i,j;return _regenerator["default"].wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return c=a.CLOUD_BUILD_POLL_URL,d=a.buildId,b.prev=1,_.logger.info("pollBuildStatus req",{buildId:d}),b.next=5,_superagent["default"].get(c).query({buildId:d});case 5:if(g=b.sent,h=g.body,i=void 0===h?{}:h,_.logger.info("pollBuildStatus res",{body:i}),i.success){b.next=11;break}throw new Error(i.message);case 11:if("FAILURE"!==(null===i||void 0===i||null===(e=i.data)||void 0===e?void 0:e.result)){b.next=13;break}throw new Error(null===i||void 0===i||null===(j=i.data)||void 0===j?void 0:j.logUrl);case 13:;if("SUCCESS"!==(null===i||void 0===i||null===(f=i.data)||void 0===f?void 0:f.result)){b.next=16;break}return b.abrupt("return",i);case 16:;return b.next=19,(0,_.delay)(POLL_DELAY_TIME);case 19:return b.next=21,pollBuildStatusPrivate({CLOUD_BUILD_POLL_URL:c,buildId:d});case 21:return b.abrupt("return",b.sent);case 24:throw b.prev=24,b.t0=b["catch"](1),new Error(b.t0.message);case 27:case"end":return b.stop();}},b,null,[[1,24]])}));return function(){return a.apply(this,arguments)}}();exports.pollBuildStatusPrivate=pollBuildStatusPrivate;var remoteFileToLocal=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:return c=a.originFile,d=a.h5Id,b.prev=1,b.next=4,(0,_.downloadFile)({url:c});case 4:return e=b.sent,f=e.data,b.next=8,(0,_.getZipFromTar)({tarFilePath:f,h5Id:d});case 8:return g=b.sent,h=g.data,b.abrupt("return",{file:h,originFile:c});case 13:throw b.prev=13,b.t0=b["catch"](1),new Error(b.t0.message);case 16:case"end":return b.stop();}},b,null,[[1,13]])}));return function(){return a.apply(this,arguments)}}();exports.remoteFileToLocal=remoteFileToLocal;
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:!0}),exports.remoteFileToLocal=exports.pollBuildStatusPrivate=exports.pollBuildStatusAlipay=exports.getFile=exports.getCloudBuildData=exports.cloudBuildPrivate=exports.cloudBuildAlipay=exports.cloudBuild=void 0;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty")),_objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")),_regenerator=_interopRequireDefault(require("@babel/runtime/regenerator")),_asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")),_superagent=_interopRequireDefault(require("superagent")),_path2=_interopRequireDefault(require("path")),_fsExtra=_interopRequireDefault(require("fs-extra")),_=require("./"),_archiver=_interopRequireDefault(require("archiver")),_chalk=_interopRequireDefault(require("chalk")),_excluded=["file"];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 POLL_DELAY_TIME=4e3,IGNORE_DIR=[".idea",".vscode",".git",".DS_Store",".umi",".umi-production",".miniu",".node",".tea"],SUBPACAKGES_ARR=[],pollGetPackageFile=function(){var a=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function c(a,b){var d,e,f,g,h,j;return _regenerator["default"].wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(a--,!(0<=a)){c.next=11;break}return d=b[a],e=d.path,f=d.tarFilePath,g=e.split("/").join("_"),c.next=6,remoteFileToLocal({originFile:f,h5Id:g});case 6:return h=c.sent,j=h.file,SUBPACAKGES_ARR.push({file:j,name:g,path:e}),c.next=11,pollGetPackageFile(a,b);case 11:case"end":return c.stop();}},c)}));return function(){return a.apply(this,arguments)}}(),mergePackageFile=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;return _regenerator["default"].wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return c=a.zipFile,d=a.subPackages,e=a.h5Id,f=(0,_.getTmpDir)(),g=_path2["default"].join(f,"".concat(e)),h=_path2["default"].join(g,"".concat(e)),i=_path2["default"].join(h,"subpackages"),j=_path2["default"].join(i,"subpackage.json"),_fsExtra["default"].existsSync(h)&&_fsExtra["default"].removeSync(h),_fsExtra["default"].ensureDirSync(h),_fsExtra["default"].ensureDirSync(i),b.prev=9,b.next=12,remoteFileToLocal({originFile:c,h5Id:e});case 12:if(k=b.sent,l=k.file,m=_path2["default"].join(h,_path2["default"].basename(l)),n={subpackageFlag:!1},!(d&&d.length)){b.next=33;break}return _fsExtra["default"].moveSync(l,m),n.subpackageFlag=!0,o=d.length,b.next=22,pollGetPackageFile(o,d);case 22:return p={},SUBPACAKGES_ARR.forEach(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:c=a.file,d=a.name,e=a.path,"main"!=d&&(p[d]=e),f=_path2["default"].join(i,_path2["default"].basename(c)),_fsExtra["default"].moveSync(c,f);case 4:case"end":return b.stop();}},b)}));return function(){return a.apply(this,arguments)}}()),_fsExtra["default"].writeJSONSync(j,p),q=_path2["default"].join(f,"".concat(e,".zip")),b.next=28,compressFile({resourceFile:g,targetFile:q,type:"directory"});case 28:console.log("SUBPACAKGES_ARR",SUBPACAKGES_ARR,p,j),n.file=q,n.originFile="",b.next=35;break;case 33:n.file=l,n.originFile=c;case 35:return console.log("get result:",n),SUBPACAKGES_ARR=[],b.abrupt("return",n);case 40:throw b.prev=40,b.t0=b["catch"](9),new Error(b.t0.message);case 43:case"end":return b.stop();}},b,null,[[9,40]])}));return function(){return a.apply(this,arguments)}}(),getCloudBuildData=function(a){var b=a.build_url,c=void 0===b?null:b;return c?{type:"private",CLOUD_BUILD_EXEC_URL:"".concat(c,"/miniApp/buildIdeMiniApp"),CLOUD_BUILD_POLL_URL:"".concat(c,"/miniApp/queryMiniAppBuildResult")}:{type:"alipay",CLOUD_BUILD_EXEC_URL:"https://hpmweb.alipay.com/tinyApp/cloudBuild/execute",CLOUD_BUILD_POLL_URL:"https://hpmweb.alipay.com/tinyApp/cloudBuild/result"}};exports.getCloudBuildData=getCloudBuildData;var cloudBuild=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:return _.logger.info("cloudBuild req",a),b.prev=1,c=a.config,d=a.file,e=(0,_objectWithoutProperties2["default"])(a,_excluded),f=getCloudBuildData(c),b.next=7,getFile({file:d,type:f.type});case 7:if(d=b.sent,g=_objectSpread(_objectSpread({},e),{},{file:d}),h={},"private"!==f.type){b.next=17;break}return _.logger.info("cloudBuild: private"),b.next=14,cloudBuildPrivate(g,a);case 14:h=b.sent,b.next=21;break;case 17:return _.logger.info("cloudBuild: alipay"),b.next=20,cloudBuildAlipay(g);case 20:h=b.sent;case 21:return _.logger.info("cloudBuild res",h),console.log(_chalk["default"].green("cloudBuild done")),b.abrupt("return",h);case 26:return b.prev=26,b.t0=b["catch"](1),_.logger.error("cloudBuild error",b.t0.message),b.next=31,(0,_.delay)(0);case 31:throw new Error(b.t0.message);case 32:case"end":return b.stop();}},b,null,[[1,26]])}));return function(){return a.apply(this,arguments)}}();exports.cloudBuild=cloudBuild;var compressFile=function(a){var b=a.resourceFile,c=a.targetFile,d=a.type;return new Promise(function(a,e){var f=_fsExtra["default"].createWriteStream(c),g=(0,_archiver["default"])("zip",{zlib:{level:9}});g.pipe(f),f.on("close",function(){a(c)}),g.on("error",function(a){e(a)}),"directory"===d?g.directory("".concat(b),""):g.file("".concat(b),{name:_path2["default"].basename(b)}),g.finalize()})},getFile=function(){var a=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function b(a){var c,d,e,f,g,h,i;return _regenerator["default"].wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(c=a.file,d=a.type,b.prev=1,_fsExtra["default"].existsSync(c)){b.next=4;break}throw new Error("\u6587\u4EF6\u4E0D\u5B58\u5728\uFF01");case 4:if(!_fsExtra["default"].lstatSync(c).isFile()){b.next=8;break}if(".amr"===_path2["default"].extname(c)){b.next=7;break}throw new Error("\u6587\u4EF6\u683C\u5F0F\u9519\u8BEF\uFF01");case 7:return b.abrupt("return",c);case 8:if(!_fsExtra["default"].lstatSync(c).isDirectory()){b.next=22;break}return e=(0,_.getTmpDir)(),f=(0,_.getTmpDir)(),_fsExtra["default"].copySync(c,e),b.next=14,compressFile({resourceFile:e,targetFile:_path2["default"].join(f,"dist.tar"),type:"directory"});case 14:if(g=b.sent,"alipay"!==d){b.next=17;break}return b.abrupt("return",g);case 17:return h=(0,_.getTmpDir)(),b.next=20,compressFile({resourceFile:_path2["default"].join(f,"dist.tar"),targetFile:_path2["default"].join(h,"dist.amr")});case 20:return i=b.sent,b.abrupt("return",i);case 22:return b.abrupt("return",c);case 25:throw b.prev=25,b.t0=b["catch"](1),new Error(b.t0.message);case 28:case"end":return b.stop();}},b,null,[[1,25]])}));return function(){return a.apply(this,arguments)}}();exports.getFile=getFile;var cloudBuildAlipay=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,v,w,x,y,z,A,B,C;return _regenerator["default"].wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.prev=0,c=a.file,d=a.config,e=void 0===d?{}:d,f=a.adaptorId,g=void 0===f?"mPaaS":f,h=a.h5Id,i=e.appId,j=getCloudBuildData(e),k=j.CLOUD_BUILD_EXEC_URL,l=j.CLOUD_BUILD_POLL_URL,m={params:"[\n \"--scriptName\",\n \"buildpack\",\n \"--ADAPTOR_NAME\",\n \"adaptor-mpaas-".concat(g,"\",\n \"--limitation\",\n \"--debug\"\n ]"),env:"{}",operationType:"build",extraInfo:JSON.stringify({appId:h,doneCommand:"pack",client:"IDE",scene:"IDE",fileFormat:"tar"})},n={value:_fsExtra["default"].readFileSync(c),options:{filename:"".concat(h,".tar"),contentType:"application/zip"}},_.logger.info("cloudBuild req",m),b.next=9,_superagent["default"].post(k).field(m).attach("file",n.value,n.options);case 9:if(o=b.sent,p=o.body,q=void 0===p?{}:p,_.logger.info("cloudBuild res",q),q.success){b.next=15;break}throw new Error(q.msg);case 15:return r=q.data.taskId,b.next=18,pollBuildStatusAlipay({CLOUD_BUILD_POLL_URL:l,taskId:r});case 18:return s=b.sent,t=s.data,t=void 0===t?{}:t,u=t.zipFile,v=t.subPackages,w=void 0===v?[]:v,x=t.plugin,x=void 0===x?{}:x,y=x.artifactUrl,z=t.uploadParams,z=void 0===z?{}:z,A=z.extendInfo,B=y||u,b.next=29,mergePackageFile({zipFile:B,subPackages:w,h5Id:h});case 29:return C=b.sent,_.logger.info("get mergePackageFileJSON:",C),b.abrupt("return",{data:_objectSpread(_objectSpread({},C),{},{appxVersion:(0,_.getAppxVersion)({extendInfo:A})}),succes:!0});case 34:throw b.prev=34,b.t0=b["catch"](0),new Error(b.t0.message);case 37:case"end":return b.stop();}},b,null,[[0,34]])}));return function(){return a.apply(this,arguments)}}();exports.cloudBuildAlipay=cloudBuildAlipay;var pollBuildStatusAlipay=function(){var a=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function b(a){var c,d,e,f,g;return _regenerator["default"].wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return c=a.CLOUD_BUILD_POLL_URL,d=a.taskId,b.prev=1,_.logger.info("pollBuildStatus req",d),b.next=5,_superagent["default"].get(c).query({taskId:d});case 5:if(e=b.sent,f=e.body,g=void 0===f?{}:f,_.logger.info("pollBuildStatus res",g),g.success){b.next=11;break}throw new Error(g.msg);case 11:if("COMPLETE"!==g.status){b.next=13;break}return b.abrupt("return",g);case 13:;return b.next=16,(0,_.delay)(POLL_DELAY_TIME);case 16:return b.next=18,pollBuildStatusAlipay({CLOUD_BUILD_POLL_URL:c,taskId:d});case 18:return b.abrupt("return",b.sent);case 21:throw b.prev=21,b.t0=b["catch"](1),new Error(b.t0.message);case 24:case"end":return b.stop();}},b,null,[[1,21]])}));return function(){return a.apply(this,arguments)}}();exports.pollBuildStatusAlipay=pollBuildStatusAlipay;var cloudBuildPrivate=function(){var a=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function c(a,b){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y;return _regenerator["default"].wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.prev=0,d=a.file,e=a.config,f=void 0===e?{}:e,g=a.h5Id,h=f.appId,i=f.workspaceId,j=f.tenantId,k=getCloudBuildData(f),l=k.CLOUD_BUILD_EXEC_URL,m=k.CLOUD_BUILD_POLL_URL,n={value:_fsExtra["default"].readFileSync(d),options:{filename:"".concat(h,".amr"),contentType:"application/zip"}},_.logger.info("cloudBuild req",{appId:h,workspaceId:i,tenantId:j}),c.next=8,_superagent["default"].post(l).field({appId:h,workspaceId:i,tenantId:j}).attach("file",n.value,n.options);case 8:if(o=c.sent,p=o.body,q=void 0===p?{}:p,_.logger.info("cloudBuild res",q),q.success){c.next=14;break}throw new Error(q.message);case 14:return c.next=16,pollBuildStatusPrivate({CLOUD_BUILD_POLL_URL:m,buildId:q.data});case 16:return r=c.sent,s=r.data,t=s.downloadUrl,u=s.pluginDownloadUrl,v=s.subPackages,w=void 0===v?[]:v,x=u||t,c.next=25,mergePackageFile({zipFile:x,subPackages:w,h5Id:g});case 25:return y=c.sent,c.abrupt("return",{data:_objectSpread(_objectSpread({},y),{},{appxVersion:(0,_.getAppxVersion)({rootPath:b.file})}),succes:!0});case 29:throw c.prev=29,c.t0=c["catch"](0),new Error(c.t0.message);case 32:case"end":return c.stop();}},c,null,[[0,29]])}));return function(){return a.apply(this,arguments)}}();exports.cloudBuildPrivate=cloudBuildPrivate;var pollBuildStatusPrivate=function(){var a=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function b(a){var c,d,e,f,g,h,i,j;return _regenerator["default"].wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return c=a.CLOUD_BUILD_POLL_URL,d=a.buildId,b.prev=1,_.logger.info("pollBuildStatus req",{buildId:d}),b.next=5,_superagent["default"].get(c).query({buildId:d});case 5:if(g=b.sent,h=g.body,i=void 0===h?{}:h,_.logger.info("pollBuildStatus res",{body:i}),i.success){b.next=11;break}throw new Error(i.message);case 11:if("FAILURE"!==(null===i||void 0===i||null===(e=i.data)||void 0===e?void 0:e.result)){b.next=13;break}throw new Error(null===i||void 0===i||null===(j=i.data)||void 0===j?void 0:j.logUrl);case 13:;if("SUCCESS"!==(null===i||void 0===i||null===(f=i.data)||void 0===f?void 0:f.result)){b.next=16;break}return b.abrupt("return",i);case 16:;return b.next=19,(0,_.delay)(POLL_DELAY_TIME);case 19:return b.next=21,pollBuildStatusPrivate({CLOUD_BUILD_POLL_URL:c,buildId:d});case 21:return b.abrupt("return",b.sent);case 24:throw b.prev=24,b.t0=b["catch"](1),new Error(b.t0.message);case 27:case"end":return b.stop();}},b,null,[[1,24]])}));return function(){return a.apply(this,arguments)}}();exports.pollBuildStatusPrivate=pollBuildStatusPrivate;var remoteFileToLocal=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:return c=a.originFile,d=a.h5Id,b.prev=1,b.next=4,(0,_.downloadFile)({url:c});case 4:return e=b.sent,f=e.data,b.next=8,(0,_.getZipFromTar)({tarFilePath:f,h5Id:d});case 8:return g=b.sent,h=g.data,b.abrupt("return",{file:h,originFile:c});case 13:throw b.prev=13,b.t0=b["catch"](1),new Error(b.t0.message);case 16:case"end":return b.stop();}},b,null,[[1,13]])}));return function(){return a.apply(this,arguments)}}();exports.remoteFileToLocal=remoteFileToLocal;

@@ -1,1 +0,1 @@

"use strict";var _exportNames={logger:!0,uuid:!0,delay:!0,getConfigType:!0,getUserInfo:!0,setUserInfo:!0,login:!0,logout:!0,defaultTinyappConfig:!0,getDefaultTinyappConfig:!0,getDefaultPluginConfig:!0,getTmpDirRoot:!0,getTmpDir:!0,cleanCache:!0,getVersion:!0,getUUID:!0,getZipFile:!0,getZipFromTar:!0,getPackageType:!0,looseJsonParse:!0,downloadFile:!0,appInfoToVariables:!0,variablesToappInfo:!0,parseDebugURL:!0,getUploadResult:!0,transformPluginParams:!0,isValidatedJsonString:!0,getAppxVersion:!0,localStore:!0};var _getUploadData=require("./getUploadData");var _localStore=_interopRequireWildcard(require("./localStorage"));var _excluded=["config"],_excluded2=["data"];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.logout=exports.login=exports.logger=exports.localStore=exports.isValidatedJsonString=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.getAppxVersion=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")),_archiver=_interopRequireDefault(require("archiver")),_isElectron=_interopRequireDefault(require("is-electron")),_os=require("os"),_path=_interopRequireDefault(require("path")),_superagent=_interopRequireDefault(require("superagent")),_tar=_interopRequireDefault(require("tar")),_fsExtra=_interopRequireWildcard(require("fs-extra")),_log4js=_interopRequireDefault(require("log4js")),_queryString=_interopRequireDefault(require("query-string")),_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]}})});exports.localStore=_localStore;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 logout=function(){var a=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function a(){return _regenerator["default"].wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.prev=0,a.next=3,localStore.removeUserInfo();case 3:return a.next=5,localStore.removeAppInfo();case 5:return a.abrupt("return",{success:!0});case 8:throw a.prev=8,a.t0=a["catch"](0),new Error(a.t0.message);case 11:case"end":return a.stop();}},a,null,[[0,8]])}));return function(){return a.apply(this,arguments)}}();exports.logout=logout;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(/&quot;/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;|&amp;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;|&amp;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(/&amp;/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||i.startsWith("RemoteX"))){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;var isValidatedJsonString=function(a){if("string"==typeof a)try{var b=JSON.parse(a);return!!("object"==(0,_typeof2["default"])(b)&&b)}catch(a){return!1}};exports.isValidatedJsonString=isValidatedJsonString;var getAppxVersion=function(a){var b=a.extendInfo,c=void 0===b?"{}":b,d=a.rootPath,e="1.0";if(d)try{var f=_path["default"].join(d,"mini.project.json"),g=_fsExtra["default"].readJsonSync(f);e=g.enableAppxNg?"2.0":"1.0"}catch(a){}else if(c){var h,i;e=isValidatedJsonString(c)&&"YES"===(null===(h=JSON.parse(c))||void 0===h||null===(i=h.launchParams)||void 0===i?void 0:i.appxRouteFramework)?"2.0":"1.0"}return e};exports.getAppxVersion=getAppxVersion;
"use strict";var _exportNames={logger:!0,uuid:!0,delay:!0,getConfigType:!0,getUserInfo:!0,setUserInfo:!0,login:!0,logout:!0,defaultTinyappConfig:!0,getDefaultTinyappConfig:!0,getDefaultPluginConfig:!0,getTmpDirRoot:!0,getTmpDir:!0,cleanCache:!0,getVersion:!0,getUUID:!0,getZipFile:!0,getZipFromTar:!0,getPackageType:!0,looseJsonParse:!0,downloadFile:!0,appInfoToVariables:!0,variablesToappInfo:!0,parseDebugURL:!0,getUploadResult:!0,transformPluginParams:!0,isValidatedJsonString:!0,getAppxVersion:!0,localStore:!0};var _getUploadData=require("./getUploadData");var _localStore=_interopRequireWildcard(require("./localStorage"));var _excluded=["config"],_excluded2=["data"];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.logout=exports.login=exports.logger=exports.localStore=exports.isValidatedJsonString=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.getAppxVersion=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")),_archiver=_interopRequireDefault(require("archiver")),_isElectron=_interopRequireDefault(require("is-electron")),_os=require("os"),_path=_interopRequireDefault(require("path")),_superagent=_interopRequireDefault(require("superagent")),_tar=_interopRequireDefault(require("tar")),_fsExtra=_interopRequireWildcard(require("fs-extra")),_log4js=_interopRequireDefault(require("log4js")),_queryString=_interopRequireDefault(require("query-string")),_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]}})});exports.localStore=_localStore;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 logout=function(){var a=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function a(){return _regenerator["default"].wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.prev=0,a.next=3,localStore.removeUserInfo();case 3:return a.next=5,localStore.removeAppInfo();case 5:return a.abrupt("return",{success:!0});case 8:throw a.prev=8,a.t0=a["catch"](0),new Error(a.t0.message);case 11:case"end":return a.stop();}},a,null,[[0,8]])}));return function(){return a.apply(this,arguments)}}();exports.logout=logout;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 d=b.sent,e=d.text,b.abrupt("return",{data:e,success:!0});case 9:throw b.prev=9,b.t0=b["catch"](1),new Error(b.t0);case 12:case"end":return b.stop();}},b,null,[[1,9]])}));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(/&quot;/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;|&amp;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;|&amp;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(/&amp;/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||i.startsWith("RemoteX"))){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;var isValidatedJsonString=function(a){if("string"==typeof a)try{var b=JSON.parse(a);return!!("object"==(0,_typeof2["default"])(b)&&b)}catch(a){return!1}};exports.isValidatedJsonString=isValidatedJsonString;var getAppxVersion=function(a){var b=a.extendInfo,c=void 0===b?"{}":b,d=a.rootPath,e="1.0";if(d)try{var f=_path["default"].join(d,"mini.project.json"),g=_fsExtra["default"].readJsonSync(f);e=g.enableAppxNg?"2.0":"1.0"}catch(a){}else if(c){var h,i;e=isValidatedJsonString(c)&&"YES"===(null===(h=JSON.parse(c))||void 0===h||null===(i=h.launchParams)||void 0===i?void 0:i.appxRouteFramework)?"2.0":"1.0"}return e};exports.getAppxVersion=getAppxVersion;
{
"name": "@alipay-inc/mpaas-ide-openapi-common",
"version": "1.0.13-alpha.4",
"version": "1.0.13-alpha.5",
"main": "dist/index.js",

@@ -37,3 +37,3 @@ "repository": "https://code.alipay.com/mPaaS-IDE-Adaptor/mPaaS-IDE-openAPI.git",

},
"gitHead": "2edf8c8ce6fa550ca365fddd4ac98b4924657fdf"
"gitHead": "50ddb27293c459685139b54c5b42724dc6d2b67b"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc