diff --git a/packages/create/logging.js b/packages/create/logging.js index 9954b666..872079e6 100644 --- a/packages/create/logging.js +++ b/packages/create/logging.js @@ -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)) { diff --git a/packages/create/package.json b/packages/create/package.json index f059d945..2cfca34a 100644 --- a/packages/create/package.json +++ b/packages/create/package.json @@ -36,7 +36,6 @@ "@inquirer/confirm": "^6.3.5", "@inquirer/input": "^5.1.9", "@inquirer/select": "^5.2.8", - "chalk": "catalog:", "yargs": "catalog:" } } diff --git a/packages/lib/package.json b/packages/lib/package.json index f2ca801d..bb572f4b 100644 --- a/packages/lib/package.json +++ b/packages/lib/package.json @@ -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", diff --git a/packages/lib/src/logging_utils.ts b/packages/lib/src/logging_utils.ts index ea062c96..da636a97 100644 --- a/packages/lib/src/logging_utils.ts +++ b/packages/lib/src/logging_utils.ts @@ -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; diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index ddd59f18..3211b103 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -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