Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
"@octokit/rest": "^16.28.7",
"@schematics/angular": "^9.0.0-next.5",
"@types/browser-sync": "^2.26.1",
"@types/chalk": "^0.4.31",
"@types/fs-extra": "^4.0.3",
"@types/glob": "^5.0.33",
"@types/gulp": "3.8.32",
Expand All @@ -97,7 +96,7 @@
"autoprefixer": "^6.7.6",
"axe-webdriverjs": "^1.1.1",
"browser-sync": "^2.26.7",
"chalk": "^1.1.3",
"chalk": "^2.4.2",
"clang-format": "^1.2.4",
"codelyzer": "^5.1.1",
"conventional-changelog": "^3.0.5",
Expand Down
10 changes: 5 additions & 5 deletions scripts/breaking-changes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {join, relative} from 'path';
import {readFileSync} from 'fs';
import {bold, red, green} from 'chalk';
import chalk from 'chalk';
import * as ts from 'typescript';
import * as tsutils from 'tsutils';

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

console.log(isExpired ? red(header) : header);
console.log(isExpired ? red(messages) : messages, '\n');
console.log(isExpired ? chalk.red(header) : header);
console.log(isExpired ? chalk.red(messages) : messages, '\n');
});

/**
Expand Down
6 changes: 3 additions & 3 deletions src/cdk/schematics/ng-update/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

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

if (hasFailures) {
console.log(yellow(
console.log(chalk.yellow(
' ⚠ Some issues were detected but could not be fixed automatically. Please check the ' +
'output above and fix these issues manually.'));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

import {bold, green, red} from 'chalk';
import chalk from 'chalk';
import * as ts from 'typescript';
import {MigrationRule} from '../../update-tool/migration-rule';
import {PropertyNameUpgradeData} from '../data/property-names';
Expand Down Expand Up @@ -54,9 +54,9 @@ export class ClassInheritanceRule extends MigrationRule<RuleUpgradeData> {
if (data) {
this.createFailureAtNode(
node,
`Found class "${bold(className)}" which extends class ` +
`"${bold(typeName)}". Please note that the base class property ` +
`"${red(data.replace)}" has changed to "${green(data.replaceWith)}". ` +
`Found class "${chalk.bold(className)}" which extends class ` +
`"${chalk.bold(typeName)}". Please note that the base class property ` +
`"${chalk.red(data.replace)}" has changed to "${chalk.green(data.replaceWith)}". ` +
`You may need to update your class as well.`);
}
});
Expand Down
1 change: 1 addition & 0 deletions src/material/schematics/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ ts_library(
"@npm//@types/node",
"@npm//tslint",
"@npm//typescript",
"@npm//chalk",
],
)

Expand Down
19 changes: 10 additions & 9 deletions src/material/schematics/ng-add/setup-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
getProjectStyleFile,
hasNgModuleImport,
} from '@angular/cdk/schematics';
import {red, bold, italic} from 'chalk';
import chalk from 'chalk';
import {getWorkspace} from '@schematics/angular/utility/config';
import {getAppModulePath} from '@schematics/angular/utility/ng-ast-utils';
import {addFontsToIndex} from './fonts/material-fonts';
Expand Down Expand Up @@ -61,9 +61,10 @@ function addAnimationsModule(options: Schema) {
// animations. If we would add the BrowserAnimationsModule while the NoopAnimationsModule
// is already configured, we would cause unexpected behavior and runtime exceptions.
if (hasNgModuleImport(host, appModulePath, noopAnimationsModuleName)) {
return console.warn(red(`Could not set up "${bold(browserAnimationsModuleName)}" ` +
`because "${bold(noopAnimationsModuleName)}" is already imported. Please manually ` +
`set up browser animations.`));
return console.warn(chalk.red(
`Could not set up "${chalk.bold(browserAnimationsModuleName)}" ` +
`because "${chalk.bold(noopAnimationsModuleName)}" is already imported. Please ` +
`manually set up browser animations.`));
}

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

if (!styleFilePath) {
console.warn(red(`Could not find the default style file for this project.`));
console.warn(red(`Please consider manually setting up the Roboto font in your CSS.`));
console.warn(chalk.red(`Could not find the default style file for this project.`));
console.warn(chalk.red(`Please consider manually setting up the Roboto font in your CSS.`));
return;
}

const buffer = host.read(styleFilePath);

if (!buffer) {
console.warn(red(`Could not read the default style file within the project ` +
`(${italic(styleFilePath)})`));
console.warn(red(`Please consider manually setting up the Robot font.`));
console.warn(chalk.red(`Could not read the default style file within the project ` +
`(${chalk.italic(styleFilePath)})`));
console.warn(chalk.red(`Please consider manually setting up the Robot font.`));
return;
}

Expand Down
15 changes: 8 additions & 7 deletions src/material/schematics/ng-add/theming/theming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
} from '@angular/cdk/schematics';
import {InsertChange} from '@schematics/angular/utility/change';
import {getWorkspace} from '@schematics/angular/utility/config';
import {bold, red, yellow} from 'chalk';
import chalk from 'chalk';
import {join} from 'path';
import {Schema} from '../schema';
import {createCustomTheme} from './create-custom-theme';
Expand Down Expand Up @@ -71,8 +71,8 @@ function insertCustomTheme(project: WorkspaceProject, projectName: string, host:
const customThemePath = normalize(join(project.sourceRoot, defaultCustomThemeFilename));

if (host.exists(customThemePath)) {
console.warn(yellow(`Cannot create a custom Angular Material theme because
${bold(customThemePath)} already exists. Skipping custom theme generation.`));
console.warn(chalk.yellow(`Cannot create a custom Angular Material theme because
${chalk.bold(customThemePath)} already exists. Skipping custom theme generation.`));
return;
}

Expand Down Expand Up @@ -125,10 +125,11 @@ function addThemeStyleToTarget(project: WorkspaceProject, targetName: 'test' | '
// theme because these files can contain custom styles, while prebuilt themes are
// always packaged and considered replaceable.
if (stylePath.includes(defaultCustomThemeFilename)) {
console.warn(red(`Could not add the selected theme to the CLI project configuration ` +
`because there is already a custom theme file referenced.`));
console.warn(red(`Please manually add the following style file to your configuration:`));
console.warn(yellow(` ${bold(assetPath)}`));
console.warn(chalk.red(`Could not add the selected theme to the CLI project ` +
`configuration because there is already a custom theme file referenced.`));
console.warn(chalk.red(
`Please manually add the following style file to your configuration:`));
console.warn(chalk.yellow(` ${chalk.bold(assetPath)}`));
return;
} else if (stylePath.includes(prebuiltThemePathSegment)) {
targetOptions.styles.splice(index, 1);
Expand Down
6 changes: 3 additions & 3 deletions src/material/schematics/ng-update/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

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

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

if (hasFailures) {
console.log(yellow(
console.log(chalk.yellow(
' ⚠ Some issues were detected but could not be fixed automatically. Please check the ' +
'output above and fix these issues manually.'));
}
Expand Down
14 changes: 7 additions & 7 deletions tools/cherry-pick-patch/output-results.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {PullsGetResponse} from '@octokit/rest';
import {cyan} from 'chalk';
import chalk from 'chalk';

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

console.log();
console.log(cyan('------------------------'));
console.log(cyan(' Results '));
console.log(cyan('------------------------'));
console.log(chalk.cyan('------------------------'));
console.log(chalk.cyan(' Results '));
console.log(chalk.cyan('------------------------'));
console.log();

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

console.log();
console.log(cyan('------------------------'));
console.log(cyan(' Cherry Pick Commands'));
console.log(cyan('------------------------'));
console.log(chalk.cyan('------------------------'));
console.log(chalk.cyan(' Cherry Pick Commands'));
console.log(chalk.cyan('------------------------'));

pullRequests.forEach((pr, index) => {
if (index % 5 === 0) {
Expand Down
5 changes: 3 additions & 2 deletions tools/gulp/tasks/default.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import {task} from 'gulp';
import {yellow} from 'chalk';
import chalk from 'chalk';

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

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

4 changes: 2 additions & 2 deletions tools/gulp/tasks/lint.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {red} from 'chalk';
import chalk from 'chalk';
import {readdirSync, readFileSync, statSync} from 'fs';
import {task} from 'gulp';
import {IMinimatch, Minimatch} from 'minimatch';
Expand Down Expand Up @@ -62,7 +62,7 @@ task('ownerslint', () => {
// Report an error for any files that didn't match any owned paths.
.filter(path => {
if (statSync(path).isFile()) {
console.log(red(`No code owner found for "${path}".`));
console.log(chalk.red(`No code owner found for "${path}".`));
errors++;
return false;
}
Expand Down
5 changes: 3 additions & 2 deletions tools/package-tools/compile-entry-point.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {join} from 'path';
import {writeFileSync, readFileSync} from 'fs';
import {sync as glob} from 'glob';
import {red} from 'chalk';
import chalk from 'chalk';
import {BuildPackage} from './build-package';
import {tsCompile} from './ts-compile';

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

return tsCompile('ngc', ngcFlags).catch(() => {
const error = red(`Failed to compile ${secondaryEntryPoint} using ${entryPointTsconfigPath}`);
const error = chalk.red(
`Failed to compile ${secondaryEntryPoint} using ${entryPointTsconfigPath}`);
console.error(error);
return Promise.reject(error);
});
Expand Down
4 changes: 2 additions & 2 deletions tools/package-tools/ts-compile.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {resolve as resolvePath} from 'path';
import {spawn} from 'child_process';
import {red} from 'chalk';
import chalk from 'chalk';

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

// Pipe stdout and stderr from the child process.
childProcess.stdout.on('data', (data: string|Buffer) => console.log(`${data}`));
childProcess.stderr.on('data', (data: string|Buffer) => console.error(red(`${data}`)));
childProcess.stderr.on('data', (data: string|Buffer) => console.error(chalk.red(`${data}`)));
childProcess.on('exit', (exitCode: number) => {
exitCode === 0 ? resolve() : reject(`${binary} compilation failure`);
});
Expand Down
2 changes: 1 addition & 1 deletion tools/package-tools/typescript-transpile.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as ts from 'typescript';
import * as path from 'path';
import * as fs from 'fs';
import * as chalk from 'chalk';
import chalk from 'chalk';

/** Reads a input file and transpiles it into a new file. */
export function transpileFile(inputPath: string, outputPath: string, options: ts.CompilerOptions) {
Expand Down
25 changes: 13 additions & 12 deletions tools/release/base-release-task.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {green, italic, red, yellow} from 'chalk';
import chalk from 'chalk';
import {prompt} from 'inquirer';
import {GitClient} from './git/git-client';
import {Version} from './version-name/parse-version';
Expand All @@ -20,15 +20,15 @@ export class BaseReleaseTask {
// If current branch already matches one of the allowed publish branches, just continue
// by exiting this function and returning the currently used publish branch.
if (allowedBranches.includes(currentBranchName)) {
console.log(green(` ✓ Using the "${italic(currentBranchName)}" branch.`));
console.log(chalk.green(` ✓ Using the "${chalk.italic(currentBranchName)}" branch.`));
return currentBranchName;
}

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

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

console.log(green(` ✓ Switched to the "${italic(defaultPublishBranch)}" branch.`));
console.log(chalk.green(
` ✓ Switched to the "${chalk.italic(defaultPublishBranch)}" branch.`));
return defaultPublishBranch;
}

Expand All @@ -56,16 +57,16 @@ export class BaseReleaseTask {

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

/** Verifies that there are no uncommitted changes in the project. */
protected verifyNoUncommittedChanges() {
if (this.git.hasUncommittedChanges()) {
console.error(red(` ✘ There are changes which are not committed and should be ` +
console.error(chalk.red(` ✘ There are changes which are not committed and should be ` +
`discarded.`));
process.exit(1);
}
Expand Down
6 changes: 3 additions & 3 deletions tools/release/changelog.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {bold, green, yellow} from 'chalk';
import chalk from 'chalk';
import {createReadStream, createWriteStream, readFileSync} from 'fs';
import {prompt} from 'inquirer';
import {join} from 'path';
Expand Down Expand Up @@ -115,7 +115,7 @@ function createChangelogWriterOptions(changelogPath: string) {
// Filter out duplicate commits. Note that we cannot compare the SHA because the commits
// will have a different SHA if they are being cherry-picked into a different branch.
if (existingChangelogContent.includes(commit.subject)) {
console.log(yellow(` ↺ Skipping duplicate: "${bold(commit.header)}"`));
console.log(chalk.yellow(` ↺ Skipping duplicate: "${chalk.bold(commit.header)}"`));
return false;
}

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