mirror of
https://github.com/codex-team/codex.docs.git
synced 2025-07-18 20:59:42 +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:
parent
1cd078317e
commit
51fb6655e2
3 changed files with 45 additions and 1 deletions
|
@ -1,5 +1,4 @@
|
||||||
{
|
{
|
||||||
"verbose": true,
|
|
||||||
"ignore": [
|
"ignore": [
|
||||||
".git",
|
".git",
|
||||||
"node_modules",
|
"node_modules",
|
||||||
|
|
|
@ -91,6 +91,45 @@ function onListening(): void {
|
||||||
: 'port ' + addr.port;
|
: 'port ' + addr.port;
|
||||||
|
|
||||||
debug('Listening on ' + bind);
|
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 {
|
export default {
|
||||||
|
|
|
@ -87,5 +87,11 @@ export default () => {
|
||||||
optimization: {
|
optimization: {
|
||||||
splitChunks: false,
|
splitChunks: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show less logs while building
|
||||||
|
* https://webpack.js.org/configuration/stats/
|
||||||
|
*/
|
||||||
|
stats: 'minimal'
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue