Skip to content

Commit df1029a

Browse files
committed
fix: drop boxen and chalk deps
Fixes #230
1 parent 39d853a commit df1029a

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

packages/core/package.json

-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@
5252
"@unrouted/preset-api": "^0.6.0",
5353
"@unrouted/preset-node": "^0.6.0",
5454
"axios": "^1.7.7",
55-
"boxen": "^8.0.1",
56-
"chalk": "^5.3.0",
5755
"cheerio": "1.0.0",
5856
"chrome-launcher": "^1.1.2",
5957
"consola": "^3.2.3",

packages/core/src/puppeteer/worker.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type {
1010
} from '../types'
1111
import fs from 'node:fs'
1212
import { join } from 'node:path'
13-
import chalk from 'chalk'
13+
import { colorize } from 'consola/utils'
1414
import { get, sortBy, uniqBy } from 'lodash-es'
1515
import { matchPathToRule } from '../discovery'
1616
import { useLogger } from '../logger'
@@ -208,7 +208,7 @@ export async function createUnlighthouseWorker(tasks: Record<UnlighthouseTask, T
208208
reportData.push(formatBytes(response.seo.htmlSize))
209209
}
210210
reportData.push(`${monitor().donePercStr}% complete`)
211-
logger.success(`Completed \`${taskName}\` for \`${routeReport.route.path}\`. ${chalk.gray(`(${reportData.join(' ')})`)}`)
211+
logger.success(`Completed \`${taskName}\` for \`${routeReport.route.path}\`. ${colorize('gray', `(${reportData.join(' ')})`)}`)
212212
// run the next task
213213
runTaskIndex(idx + 1)
214214
})

packages/core/src/unlighthouse.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type {
1010
} from './types'
1111
import { existsSync } from 'node:fs'
1212
import { isAbsolute, join } from 'node:path'
13-
import chalk from 'chalk'
13+
import { colorize } from 'consola/utils'
1414
import { defu } from 'defu'
1515
import fs from 'fs-extra'
1616
import { createHooks } from 'hookable'
@@ -329,7 +329,7 @@ export async function createUnlighthouse(userConfig: UserConfig, provider?: Prov
329329

330330
if (provider?.name !== 'ci') {
331331
// fancy CLI banner when we start
332-
const label = (name: string) => chalk.bold.magenta(`▸ ${name}:`)
332+
const label = (name: string) => colorize('bold', colorize('magenta', (`▸ ${name}:`)))
333333
let mode = ''
334334
if (resolvedConfig.urls?.length)
335335
mode = 'Manual'
@@ -347,35 +347,35 @@ export async function createUnlighthouse(userConfig: UserConfig, provider?: Prov
347347
catch (e) {}
348348

349349
const title = [
350-
`⛵ ${chalk.bold.blueBright(AppName)} ${chalk.dim(`${provider?.name} @ v${version}`)}`,
350+
`⛵ ${colorize('bold', colorize('blueBright', AppName))} ${colorize('dim', `${provider?.name} @ v${version}`)}`,
351351
]
352352
if (Number(latestTag.replace('v', '').replace('.', '')) > Number(version.replace('.', ''))) {
353353
title.push(...[
354354
'',
355355
`🎉 New version ${latestTag} available! Use the latest:`,
356-
chalk.gray(` > ${chalk.underline(`npx unlighthouse@^${latestTag} --site ${resolvedConfig.site}`)}`),
356+
colorize('gray', ` > ${colorize('underline', `npx unlighthouse@^${latestTag} --site ${resolvedConfig.site}`)}`),
357357
])
358358
}
359359
title.push(...[
360360
'',
361361
`${label('Scanning')} ${resolvedConfig.site}`,
362-
`${label('Route Discovery')} ${mode} ${ctx.routes.length > 1 ? (chalk.dim(`${ctx.routes.length} initial URLs`)) : ''}`,
362+
`${label('Route Discovery')} ${mode} ${ctx.routes.length > 1 ? (colorize('dim', (`${ctx.routes.length} initial URLs`))) : ''}`,
363363
'',
364-
chalk.dim(' 💖 Like Unlighthouse? Support the development: https://github.com/sponsors/harlan-zw'),
364+
colorize('dim', (' 💖 Like Unlighthouse? Support the development: https://github.com/sponsors/harlan-zw')),
365365
])
366366
if (ctx.routeDefinitions?.length)
367367
title.push(`${label('Route Definitions')} ${ctx.routeDefinitions.length}`)
368368

369369
process.stdout.write(successBox(
370370
// messages
371371
[
372-
ctx.runtimeSettings.clientUrl ? chalk.whiteBright(`Report: ${ctx.runtimeSettings.clientUrl}`) : '',
372+
ctx.runtimeSettings.clientUrl ? colorize('whiteBright', `Report: ${ctx.runtimeSettings.clientUrl}`) : '',
373373
].join('\n'),
374374
// title
375375
title.join('\n'),
376376
))
377377
if (existsSync(join(ctx.runtimeSettings.generatedClientPath, 'reports', 'lighthouse.json')) && ctx.resolvedConfig.cache)
378-
logger.info(`Restoring reports from cache. ${chalk.gray('You can disable this behavior by passing --no-cache.')}`)
378+
logger.info(`Restoring reports from cache. ${colorize('gray', 'You can disable this behavior by passing --no-cache.')}`)
379379
}
380380
return ctx
381381
}

packages/core/src/util/cliFormatting.ts

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import boxen from 'boxen'
2-
import chalk from 'chalk'
1+
import type { BoxOpts } from 'consola/utils'
2+
import { colorize, box as makeBox } from 'consola/utils'
33
import wrapAnsi from 'wrap-ansi'
44

55
/**
@@ -30,11 +30,11 @@ export function foldLines(string: string, spaces: number, firstLineSpaces: numbe
3030
return indentLines(wrapAnsi(string, charsPerLine), spaces, firstLineSpaces)
3131
}
3232

33-
export function box(message: string, title: string, options: any) {
34-
return `${boxen([
35-
title || chalk.white('Nuxt Message'),
33+
export function box(message: string, title: string, options?: BoxOpts) {
34+
return `${makeBox([
35+
title,
3636
'',
37-
chalk.white(foldLines(message, 0, 0, maxCharsPerLine())),
37+
colorize('white', foldLines(message, 0, 0, maxCharsPerLine())),
3838
].join('\n'), Object.assign({
3939
borderColor: 'white',
4040
borderStyle: 'round',
@@ -44,7 +44,9 @@ export function box(message: string, title: string, options: any) {
4444
}
4545

4646
export function successBox(message: string, title: string) {
47-
return box(message, title || chalk.green('✔ Nuxt Success'), {
48-
borderColor: 'green',
47+
return box(message, title, {
48+
style: {
49+
borderColor: 'green',
50+
},
4951
})
5052
}

0 commit comments

Comments
 (0)