From 654d63476cfd485c19b7124aeef8fc0200bc391c Mon Sep 17 00:00:00 2001 From: James Garbutt <43081j@users.noreply.github.com> Date: Mon, 16 Sep 2024 17:45:13 +0700 Subject: [PATCH] feat(nx-plugin): migrate from chalk to picocolors Migrates from `chalk` to the much smaller and faster `picocolors`. --- .../create-nx-plugin/bin/create-nx-plugin.ts | 28 +++++++++---------- packages/create-nx-plugin/package.json | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/create-nx-plugin/bin/create-nx-plugin.ts b/packages/create-nx-plugin/bin/create-nx-plugin.ts index 5aced381f477b..4b7be79b8cac0 100644 --- a/packages/create-nx-plugin/bin/create-nx-plugin.ts +++ b/packages/create-nx-plugin/bin/create-nx-plugin.ts @@ -1,5 +1,5 @@ #!/usr/bin/env node -import chalk = require('chalk'); +import * as pc from 'picocolors'; import enquirer = require('enquirer'); import yargs = require('yargs'); @@ -26,16 +26,16 @@ import { } from 'create-nx-workspace/src/utils/nx/ab-testing'; export const yargsDecorator = { - 'Options:': `${chalk.green`Options`}:`, - 'Examples:': `${chalk.green`Examples`}:`, - boolean: `${chalk.blue`boolean`}`, - count: `${chalk.blue`count`}`, - string: `${chalk.blue`string`}`, - array: `${chalk.blue`array`}`, - required: `${chalk.blue`required`}`, - 'default:': `${chalk.blue`default`}:`, - 'choices:': `${chalk.blue`choices`}:`, - 'aliases:': `${chalk.blue`aliases`}:`, + 'Options:': `${pc.green(`Options`)}:`, + 'Examples:': `${pc.green(`Examples`)}:`, + boolean: `${pc.blue(`boolean`)}`, + count: `${pc.blue(`count`)}`, + string: `${pc.blue(`string`)}`, + array: `${pc.blue(`array`)}`, + required: `${pc.blue(`required`)}`, + 'default:': `${pc.blue(`default`)}:`, + 'choices:': `${pc.blue(`choices`)}:`, + 'aliases:': `${pc.blue(`aliases`)}:`, }; const nxVersion = require('../package.json').version; @@ -97,7 +97,7 @@ export const commandsObject: yargs.Argv = yargs withOptions( yargs .positional('pluginName', { - describe: chalk.dim`Plugin name`, + describe: pc.dim(`Plugin name`), type: 'string', alias: ['name'], }) @@ -121,11 +121,11 @@ export const commandsObject: yargs.Argv = yargs }, [normalizeArgsMiddleware] ) - .help('help', chalk.dim`Show help`) + .help('help', pc.dim(`Show help`)) .updateLocale(yargsDecorator) .version( 'version', - chalk.dim`Show version`, + pc.dim(`Show version`), nxVersion ) as yargs.Argv; diff --git a/packages/create-nx-plugin/package.json b/packages/create-nx-plugin/package.json index ac1a55894a385..2d8c9e15553a3 100644 --- a/packages/create-nx-plugin/package.json +++ b/packages/create-nx-plugin/package.json @@ -30,7 +30,7 @@ "homepage": "https://nx.dev", "dependencies": { "create-nx-workspace": "file:../create-nx-workspace", - "chalk": "^4.1.0", + "picocolors": "^1.1.0", "enquirer": "~2.3.6", "tslib": "^2.3.0", "yargs": "^17.6.2"