Skip to content

Commit ecc4a66

Browse files
authored
feat: replace picocolors and chalk with ansis (#935)
1 parent aa84bbc commit ecc4a66

File tree

8 files changed

+1278
-1226
lines changed

8 files changed

+1278
-1226
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"lint": "eslint . --cache",
88
"release": "bumpp",
99
"publish:ci": "pnpm -r publish --access public --no-git-checks",
10-
"test": "vitest",
10+
"test": "FORCE_COLOR=3 && vitest",
1111
"typecheck": "vue-tsc --noEmit",
1212
"build": "pnpm -r run build",
1313
"docs": "pnpm -C docs run docs:dev",
@@ -41,6 +41,7 @@
4141
"@types/node": "catalog:",
4242
"@vitest/coverage-v8": "catalog:",
4343
"ansi-sequence-parser": "catalog:",
44+
"ansis": "catalog:",
4445
"bumpp": "catalog:",
4546
"diff-match-patch-es": "catalog:",
4647
"eslint": "catalog:",
@@ -57,7 +58,6 @@
5758
"mdast-util-to-hast": "catalog:",
5859
"ofetch": "catalog:",
5960
"ohash": "catalog:",
60-
"picocolors": "catalog:",
6161
"pnpm": "catalog:",
6262
"prettier": "catalog:",
6363
"rimraf": "catalog:",

packages/cli/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
},
4949
"dependencies": {
5050
"@shikijs/vscode-textmate": "catalog:",
51-
"chalk": "catalog:",
51+
"ansis": "catalog:",
5252
"minimist": "catalog:",
5353
"shiki": "workspace:*"
5454
},

packages/cli/src/code-to-ansi.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { BundledLanguage, BundledTheme } from 'shiki'
22
import { FontStyle } from '@shikijs/vscode-textmate'
3-
import c from 'chalk'
3+
import c from 'ansis'
44
import { codeToTokensBase, getSingletonHighlighter } from 'shiki'
55
import { hexApplyAlpha } from './colors'
66

packages/colorized-brackets/test/fixtures.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { lstatSync, readdirSync } from 'node:fs'
33
import { readFile } from 'node:fs/promises'
44
import { join, sep } from 'node:path'
5-
import c from 'picocolors'
5+
import c from 'ansis'
66
import { createHighlighter } from 'shiki'
77
import { describe, expect, it } from 'vitest'
88
import { transformerColorizedBrackets } from '../src'

packages/colorized-brackets/test/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import c from 'picocolors'
1+
import c from 'ansis'
22

33
interface ColoredBracket {
44
bracket: string

pnpm-lock.yaml

+1,265-1,212
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ catalog:
3131
'@vitest/coverage-v8': ^3.0.5
3232
'@vueuse/core': ^12.7.0
3333
ansi-sequence-parser: ^1.1.3
34+
ansis: ^3.15.0
3435
bumpp: ^10.0.3
3536
cac: ^6.7.14
36-
chalk: ^5.4.1
3737
diff-match-patch-es: ^1.0.1
3838
eslint: ^9.20.1
3939
eslint-plugin-format: ^1.0.1
@@ -58,7 +58,6 @@ catalog:
5858
ofetch: ^1.4.1
5959
ohash: ^1.1.4
6060
oniguruma-to-es: ^3.1.0
61-
picocolors: ^1.1.1
6261
pinia: ^3.0.1
6362
pnpm: ^10.4.0
6463
prettier: ^3.5.1

scripts/report-engine-js-compat.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import type { Diff } from 'diff-match-patch-es'
66
import type { BundledLanguage, BundledTheme, HighlighterGeneric } from 'shiki'
77
import fs from 'node:fs/promises'
88
import process from 'node:process'
9+
import c from 'ansis'
910
import { diffCleanupSemantic, diffMain } from 'diff-match-patch-es'
10-
import c from 'picocolors'
1111
import { format } from 'prettier'
1212
import { bundledLanguages, createHighlighter, createJavaScriptRegexEngine } from 'shiki'
1313
import { version } from '../package.json'
@@ -42,7 +42,7 @@ async function run() {
4242
.catch(() => '')
4343

4444
if (!sample) {
45-
console.log(c.dim(`[${lang}] Sample not found`))
45+
console.log(c.dim`[${lang}] Sample not found`)
4646
continue
4747
}
4848

@@ -85,7 +85,7 @@ async function run() {
8585
}
8686
catch (e: any) {
8787
highlightMatch = 'error'
88-
console.log(c.red(`[${lang}] Error ${e} ${e.cause || ''}`))
88+
console.log(c.red`[${lang}] Error ${e} ${e.cause || ''}`)
8989
}
9090
finally {
9191
shiki?.dispose()
@@ -101,7 +101,7 @@ async function run() {
101101
highlightB = serializeTokens(shiki, sample, lang)
102102
}
103103
catch (e: any) {
104-
console.log(c.red(`[${lang}] Error ${e} ${e.cause || ''}`))
104+
console.log(c.red`[${lang}] Error ${e} ${e.cause || ''}`)
105105
}
106106
finally {
107107
shiki?.dispose()
@@ -115,7 +115,7 @@ async function run() {
115115
diffCleanupSemantic(highlightDiff)
116116

117117
if (highlightB && highlightMatch !== true) {
118-
console.log(c.yellow(`[${lang}] Mismatch`))
118+
console.log(c.yellow`[${lang}] Mismatch`)
119119

120120
await fs.mkdir(new URL('./compares', import.meta.url), { recursive: true })
121121

@@ -137,7 +137,7 @@ async function run() {
137137
)
138138
}
139139
else {
140-
console.log(c.green(`[${lang}] OK`))
140+
console.log(c.green`[${lang}] OK`)
141141
}
142142

143143
report.push({

0 commit comments

Comments
 (0)