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
3
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.0-beta.17 to 1.0.0-beta.18

16

dist/cloudBuild.js

@@ -1,11 +0,15 @@

"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:!0}),exports.remoteFileToLocal=exports.pollBuildStatusPrivate=exports.pollBuildStatusAlipay=exports.getCloudBuildData=exports.cloudBuildPrivate=exports.cloudBuildAlipay=exports.cloudBuild=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator")),_asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")),_superagent=_interopRequireDefault(require("superagent")),_path=_interopRequireDefault(require("path")),_fsExtra=_interopRequireDefault(require("fs-extra")),_=require("./"),POLL_DELAY_TIME=4e3,getCloudBuildData=function(a){var b=a.build_url,c=void 0===b?null:b;// 有build_url,即认为是私有化部署的云构建
"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 _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator")),_defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty")),_objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")),_asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")),_superagent=_interopRequireDefault(require("superagent")),_path=_interopRequireDefault(require("path")),_fsExtra=_interopRequireDefault(require("fs-extra")),_=require("./"),_archiver=_interopRequireDefault(require("archiver")),_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"],getCloudBuildData=function(a){var b=a.build_url,c=void 0===b?null:b;// 有build_url,即认为是私有化部署的云构建
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"};// 无build_url,则继续使用alipay云构建
};exports.getCloudBuildData=getCloudBuildData;// 云构建
var cloudBuild=/*#__PURE__*/function(){var a=(0,_asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function a(b){var c,d,e;return _regenerator["default"].wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(a.prev=0,c=b.file,d=b.config,_fsExtra["default"].existsSync(c)){a.next=4;break}throw new Error("\u6587\u4EF6\u4E0D\u5B58\u5728\uFF01");case 4:if(e=getCloudBuildData(d),"private"!==e.type){a.next=9;break}return a.next=8,cloudBuildPrivate(b);case 8:return a.abrupt("return",a.sent);case 9:return a.next=11,cloudBuildAlipay(b);case 11:return a.abrupt("return",a.sent);case 14:throw a.prev=14,a.t0=a["catch"](0),new Error(a.t0.message);case 17:case"end":return a.stop();}},a,null,[[0,14]])}));return function(){return a.apply(this,arguments)}}();// alipay 构建
exports.cloudBuild=cloudBuild;var cloudBuildAlipay=/*#__PURE__*/function(){var a=(0,_asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function a(b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t;return _regenerator["default"].wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.prev=0,(0,_.logger)("cloudBuild: alipay"),c=b.file,d=b.config,e=void 0===d?{}:d,f=b.adaptorId,g=void 0===f?"mPaaS":f,h=b.h5Id,i=e.appId,j=getCloudBuildData(e),k=j.CLOUD_BUILD_EXEC_URL,l=j.CLOUD_BUILD_POLL_URL,m={params:"[\"--scriptName\",\"buildpack\",\"--ADAPTOR_NAME\",\"adaptor-mpaas-".concat(g,"\",\"--limitation\",\"--preview\"]"),env:"{}",operationType:"build",extraInfo:JSON.stringify({appId:i,doneCommand:"pack",client:"IDE",scene:"IDE",fileFormat:"tar"})},(0,_.logger)("uploadBundle start",m),n={value:_fsExtra["default"].readFileSync(c),options:{filename:"".concat(i,".tar"),contentType:"application/zip"}},a.next=10,_superagent["default"].post(k).field(m).attach("file",n.value,n.options);case 10:if(o=a.sent,p=JSON.parse(o.text),p.success){a.next=14;break}throw new Error(p.msg);case 14:return q=p.data.taskId,a.next=17,pollBuildStatusAlipay({CLOUD_BUILD_POLL_URL:l,taskId:q});case 17:return r=a.sent,s=r.data,s=void 0===s?{}:s,t=s.zipFile,a.next=23,remoteFileToLocal({originFile:t,h5Id:h});case 23:return a.abrupt("return",a.sent);case 26:throw a.prev=26,a.t0=a["catch"](0),new Error(a.t0.message);case 29:case"end":return a.stop();}},a,null,[[0,26]])}));return function(){return a.apply(this,arguments)}}();// alipay 查询构建结果
var cloudBuild=/*#__PURE__*/function(){var a=(0,_asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function a(b){var c,d,e,f,g;return _regenerator["default"].wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.prev=0,c=b.config,d=b.file,e=(0,_objectWithoutProperties2["default"])(b,_excluded),f=getCloudBuildData(c),a.next=6,getFile({file:d,type:f.type});case 6:if(d=a.sent,g=_objectSpread(_objectSpread({},e),{},{file:d}),"private"!==f.type){a.next=13;break}return(0,_.logger)("cloudBuild: private"),a.next=12,cloudBuildPrivate(g);case 12:return a.abrupt("return",a.sent);case 13:return(0,_.logger)("cloudBuild: alipay"),a.next=16,cloudBuildAlipay(g);case 16:return a.abrupt("return",a.sent);case 19:throw a.prev=19,a.t0=a["catch"](0),new Error(a.t0.message);case 22:case"end":return a.stop();}},a,null,[[0,19]])}));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:_path["default"].basename(b)}),g.finalize()})},getFile=/*#__PURE__*/function(){var a=(0,_asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function a(b){var c,d,e,f,g,h,i;return _regenerator["default"].wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(c=b.file,d=b.type,a.prev=1,_fsExtra["default"].existsSync(c)){a.next=4;break}throw new Error("\u6587\u4EF6\u4E0D\u5B58\u5728\uFF01");case 4:if(!_fsExtra["default"].lstatSync(c).isFile()){a.next=8;break}if(".amr"===_path["default"].extname(c)){a.next=7;break}throw new Error("\u6587\u4EF6\u683C\u5F0F\u9519\u8BEF\uFF01");case 7:return a.abrupt("return",c);case 8:if(!_fsExtra["default"].lstatSync(c).isDirectory()){a.next=22;break}return e=(0,_.getTmpDir)(),f=(0,_.getTmpDir)(),_fsExtra["default"].copySync(c,e),a.next=14,compressFile({resourceFile:e,targetFile:_path["default"].join(f,"dist.tar"),type:"directory"});case 14:if(g=a.sent,"alipay"!==d){a.next=17;break}return a.abrupt("return",g);case 17:return h=(0,_.getTmpDir)(),a.next=20,compressFile({resourceFile:_path["default"].join(f,"dist.tar"),targetFile:_path["default"].join(h,"dist.amr")});case 20:return i=a.sent,a.abrupt("return",i);case 22:return a.abrupt("return",c);case 25:throw a.prev=25,a.t0=a["catch"](1),new Error(a.t0.message);case 28:case"end":return a.stop();}},a,null,[[1,25]])}));return function(){return a.apply(this,arguments)}}();// 处理入参的文件,可以支持路径/amr
exports.getFile=getFile;// alipay 构建
var cloudBuildAlipay=/*#__PURE__*/function(){var a=(0,_asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function a(b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t;return _regenerator["default"].wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.prev=0,c=b.file,d=b.config,e=void 0===d?{}:d,f=b.adaptorId,g=void 0===f?"mPaaS":f,h=b.h5Id,i=e.appId,j=getCloudBuildData(e),k=j.CLOUD_BUILD_EXEC_URL,l=j.CLOUD_BUILD_POLL_URL,m={params:"[\"--scriptName\",\"buildpack\",\"--ADAPTOR_NAME\",\"adaptor-mpaas-".concat(g,"\",\"--limitation\",\"--preview\"]"),env:"{}",operationType:"build",extraInfo:JSON.stringify({appId:i,doneCommand:"pack",client:"IDE",scene:"IDE",fileFormat:"tar"})},(0,_.logger)("uploadBundle start",m),n={value:_fsExtra["default"].readFileSync(c),options:{filename:"".concat(i,".tar"),contentType:"application/zip"}},a.next=9,_superagent["default"].post(k).field(m).attach("file",n.value,n.options);case 9:if(o=a.sent,p=JSON.parse(o.text),p.success){a.next=13;break}throw new Error(p.msg);case 13:return q=p.data.taskId,a.next=16,pollBuildStatusAlipay({CLOUD_BUILD_POLL_URL:l,taskId:q});case 16:return r=a.sent,s=r.data,s=void 0===s?{}:s,t=s.zipFile,a.next=22,remoteFileToLocal({originFile:t,h5Id:h});case 22:return a.abrupt("return",a.sent);case 25:throw a.prev=25,a.t0=a["catch"](0),new Error(a.t0.message);case 28:case"end":return a.stop();}},a,null,[[0,25]])}));return function(){return a.apply(this,arguments)}}();// alipay 查询构建结果
exports.cloudBuildAlipay=cloudBuildAlipay;var pollBuildStatusAlipay=/*#__PURE__*/function(){var a=(0,_asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function a(b){var c,d,e,f;return _regenerator["default"].wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return c=b.CLOUD_BUILD_POLL_URL,d=b.taskId,a.prev=1,a.next=4,_superagent["default"].get(c).query({taskId:d});case 4:if(e=a.sent,f=JSON.parse(e.text),f.success){a.next=8;break}throw new Error(f.msg);case 8:if("COMPLETE"!==f.status){a.next=10;break}return a.abrupt("return",f);case 10:;// 构建未完成,轮询查询
return a.next=13,(0,_.delay)(POLL_DELAY_TIME);case 13:return a.next=15,pollBuildStatusAlipay({CLOUD_BUILD_POLL_URL:c,taskId:d});case 15:return a.abrupt("return",a.sent);case 18:throw a.prev=18,a.t0=a["catch"](1),new Error(a.t0.message);case 21:case"end":return a.stop();}},a,null,[[1,18]])}));return function(){return a.apply(this,arguments)}}();// private 构建
exports.pollBuildStatusAlipay=pollBuildStatusAlipay;var cloudBuildPrivate=/*#__PURE__*/function(){var a=(0,_asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function a(b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;return _regenerator["default"].wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.prev=0,(0,_.logger)("cloudBuild: private"),c=b.file,d=b.config,e=void 0===d?{}:d,f=b.h5Id,g=e.appId,h=e.workspaceId,i=e.tenantId,j=getCloudBuildData(e),k=j.CLOUD_BUILD_EXEC_URL,l=j.CLOUD_BUILD_POLL_URL,m={value:_fsExtra["default"].readFileSync(c),options:{filename:"".concat(g,".tar"),contentType:"application/zip"}},a.next=8,_superagent["default"].post(k).field({appId:g,workspaceId:h,tenantId:i}).attach("file",m.value,m.options);case 8:return n=a.sent,o=JSON.parse(n.text),a.next=12,pollBuildStatusPrivate({CLOUD_BUILD_POLL_URL:l,buildId:o.data});case 12:return p=a.sent,q=p.data.downloadUrl,a.next=16,remoteFileToLocal({originFile:q,h5Id:f});case 16:return a.abrupt("return",a.sent);case 19:throw a.prev=19,a.t0=a["catch"](0),new Error(a.t0.message);case 22:case"end":return a.stop();}},a,null,[[0,19]])}));return function(){return a.apply(this,arguments)}}();// private 查询构建结果
exports.cloudBuildPrivate=cloudBuildPrivate;var pollBuildStatusPrivate=/*#__PURE__*/function(){var a=(0,_asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function a(b){var c,d,e,f,g;return _regenerator["default"].wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return c=b.CLOUD_BUILD_POLL_URL,d=b.buildId,a.prev=1,a.next=4,_superagent["default"].get(c).query({buildId:d});case 4:if(f=a.sent,g=JSON.parse(f.text),g.success){a.next=8;break}throw new Error(g.message);case 8:if("SUCCESS"!==(null===g||void 0===g||null===(e=g.data)||void 0===e?void 0:e.result)){a.next=10;break}return a.abrupt("return",g);case 10:;// 构建未完成,轮询查询
return a.next=13,(0,_.delay)(POLL_DELAY_TIME);case 13:return a.next=15,pollBuildStatusPrivate({CLOUD_BUILD_POLL_URL:c,buildId:d});case 15:return a.abrupt("return",a.sent);case 18:throw a.prev=18,a.t0=a["catch"](1),new Error(a.t0.message);case 21:case"end":return a.stop();}},a,null,[[1,18]])}));return function(){return a.apply(this,arguments)}}();// 将远程的tar文件转换为符合mPaaS条件的zip文件
exports.pollBuildStatusAlipay=pollBuildStatusAlipay;var cloudBuildPrivate=/*#__PURE__*/function(){var a=(0,_asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function a(b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;return _regenerator["default"].wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.prev=0,c=b.file,d=b.config,e=void 0===d?{}:d,f=b.h5Id,g=e.appId,h=e.workspaceId,i=e.tenantId,j=getCloudBuildData(e),k=j.CLOUD_BUILD_EXEC_URL,l=j.CLOUD_BUILD_POLL_URL,m={value:_fsExtra["default"].readFileSync(c),options:{filename:"".concat(g,".tar"),contentType:"application/zip"}},a.next=7,_superagent["default"].post(k).field({appId:g,workspaceId:h,tenantId:i}).attach("file",m.value,m.options);case 7:return n=a.sent,o=JSON.parse(n.text),a.next=11,pollBuildStatusPrivate({CLOUD_BUILD_POLL_URL:l,buildId:o.data});case 11:return p=a.sent,q=p.data.downloadUrl,a.next=15,remoteFileToLocal({originFile:q,h5Id:f});case 15:return a.abrupt("return",a.sent);case 18:throw a.prev=18,a.t0=a["catch"](0),new Error(a.t0.message);case 21:case"end":return a.stop();}},a,null,[[0,18]])}));return function(){return a.apply(this,arguments)}}();// private 查询构建结果
exports.cloudBuildPrivate=cloudBuildPrivate;var pollBuildStatusPrivate=/*#__PURE__*/function(){var a=(0,_asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function a(b){var c,d,e,f,g,h,i;return _regenerator["default"].wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return c=b.CLOUD_BUILD_POLL_URL,d=b.buildId,a.prev=1,a.next=4,_superagent["default"].get(c).query({buildId:d});case 4:if(g=a.sent,h=JSON.parse(g.text),h.success){a.next=8;break}throw new Error(h.message);case 8:if("FAILURE"!==(null===h||void 0===h||null===(e=h.data)||void 0===e?void 0:e.result)){a.next=10;break}throw new Error(null===h||void 0===h||null===(i=h.data)||void 0===i?void 0:i.logUrl);case 10:;// 构建成功,直接返回构建结果
if("SUCCESS"!==(null===h||void 0===h||null===(f=h.data)||void 0===f?void 0:f.result)){a.next=13;break}return a.abrupt("return",h);case 13:;// 构建未完成,轮询查询
return a.next=16,(0,_.delay)(POLL_DELAY_TIME);case 16:return a.next=18,pollBuildStatusPrivate({CLOUD_BUILD_POLL_URL:c,buildId:d});case 18:return a.abrupt("return",a.sent);case 21:throw a.prev=21,a.t0=a["catch"](1),new Error(a.t0.message);case 24:case"end":return a.stop();}},a,null,[[1,21]])}));return function(){return a.apply(this,arguments)}}();// 将远程的tar文件转换为符合mPaaS条件的zip文件
exports.pollBuildStatusPrivate=pollBuildStatusPrivate;var remoteFileToLocal=/*#__PURE__*/function(){var a=(0,_asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function a(b){var c,d,e,f,g,h;return _regenerator["default"].wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return c=b.originFile,d=b.h5Id,a.prev=1,a.next=4,(0,_.downloadFile)({url:c});case 4:return e=a.sent,f=e.data,a.next=8,(0,_.getZipFromTar)({tarFilePath:f,h5Id:d});case 8:return g=a.sent,h=g.data,a.abrupt("return",{data:{file:h,originFile:c},success:!0});case 13:throw a.prev=13,a.t0=a["catch"](1),new Error(a.t0.message);case 16:case"end":return a.stop();}},a,null,[[1,13]])}));return function(){return a.apply(this,arguments)}}();exports.remoteFileToLocal=remoteFileToLocal;

