Skip to content

Commit f1ab1d3

Browse files
committed
refactor(@angular-devkit/architect-cli): replace ansi-colors with node:util.styleText
This commit removes the external dependency 'ansi-colors' from the @angular-devkit/architect-cli package and replaces its usage with the native 'node:util.styleText' function for console output styling. This change reduces the project's dependency footprint and leverages built-in Node.js functionality.
1 parent eb48d71 commit f1ab1d3

File tree

4 files changed

+7
-15
lines changed

4 files changed

+7
-15
lines changed

packages/angular_devkit/architect_cli/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ ts_project(
1919
deps = [
2020
":node_modules/@angular-devkit/architect",
2121
":node_modules/@angular-devkit/core",
22-
":node_modules/ansi-colors",
2322
":node_modules/yargs-parser",
2423
"//:node_modules/@types/node",
2524
"//:node_modules/@types/yargs-parser",

packages/angular_devkit/architect_cli/bin/architect.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import { Architect } from '@angular-devkit/architect';
1111
import { WorkspaceNodeModulesArchitectHost } from '@angular-devkit/architect/node';
1212
import { JsonValue, json, logging, schema, tags, workspaces } from '@angular-devkit/core';
1313
import { NodeJsSyncHost, createConsoleLogger } from '@angular-devkit/core/node';
14-
import * as ansiColors from 'ansi-colors';
1514
import { existsSync } from 'node:fs';
1615
import * as path from 'node:path';
16+
import { styleText } from 'node:util';
1717
import yargsParser, { camelCase, decamelize } from 'yargs-parser';
1818

1919
function findUp(names: string | string[], from: string) {
@@ -58,9 +58,6 @@ function usage(logger: logging.Logger, exitCode = 0): never {
5858
return process.exit(exitCode);
5959
}
6060

61-
// Create a separate instance to prevent unintended global changes to the color configuration
62-
const colors = ansiColors.create();
63-
6461
async function _executeTarget(
6562
parentLogger: logging.Logger,
6663
workspace: workspaces.WorkspaceDefinition,
@@ -100,9 +97,9 @@ async function _executeTarget(
10097
try {
10198
const result = await run.lastOutput;
10299
if (result.success) {
103-
parentLogger.info(colors.green('SUCCESS'));
100+
parentLogger.info(styleText(['green'], 'SUCCESS'));
104101
} else {
105-
parentLogger.info(colors.red('FAILURE'));
102+
parentLogger.info(styleText(['red'], 'FAILURE'));
106103
}
107104
parentLogger.info('Result: ' + JSON.stringify({ ...result, info: undefined }, null, 4));
108105

@@ -114,7 +111,7 @@ async function _executeTarget(
114111

115112
return result.success ? 0 : 1;
116113
} catch (err) {
117-
parentLogger.info(colors.red('ERROR'));
114+
parentLogger.info(styleText(['red'], 'ERROR'));
118115
parentLogger.info('\nLogs:');
119116
logs.forEach((l) => parentLogger.next(l));
120117

@@ -141,9 +138,9 @@ async function main(args: string[]): Promise<number> {
141138
const logger = createConsoleLogger(argv['verbose'], process.stdout, process.stderr, {
142139
info: (s) => s,
143140
debug: (s) => s,
144-
warn: (s) => colors.bold.yellow(s),
145-
error: (s) => colors.bold.red(s),
146-
fatal: (s) => colors.bold.red(s),
141+
warn: (s) => styleText(['yellow', 'bold'], s),
142+
error: (s) => styleText(['red', 'bold'], s),
143+
fatal: (s) => styleText(['red', 'bold'], s),
147144
});
148145

149146
// Check the target.

packages/angular_devkit/architect_cli/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
"dependencies": {
1717
"@angular-devkit/architect": "workspace:0.0.0-EXPERIMENTAL-PLACEHOLDER",
1818
"@angular-devkit/core": "workspace:0.0.0-PLACEHOLDER",
19-
"ansi-colors": "4.1.3",
2019
"yargs-parser": "22.0.0"
2120
}
2221
}

pnpm-lock.yaml

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)