Skip to content

Commit af3a7f9

Browse files
Remove chalk (#928)
1 parent a5dec63 commit af3a7f9

File tree

5 files changed

+12
-16
lines changed

5 files changed

+12
-16
lines changed

app/entry.server.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { PassThrough } from 'node:stream'
2+
import { styleText } from 'node:util'
23
import { createReadableStreamFromReadable } from '@react-router/node'
3-
44
import * as Sentry from '@sentry/node'
5-
import chalk from 'chalk'
65
import { isbot } from 'isbot'
76
import { renderToPipeableStream } from 'react-dom/server'
87
import {
@@ -107,7 +106,7 @@ export function handleError(
107106
return
108107
}
109108
if (error instanceof Error) {
110-
console.error(chalk.red(error.stack))
109+
console.error(styleText('red', String(error.stack)))
111110
void Sentry.captureException(error)
112111
} else {
113112
console.error(error)

app/utils/db.server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import { styleText } from 'node:util'
12
import { remember } from '@epic-web/remember'
23
// Changed import due to issue: https://github.com/remix-run/react-router/pull/12644
34
import { PrismaClient } from '@prisma/client/index.js'
4-
import chalk from 'chalk'
55

66
export const prisma = remember('prisma', () => {
77
// NOTE: if you change anything in this function you'll need to restart
@@ -29,7 +29,7 @@ export const prisma = remember('prisma', () => {
2929
: e.duration < logThreshold * 1.4
3030
? 'redBright'
3131
: 'red'
32-
const dur = chalk[color](`${e.duration}ms`)
32+
const dur = styleText(color, `${e.duration}ms`)
3333
console.info(`prisma:query - ${dur} - ${e.query}`)
3434
})
3535
void client.$connect()

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@
7676
"address": "^2.0.3",
7777
"bcryptjs": "^2.4.3",
7878
"better-sqlite3": "^11.8.1",
79-
"chalk": "^5.4.1",
8079
"class-variance-authority": "^0.7.1",
8180
"close-with-grace": "^2.2.0",
8281
"clsx": "^2.1.1",

server/index.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import crypto from 'node:crypto'
2+
import { styleText } from 'node:util'
23
import { createRequestHandler } from '@react-router/express'
34
import * as Sentry from '@sentry/node'
45
import { ip as ipAddress } from 'address'
5-
import chalk from 'chalk'
66
import closeWithGrace from 'close-with-grace'
77
import compression from 'compression'
88
import express from 'express'
@@ -258,9 +258,7 @@ if (!portAvailable && !IS_DEV) {
258258
const server = app.listen(portToUse, () => {
259259
if (!portAvailable) {
260260
console.warn(
261-
chalk.yellow(
262-
`⚠️ Port ${desiredPort} is not available, using ${portToUse} instead.`,
263-
),
261+
styleText('yellow', `⚠️ Port ${desiredPort} is not available, using ${portToUse} instead.`),
264262
)
265263
}
266264
console.log(`🚀 We have liftoff!`)
@@ -276,9 +274,9 @@ const server = app.listen(portToUse, () => {
276274

277275
console.log(
278276
`
279-
${chalk.bold('Local:')} ${chalk.cyan(localUrl)}
280-
${lanUrl ? `${chalk.bold('On Your Network:')} ${chalk.cyan(lanUrl)}` : ''}
281-
${chalk.bold('Press Ctrl+C to stop')}
277+
${styleText('bold', 'Local:')} ${styleText('cyan', localUrl)}
278+
${lanUrl ? `${styleText('bold', 'On Your Network:')} ${styleText('cyan', lanUrl)}` : ''}
279+
${styleText('bold', 'Press Ctrl+C to stop')}
282280
`.trim(),
283281
)
284282
})
@@ -288,8 +286,8 @@ closeWithGrace(async ({ err }) => {
288286
server.close((e) => (e ? reject(e) : resolve('ok')))
289287
})
290288
if (err) {
291-
console.error(chalk.red(err))
292-
console.error(chalk.red(err.stack))
289+
console.error(styleText('red', String(err)))
290+
console.error(styleText('red', String(err.stack)))
293291
if (SENTRY_ENABLED) {
294292
Sentry.captureException(err)
295293
await Sentry.flush(500)

0 commit comments

Comments
 (0)