Skip to content

Commit 7cd78ff

Browse files
devversionjelbourn
authored andcommitted
build: update to chalk version that works in circleci (#17193)
Updates to a chalk version that works in CircleCI (due to a more recent dependency on `supports-color`). Since the latest chalk version brings official typings that do not declare individual colors as ESM exports, we need to go through the default export. This is the official expected behavior with `chalk` according to: chalk/chalk#215.
1 parent 7b07e4d commit 7cd78ff

File tree

21 files changed

+153
-143
lines changed

21 files changed

+153
-143
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@
7878
"@octokit/rest": "^16.28.7",
7979
"@schematics/angular": "^9.0.0-next.5",
8080
"@types/browser-sync": "^2.26.1",
81-
"@types/chalk": "^0.4.31",
8281
"@types/fs-extra": "^4.0.3",
8382
"@types/glob": "^5.0.33",
8483
"@types/gulp": "3.8.32",
@@ -97,7 +96,7 @@
9796
"autoprefixer": "^6.7.6",
9897
"axe-webdriverjs": "^1.1.1",
9998
"browser-sync": "^2.26.7",
100-
"chalk": "^1.1.3",
99+
"chalk": "^2.4.2",
101100
"clang-format": "^1.2.4",
102101
"codelyzer": "^5.1.1",
103102
"conventional-changelog": "^3.0.5",

scripts/breaking-changes.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {join, relative} from 'path';
22
import {readFileSync} from 'fs';
3-
import {bold, red, green} from 'chalk';
3+
import chalk from 'chalk';
44
import * as ts from 'typescript';
55
import * as tsutils from 'tsutils';
66

@@ -47,12 +47,12 @@ parsedConfig.fileNames.forEach(fileName => {
4747
// Go through the summary and log out all of the breaking changes.
4848
Object.keys(summary).forEach(version => {
4949
const isExpired = hasExpired(packageVersion, version);
50-
const status = isExpired ? red('(expired)') : green('(not expired)');
51-
const header = bold(`Breaking changes for ${version} ${status}:`);
50+
const status = isExpired ? chalk.red('(expired)') : chalk.green('(not expired)');
51+
const header = chalk.bold(`Breaking changes for ${version} ${status}:`);
5252
const messages = summary[version].join('\n');
5353

54-
console.log(isExpired ? red(header) : header);
55-
console.log(isExpired ? red(messages) : messages, '\n');
54+
console.log(isExpired ? chalk.red(header) : header);
55+
console.log(isExpired ? chalk.red(messages) : messages, '\n');
5656
});
5757

5858
/**

src/cdk/schematics/ng-update/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import {Rule} from '@angular-devkit/schematics';
10-
import {green, yellow} from 'chalk';
10+
import chalk from 'chalk';
1111
import {TargetVersion} from '../update-tool/target-version';
1212
import {cdkUpgradeData} from './upgrade-data';
1313
import {createUpgradeRule} from './upgrade-rules';
@@ -35,11 +35,11 @@ export function updateToV9(): Rule {
3535
/** Function that will be called when the migration completed. */
3636
function onMigrationComplete(targetVersion: TargetVersion, hasFailures: boolean) {
3737
console.log();
38-
console.log(green(` ✓ Updated Angular CDK to ${targetVersion}`));
38+
console.log(chalk.green(` ✓ Updated Angular CDK to ${targetVersion}`));
3939
console.log();
4040

4141
if (hasFailures) {
42-
console.log(yellow(
42+
console.log(chalk.yellow(
4343
' ⚠ Some issues were detected but could not be fixed automatically. Please check the ' +
4444
'output above and fix these issues manually.'));
4545
}

src/cdk/schematics/ng-update/upgrade-rules/class-inheritance-rule.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {bold, green, red} from 'chalk';
9+
import chalk from 'chalk';
1010
import * as ts from 'typescript';
1111
import {MigrationRule} from '../../update-tool/migration-rule';
1212
import {PropertyNameUpgradeData} from '../data/property-names';
@@ -54,9 +54,9 @@ export class ClassInheritanceRule extends MigrationRule<RuleUpgradeData> {
5454
if (data) {
5555
this.createFailureAtNode(
5656
node,
57-
`Found class "${bold(className)}" which extends class ` +
58-
`"${bold(typeName)}". Please note that the base class property ` +
59-
`"${red(data.replace)}" has changed to "${green(data.replaceWith)}". ` +
57+
`Found class "${chalk.bold(className)}" which extends class ` +
58+
`"${chalk.bold(typeName)}". Please note that the base class property ` +
59+
`"${chalk.red(data.replace)}" has changed to "${chalk.green(data.replaceWith)}". ` +
6060
`You may need to update your class as well.`);
6161
}
6262
});

src/material/schematics/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ ts_library(
3434
"@npm//@types/node",
3535
"@npm//tslint",
3636
"@npm//typescript",
37+
"@npm//chalk",
3738
],
3839
)
3940

src/material/schematics/ng-add/setup-project.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
getProjectStyleFile,
1515
hasNgModuleImport,
1616
} from '@angular/cdk/schematics';
17-
import {red, bold, italic} from 'chalk';
17+
import chalk from 'chalk';
1818
import {getWorkspace} from '@schematics/angular/utility/config';
1919
import {getAppModulePath} from '@schematics/angular/utility/ng-ast-utils';
2020
import {addFontsToIndex} from './fonts/material-fonts';
@@ -61,9 +61,10 @@ function addAnimationsModule(options: Schema) {
6161
// animations. If we would add the BrowserAnimationsModule while the NoopAnimationsModule
6262
// is already configured, we would cause unexpected behavior and runtime exceptions.
6363
if (hasNgModuleImport(host, appModulePath, noopAnimationsModuleName)) {
64-
return console.warn(red(`Could not set up "${bold(browserAnimationsModuleName)}" ` +
65-
`because "${bold(noopAnimationsModuleName)}" is already imported. Please manually ` +
66-
`set up browser animations.`));
64+
return console.warn(chalk.red(
65+
`Could not set up "${chalk.bold(browserAnimationsModuleName)}" ` +
66+
`because "${chalk.bold(noopAnimationsModuleName)}" is already imported. Please ` +
67+
`manually set up browser animations.`));
6768
}
6869

6970
addModuleImportToRootModule(host, browserAnimationsModuleName,
@@ -90,17 +91,17 @@ function addMaterialAppStyles(options: Schema) {
9091
const styleFilePath = getProjectStyleFile(project);
9192

9293
if (!styleFilePath) {
93-
console.warn(red(`Could not find the default style file for this project.`));
94-
console.warn(red(`Please consider manually setting up the Roboto font in your CSS.`));
94+
console.warn(chalk.red(`Could not find the default style file for this project.`));
95+
console.warn(chalk.red(`Please consider manually setting up the Roboto font in your CSS.`));
9596
return;
9697
}
9798

9899
const buffer = host.read(styleFilePath);
99100

100101
if (!buffer) {
101-
console.warn(red(`Could not read the default style file within the project ` +
102-
`(${italic(styleFilePath)})`));
103-
console.warn(red(`Please consider manually setting up the Robot font.`));
102+
console.warn(chalk.red(`Could not read the default style file within the project ` +
103+
`(${chalk.italic(styleFilePath)})`));
104+
console.warn(chalk.red(`Please consider manually setting up the Robot font.`));
104105
return;
105106
}
106107

src/material/schematics/ng-add/theming/theming.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
} from '@angular/cdk/schematics';
1717
import {InsertChange} from '@schematics/angular/utility/change';
1818
import {getWorkspace} from '@schematics/angular/utility/config';
19-
import {bold, red, yellow} from 'chalk';
19+
import chalk from 'chalk';
2020
import {join} from 'path';
2121
import {Schema} from '../schema';
2222
import {createCustomTheme} from './create-custom-theme';
@@ -71,8 +71,8 @@ function insertCustomTheme(project: WorkspaceProject, projectName: string, host:
7171
const customThemePath = normalize(join(project.sourceRoot, defaultCustomThemeFilename));
7272

7373
if (host.exists(customThemePath)) {
74-
console.warn(yellow(`Cannot create a custom Angular Material theme because
75-
${bold(customThemePath)} already exists. Skipping custom theme generation.`));
74+
console.warn(chalk.yellow(`Cannot create a custom Angular Material theme because
75+
${chalk.bold(customThemePath)} already exists. Skipping custom theme generation.`));
7676
return;
7777
}
7878

@@ -125,10 +125,11 @@ function addThemeStyleToTarget(project: WorkspaceProject, targetName: 'test' | '
125125
// theme because these files can contain custom styles, while prebuilt themes are
126126
// always packaged and considered replaceable.
127127
if (stylePath.includes(defaultCustomThemeFilename)) {
128-
console.warn(red(`Could not add the selected theme to the CLI project configuration ` +
129-
`because there is already a custom theme file referenced.`));
130-
console.warn(red(`Please manually add the following style file to your configuration:`));
131-
console.warn(yellow(` ${bold(assetPath)}`));
128+
console.warn(chalk.red(`Could not add the selected theme to the CLI project ` +
129+
`configuration because there is already a custom theme file referenced.`));
130+
console.warn(chalk.red(
131+
`Please manually add the following style file to your configuration:`));
132+
console.warn(chalk.yellow(` ${chalk.bold(assetPath)}`));
132133
return;
133134
} else if (stylePath.includes(prebuiltThemePathSegment)) {
134135
targetOptions.styles.splice(index, 1);

src/material/schematics/ng-update/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import {Rule} from '@angular-devkit/schematics';
1010
import {createUpgradeRule, TargetVersion} from '@angular/cdk/schematics';
11-
import {green, yellow} from 'chalk';
11+
import chalk from 'chalk';
1212

1313
import {materialUpgradeData} from './upgrade-data';
1414
import {MiscClassInheritanceRule} from './upgrade-rules/misc-checks/misc-class-inheritance-rule';
@@ -58,11 +58,11 @@ export function updateToV9(): Rule {
5858
/** Function that will be called when the migration completed. */
5959
function onMigrationComplete(targetVersion: TargetVersion, hasFailures: boolean) {
6060
console.log();
61-
console.log(green(` ✓ Updated Angular Material to ${targetVersion}`));
61+
console.log(chalk.green(` ✓ Updated Angular Material to ${targetVersion}`));
6262
console.log();
6363

6464
if (hasFailures) {
65-
console.log(yellow(
65+
console.log(chalk.yellow(
6666
' ⚠ Some issues were detected but could not be fixed automatically. Please check the ' +
6767
'output above and fix these issues manually.'));
6868
}

tools/cherry-pick-patch/output-results.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {PullsGetResponse} from '@octokit/rest';
2-
import {cyan} from 'chalk';
2+
import chalk from 'chalk';
33

44
/** Outputs the information of the pull requests to be cherry-picked and the commands to run. */
55
export function outputResults(pullRequests: PullsGetResponse[]) {
@@ -9,9 +9,9 @@ export function outputResults(pullRequests: PullsGetResponse[]) {
99
}
1010

1111
console.log();
12-
console.log(cyan('------------------------'));
13-
console.log(cyan(' Results '));
14-
console.log(cyan('------------------------'));
12+
console.log(chalk.cyan('------------------------'));
13+
console.log(chalk.cyan(' Results '));
14+
console.log(chalk.cyan('------------------------'));
1515
console.log();
1616

1717
pullRequests.forEach(p => {
@@ -20,9 +20,9 @@ export function outputResults(pullRequests: PullsGetResponse[]) {
2020
});
2121

2222
console.log();
23-
console.log(cyan('------------------------'));
24-
console.log(cyan(' Cherry Pick Commands'));
25-
console.log(cyan('------------------------'));
23+
console.log(chalk.cyan('------------------------'));
24+
console.log(chalk.cyan(' Cherry Pick Commands'));
25+
console.log(chalk.cyan('------------------------'));
2626

2727
pullRequests.forEach((pr, index) => {
2828
if (index % 5 === 0) {

tools/gulp/tasks/default.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import {task} from 'gulp';
2-
import {yellow} from 'chalk';
2+
import chalk from 'chalk';
33

44
task('default', ['help']);
55

66
task('help', function() {
77
console.log();
88
console.log('Please specify a gulp task you want to run.');
9-
console.log(`You're probably looking for ${yellow('test')} or ${yellow('serve:devapp')}.`);
9+
console.log(`You're probably looking for ${chalk.yellow('test')} or ` +
10+
`${chalk.yellow('serve:devapp')}.`);
1011
console.log();
1112
});
1213

tools/gulp/tasks/lint.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {red} from 'chalk';
1+
import chalk from 'chalk';
22
import {readdirSync, readFileSync, statSync} from 'fs';
33
import {task} from 'gulp';
44
import {IMinimatch, Minimatch} from 'minimatch';
@@ -62,7 +62,7 @@ task('ownerslint', () => {
6262
// Report an error for any files that didn't match any owned paths.
6363
.filter(path => {
6464
if (statSync(path).isFile()) {
65-
console.log(red(`No code owner found for "${path}".`));
65+
console.log(chalk.red(`No code owner found for "${path}".`));
6666
errors++;
6767
return false;
6868
}

tools/package-tools/compile-entry-point.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {join} from 'path';
22
import {writeFileSync, readFileSync} from 'fs';
33
import {sync as glob} from 'glob';
4-
import {red} from 'chalk';
4+
import chalk from 'chalk';
55
import {BuildPackage} from './build-package';
66
import {tsCompile} from './ts-compile';
77

@@ -20,7 +20,8 @@ export async function compileEntryPoint(buildPackage: BuildPackage, tsconfigName
2020
}
2121

2222
return tsCompile('ngc', ngcFlags).catch(() => {
23-
const error = red(`Failed to compile ${secondaryEntryPoint} using ${entryPointTsconfigPath}`);
23+
const error = chalk.red(
24+
`Failed to compile ${secondaryEntryPoint} using ${entryPointTsconfigPath}`);
2425
console.error(error);
2526
return Promise.reject(error);
2627
});

tools/package-tools/ts-compile.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {resolve as resolvePath} from 'path';
22
import {spawn} from 'child_process';
3-
import {red} from 'chalk';
3+
import chalk from 'chalk';
44

55
/**
66
* Spawns a child process that compiles TypeScript using the specified compiler binary.
@@ -15,7 +15,7 @@ export function tsCompile(binary: 'tsc' | 'ngc', flags: string[]) {
1515

1616
// Pipe stdout and stderr from the child process.
1717
childProcess.stdout.on('data', (data: string|Buffer) => console.log(`${data}`));
18-
childProcess.stderr.on('data', (data: string|Buffer) => console.error(red(`${data}`)));
18+
childProcess.stderr.on('data', (data: string|Buffer) => console.error(chalk.red(`${data}`)));
1919
childProcess.on('exit', (exitCode: number) => {
2020
exitCode === 0 ? resolve() : reject(`${binary} compilation failure`);
2121
});

tools/package-tools/typescript-transpile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as ts from 'typescript';
22
import * as path from 'path';
33
import * as fs from 'fs';
4-
import * as chalk from 'chalk';
4+
import chalk from 'chalk';
55

66
/** Reads a input file and transpiles it into a new file. */
77
export function transpileFile(inputPath: string, outputPath: string, options: ts.CompilerOptions) {

tools/release/base-release-task.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {green, italic, red, yellow} from 'chalk';
1+
import chalk from 'chalk';
22
import {prompt} from 'inquirer';
33
import {GitClient} from './git/git-client';
44
import {Version} from './version-name/parse-version';
@@ -20,15 +20,15 @@ export class BaseReleaseTask {
2020
// If current branch already matches one of the allowed publish branches, just continue
2121
// by exiting this function and returning the currently used publish branch.
2222
if (allowedBranches.includes(currentBranchName)) {
23-
console.log(green(` ✓ Using the "${italic(currentBranchName)}" branch.`));
23+
console.log(chalk.green(` ✓ Using the "${chalk.italic(currentBranchName)}" branch.`));
2424
return currentBranchName;
2525
}
2626

2727
// In case there are multiple allowed publish branches for this version, we just
2828
// exit and let the user decide which branch they want to release from.
2929
if (allowedBranches.length !== 1) {
30-
console.warn(yellow(' ✘ You are not on an allowed publish branch.'));
31-
console.warn(yellow(` Please switch to one of the following branches: ` +
30+
console.warn(chalk.yellow(' ✘ You are not on an allowed publish branch.'));
31+
console.warn(chalk.yellow(` Please switch to one of the following branches: ` +
3232
`${allowedBranches.join(', ')}`));
3333
process.exit(0);
3434
}
@@ -38,14 +38,15 @@ export class BaseReleaseTask {
3838
const defaultPublishBranch = allowedBranches[0];
3939

4040
if (!this.git.checkoutBranch(defaultPublishBranch)) {
41-
console.error(red(` ✘ Could not switch to the "${italic(defaultPublishBranch)}" ` +
42-
`branch.`));
43-
console.error(red(` Please ensure that the branch exists or manually switch to the ` +
44-
`branch.`));
41+
console.error(chalk.red(
42+
` ✘ Could not switch to the "${chalk.italic(defaultPublishBranch)}" branch.`));
43+
console.error(chalk.red(
44+
` Please ensure that the branch exists or manually switch to the branch.`));
4545
process.exit(1);
4646
}
4747

48-
console.log(green(` ✓ Switched to the "${italic(defaultPublishBranch)}" branch.`));
48+
console.log(chalk.green(
49+
` ✓ Switched to the "${chalk.italic(defaultPublishBranch)}" branch.`));
4950
return defaultPublishBranch;
5051
}
5152

@@ -56,16 +57,16 @@ export class BaseReleaseTask {
5657

5758
// Check if the current branch is in sync with the remote branch.
5859
if (upstreamCommitSha !== localCommitSha) {
59-
console.error(red(` ✘ The current branch is not in sync with the remote branch. Please ` +
60-
`make sure your local branch "${italic(publishBranch)}" is up to date.`));
60+
console.error(chalk.red(` ✘ The current branch is not in sync with the remote branch. Please ` +
61+
`make sure your local branch "${chalk.italic(publishBranch)}" is up to date.`));
6162
process.exit(1);
6263
}
6364
}
6465

6566
/** Verifies that there are no uncommitted changes in the project. */
6667
protected verifyNoUncommittedChanges() {
6768
if (this.git.hasUncommittedChanges()) {
68-
console.error(red(` ✘ There are changes which are not committed and should be ` +
69+
console.error(chalk.red(` ✘ There are changes which are not committed and should be ` +
6970
`discarded.`));
7071
process.exit(1);
7172
}

tools/release/changelog.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {bold, green, yellow} from 'chalk';
1+
import chalk from 'chalk';
22
import {createReadStream, createWriteStream, readFileSync} from 'fs';
33
import {prompt} from 'inquirer';
44
import {join} from 'path';
@@ -115,7 +115,7 @@ function createChangelogWriterOptions(changelogPath: string) {
115115
// Filter out duplicate commits. Note that we cannot compare the SHA because the commits
116116
// will have a different SHA if they are being cherry-picked into a different branch.
117117
if (existingChangelogContent.includes(commit.subject)) {
118-
console.log(yellow(` ↺ Skipping duplicate: "${bold(commit.header)}"`));
118+
console.log(chalk.yellow(` ↺ Skipping duplicate: "${chalk.bold(commit.header)}"`));
119119
return false;
120120
}
121121

@@ -206,6 +206,6 @@ function getTypeOfCommitGroupDescription(description: string): string {
206206
/** Entry-point for generating the changelog when called through the CLI. */
207207
if (require.main === module) {
208208
promptAndGenerateChangelog(join(__dirname, '../../CHANGELOG.md')).then(() => {
209-
console.log(green(' ✓ Successfully updated the changelog.'));
209+
console.log(chalk.green(' ✓ Successfully updated the changelog.'));
210210
});
211211
}

0 commit comments

Comments
 (0)