2021-06-18 15:14:31 +02:00
|
|
|
/**
|
2021-06-23 13:44:18 +02:00
|
|
|
* Returns a welcome message, to be printed to the user when they start the app
|
2021-06-18 15:14:31 +02:00
|
|
|
* Contains essential info about restarting and managing the container or service
|
2021-06-23 13:44:18 +02:00
|
|
|
* @param String ip: The users local IP address or hostname
|
|
|
|
* @param Integer port: the port number that the app is running at
|
2021-06-18 15:14:31 +02:00
|
|
|
* @param Boolean isDocker: whether or not the app is being run within a container
|
|
|
|
* @returns A string formatted for the terminal
|
|
|
|
*/
|
|
|
|
module.exports = (ip, port, isDocker) => {
|
2021-06-23 13:44:18 +02:00
|
|
|
let msg = ''; // To return
|
|
|
|
const chars = { // Color codes used in the message
|
2021-06-18 15:14:31 +02:00
|
|
|
RESET: '\x1b[0m',
|
|
|
|
CYAN: '\x1b[36m',
|
|
|
|
GREEN: '\x1b[32m',
|
|
|
|
BLUE: '\x1b[34m',
|
|
|
|
BRIGHT: '\x1b[1m',
|
|
|
|
BR: '\n',
|
|
|
|
};
|
2021-06-23 13:44:18 +02:00
|
|
|
// Functions to insert string of set length of characters
|
|
|
|
const printChars = (count, char) => new Array(count).fill(char).join('');
|
|
|
|
const stars = (count) => printChars(count, '*');
|
|
|
|
const line = (count) => printChars(count, '━');
|
|
|
|
const blanks = (count) => printChars(count, ' ');
|
2021-06-18 15:14:31 +02:00
|
|
|
if (isDocker) {
|
2021-06-23 13:44:18 +02:00
|
|
|
// Prepare message for Docker users
|
2021-08-27 00:03:26 +02:00
|
|
|
const containerId = process.env.HOST || undefined;
|
2021-06-18 15:14:31 +02:00
|
|
|
msg = `${chars.BLUE}${stars(91)}${chars.BR}${chars.RESET}`
|
|
|
|
+ `${chars.CYAN}Welcome to Dashy! 🚀${chars.RESET}${chars.BR}`
|
|
|
|
+ `${chars.GREEN}Your new dashboard is now up and running `
|
|
|
|
+ `${containerId ? `in container ID ${containerId}` : 'with Docker'}${chars.BR}`
|
|
|
|
+ `${chars.GREEN}After updating your config file, run `
|
|
|
|
+ `'${chars.BRIGHT}docker exec -it ${containerId || '[container-id]'} yarn build`
|
|
|
|
+ `${chars.RESET}${chars.GREEN}' to rebuild${chars.BR}`
|
|
|
|
+ `${chars.BLUE}${stars(91)}${chars.BR}${chars.RESET}`;
|
|
|
|
} else {
|
2021-06-23 13:44:18 +02:00
|
|
|
// Prepare message for users running app on bare metal
|
2021-06-18 15:14:31 +02:00
|
|
|
msg = `${chars.GREEN}┏${line(75)}┓${chars.BR}`
|
|
|
|
+ `┃ ${chars.CYAN}Welcome to Dashy! 🚀${blanks(55)}${chars.GREEN}┃${chars.BR}`
|
|
|
|
+ `┃ ${chars.CYAN}Your new dashboard is now up and running at ${chars.BRIGHT}`
|
|
|
|
+ `http://${ip}:${port}${chars.RESET}${blanks(18 - ip.length)}${chars.GREEN}┃${chars.BR}`
|
|
|
|
+ `┃ ${chars.CYAN}After updating your config file, run '${chars.BRIGHT}yarn build`
|
|
|
|
+ `${chars.RESET}${chars.CYAN}' to rebuild the app${blanks(6)}${chars.GREEN}┃${chars.BR}`
|
2021-06-20 21:45:50 +02:00
|
|
|
+ `┗${line(75)}┛${chars.BR}${chars.BR}${chars.RESET}`;
|
2021-06-18 15:14:31 +02:00
|
|
|
}
|
2021-06-23 13:44:18 +02:00
|
|
|
// Make some sexy ascii art ;)
|
2021-09-04 00:49:29 +02:00
|
|
|
const ascii = `${chars.CYAN}\n\n`
|
2021-06-23 13:44:18 +02:00
|
|
|
+ ' ██████╗ █████╗ ███████╗██╗ ██╗██╗ ██╗\n'
|
|
|
|
+ ' ██╔══██╗██╔══██╗██╔════╝██║ ██║╚██╗ ██╔╝\n'
|
|
|
|
+ ' ██║ ██║███████║███████╗███████║ ╚████╔╝\n'
|
|
|
|
+ ' ██║ ██║██╔══██║╚════██║██╔══██║ ╚██╔╝\n'
|
|
|
|
+ ' ██████╔╝██║ ██║███████║██║ ██║ ██║\n'
|
|
|
|
+ ` ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝\n${chars.RESET}\n`;
|
|
|
|
|
|
|
|
return ascii + msg;
|
2021-06-18 15:14:31 +02:00
|
|
|
};
|