diff --git a/packages/create-turbo/__tests__/index.test.ts b/packages/create-turbo/__tests__/index.test.ts index bb5f1d62b307e..369e2eec7d928 100644 --- a/packages/create-turbo/__tests__/index.test.ts +++ b/packages/create-turbo/__tests__/index.test.ts @@ -1,6 +1,6 @@ import path from "node:path"; import childProcess from "node:child_process"; -import chalk from "chalk"; +import { bold, cyan, green, red } from "picocolors"; import { setupTestFixtures, spyConsole, spyExit } from "@turbo/test-utils"; import { logger } from "@turbo/utils"; import type { PackageManager } from "@turbo/utils"; @@ -92,20 +92,16 @@ describe("create-turbo", () => { telemetry, }); - const expected = `${chalk.bold( + const expected = `${bold( logger.turboGradient(">>> Success!") - )} Created your Turborepo at ${chalk.green( + )} Created your Turborepo at ${green( path.relative(process.cwd(), root) )}`; expect(mockConsole.log).toHaveBeenCalledWith(expected); expect(mockConsole.log).toHaveBeenCalledWith(); - expect(mockConsole.log).toHaveBeenCalledWith( - chalk.bold("To get started:") - ); + expect(mockConsole.log).toHaveBeenCalledWith(bold("To get started:")); - expect(mockConsole.log).toHaveBeenCalledWith( - chalk.cyan("Library packages") - ); + expect(mockConsole.log).toHaveBeenCalledWith(cyan("Library packages")); expect(mockConsole.log).toHaveBeenCalledWith( "- Run commands with Turborepo:" @@ -113,7 +109,7 @@ describe("create-turbo", () => { availableScripts.forEach((script) => { expect(mockConsole.log).toHaveBeenCalledWith( - expect.stringContaining(chalk.cyan(`${packageManager} run ${script}`)) + expect.stringContaining(cyan(`${packageManager} run ${script}`)) ); }); @@ -179,20 +175,16 @@ describe("create-turbo", () => { telemetry, }); - const expected = `${chalk.bold( + const expected = `${bold( logger.turboGradient(">>> Success!") - )} Created your Turborepo at ${chalk.green( + )} Created your Turborepo at ${green( path.relative(process.cwd(), root) )}`; expect(mockConsole.log).toHaveBeenCalledWith(expected); expect(mockConsole.log).toHaveBeenCalledWith(); - expect(mockConsole.log).toHaveBeenCalledWith( - chalk.bold("To get started:") - ); + expect(mockConsole.log).toHaveBeenCalledWith(bold("To get started:")); - expect(mockConsole.log).toHaveBeenCalledWith( - chalk.cyan("Library packages") - ); + expect(mockConsole.log).toHaveBeenCalledWith(cyan("Library packages")); expect(mockConsole.log).toHaveBeenCalledWith( "- Run commands with Turborepo:" @@ -200,7 +192,7 @@ describe("create-turbo", () => { availableScripts.forEach((script) => { expect(mockConsole.log).toHaveBeenCalledWith( - expect.stringContaining(chalk.cyan(`${packageManager} run ${script}`)) + expect.stringContaining(cyan(`${packageManager} run ${script}`)) ); }); @@ -255,13 +247,13 @@ describe("create-turbo", () => { expect(mockConsole.error).toHaveBeenCalledTimes(2); expect(mockConsole.error).toHaveBeenNthCalledWith( 1, - logger.turboRed.bold(">>>"), - chalk.red("Unable to download template from Github") + logger.turboRed(bold(">>>")), + red("Unable to download template from Github") ); expect(mockConsole.error).toHaveBeenNthCalledWith( 2, - logger.turboRed.bold(">>>"), - chalk.red("Could not connect") + logger.turboRed(bold(">>>")), + red("Could not connect") ); expect(mockExit.exit).toHaveBeenCalledWith(1); diff --git a/packages/create-turbo/package.json b/packages/create-turbo/package.json index 5ebc3f5c2f16c..a74d91ca7f973 100644 --- a/packages/create-turbo/package.json +++ b/packages/create-turbo/package.json @@ -23,10 +23,10 @@ "lint:prettier": "prettier -c . --cache --ignore-path=../../.prettierignore" }, "dependencies": { - "chalk": "4.1.2", "commander": "^11.0.0", "fs-extra": "^11.1.1", "inquirer": "^8.0.0", + "picocolors": "1.0.1", "proxy-agent": "^6.2.2", "rimraf": "^3.0.2", "semver": "^7.3.8", diff --git a/packages/create-turbo/src/cli.ts b/packages/create-turbo/src/cli.ts index 3d1b252d7db0c..856b78938e423 100644 --- a/packages/create-turbo/src/cli.ts +++ b/packages/create-turbo/src/cli.ts @@ -2,7 +2,7 @@ import http from "node:http"; import https from "node:https"; -import chalk from "chalk"; +import { bold } from "picocolors"; import { Command, Option } from "commander"; import { logger } from "@turbo/utils"; import { @@ -27,9 +27,9 @@ const createTurboCli = new Command(); // create createTurboCli - .name(chalk.bold(logger.turboGradient("create-turbo"))) + .name(bold(logger.turboGradient("create-turbo"))) .description("Create a new Turborepo") - .usage(`${chalk.bold("")} [options]`) + .usage(`${bold("")} [options]`) .hook("preAction", async (_, thisAction) => { const { telemetry } = await initTelemetry<"create-turbo">({ packageInfo: { diff --git a/packages/create-turbo/src/commands/create/index.ts b/packages/create-turbo/src/commands/create/index.ts index 6904d8c778bca..9d21ad65f9120 100644 --- a/packages/create-turbo/src/commands/create/index.ts +++ b/packages/create-turbo/src/commands/create/index.ts @@ -1,5 +1,5 @@ import path from "node:path"; -import chalk from "chalk"; +import { bold, red, cyan, green } from "picocolors"; import type { Project } from "@turbo/workspaces"; import { getWorkspaceDetails, @@ -39,18 +39,18 @@ function handleErrors( telemetry?.trackCommandStatus({ command: "create", status: "error" }); // handle errors from ../../transforms if (err instanceof TransformError) { - error(chalk.bold(err.transform), chalk.red(err.message)); + error(bold(err.transform), red(err.message)); if (err.fatal) { process.exit(1); } // handle errors from @turbo/workspaces } else if (err instanceof ConvertError && err.type !== "unknown") { - error(chalk.red(err.message)); + error(red(err.message)); process.exit(1); // handle download errors from @turbo/utils } else if (err instanceof DownloadError) { - error(chalk.red("Unable to download template from Github")); - error(chalk.red(err.message)); + error(red("Unable to download template from Github")); + error(red(err.message)); process.exit(1); } @@ -203,16 +203,14 @@ export async function create( let lastGroup: string | undefined; workspacesForDisplay.forEach(({ group, title, description }, idx) => { if (idx === 0 || group !== lastGroup) { - logger.log(chalk.cyan(group)); + logger.log(cyan(group)); } - logger.log( - ` - ${chalk.bold(title)}${description ? `: ${description}` : ""}` - ); + logger.log(` - ${bold(title)}${description ? `: ${description}` : ""}`); lastGroup = group; }); } else { - logger.log(chalk.cyan("apps")); - logger.log(` - ${chalk.bold(projectName)}`); + logger.log(cyan("apps")); + logger.log(` - ${bold(projectName)}`); } // run install @@ -248,15 +246,13 @@ export async function create( if (projectDirIsCurrentDir) { logger.log( - `${chalk.bold( - turboGradient(">>> Success!") - )} Your new Turborepo is ready.` + `${bold(turboGradient(">>> Success!"))} Your new Turborepo is ready.` ); } else { logger.log( - `${chalk.bold( - turboGradient(">>> Success!") - )} Created your Turborepo at ${chalk.green(relativeProjectDir)}` + `${bold(turboGradient(">>> Success!"))} Created your Turborepo at ${green( + relativeProjectDir + )}` ); } @@ -264,14 +260,14 @@ export async function create( const packageManagerMeta = getPackageManagerMeta(projectPackageManager); if (packageManagerMeta && hasPackageJson) { logger.log(); - logger.log(chalk.bold("To get started:")); + logger.log(bold("To get started:")); if (!projectDirIsCurrentDir) { logger.log( - `- Change to the directory: ${chalk.cyan(`cd ${relativeProjectDir}`)}` + `- Change to the directory: ${cyan(`cd ${relativeProjectDir}`)}` ); } logger.log( - `- Enable Remote Caching (recommended): ${chalk.cyan( + `- Enable Remote Caching (recommended): ${cyan( `${packageManagerMeta.executable} turbo login` )}` ); @@ -282,7 +278,7 @@ export async function create( .filter((script) => SCRIPTS_TO_DISPLAY[script]) .forEach((script) => { logger.log( - ` - ${chalk.cyan(`${packageManagerMeta.command} run ${script}`)}: ${ + ` - ${cyan(`${packageManagerMeta.command} run ${script}`)}: ${ SCRIPTS_TO_DISPLAY[script] } all apps and packages` ); diff --git a/packages/create-turbo/src/utils/notifyUpdate.ts b/packages/create-turbo/src/utils/notifyUpdate.ts index 26083ebef5415..397e19c04c0ed 100644 --- a/packages/create-turbo/src/utils/notifyUpdate.ts +++ b/packages/create-turbo/src/utils/notifyUpdate.ts @@ -1,4 +1,4 @@ -import chalk from "chalk"; +import { yellow, bold } from "picocolors"; import checkForUpdate from "update-check"; import { logger } from "@turbo/utils"; import cliPkgJson from "../../package.json"; @@ -10,9 +10,7 @@ export async function notifyUpdate(): Promise { const res = await update; if (res?.latest) { logger.log(); - logger.log( - chalk.yellow.bold("A new version of `create-turbo` is available!") - ); + logger.log(yellow(bold("A new version of `create-turbo` is available!"))); logger.log(); } process.exit(); diff --git a/packages/devlow-bench/package.json b/packages/devlow-bench/package.json index 0369144a5edb7..997b889898f23 100644 --- a/packages/devlow-bench/package.json +++ b/packages/devlow-bench/package.json @@ -38,9 +38,9 @@ }, "dependencies": { "@datadog/datadog-api-client": "^1.13.0", - "chalk": "2.4.2", "inquirer": "^9.2.7", "minimist": "^1.2.8", + "picocolors": "1.0.1", "pidusage-tree": "^2.0.5", "playwright-chromium": "^1.39.0", "split2": "^4.2.0", diff --git a/packages/devlow-bench/src/interfaces/console.ts b/packages/devlow-bench/src/interfaces/console.ts index 6e845eaed1e5e..4841b634d36d9 100644 --- a/packages/devlow-bench/src/interfaces/console.ts +++ b/packages/devlow-bench/src/interfaces/console.ts @@ -1,6 +1,6 @@ import { Interface, Scenario, ScenarioVariant } from "../index.js"; import inquirer from "inquirer"; -import chalk from "chalk"; +import { bgCyan, bold, magenta, red, underline } from "picocolors"; import { formatUnit } from "../units.js"; import { formatVariant } from "../utils.js"; @@ -8,25 +8,31 @@ export default function createInterface(): Interface { const iface: Interface = { start: async (scenario, props) => { console.log( - chalk.bold.underline(`Running ${formatVariant(scenario, props)}...`) + bold(underline(`Running ${formatVariant(scenario, props)}...`)) ); }, measurement: async (scenario, props, name, value, unit, relativeTo) => { console.log( - chalk.bgCyan.bold.magenta( - `${formatVariant(scenario, props)}: ${name} = ${formatUnit( - value, - unit - )}${relativeTo ? ` (from ${relativeTo})` : ""}` + bgCyan( + bold( + magenta( + `${formatVariant(scenario, props)}: ${name} = ${formatUnit( + value, + unit + )}${relativeTo ? ` (from ${relativeTo})` : ""}` + ) + ) ) ); }, error: async (scenario, props, error) => { console.log( - chalk.bold.red( - `${formatVariant(scenario, props)}: ${ - (error && (error as any).stack) || error - }` + bold( + red( + `${formatVariant(scenario, props)}: ${ + (error && (error as any).stack) || error + }` + ) ) ); }, diff --git a/packages/devlow-bench/src/interfaces/interactive.ts b/packages/devlow-bench/src/interfaces/interactive.ts index dc77fa195f62f..d173cb9bed86a 100644 --- a/packages/devlow-bench/src/interfaces/interactive.ts +++ b/packages/devlow-bench/src/interfaces/interactive.ts @@ -1,6 +1,5 @@ import { Interface, Scenario, ScenarioVariant } from "../index.js"; import inquirer from "inquirer"; -import chalk from "chalk"; import { formatUnit } from "../units.js"; import { formatVariant } from "../utils.js"; diff --git a/packages/devlow-bench/src/interfaces/json.ts b/packages/devlow-bench/src/interfaces/json.ts index 0e3dbee99ee6e..5b3b22de43e37 100644 --- a/packages/devlow-bench/src/interfaces/json.ts +++ b/packages/devlow-bench/src/interfaces/json.ts @@ -1,6 +1,5 @@ import { Interface, Scenario, ScenarioVariant } from "../index.js"; import inquirer from "inquirer"; -import chalk from "chalk"; import { formatUnit } from "../units.js"; import { formatVariant } from "../utils.js"; import { writeFile } from "fs/promises"; diff --git a/packages/devlow-bench/src/types.d.ts b/packages/devlow-bench/src/types.d.ts index ba169651fbe50..95d3dd4e6ccdd 100644 --- a/packages/devlow-bench/src/types.d.ts +++ b/packages/devlow-bench/src/types.d.ts @@ -1,2 +1 @@ -declare module "chalk"; declare module "pidusage-tree"; diff --git a/packages/turbo-codemod/package.json b/packages/turbo-codemod/package.json index 5a4377886c8a3..4a9a3fd9c792b 100644 --- a/packages/turbo-codemod/package.json +++ b/packages/turbo-codemod/package.json @@ -23,7 +23,6 @@ }, "dependencies": { "axios": "0.27.2", - "chalk": "2.4.2", "commander": "^9.5.0", "diff": "^5.1.0", "find-up": "4.1.0", @@ -34,6 +33,7 @@ "json5": "^2.2.3", "is-git-clean": "^1.1.0", "ora": "4.1.1", + "picocolors": "1.0.1", "semver": "^7.3.7", "update-check": "^1.5.4" }, @@ -45,7 +45,6 @@ "@turbo/types": "workspace:*", "@turbo/utils": "workspace:*", "@turbo/workspaces": "workspace:*", - "@types/chalk-animation": "^1.6.0", "@types/diff": "^5.0.2", "@types/fs-extra": "^9.0.13", "@types/gradient-string": "^1.1.2", diff --git a/packages/turbo-codemod/src/cli.ts b/packages/turbo-codemod/src/cli.ts index 8ef880d6057ab..717cf652cfe35 100644 --- a/packages/turbo-codemod/src/cli.ts +++ b/packages/turbo-codemod/src/cli.ts @@ -1,6 +1,6 @@ #!/usr/bin/env node -import chalk from "chalk"; +import { red } from "picocolors"; import { logger } from "@turbo/utils"; import { Command } from "commander"; import cliPkg from "../package.json"; @@ -69,7 +69,7 @@ codemodCli .then(notifyUpdate) .catch(async (reason) => { logger.log(); - logger.log(chalk.red("Unexpected error. Please report it as a bug:")); + logger.log(red("Unexpected error. Please report it as a bug:")); logger.log(reason); logger.log(); diff --git a/packages/turbo-codemod/src/commands/migrate/index.ts b/packages/turbo-codemod/src/commands/migrate/index.ts index 5958d97a9655d..a2076f63be5e4 100644 --- a/packages/turbo-codemod/src/commands/migrate/index.ts +++ b/packages/turbo-codemod/src/commands/migrate/index.ts @@ -1,6 +1,6 @@ import os from "node:os"; import { execSync } from "node:child_process"; -import chalk from "chalk"; +import { green, red, dim, bold } from "picocolors"; import { prompt } from "inquirer"; import { getWorkspaceDetails, type Project } from "@turbo/workspaces"; import { logger } from "@turbo/utils"; @@ -24,14 +24,14 @@ function endMigration({ success: boolean; }) { if (success) { - logger.bold(chalk.green("Migration completed")); + logger.bold(green("Migration completed")); if (message) { logger.log(message); } return process.exit(0); } - logger.bold(chalk.red("Migration failed")); + logger.bold(red("Migration failed")); if (message) { logger.log(message); } @@ -71,7 +71,7 @@ export async function migrate( if (exists) { return true; } - return `Directory ${chalk.dim(`(${absolute})`)} does not exist`; + return `Directory ${dim(`(${absolute})`)} does not exist`; }, filter: (d: string) => d.trim(), }, @@ -85,16 +85,14 @@ export async function migrate( if (!exists) { return endMigration({ success: false, - message: `Directory ${chalk.dim(`(${root})`)} does not exist`, + message: `Directory ${dim(`(${root})`)} does not exist`, }); } if (!looksLikeRepo({ directory: root })) { return endMigration({ success: false, - message: `Directory (${chalk.dim( - root - )}) does not appear to be a repository`, + message: `Directory (${dim(root)}) does not appear to be a repository`, }); } @@ -104,7 +102,7 @@ export async function migrate( } catch (err) { return endMigration({ success: false, - message: `Unable to read determine package manager details from ${chalk.dim( + message: `Unable to read determine package manager details from ${dim( root )}`, }); @@ -144,9 +142,9 @@ export async function migrate( if (fromVersion === toVersion) { return endMigration({ success: true, - message: `Nothing to do, current version (${chalk.bold( + message: `Nothing to do, current version (${bold( fromVersion - )}) is the same as the requested version (${chalk.bold(toVersion)})`, + )}) is the same as the requested version (${bold(toVersion)})`, }); } @@ -167,9 +165,7 @@ export async function migrate( // step 4 logger.log( - `Upgrading turbo from ${chalk.bold(fromVersion)} to ${chalk.bold( - toVersion - )} (${ + `Upgrading turbo from ${bold(fromVersion)} to ${bold(toVersion)} (${ codemods.length === 0 ? "no codemods required" : `${codemods.length} required codemod${ @@ -182,7 +178,7 @@ export async function migrate( const results: Array = []; for (const [idx, codemod] of codemods.entries()) { logger.log( - `(${idx + 1}/${codemods.length}) ${chalk.bold(`Running ${codemod.name}`)}` + `(${idx + 1}/${codemods.length}) ${bold(`Running ${codemod.name}`)}` ); // eslint-disable-next-line no-await-in-loop -- transforms have to run serially to avoid conflicts @@ -226,13 +222,11 @@ export async function migrate( if (options.install) { if (options.dryRun) { logger.log( - `Upgrading turbo with ${chalk.bold(upgradeCommand)} ${chalk.dim( - "(dry run)" - )}`, + `Upgrading turbo with ${bold(upgradeCommand)} ${dim("(dry run)")}`, os.EOL ); } else { - logger.log(`Upgrading turbo with ${chalk.bold(upgradeCommand)}`, os.EOL); + logger.log(`Upgrading turbo with ${bold(upgradeCommand)}`, os.EOL); try { execSync(upgradeCommand, { stdio: "pipe", cwd: project.paths.root }); } catch (err: unknown) { @@ -243,7 +237,7 @@ export async function migrate( } } } else { - logger.log(`Upgrade turbo with ${chalk.bold(upgradeCommand)}`, os.EOL); + logger.log(`Upgrade turbo with ${bold(upgradeCommand)}`, os.EOL); } endMigration({ success: true }); diff --git a/packages/turbo-codemod/src/commands/transform/index.ts b/packages/turbo-codemod/src/commands/transform/index.ts index e31d16cdf1eb3..ca61ad3a3f678 100644 --- a/packages/turbo-codemod/src/commands/transform/index.ts +++ b/packages/turbo-codemod/src/commands/transform/index.ts @@ -1,4 +1,4 @@ -import chalk from "chalk"; +import { bold, cyan, dim, gray } from "picocolors"; import { prompt } from "inquirer"; import { logger } from "@turbo/utils"; import { loadTransformers } from "../../utils/loadTransformers"; @@ -17,7 +17,7 @@ export async function transform( ) { const transforms = loadTransformers(); if (options.list) { - logger.log(transforms.map((t) => `- ${chalk.cyan(t.name)}`).join("\n")); + logger.log(transforms.map((t) => `- ${cyan(t.name)}`).join("\n")); return process.exit(0); } @@ -41,7 +41,7 @@ export async function transform( if (exists) { return true; } - return `Directory ${chalk.dim(`(${absolute})`)} does not exist`; + return `Directory ${dim(`(${absolute})`)} does not exist`; }, filter: (d: string) => d.trim(), }, @@ -52,9 +52,9 @@ export async function transform( when: !transformName, pageSize: transforms.length, choices: transforms.map((t) => ({ - name: `${chalk.bold(t.name)} - ${chalk.gray( - t.description - )} ${chalk.gray(`(${t.introducedIn})`)}`, + name: `${bold(t.name)} - ${gray(t.description)} ${gray( + `(${t.introducedIn})` + )}`, value: t.name, })), }, @@ -69,7 +69,7 @@ export async function transform( directory: selectedDirectory, }); if (!exists) { - logger.error(`Directory ${chalk.dim(`(${root})`)} does not exist`); + logger.error(`Directory ${dim(`(${root})`)} does not exist`); return process.exit(1); } @@ -79,9 +79,7 @@ export async function transform( // validate transforms if (!transformData) { logger.error( - `Invalid transform choice ${chalk.dim( - `(${transformName})` - )}, pick one of:` + `Invalid transform choice ${dim(`(${transformName})`)}, pick one of:` ); logger.error(transformKeys.map((key) => `- ${key}`).join("\n")); return process.exit(1); diff --git a/packages/turbo-codemod/src/runner/FileTransform.ts b/packages/turbo-codemod/src/runner/FileTransform.ts index bce120933e13d..e2cf3751bc119 100644 --- a/packages/turbo-codemod/src/runner/FileTransform.ts +++ b/packages/turbo-codemod/src/runner/FileTransform.ts @@ -1,7 +1,7 @@ import os from "node:os"; import path from "node:path"; import { logger } from "@turbo/utils"; -import chalk from "chalk"; +import { dim, green, red } from "picocolors"; import type { Change } from "diff"; import { diffLines, diffJson } from "diff"; import { @@ -85,11 +85,11 @@ export class FileTransform { if (args.diff) { this.changes.forEach((part) => { if (part.added) { - process.stdout.write(chalk.green(part.value)); + process.stdout.write(green(part.value)); } else if (part.removed) { - process.stdout.write(chalk.red(part.value)); + process.stdout.write(red(part.value)); } else { - process.stdout.write(chalk.dim(part.value)); + process.stdout.write(dim(part.value)); } }); logger.log(os.EOL); diff --git a/packages/turbo-codemod/src/runner/Runner.ts b/packages/turbo-codemod/src/runner/Runner.ts index 8e7887ab1e861..95d0033515464 100644 --- a/packages/turbo-codemod/src/runner/Runner.ts +++ b/packages/turbo-codemod/src/runner/Runner.ts @@ -1,4 +1,4 @@ -import chalk from "chalk"; +import { bold, dim } from "picocolors"; import { logger } from "@turbo/utils"; import { Logger } from "../utils/logger"; import type { UtilityArgs } from "../types"; @@ -57,12 +57,12 @@ export class Runner { if (mod.hasChanges()) { if (this.dry) { result.action = "skipped"; - this.logger.skipped(chalk.dim(mod.fileName())); + this.logger.skipped(dim(mod.fileName())); } else { try { mod.write(); result.action = "modified"; - this.logger.modified(chalk.bold(mod.fileName())); + this.logger.modified(bold(mod.fileName())); } catch (err) { let message = "Unknown error"; if (err instanceof Error) { @@ -78,7 +78,7 @@ export class Runner { mod.log({ diff: true }); } } else { - this.logger.unchanged(chalk.dim(mod.fileName())); + this.logger.unchanged(dim(mod.fileName())); } results.changes[mod.fileName()] = result; diff --git a/packages/turbo-codemod/src/utils/checkGitStatus.ts b/packages/turbo-codemod/src/utils/checkGitStatus.ts index 12179a01d84fb..ef68915b59487 100644 --- a/packages/turbo-codemod/src/utils/checkGitStatus.ts +++ b/packages/turbo-codemod/src/utils/checkGitStatus.ts @@ -1,4 +1,4 @@ -import chalk from "chalk"; +import { yellow } from "picocolors"; import isGitClean from "is-git-clean"; import { logger } from "@turbo/utils"; @@ -24,12 +24,12 @@ export function checkGitStatus({ if (!clean) { if (force) { logger.log( - `${chalk.yellow("WARNING")}: ${errorMessage}. Forcibly continuing...` + `${yellow("WARNING")}: ${errorMessage}. Forcibly continuing...` ); } else { logger.log("Thank you for using @turbo/codemod!"); logger.log( - chalk.yellow( + yellow( "\nBut before we continue, please stash or commit your git changes." ) ); diff --git a/packages/turbo-codemod/src/utils/logger.ts b/packages/turbo-codemod/src/utils/logger.ts index 4e21103129545..152977df6eda2 100644 --- a/packages/turbo-codemod/src/utils/logger.ts +++ b/packages/turbo-codemod/src/utils/logger.ts @@ -1,4 +1,4 @@ -import chalk from "chalk"; +import { green, dim, bold, red, yellow, gray } from "picocolors"; import type { UtilityArgs } from "../types"; export class Logger { @@ -16,38 +16,18 @@ export class Logger { } modified(...args: Array) { - this._log( - chalk.green(` MODIFIED `), - ...args, - this.dry ? chalk.dim(`(dry run)`) : "" - ); + this._log(green(` MODIFIED `), ...args, this.dry ? dim(`(dry run)`) : ""); } unchanged(...args: Array) { - this._log( - chalk.gray(` UNCHANGED `), - ...args, - this.dry ? chalk.dim(`(dry run)`) : "" - ); + this._log(gray(` UNCHANGED `), ...args, this.dry ? dim(`(dry run)`) : ""); } skipped(...args: Array) { - this._log( - chalk.yellow(` SKIPPED `), - ...args, - this.dry ? chalk.dim(`(dry run)`) : "" - ); + this._log(yellow(` SKIPPED `), ...args, this.dry ? dim(`(dry run)`) : ""); } error(...args: Array) { - this._log( - chalk.red(` ERROR `), - ...args, - this.dry ? chalk.dim(`(dry run)`) : "" - ); + this._log(red(` ERROR `), ...args, this.dry ? dim(`(dry run)`) : ""); } info(...args: Array) { - this._log( - chalk.bold(` INFO `), - ...args, - this.dry ? chalk.dim(`(dry run)`) : "" - ); + this._log(bold(` INFO `), ...args, this.dry ? dim(`(dry run)`) : ""); } } diff --git a/packages/turbo-codemod/src/utils/notifyUpdate.ts b/packages/turbo-codemod/src/utils/notifyUpdate.ts index 7673daf9af4ae..8085cbf7fc6d1 100644 --- a/packages/turbo-codemod/src/utils/notifyUpdate.ts +++ b/packages/turbo-codemod/src/utils/notifyUpdate.ts @@ -1,4 +1,4 @@ -import chalk from "chalk"; +import { cyan, bold, yellow } from "picocolors"; import checkForUpdate from "update-check"; import { logger } from "@turbo/utils"; import { getWorkspaceDetails } from "@turbo/workspaces"; @@ -23,9 +23,9 @@ export async function notifyUpdate(): Promise { logger.log(); logger.log( - chalk.yellow.bold("A new version of `@turbo/codemod` is available!") + yellow(bold("A new version of `@turbo/codemod` is available!")) ); - logger.log(`You can update by running: ${chalk.cyan(upgradeCommand)}`); + logger.log(`You can update by running: ${cyan(upgradeCommand)}`); logger.log(); } process.exit(); diff --git a/packages/turbo-gen/package.json b/packages/turbo-gen/package.json index c99e243467962..e2b29d83e4382 100644 --- a/packages/turbo-gen/package.json +++ b/packages/turbo-gen/package.json @@ -22,12 +22,12 @@ }, "dependencies": { "@turbo/workspaces": "workspace:*", - "chalk": "2.4.2", "commander": "^10.0.0", "fs-extra": "^10.1.0", "inquirer": "^8.2.4", "minimatch": "^9.0.0", "node-plop": "^0.26.3", + "picocolors": "1.0.1", "proxy-agent": "^6.2.2", "ts-node": "^10.9.1", "update-check": "^1.5.4", diff --git a/packages/turbo-gen/src/cli.ts b/packages/turbo-gen/src/cli.ts index c60aba4b234e3..0dc8f33b9d396 100644 --- a/packages/turbo-gen/src/cli.ts +++ b/packages/turbo-gen/src/cli.ts @@ -2,7 +2,7 @@ import http from "node:http"; import https from "node:https"; -import chalk from "chalk"; +import { bold } from "picocolors"; import { Argument, Command, Option } from "commander"; import { logger } from "@turbo/utils"; import { ProxyAgent } from "proxy-agent"; @@ -19,7 +19,7 @@ https.globalAgent = agent; const turboGenCli = new Command(); turboGenCli - .name(chalk.bold(logger.turboGradient("@turbo/gen"))) + .name(bold(logger.turboGradient("@turbo/gen"))) .description("Extend your Turborepo") .version(cliPkg.version, "-v, --version", "Output the current version") .helpOption("-h, --help", "Display help for command") diff --git a/packages/turbo-gen/src/generators/copy.ts b/packages/turbo-gen/src/generators/copy.ts index aaa50bca2b913..a24f3d618e82f 100644 --- a/packages/turbo-gen/src/generators/copy.ts +++ b/packages/turbo-gen/src/generators/copy.ts @@ -1,7 +1,7 @@ import path from "node:path"; import type { CopyFilterAsync } from "fs-extra"; import { rm, writeJSON, readJSON, copy, existsSync } from "fs-extra"; -import chalk from "chalk"; +import { bold } from "picocolors"; import { createProject, logger, @@ -90,7 +90,7 @@ export async function generate({ project, opts }: TurboGeneratorArguments) { logger.log(); logger.log( - `${chalk.bold(logger.turboGradient(">>> Success!"))} Created ${name} at "${ + `${bold(logger.turboGradient(">>> Success!"))} Created ${name} at "${ location.relative }"` ); diff --git a/packages/turbo-gen/src/generators/empty.ts b/packages/turbo-gen/src/generators/empty.ts index d0b99b79548b8..78f176dd3c5da 100644 --- a/packages/turbo-gen/src/generators/empty.ts +++ b/packages/turbo-gen/src/generators/empty.ts @@ -1,6 +1,6 @@ import path from "node:path"; import { writeFileSync, mkdirSync } from "fs-extra"; -import chalk from "chalk"; +import { bold } from "picocolors"; import { logger, type PackageJson, type DependencyGroups } from "@turbo/utils"; import { gatherAddRequirements } from "../utils/gatherAddRequirements"; import type { TurboGeneratorArguments } from "./types"; @@ -45,7 +45,7 @@ export async function generate({ project, opts }: TurboGeneratorArguments) { logger.log(); logger.log( - `${chalk.bold(logger.turboGradient(">>> Success!"))} Created ${name} at "${ + `${bold(logger.turboGradient(">>> Success!"))} Created ${name} at "${ location.relative }"` ); diff --git a/packages/turbo-gen/src/utils/notifyUpdate.ts b/packages/turbo-gen/src/utils/notifyUpdate.ts index 325d70cc1af05..47efc72ab20e4 100644 --- a/packages/turbo-gen/src/utils/notifyUpdate.ts +++ b/packages/turbo-gen/src/utils/notifyUpdate.ts @@ -1,4 +1,4 @@ -import chalk from "chalk"; +import { yellow, bold } from "picocolors"; import checkForUpdate from "update-check"; import { logger } from "@turbo/utils"; import cliPkgJson from "../../package.json"; @@ -11,9 +11,7 @@ export async function notifyUpdate(): Promise { if (res?.latest) { logger.log(); logger.log( - chalk.yellow.bold( - `A new version of \`${cliPkgJson.name}\` is available!` - ) + yellow(bold(`A new version of \`${cliPkgJson.name}\` is available!`)) ); logger.log(); } diff --git a/packages/turbo-gen/tsup.config.ts b/packages/turbo-gen/tsup.config.ts index 9e4678cd7221d..92aa017b74812 100644 --- a/packages/turbo-gen/tsup.config.ts +++ b/packages/turbo-gen/tsup.config.ts @@ -1,6 +1,6 @@ import { defineConfig, Options } from "tsup"; import fs from "fs-extra"; -import chalk from "chalk"; +import pc from "picocolors"; export default defineConfig((options: Options) => ({ entry: ["src/cli.ts", "src/types.ts"], @@ -14,9 +14,9 @@ export default defineConfig((options: Options) => ({ await fs.copy("src/templates", "dist/templates"); // make the output match console.log( - chalk.hex("#7c5cad")("TEMPLATES"), + pc.magenta("TEMPLATES"), "copied in", - chalk.green(`${Date.now() - start}ms`) + pc.green(`${Date.now() - start}ms`) ); }, ...options, diff --git a/packages/turbo-telemetry/package.json b/packages/turbo-telemetry/package.json index 85f7d800e3221..31bbdbf680a35 100644 --- a/packages/turbo-telemetry/package.json +++ b/packages/turbo-telemetry/package.json @@ -25,9 +25,9 @@ "lint:prettier": "prettier -c . --cache --ignore-path=../../.prettierignore" }, "dependencies": { - "chalk": "^4.1.2", "ci-info": "^4.0.0", "got": "^11.8.6", + "picocolors": "1.0.1", "zod": "^3.22.4" }, "devDependencies": { diff --git a/packages/turbo-telemetry/src/cli.ts b/packages/turbo-telemetry/src/cli.ts index 421c15b6d8945..dc95feb7856bb 100644 --- a/packages/turbo-telemetry/src/cli.ts +++ b/packages/turbo-telemetry/src/cli.ts @@ -1,4 +1,4 @@ -import chalk from "chalk"; +import { bold, green, red } from "picocolors"; import { logger } from "@turbo/utils"; import { type Command, Argument } from "commander"; import { type TelemetryClient } from "./client"; @@ -14,11 +14,7 @@ interface TelemetryCLIOptions { function status(options: TelemetryCLIOptions) { const isEnabled = options.telemetry?.config.isEnabled(); logger.log( - `Status: ${ - isEnabled - ? chalk.bold(chalk.green("Enabled")) - : chalk.bold(chalk.red("Disabled")) - }` + `Status: ${isEnabled ? bold(green("Enabled")) : bold(red("Disabled"))}` ); logger.log(); if (isEnabled) { diff --git a/packages/turbo-telemetry/src/config.ts b/packages/turbo-telemetry/src/config.ts index 8cac6ceb91b6c..f7e44ddb79181 100644 --- a/packages/turbo-telemetry/src/config.ts +++ b/packages/turbo-telemetry/src/config.ts @@ -1,7 +1,7 @@ import { readFileSync, writeFileSync, rmSync } from "node:fs"; import { randomUUID } from "node:crypto"; import { logger } from "@turbo/utils"; -import chalk from "chalk"; +import { gray } from "picocolors"; import { z } from "zod"; import utils from "./utils"; @@ -167,7 +167,7 @@ export class TelemetryConfig { logger.grey( "You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:" ); - logger.underline(chalk.grey("https://turbo.build/repo/docs/telemetry")); + logger.underline(gray("https://turbo.build/repo/docs/telemetry")); } this.alertShown(); diff --git a/packages/turbo-utils/package.json b/packages/turbo-utils/package.json index b8b2994c87112..74e21f3c89ed9 100644 --- a/packages/turbo-utils/package.json +++ b/packages/turbo-utils/package.json @@ -38,7 +38,6 @@ "@types/node": "^20.5.7", "@types/tar": "^6.1.4", "async-retry": "^1.3.3", - "chalk": "2.4.2", "execa": "5.1.1", "fast-glob": "^3.2.12", "fs-extra": "^11.1.1", @@ -48,6 +47,7 @@ "js-yaml": "^4.1.0", "json5": "^2.2.3", "ora": "4.1.1", + "picocolors": "1.0.1", "tar": "6.1.13", "ts-jest": "^27.1.1", "typescript": "5.3.3" diff --git a/packages/turbo-utils/src/createProject.ts b/packages/turbo-utils/src/createProject.ts index 01b822ec5705c..798c24b564af6 100644 --- a/packages/turbo-utils/src/createProject.ts +++ b/packages/turbo-utils/src/createProject.ts @@ -1,6 +1,6 @@ import path from "node:path"; import retry from "async-retry"; -import chalk from "chalk"; +import { dim, red } from "picocolors"; import { mkdir, readJsonSync, existsSync } from "fs-extra"; import * as logger from "./logger"; import { @@ -65,7 +65,7 @@ export async function createProject({ if (repoUrl) { if (repoUrl.origin !== "https://github.com") { logger.error( - `Invalid URL: ${chalk.red( + `Invalid URL: ${red( `"${example}"` )}. Only GitHub repositories are supported. Please use a GitHub URL and try again.` ); @@ -76,7 +76,7 @@ export async function createProject({ if (!repoInfo) { logger.error( - `Unable to fetch repository information from: ${chalk.red( + `Unable to fetch repository information from: ${red( `"${example}"` )}. Please fix the URL and try again.` ); @@ -87,7 +87,7 @@ export async function createProject({ if (!found) { logger.error( - `Could not locate the repository for ${chalk.red( + `Could not locate the repository for ${red( `"${example}"` )}. Please check that the repository exists and try again.` ); @@ -98,10 +98,10 @@ export async function createProject({ if (!found) { logger.error( - `Could not locate an example named ${chalk.red( + `Could not locate an example named ${red( `"${example}"` )}. It could be due to the following:\n`, - `1. Your spelling of example ${chalk.red( + `1. Your spelling of example ${red( `"${example}"` )} might be incorrect.\n`, `2. You might not be connected to the internet or you are behind a proxy.` @@ -134,7 +134,7 @@ export async function createProject({ const { isEmpty, conflicts } = isFolderEmpty(root); if (!isEmpty) { logger.error( - `${chalk.dim(root)} has ${conflicts.length} conflicting ${ + `${dim(root)} has ${conflicts.length} conflicting ${ conflicts.length === 1 ? "file" : "files" } - please try a different location` ); diff --git a/packages/turbo-utils/src/logger.ts b/packages/turbo-utils/src/logger.ts index 1860604aa353c..4e2fbac885196 100644 --- a/packages/turbo-utils/src/logger.ts +++ b/packages/turbo-utils/src/logger.ts @@ -1,4 +1,10 @@ -import chalk from "chalk"; +import { + reset, + bold as pcBold, + underline as pcUnderline, + gray, + dim, +} from "picocolors"; import ora from "ora"; import gradient from "gradient-string"; @@ -6,10 +12,15 @@ const BLUE = "#0099F7"; const RED = "#F11712"; const YELLOW = "#FFFF00"; +const hex = (color: string): ((text: string) => string) => { + const ansiColor = hexToAnsi256(color); + return (text: string) => `\x1b[38;5;${ansiColor}m${text}${reset("")}`; +}; + export const turboGradient = gradient(BLUE, RED); -export const turboBlue = chalk.hex(BLUE); -export const turboRed = chalk.hex(RED); -export const yellow = chalk.hex(YELLOW); +export const turboBlue = hex(BLUE); +export const turboRed = hex(RED); +export const yellow = hex(YELLOW); export const turboLoader = (text: string) => ora({ @@ -20,27 +31,27 @@ export const turboLoader = (text: string) => }); export const info = (...args: Array) => { - log(turboBlue.bold(">>>"), ...args); + log(turboBlue(pcBold(">>>")), args.join(" ")); }; export const bold = (...args: Array) => { - log(chalk.bold(...args)); + log(pcBold(args.join(" "))); }; export const underline = (...args: Array) => { - log(chalk.underline(...args)); + log(pcUnderline(args.join(" "))); }; export const dimmed = (...args: Array) => { - log(chalk.dim(...args)); + log(dim(args.join(" "))); }; export const grey = (...args: Array) => { - log(chalk.grey(...args)); + log(gray(args.join(" "))); }; export const item = (...args: Array) => { - log(turboBlue.bold(" •"), ...args); + log(turboBlue(pcBold(" •")), args.join(" ")); }; export const log = (...args: Array) => { @@ -50,10 +61,24 @@ export const log = (...args: Array) => { export const warn = (...args: Array) => { // eslint-disable-next-line no-console -- warn logger - console.error(yellow.bold(">>>"), ...args); + console.error(yellow(pcBold(">>>")), args.join(" ")); }; export const error = (...args: Array) => { // eslint-disable-next-line no-console -- error logger - console.error(turboRed.bold(">>>"), ...args); + console.error(turboRed(pcBold(">>>")), args.join(" ")); }; + +function hexToAnsi256(sHex: string): number { + const rgb = parseInt(sHex.slice(1), 16); + const r = Math.floor(rgb / (256 * 256)) % 256; + const g = Math.floor(rgb / 256) % 256; + const b = rgb % 256; + + const ansi = + 16 + + 36 * Math.round((r / 255) * 5) + + 6 * Math.round((g / 255) * 5) + + Math.round((b / 255) * 5); + return ansi; +} diff --git a/packages/turbo-utils/src/validateDirectory.ts b/packages/turbo-utils/src/validateDirectory.ts index dd043a8c32500..bdf5429742e91 100644 --- a/packages/turbo-utils/src/validateDirectory.ts +++ b/packages/turbo-utils/src/validateDirectory.ts @@ -1,6 +1,6 @@ import path from "node:path"; import fs from "fs-extra"; -import chalk from "chalk"; +import { dim } from "picocolors"; import { isFolderEmpty } from "./isFolderEmpty"; export function validateDirectory(directory: string): { @@ -19,7 +19,7 @@ export function validateDirectory(directory: string): { valid: false, root, projectName, - error: `${chalk.dim( + error: `${dim( projectName )} is not a directory - please try a different location`, }; @@ -32,7 +32,7 @@ export function validateDirectory(directory: string): { valid: false, root, projectName, - error: `${chalk.dim(projectName)} (${root}) has ${ + error: `${dim(projectName)} (${root}) has ${ conflicts.length } conflicting ${ conflicts.length === 1 ? "file" : "files" diff --git a/packages/turbo-workspaces/package.json b/packages/turbo-workspaces/package.json index a7542169d9519..43417c322e2d5 100644 --- a/packages/turbo-workspaces/package.json +++ b/packages/turbo-workspaces/package.json @@ -25,7 +25,6 @@ "lint:prettier": "prettier -c . --cache --ignore-path=../../.prettierignore" }, "dependencies": { - "chalk": "2.4.2", "commander": "^10.0.0", "execa": "5.1.1", "fast-glob": "^3.2.12", @@ -34,6 +33,7 @@ "inquirer": "^8.0.0", "js-yaml": "^4.1.0", "ora": "4.1.1", + "picocolors": "1.0.1", "rimraf": "^3.0.2", "semver": "^7.3.5", "update-check": "^1.5.4" @@ -43,7 +43,6 @@ "@turbo/test-utils": "workspace:*", "@turbo/tsconfig": "workspace:*", "@turbo/utils": "workspace:*", - "@types/chalk-animation": "^1.6.0", "@types/fs-extra": "^9.0.13", "@types/gradient-string": "^1.1.2", "@types/inquirer": "^7.3.1", diff --git a/packages/turbo-workspaces/src/cli.ts b/packages/turbo-workspaces/src/cli.ts index 594b88b37069c..8ff87fd35d446 100644 --- a/packages/turbo-workspaces/src/cli.ts +++ b/packages/turbo-workspaces/src/cli.ts @@ -1,6 +1,6 @@ #!/usr/bin/env node -import chalk from "chalk"; +import { red } from "picocolors"; import { Command } from "commander"; import { logger } from "@turbo/utils"; import cliPkg from "../package.json"; @@ -43,9 +43,9 @@ workspacesCli workspacesCli.parseAsync().catch((error) => { logger.log(); if (error instanceof ConvertError) { - logger.log(chalk.red(error.message)); + logger.log(red(error.message)); } else { - logger.log(chalk.red("Unexpected error. Please report it as a bug:")); + logger.log(red("Unexpected error. Please report it as a bug:")); logger.log(error); } logger.log(); diff --git a/packages/turbo-workspaces/src/commands/convert/index.ts b/packages/turbo-workspaces/src/commands/convert/index.ts index 535071b2aa9e3..8d13bf6b1fcd2 100644 --- a/packages/turbo-workspaces/src/commands/convert/index.ts +++ b/packages/turbo-workspaces/src/commands/convert/index.ts @@ -1,5 +1,5 @@ import inquirer from "inquirer"; -import chalk from "chalk"; +import { dim } from "picocolors"; import { getAvailablePackageManagers, type PackageManager } from "@turbo/utils"; import { Logger } from "../../logger"; import { directoryInfo } from "../../utils"; @@ -51,7 +51,7 @@ export async function convertCommand( if (exists) { return true; } - return `Directory ${chalk.dim(`(${absolute})`)} does not exist`; + return `Directory ${dim(`(${absolute})`)} does not exist`; }, filter: (d: string) => d.trim(), }); @@ -61,7 +61,7 @@ export async function convertCommand( directory: selectedDirectory, }); if (!exists) { - logger.error(`Directory ${chalk.dim(`(${root})`)} does not exist`); + logger.error(`Directory ${dim(`(${root})`)} does not exist`); return process.exit(1); } diff --git a/packages/turbo-workspaces/src/commands/summary/index.ts b/packages/turbo-workspaces/src/commands/summary/index.ts index c06e2f4668d15..e6810c84343a1 100644 --- a/packages/turbo-workspaces/src/commands/summary/index.ts +++ b/packages/turbo-workspaces/src/commands/summary/index.ts @@ -1,6 +1,6 @@ import path from "node:path"; import inquirer from "inquirer"; -import chalk from "chalk"; +import { bold, dim, italic, underline } from "picocolors"; import { Logger } from "../../logger"; import { directoryInfo } from "../../utils"; import { getWorkspaceDetails } from "../../getWorkspaceDetails"; @@ -24,7 +24,7 @@ export async function summaryCommand(directory: SummaryCommandArgument) { if (exists) { return true; } - return `Directory ${chalk.dim(`(${absolute})`)} does not exist`; + return `Directory ${dim(`(${absolute})`)} does not exist`; }, filter: (d: string) => d.trim(), }); @@ -34,7 +34,7 @@ export async function summaryCommand(directory: SummaryCommandArgument) { directory: selectedDirectory, }); if (!exists) { - logger.error(`Directory ${chalk.dim(`(${root})`)} does not exist`); + logger.error(`Directory ${dim(`(${root})`)} does not exist`); return process.exit(1); } @@ -54,9 +54,7 @@ export async function summaryCommand(directory: SummaryCommandArgument) { }); const renderWorkspace = (w: Workspace) => { - return `${w.name} (${chalk.italic( - `./${path.relative(root, w.paths.root)}` - )})`; + return `${w.name} (${italic(`./${path.relative(root, w.paths.root)}`)})`; }; const renderDirectory = ({ @@ -68,7 +66,7 @@ export async function summaryCommand(directory: SummaryCommandArgument) { dir: string; workspaces: Array; }) => { - logger.indented(2, `${number}. ${chalk.bold(dir)}`); + logger.indented(2, `${number}. ${bold(dir)}`); workspaces.forEach((workspace, idx) => { logger.indented(3, `${idx + 1}. ${renderWorkspace(workspace)}`); }); @@ -76,15 +74,15 @@ export async function summaryCommand(directory: SummaryCommandArgument) { // repo header logger.header(`Repository Summary`); - logger.indented(1, `${chalk.underline(project.name)}:`); + logger.indented(1, `${underline(project.name)}:`); // workspace manager header logger.indented( 1, - `Package Manager: ${chalk.bold(chalk.italic(project.packageManager))}` + `Package Manager: ${bold(italic(project.packageManager))}` ); if (hasWorkspaces) { // workspaces header - logger.indented(1, `Workspaces (${chalk.bold(numWorkspaces.toString())}):`); + logger.indented(1, `Workspaces (${bold(numWorkspaces.toString())}):`); Object.keys(workspacesByDirectory).forEach((dir, idx) => { renderDirectory({ number: idx + 1, diff --git a/packages/turbo-workspaces/src/convert.ts b/packages/turbo-workspaces/src/convert.ts index b4d56eae7ce28..6f7f55418a3d0 100644 --- a/packages/turbo-workspaces/src/convert.ts +++ b/packages/turbo-workspaces/src/convert.ts @@ -1,4 +1,4 @@ -import chalk from "chalk"; +import { yellow } from "picocolors"; import { MANAGERS } from "./managers"; import type { Project, @@ -70,7 +70,7 @@ export async function convertProject({ await MANAGERS[to.name].convertLock({ project, to, logger, options }); await install({ project, to, logger, options }); } else { - logger.subStep(chalk.yellow("Skipping install")); + logger.subStep(yellow("Skipping install")); } logger.mainStep(`Cleaning up ${project.packageManager} workspaces`); diff --git a/packages/turbo-workspaces/src/logger.ts b/packages/turbo-workspaces/src/logger.ts index 30b68d7720de2..4405bfe6fb711 100644 --- a/packages/turbo-workspaces/src/logger.ts +++ b/packages/turbo-workspaces/src/logger.ts @@ -1,4 +1,4 @@ -import chalk from "chalk"; +import { bold, green, red, underline, yellow } from "picocolors"; import gradient from "gradient-string"; const INDENTATION = 2; @@ -30,12 +30,12 @@ export class Logger { header(title: string) { this.blankLine(); - this.logger(chalk.bold(title)); + this.logger(bold(title)); } installerFrames() { const prefix = `${" ".repeat(INDENTATION)} - ${ - this.dry ? chalk.yellow("SKIPPED | ") : chalk.green("OK | ") + this.dry ? yellow("SKIPPED | ") : green("OK | ") }`; return [`${prefix} `, `${prefix}> `, `${prefix}>> `, `${prefix}>>>`]; } @@ -46,7 +46,7 @@ export class Logger { } hero() { - this.logger(chalk.bold(this.gradient(`\n>>> TURBOREPO\n`))); + this.logger(bold(this.gradient(`\n>>> TURBOREPO\n`))); } info(...args: Array) { @@ -55,7 +55,7 @@ export class Logger { mainStep(title: string) { this.blankLine(); - this.logger(`${this.step}. ${chalk.underline(title)}`); + this.logger(`${this.step}. ${underline(title)}`); this.step += 1; } @@ -63,13 +63,13 @@ export class Logger { this.logger( " ".repeat(INDENTATION), `-`, - this.dry ? chalk.yellow("SKIPPED |") : chalk.green("OK |"), + this.dry ? yellow("SKIPPED |") : green("OK |"), ...args ); } subStepFailure(...args: Array) { - this.logger(" ".repeat(INDENTATION), `-`, chalk.red("ERROR |"), ...args); + this.logger(" ".repeat(INDENTATION), `-`, red("ERROR |"), ...args); } rootHeader() { @@ -81,7 +81,7 @@ export class Logger { this.logger( " ".repeat(INDENTATION * 3), `-`, - this.dry ? chalk.yellow("SKIPPED |") : chalk.green("OK |"), + this.dry ? yellow("SKIPPED |") : green("OK |"), ...args ); } @@ -95,7 +95,7 @@ export class Logger { this.logger( " ".repeat(INDENTATION * 3), `-`, - this.dry ? chalk.yellow("SKIPPED |") : chalk.green("OK |"), + this.dry ? yellow("SKIPPED |") : green("OK |"), ...args ); } diff --git a/packages/turbo-workspaces/src/updateDependencies.ts b/packages/turbo-workspaces/src/updateDependencies.ts index 4dddbbe32ca6f..33c782dbafb23 100644 --- a/packages/turbo-workspaces/src/updateDependencies.ts +++ b/packages/turbo-workspaces/src/updateDependencies.ts @@ -1,6 +1,6 @@ import path from "node:path"; import { writeJSONSync } from "fs-extra"; -import chalk from "chalk"; +import { green } from "picocolors"; import type { DependencyList, DependencyGroups } from "@turbo/utils"; import type { Project, @@ -99,7 +99,7 @@ export function updateDependencies({ const toLog = (key: keyof DependencyGroups) => { const total = stats[key].length; if (total > 0) { - return `${chalk.green(total.toString())} ${key}`; + return `${green(total.toString())} ${key}`; } return undefined; }; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0722cc0521368..2cde7cfbebb84 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -162,9 +162,6 @@ importers: packages/create-turbo: dependencies: - chalk: - specifier: 4.1.2 - version: 4.1.2 commander: specifier: ^11.0.0 version: 11.0.0 @@ -174,6 +171,9 @@ importers: inquirer: specifier: ^8.0.0 version: 8.2.4 + picocolors: + specifier: 1.0.1 + version: 1.0.1 proxy-agent: specifier: ^6.2.2 version: 6.2.2 @@ -241,15 +241,15 @@ importers: '@datadog/datadog-api-client': specifier: ^1.13.0 version: 1.13.0 - chalk: - specifier: 2.4.2 - version: 2.4.2 inquirer: specifier: ^9.2.7 version: 9.2.7 minimist: specifier: ^1.2.8 version: 1.2.8 + picocolors: + specifier: 1.0.1 + version: 1.0.1 pidusage-tree: specifier: ^2.0.5 version: 2.0.5 @@ -434,9 +434,6 @@ importers: axios: specifier: 0.27.2 version: 0.27.2 - chalk: - specifier: 2.4.2 - version: 2.4.2 commander: specifier: ^9.5.0 version: 9.5.0 @@ -467,6 +464,9 @@ importers: ora: specifier: 4.1.1 version: 4.1.1 + picocolors: + specifier: 1.0.1 + version: 1.0.1 semver: specifier: ^7.3.7 version: 7.5.0 @@ -495,9 +495,6 @@ importers: '@turbo/workspaces': specifier: workspace:* version: link:../turbo-workspaces - '@types/chalk-animation': - specifier: ^1.6.0 - version: 1.6.1 '@types/diff': specifier: ^5.0.2 version: 5.0.2 @@ -548,9 +545,6 @@ importers: '@turbo/workspaces': specifier: workspace:* version: link:../turbo-workspaces - chalk: - specifier: 2.4.2 - version: 2.4.2 commander: specifier: ^10.0.0 version: 10.0.0 @@ -566,6 +560,9 @@ importers: node-plop: specifier: ^0.26.3 version: 0.26.3 + picocolors: + specifier: 1.0.1 + version: 1.0.1 proxy-agent: specifier: ^6.2.2 version: 6.2.2 @@ -682,9 +679,6 @@ importers: packages/turbo-telemetry: dependencies: - chalk: - specifier: ^4.1.2 - version: 4.1.2 ci-info: specifier: ^4.0.0 version: 4.0.0 @@ -694,6 +688,9 @@ importers: got: specifier: ^11.8.6 version: 11.8.6 + picocolors: + specifier: 1.0.1 + version: 1.0.1 zod: specifier: ^3.22.4 version: 3.22.4 @@ -870,9 +867,6 @@ importers: async-retry: specifier: ^1.3.3 version: 1.3.3 - chalk: - specifier: 2.4.2 - version: 2.4.2 execa: specifier: 5.1.1 version: 5.1.1 @@ -900,6 +894,9 @@ importers: ora: specifier: 4.1.1 version: 4.1.1 + picocolors: + specifier: 1.0.1 + version: 1.0.1 tar: specifier: 6.1.13 version: 6.1.13 @@ -934,9 +931,6 @@ importers: packages/turbo-workspaces: dependencies: - chalk: - specifier: 2.4.2 - version: 2.4.2 commander: specifier: ^10.0.0 version: 10.0.0 @@ -961,6 +955,9 @@ importers: ora: specifier: 4.1.1 version: 4.1.1 + picocolors: + specifier: 1.0.1 + version: 1.0.1 rimraf: specifier: ^3.0.2 version: 3.0.2 @@ -983,9 +980,6 @@ importers: '@turbo/utils': specifier: workspace:* version: link:../turbo-utils - '@types/chalk-animation': - specifier: ^1.6.0 - version: 1.6.1 '@types/fs-extra': specifier: ^9.0.13 version: 9.0.13 @@ -3181,7 +3175,7 @@ packages: fast-glob: 3.3.1 is-glob: 4.0.3 open: 9.1.0 - picocolors: 1.0.0 + picocolors: 1.0.1 tslib: 2.6.1 dev: true @@ -3309,10 +3303,6 @@ packages: '@types/node': 18.17.4 '@types/responselike': 1.0.0 - /@types/chalk-animation@1.6.1: - resolution: {integrity: sha512-MSuZqFkBeKcik4oMzd/BjaTRYkLpNftRSYkI/oszmckHAZOTSKslWR1CRdURwsxXBgYHPRlb5JM6Cx+tkyXUAg==} - dev: true - /@types/diff@5.0.2: resolution: {integrity: sha512-uw8eYMIReOwstQ0QKF0sICefSy8cNO/v7gOTiIy9SbwuHyEecJUm7qlgueOO5S1udZ5I/irVydHVwMchgzbKTg==} dev: true @@ -10320,8 +10310,8 @@ packages: resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} engines: {node: '>=8'} - /picocolors@1.0.0: - resolution: {integrity: sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==} + /picocolors@1.0.1: + resolution: {integrity: sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew==} /picomatch@2.3.1: resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} @@ -10430,7 +10420,7 @@ packages: engines: {node: ^10 || ^12 || >=14} dependencies: nanoid: 3.3.7 - picocolors: 1.0.0 + picocolors: 1.0.1 source-map-js: 1.0.2 dev: true @@ -10439,7 +10429,7 @@ packages: engines: {node: ^10 || ^12 || >=14} dependencies: nanoid: 3.3.7 - picocolors: 1.0.0 + picocolors: 1.0.1 source-map-js: 1.0.2 dev: false @@ -12426,7 +12416,7 @@ packages: dependencies: browserslist: 4.21.5 escalade: 3.1.1 - picocolors: 1.0.0 + picocolors: 1.0.1 dev: true /update-browserslist-db@1.0.13(browserslist@4.22.2): @@ -12437,7 +12427,7 @@ packages: dependencies: browserslist: 4.22.2 escalade: 3.1.1 - picocolors: 1.0.0 + picocolors: 1.0.1 /update-check@1.5.4: resolution: {integrity: sha512-5YHsflzHP4t1G+8WGPlvKbJEbAJGCgw+Em+dGR1KmBUbr1J36SJBqlHLjR7oob7sco5hWHGQVcr9B2poIVDDTQ==}