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
0
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.17-alpha.0 to 1.0.31-alpha.0

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,q,r,s,t,u,v,w,x;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=a.plugin,g=void 0===f?"":f,h=(0,_.getTmpDir)(),i=_path2["default"].join(h,"".concat(e)),j=_path2["default"].join(i,"".concat(e)),k=_path2["default"].join(j,"subpackages"),l=_path2["default"].join(k,"subpackage.json"),_fsExtra["default"].existsSync(j)&&_fsExtra["default"].removeSync(j),_fsExtra["default"].ensureDirSync(j),_fsExtra["default"].ensureDirSync(k),b.prev=9,b.next=12,remoteFileToLocal({originFile:c,h5Id:e});case 12:if(m=b.sent,n=m.file,o=_path2["default"].join(j,_path2["default"].basename(n)),p={subpackageFlag:!1},q="",!g){b.next=25;break}return b.next=20,(0,_.downloadFile)({url:g});case 20:r=b.sent,s=r.data,t=r.success,u=void 0===t||t,u&&(q=s);case 25:if(!(d&&d.length)){b.next=43;break}return _fsExtra["default"].moveSync(n,o),p.subpackageFlag=!0,v=d.length,b.next=31,pollGetPackageFile(v,d);case 31:return w={},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&&(w[d]=e),f=_path2["default"].join(k,_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(l,w),x=_path2["default"].join(h,"".concat(e,".zip")),b.next=37,compressFile({resourceFile:i,targetFile:x,type:"directory"});case 37:console.log("SUBPACAKGES_ARR",SUBPACAKGES_ARR,w,l),g&&(p.pluginFile=q,p.pluginOriginFile=g),p.file=x,p.originFile="",b.next=46;break;case 43:g&&(p.pluginFile=q,p.pluginOriginFile=g),p.file=n,p.originFile=c;case 46:return console.log("get result:",p),SUBPACAKGES_ARR=[],b.abrupt("return",p);case 51:throw b.prev=51,b.t0=b["catch"](9),new Error(b.t0.message);case 54:case"end":return b.stop();}},b,null,[[9,51]])}));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,D;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=u,C=y,b.next=30,mergePackageFile({zipFile:B,subPackages:w,h5Id:h,plugin:C});case 30:return D=b.sent,_.logger.info("get mergePackageFileJSON:",D),b.abrupt("return",{data:_objectSpread(_objectSpread({},D),{},{appxVersion:(0,_.getAppxVersion)({extendInfo:A}),originData:s}),succes:!0});case 35:throw b.prev=35,b.t0=b["catch"](0),new Error(b.t0.message);case 38:case"end":return b.stop();}},b,null,[[0,35]])}));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 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;return _regenerator["default"].wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.prev=0,e=a.file,f=a.config,g=void 0===f?{}:f,h=a.h5Id,i=g.appId,j=g.workspaceId,k=g.tenantId,l=getCloudBuildData(g),m=l.CLOUD_BUILD_EXEC_URL,n=l.CLOUD_BUILD_POLL_URL,o={value:_fsExtra["default"].readFileSync(e),options:{filename:"".concat(i,".amr"),contentType:"application/zip"}},_.logger.info("cloudBuild req",{appId:i,workspaceId:j,tenantId:k,h5Id:h}),b.next=8,_superagent["default"].post(m).field({appId:i,workspaceId:j,tenantId:k,h5Id:h}).attach("file",o.value,o.options);case 8:if(p=b.sent,q=p.body,r=void 0===q?{}:q,_.logger.info("cloudBuild res",r),r.success){b.next=14;break}throw new Error(r.message);case 14:return b.next=16,pollBuildStatusPrivate({CLOUD_BUILD_POLL_URL:n,buildId:r.data});case 16:return s=b.sent,t=s.data,u=t.downloadUrl,v=t.pluginDownloadUrl,w=t.subPackages,x=void 0===w?[]:w,y=t.cubePackage,z=(null===y||void 0===y?void 0:y.downloadUrl)||u,A=v,b.next=23,mergePackageFile({zipFile:z,subPackages:x,h5Id:h,plugin:A});case 23:return B=b.sent,b.abrupt("return",{data:_objectSpread(_objectSpread({},B),{},{appxVersion:(0,_.getAppxVersion)({extendInfo:(null===t||void 0===t||null===(c=t.miniBuiltInfoContent)||void 0===c||null===(d=c.packageInfo)||void 0===d?void 0:d.extendInfo)||"{}"}),originData:s}),succes:!0});case 27:throw b.prev=27,b.t0=b["catch"](0),new Error(b.t0.message);case 30:case"end":return b.stop();}},b,null,[[0,27]])}));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,r,s,t,u,v,w,x;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=a.plugin,g=void 0===f?"":f,h=(0,_.getTmpDir)(),i=_path2["default"].join(h,"".concat(e)),j=_path2["default"].join(i,"".concat(e)),k=_path2["default"].join(j,"subpackages"),l=_path2["default"].join(k,"subpackage.json"),_fsExtra["default"].existsSync(j)&&_fsExtra["default"].removeSync(j),_fsExtra["default"].ensureDirSync(j),_fsExtra["default"].ensureDirSync(k),b.prev=9,b.next=12,remoteFileToLocal({originFile:c,h5Id:e});case 12:if(m=b.sent,n=m.file,o=_path2["default"].join(j,_path2["default"].basename(n)),p={subpackageFlag:!1},q="",!g){b.next=25;break}return b.next=20,(0,_.downloadFile)({url:g});case 20:r=b.sent,s=r.data,t=r.success,u=void 0===t||t,u&&(q=s);case 25:if(!(d&&d.length)){b.next=43;break}return _fsExtra["default"].moveSync(n,o),p.subpackageFlag=!0,v=d.length,b.next=31,pollGetPackageFile(v,d);case 31:return w={},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&&(w[d]=e),f=_path2["default"].join(k,_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(l,w),x=_path2["default"].join(h,"".concat(e,".zip")),b.next=37,compressFile({resourceFile:i,targetFile:x,type:"directory"});case 37:console.log("SUBPACAKGES_ARR",SUBPACAKGES_ARR,w,l),g&&(p.pluginFile=q,p.pluginOriginFile=g),p.file=x,p.originFile="",b.next=46;break;case 43:g&&(p.pluginFile=q,p.pluginOriginFile=g),p.file=n,p.originFile=c;case 46:return console.log("get result:",p),SUBPACAKGES_ARR=[],b.abrupt("return",p);case 51:throw b.prev=51,b.t0=b["catch"](9),new Error(b.t0.message);case 54:case"end":return b.stop();}},b,null,[[9,51]])}));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,D,E,F;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=a.isCube,j=void 0!==i&&i,k=e.appId,l=getCloudBuildData(e),m=l.CLOUD_BUILD_EXEC_URL,n=l.CLOUD_BUILD_POLL_URL,o={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"})},j&&(o.extraBuildConfig=JSON.stringify({allowCube:!0})),p={value:_fsExtra["default"].readFileSync(c),options:{filename:"".concat(h,".tar"),contentType:"application/zip"}},_.logger.info("cloudBuild req",o),b.next=10,_superagent["default"].post(m).field(o).attach("file",p.value,p.options);case 10:if(q=b.sent,r=q.body,s=void 0===r?{}:r,_.logger.info("cloudBuild res",s),s.success){b.next=16;break}throw new Error(s.msg);case 16:return t=s.data.taskId,b.next=19,pollBuildStatusAlipay({CLOUD_BUILD_POLL_URL:n,taskId:t});case 19:return u=b.sent,v=u.data,v=void 0===v?{}:v,w=v.zipFile,x=v.subPackages,y=void 0===x?[]:x,z=v.plugin,z=void 0===z?{}:z,A=z.artifactUrl,B=v.uploadParams,B=void 0===B?{}:B,C=B.extendInfo,D=w,E=A,b.next=31,mergePackageFile({zipFile:D,subPackages:y,h5Id:h,plugin:E});case 31:return F=b.sent,_.logger.info("get mergePackageFileJSON:",F),b.abrupt("return",{data:_objectSpread(_objectSpread({},F),{},{appxVersion:(0,_.getAppxVersion)({extendInfo:C}),originData:u}),succes:!0});case 36:throw b.prev=36,b.t0=b["catch"](0),new Error(b.t0.message);case 39:case"end":return b.stop();}},b,null,[[0,36]])}));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 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;return _regenerator["default"].wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.prev=0,e=a.file,f=a.config,g=void 0===f?{}:f,h=a.h5Id,i=g.appId,j=g.workspaceId,k=g.tenantId,l=getCloudBuildData(g),m=l.CLOUD_BUILD_EXEC_URL,n=l.CLOUD_BUILD_POLL_URL,o={value:_fsExtra["default"].readFileSync(e),options:{filename:"".concat(i,".amr"),contentType:"application/zip"}},_.logger.info("cloudBuild req",{appId:i,workspaceId:j,tenantId:k,h5Id:h}),b.next=8,_superagent["default"].post(m).field({appId:i,workspaceId:j,tenantId:k,h5Id:h}).attach("file",o.value,o.options);case 8:if(p=b.sent,q=p.body,r=void 0===q?{}:q,_.logger.info("cloudBuild res",r),r.success){b.next=14;break}throw new Error(r.message);case 14:return b.next=16,pollBuildStatusPrivate({CLOUD_BUILD_POLL_URL:n,buildId:r.data});case 16:return s=b.sent,t=s.data,u=t.downloadUrl,v=t.pluginDownloadUrl,w=t.subPackages,x=void 0===w?[]:w,y=t.cubePackage,z=(null===y||void 0===y?void 0:y.downloadUrl)||u,A=v,b.next=23,mergePackageFile({zipFile:z,subPackages:x,h5Id:h,plugin:A});case 23:return B=b.sent,b.abrupt("return",{data:_objectSpread(_objectSpread({},B),{},{appxVersion:(0,_.getAppxVersion)({extendInfo:(null===t||void 0===t||null===(c=t.miniBuiltInfoContent)||void 0===c||null===(d=c.packageInfo)||void 0===d?void 0:d.extendInfo)||"{}"}),originData:s}),succes:!0});case 27:throw b.prev=27,b.t0=b["catch"](0),new Error(b.t0.message);case 30:case"end":return b.stop();}},b,null,[[0,27]])}));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;
{
"name": "@alipay-inc/mpaas-ide-openapi-common",
"version": "1.0.17-alpha.0",
"version": "1.0.31-alpha.0",
"main": "dist/index.js",

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

},
"gitHead": "fe582362185110627231c2e4ef30c87a517d4121"
"gitHead": "dfa9a212425f8f091f99b47de5d153ec7963d332"
}
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