diff --git a/package-lock.json b/package-lock.json index af55caae2..a5b1f5142 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,6 +21,7 @@ "bing-translate-api": "^4.0.2", "body-parser": "^1.20.2", "bowser": "^2.11.0", + "chalk": "^5.4.1", "command-exists": "^1.2.9", "compression": "^1", "cookie-parser": "^1.4.6", @@ -2438,17 +2439,12 @@ } }, "node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.4.1.tgz", + "integrity": "sha512-zgVZuo2WcZgfUEmsn6eO3kINexW8RAE4maiQ8QNs8CtpPCSyMiYsULR3HQYkm3w8FIA3SberyMJMSldGsW+U3w==", "license": "MIT", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, "engines": { - "node": ">=10" + "node": "^12.17.0 || ^14.13 || >=16.0.0" }, "funding": { "url": "https://github.com/chalk/chalk?sponsor=1" @@ -3492,6 +3488,23 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/eslint/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, "node_modules/eslint/node_modules/debug": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", diff --git a/package.json b/package.json index 37fdc5e38..ea7bac657 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "bing-translate-api": "^4.0.2", "body-parser": "^1.20.2", "bowser": "^2.11.0", + "chalk": "^5.4.1", "command-exists": "^1.2.9", "compression": "^1", "cookie-parser": "^1.4.6", diff --git a/post-install.js b/post-install.js index 00ef731ad..1989b61aa 100644 --- a/post-install.js +++ b/post-install.js @@ -7,26 +7,13 @@ import crypto from 'node:crypto'; import process from 'node:process'; import yaml from 'yaml'; import _ from 'lodash'; +import chalk from 'chalk'; import { createRequire } from 'node:module'; /** * Colorizes console output. */ -const color = { - byNum: (mess, fgNum) => { - mess = mess || ''; - fgNum = fgNum === undefined ? 31 : fgNum; - return '\u001b[' + fgNum + 'm' + mess + '\u001b[39m'; - }, - black: (mess) => color.byNum(mess, 30), - red: (mess) => color.byNum(mess, 31), - green: (mess) => color.byNum(mess, 32), - yellow: (mess) => color.byNum(mess, 33), - blue: (mess) => color.byNum(mess, 34), - magenta: (mess) => color.byNum(mess, 35), - cyan: (mess) => color.byNum(mess, 36), - white: (mess) => color.byNum(mess, 37), -}; +const color = chalk; const keyMigrationMap = [ { diff --git a/public/lib.js b/public/lib.js index 4c6f318af..a615a1df4 100644 --- a/public/lib.js +++ b/public/lib.js @@ -20,6 +20,7 @@ import * as Popper from '@popperjs/core'; import droll from 'droll'; import morphdom from 'morphdom'; import { toggle as slideToggle } from 'slidetoggle'; +import chalk from 'chalk'; /** * Expose the libraries to the 'window' object. @@ -96,6 +97,7 @@ export default { droll, morphdom, slideToggle, + chalk, }; export { @@ -118,4 +120,5 @@ export { droll, morphdom, slideToggle, + chalk, }; diff --git a/src/util.js b/src/util.js index 443a4f91a..e6246b5d2 100644 --- a/src/util.js +++ b/src/util.js @@ -14,6 +14,7 @@ import _ from 'lodash'; import yauzl from 'yauzl'; import mime from 'mime-types'; import { default as simpleGit } from 'simple-git'; +import chalk from 'chalk'; import { LOG_LEVELS } from './constants.js'; /** @@ -323,21 +324,7 @@ export function deepMerge(target, source) { return output; } -export const color = { - byNum: (mess, fgNum) => { - mess = mess || ''; - fgNum = fgNum === undefined ? 31 : fgNum; - return '\u001b[' + fgNum + 'm' + mess + '\u001b[39m'; - }, - black: (mess) => color.byNum(mess, 30), - red: (mess) => color.byNum(mess, 31), - green: (mess) => color.byNum(mess, 32), - yellow: (mess) => color.byNum(mess, 33), - blue: (mess) => color.byNum(mess, 34), - magenta: (mess) => color.byNum(mess, 35), - cyan: (mess) => color.byNum(mess, 36), - white: (mess) => color.byNum(mess, 37), -}; +export const color = chalk; /** * Gets a random UUIDv4 string.