Skip to content

Commit feb65c1

Browse files
torresgol10torresgol10.itdanthonyshew
authored
Replace chalk by picocolors (vercel/turborepo#8390)
We replaced chalk with picocolors as it is much more optimal and smaller. Discussions: vercel/turborepo#8341 In this PR has been the replacement in all the packages inside /packages/, I will make another one for the update of the examples, but I can also include in this same PR. I have deleted in 2 package.json the dependency on: @types/chalk-animation as I checked and it was not being used. Picocolors does not have the function to pass a hexadecimal colour to ASCII, to keep the colours, I have created the function and here 2 things to comment. I have created this function in the most used place in the turbo-utils / logger, but it is also used in 1 specific place, that's why I have used the export. 1. The implementation does not use the ‘bits’ because typescript gives error, if you see it necessary I can change the implementation. 2. I don't know if this is the right place to put this function, do you think it's necessary to create a test? --------- Co-authored-by: torresgol10.itd <[email protected]> Co-authored-by: Anthony Shew <[email protected]>
1 parent e821515 commit feb65c1

File tree

5 files changed

+18
-15
lines changed

5 files changed

+18
-15
lines changed

packages/devlow-bench/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838
},
3939
"dependencies": {
4040
"@datadog/datadog-api-client": "^1.13.0",
41-
"chalk": "2.4.2",
4241
"inquirer": "^9.2.7",
4342
"minimist": "^1.2.8",
43+
"picocolors": "1.0.1",
4444
"pidusage-tree": "^2.0.5",
4545
"playwright-chromium": "^1.39.0",
4646
"split2": "^4.2.0",

packages/devlow-bench/src/interfaces/console.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,38 @@
11
import { Interface, Scenario, ScenarioVariant } from "../index.js";
22
import inquirer from "inquirer";
3-
import chalk from "chalk";
3+
import { bgCyan, bold, magenta, red, underline } from "picocolors";
44
import { formatUnit } from "../units.js";
55
import { formatVariant } from "../utils.js";
66

77
export default function createInterface(): Interface {
88
const iface: Interface = {
99
start: async (scenario, props) => {
1010
console.log(
11-
chalk.bold.underline(`Running ${formatVariant(scenario, props)}...`)
11+
bold(underline(`Running ${formatVariant(scenario, props)}...`))
1212
);
1313
},
1414
measurement: async (scenario, props, name, value, unit, relativeTo) => {
1515
console.log(
16-
chalk.bgCyan.bold.magenta(
17-
`${formatVariant(scenario, props)}: ${name} = ${formatUnit(
18-
value,
19-
unit
20-
)}${relativeTo ? ` (from ${relativeTo})` : ""}`
16+
bgCyan(
17+
bold(
18+
magenta(
19+
`${formatVariant(scenario, props)}: ${name} = ${formatUnit(
20+
value,
21+
unit
22+
)}${relativeTo ? ` (from ${relativeTo})` : ""}`
23+
)
24+
)
2125
)
2226
);
2327
},
2428
error: async (scenario, props, error) => {
2529
console.log(
26-
chalk.bold.red(
27-
`${formatVariant(scenario, props)}: ${
28-
(error && (error as any).stack) || error
29-
}`
30+
bold(
31+
red(
32+
`${formatVariant(scenario, props)}: ${
33+
(error && (error as any).stack) || error
34+
}`
35+
)
3036
)
3137
);
3238
},

packages/devlow-bench/src/interfaces/interactive.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Interface, Scenario, ScenarioVariant } from "../index.js";
22
import inquirer from "inquirer";
3-
import chalk from "chalk";
43
import { formatUnit } from "../units.js";
54
import { formatVariant } from "../utils.js";
65

packages/devlow-bench/src/interfaces/json.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Interface, Scenario, ScenarioVariant } from "../index.js";
22
import inquirer from "inquirer";
3-
import chalk from "chalk";
43
import { formatUnit } from "../units.js";
54
import { formatVariant } from "../utils.js";
65
import { writeFile } from "fs/promises";
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
declare module "chalk";
21
declare module "pidusage-tree";

0 commit comments

Comments
 (0)