diff --git a/packages/angular/.eslintrc.json b/packages/angular/.eslintrc.json index f43efe603d99e..fd61a7a4d0d07 100644 --- a/packages/angular/.eslintrc.json +++ b/packages/angular/.eslintrc.json @@ -5,7 +5,15 @@ "overrides": [ { "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], - "rules": {} + "rules": { + "no-restricted-imports": [ + "error", + { + "name": "chalk", + "message": "Please use `picocolors` in place of `chalk` for rendering terminal colors" + } + ] + } }, { "files": ["*.ts", "*.tsx"], diff --git a/packages/angular/ng-package.json b/packages/angular/ng-package.json index 1973ef2d3805c..62702b7118455 100644 --- a/packages/angular/ng-package.json +++ b/packages/angular/ng-package.json @@ -13,7 +13,6 @@ "@schematics", "@phenomnomnominal/tsquery", "@typescript-eslint/", - "chalk", "ignore", "minimatch", "rxjs-for-await", diff --git a/packages/angular/package.json b/packages/angular/package.json index 1ebeda5888af8..e91d7c6571be1 100644 --- a/packages/angular/package.json +++ b/packages/angular/package.json @@ -50,7 +50,7 @@ "dependencies": { "@phenomnomnominal/tsquery": "~5.0.1", "@typescript-eslint/type-utils": "^8.0.0", - "chalk": "^4.1.0", + "picocolors": "^1.1.0", "magic-string": "~0.30.2", "minimatch": "9.0.3", "semver": "^7.5.3", diff --git a/packages/angular/src/generators/ng-add/utilities/validation-logging.spec.ts b/packages/angular/src/generators/ng-add/utilities/validation-logging.spec.ts index 709a243163fef..b616888b449b7 100644 --- a/packages/angular/src/generators/ng-add/utilities/validation-logging.spec.ts +++ b/packages/angular/src/generators/ng-add/utilities/validation-logging.spec.ts @@ -1,4 +1,4 @@ -import chalk = require('chalk'); +import * as pc from 'picocolors'; import { arrayToString, getProjectValidationResultMessage, @@ -48,10 +48,10 @@ describe('getProjectValidationResultMessage', () => { }, ]); - expect(message).toBe(`${chalk.bold(`Validation results`)}: + expect(message).toBe(`${pc.bold(`Validation results`)}: - Simple error message with hint - ${chalk.dim(chalk.italic(` Some hint message`))} + ${pc.dim(pc.italic(` Some hint message`))} - Simple error message without hint @@ -60,7 +60,7 @@ describe('getProjectValidationResultMessage', () => { - First error message - Second error message - Third error message - ${chalk.dim(chalk.italic(` - Some hint message`))} + ${pc.dim(pc.italic(` - Some hint message`))} - Message group without hint: - Errors: diff --git a/packages/angular/src/generators/ng-add/utilities/validation-logging.ts b/packages/angular/src/generators/ng-add/utilities/validation-logging.ts index 1699edd39802d..afea8e7ef22b1 100644 --- a/packages/angular/src/generators/ng-add/utilities/validation-logging.ts +++ b/packages/angular/src/generators/ng-add/utilities/validation-logging.ts @@ -1,4 +1,4 @@ -import chalk = require('chalk'); +import * as pc from 'picocolors'; import type { ValidationError } from './types'; export function arrayToString(array: string[]): string { @@ -18,7 +18,7 @@ export function arrayToString(array: string[]): string { export function getProjectValidationResultMessage( validationResult: ValidationError[] ): string { - return `${chalk.bold('Validation results')}: + return `${pc.bold('Validation results')}: ${validationResult .map((error) => getValidationErrorText(error)) @@ -31,12 +31,12 @@ function getValidationErrorText({ hint, }: ValidationError): string { let lines = message - ? [`- ${message}`, ...(hint ? [chalk.dim(chalk.italic(` ${hint}`))] : [])] + ? [`- ${message}`, ...(hint ? [pc.dim(pc.italic(` ${hint}`))] : [])] : [ `- ${messageGroup.title}:`, ' - Errors:', ...messageGroup.messages.map((message) => ` - ${message}`), - ...(hint ? [chalk.dim(chalk.italic(` - ${hint}`))] : []), + ...(hint ? [pc.dim(pc.italic(` - ${hint}`))] : []), ]; return lines.join('\n ');