mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-23 16:23:12 +09:00
Merge pull request #1233 from bbassie/chore/drop-chalk
Replace chalk with util.styleText
This commit is contained in:
1 parent
bd41801c8d
commit
81c7d24867
5 files changed
+12
-19
No files matched your search
@@ -1,5 +1,5 @@
|
|||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
import chalk from "chalk";
|
import { styleText } from "node:util";
|
||||||
|
|
||||||
export const levels = Object.freeze({
|
export const levels = Object.freeze({
|
||||||
fatal: 0,
|
fatal: 0,
|
||||||
@@ -27,10 +27,7 @@ for (let [name, level] of Object.entries(levels)) {
|
|||||||
if (level > maxLogLevel) {
|
if (level > maxLogLevel) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let style = chalk;
|
const style = text => styleText(colors[name].split(" "), text);
|
||||||
for (let part of colors[name].split(" ")) {
|
|
||||||
style = style[part];
|
|
||||||
}
|
|
||||||
if (["fatal", "error"].includes(name)) {
|
if (["fatal", "error"].includes(name)) {
|
||||||
console.error(`${style(name)} ${message}`);
|
console.error(`${style(name)} ${message}`);
|
||||||
} else if (["warn"].includes(name)) {
|
} else if (["warn"].includes(name)) {
|
||||||
|
|||||||
@@ -36,7 +36,6 @@
|
|||||||
"@inquirer/confirm": "^6.3.5",
|
"@inquirer/confirm": "^6.3.5",
|
||||||
"@inquirer/input": "^5.1.9",
|
"@inquirer/input": "^5.1.9",
|
||||||
"@inquirer/select": "^5.2.8",
|
"@inquirer/select": "^5.2.8",
|
||||||
"chalk": "catalog:",
|
|
||||||
"yargs": "catalog:"
|
"yargs": "catalog:"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -54,7 +54,6 @@
|
|||||||
"@types/yauzl": "catalog:",
|
"@types/yauzl": "catalog:",
|
||||||
"@types/yazl": "catalog:",
|
"@types/yazl": "catalog:",
|
||||||
"ajv": "^8.20.0",
|
"ajv": "^8.20.0",
|
||||||
"chalk": "catalog:",
|
|
||||||
"fast-deep-equal": "^3.1.3",
|
"fast-deep-equal": "^3.1.3",
|
||||||
"set-blocking": "catalog:",
|
"set-blocking": "catalog:",
|
||||||
"triple-beam": "^1.4.1",
|
"triple-beam": "^1.4.1",
|
||||||
|
|||||||
@@ -8,11 +8,10 @@ import fs from "node:fs/promises";
|
|||||||
import type { ReadStream } from "node:fs";
|
import type { ReadStream } from "node:fs";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import stream from "stream";
|
import stream from "stream";
|
||||||
import util from "util";
|
import util, { styleText } from "util";
|
||||||
import winston from "winston";
|
import winston from "winston";
|
||||||
import Transport from "winston-transport";
|
import Transport from "winston-transport";
|
||||||
import { LEVEL, MESSAGE } from "triple-beam";
|
import { LEVEL, MESSAGE } from "triple-beam";
|
||||||
import chalk from "chalk";
|
|
||||||
|
|
||||||
import * as libData from "./data/index.js";
|
import * as libData from "./data/index.js";
|
||||||
import * as libErrors from "./errors.js";
|
import * as libErrors from "./errors.js";
|
||||||
@@ -108,30 +107,30 @@ export type ParsedFactorioOutput =
|
|||||||
function formatServerOutput(parsed: ParsedFactorioOutput) {
|
function formatServerOutput(parsed: ParsedFactorioOutput) {
|
||||||
let time = "";
|
let time = "";
|
||||||
if (parsed.format === "seconds") {
|
if (parsed.format === "seconds") {
|
||||||
time = `${chalk.yellow(parsed.time.padStart(8))} `;
|
time = `${styleText("yellow", parsed.time.padStart(8))} `;
|
||||||
} else if (parsed.format === "date") {
|
} else if (parsed.format === "date") {
|
||||||
time = `${chalk.yellow(parsed.time)} `;
|
time = `${styleText("yellow", parsed.time)} `;
|
||||||
}
|
}
|
||||||
|
|
||||||
let info = "";
|
let info = "";
|
||||||
if (parsed.type === "log") {
|
if (parsed.type === "log") {
|
||||||
let level = parsed.level;
|
let level = parsed.level;
|
||||||
if (level === "Script") {
|
if (level === "Script") {
|
||||||
level = chalk.bold.greenBright(level);
|
level = styleText(["bold", "greenBright"], level);
|
||||||
} else if (level === "Verbose") {
|
} else if (level === "Verbose") {
|
||||||
level = chalk.bold.gray(level);
|
level = styleText(["bold", "gray"], level);
|
||||||
} else if (level === "Info") {
|
} else if (level === "Info") {
|
||||||
level = chalk.bold.blueBright(level);
|
level = styleText(["bold", "blueBright"], level);
|
||||||
} else if (parsed.level === "Warning") {
|
} else if (parsed.level === "Warning") {
|
||||||
level = chalk.bold.yellowBright(level);
|
level = styleText(["bold", "yellowBright"], level);
|
||||||
} else if (parsed.level === "Error") {
|
} 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") {
|
} else if (parsed.type === "action") {
|
||||||
info = `[${chalk.yellow(parsed.action)}] `;
|
info = `[${styleText("yellow", parsed.action)}] `;
|
||||||
}
|
}
|
||||||
|
|
||||||
return time + info + parsed.message;
|
return time + info + parsed.message;
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ catalog:
|
|||||||
'@types/yazl': ^3.3.1
|
'@types/yazl': ^3.3.1
|
||||||
'@vitejs/plugin-react': ^6.1.2
|
'@vitejs/plugin-react': ^6.1.2
|
||||||
antd: ^5.29.3
|
antd: ^5.29.3
|
||||||
chalk: ^6.0.1
|
|
||||||
express: ^5.3.0
|
express: ^5.3.0
|
||||||
jsonwebtoken: ^9.0.3
|
jsonwebtoken: ^9.0.3
|
||||||
react: ^18.3.1
|
react: ^18.3.1
|
||||||
|
|||||||
Reference in new issue
Block a user