yyp-node-utils
Advanced tools
@@ -1,1 +0,1 @@ | ||
| 'use strict';var nodeSsh=require('node-ssh'),child_process=require('child_process'),u=require('fs'),s=require('path');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var u__default=/*#__PURE__*/_interopDefault(u);var s__default=/*#__PURE__*/_interopDefault(s);function a(n){return n==null?true:typeof n=="string"?n.trim()==="":Array.isArray(n)?n.length===0:typeof n=="object"?Object.keys(n).length===0:false}var f=class c{constructor(t,e,o){this.success=t,this.message=e,this.data=o;}static ok(t,e="\u64CD\u4F5C\u6210\u529F"){return new c(true,e,t)}static fail(t="\u64CD\u4F5C\u5931\u8D25",e){return new c(false,t,e)}};var g={FULL:"yyyy-MM-dd HH:mm:ss"};function p(n=new Date,t=g.FULL){if(n==null||n==="")return "";let e;if(n instanceof Date)e=n;else if(typeof n=="number"){let r=n<1e11?n*1e3:n;e=new Date(r);}else if(typeof n=="string"){let r=n.trim();/^\d{4}-\d{2}-\d{2}/.test(r)&&(r=r.replace(/-/g,"/")),r=r.replace("T"," ").replace(/Z$/,""),e=new Date(r);}else return "";if(isNaN(e.getTime()))return "";let o=(r,l=2)=>String(r).padStart(l,"0"),i={yyyy:e.getFullYear(),MM:o(e.getMonth()+1),dd:o(e.getDate()),HH:o(e.getHours()),mm:o(e.getMinutes()),ss:o(e.getSeconds()),SSS:o(e.getMilliseconds(),3),q:Math.floor((e.getMonth()+3)/3)};return t.replace(/yyyy|MM|dd|HH|mm|ss|SSS|q/g,r=>String(i[r]??r))}function D(n,t){return new Promise(e=>{let o=n.split(" "),i=child_process.spawn(o[0],o.slice(1),{cwd:t,shell:true});i.stdout.on("data",r=>process.stdout.write(r)),i.stderr.on("data",r=>process.stderr.write(r)),i.on("close",r=>e(r===0)),i.on("error",()=>e(false));})}async function h(n,t={}){let{stopOnError:e=true,cwd:o=process.cwd()}=t;for(let i of n)if(!await D(i,o))return f.fail(`\u547D\u4EE4\u6267\u884C\u5931\u8D25\uFF1A${i}`);return f.ok(void 0,"\u6240\u6709\u547D\u4EE4\u6267\u884C\u6210\u529F")}var m=class{constructor(t){this.remoteOptions=t;let{remotePath:e,remoteFolder:o,projectPath:i=process.cwd(),localFolder:r="dist"}=t;if(a(e)||a(o))throw new Error("\u8BF7\u586B\u5199\u8FDC\u7A0B\u76EE\u5F55\u548C\u8FDC\u7A0B\u524D\u7AEF\u6587\u4EF6\u5939\u540D\u79F0");this.ssh=new nodeSsh.NodeSSH,this.remoteDist=s__default.default.join(e,o),this.defaultDist=s__default.default.join(i,r),this.fallbackDist=s__default.default.join(i,"dist"),this.localDist=s__default.default.join(i,o);}async delopy(t=["node -v","git branch","npm i","npx cross-env NODE_OPTIONS=--openssl-legacy-provider npm run build"]){try{await h(t,{cwd:this.remoteOptions.projectPath}),await this.renameDirectory(),await this.ssh.connect({host:this.remoteOptions.host,username:this.remoteOptions.username,password:this.remoteOptions.password}),await this.existRemotePath(this.remoteDist),await this.uploading(this.localDist,this.remoteDist),this.ssh.dispose();}catch{this.ssh.dispose(),process.exit(1);}}async renameDirectory(){let t=this.defaultDist;if(u__default.default.existsSync(t)||u__default.default.existsSync(this.fallbackDist)&&(t=this.fallbackDist),!u__default.default.existsSync(t)&&!u__default.default.existsSync(this.localDist))throw new Error(`\u672C\u5730\u6253\u5305\u5931\u8D25\uFF1A\u672A\u627E\u5230 "${t}" \u6216 "${this.localDist}"`);u__default.default.existsSync(t)&&s__default.default.resolve(t)!==s__default.default.resolve(this.localDist)&&(u__default.default.existsSync(this.localDist)&&u__default.default.rmSync(this.localDist,{recursive:true,force:true}),u__default.default.renameSync(t,this.localDist));}async existRemotePath(t){let{stdout:e}=await this.ssh.execCommand(`[ -d "${t}" ] && echo exists || mkdir -p "${t}"`);e.includes("exists"),this.remoteOptions.cleanBeforeDeploy&&await this.ssh.execCommand(`rm -rf ${this.remoteDist}/*`);}async uploading(t,e,o=2){p();for(let r=1;r<=o+1;r++)try{if(await this.ssh.putDirectory(t,e,{recursive:!0,concurrency:5,tick:(d,F,y)=>{}})){let d=p();return}else throw new Error("\u4E0A\u4F20\u8FD4\u56DE false")}catch{if(r>o)throw new Error("\u591A\u6B21\u4E0A\u4F20\u5931\u8D25\uFF0C\u90E8\u7F72\u7EC8\u6B62")}}};exports.SSHLink=m; | ||
| 'use strict';var nodeSsh=require('node-ssh'),child_process=require('child_process'),u=require('fs'),s=require('path');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var u__default=/*#__PURE__*/_interopDefault(u);var s__default=/*#__PURE__*/_interopDefault(s);function a(n){return n==null?true:typeof n=="string"?n.trim()==="":Array.isArray(n)?n.length===0:typeof n=="object"?Object.keys(n).length===0:false}var f=class c{constructor(t,e,o){this.success=t,this.message=e,this.data=o;}static ok(t,e="\u64CD\u4F5C\u6210\u529F"){return new c(true,e,t)}static fail(t="\u64CD\u4F5C\u5931\u8D25",e){return new c(false,t,e)}};var g={FULL:"yyyy-MM-dd HH:mm:ss"};function p(n=new Date,t=g.FULL){if(n==null||n==="")return "";let e;if(n instanceof Date)e=n;else if(typeof n=="number"){let r=n<1e11?n*1e3:n;e=new Date(r);}else if(typeof n=="string"){let r=n.trim();/^\d{4}-\d{2}-\d{2}/.test(r)&&(r=r.replace(/-/g,"/")),r=r.replace("T"," ").replace(/Z$/,""),e=new Date(r);}else return "";if(isNaN(e.getTime()))return "";let o=(r,l=2)=>String(r).padStart(l,"0"),i={yyyy:e.getFullYear(),MM:o(e.getMonth()+1),dd:o(e.getDate()),HH:o(e.getHours()),mm:o(e.getMinutes()),ss:o(e.getSeconds()),SSS:o(e.getMilliseconds(),3),q:Math.floor((e.getMonth()+3)/3)};return t.replace(/yyyy|MM|dd|HH|mm|ss|SSS|q/g,r=>String(i[r]??r))}function D(n,t){return new Promise(e=>{let o=n.split(" "),i=child_process.spawn(o[0],o.slice(1),{cwd:t,shell:true});i.stdout.on("data",r=>process.stdout.write(r)),i.stderr.on("data",r=>process.stderr.write(r)),i.on("close",r=>e(r===0)),i.on("error",()=>e(false));})}async function h(n,t={}){let{stopOnError:e=true,cwd:o=process.cwd()}=t;for(let i of n)if(!await D(i,o))return f.fail(`\u547D\u4EE4\u6267\u884C\u5931\u8D25\uFF1A${i}`);return f.ok(void 0,"\u6240\u6709\u547D\u4EE4\u6267\u884C\u6210\u529F")}var m=class{constructor(t){this.remoteOptions=t;let{remotePath:e,remoteFolder:o,projectPath:i=process.cwd(),localFolder:r="dist"}=t;if(a(e)||a(o))throw new Error("\u8BF7\u586B\u5199\u8FDC\u7A0B\u76EE\u5F55\u548C\u8FDC\u7A0B\u524D\u7AEF\u6587\u4EF6\u5939\u540D\u79F0");this.ssh=new nodeSsh.NodeSSH,this.remoteDist=s__default.default.join(e,o),this.defaultDist=s__default.default.join(i,r),this.fallbackDist=s__default.default.join(i,"dist"),this.localDist=s__default.default.join(i,o);}async delopy(t=["npm i","npx cross-env NODE_OPTIONS=--openssl-legacy-provider npm run build"]){try{await h(t,{cwd:this.remoteOptions.projectPath}),await this.renameDirectory(),await this.ssh.connect({host:this.remoteOptions.host,username:this.remoteOptions.username,password:this.remoteOptions.password}),await this.existRemotePath(this.remoteDist),await this.uploading(this.localDist,this.remoteDist),this.ssh.dispose();}catch{this.ssh.dispose(),process.exit(1);}}async renameDirectory(){let t=this.defaultDist;if(u__default.default.existsSync(t)||u__default.default.existsSync(this.fallbackDist)&&(t=this.fallbackDist),!u__default.default.existsSync(t)&&!u__default.default.existsSync(this.localDist))throw new Error(`\u672C\u5730\u6253\u5305\u5931\u8D25\uFF1A\u672A\u627E\u5230 "${t}" \u6216 "${this.localDist}"`);u__default.default.existsSync(t)&&s__default.default.resolve(t)!==s__default.default.resolve(this.localDist)&&(u__default.default.existsSync(this.localDist)&&u__default.default.rmSync(this.localDist,{recursive:true,force:true}),u__default.default.renameSync(t,this.localDist));}async existRemotePath(t){let{stdout:e}=await this.ssh.execCommand(`[ -d "${t}" ] && echo exists || mkdir -p "${t}"`);e.includes("exists"),this.remoteOptions.cleanBeforeDeploy&&await this.ssh.execCommand(`rm -rf ${this.remoteDist}/*`);}async uploading(t,e,o=2){p();for(let r=1;r<=o+1;r++)try{if(await this.ssh.putDirectory(t,e,{recursive:!0,concurrency:5,tick:(d,F,y)=>{}})){let d=p();return}else throw new Error("\u4E0A\u4F20\u8FD4\u56DE false")}catch{if(r>o)throw new Error("\u591A\u6B21\u4E0A\u4F20\u5931\u8D25\uFF0C\u90E8\u7F72\u7EC8\u6B62")}}};exports.SSHLink=m; |
@@ -1,1 +0,1 @@ | ||
| import {NodeSSH}from'node-ssh';import {spawn}from'child_process';import u from'fs';import s from'path';function a(n){return n==null?true:typeof n=="string"?n.trim()==="":Array.isArray(n)?n.length===0:typeof n=="object"?Object.keys(n).length===0:false}var f=class c{constructor(t,e,o){this.success=t,this.message=e,this.data=o;}static ok(t,e="\u64CD\u4F5C\u6210\u529F"){return new c(true,e,t)}static fail(t="\u64CD\u4F5C\u5931\u8D25",e){return new c(false,t,e)}};var g={FULL:"yyyy-MM-dd HH:mm:ss"};function p(n=new Date,t=g.FULL){if(n==null||n==="")return "";let e;if(n instanceof Date)e=n;else if(typeof n=="number"){let r=n<1e11?n*1e3:n;e=new Date(r);}else if(typeof n=="string"){let r=n.trim();/^\d{4}-\d{2}-\d{2}/.test(r)&&(r=r.replace(/-/g,"/")),r=r.replace("T"," ").replace(/Z$/,""),e=new Date(r);}else return "";if(isNaN(e.getTime()))return "";let o=(r,l=2)=>String(r).padStart(l,"0"),i={yyyy:e.getFullYear(),MM:o(e.getMonth()+1),dd:o(e.getDate()),HH:o(e.getHours()),mm:o(e.getMinutes()),ss:o(e.getSeconds()),SSS:o(e.getMilliseconds(),3),q:Math.floor((e.getMonth()+3)/3)};return t.replace(/yyyy|MM|dd|HH|mm|ss|SSS|q/g,r=>String(i[r]??r))}function D(n,t){return new Promise(e=>{let o=n.split(" "),i=spawn(o[0],o.slice(1),{cwd:t,shell:true});i.stdout.on("data",r=>process.stdout.write(r)),i.stderr.on("data",r=>process.stderr.write(r)),i.on("close",r=>e(r===0)),i.on("error",()=>e(false));})}async function h(n,t={}){let{stopOnError:e=true,cwd:o=process.cwd()}=t;for(let i of n)if(!await D(i,o))return f.fail(`\u547D\u4EE4\u6267\u884C\u5931\u8D25\uFF1A${i}`);return f.ok(void 0,"\u6240\u6709\u547D\u4EE4\u6267\u884C\u6210\u529F")}var m=class{constructor(t){this.remoteOptions=t;let{remotePath:e,remoteFolder:o,projectPath:i=process.cwd(),localFolder:r="dist"}=t;if(a(e)||a(o))throw new Error("\u8BF7\u586B\u5199\u8FDC\u7A0B\u76EE\u5F55\u548C\u8FDC\u7A0B\u524D\u7AEF\u6587\u4EF6\u5939\u540D\u79F0");this.ssh=new NodeSSH,this.remoteDist=s.join(e,o),this.defaultDist=s.join(i,r),this.fallbackDist=s.join(i,"dist"),this.localDist=s.join(i,o);}async delopy(t=["node -v","git branch","npm i","npx cross-env NODE_OPTIONS=--openssl-legacy-provider npm run build"]){try{await h(t,{cwd:this.remoteOptions.projectPath}),await this.renameDirectory(),await this.ssh.connect({host:this.remoteOptions.host,username:this.remoteOptions.username,password:this.remoteOptions.password}),await this.existRemotePath(this.remoteDist),await this.uploading(this.localDist,this.remoteDist),this.ssh.dispose();}catch{this.ssh.dispose(),process.exit(1);}}async renameDirectory(){let t=this.defaultDist;if(u.existsSync(t)||u.existsSync(this.fallbackDist)&&(t=this.fallbackDist),!u.existsSync(t)&&!u.existsSync(this.localDist))throw new Error(`\u672C\u5730\u6253\u5305\u5931\u8D25\uFF1A\u672A\u627E\u5230 "${t}" \u6216 "${this.localDist}"`);u.existsSync(t)&&s.resolve(t)!==s.resolve(this.localDist)&&(u.existsSync(this.localDist)&&u.rmSync(this.localDist,{recursive:true,force:true}),u.renameSync(t,this.localDist));}async existRemotePath(t){let{stdout:e}=await this.ssh.execCommand(`[ -d "${t}" ] && echo exists || mkdir -p "${t}"`);e.includes("exists"),this.remoteOptions.cleanBeforeDeploy&&await this.ssh.execCommand(`rm -rf ${this.remoteDist}/*`);}async uploading(t,e,o=2){p();for(let r=1;r<=o+1;r++)try{if(await this.ssh.putDirectory(t,e,{recursive:!0,concurrency:5,tick:(d,F,y)=>{}})){let d=p();return}else throw new Error("\u4E0A\u4F20\u8FD4\u56DE false")}catch{if(r>o)throw new Error("\u591A\u6B21\u4E0A\u4F20\u5931\u8D25\uFF0C\u90E8\u7F72\u7EC8\u6B62")}}};export{m as SSHLink}; | ||
| import {NodeSSH}from'node-ssh';import {spawn}from'child_process';import u from'fs';import s from'path';function a(n){return n==null?true:typeof n=="string"?n.trim()==="":Array.isArray(n)?n.length===0:typeof n=="object"?Object.keys(n).length===0:false}var f=class c{constructor(t,e,o){this.success=t,this.message=e,this.data=o;}static ok(t,e="\u64CD\u4F5C\u6210\u529F"){return new c(true,e,t)}static fail(t="\u64CD\u4F5C\u5931\u8D25",e){return new c(false,t,e)}};var g={FULL:"yyyy-MM-dd HH:mm:ss"};function p(n=new Date,t=g.FULL){if(n==null||n==="")return "";let e;if(n instanceof Date)e=n;else if(typeof n=="number"){let r=n<1e11?n*1e3:n;e=new Date(r);}else if(typeof n=="string"){let r=n.trim();/^\d{4}-\d{2}-\d{2}/.test(r)&&(r=r.replace(/-/g,"/")),r=r.replace("T"," ").replace(/Z$/,""),e=new Date(r);}else return "";if(isNaN(e.getTime()))return "";let o=(r,l=2)=>String(r).padStart(l,"0"),i={yyyy:e.getFullYear(),MM:o(e.getMonth()+1),dd:o(e.getDate()),HH:o(e.getHours()),mm:o(e.getMinutes()),ss:o(e.getSeconds()),SSS:o(e.getMilliseconds(),3),q:Math.floor((e.getMonth()+3)/3)};return t.replace(/yyyy|MM|dd|HH|mm|ss|SSS|q/g,r=>String(i[r]??r))}function D(n,t){return new Promise(e=>{let o=n.split(" "),i=spawn(o[0],o.slice(1),{cwd:t,shell:true});i.stdout.on("data",r=>process.stdout.write(r)),i.stderr.on("data",r=>process.stderr.write(r)),i.on("close",r=>e(r===0)),i.on("error",()=>e(false));})}async function h(n,t={}){let{stopOnError:e=true,cwd:o=process.cwd()}=t;for(let i of n)if(!await D(i,o))return f.fail(`\u547D\u4EE4\u6267\u884C\u5931\u8D25\uFF1A${i}`);return f.ok(void 0,"\u6240\u6709\u547D\u4EE4\u6267\u884C\u6210\u529F")}var m=class{constructor(t){this.remoteOptions=t;let{remotePath:e,remoteFolder:o,projectPath:i=process.cwd(),localFolder:r="dist"}=t;if(a(e)||a(o))throw new Error("\u8BF7\u586B\u5199\u8FDC\u7A0B\u76EE\u5F55\u548C\u8FDC\u7A0B\u524D\u7AEF\u6587\u4EF6\u5939\u540D\u79F0");this.ssh=new NodeSSH,this.remoteDist=s.join(e,o),this.defaultDist=s.join(i,r),this.fallbackDist=s.join(i,"dist"),this.localDist=s.join(i,o);}async delopy(t=["npm i","npx cross-env NODE_OPTIONS=--openssl-legacy-provider npm run build"]){try{await h(t,{cwd:this.remoteOptions.projectPath}),await this.renameDirectory(),await this.ssh.connect({host:this.remoteOptions.host,username:this.remoteOptions.username,password:this.remoteOptions.password}),await this.existRemotePath(this.remoteDist),await this.uploading(this.localDist,this.remoteDist),this.ssh.dispose();}catch{this.ssh.dispose(),process.exit(1);}}async renameDirectory(){let t=this.defaultDist;if(u.existsSync(t)||u.existsSync(this.fallbackDist)&&(t=this.fallbackDist),!u.existsSync(t)&&!u.existsSync(this.localDist))throw new Error(`\u672C\u5730\u6253\u5305\u5931\u8D25\uFF1A\u672A\u627E\u5230 "${t}" \u6216 "${this.localDist}"`);u.existsSync(t)&&s.resolve(t)!==s.resolve(this.localDist)&&(u.existsSync(this.localDist)&&u.rmSync(this.localDist,{recursive:true,force:true}),u.renameSync(t,this.localDist));}async existRemotePath(t){let{stdout:e}=await this.ssh.execCommand(`[ -d "${t}" ] && echo exists || mkdir -p "${t}"`);e.includes("exists"),this.remoteOptions.cleanBeforeDeploy&&await this.ssh.execCommand(`rm -rf ${this.remoteDist}/*`);}async uploading(t,e,o=2){p();for(let r=1;r<=o+1;r++)try{if(await this.ssh.putDirectory(t,e,{recursive:!0,concurrency:5,tick:(d,F,y)=>{}})){let d=p();return}else throw new Error("\u4E0A\u4F20\u8FD4\u56DE false")}catch{if(r>o)throw new Error("\u591A\u6B21\u4E0A\u4F20\u5931\u8D25\uFF0C\u90E8\u7F72\u7EC8\u6B62")}}};export{m as SSHLink}; |
+1
-1
| { | ||
| "name": "yyp-node-utils", | ||
| "version": "1.0.2", | ||
| "version": "1.1.0", | ||
| "main": "./dist/index.cjs", | ||
@@ -5,0 +5,0 @@ "module": "./dist/index.js", |
Unpublished package
Supply chain riskPackage version was not found on the registry. It may exist on a different registry and need to be configured to pull from that registry.
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 2 instances
Unpublished package
Supply chain riskPackage version was not found on the registry. It may exist on a different registry and need to be configured to pull from that registry.
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 2 instances
26183
-0.18%