From 34a75bf4679bddff947539433923afe037bd1928 Mon Sep 17 00:00:00 2001 From: Dragan Filipovic Date: Sat, 31 Dec 2022 10:23:56 +0100 Subject: [PATCH] remove unused package --- dist/index.js | 2 +- package-lock.json | 11 ----------- package.json | 1 - 3 files changed, 1 insertion(+), 13 deletions(-) diff --git a/dist/index.js b/dist/index.js index 5952a78..b31e0e6 100755 --- a/dist/index.js +++ b/dist/index.js @@ -1,2 +1,2 @@ #!/usr/bin/env node -(()=>{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}if(typeof e.args!=="undefined"&&n.isArray(e.args)){i=[...new Set([...i,...e.args])]}i=[...new Set(i)];var noop=function(){};var l=e.onStdout||noop;var d=e.onStderr||noop;var f="rsync ";i.forEach((function(e){if(e.substr(0,4)==="ssh "){e='"'+e+'"'}f+=e+" "}));f=f.trim();if(e.noExec){r(null,null,null,f);return}try{var p="";var y="";var _;if(o){_=t("cmd.exe",["/s","/c",'"'+f+'"'],{windowsVerbatimArguments:true,stdio:[process.stdin,"pipe","pipe"]})}else{_=t("/bin/sh",["-c",f])}_.stdout.on("data",(function(e){l(e);p+=e}));_.stderr.on("data",(function(e){d(e);y+=e}));_.on("exit",(function(e){var s=null;if(e!==0){s=new Error("rsync exited with code "+e);s.code=e}r(s,p,y,f)}))}catch(e){r(e,null,null,f)}}},505:(e,r,s)=>{const{existsSync:t,mkdirSync:n,writeFileSync:o}=s(147);const{GITHUB_WORKSPACE:c}=process.env;const validateDir=e=>{if(!t(e)){console.log(`[SSH] Creating ${e} dir in `,c);n(e);console.log("✅ [SSH] dir created.")}else{console.log(`[SSH] ${e} dir exist`)}};const validateFile=e=>{if(!t(e)){console.log(`[SSH] Creating ${e} file in `,c);try{o(e,"",{encoding:"utf8",mode:384});console.log("✅ [SSH] file created.")}catch(r){console.error("⚠️ [SSH] writeFileSync error",e,r.message);process.abort()}}else{console.log(`[SSH] ${e} file exist`)}};e.exports={validateDir:validateDir,validateFile:validateFile}},229:e=>{const r=["REMOTE_HOST","REMOTE_USER","REMOTE_PORT","SSH_PRIVATE_KEY","DEPLOY_KEY_NAME","SOURCE","TARGET","ARGS","EXCLUDE"];const s={GITHUB_WORKSPACE:process.env.GITHUB_WORKSPACE};r.forEach((e=>{s[e]=process.env[e]||process.env[`INPUT_${e}`]}));e.exports=s},447:(e,r,s)=>{const{sync:t}=s(569);const{exec:n,execSync:o}=s(81);const validateRsync=(e=(()=>{}))=>{const r=t("rsync");if(r){console.log("⚠️ [CLI] Rsync exists");const r=o("rsync --version",{stdio:"inherit"});return e()}console.log('⚠️ [CLI] Rsync doesn\'t exists. Start installation with "apt-get" \n');n("sudo apt-get update && sudo apt-get --no-install-recommends install rsync",((r,s,t)=>{if(r){console.log("⚠️ [CLI] Rsync installation failed. Aborting ... ",r.message);process.abort()}else{console.log("✅ [CLI] Rsync installed. \n",s,t);e()}}))};const validateInputs=e=>{const r=Object.keys(e);const s=r.filter((r=>{const s=e[r];if(!s){console.error(`⚠️ [INPUTS] ${r} is mandatory`)}return s}));if(s.length!==r.length){console.error("⚠️ [INPUTS] Inputs not valid, aborting ...");process.abort()}};e.exports={validateRsync:validateRsync,validateInputs:validateInputs}},822:(e,r,s)=>{const{writeFileSync:t}=s(147);const{join:n}=s(17);const{validateDir:o,validateFile:c}=s(505);const{HOME:i}=process.env;const addSshKey=(e,r)=>{const s=n(i||__dirname,".ssh");const a=n(s,r);o(s);c(`${s}/known_hosts`);try{t(a,e,{encoding:"utf8",mode:384})}catch(e){console.error("⚠️ writeFileSync error",a,e.message);process.abort()}console.log("✅ Ssh key added to `.ssh` dir ",a);return a};e.exports={addSshKey:addSshKey}},81:e=>{"use strict";e.exports=require("child_process")},147:e=>{"use strict";e.exports=require("fs")},17:e=>{"use strict";e.exports=require("path")},837:e=>{"use strict";e.exports=require("util")}};var r={};function __nccwpck_require__(s){var t=r[s];if(t!==undefined){return t.exports}var n=r[s]={exports:{}};var o=true;try{e[s](n,n.exports,__nccwpck_require__);o=false}finally{if(o)delete r[s]}return n.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var s={};(()=>{const e=__nccwpck_require__(898);const{validateRsync:r,validateInputs:s}=__nccwpck_require__(447);const{addSshKey:t}=__nccwpck_require__(822);const{REMOTE_HOST:n,REMOTE_USER:o,REMOTE_PORT:c,SSH_PRIVATE_KEY:i,DEPLOY_KEY_NAME:a,SOURCE:u,TARGET:l,ARGS:d,EXCLUDE:f,GITHUB_WORKSPACE:p}=__nccwpck_require__(229);const y={ssh:true,sshCmdArgs:["-o StrictHostKeyChecking=no"],recursive:true};console.log("GITHUB_WORKSPACE: ",p);console.log("REMOTE_HOST: ",process.env.REMOTE_HOST);console.log("REMOTE_USER: ",process.env.REMOTE_USER);console.log("SSH_PRIVATE_KEY: ",process.env.SSH_PRIVATE_KEY);const _=(()=>{const rsync=({privateKey:r,port:s,src:t,dest:n,args:o,exclude:c})=>{console.log(`[Rsync] Starting Rsync Action: ${t} to ${n}`);if(c)console.log(`[Rsync] exluding folders ${c}`);try{e({src:t,dest:n,args:o,privateKey:r,port:s,excludeFirst:c,...y},((e,r,s,t)=>{if(e){console.error("⚠️ [Rsync] error: ",e.message);console.log("⚠️ [Rsync] stderr: ",s);console.log("⚠️ [Rsync] stdout: ",r);console.log("⚠️ [Rsync] cmd: ",t);process.abort()}else{console.log("✅ [Rsync] finished.",r)}}))}catch(e){console.error("⚠️ [Rsync] command error: ",e.message,e.stack);process.abort()}};const init=({src:e,dest:s,args:n,host:o="localhost",port:c,username:i,privateKeyContent:u,exclude:l=[]})=>{r((()=>{const r=t(u,a||"deploy_key");const d=`${i}@${o}:${s}`;rsync({privateKey:r,port:c,src:e,dest:d,args:n,exclude:l})}))};return{init:init}})();const run=()=>{s({SSH_PRIVATE_KEY:i,REMOTE_HOST:n,REMOTE_USER:o});_.init({src:`${p}/${u||""}`,dest:l||`/home/${o}/`,args:d?[d]:["-rltgoDzvO"],host:n,port:c||"22",username:o,privateKeyContent:i,exclude:(f||"").split(",").map((e=>e.trim()))})};run()})();module.exports=s})(); \ No newline at end of file +(()=>{var __webpack_modules__={898:(e,s,r)=>{"use strict";var o=r(81).spawn;var t=r(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(s){var r=e[s];if(typeof r==="string"){e[s]=escapeSpaces(r)}else if(Array.isArray(r)===true){e[s]=r.map(escapeSpaces)}}));return e};e.exports=function(e,s){e=e||{};e=t._extend({},e);e=escapeSpacesInOptions(e);var r=e.platform||process.platform;var n=r==="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(n&&!a){i.push("--chmod=ugo=rwX")}if(typeof e.host!=="undefined"||e.ssh){i.push("--rsh");var l="ssh";if(typeof e.port!=="undefined"){l+=" -p "+e.port}if(typeof e.privateKey!=="undefined"){l+=" -i "+e.privateKey}if(typeof e.sshCmdArgs!=="undefined"){l+=" "+e.sshCmdArgs.join(" ")}i.push(l)}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"&&t.isArray(e.excludeFirst)){e.excludeFirst.forEach((function(e,s){i.push("--exclude="+e)}))}if(typeof e.include!=="undefined"&&t.isArray(e.include)){e.include.forEach((function(e,s){i.push("--include="+e)}))}if(typeof e.exclude!=="undefined"&&t.isArray(e.exclude)){e.exclude.forEach((function(e,s){i.push("--exclude="+e)}))}switch(e.compareMode){case"sizeOnly":i.push("--size-only");break;case"checksum":i.push("--checksum");break}if(typeof e.args!=="undefined"&&t.isArray(e.args)){i=[...new Set([...i,...e.args])]}i=[...new Set(i)];var noop=function(){};var d=e.onStdout||noop;var u=e.onStderr||noop;var _="rsync ";i.forEach((function(e){if(e.substr(0,4)==="ssh "){e='"'+e+'"'}_+=e+" "}));_=_.trim();if(e.noExec){s(null,null,null,_);return}try{var p="";var f="";var y;if(n){y=o("cmd.exe",["/s","/c",'"'+_+'"'],{windowsVerbatimArguments:true,stdio:[process.stdin,"pipe","pipe"]})}else{y=o("/bin/sh",["-c",_])}y.stdout.on("data",(function(e){d(e);p+=e}));y.stderr.on("data",(function(e){u(e);f+=e}));y.on("exit",(function(e){var r=null;if(e!==0){r=new Error("rsync exited with code "+e);r.code=e}s(r,p,f,_)}))}catch(e){s(e,null,null,_)}}},505:(e,s,r)=>{const{existsSync:o,mkdirSync:t,writeFileSync:n}=r(147);const{GITHUB_WORKSPACE:c}=process.env;const validateDir=e=>{if(!o(e)){console.log(`[SSH] Creating ${e} dir in `,c);t(e);console.log("✅ [SSH] dir created.")}else{console.log(`[SSH] ${e} dir exist`)}};const validateFile=e=>{if(!o(e)){console.log(`[SSH] Creating ${e} file in `,c);try{n(e,"",{encoding:"utf8",mode:384});console.log("✅ [SSH] file created.")}catch(s){console.error("⚠️ [SSH] writeFileSync error",e,s.message);process.abort()}}else{console.log(`[SSH] ${e} file exist`)}};e.exports={validateDir:validateDir,validateFile:validateFile}},229:e=>{const s=["REMOTE_HOST","REMOTE_USER","REMOTE_PORT","SSH_PRIVATE_KEY","DEPLOY_KEY_NAME","SOURCE","TARGET","ARGS","EXCLUDE"];const r={GITHUB_WORKSPACE:process.env.GITHUB_WORKSPACE};s.forEach((e=>{r[e]=process.env[e]||process.env[`INPUT_${e}`]}));e.exports=r},447:(e,s,r)=>{const{sync:o}=r(238);const{exec:t,execSync:n}=r(81);const validateRsync=(e=(()=>{}))=>{const s=o("rsync");if(s){console.log("⚠️ [CLI] Rsync exists");const s=n("rsync --version",{stdio:"inherit"});return e()}console.log('⚠️ [CLI] Rsync doesn\'t exists. Start installation with "apt-get" \n');t("sudo apt-get update && sudo apt-get --no-install-recommends install rsync",((s,r,o)=>{if(s){console.log("⚠️ [CLI] Rsync installation failed. Aborting ... ",s.message);process.abort()}else{console.log("✅ [CLI] Rsync installed. \n",r,o);e()}}))};const validateInputs=e=>{const s=Object.keys(e);const r=s.filter((s=>{const r=e[s];if(!r){console.error(`⚠️ [INPUTS] ${s} is mandatory`)}return r}));if(r.length!==s.length){console.error("⚠️ [INPUTS] Inputs not valid, aborting ...");process.abort()}};e.exports={validateRsync:validateRsync,validateInputs:validateInputs}},822:(e,s,r)=>{const{writeFileSync:o}=r(147);const{join:t}=r(17);const{validateDir:n,validateFile:c}=r(505);const{HOME:i}=process.env;const addSshKey=(e,s)=>{const r=t(i||__dirname,".ssh");const a=t(r,s);n(r);c(`${r}/known_hosts`);try{o(a,e,{encoding:"utf8",mode:384})}catch(e){console.error("⚠️ writeFileSync error",a,e.message);process.abort()}console.log("✅ Ssh key added to `.ssh` dir ",a);return a};e.exports={addSshKey:addSshKey}},238:module=>{module.exports=eval("require")("command-exists")},81:e=>{"use strict";e.exports=require("child_process")},147:e=>{"use strict";e.exports=require("fs")},17:e=>{"use strict";e.exports=require("path")},837:e=>{"use strict";e.exports=require("util")}};var __webpack_module_cache__={};function __nccwpck_require__(e){var s=__webpack_module_cache__[e];if(s!==undefined){return s.exports}var r=__webpack_module_cache__[e]={exports:{}};var o=true;try{__webpack_modules__[e](r,r.exports,__nccwpck_require__);o=false}finally{if(o)delete __webpack_module_cache__[e]}return r.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var __webpack_exports__={};(()=>{const e=__nccwpck_require__(898);const{validateRsync:s,validateInputs:r}=__nccwpck_require__(447);const{addSshKey:o}=__nccwpck_require__(822);const{REMOTE_HOST:t,REMOTE_USER:n,REMOTE_PORT:c,SSH_PRIVATE_KEY:i,DEPLOY_KEY_NAME:a,SOURCE:l,TARGET:d,ARGS:u,EXCLUDE:_,GITHUB_WORKSPACE:p}=__nccwpck_require__(229);const f={ssh:true,sshCmdArgs:["-o StrictHostKeyChecking=no"],recursive:true};console.log("GITHUB_WORKSPACE: ",p);console.log("REMOTE_HOST: ",process.env.REMOTE_HOST);console.log("REMOTE_USER: ",process.env.REMOTE_USER);console.log("SSH_PRIVATE_KEY: ",process.env.SSH_PRIVATE_KEY);const y=(()=>{const rsync=({privateKey:s,port:r,src:o,dest:t,args:n,exclude:c})=>{console.log(`[Rsync] Starting Rsync Action: ${o} to ${t}`);if(c)console.log(`[Rsync] exluding folders ${c}`);try{e({src:o,dest:t,args:n,privateKey:s,port:r,excludeFirst:c,...f},((e,s,r,o)=>{if(e){console.error("⚠️ [Rsync] error: ",e.message);console.log("⚠️ [Rsync] stderr: ",r);console.log("⚠️ [Rsync] stdout: ",s);console.log("⚠️ [Rsync] cmd: ",o);process.abort()}else{console.log("✅ [Rsync] finished.",s)}}))}catch(e){console.error("⚠️ [Rsync] command error: ",e.message,e.stack);process.abort()}};const init=({src:e,dest:r,args:t,host:n="localhost",port:c,username:i,privateKeyContent:l,exclude:d=[]})=>{s((()=>{const s=o(l,a||"deploy_key");const u=`${i}@${n}:${r}`;rsync({privateKey:s,port:c,src:e,dest:u,args:t,exclude:d})}))};return{init:init}})();const run=()=>{r({SSH_PRIVATE_KEY:i,REMOTE_HOST:t,REMOTE_USER:n});y.init({src:`${p}/${l||""}`,dest:d||`/home/${n}/`,args:u?[u]:["-rltgoDzvO"],host:t,port:c||"22",username:n,privateKeyContent:i,exclude:(_||"").split(",").map((e=>e.trim()))})};run()})();module.exports=__webpack_exports__})(); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 4026c44..2e29acb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,6 @@ "version": "3.0.1", "license": "MIT", "dependencies": { - "command-exists": "^1.2.9", "rsyncwrapper": "^3.0.1" }, "devDependencies": { @@ -301,11 +300,6 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, - "node_modules/command-exists": { - "version": "1.2.9", - "resolved": "https://registry.npmjs.org/command-exists/-/command-exists-1.2.9.tgz", - "integrity": "sha512-LTQ/SGc+s0Xc0Fu5WaKnR0YiygZkm9eKFvyS+fRsU7/ZWFF8ykFM6Pc9aCVf1+xasOOZpO3BAVgVrKvsqKHV7w==" - }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -2188,11 +2182,6 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, - "command-exists": { - "version": "1.2.9", - "resolved": "https://registry.npmjs.org/command-exists/-/command-exists-1.2.9.tgz", - "integrity": "sha512-LTQ/SGc+s0Xc0Fu5WaKnR0YiygZkm9eKFvyS+fRsU7/ZWFF8ykFM6Pc9aCVf1+xasOOZpO3BAVgVrKvsqKHV7w==" - }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", diff --git a/package.json b/package.json index 41d082c..c08fceb 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,6 @@ }, "homepage": "https://github.com/easingthemes/ssh-deploy#readme", "dependencies": { - "command-exists": "^1.2.9", "rsyncwrapper": "^3.0.1" }, "devDependencies": {