diff --git a/app/entry.server.tsx b/app/entry.server.tsx index 59adaf914..76ac360c4 100644 --- a/app/entry.server.tsx +++ b/app/entry.server.tsx @@ -1,8 +1,7 @@ import { PassThrough } from 'node:stream' +import { styleText } from 'node:util' import { createReadableStreamFromReadable } from '@react-router/node' - import * as Sentry from '@sentry/node' -import chalk from 'chalk' import { isbot } from 'isbot' import { renderToPipeableStream } from 'react-dom/server' import { @@ -107,7 +106,7 @@ export function handleError( return } if (error instanceof Error) { - console.error(chalk.red(error.stack)) + console.error(styleText('red', String(error.stack))) void Sentry.captureException(error) } else { console.error(error) diff --git a/app/utils/db.server.ts b/app/utils/db.server.ts index 1d3c44485..711844e89 100644 --- a/app/utils/db.server.ts +++ b/app/utils/db.server.ts @@ -1,7 +1,7 @@ +import { styleText } from 'node:util' import { remember } from '@epic-web/remember' // Changed import due to issue: https://github.com/remix-run/react-router/pull/12644 import { PrismaClient } from '@prisma/client/index.js' -import chalk from 'chalk' export const prisma = remember('prisma', () => { // NOTE: if you change anything in this function you'll need to restart @@ -29,7 +29,7 @@ export const prisma = remember('prisma', () => { : e.duration < logThreshold * 1.4 ? 'redBright' : 'red' - const dur = chalk[color](`${e.duration}ms`) + const dur = styleText(color, `${e.duration}ms`) console.info(`prisma:query - ${dur} - ${e.query}`) }) void client.$connect() diff --git a/package-lock.json b/package-lock.json index 91cee3351..c5d47a201 100644 --- a/package-lock.json +++ b/package-lock.json @@ -39,7 +39,6 @@ "address": "^2.0.3", "bcryptjs": "^2.4.3", "better-sqlite3": "^11.8.1", - "chalk": "^5.4.1", "class-variance-authority": "^0.7.1", "close-with-grace": "^2.2.0", "clsx": "^2.1.1", @@ -7163,6 +7162,7 @@ "version": "5.4.1", "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.4.1.tgz", "integrity": "sha512-zgVZuo2WcZgfUEmsn6eO3kINexW8RAE4maiQ8QNs8CtpPCSyMiYsULR3HQYkm3w8FIA3SberyMJMSldGsW+U3w==", + "dev": true, "license": "MIT", "engines": { "node": "^12.17.0 || ^14.13 || >=16.0.0" diff --git a/package.json b/package.json index 14c3b9115..e4baaa5b4 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,6 @@ "address": "^2.0.3", "bcryptjs": "^2.4.3", "better-sqlite3": "^11.8.1", - "chalk": "^5.4.1", "class-variance-authority": "^0.7.1", "close-with-grace": "^2.2.0", "clsx": "^2.1.1", diff --git a/server/index.ts b/server/index.ts index 98fa792cb..b6db8975a 100644 --- a/server/index.ts +++ b/server/index.ts @@ -1,8 +1,8 @@ import crypto from 'node:crypto' +import { styleText } from 'node:util' import { createRequestHandler } from '@react-router/express' import * as Sentry from '@sentry/node' import { ip as ipAddress } from 'address' -import chalk from 'chalk' import closeWithGrace from 'close-with-grace' import compression from 'compression' import express from 'express' @@ -258,9 +258,7 @@ if (!portAvailable && !IS_DEV) { const server = app.listen(portToUse, () => { if (!portAvailable) { console.warn( - chalk.yellow( - `⚠️ Port ${desiredPort} is not available, using ${portToUse} instead.`, - ), + styleText('yellow', `⚠️ Port ${desiredPort} is not available, using ${portToUse} instead.`), ) } console.log(`🚀 We have liftoff!`) @@ -276,9 +274,9 @@ const server = app.listen(portToUse, () => { console.log( ` -${chalk.bold('Local:')} ${chalk.cyan(localUrl)} -${lanUrl ? `${chalk.bold('On Your Network:')} ${chalk.cyan(lanUrl)}` : ''} -${chalk.bold('Press Ctrl+C to stop')} +${styleText('bold', 'Local:')} ${styleText('cyan', localUrl)} +${lanUrl ? `${styleText('bold', 'On Your Network:')} ${styleText('cyan', lanUrl)}` : ''} +${styleText('bold', 'Press Ctrl+C to stop')} `.trim(), ) }) @@ -288,8 +286,8 @@ closeWithGrace(async ({ err }) => { server.close((e) => (e ? reject(e) : resolve('ok'))) }) if (err) { - console.error(chalk.red(err)) - console.error(chalk.red(err.stack)) + console.error(styleText('red', String(err))) + console.error(styleText('red', String(err.stack))) if (SENTRY_ENABLED) { Sentry.captureException(err) await Sentry.flush(500)