1
0
Fork 0
mirror of https://github.com/codex-team/codex.docs.git synced 2025-08-09 23:45:25 +02:00

beautify terminal output

- draw welcome banner on server starting
- use minimal logs for webpack
- disable verbose mode for nodemon

resolves #240
This commit is contained in:
Taly 2022-09-14 12:46:27 +03:00
parent 1cd078317e
commit 7420507a7c
3 changed files with 41 additions and 1 deletions

View file

@ -1,5 +1,4 @@
{
"verbose": true,
"ignore": [
".git",
"node_modules",

View file

@ -91,6 +91,41 @@ function onListening(): void {
: 'port ' + addr.port;
debug('Listening on ' + bind);
drawBanner([
`CodeX Docs server is running`,
``,
`Main page: http://localhost:${port}`
]);
}
function drawBanner(lines: string[]) {
/** Define banner parts */
const PARTS = {
TOP_LEFT: '┌',
TOP_RIGHT: '┐',
BOTTOM_LEFT: '└',
BOTTOM_RIGHT: '┘',
HORIZONTAL: '─',
VERTICAL: '│',
SPACE: ' ',
}
/** Calculate max line length */
const maxLength = lines.reduce((max, line) => Math.max(max, line.length), 0);
/** Prepare top line */
const top = PARTS.TOP_LEFT + PARTS.HORIZONTAL.repeat(maxLength + 2) + PARTS.TOP_RIGHT;
/** Compose middle lines */
const middle = lines.map(line => PARTS.VERTICAL + ' ' + line + PARTS.SPACE.repeat(maxLength - line.length) + ' ' + PARTS.VERTICAL);
/** Prepare bottom line */
const bottom = PARTS.BOTTOM_LEFT + PARTS.HORIZONTAL.repeat(maxLength + 2) + PARTS.BOTTOM_RIGHT;
console.log(top);
console.log(middle.join('\n'));
console.log(bottom);
}
export default {

View file

@ -87,5 +87,11 @@ export default () => {
optimization: {
splitChunks: false,
},
/**
* Show less logs while building
* https://webpack.js.org/configuration/stats/
*/
stats: 'minimal'
};
};