Skip to content

Commit a948b8b

Browse files
authoredFeb 12, 2025··
feat: replace picocolors with ansis (#259)
1 parent 3797d46 commit a948b8b

File tree

6 files changed

+18
-12
lines changed

6 files changed

+18
-12
lines changed
 

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@
5555
"@types/ini": "^4.1.1",
5656
"@types/node": "^22.10.10",
5757
"@types/which": "^3.0.4",
58+
"ansis": "^3.12.0",
5859
"bumpp": "^10.0.1",
5960
"eslint": "^9.19.0",
6061
"fs-extra": "^11.3.0",
6162
"fzf": "^0.5.2",
6263
"ini": "^5.0.0",
6364
"lint-staged": "^15.4.2",
6465
"package-manager-detector": "^0.2.9",
65-
"picocolors": "^1.1.1",
6666
"simple-git-hooks": "^2.11.1",
6767
"taze": "^18.3.0",
6868
"terminal-link": "^3.0.0",

‎pnpm-lock.yaml

+9-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/commands/ni.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { Choice } from '@posva/prompts'
22
import process from 'node:process'
33
import prompts from '@posva/prompts'
4+
import c from 'ansis'
45
import { Fzf } from 'fzf'
5-
import c from 'picocolors'
66
import { fetchNpmPackages } from '../fetch'
77
import { parseNi } from '../parse'
88
import { runCli } from '../runner'

‎src/fetch.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Choice } from '@posva/prompts'
22
import process from 'node:process'
3-
import c from 'picocolors'
3+
import c from 'ansis'
44
import { formatPackageWithUrl } from './utils'
55

66
export interface NpmPackage {
@@ -32,7 +32,7 @@ export async function fetchNpmPackages(pattern: string): Promise<Choice[]> {
3232

3333
return result.objects.map(({ package: pkg }) => ({
3434
title: formatPackageWithUrl(
35-
`${pkg.name.padEnd(30, ' ')} ${c.blue(`v${pkg.version}`)}`,
35+
`${pkg.name.padEnd(30, ' ')} ${c.blue`v${pkg.version}`}`,
3636
pkg.links.repository ?? pkg.links.npm,
3737
terminalColumns,
3838
),

‎src/runner.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import type { DetectOptions } from './detect'
55
import { resolve } from 'node:path'
66
import process from 'node:process'
77
import prompts from '@posva/prompts'
8+
import c from 'ansis'
89
import { AGENTS } from 'package-manager-detector'
9-
import c from 'picocolors'
1010
import { x } from 'tinyexec'
1111
import { version } from '../package.json'
1212
import { getDefaultAgent, getGlobalAgent } from './config'
@@ -110,7 +110,7 @@ export async function run(fn: Runner, args: string[], options: DetectOptions = {
110110
const agentVersionPromise = agentPromise.then(a => a && getV(a))
111111
const nodeVersionPromise = getV('node')
112112

113-
console.log(`@antfu/ni ${c.cyan(`v${version}`)}`)
113+
console.log(`@antfu/ni ${c.cyan`v${version}`}`)
114114
console.log(`node ${c.green(await nodeVersionPromise)}`)
115115
const [agent, agentVersion] = await Promise.all([agentPromise, agentVersionPromise])
116116
if (agent)
@@ -124,7 +124,7 @@ export async function run(fn: Runner, args: string[], options: DetectOptions = {
124124

125125
if (args.length === 1 && ['-h', '--help'].includes(args[0])) {
126126
const dash = c.dim('-')
127-
console.log(c.green(c.bold('@antfu/ni')) + c.dim(` use the right package manager v${version}\n`))
127+
console.log(c.green.bold('@antfu/ni') + c.dim` use the right package manager v${version}\n`)
128128
console.log(`ni ${dash} install`)
129129
console.log(`nr ${dash} run`)
130130
console.log(`nlx ${dash} execute`)

‎src/utils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { existsSync, promises as fs } from 'node:fs'
33
import os from 'node:os'
44
import { dirname, join } from 'node:path'
55
import process from 'node:process'
6-
import c from 'picocolors'
6+
import c from 'ansis'
77
import terminalLink from 'terminal-link'
88
import which from 'which'
99

@@ -101,7 +101,7 @@ export function formatPackageWithUrl(pkg: string, url?: string, limits = 80) {
101101
{
102102
fallback: (_, url) => (pkg.length + url.length > limits)
103103
? pkg
104-
: pkg + c.dim(` - ${url}`),
104+
: pkg + c.dim` - ${url}`,
105105
},
106106
)
107107
: pkg

0 commit comments

Comments
 (0)
Please sign in to comment.