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
on:
push:
branches:
- feature/add-tests
workflow_run:
workflows: ["Build"]
branches: [ main ]
types:
- completed
env:
TEST_HOST_DOCKER: ./test
@ -54,19 +56,11 @@ jobs:
date +"%Y-%m-%d %H:%M:%S,%3N" >> index.html
cat index.html
# - name: e2e Test local ssh-deploy action
# run: node ./dist/index.js
# 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/"
- name: e2e Test published ssh-deploy action
uses: easingthemes/ssh-deploy@main
- name: e2e Test local ssh-deploy action
run: |
npm ci
npm run build
node ./src/index.js
env:
SSH_PRIVATE_KEY: $EXAMPLE_SSH_PRIVATE_KEY
ARGS: "-rltgoDzvO"
@ -76,3 +70,14 @@ jobs:
TARGET: "/var/www/html/"
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",
"dependencies": {
"command-exists": "^1.2.9",
"node-cmd": "^5.0.0",
"rsyncwrapper": "^3.0.1"
},
"devDependencies": {
@ -1397,14 +1396,6 @@
"integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==",
"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": {
"version": "1.12.2",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.2.tgz",
@ -3012,11 +3003,6 @@
"integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==",
"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": {
"version": "1.12.2",
"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",
"dependencies": {
"command-exists": "^1.2.9",
"node-cmd": "^5.0.0",
"rsyncwrapper": "^3.0.1"
},
"devDependencies": {

View File

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