replace nodeCMD with exec

main
Dragan Filipovic 2022-12-30 15:23:23 +01:00
parent 692d3fee7d
commit c7bd38757d
8 changed files with 36 additions and 572 deletions

View File

@ -1,9 +1,11 @@
name: e2e Test name: e2e Test
on: on:
push: workflow_run:
branches: workflows: ["Build"]
- feature/add-tests branches: [ main ]
types:
- completed
env: env:
TEST_HOST_DOCKER: ./test TEST_HOST_DOCKER: ./test
@ -54,19 +56,11 @@ jobs:
date +"%Y-%m-%d %H:%M:%S,%3N" >> index.html date +"%Y-%m-%d %H:%M:%S,%3N" >> index.html
cat index.html cat index.html
# - name: e2e Test local ssh-deploy action - name: e2e Test local ssh-deploy action
# run: node ./dist/index.js run: |
# env: npm ci
# SSH_PRIVATE_KEY: $EXAMPLE_SSH_PRIVATE_KEY npm run build
# ARGS: "-rltgoDzvO" node ./src/index.js
# SOURCE: "test_project/"
# REMOTE_HOST: $EXAMPLE_REMOTE_HOST
# REMOTE_USER: $TEST_USER
# TARGET: "/var/www/html/"
# EXCLUDE: "/dist/, /node_modules/"
- name: e2e Test published ssh-deploy action
uses: easingthemes/ssh-deploy@main
env: env:
SSH_PRIVATE_KEY: $EXAMPLE_SSH_PRIVATE_KEY SSH_PRIVATE_KEY: $EXAMPLE_SSH_PRIVATE_KEY
ARGS: "-rltgoDzvO" ARGS: "-rltgoDzvO"
@ -76,3 +70,14 @@ jobs:
TARGET: "/var/www/html/" TARGET: "/var/www/html/"
EXCLUDE: "/dist/, /node_modules/" EXCLUDE: "/dist/, /node_modules/"
# - name: e2e Test published ssh-deploy action
# uses: easingthemes/ssh-deploy@main
# env:
# SSH_PRIVATE_KEY: $EXAMPLE_SSH_PRIVATE_KEY
# ARGS: "-rltgoDzvO"
# SOURCE: "test_project/"
# REMOTE_HOST: $EXAMPLE_REMOTE_HOST
# REMOTE_USER: $TEST_USER
# TARGET: "/var/www/html/"
# EXCLUDE: "/dist/, /node_modules/"

525
dist/index.js vendored

File diff suppressed because one or more lines are too long

14
package-lock.json generated
View File

@ -10,7 +10,6 @@
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"command-exists": "^1.2.9", "command-exists": "^1.2.9",
"node-cmd": "^5.0.0",
"rsyncwrapper": "^3.0.1" "rsyncwrapper": "^3.0.1"
}, },
"devDependencies": { "devDependencies": {
@ -1397,14 +1396,6 @@
"integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==",
"dev": true "dev": true
}, },
"node_modules/node-cmd": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/node-cmd/-/node-cmd-5.0.0.tgz",
"integrity": "sha512-4sQTJmsS5uZKAPz/Df9fnIbmvOySfGdW+UreH4X5NcAOOpKjaE+K5wf4ehNBbZVPo0vQ36RkRnhhsXXJAT+Syw==",
"engines": {
"node": ">=6.4.0"
}
},
"node_modules/object-inspect": { "node_modules/object-inspect": {
"version": "1.12.2", "version": "1.12.2",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.2.tgz", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.2.tgz",
@ -3012,11 +3003,6 @@
"integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==",
"dev": true "dev": true
}, },
"node-cmd": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/node-cmd/-/node-cmd-5.0.0.tgz",
"integrity": "sha512-4sQTJmsS5uZKAPz/Df9fnIbmvOySfGdW+UreH4X5NcAOOpKjaE+K5wf4ehNBbZVPo0vQ36RkRnhhsXXJAT+Syw=="
},
"object-inspect": { "object-inspect": {
"version": "1.12.2", "version": "1.12.2",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.2.tgz", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.2.tgz",

View File

@ -31,7 +31,6 @@
"homepage": "https://github.com/easingthemes/ssh-deploy#readme", "homepage": "https://github.com/easingthemes/ssh-deploy#readme",
"dependencies": { "dependencies": {
"command-exists": "^1.2.9", "command-exists": "^1.2.9",
"node-cmd": "^5.0.0",
"rsyncwrapper": "^3.0.1" "rsyncwrapper": "^3.0.1"
}, },
"devDependencies": { "devDependencies": {

View File

@ -1,23 +1,20 @@
const { sync: commandExists } = require('command-exists'); const { sync: commandExists } = require("command-exists");
const { get: nodeCmd } = require('node-cmd'); const { exec, execSync } = require("child_process");
const validateRsync = (callback = () => {}) => { const validateRsync = (callback = () => {}) => {
const rsyncCli = commandExists('rsync'); const rsyncCli = commandExists("rsync");
console.log('⚠️ [CLI] Rsync doesn\'t exists. Start installation with "apt-get" \n'); console.log('⚠️ [CLI] Rsync doesn\'t exists. Start installation with "apt-get" \n');
console.log('nodeCmd: ', nodeCmd);
if (!rsyncCli) { if (!rsyncCli) {
nodeCmd( execSync("sudo apt-get update");
'sudo apt-get --no-install-recommends install rsync', exec("sudo apt-get --no-install-recommends install rsync", (err, data, stderr) => {
(err, data, stderr) => { if (err) {
if (err) { console.log("⚠️ [CLI] Rsync installation failed. Aborting ... ", err.message);
console.log('⚠️ [CLI] Rsync installation failed. Aborting ... ', err.message); process.abort();
process.abort(); } else {
} else { console.log("✅ [CLI] Rsync installed. \n", data, stderr);
console.log('✅ [CLI] Rsync installed. \n', data, stderr); callback();
callback();
}
} }
); });
} else { } else {
callback(); callback();
} }
@ -36,12 +33,12 @@ const validateInputs = (inputs) => {
}); });
if (validInputs.length !== inputKeys.length) { if (validInputs.length !== inputKeys.length) {
console.error('⚠️ [INPUTS] Inputs not valid, aborting ...'); console.error("⚠️ [INPUTS] Inputs not valid, aborting ...");
process.abort(); process.abort();
} }
}; };
module.exports = { module.exports = {
validateRsync, validateRsync,
validateInputs validateInputs,
}; };