From fd59a1b368bf1c422f8ba584b7670b945de51c79 Mon Sep 17 00:00:00 2001 From: Luciano Dantas Date: Tue, 17 Nov 2020 10:24:33 +0000 Subject: [PATCH] Update validation messages --- validations.js | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/validations.js b/validations.js index 68034e0..98d2354 100644 --- a/validations.js +++ b/validations.js @@ -1,12 +1,12 @@ const fs = require("fs-extra"); const path = require("path"); -async function isConfigurationJsonValid(){ +async function isConfigurationJsonValid() { - const configurationsFileLocation = path.join(__dirname, "configuration.json"); + const configurationsFileLocation = path.join(__dirname, "configuration.json"); - if(!fs.existsSync(configurationsFileLocation)){ - console.log(`The configurations.json file is missing`); + if (!fs.existsSync(configurationsFileLocation)) { + console.log(`[configurations.json] The file configurations.json is missing`); return false; } @@ -15,38 +15,38 @@ async function isConfigurationJsonValid(){ ); return configurations; } - + const errorsMessages = []; - const {ejbServerComponents, webClientComponents, skipComponents } = await getConfigurations(); + const { ejbServerComponents, webClientComponents, skipComponents } = await getConfigurations(); - if(!webClientComponents){ - errorsMessages.push( `The field "webClientComponents" is missing`); + if (!webClientComponents) { + errorsMessages.push(`[configurations.json] The field "webClientComponents" is missing in the file configurations.json`); } - if(!ejbServerComponents){ - errorsMessages.push( `The field "ejbServerComponents" is missing`); + if (!ejbServerComponents) { + errorsMessages.push(`[configurations.json] The field "ejbServerComponents" is missing in the file configurations.json`); } - if(skipComponents && !Array.isArray(skipComponents)){ - errorsMessages.push(`The field "skipComponents" must be an array of string`); + if (skipComponents && !Array.isArray(skipComponents)) { + errorsMessages.push(`[configurations.json] The field "skipComponents" in the file configurations.json must be an array of strings`); } // test paths - if(webClientComponents && !fs.existsSync(webClientComponents)){ - errorsMessages.push(`The path in "webClientComponents" does not exist`); + if (webClientComponents && !fs.existsSync(webClientComponents)) { + errorsMessages.push(`[configurations.json] The path in "webClientComponents" does not exist. Update the file configurations.json`); } - if(ejbServerComponents && !fs.existsSync(ejbServerComponents)){ - errorsMessages.push(`The path in "ejbServerComponents" does not exist`); + if (ejbServerComponents && !fs.existsSync(ejbServerComponents)) { + errorsMessages.push(`[configurations.json] The path in "ejbServerComponents" does not exist. Update the file configurations.json`); } - if(errorsMessages.length){ + if (errorsMessages.length) { console.error("Errors found:") - errorsMessages.forEach( message => { + errorsMessages.forEach(message => { console.error(`* ${message}`); }) return false;