Skip to content

Commit 588e1a1

Browse files
authored
refactor(cli): replace picocolors with styleText (#1070)
1 parent a51e4bd commit 588e1a1

File tree

4 files changed

+10
-14
lines changed

4 files changed

+10
-14
lines changed

cli/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
"citty": "^0.2.0",
3737
"h3-next": "npm:h3@^2.0.1-rc.11",
3838
"obug": "^2.1.1",
39-
"picocolors": "^1.1.1",
4039
"srvx": "^0.10.1",
4140
"valibot": "^1.2.0",
4241
"validate-npm-package-name": "^7.0.2"

cli/src/cli.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env node
22
import process from 'node:process'
33
import { spawn } from 'node:child_process'
4+
import { styleText } from 'node:util'
45
import * as p from '@clack/prompts'
5-
import pc from 'picocolors'
66
import { defineCommand, runMain } from 'citty'
77
import { serve } from 'srvx'
88
import { createConnectorApp, generateToken, CONNECTOR_VERSION } from './server.ts'
@@ -52,7 +52,7 @@ const main = defineCommand({
5252

5353
// Warning message and accept prompt
5454
logWarning(
55-
`This allows ${pc.underline('npmx.dev')} to access your npm cli and any authenticated contexts.`,
55+
`This allows ${styleText('underline', 'npmx.dev')} to access your npm cli and any authenticated contexts.`,
5656
)
5757
const accept = await p.confirm({
5858
message: 'Do you accept?',

cli/src/logger.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { styleText } from 'node:util'
12
import * as p from '@clack/prompts'
2-
import pc from 'picocolors'
33
import { createDebug } from 'obug'
44

55
let isInitialized = false
@@ -10,35 +10,35 @@ let isInitialized = false
1010
export function initLogger(): void {
1111
if (isInitialized) return
1212
isInitialized = true
13-
p.intro(pc.bgCyan(pc.black(' npmx connector ')))
13+
p.intro(styleText(['bgCyan', 'black'], ' npmx connector '))
1414
}
1515

1616
/**
1717
* Log when starting to execute a command
1818
*/
1919
export function logCommand(command: string): void {
20-
p.log.step(pc.dim('$ ') + pc.cyan(command))
20+
p.log.step(`${styleText('dim', '$ ')}${styleText('cyan', command)}`)
2121
}
2222

2323
/**
2424
* Log successful command completion
2525
*/
2626
export function logSuccess(message: string): void {
27-
p.log.success(pc.green(message))
27+
p.log.success(styleText('green', message))
2828
}
2929

3030
/**
3131
* Log command failure
3232
*/
3333
export function logError(message: string): void {
34-
p.log.error(pc.red(message))
34+
p.log.error(styleText('red', message))
3535
}
3636

3737
/**
3838
* Log warning
3939
*/
4040
export function logWarning(message: string): void {
41-
p.log.warn(pc.yellow(message))
41+
p.log.warn(styleText('yellow', message))
4242
}
4343

4444
/**
@@ -61,9 +61,9 @@ export function showToken(token: string, port: number, frontendUrl: string): voi
6161

6262
p.note(
6363
[
64-
`Open: ${pc.bold(pc.underline(pc.cyan(connectUrl)))}`,
64+
`Open: ${styleText(['bold', 'underline', 'cyan'], connectUrl)}`,
6565
'',
66-
pc.dim(`Or paste token manually: ${token}`),
66+
styleText('dim', `Or paste token manually: ${token}`),
6767
].join('\n'),
6868
'Click to connect',
6969
)

pnpm-lock.yaml

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)