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

@sumor/utils

Package Overview
Dependencies
Maintainers
1
Versions
99
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sumor/utils - npm Package Compare versions

Comparing version 11.0.29 to 11.0.30

2

index.js

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

!function(e){var t={};function n(i){if(t[i])return t[i].exports;var o=t[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:i})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t,n){const i=n(5),o=n(6),r=n(7),a=n(8),s=n(9),c=n(10);e.exports=class{constructor(){}normalize(e){let t=a.normalize(e);return t=t.replace(/\\/g,"/")}async download(e,t){await new Promise(function(n){s(e).pipe(i.createWriteStream(t)).on("close",function(){n()})})}async find(e,t){return t=t||{},await new Promise(function(n){c(e,t,function(e,t){for(let e in t)t[e]=a.normalize(t[e]),t[e]=t[e].replace(/\\/g,"/");n(t)})})}async zip(e,t,n){return await new Promise(function(r,a){let s=i.createWriteStream(t),c=o("zip",{zlib:{level:9}});s.on("close",function(){r()}),c.pipe(s),c.glob("**",{cwd:e,ignore:n||[]}),c.finalize()})}async unzip(e,t){return e=a.normalize(e),await new Promise(function(n,i){r(e,{dir:t},function(e){n()})})}async exist(e){return await new Promise(function(t){i.access(e,function(e){t(!e)})})}async isDirectory(e){return(await this.info(e)).isDirectory()}async info(e){return await new Promise(function(t,n){i.open(e,"a",function(e,o){e&&n(error),i.fstat(o,function(e,r){e&&n(error),i.close(o,function(){t(r)})})})})}async move(e,t){await i.move(e,t)}async delete(e){await i.remove(e)}async ensureFile(e){await i.ensureFile(e)}async ensureDir(e){await i.ensureDir(e)}async copy(e,t,n){await i.copy(e,t,n)}async writeFile(e,t){return await new Promise((n,o)=>{i.writeFile(e,t,e=>{e?o(e):n()})})}async appendFile(e,t){return await new Promise((n,o)=>{i.appendFile(e,t,e=>{e?o(e):n()})})}async readFile(e,t){if(await this.exist(e))return await new Promise(function(n){i.readFile(e,t,(e,t)=>{n(t)})})}async readJson(e){return await i.readJson(e)}async getExt(e){return a.extname(e)}}},function(e,t,n){const i=n(11),o=n(12),r=n(13);e.exports=class{constructor(){this.triggerQueue={}}uuid(){return o.v4().replace(/-/g,"")}md5(e){const t=i.createHash("md5");return t.update(e),t.digest("hex")}async qrcode(e){let t={errorCorrectionLevel:"H",rendererOpts:{quality:.8},color:{light:"#f8f8f8"}};return await new Promise(function(n,i){r.toDataURL(e,t,function(e,t){e?i(e):n(t)})})}getTimestamp(){return Math.round((new Date).getTime()/1e3)}async delay(e){return e=e||1e3,await new Promise(function(t){setTimeout(function(){t()},e)})}formatTime(e,t,n){let i;if(i="number"==typeof e?1e3*e:e.getTime(),"number"!=typeof(n=void 0!==n?n:-(new Date).getTimezoneOffset()))throw{code:"NOT_SUPPORT_STRING_TIMEZORE",message:"暂不支持字符串格式时区,请输入分钟数"};i+=60*n*1e3;const o=new Date(i),r={"M+":o.getUTCMonth()+1,"d+":o.getUTCDate(),"W+":function(e){switch(e.getUTCDay()){case 0:return"日";case 1:return"一";case 2:return"二";case 3:return"三";case 4:return"四";case 5:return"五";case 6:return"六"}}(o),"h+":o.getUTCHours(),"m+":o.getUTCMinutes(),"s+":o.getUTCSeconds(),"q+":Math.floor((o.getUTCMonth()+3)/3),S:("00"+o.getUTCMilliseconds()).slice(-3)};for(var a in/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(o.getUTCFullYear()+"").substr(4-RegExp.$1.length))),r)new RegExp("("+a+")").test(t)&&(t=t.replace(RegExp.$1,1===RegExp.$1.length?r[a]:("00"+r[a]).substr((""+r[a]).length)));return t}random(e,t){const n=(t||"ABCDEFGHIJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz23456789!@#$%^&*()_+-=").split("");let i="";for(let t=0;t<e;t++){i+=n[Math.floor(Math.random()*n.length)]}return i}toCamelCase(e,t,n){t=t||"-";let i=(e=e.toLowerCase()).split(t);e="";for(let t in i){let n=i[t];e+=n.replace(n[0],n[0].toUpperCase())}return n&&(e=e.replace(e[0],e[0].toLowerCase())),e}fromCamelCase(e,t){t=t||"-";const n=[];for(let t=0;t<e.length;t++){const o=e.charAt(t),r=o.toLowerCase();0===n.length?n.push(r):((i=o)>="A"&&i<="Z"&&n.push(""),n[n.length-1]=n[n.length-1]+=r)}var i;return n.join(t)}trigger(e){const t=this.uuid(),n=this.triggerQueue;return async()=>{if(n[t]||(n[t]={running:!1,again:!1}),n[t].running)n[t].again=!0;else{n[t].running=!0;const i=async()=>{await e(),n[t].again?(n[t].again=!1,await i()):delete n[t]};await i()}}}}},function(e,t,n){e.exports=n(3)},function(e,t,n){global.sumor_output=n(4)},function(e,t,n){const i=n(0),o=n(1),r=n(14),a=n(16),s=n(17),c=new i,u=new o;e.exports={file:c,basic:u,cmd:r,Log:a,SSH:s}},function(e,t){e.exports=require("fs-extra")},function(e,t){e.exports=require("archiver")},function(e,t){e.exports=require("extract-zip")},function(e,t){e.exports=require("path")},function(e,t){e.exports=require("download")},function(e,t){e.exports=require("glob")},function(e,t){e.exports=require("crypto")},function(e,t){e.exports=require("uuid")},function(e,t){e.exports=require("qrcode")},function(e,t,n){const{exec:i,spawn:o}=n(15);e.exports={exec:async(e,t)=>(t||(t={}),await new Promise(function(n,o){i(e,t,function(e,t,i){e?o(i):n(t)})})),spawn:async(e,t,n)=>{let i=e,r=(t=t||{}).args;return r||(r=e.split(" "),i=r[0],r.shift()),await new Promise(function(e,a){const s=o(i,r,t);let c="",u="";s.stdout.on("data",async e=>{c+=e.toString(),n&&n(e.toString())}),s.stderr.on("data",async e=>{c+=e.toString(),u+=e.toString(),n&&n(e.toString())}),s.on("close",async t=>{0!==t?a(u):e(c)})})}}},function(e,t){e.exports=require("child_process")},function(e,t,n){const i=n(0),o=n(1),r=new i,a=new o;e.exports=class{constructor(e,t){this.root=e,this.name=t,this.message=[],this.updating=!1}async new(){const e=a.getTimestamp();this.path=`${this.root}/logs/${this.name}-${e}.log`,await r.ensureFile(this.path)}async load(){const e=await r.find(`${this.name}-*.log`,{cwd:`${this.root}/logs`});e.length>0?this.path=`${this.root}/logs/${e[e.length-1]}`:await this.new()}write(e){this.message.push(e),this.update()}async update(){if(!this.updating){if(this.updating=!0,this.path||await this.load(),this.message.length>0){const e=this.message.join();this.message=[],await r.appendFile(this.path,e)}this.updating=!1,this.message.length>0&&this.update()}}}},function(e,t,n){const i=n(18),o=n(0),r=n(1),a=(new o,new r);e.exports=class{constructor(e){this.config=e}async connect(){await new Promise((e,t)=>{this.connection=new i,this.connection.connect(this.config).then(function(){e()}).catch(e=>{t(e)})})}async disconnect(){this.connection.dispose()}async exec(e,t){return(t=t||{}).cwd=t.cwd||"~",await this.connection.execCommand(e,t)}putFile(e,t){return this.connection.putFile(e,t)}async putBufferFile(e,t){const n=`${a.uuid()}.tmp`,i=`${__dirname}/tmp/${n}`;await e.ensureFile(i),await e.writeFile(i,e),await this.connection.putFile(i,t),await e.delete(i)}getFile(e,t){return this.connection.getFile(e,t)}async unzip(e,t){try{await this.connection.exec(`unzip -o ${e} -d ${t}`)}catch(n){n.message.indexOf("command not found")&&(await this.install("zip"),await this.connection.exec(`unzip -o ${e} -d ${t}`))}}async delete(e){await this.connection.exec(`rm -rf ${e}`)}async checkSoftware(e){let t=!0;try{await this.connection.exec(e+" --help")}catch(e){e.message.indexOf("command not found")&&(t=!1)}return t}async install(e){console.log(`installing software ${e}`),await this.connection.exec("apt-get update"),await this.connection.exec(`apt-get install ${e} -y`),console.log(`software ${e} installed`)}async checkPort(e){return""===await this.connection.exec(`lsof -i:${e}`)}async randomPort(){const e=1e4+Math.floor(1e4*Math.random());return await this.checkPort(e)?e:await this.randomPort()}}},function(e,t){e.exports=require("node-ssh")}]),global.dynamicRequire=require;var sumor_output=global.sumor_output;delete global.sumor_output,module.exports=sumor_output;
!function(e){var t={};function n(i){if(t[i])return t[i].exports;var o=t[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:i})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t,n){const i=n(5),o=n(6),r=n(7),a=n(8),s=n(9),c=n(10);e.exports=class{constructor(){}normalize(e){let t=a.normalize(e);return t=t.replace(/\\/g,"/")}async download(e,t){await new Promise(function(n){s(e).pipe(i.createWriteStream(t)).on("close",function(){n()})})}async find(e,t){return t=t||{},await new Promise(function(n){c(e,t,function(e,t){for(let e in t)t[e]=a.normalize(t[e]),t[e]=t[e].replace(/\\/g,"/");n(t)})})}async zip(e,t,n){return await new Promise(function(r,a){let s=i.createWriteStream(t),c=o("zip",{zlib:{level:9}});s.on("close",function(){r()}),c.pipe(s),c.glob("**",{cwd:e,ignore:n||[]}),c.finalize()})}async unzip(e,t){return e=a.normalize(e),await new Promise(function(n,i){r(e,{dir:t},function(e){n()})})}async exist(e){return await new Promise(function(t){i.access(e,function(e){t(!e)})})}async isDirectory(e){return(await this.info(e)).isDirectory()}async info(e){return await new Promise(function(t,n){i.open(e,"a",function(e,o){e&&n(error),i.fstat(o,function(e,r){e&&n(error),i.close(o,function(){t(r)})})})})}async move(e,t){await i.move(e,t)}async delete(e){await i.remove(e)}async ensureFile(e){await i.ensureFile(e)}async ensureDir(e){await i.ensureDir(e)}async copy(e,t,n){await i.copy(e,t,n)}async writeFile(e,t){return await new Promise((n,o)=>{i.writeFile(e,t,e=>{e?o(e):n()})})}async appendFile(e,t){return await new Promise((n,o)=>{i.appendFile(e,t,e=>{e?o(e):n()})})}async readFile(e,t){if(await this.exist(e))return await new Promise(function(n){i.readFile(e,t,(e,t)=>{n(t)})})}async readJson(e){return await i.readJson(e)}async getExt(e){return a.extname(e)}}},function(e,t,n){const i=n(11),o=n(12),r=n(13);e.exports=class{constructor(){this.triggerQueue={}}uuid(){return o.v4().replace(/-/g,"")}md5(e){const t=i.createHash("md5");return t.update(e),t.digest("hex")}async qrcode(e){let t={errorCorrectionLevel:"H",rendererOpts:{quality:.8},color:{light:"#f8f8f8"}};return await new Promise(function(n,i){r.toDataURL(e,t,function(e,t){e?i(e):n(t)})})}getTimestamp(){return Math.round((new Date).getTime()/1e3)}async delay(e){return e=e||1e3,await new Promise(function(t){setTimeout(function(){t()},e)})}formatTime(e,t,n){let i;if(i="number"==typeof e?1e3*e:e.getTime(),"number"!=typeof(n=void 0!==n?n:-(new Date).getTimezoneOffset()))throw{code:"NOT_SUPPORT_STRING_TIMEZORE",message:"暂不支持字符串格式时区,请输入分钟数"};i+=60*n*1e3;const o=new Date(i),r={"M+":o.getUTCMonth()+1,"d+":o.getUTCDate(),"W+":function(e){switch(e.getUTCDay()){case 0:return"日";case 1:return"一";case 2:return"二";case 3:return"三";case 4:return"四";case 5:return"五";case 6:return"六"}}(o),"h+":o.getUTCHours(),"m+":o.getUTCMinutes(),"s+":o.getUTCSeconds(),"q+":Math.floor((o.getUTCMonth()+3)/3),S:("00"+o.getUTCMilliseconds()).slice(-3)};for(var a in/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(o.getUTCFullYear()+"").substr(4-RegExp.$1.length))),r)new RegExp("("+a+")").test(t)&&(t=t.replace(RegExp.$1,1===RegExp.$1.length?r[a]:("00"+r[a]).substr((""+r[a]).length)));return t}random(e,t){const n=(t||"ABCDEFGHIJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz23456789!@#$%^&*()_+-=").split("");let i="";for(let t=0;t<e;t++){i+=n[Math.floor(Math.random()*n.length)]}return i}toCamelCase(e,t,n){t=t||"-";let i=(e=e.toLowerCase()).split(t);e="";for(let t in i){let n=i[t];e+=n.replace(n[0],n[0].toUpperCase())}return n&&(e=e.replace(e[0],e[0].toLowerCase())),e}fromCamelCase(e,t){t=t||"-";const n=[];for(let t=0;t<e.length;t++){const o=e.charAt(t),r=o.toLowerCase();0===n.length?n.push(r):((i=o)>="A"&&i<="Z"&&n.push(""),n[n.length-1]=n[n.length-1]+=r)}var i;return n.join(t)}trigger(e){const t=this.uuid(),n=this.triggerQueue;return async()=>{if(n[t]||(n[t]={running:!1,again:!1}),n[t].running)n[t].again=!0;else{n[t].running=!0;const i=async()=>{await e(),n[t].again?(n[t].again=!1,await i()):delete n[t]};await i()}}}}},function(e,t,n){e.exports=n(3)},function(e,t,n){global.sumor_output=n(4)},function(e,t,n){const i=n(0),o=n(1),r=n(14),a=n(16),s=n(17),c=new i,u=new o;e.exports={file:c,basic:u,cmd:r,Log:a,SSH:s}},function(e,t){e.exports=require("fs-extra")},function(e,t){e.exports=require("archiver")},function(e,t){e.exports=require("extract-zip")},function(e,t){e.exports=require("path")},function(e,t){e.exports=require("download")},function(e,t){e.exports=require("glob")},function(e,t){e.exports=require("crypto")},function(e,t){e.exports=require("uuid")},function(e,t){e.exports=require("qrcode")},function(e,t,n){const{exec:i,spawn:o}=n(15);e.exports={app:{npm:"win32"===process.platform?"npm.cmd":"npm"},exec:async(e,t)=>(t||(t={}),await new Promise(function(n,o){i(e,t,function(e,t,i){e?o(i):n(t)})})),spawn:async(e,t,n)=>{let i=e,r=(t=t||{}).args;return r||(r=e.split(" "),i=r[0],r.shift()),await new Promise(function(e,a){const s=o(i,r,t);let c="",u="";s.stdout.on("data",async e=>{c+=e.toString(),n&&n(e.toString())}),s.stderr.on("data",async e=>{c+=e.toString(),u+=e.toString(),n&&n(e.toString())}),s.on("close",async t=>{0!==t?a(u):e(c)})})}}},function(e,t){e.exports=require("child_process")},function(e,t,n){const i=n(0),o=n(1),r=new i,a=new o;e.exports=class{constructor(e,t){this.root=e,this.name=t,this.message=[],this.updating=!1}async new(){const e=a.getTimestamp();this.path=`${this.root}/logs/${this.name}-${e}.log`,await r.ensureFile(this.path)}async load(){const e=await r.find(`${this.name}-*.log`,{cwd:`${this.root}/logs`});e.length>0?this.path=`${this.root}/logs/${e[e.length-1]}`:await this.new()}write(e){this.message.push(e),this.update()}async update(){if(!this.updating){if(this.updating=!0,this.path||await this.load(),this.message.length>0){const e=this.message.join();this.message=[],await r.appendFile(this.path,e)}this.updating=!1,this.message.length>0&&this.update()}}}},function(e,t,n){const i=n(18),o=n(0),r=n(1),a=(new o,new r);e.exports=class{constructor(e){this.config=e}async connect(){await new Promise((e,t)=>{this.connection=new i,this.connection.connect(this.config).then(function(){e()}).catch(e=>{t(e)})})}async disconnect(){this.connection.dispose()}async exec(e,t){return(t=t||{}).cwd=t.cwd||"~",await this.connection.execCommand(e,t)}putFile(e,t){return this.connection.putFile(e,t)}async putBufferFile(e,t){const n=`${a.uuid()}.tmp`,i=`${__dirname}/tmp/${n}`;await e.ensureFile(i),await e.writeFile(i,e),await this.connection.putFile(i,t),await e.delete(i)}getFile(e,t){return this.connection.getFile(e,t)}async unzip(e,t){try{await this.connection.exec(`unzip -o ${e} -d ${t}`)}catch(n){n.message.indexOf("command not found")&&(await this.install("zip"),await this.connection.exec(`unzip -o ${e} -d ${t}`))}}async delete(e){await this.connection.exec(`rm -rf ${e}`)}async checkSoftware(e){let t=!0;try{await this.connection.exec(e+" --help")}catch(e){e.message.indexOf("command not found")&&(t=!1)}return t}async install(e){console.log(`installing software ${e}`),await this.connection.exec("apt-get update"),await this.connection.exec(`apt-get install ${e} -y`),console.log(`software ${e} installed`)}async checkPort(e){return""===await this.connection.exec(`lsof -i:${e}`)}async randomPort(){const e=1e4+Math.floor(1e4*Math.random());return await this.checkPort(e)?e:await this.randomPort()}}},function(e,t){e.exports=require("node-ssh")}]),global.dynamicRequire=require;var sumor_output=global.sumor_output;delete global.sumor_output,module.exports=sumor_output;
{
"name": "@sumor/utils",
"version": "11.0.29",
"version": "11.0.30",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

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