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

# Conflicts:
#	.gitignore
#	README.md
#	dist/index.js
#	src/index.js
This commit is contained in:
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.test
# Ide
# IDE
.idea

18
dist/index.js vendored
View File

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

View File

@ -16,7 +16,8 @@
},
"scripts": {
"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": {
"type": "git",

View File

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

View File

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