Skip to content

Commit

Permalink
chore(core): improve consistency of output colors across terminal the…
Browse files Browse the repository at this point in the history
…mes (#9231)
  • Loading branch information
JamesHenry committed Mar 8, 2022
1 parent 8101df4 commit a3242c4
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 36 deletions.
2 changes: 1 addition & 1 deletion packages/tao/src/shared/logger.ts
Expand Up @@ -21,7 +21,7 @@ export const logger = {
if (typeof s === 'string' && s.startsWith('NX ')) {
console.info(`\n${NX_PREFIX} ${chalk.bold(s.substr(3))}\n`);
} else {
console.info(chalk.white(s));
console.info(s);
}
},
log: (...s) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/workspace/src/command-line/affected.ts
Expand Up @@ -50,7 +50,7 @@ export async function affected(
if (apps.length) {
output.log({
title: 'Affected apps:',
bodyLines: apps.map((app) => `${output.colors.gray('-')} ${app}`),
bodyLines: apps.map((app) => `${output.dim('-')} ${app}`),
});
}
}
Expand All @@ -66,7 +66,7 @@ export async function affected(
if (libs.length) {
output.log({
title: 'Affected libs:',
bodyLines: libs.map((lib) => `${output.colors.gray('-')} ${lib}`),
bodyLines: libs.map((lib) => `${output.dim('-')} ${lib}`),
});
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/workspace/src/command-line/utils.ts
Expand Up @@ -130,9 +130,9 @@ export function splitArgsIntoNxArgsAndOverrides(
'--all'
)} is not meant to be used for any sizable project or to be used in CI.`,
'',
`${output.colors.gray(
'Learn more about checking only what is affected: '
)}https://nx.dev/latest/angular/cli/affected#affected.`,
`${output.dim(
'Learn more about checking only what is affected: https://nx.dev/latest/angular/cli/affected#affected'
)}`,
],
});
}
Expand Down
Expand Up @@ -15,9 +15,7 @@ export class WorkspaceIntegrityChecks {
.filter((n) => n.data.files.length === 0)
.map((p) => `Cannot find project '${p.name}' in '${p.data.root}'`);

const errorGroupBodyLines = errors.map(
(f) => `${output.colors.gray('-')} ${f}`
);
const errorGroupBodyLines = errors.map((f) => `${output.dim('-')} ${f}`);

return errors.length === 0
? []
Expand All @@ -42,7 +40,7 @@ export class WorkspaceIntegrityChecks {
: allFilesWithoutProjects;

const errorGroupBodyLines = first5FilesWithoutProjects.map(
(f) => `${output.colors.gray('-')} ${f}`
(f) => `${output.dim('-')} ${f}`
);

return first5FilesWithoutProjects.length === 0
Expand Down
Expand Up @@ -134,9 +134,9 @@ export async function createRunOneDynamicOutputRenderer({
linesToRender.push(
` ${output.colors.cyan(
dots.frames[dependentTargetsCurrentFrame]
)} ${output.colors.white.dim(
)} ${output.dim(
`Nx is waiting on ${remainingDependentTasksNotFromInitiatingProject} dependent project tasks before running tasks from`
)} ${output.colors.white(`${initiatingProject}`)}...`
)} ${initiatingProject}${output.dim('...')}`
);
if (totalSuccessfulTasks > 0) {
linesToRender.push('');
Expand Down Expand Up @@ -296,7 +296,7 @@ export async function createRunOneDynamicOutputRenderer({
const pinnedFooterLines = [
output.applyNxPrefix(
'green',
output.colors.green(text) + output.dim.white(` (${timeTakenText})`)
output.colors.green(text) + output.dim(` (${timeTakenText})`)
),
...taskOverridesLines,
];
Expand Down Expand Up @@ -338,7 +338,7 @@ export async function createRunOneDynamicOutputRenderer({
[
output.applyNxPrefix(
'red',
output.colors.red(text) + output.dim.white(` (${timeTakenText})`)
output.colors.red(text) + output.dim(` (${timeTakenText})`)
),
...taskOverridesLines,
'',
Expand Down
Expand Up @@ -38,11 +38,11 @@ export class StaticRunManyTerminalOutputLifeCycle implements LifeCycle {
}

const bodyLines = this.projectNames.map(
(affectedProject) => ` ${output.colors.gray('-')} ${affectedProject}`
(affectedProject) => ` ${output.dim('-')} ${affectedProject}`
);
if (Object.keys(this.taskOverrides).length > 0) {
bodyLines.push('');
bodyLines.push(`${output.colors.gray('With flags:')}`);
bodyLines.push(`${output.dim('With flags:')}`);
Object.entries(this.taskOverrides)
.map(([flag, value]) => ` --${flag}=${value}`)
.forEach((arg) => bodyLines.push(arg));
Expand Down Expand Up @@ -77,7 +77,7 @@ export class StaticRunManyTerminalOutputLifeCycle implements LifeCycle {
const bodyLines =
this.cachedTasks.length > 0
? [
output.colors.gray(
output.dim(
`Nx read the output from the cache instead of running the command for ${this.cachedTasks.length} out of ${this.tasks.length} tasks.`
),
]
Expand All @@ -96,21 +96,17 @@ export class StaticRunManyTerminalOutputLifeCycle implements LifeCycle {
const skippedTasks = this.skippedTasks();
if (skippedTasks.length > 0) {
bodyLines.push(
output.colors.gray(
'Tasks not run because their dependencies failed:'
),
output.dim('Tasks not run because their dependencies failed:'),
'',
...skippedTasks.map(
(task) => `${output.colors.gray('-')} ${task.id}`
),
...skippedTasks.map((task) => `${output.dim('-')} ${task.id}`),
''
);
}
bodyLines.push(
output.colors.gray('Failed tasks:'),
output.dim('Failed tasks:'),
'',
...[...this.failedTasks.values()].map(
(task) => `${output.colors.gray('-')} ${task.id}`
(task) => `${output.dim('-')} ${task.id}`
)
);
output.error({
Expand Down
Expand Up @@ -58,7 +58,7 @@ export class StaticRunOneTerminalOutputLifeCycle implements LifeCycle {
const bodyLines =
this.cachedTasks.length > 0
? [
output.colors.gray(
output.dim(
`Nx read the output from the cache instead of running the command for ${this.cachedTasks.length} out of ${this.tasks.length} tasks.`
),
]
Expand All @@ -74,15 +74,13 @@ export class StaticRunOneTerminalOutputLifeCycle implements LifeCycle {
output.addVerticalSeparatorWithoutNewLines('red');

const bodyLines = [
output.colors.gray('Failed tasks:'),
output.dim('Failed tasks:'),
'',
...this.failedTasks.map(
(task) => `${output.colors.gray('-')} ${task.id}`
),
...this.failedTasks.map((task) => `${output.dim('-')} ${task.id}`),
'',
`${output.colors.gray(
'Hint: run the command with'
)} --verbose ${output.colors.gray('for more details.')}`,
`${output.dim('Hint: run the command with')} --verbose ${output.dim(
'for more details.'
)}`,
];
output.error({
title: `Running target "${this.initiatingProject}:${this.args.target}" failed`,
Expand Down
6 changes: 3 additions & 3 deletions packages/workspace/src/utilities/output.ts
Expand Up @@ -219,11 +219,11 @@ class CLIOutput {
this.addNewline();
let commandOutput = `${chalk.dim('> nx run')} ${message}`;
if (taskStatus === 'local-cache') {
commandOutput += ` ${chalk.grey('[local cache]')}`;
commandOutput += ` ${chalk.dim('[local cache]')}`;
} else if (taskStatus === 'remote-cache') {
commandOutput += ` ${chalk.grey('[remote cache]')}`;
commandOutput += ` ${chalk.dim('[remote cache]')}`;
} else if (taskStatus === 'local-cache-kept-existing') {
commandOutput += ` ${chalk.grey(
commandOutput += ` ${chalk.dim(
'[existing outputs match the cache, left as is]'
)}`;
}
Expand Down

0 comments on commit a3242c4

Please sign in to comment.