1
0
Fork 0
mirror of https://github.com/codex-team/codex.docs.git synced 2025-07-18 12:49:41 +02:00

Beautify terminal output (#261)

* beautify terminal output

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

resolves #240

* Update server.ts
This commit is contained in:
Taly 2022-09-14 13:27:31 +03:00 committed by GitHub
parent 1cd078317e
commit 51fb6655e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 1 deletions

View file

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

View file

@ -91,6 +91,45 @@ function onListening(): void {
: 'port ' + addr.port;
debug('Listening on ' + bind);
drawBanner([
`CodeX Docs server is running`,
``,
`Main page: http://localhost:${port}`
]);
}
/**
* Draw banner in console with given text lines
* @param {string[]} lines
*/
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'
};
};