Merge branch 'master' into feature/SSH-DEPLOY-refactor

# Conflicts:
#	.gitignore
#	README.md
#	dist/index.js
#	src/index.js
main
Dragan Filipovic 2020-04-11 16:54:21 +02:00
commit 62063532be
5 changed files with 25 additions and 16 deletions

2
.gitignore vendored
View File

@ -17,5 +17,5 @@ node_modules/
.env .env
.env.test .env.test
# Ide # IDE
.idea .idea

18
dist/index.js vendored
View File

@ -623,7 +623,7 @@ const sshDeploy = (() => {
})(); })();
const run = () => { const run = () => {
validateInputs([SSH_PRIVATE_KEY, REMOTE_HOST, REMOTE_USER]); validateInputs({ SSH_PRIVATE_KEY, REMOTE_HOST, REMOTE_USER });
sshDeploy.init({ sshDeploy.init({
src: `${GITHUB_WORKSPACE}/${SOURCE}` || '', src: `${GITHUB_WORKSPACE}/${SOURCE}` || '',
@ -663,7 +663,7 @@ const validateRsync = (callback = () => {}) => {
'sudo apt-get --no-install-recommends install rsync', 'sudo apt-get --no-install-recommends install rsync',
(err, data, stderr) => { (err, data, stderr) => {
if (err) { if (err) {
console.log('⚠️ [CLI] Rsync installation failed ', 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);
@ -677,15 +677,19 @@ const validateRsync = (callback = () => {}) => {
}; };
const validateInputs = (inputs) => { const validateInputs = (inputs) => {
const validInputs = inputs.filter((input) => { const inputKeys = Object.keys(inputs);
if (!input) { const validInputs = inputKeys.filter((inputKey) => {
console.error(`⚠️ ${input} is mandatory`); const inputValue = inputs[inputKey];
if (!inputValue) {
console.error(`⚠️ [INPUTS] ${inputKey} is mandatory`);
} }
return input; return inputValue;
}); });
if (validInputs.length !== inputs.length) { if (validInputs.length !== inputKeys.length) {
console.error(`⚠️ [INPUTS] Inputs not valid, aborting ...`);
process.abort(); process.abort();
} }
}; };

View File

@ -16,7 +16,8 @@
}, },
"scripts": { "scripts": {
"build": "npm run lint && ncc build ./src/index.js -o dist", "build": "npm run lint && ncc build ./src/index.js -o dist",
"lint": "eslint ./src/index.js" "lint": "eslint ./src/index.js",
"lint:fix": "eslint ./src/index.js --fix"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -59,7 +59,7 @@ const sshDeploy = (() => {
})(); })();
const run = () => { const run = () => {
validateInputs([SSH_PRIVATE_KEY, REMOTE_HOST, REMOTE_USER]); validateInputs({ SSH_PRIVATE_KEY, REMOTE_HOST, REMOTE_USER });
sshDeploy.init({ sshDeploy.init({
src: `${GITHUB_WORKSPACE}/${SOURCE}` || '', src: `${GITHUB_WORKSPACE}/${SOURCE}` || '',

View File

@ -9,7 +9,7 @@ const validateRsync = (callback = () => {}) => {
'sudo apt-get --no-install-recommends install rsync', 'sudo apt-get --no-install-recommends install rsync',
(err, data, stderr) => { (err, data, stderr) => {
if (err) { if (err) {
console.log('⚠️ [CLI] Rsync installation failed ', 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);
@ -23,15 +23,19 @@ const validateRsync = (callback = () => {}) => {
}; };
const validateInputs = (inputs) => { const validateInputs = (inputs) => {
const validInputs = inputs.filter((input) => { const inputKeys = Object.keys(inputs);
if (!input) { const validInputs = inputKeys.filter((inputKey) => {
console.error(`⚠️ ${input} is mandatory`); const inputValue = inputs[inputKey];
if (!inputValue) {
console.error(`⚠️ [INPUTS] ${inputKey} is mandatory`);
} }
return input; return inputValue;
}); });
if (validInputs.length !== inputs.length) { if (validInputs.length !== inputKeys.length) {
console.error(`⚠️ [INPUTS] Inputs not valid, aborting ...`);
process.abort(); process.abort();
} }
}; };