@@ -1,6 +0,7 @@

"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _exportNames={delay:!0,defaultTinyappConfig:!0,getDefaultTinyappConfig:!0,getTmpDirRoot:!0,getTmpDir:!0,getVersion:!0,getUUID:!0,getZipFile:!0,getZipFromTar:!0,logger:!0,getPackageType:!0,looseJsonParse:!0,downloadFile:!0,getUploadData:!0};Object.defineProperty(exports,"__esModule",{value:!0});exports.looseJsonParse=exports.logger=exports.getZipFromTar=exports.getZipFile=exports.getVersion=exports.getUploadData=exports.getUUID=exports.getTmpDirRoot=exports.getTmpDir=exports.getPackageType=exports.getDefaultTinyappConfig=exports.downloadFile=exports.delay=exports.defaultTinyappConfig=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator")),_toConsumableArray2=_interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")),_asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")),_slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")),_defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty")),_superagent=_interopRequireDefault(require("superagent")),_tar=_interopRequireDefault(require("tar")),_archiver=_interopRequireDefault(require("archiver")),_os=require("os"),_path=_interopRequireDefault(require("path")),_uuid=_interopRequireDefault(require("uuid")),_progress=_interopRequireDefault(require("progress")),_fsExtra=require("fs-extra"),_cloudBuild=require("./cloudBuild");Object.keys(_cloudBuild).forEach(function(a){"default"===a||"__esModule"===a||Object.prototype.hasOwnProperty.call(_exportNames,a)||a in exports&&exports[a]===_cloudBuild[a]||Object.defineProperty(exports,a,{enumerable:!0,get:function get(){return _cloudBuild[a]}})});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 tmpdirRoot="".concat((0,_os.tmpdir)(),"/.mpaas_ide_openapi"),delay=function(a){return new Promise(function(b){return setTimeout(b,a)})};exports.delay=delay;// 小程序默认配置
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _exportNames={delay:!0,defaultTinyappConfig:!0,getDefaultTinyappConfig:!0,getTmpDirRoot:!0,getTmpDir:!0,cleanCache:!0,getVersion:!0,getUUID:!0,getZipFile:!0,getZipFromTar:!0,logger:!0,getPackageType:!0,looseJsonParse:!0,downloadFile:!0,getUploadData:!0};Object.defineProperty(exports,"__esModule",{value:!0});exports.looseJsonParse=exports.logger=exports.getZipFromTar=exports.getZipFile=exports.getVersion=exports.getUploadData=exports.getUUID=exports.getTmpDirRoot=exports.getTmpDir=exports.getPackageType=exports.getDefaultTinyappConfig=exports.downloadFile=exports.delay=exports.defaultTinyappConfig=exports.cleanCache=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator")),_toConsumableArray2=_interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")),_asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")),_slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")),_defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty")),_superagent=_interopRequireDefault(require("superagent")),_tar=_interopRequireDefault(require("tar")),_archiver=_interopRequireDefault(require("archiver")),_os=require("os"),_path=_interopRequireDefault(require("path")),_uuid=_interopRequireDefault(require("uuid")),_progress=_interopRequireDefault(require("progress")),_fsExtra=require("fs-extra"),_cloudBuild=require("./cloudBuild");Object.keys(_cloudBuild).forEach(function(a){"default"===a||"__esModule"===a||Object.prototype.hasOwnProperty.call(_exportNames,a)||a in exports&&exports[a]===_cloudBuild[a]||Object.defineProperty(exports,a,{enumerable:!0,get:function get(){return _cloudBuild[a]}})});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 tmpdirRoot="".concat((0,_os.tmpdir)(),"/.mpaas_ide_openapi"),delay=function(a){return new Promise(function(b){return setTimeout(b,a)})};exports.delay=delay;// 小程序默认配置
var defaultTinyappConfig={appCode:"",autoInstall:1,clientVersionMax:"",clientVersionMin:"0.0.0.0;0.0.0.0",downloadUrl:"",debugUrl:"",extendInfo:"",extraData:"{\"enableKeepAlive\":\"0\",\"enableOptionMenu\":\"1\",\"enableTabBar\":\"0\",\"iconUrl\":\"\",\"resourceType\":\"4\"}",fallbackBaseUrl:"",fileSize:"",gmtCreate:"",gmtModified:"",h5Version:"1.0.0.0",installType:1,lazyLoad:0,mainUrl:"/index.html#pages/index/index",md5:"",memo:"",modifier:"success",platform:"all",publishPeriod:5,releaseVersion:"",resourceType:"4",status:1};exports.defaultTinyappConfig=defaultTinyappConfig;var getDefaultTinyappConfig=function(a){return{data:_objectSpread(_objectSpread({},defaultTinyappConfig),a),success:!0}};// 获取根目录
exports.getDefaultTinyappConfig=getDefaultTinyappConfig;var getTmpDirRoot=function(){var a=(0,_fsExtra.existsSync)(tmpdirRoot);return a||(0,_fsExtra.mkdirSync)(tmpdirRoot),tmpdirRoot};// 获取临时文件路径
exports.getTmpDirRoot=getTmpDirRoot;var getTmpDir=function(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"appid",b=getTmpDirRoot(),c="".concat(b,"/").concat(a,"_").concat(new Date().valueOf(),"_").concat(_uuid["default"].v4()),d=(0,_fsExtra.existsSync)(c);return d||(0,_fsExtra.mkdirSync)(c),c};// 版本号处理
exports.getTmpDir=getTmpDir;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(".");// 格式化
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["default"].v4()),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)}};// 创建一个临时文件夹

@@ -7,0 +8,0 @@ // export const getTmpDir = () => path.join(tmpdir(), uuid.v4());

{
"name": "@alipay-inc/mpaas-ide-openapi-common",
"version": "1.0.0-beta.17",
"version": "1.0.0-beta.18",
"main": "dist/index.js",

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

},
"gitHead": "949681ae49bc5d70f1a7fe0200c774e954a43ee9"
"gitHead": "ba3cc232618da8fb0e73fc24bb289f925966684b"
}
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