From 72f3b2751de109a1d36e5cfcaabf489614a10311 Mon Sep 17 00:00:00 2001 From: Rolando Bosch Date: Fri, 27 Feb 2026 16:56:37 -0800 Subject: [PATCH] chore(deps): replace chalk with picocolors Replace chalk (4 transitive dependencies) with picocolors (zero transitive dependencies) for terminal color output. All usage is single-method calls (bold, red, green, gray, blue) which are directly supported by picocolors. Co-Authored-By: Claude Opus 4.6 --- package-lock.json | 2 +- package.json | 2 +- src/clean.ts | 10 +++++----- src/init.ts | 14 +++++++------- test/kitchen.ts | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/package-lock.json b/package-lock.json index 497068ee..a6a14e43 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,6 @@ "@eslint/js": "^9.37.0", "@typescript-eslint/eslint-plugin": "^8.46.1", "@typescript-eslint/parser": "^8.46.1", - "chalk": "^4.1.2", "eslint": "^9.37.0", "eslint-config-prettier": "^10.1.8", "eslint-plugin-n": "^17.23.1", @@ -22,6 +21,7 @@ "json5": "^2.1.3", "meow": "^9.0.0", "ncp": "^2.0.0", + "picocolors": "^1.1.1", "prettier": "^3.6.2", "typescript-eslint": "^8.46.1", "write-file-atomic": "^6.0.0" diff --git a/package.json b/package.json index 7e841e8b..d10841d6 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@eslint/js": "^9.37.0", "@typescript-eslint/eslint-plugin": "^8.46.1", "@typescript-eslint/parser": "^8.46.1", - "chalk": "^4.1.2", + "picocolors": "^1.1.1", "eslint": "^9.37.0", "eslint-config-prettier": "^10.1.8", "eslint-plugin-n": "^17.23.1", diff --git a/src/clean.ts b/src/clean.ts index 7838ac32..d38f36f2 100644 --- a/src/clean.ts +++ b/src/clean.ts @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import chalk = require('chalk'); +import pc = require('picocolors'); import * as fs from 'fs'; import * as ts from 'typescript'; @@ -33,19 +33,19 @@ export async function clean(options: Options): Promise { const outDir = tsconfig.compilerOptions.outDir; if (outDir === '.') { options.logger.error( - `${chalk.red('ERROR:')} ${chalk.gray('compilerOptions.outDir')} ` + + `${pc.red('ERROR:')} ${pc.gray('compilerOptions.outDir')} ` + 'cannot use the value ".". That would delete all of our sources.', ); return false; } - const message = `${chalk.red('Removing')} ${outDir} ...`; + const message = `${pc.red('Removing')} ${outDir} ...`; options.logger.log(message); await fs.promises.rm(outDir, {recursive: true, force: true}); return true; } else { options.logger.error( - `${chalk.red('ERROR:')} The ${chalk.gray('clean')} command` + - ` requires ${chalk.gray('compilerOptions.outDir')} to be defined in ` + + `${pc.red('ERROR:')} The ${pc.gray('clean')} command` + + ` requires ${pc.gray('compilerOptions.outDir')} to be defined in ` + 'tsconfig.json.', ); return false; diff --git a/src/init.ts b/src/init.ts index ec10247b..1bd60f03 100644 --- a/src/init.ts +++ b/src/init.ts @@ -31,7 +31,7 @@ import { import {Options} from './cli'; import {PackageJSON} from '@npm/types'; -import chalk = require('chalk'); +import pc = require('picocolors'); const pkg = require('../../package.json'); @@ -102,8 +102,8 @@ export async function addScripts( if (existing !== target) { if (existing) { const message = - `package.json already has a script for ${chalk.bold(script)}:\n` + - `-${chalk.red(existing)}\n+${chalk.green(target)}`; + `package.json already has a script for ${pc.bold(script)}:\n` + + `-${pc.red(existing)}\n+${pc.green(target)}`; install = await query(message, 'Replace', false, options); } @@ -139,8 +139,8 @@ export async function addDependencies( if (existing !== target) { if (existing) { const message = - `Already have devDependency for ${chalk.bold(dep)}:\n` + - `-${chalk.red(existing)}\n+${chalk.green(target)}`; + `Already have devDependency for ${pc.bold(dep)}:\n` + + `-${pc.red(existing)}\n+${pc.green(target)}`; install = await query(message, 'Overwrite', false, options); } @@ -216,7 +216,7 @@ async function generateConfigFile( return; } else if (existing) { writeFile = await query( - `${chalk.bold(filename)} already exists`, + `${pc.bold(filename)} already exists`, 'Overwrite', false, options, @@ -313,7 +313,7 @@ export async function init(options: Options): Promise { throw new Error(`Unable to open package.json file: ${err.message}`); } const generate = await query( - `${chalk.bold('package.json')} does not exist.`, + `${pc.bold('package.json')} does not exist.`, 'Generate', true, options, diff --git a/test/kitchen.ts b/test/kitchen.ts index 7a971b74..56378138 100644 --- a/test/kitchen.ts +++ b/test/kitchen.ts @@ -1,4 +1,4 @@ -import chalk = require('chalk'); +import pc = require('picocolors'); import * as cp from 'child_process'; import * as fs from 'fs-extra'; import * as tmp from 'tmp'; @@ -40,7 +40,7 @@ action('🚰 kitchen sink', () => { // Create a staging directory with temp fixtures used to test on a fresh application. before(() => { - console.log(`${chalk.blue(`${__filename} staging area: ${stagingPath}`)}`); + console.log(`${pc.blue(`${__filename} staging area: ${stagingPath}`)}`); cp.execSync('npm pack'); const tarball = `${pkg.name}-${pkg.version}.tgz`; fs.renameSync(tarball, 'gts.tgz');