-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Replace kleur with picocolors
#14598
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
Changes from all commits
218c277
c25b4cf
0a89ff5
405c2a6
9cd0a1f
6ceab23
0f938c1
832a558
998ba04
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| '@astrojs/mdx': patch | ||
| '@astrojs/rss': patch | ||
| 'astro': patch | ||
| '@astrojs/db': patch | ||
| --- | ||
|
|
||
| Reduces terminal text styling dependency size by switching from `kleur` to `picocolors` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,6 @@ | |
| }, | ||
| "dependencies": { | ||
| "fast-xml-parser": "^5.3.0", | ||
| "kleur": "^4.1.5" | ||
| "picocolors": "^1.1.1" | ||
| } | ||
| } | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import colors from 'picocolors'; | ||
| import type { TextStyler } from '../definitions.js'; | ||
|
|
||
| export function createPicocolorsTextStyler(): TextStyler { | ||
| return colors; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ import { fileURLToPath } from 'node:url'; | |
| import { formatWithOptions } from 'node:util'; | ||
| import dlv from 'dlv'; | ||
| import { flattie } from 'flattie'; | ||
| import { bgGreen, black, bold, dim, yellow } from 'kleur/colors'; | ||
| import colors from 'picocolors'; | ||
| import { resolveConfig } from '../../core/config/config.js'; | ||
| import { createSettings } from '../../core/config/settings.js'; | ||
| import { collectErrorMetadata } from '../../core/errors/dev/utils.js'; | ||
|
|
@@ -13,6 +13,8 @@ import { coerce, isValidKey, type PreferenceKey } from '../../preferences/index. | |
| import type { AstroSettings } from '../../types/astro.js'; | ||
| import { createLoggerFromFlags, type Flags, flagsToAstroInlineConfig } from '../flags.js'; | ||
|
|
||
| const { bgGreen, black, bold, dim, yellow } = colors; | ||
|
|
||
| interface PreferencesOptions { | ||
| flags: Flags; | ||
| } | ||
|
|
@@ -323,9 +325,11 @@ function annotatedFormat(mv: AnnotatedValue) { | |
| // this is the real formatting for annotated values | ||
| function formatAnnotated( | ||
| mv: AnnotatedValue, | ||
| style: (value: string | number | boolean) => string = (v) => v.toString(), | ||
| style: (value: string) => string = (v) => v.toString(), | ||
| ) { | ||
| return mv.annotation ? `${style(mv.value)} ${dim(mv.annotation)}` : style(mv.value); | ||
| return mv.annotation | ||
| ? `${style(String(mv.value))} ${dim(mv.annotation)}` | ||
| : style(String(mv.value)); | ||
|
Comment on lines
+330
to
+332
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suspect this isn’t technically required, but |
||
| } | ||
| function formatTable(object: Record<string, AnnotatedValue>, columnLabels: [string, string]) { | ||
| const [colA, colB] = columnLabels; | ||
|
|
@@ -335,7 +339,7 @@ function formatTable(object: Record<string, AnnotatedValue>, columnLabels: [stri | |
| _i: number, | ||
| a: string, | ||
| b: AnnotatedValue, | ||
| style: (value: string | number | boolean) => string = (v) => v.toString(), | ||
| style: (value: string) => string = (v) => v.toString(), | ||
| ): string { | ||
| return `${dim(chars.v)} ${style(a)} ${space(colALength - a.length - 2)} ${dim( | ||
| chars.v, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In most modules, I refactored to use
colors.method()directly, but in a couple like this one where there’s heavy use of the APIs, I kept the destructured approach to minimize code changes and keep usage a bit cleaner.