ssh-deploy/dist/index.js

2 lines
9.0 KiB
JavaScript
Raw Normal View History

2019-10-03 00:52:52 +03:00
#!/usr/bin/env node
2022-12-31 12:30:19 +03:00
(()=>{var e={569:(e,r,s)=>{e.exports=s(325)},325:(e,r,s)=>{"use strict";var t=s(81).exec;var n=s(81).execSync;var o=s(147);var c=s(17);var i=o.access;var a=o.accessSync;var u=o.constants||o;var l=process.platform=="win32";var fileNotExists=function(e,r){i(e,u.F_OK,(function(e){r(!e)}))};var fileNotExistsSync=function(e){try{a(e,u.F_OK);return false}catch(e){return true}};var localExecutable=function(e,r){i(e,u.F_OK|u.X_OK,(function(e){r(null,!e)}))};var localExecutableSync=function(e){try{a(e,u.F_OK|u.X_OK);return true}catch(e){return false}};var commandExistsUnix=function(e,r,s){fileNotExists(e,(function(n){if(!n){var o=t("command -v "+r+" 2>/dev/null"+" && { echo >&1 "+r+"; exit 0; }",(function(e,r,t){s(null,!!r)}));return}localExecutable(e,s)}))};var commandExistsWindows=function(e,r,s){if(!/^(?!(?:.*\s|.*\.|\W+)$)(?:[a-zA-Z]:)?(?:(?:[^<>:"\|\?\*\n])+(?:\/\/|\/|\\\\|\\)?)+$/m.test(e)){s(null,false);return}var n=t("where "+r,(function(e){if(e!==null){s(null,false)}else{s(null,true)}}))};var commandExistsUnixSync=function(e,r){if(fileNotExistsSync(e)){try{var s=n("command -v "+r+" 2>/dev/null"+" && { echo >&1 "+r+"; exit 0; }");return!!s}catch(e){return false}}return localExecutableSync(e)};var commandExistsWindowsSync=function(e,r,s){if(!/^(?!(?:.*\s|.*\.|\W+)$)(?:[a-zA-Z]:)?(?:(?:[^<>:"\|\?\*\n])+(?:\/\/|\/|\\\\|\\)?)+$/m.test(e)){return false}try{var t=n("where "+r,{stdio:[]});return!!t}catch(e){return false}};var cleanInput=function(e){if(/[^A-Za-z0-9_\/:=-]/.test(e)){e="'"+e.replace(/'/g,"'\\''")+"'";e=e.replace(/^(?:'')+/g,"").replace(/\\'''/g,"\\'")}return e};if(l){cleanInput=function(e){var r=/[\\]/.test(e);if(r){var s='"'+c.dirname(e)+'"';var t='"'+c.basename(e)+'"';return s+":"+t}return'"'+e+'"'}}e.exports=function commandExists(e,r){var s=cleanInput(e);if(!r&&typeof Promise!=="undefined"){return new Promise((function(r,s){commandExists(e,(function(t,n){if(n){r(e)}else{s(t)}}))}))}if(l){commandExistsWindows(e,s,r)}else{commandExistsUnix(e,s,r)}};e.exports.sync=function(e){var r=cleanInput(e);if(l){return commandExistsWindowsSync(e,r)}else{return commandExistsUnixSync(e,r)}}},898:(e,r,s)=>{"use strict";var t=s(81).spawn;var n=s(837);var escapeSpaces=function(e){if(typeof e==="string"){return e.replace(/\b\s/g,"\\ ")}else{return e}};var escapeSpacesInOptions=function(e){["src","dest","include","exclude","excludeFirst"].forEach((function(r){var s=e[r];if(typeof s==="string"){e[r]=escapeSpaces(s)}else if(Array.isArray(s)===true){e[r]=s.map(escapeSpaces)}}));return e};e.exports=function(e,r){e=e||{};e=n._extend({},e);e=escapeSpacesInOptions(e);var s=e.platform||process.platform;var o=s==="win32";if(typeof e.src==="undefined"){throw new Error("'src' directory is missing from options")}if(typeof e.dest==="undefined"){throw new Error("'dest' directory is missing from options")}var c=e.dest;if(typeof e.host!=="undefined"){c=e.host+":"+e.dest}if(!Array.isArray(e.src)){e.src=[e.src]}var i=[].concat(e.src);i.push(c);var a=(e.args||[]).find((function(e){return e.match(/--chmod=/)}));if(o&&!a){i.push("--chmod=ugo=rwX")}if(typeof e.host!=="undefined"||e.ssh){i.push("--rsh");var u="ssh";if(typeof e.port!=="undefined"){u+=" -p "+e.port}if(typeof e.privateKey!=="undefined"){u+=" -i "+e.privateKey}if(typeof e.sshCmdArgs!=="undefined"){u+=" "+e.sshCmdArgs.join(" ")}i.push(u)}if(e.recursive===true){i.push("--recursive")}if(e.times===true){i.push("--times")}if(e.syncDest===true||e.deleteAll===true){i.push("--delete");i.push("--delete-excluded")}if(e.syncDestIgnoreExcl===true||e.delete===true){i.push("--delete")}if(e.dryRun===true){i.push("--dry-run");i.push("--verbose")}if(typeof e.excludeFirst!=="undefined"&&n.isArray(e.excludeFirst)){e.excludeFirst.forEach((function(e,r){i.push("--exclude="+e)}))}if(typeof e.include!=="undefined"&&n.isArray(e.include)){e.include.forEach((function(e,r){i.push("--include="+e)}))}if(typeof e.exclude!=="undefined"&&n.isArray(e.exclude)){e.exclude.forEach((function(e,r){i.push("--exclude="+e)}))}switch(e.compareMode){case"sizeOnly":i.push("--size-only");break;case"checksum":i.push("--checksum");break