const MESSAGES = {
    "EXTRACT_SOURCES": "\x1b[36m > Extracting the add-on sources. This could take some time based on your hard disk performance.\x1b[0m\n  - Extracting \x1b[33m$tarballCount$\x1b[0m files. ",
    "EXTRACT_SOURCES_SUCCES": " > The sources have been extracted successfully.\n",
    "EXTRACT_SOURCES_CORRUPTED": " > The add-on sources are corrupted. The add-on sources will be removed.\n",
    "INSTALL_STARTED": "\x1b[36m > The add-on components installation started. Please wait, this can take some time... \x1b[0m\n",
    "INSTALL_PATH": " > Copying '$component$' component '$member$' member:\n  - from: '$from$'\n  - to: '$to$'\n",
    "INSTALL_CREATE_DIR": " > Path for '$component$' doesn't exist, a folder was created:\n  - at: '$to$'\n",
    "INSTALL_COMPONENTS": " > The add-on components have been successfully installed.",
    "INSTALL_COMPLETE": " \x1b[36m> You can check your shiny add-on working in a few minutes. \n \x1b[36m> Thanks for choosing Sisense!\x1b[0m",
    "REMOVE_STARTED": "\x1b[36m > The add-on components uninstallation started. Please wait, this can take some time...\n\x1b[0m",
    "REMOVE_PATH": " > Removing '$component$' component '$member$' member: \n  - from: '$from$'\n",
    "REMOVE_COMPONENTS": " > The add-on components have been uninstalled.",
    "REMOVE_COMPLETE": " > Thanks for flying with Sisense :)",
    "CHECK_STARTED": "\x1b[36m > Verifying installation...\n\x1b[0m",
    "CHECK_PATH": " > Checking '$component$' component's '$member$' member:\n  - from: '$to$'",
    "CHECK_PATH_SUCCCESS": "  - result: OK",
    "CHECK_PATH_ERROR": "  - result: Warning! Missing component found!",
    "CHECK_SOURCES_ERROR": " > The add-on verification found missing components. Please re-install the add-on.",
    "CHECK_SOURCES_SUCCESS": "\n > The add-on components are installed correctly.",
    "UPDATE_STARTED": "\x1b[36m > The add-on components update has started.\x1b[0m\n",
    "UPDATE_COMPONENTS": " > The add-on components have been updated.",
    "UPDATE_COMPLETE": " \x1b[36m> You can check your shiny add-on working in a few minutes. \n \x1b[36m> Thanks for choosing Sisense!\x1b[0m",
    "BACKUP_PATH": " > Backing up '$component$' component '$member$' protected members:\n  - to: $to$ \n",
    "RESTORE_PATH": " > Restoring the backed up '$component$' component '$member$' protected members:\n  - from: $from$\n  - to: $to$ \n",
    "NO_BACKUP": " > No protected files/folders (config.js, config.6.js, config.json, resources) were found.",
    "WINDOWS_SERVICE_CREATE_SUCCESS": " > Windows service '$service_name$' was registered.\n",
    "WINDOWS_SERVICE_START_SUCCESS": " > Windows service '$service_name$' was started.\n",
    "WINDOWS_SERVICE_STOP_SUCCESS": " > Windows service '$service_name$' was stopped.\n",
    "WINDOWS_SERVICE_DELETE_SUCCESS": " > Windows service '$service_name$' was deleted.\n",
    "WINDOWS_SERVICE_CREATE_ERROR": " > Windows service '$service_name$' failed to register.\n  - Error: $error_msg$\n",
    "WINDOWS_SERVICE_START_ERROR": " > Windows service '$service_name$' failed to start.\n  - Error: $error_msg$\n",
    "WINDOWS_SERVICE_STOP_ERROR": " > Windows service '$service_name$' failed to stop.\n  - Error: $error_msg$\n",
    "WINDOWS_SERVICE_DELETE_ERROR": " > Windows service '$service_name$' failed to delete.\n  - Error: $error_msg$\n",
    "HELP_MESSAGE": buildHelpMsg(),
    "INSTALL_PARTIAL": " > The add-on is installed partially, please run the Remove command.\n",
    "INSTALL_FULL": " > The add-on is already installed, please run Remove or Update command.\n",
    "REMOVE_FULL": " > The add-on is already removed, please run Install or Update command.\n",
    "REMOVE_SKIP": " > Component '$component$' member '$member$' was not installed, remove step was skipped.\n",
    "BACKUP_SKIP": " > Component '$component$' member '$member$' was not installed, back-up step was skipped.\n",
    "ERROR_NO_PARAMS": " > No command was specified. Please enter a valid command.\n",
    "ERROR_INVALID_PARAMS": " > Invalid command key, value, or combination. Please enter a valid command.\n",
    "NO_COMPONENTS": " > There is no need to install the add-on components on the current node type.\n",
    "HANDLED_ERROR": " > An error occurred during action execution. Further execution was stopped.\n  - Reason: $reason$\n"
};

const ERROR_MESSAGES = {
    "ENOTEMPTY": "File System error. The resource is not empty or opened in another program."
}

const messageMap = Object.keys(MESSAGES).reduce((acc, msg) => {
    acc[msg] = msg;
    return acc;
}, {});

function buildHelpMsg() {
    const h = " > \x1b[32m-h\x1b[0m - help - show information about commands.\n";
    const c = " > \x1b[32m-c\x1b[0m - [s<single> | q<query> | b<build> | a<app>] - check - verify if all the add-on components are already installed in proper folders based on the node type parameter.\n";
    const i = " > \x1b[32m-i\x1b[0m - [s<single> | q<query> | b<build> | a<app>] - install - install the add-on components based on the node type parameter.\n";
    const u = " > \x1b[32m-u\x1b[0m - [s<single> | q<query> | b<build> | a<app>] - update - update the add-on preserving protected files(config.js, config.6.js, config.json) and folders(resources) based on the node type parameter.\n";
    const r = " > \x1b[32m-r\x1b[0m - [s<single> | q<query> | b<build> | a<app>] - remove - remove all the add-on components based on the node type parameter. If there's a configuration saved in MongoDB or in the Configuration Page, it will persist.\n";
    const v = " > \x1b[32m-v\x1b[0m - version - return the version of the add-on from this installation package.\n";

    return `${h}${c}${i}${u}${r}${v}`;
}

Object.freeze(messageMap);

module.exports = { MESSAGES, messageMap, ERROR_MESSAGES };
