Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(core): improve output color consistency across terminal themes (#…
  • Loading branch information
JamesHenry committed Feb 28, 2022
1 parent cef4bbd commit 471f7be
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
Expand Up @@ -13,6 +13,9 @@ import { prettyTime } from './pretty-time';
* are added. It is therefore intended for use on a user's local machines.
*
* In CI environments the static equivalent of this life cycle should be used.
*
* NOTE: output.dim() should be preferred over output.colors.gray() because it
* is much more consistently readable across different terminal color themes.
*/
export async function createRunManyDynamicOutputRenderer({
projectNames,
Expand Down Expand Up @@ -114,7 +117,7 @@ export async function createRunManyDynamicOutputRenderer({
output.colors.green(figures.tick) +
output.dim(' nx run ') +
task.id
} ${output.colors.gray('[local cache]')}`
} ${output.dim('[local cache]')}`
);
if (isVerbose) {
writeCommandOutputBlock(tasksToTerminalOutputs[task.id]);
Expand All @@ -126,9 +129,7 @@ export async function createRunManyDynamicOutputRenderer({
output.colors.green(figures.tick) +
output.dim(' nx run ') +
task.id
} ${output.colors.gray(
'[existing outputs match the cache, left as is]'
)}`
} ${output.dim('[existing outputs match the cache, left as is]')}`
);
if (isVerbose) {
writeCommandOutputBlock(tasksToTerminalOutputs[task.id]);
Expand All @@ -140,7 +141,7 @@ export async function createRunManyDynamicOutputRenderer({
output.colors.green(figures.tick) +
output.dim(' nx run ') +
task.id
} ${output.colors.gray('[remote cache]')}`
} ${output.dim('[remote cache]')}`
);
if (isVerbose) {
writeCommandOutputBlock(tasksToTerminalOutputs[task.id]);
Expand All @@ -154,7 +155,7 @@ export async function createRunManyDynamicOutputRenderer({
output.colors.green(figures.tick) +
output.dim(' nx run ') +
task.id +
output.dim.gray(` (${timeTakenText})`)
output.dim(` (${timeTakenText})`)
);
if (isVerbose) {
writeCommandOutputBlock(tasksToTerminalOutputs[task.id]);
Expand Down Expand Up @@ -241,7 +242,7 @@ export async function createRunManyDynamicOutputRenderer({
additionalFooterRows.push(
` ${output.colors.green(
figures.tick
)} ${totalSuccessfulTasks}${`/${totalCompletedTasks}`} succeeded ${output.colors.gray(
)} ${totalSuccessfulTasks}${`/${totalCompletedTasks}`} succeeded ${output.dim(
`[${totalCachedTasks} read from cache]`
)}`
);
Expand Down Expand Up @@ -344,7 +345,7 @@ export async function createRunManyDynamicOutputRenderer({
];
if (totalCachedTasks > 0) {
pinnedFooterLines.push(
output.colors.gray(
output.dim(
`${EOL} Nx read the output from the cache instead of running the command for ${totalCachedTasks} out of ${totalTasks} tasks.`
)
);
Expand Down Expand Up @@ -385,9 +386,9 @@ export async function createRunManyDynamicOutputRenderer({
` ${output.colors.red(
figures.cross
)} ${totalFailedTasks}${`/${totalCompletedTasks}`} failed`,
` ${output.colors.gray(
` ${output.dim(
figures.tick
)} ${totalSuccessfulTasks}${`/${totalCompletedTasks}`} succeeded ${output.colors.gray(
)} ${totalSuccessfulTasks}${`/${totalCompletedTasks}`} succeeded ${output.dim(
`[${totalCachedTasks} read from cache]`
)}`,
],
Expand Down
Expand Up @@ -25,6 +25,9 @@ type State =
* are added. It is therefore intended for use on a user's local machines.
*
* In CI environments the static equivalent of this life cycle should be used.
*
* NOTE: output.dim() should be preferred over output.colors.gray() because it
* is much more consistently readable across different terminal color themes.
*/
export async function createRunOneDynamicOutputRenderer({
initiatingProject,
Expand Down Expand Up @@ -154,10 +157,10 @@ export async function createRunOneDynamicOutputRenderer({

if (totalSuccessfulTasks > 0) {
linesToRender.push(
output.colors.gray(
` ${output.colors.gray(
output.dim(
` ${output.dim(
figures.tick
)} ${totalSuccessfulTasks}${`/${totalCompletedTasks}`} dependent project tasks succeeded ${output.colors.gray.dim(
)} ${totalSuccessfulTasks}${`/${totalCompletedTasks}`} dependent project tasks succeeded ${output.dim(
`[${totalCachedTasks} read from cache]`
)}`
)
Expand Down Expand Up @@ -195,9 +198,9 @@ export async function createRunOneDynamicOutputRenderer({
if (totalDependentTasksNotFromInitiatingProject > 0) {
output.addNewline();
process.stdout.write(
` ${output.colors.gray(
` ${output.dim(
'Hint: you can run the command with'
)} --verbose ${output.colors.gray(
)} --verbose ${output.dim(
'to see the full dependent project outputs'
)}` + EOL
);
Expand Down Expand Up @@ -299,7 +302,7 @@ export async function createRunOneDynamicOutputRenderer({
];
if (totalCachedTasks > 0) {
pinnedFooterLines.push(
output.colors.gray(
output.dim(
`${EOL} Nx read the output from the cache instead of running the command for ${totalCachedTasks} out of ${totalTasks} tasks.`
)
);
Expand Down Expand Up @@ -342,9 +345,9 @@ export async function createRunOneDynamicOutputRenderer({
` ${output.colors.red(
figures.cross
)} ${totalFailedTasks}${`/${totalCompletedTasks}`} failed`,
` ${output.colors.gray(
` ${output.dim(
figures.tick
)} ${totalSuccessfulTasks}${`/${totalCompletedTasks}`} succeeded ${output.colors.gray(
)} ${totalSuccessfulTasks}${`/${totalCompletedTasks}`} succeeded ${output.dim(
`[${totalCachedTasks} read from cache]`
)}`,
],
Expand Down

0 comments on commit 471f7be

Please sign in to comment.