Merge pull request #1233 from bbassie/chore/drop-chalk

Replace chalk with util.styleText
This commit is contained in:
Bastiaan authored and GitHub committed 2026-11-20 20:54:30 +00:00
1 parent bd41801c8d
commit 81c7d24867
5 files changed
+12 -19

No files matched your search

+2 -5
View File
@@ -1,5 +1,5 @@
/* eslint-disable no-console */
import chalk from "chalk";
import { styleText } from "node:util";
export const levels = Object.freeze({
fatal: 0,
@@ -27,10 +27,7 @@ for (let [name, level] of Object.entries(levels)) {
if (level > maxLogLevel) {
return;
}
let style = chalk;
for (let part of colors[name].split(" ")) {
style = style[part];
}
const style = text => styleText(colors[name].split(" "), text);
if (["fatal", "error"].includes(name)) {
console.error(`${style(name)} ${message}`);
} else if (["warn"].includes(name)) {
-1
View File
@@ -36,7 +36,6 @@
"@inquirer/confirm": "^6.3.5",
"@inquirer/input": "^5.1.9",
"@inquirer/select": "^5.2.8",
"chalk": "catalog:",
"yargs": "catalog:"
}
}
-1
View File
@@ -54,7 +54,6 @@
"@types/yauzl": "catalog:",
"@types/yazl": "catalog:",
"ajv": "^8.20.0",
"chalk": "catalog:",
"fast-deep-equal": "^3.1.3",
"set-blocking": "catalog:",
"triple-beam": "^1.4.1",
+10 -11
View File
@@ -8,11 +8,10 @@ import fs from "node:fs/promises";
import type { ReadStream } from "node:fs";
import path from "path";
import stream from "stream";
import util from "util";
import util, { styleText } from "util";
import winston from "winston";
import Transport from "winston-transport";
import { LEVEL, MESSAGE } from "triple-beam";
import chalk from "chalk";
import * as libData from "./data/index.js";
import * as libErrors from "./errors.js";
@@ -108,30 +107,30 @@ export type ParsedFactorioOutput =
function formatServerOutput(parsed: ParsedFactorioOutput) {
let time = "";
if (parsed.format === "seconds") {
time = `${chalk.yellow(parsed.time.padStart(8))} `;
time = `${styleText("yellow", parsed.time.padStart(8))} `;
} else if (parsed.format === "date") {
time = `${chalk.yellow(parsed.time)} `;
time = `${styleText("yellow", parsed.time)} `;
}
let info = "";
if (parsed.type === "log") {
let level = parsed.level;
if (level === "Script") {
level = chalk.bold.greenBright(level);
level = styleText(["bold", "greenBright"], level);
} else if (level === "Verbose") {
level = chalk.bold.gray(level);
level = styleText(["bold", "gray"], level);
} else if (level === "Info") {
level = chalk.bold.blueBright(level);
level = styleText(["bold", "blueBright"], level);
} else if (parsed.level === "Warning") {
level = chalk.bold.yellowBright(level);
level = styleText(["bold", "yellowBright"], level);
} else if (parsed.level === "Error") {
level = chalk.bold.redBright(level);
level = styleText(["bold", "redBright"], level);
}
info = `${level} ${chalk.gray(parsed.file)}: `;
info = `${level} ${styleText("gray", parsed.file)}: `;
} else if (parsed.type === "action") {
info = `[${chalk.yellow(parsed.action)}] `;
info = `[${styleText("yellow", parsed.action)}] `;
}
return time + info + parsed.message;
-1
View File
@@ -21,7 +21,6 @@ catalog:
'@types/yazl': ^3.3.1
'@vitejs/plugin-react': ^6.1.2
antd: ^5.29.3
chalk: ^6.0.1
express: ^5.3.0
jsonwebtoken: ^9.0.3
react: ^18.3.1