chore(core): improve consistency of output colors across terminal themes (#9231)

This commit is contained in:
James Henry 2022-03-09 00:11:32 +04:00 committed by GitHub
parent 8101df4396
commit a3242c4dcc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 28 additions and 36 deletions

View File

@ -21,7 +21,7 @@ export const logger = {
if (typeof s === 'string' && s.startsWith('NX ')) { if (typeof s === 'string' && s.startsWith('NX ')) {
console.info(`\n${NX_PREFIX} ${chalk.bold(s.substr(3))}\n`); console.info(`\n${NX_PREFIX} ${chalk.bold(s.substr(3))}\n`);
} else { } else {
console.info(chalk.white(s)); console.info(s);
} }
}, },
log: (...s) => { log: (...s) => {

View File

@ -50,7 +50,7 @@ export async function affected(
if (apps.length) { if (apps.length) {
output.log({ output.log({
title: 'Affected apps:', title: 'Affected apps:',
bodyLines: apps.map((app) => `${output.colors.gray('-')} ${app}`), bodyLines: apps.map((app) => `${output.dim('-')} ${app}`),
}); });
} }
} }
@ -66,7 +66,7 @@ export async function affected(
if (libs.length) { if (libs.length) {
output.log({ output.log({
title: 'Affected libs:', title: 'Affected libs:',
bodyLines: libs.map((lib) => `${output.colors.gray('-')} ${lib}`), bodyLines: libs.map((lib) => `${output.dim('-')} ${lib}`),
}); });
} }
} }

View File

@ -130,9 +130,9 @@ export function splitArgsIntoNxArgsAndOverrides(
'--all' '--all'
)} is not meant to be used for any sizable project or to be used in CI.`, )} is not meant to be used for any sizable project or to be used in CI.`,
'', '',
`${output.colors.gray( `${output.dim(
'Learn more about checking only what is affected: ' 'Learn more about checking only what is affected: https://nx.dev/latest/angular/cli/affected#affected'
)}https://nx.dev/latest/angular/cli/affected#affected.`, )}`,
], ],
}); });
} }

View File

@ -15,9 +15,7 @@ export class WorkspaceIntegrityChecks {
.filter((n) => n.data.files.length === 0) .filter((n) => n.data.files.length === 0)
.map((p) => `Cannot find project '${p.name}' in '${p.data.root}'`); .map((p) => `Cannot find project '${p.name}' in '${p.data.root}'`);
const errorGroupBodyLines = errors.map( const errorGroupBodyLines = errors.map((f) => `${output.dim('-')} ${f}`);
(f) => `${output.colors.gray('-')} ${f}`
);
return errors.length === 0 return errors.length === 0
? [] ? []
@ -42,7 +40,7 @@ export class WorkspaceIntegrityChecks {
: allFilesWithoutProjects; : allFilesWithoutProjects;
const errorGroupBodyLines = first5FilesWithoutProjects.map( const errorGroupBodyLines = first5FilesWithoutProjects.map(
(f) => `${output.colors.gray('-')} ${f}` (f) => `${output.dim('-')} ${f}`
); );
return first5FilesWithoutProjects.length === 0 return first5FilesWithoutProjects.length === 0

View File

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

View File

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

View File

@ -58,7 +58,7 @@ export class StaticRunOneTerminalOutputLifeCycle implements LifeCycle {
const bodyLines = const bodyLines =
this.cachedTasks.length > 0 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.` `Nx read the output from the cache instead of running the command for ${this.cachedTasks.length} out of ${this.tasks.length} tasks.`
), ),
] ]
@ -74,15 +74,13 @@ export class StaticRunOneTerminalOutputLifeCycle implements LifeCycle {
output.addVerticalSeparatorWithoutNewLines('red'); output.addVerticalSeparatorWithoutNewLines('red');
const bodyLines = [ const bodyLines = [
output.colors.gray('Failed tasks:'), output.dim('Failed tasks:'),
'', '',
...this.failedTasks.map( ...this.failedTasks.map((task) => `${output.dim('-')} ${task.id}`),
(task) => `${output.colors.gray('-')} ${task.id}`
),
'', '',
`${output.colors.gray( `${output.dim('Hint: run the command with')} --verbose ${output.dim(
'Hint: run the command with' 'for more details.'
)} --verbose ${output.colors.gray('for more details.')}`, )}`,
]; ];
output.error({ output.error({
title: `Running target "${this.initiatingProject}:${this.args.target}" failed`, title: `Running target "${this.initiatingProject}:${this.args.target}" failed`,

View File

@ -219,11 +219,11 @@ class CLIOutput {
this.addNewline(); this.addNewline();
let commandOutput = `${chalk.dim('> nx run')} ${message}`; let commandOutput = `${chalk.dim('> nx run')} ${message}`;
if (taskStatus === 'local-cache') { if (taskStatus === 'local-cache') {
commandOutput += ` ${chalk.grey('[local cache]')}`; commandOutput += ` ${chalk.dim('[local cache]')}`;
} else if (taskStatus === 'remote-cache') { } else if (taskStatus === 'remote-cache') {
commandOutput += ` ${chalk.grey('[remote cache]')}`; commandOutput += ` ${chalk.dim('[remote cache]')}`;
} else if (taskStatus === 'local-cache-kept-existing') { } else if (taskStatus === 'local-cache-kept-existing') {
commandOutput += ` ${chalk.grey( commandOutput += ` ${chalk.dim(
'[existing outputs match the cache, left as is]' '[existing outputs match the cache, left as is]'
)}`; )}`;
} }