Skip to content

Commit bf6a91a

Browse files
devversionandrewseguin
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. (cherry picked from commit 7cd78ff)
1 parent a5d2ed8 commit bf6a91a

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": "^8.2.1",
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.0",
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';
@@ -30,11 +30,11 @@ export function updateToV8(): Rule {
3030
/** Function that will be called when the migration completed. */
3131
function onMigrationComplete(targetVersion: TargetVersion, hasFailures: boolean) {
3232
console.log();
33-
console.log(green(` ✓ Updated Angular CDK to ${targetVersion}`));
33+
console.log(chalk.green(` ✓ Updated Angular CDK to ${targetVersion}`));
3434
console.log();
3535

3636
if (hasFailures) {
37-
console.log(yellow(
37+
console.log(chalk.yellow(
3838
' ⚠ Some issues were detected but could not be fixed automatically. Please check the ' +
3939
'output above and fix these issues manually.'));
4040
}

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';
@@ -52,11 +52,11 @@ export function updateToV8(): Rule {
5252
/** Function that will be called when the migration completed. */
5353
function onMigrationComplete(targetVersion: TargetVersion, hasFailures: boolean) {
5454
console.log();
55-
console.log(green(` ✓ Updated Angular Material to ${targetVersion}`));
55+
console.log(chalk.green(` ✓ Updated Angular Material to ${targetVersion}`));
5656
console.log();
5757

5858
if (hasFailures) {
59-
console.log(yellow(
59+
console.log(chalk.yellow(
6060
' ⚠ Some issues were detected but could not be fixed automatically. Please check the ' +
6161
'output above and fix these issues manually.'));
6262
}

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

0 commit comments

Comments
 (0)