diff --git a/nodemon.json b/nodemon.json index 063c303..70b8ccc 100644 --- a/nodemon.json +++ b/nodemon.json @@ -1,5 +1,4 @@ { - "verbose": true, "ignore": [ ".git", "node_modules", diff --git a/src/bin/server.ts b/src/bin/server.ts index 3b67135..9f6c225 100644 --- a/src/bin/server.ts +++ b/src/bin/server.ts @@ -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 { diff --git a/webpack.config.js b/webpack.config.js index 811aa0f..23cf2da 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -87,5 +87,11 @@ export default () => { optimization: { splitChunks: false, }, + + /** + * Show less logs while building + * https://webpack.js.org/configuration/stats/ + */ + stats: 'minimal' }; };