Skip to content

Commit 610e112

Browse files
committed
Replace colors with Colorize.
1 parent 4d16863 commit 610e112

File tree

99 files changed

+581
-528
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+581
-528
lines changed

apps/api-documenter/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@
2323
"@microsoft/api-extractor-model": "workspace:*",
2424
"@microsoft/tsdoc": "0.14.2",
2525
"@rushstack/node-core-library": "workspace:*",
26+
"@rushstack/terminal": "workspace:*",
2627
"@rushstack/ts-command-line": "workspace:*",
27-
"colors": "~1.2.1",
2828
"js-yaml": "~3.13.1",
2929
"resolve": "~1.22.1"
3030
},
3131
"devDependencies": {
3232
"@rushstack/heft": "workspace:*",
33-
"local-node-rig": "workspace:*",
3433
"@types/js-yaml": "3.12.1",
35-
"@types/resolve": "1.20.2"
34+
"@types/resolve": "1.20.2",
35+
"local-node-rig": "workspace:*"
3636
}
3737
}

apps/api-documenter/src/cli/BaseAction.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import * as path from 'path';
55
import type * as tsdoc from '@microsoft/tsdoc';
6-
import colors from 'colors/safe';
76

87
import {
98
CommandLineAction,
@@ -18,6 +17,7 @@ import {
1817
ApiDocumentedItem,
1918
type IResolveDeclarationReferenceResult
2019
} from '@microsoft/api-extractor-model';
20+
import { Colorize } from '@rushstack/terminal';
2121

2222
export interface IBuildApiModelResult {
2323
apiModel: ApiModel;
@@ -94,7 +94,7 @@ export abstract class BaseAction extends CommandLineAction {
9494

9595
if (result.errorMessage) {
9696
console.log(
97-
colors.yellow(
97+
Colorize.yellow(
9898
`Warning: Unresolved @inheritDoc tag for ${apiItem.displayName}: ` + result.errorMessage
9999
)
100100
);

apps/api-documenter/src/documenters/OfficeYamlDocumenter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
22
// See LICENSE in the project root for license information.
33

4-
import colors from 'colors';
54
import * as path from 'path';
65
import yaml = require('js-yaml');
76

87
import type { ApiModel } from '@microsoft/api-extractor-model';
98
import { FileSystem } from '@rushstack/node-core-library';
9+
import { Colorize } from '@rushstack/terminal';
1010

1111
import type { IYamlTocItem } from '../yaml/IYamlTocFile';
1212
import type { IYamlItem } from '../yaml/IYamlApiFile';
@@ -59,7 +59,7 @@ export class OfficeYamlDocumenter extends YamlDocumenter {
5959
// After we generate everything, check for any unused snippets
6060
console.log();
6161
for (const apiName of Object.keys(this._snippets)) {
62-
console.error(colors.yellow('Warning: Unused snippet ' + apiName));
62+
console.error(Colorize.yellow('Warning: Unused snippet ' + apiName));
6363
}
6464
}
6565

apps/api-documenter/src/markdown/CustomMarkdownEmitter.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
22
// See LICENSE in the project root for license information.
33

4-
import colors from 'colors';
5-
64
import type { DocNode, DocLinkTag, StringBuilder } from '@microsoft/tsdoc';
75
import type { ApiModel, IResolveDeclarationReferenceResult, ApiItem } from '@microsoft/api-extractor-model';
6+
import { Colorize } from '@rushstack/terminal';
87

98
import { CustomDocNodeKind } from '../nodes/CustomDocNodeKind';
109
import type { DocHeading } from '../nodes/DocHeading';
@@ -183,12 +182,12 @@ export class CustomMarkdownEmitter extends MarkdownEmitter {
183182
context.writer.write(encodedLinkText);
184183
context.writer.write(`](${filename!})`);
185184
} else {
186-
console.log(colors.yellow('WARNING: Unable to determine link text'));
185+
console.log(Colorize.yellow('WARNING: Unable to determine link text'));
187186
}
188187
}
189188
} else if (result.errorMessage) {
190189
console.log(
191-
colors.yellow(
190+
Colorize.yellow(
192191
`WARNING: Unable to resolve reference "${docLinkTag.codeDestination!.emitAsTsdoc()}": ` +
193192
result.errorMessage
194193
)

apps/api-documenter/src/start.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22
// See LICENSE in the project root for license information.
33

44
import * as os from 'os';
5-
import colors from 'colors';
65

76
import { PackageJsonLookup } from '@rushstack/node-core-library';
7+
import { Colorize } from '@rushstack/terminal';
88

99
import { ApiDocumenterCommandLine } from './cli/ApiDocumenterCommandLine';
1010

1111
const myPackageVersion: string = PackageJsonLookup.loadOwnPackageJson(__dirname).version;
1212

1313
console.log(
1414
os.EOL +
15-
colors.bold(`api-documenter ${myPackageVersion} ` + colors.cyan(' - https://api-extractor.com/') + os.EOL)
15+
Colorize.bold(
16+
`api-documenter ${myPackageVersion} ` + Colorize.cyan(' - https://api-extractor.com/') + os.EOL
17+
)
1618
);
1719

1820
const parser: ApiDocumenterCommandLine = new ApiDocumenterCommandLine();

apps/api-extractor/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,26 +38,26 @@
3838
},
3939
"dependencies": {
4040
"@microsoft/api-extractor-model": "workspace:*",
41-
"@microsoft/tsdoc": "0.14.2",
4241
"@microsoft/tsdoc-config": "~0.16.1",
42+
"@microsoft/tsdoc": "0.14.2",
4343
"@rushstack/node-core-library": "workspace:*",
4444
"@rushstack/rig-package": "workspace:*",
45+
"@rushstack/terminal": "workspace:*",
4546
"@rushstack/ts-command-line": "workspace:*",
46-
"colors": "~1.2.1",
4747
"lodash": "~4.17.15",
4848
"resolve": "~1.22.1",
4949
"semver": "~7.5.4",
5050
"source-map": "~0.6.1",
5151
"typescript": "5.3.3"
5252
},
5353
"devDependencies": {
54-
"local-eslint-config": "workspace:*",
55-
"@rushstack/heft": "0.64.0",
5654
"@rushstack/heft-node-rig": "2.4.0",
55+
"@rushstack/heft": "0.64.0",
5756
"@types/heft-jest": "1.0.1",
5857
"@types/lodash": "4.14.116",
5958
"@types/node": "18.17.15",
6059
"@types/resolve": "1.20.2",
61-
"@types/semver": "7.5.0"
60+
"@types/semver": "7.5.0",
61+
"local-eslint-config": "workspace:*"
6262
}
6363
}

apps/api-extractor/src/api/CompilerState.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33

44
import * as path from 'path';
55
import * as ts from 'typescript';
6-
import colors = require('colors');
76

87
import { JsonFile } from '@rushstack/node-core-library';
98

109
import { ExtractorConfig } from './ExtractorConfig';
1110
import type { IExtractorInvokeOptions } from './Extractor';
11+
import { Colorize } from '@rushstack/terminal';
1212

1313
/**
1414
* Options for {@link CompilerState.create}
@@ -60,7 +60,7 @@ export class CompilerState {
6060
if (!commandLine.options.skipLibCheck && extractorConfig.skipLibCheck) {
6161
commandLine.options.skipLibCheck = true;
6262
console.log(
63-
colors.cyan(
63+
Colorize.cyan(
6464
'API Extractor was invoked with skipLibCheck. This is not recommended and may cause ' +
6565
'incorrect type analysis.'
6666
)

apps/api-extractor/src/cli/ApiExtractorCommandLine.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
22
// See LICENSE in the project root for license information.
33

4-
import colors from 'colors';
54
import * as os from 'os';
65

76
import { CommandLineParser, type CommandLineFlagParameter } from '@rushstack/ts-command-line';
87
import { InternalError } from '@rushstack/node-core-library';
8+
import { Colorize } from '@rushstack/terminal';
99

1010
import { RunAction } from './RunAction';
1111
import { InitAction } from './InitAction';
@@ -42,7 +42,7 @@ export class ApiExtractorCommandLine extends CommandLineParser {
4242
if (this._debugParameter.value) {
4343
console.error(os.EOL + error.stack);
4444
} else {
45-
console.error(os.EOL + colors.red('ERROR: ' + error.message.trim()));
45+
console.error(os.EOL + Colorize.red('ERROR: ' + error.message.trim()));
4646
}
4747

4848
process.exitCode = 1;

apps/api-extractor/src/cli/InitAction.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
22
// See LICENSE in the project root for license information.
33

4-
import colors from 'colors';
54
import * as path from 'path';
65
import { FileSystem } from '@rushstack/node-core-library';
76
import { CommandLineAction } from '@rushstack/ts-command-line';
7+
import { Colorize } from '@rushstack/terminal';
88

99
import type { ApiExtractorCommandLine } from './ApiExtractorCommandLine';
1010
import { ExtractorConfig } from '../api/ExtractorConfig';
@@ -27,12 +27,12 @@ export class InitAction extends CommandLineAction {
2727
const outputFilePath: string = path.resolve(ExtractorConfig.FILENAME);
2828

2929
if (FileSystem.exists(outputFilePath)) {
30-
console.log(colors.red('The output file already exists:'));
30+
console.log(Colorize.red('The output file already exists:'));
3131
console.log('\n ' + outputFilePath + '\n');
3232
throw new Error('Unable to write output file');
3333
}
3434

35-
console.log(colors.green('Writing file: ') + outputFilePath);
35+
console.log(Colorize.green('Writing file: ') + outputFilePath);
3636
FileSystem.copyFile({
3737
sourcePath: inputFilePath,
3838
destinationPath: outputFilePath

apps/api-extractor/src/cli/RunAction.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
22
// See LICENSE in the project root for license information.
33

4-
import colors from 'colors';
54
import * as os from 'os';
65
import * as path from 'path';
76
import { PackageJsonLookup, FileSystem, type IPackageJson, Path } from '@rushstack/node-core-library';
8-
7+
import { Colorize } from '@rushstack/terminal';
98
import {
109
CommandLineAction,
1110
type CommandLineStringParameter,
1211
type CommandLineFlagParameter
1312
} from '@rushstack/ts-command-line';
1413

1514
import { Extractor, type ExtractorResult } from '../api/Extractor';
16-
1715
import type { ApiExtractorCommandLine } from './ApiExtractorCommandLine';
1816
import { ExtractorConfig, type IExtractorConfigPrepareOptions } from '../api/ExtractorConfig';
1917

@@ -144,9 +142,9 @@ export class RunAction extends CommandLineAction {
144142
process.exitCode = 1;
145143

146144
if (extractorResult.errorCount > 0) {
147-
console.log(os.EOL + colors.red('API Extractor completed with errors'));
145+
console.log(os.EOL + Colorize.red('API Extractor completed with errors'));
148146
} else {
149-
console.log(os.EOL + colors.yellow('API Extractor completed with warnings'));
147+
console.log(os.EOL + Colorize.yellow('API Extractor completed with warnings'));
150148
}
151149
}
152150
}

apps/api-extractor/src/collector/MessageRouter.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
22
// See LICENSE in the project root for license information.
33

4-
import colors from 'colors';
54
import * as ts from 'typescript';
65
import type * as tsdoc from '@microsoft/tsdoc';
76
import { Sort, InternalError } from '@rushstack/node-core-library';
7+
import { Colorize } from '@rushstack/terminal';
88

99
import { AstDeclaration } from '../analyzer/AstDeclaration';
1010
import type { AstSymbol } from '../analyzer/AstSymbol';
@@ -597,17 +597,17 @@ export class MessageRouter {
597597

598598
switch (message.logLevel) {
599599
case ExtractorLogLevel.Error:
600-
console.error(colors.red('Error: ' + messageText));
600+
console.error(Colorize.red('Error: ' + messageText));
601601
break;
602602
case ExtractorLogLevel.Warning:
603-
console.warn(colors.yellow('Warning: ' + messageText));
603+
console.warn(Colorize.yellow('Warning: ' + messageText));
604604
break;
605605
case ExtractorLogLevel.Info:
606606
console.log(messageText);
607607
break;
608608
case ExtractorLogLevel.Verbose:
609609
if (this.showVerboseMessages) {
610-
console.log(colors.cyan(messageText));
610+
console.log(Colorize.cyan(messageText));
611611
}
612612
break;
613613
default:

apps/api-extractor/src/start.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,21 @@
22
// See LICENSE in the project root for license information.
33

44
import * as os from 'os';
5-
import colors from 'colors';
5+
import { Colorize } from '@rushstack/terminal';
66

77
import { ApiExtractorCommandLine } from './cli/ApiExtractorCommandLine';
88
import { Extractor } from './api/Extractor';
99

1010
console.log(
1111
os.EOL +
12-
colors.bold(`api-extractor ${Extractor.version} ` + colors.cyan(' - https://api-extractor.com/') + os.EOL)
12+
Colorize.bold(
13+
`api-extractor ${Extractor.version} ` + Colorize.cyan(' - https://api-extractor.com/') + os.EOL
14+
)
1315
);
1416

1517
const parser: ApiExtractorCommandLine = new ApiExtractorCommandLine();
1618

1719
parser.execute().catch((error) => {
18-
console.error(colors.red(`An unexpected error occurred: ${error}`));
20+
console.error(Colorize.red(`An unexpected error occurred: ${error}`));
1921
process.exit(1);
2022
});

apps/lockfile-explorer/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,18 @@
3838
},
3939
"devDependencies": {
4040
"@microsoft/rush-lib": "workspace:*",
41-
"local-node-rig": "workspace:*",
4241
"@rushstack/heft": "workspace:*",
4342
"@rushstack/lockfile-explorer-web": "workspace:*",
4443
"@types/cors": "~2.8.12",
4544
"@types/express": "4.17.13",
4645
"@types/js-yaml": "3.12.1",
47-
"@types/update-notifier": "~6.0.1"
46+
"@types/update-notifier": "~6.0.1",
47+
"local-node-rig": "workspace:*"
4848
},
4949
"dependencies": {
5050
"@rushstack/node-core-library": "workspace:*",
51+
"@rushstack/terminal": "workspace:*",
5152
"@types/express": "4.17.13",
52-
"colors": "~1.2.1",
5353
"cors": "~2.8.5",
5454
"express": "4.18.1",
5555
"js-yaml": "~3.13.1",

apps/lockfile-explorer/src/start.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ import express from 'express';
55
import yaml from 'js-yaml';
66
import cors from 'cors';
77
import process from 'process';
8-
import colors from 'colors/safe';
98
import open from 'open';
109
import updateNotifier from 'update-notifier';
10+
import { AlreadyReportedError } from '@rushstack/node-core-library';
1111
import { FileSystem, type IPackageJson, JsonFile, PackageJsonLookup } from '@rushstack/node-core-library';
1212
import type { IAppContext } from '@rushstack/lockfile-explorer-web/lib/AppContext';
13+
import { Colorize } from '@rushstack/terminal';
14+
1315
import { init } from './init';
1416
import type { IAppState } from './state';
15-
import { AlreadyReportedError } from '@rushstack/node-core-library';
1617

1718
function startApp(debugMode: boolean): void {
1819
const lockfileExplorerProjectRoot: string = PackageJsonLookup.instance.tryGetPackageFolderFor(__dirname)!;
@@ -22,7 +23,7 @@ function startApp(debugMode: boolean): void {
2223
const appVersion: string = lockfileExplorerPackageJson.version;
2324

2425
console.log(
25-
colors.bold(`\nRush Lockfile Explorer ${appVersion}`) + colors.cyan(' - https://lfx.rushstack.io/\n')
26+
Colorize.bold(`\nRush Lockfile Explorer ${appVersion}`) + Colorize.cyan(' - https://lfx.rushstack.io/\n')
2627
);
2728

2829
updateNotifier({
@@ -66,7 +67,7 @@ function startApp(debugMode: boolean): void {
6667
let disconnected: boolean = false;
6768
setInterval(() => {
6869
if (!isClientConnected && !awaitingFirstConnect && !disconnected) {
69-
console.log(colors.red('The client has disconnected!'));
70+
console.log(Colorize.red('The client has disconnected!'));
7071
console.log(`Please open a browser window at http://localhost:${PORT}/app`);
7172
disconnected = true;
7273
} else if (!awaitingFirstConnect) {
@@ -104,7 +105,7 @@ function startApp(debugMode: boolean): void {
104105
isClientConnected = true;
105106
if (disconnected) {
106107
disconnected = false;
107-
console.log(colors.green('The client has reconnected!'));
108+
console.log(Colorize.green('The client has reconnected!'));
108109
}
109110
res.status(200).send();
110111
});
@@ -201,7 +202,7 @@ if (debugMode) {
201202
} catch (error) {
202203
if (!(error instanceof AlreadyReportedError)) {
203204
console.error();
204-
console.error(colors.red('ERROR: ' + error.message));
205+
console.error(Colorize.red('ERROR: ' + error.message));
205206
}
206207
}
207208
}

apps/rush/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,8 @@
3838
"dependencies": {
3939
"@microsoft/rush-lib": "workspace:*",
4040
"@rushstack/node-core-library": "workspace:*",
41-
"colors": "~1.2.1",
42-
"semver": "~7.5.4",
43-
"@rushstack/terminal": "workspace:*"
41+
"@rushstack/terminal": "workspace:*",
42+
"semver": "~7.5.4"
4443
},
4544
"devDependencies": {
4645
"@rushstack/heft": "workspace:*",

0 commit comments

Comments
 (0)