Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: replace picocolors and chalk with ansis #935

Merged
merged 1 commit into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"lint": "eslint . --cache",
"release": "bumpp",
"publish:ci": "pnpm -r publish --access public --no-git-checks",
"test": "vitest",
"test": "FORCE_COLOR=3 && vitest",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "FORCE_COLOR=3" required to enable color output in console, since vitest is not TTY.

"typecheck": "vue-tsc --noEmit",
"build": "pnpm -r run build",
"docs": "pnpm -C docs run docs:dev",
Expand Down Expand Up @@ -41,6 +41,7 @@
"@types/node": "catalog:",
"@vitest/coverage-v8": "catalog:",
"ansi-sequence-parser": "catalog:",
"ansis": "catalog:",
"bumpp": "catalog:",
"diff-match-patch-es": "catalog:",
"eslint": "catalog:",
Expand All @@ -57,7 +58,6 @@
"mdast-util-to-hast": "catalog:",
"ofetch": "catalog:",
"ohash": "catalog:",
"picocolors": "catalog:",
"pnpm": "catalog:",
"prettier": "catalog:",
"rimraf": "catalog:",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
},
"dependencies": {
"@shikijs/vscode-textmate": "catalog:",
"chalk": "catalog:",
"ansis": "catalog:",
"minimist": "catalog:",
"shiki": "workspace:*"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/code-to-ansi.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { BundledLanguage, BundledTheme } from 'shiki'
import { FontStyle } from '@shikijs/vscode-textmate'
import c from 'chalk'
import c from 'ansis'
import { codeToTokensBase, getSingletonHighlighter } from 'shiki'
import { hexApplyAlpha } from './colors'

Expand Down
2 changes: 1 addition & 1 deletion packages/colorized-brackets/test/fixtures.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { lstatSync, readdirSync } from 'node:fs'
import { readFile } from 'node:fs/promises'
import { join, sep } from 'node:path'
import c from 'picocolors'
import c from 'ansis'
import { createHighlighter } from 'shiki'
import { describe, expect, it } from 'vitest'
import { transformerColorizedBrackets } from '../src'
Expand Down
2 changes: 1 addition & 1 deletion packages/colorized-brackets/test/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import c from 'picocolors'
import c from 'ansis'

interface ColoredBracket {
bracket: string
Expand Down
2,477 changes: 1,265 additions & 1,212 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ catalog:
'@vitest/coverage-v8': ^3.0.5
'@vueuse/core': ^12.7.0
ansi-sequence-parser: ^1.1.3
ansis: ^3.15.0
bumpp: ^10.0.3
cac: ^6.7.14
chalk: ^5.4.1
diff-match-patch-es: ^1.0.1
eslint: ^9.20.1
eslint-plugin-format: ^1.0.1
Expand All @@ -58,7 +58,6 @@ catalog:
ofetch: ^1.4.1
ohash: ^1.1.4
oniguruma-to-es: ^3.1.0
picocolors: ^1.1.1
pinia: ^3.0.1
pnpm: ^10.4.0
prettier: ^3.5.1
Expand Down
12 changes: 6 additions & 6 deletions scripts/report-engine-js-compat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import type { Diff } from 'diff-match-patch-es'
import type { BundledLanguage, BundledTheme, HighlighterGeneric } from 'shiki'
import fs from 'node:fs/promises'
import process from 'node:process'
import c from 'ansis'
import { diffCleanupSemantic, diffMain } from 'diff-match-patch-es'
import c from 'picocolors'
import { format } from 'prettier'
import { bundledLanguages, createHighlighter, createJavaScriptRegexEngine } from 'shiki'
import { version } from '../package.json'
Expand Down Expand Up @@ -42,7 +42,7 @@ async function run() {
.catch(() => '')

if (!sample) {
console.log(c.dim(`[${lang}] Sample not found`))
console.log(c.dim`[${lang}] Sample not found`)
continue
}

Expand Down Expand Up @@ -85,7 +85,7 @@ async function run() {
}
catch (e: any) {
highlightMatch = 'error'
console.log(c.red(`[${lang}] Error ${e} ${e.cause || ''}`))
console.log(c.red`[${lang}] Error ${e} ${e.cause || ''}`)
}
finally {
shiki?.dispose()
Expand All @@ -101,7 +101,7 @@ async function run() {
highlightB = serializeTokens(shiki, sample, lang)
}
catch (e: any) {
console.log(c.red(`[${lang}] Error ${e} ${e.cause || ''}`))
console.log(c.red`[${lang}] Error ${e} ${e.cause || ''}`)
}
finally {
shiki?.dispose()
Expand All @@ -115,7 +115,7 @@ async function run() {
diffCleanupSemantic(highlightDiff)

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

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

Expand All @@ -137,7 +137,7 @@ async function run() {
)
}
else {
console.log(c.green(`[${lang}] OK`))
console.log(c.green`[${lang}] OK`)
}

report.push({
Expand Down
Loading