[turborepo] Logging colors are non-deterministic
What version of Turborepo are you using?
1.6.3
What package manager are you using / does the bug impact?
Yarn v1
What operating system are you using?
Mac
Describe the Bug
CLI colors are changing between runs for the same package. It sure looks pretty for VC demos, but is very confusing, as a user expects the package name to have the same color between consecutive runs.
Expected Behavior
Colors of a package name in the CLI must remain the same no matter when or where you run the CLI
To Reproduce
Run a turbo repo command twice, the colours will randomly change.
Reproduction Repo
No response
I believe this is not deterministic because the order of tasks running is also not deterministic (by design). We could base the color on the task name itself to make it deterministic, but I'm not sure how we'd support an unbounded number of colors (I'm sure it's possible, just not sure off the top of my head what's available)
The code is here:
https://github.com/vercel/turbo/blob/261d22177f6c7301f9c5e93518112b025b15d7aa/cli/internal/colorcache/colorcache.go#L33-L45
wouldn't have to be unbound could just hash to an integer and modulus to the number of colors to least stay consistent. just a thought (i noticed this even for a single task)
I just had a build fail and was left typing invisible characters into the shell prompt. My background was black, so maybe the characters were also black.
What's even more undesirable is even the replayed output from a >>> FULL TURBO cached run does not yield a deterministic color 😢.
I'd imagine with the port to rust it would be a good idea to make the color be derived from the package/task name.
cc @anthonyshew since were talking about this the other day.