observablehq / framework

A static site generator for data apps, dashboards, reports, and more. Observable Framework combines JavaScript on the front-end for interactive graphics with any language on the back-end for data analysis.
https://observablehq.com/framework/
ISC License
2.56k stars 122 forks source link

adopt picocolors #1769

Closed mbostock closed 3 weeks ago

mbostock commented 1 month ago

Replaces our hand-rolled version with the popular picocolors, offering support for NO_COLOR and relying on picocolor’s own color support detection. As an alternative, we could also use yoctocolors which already uses hasColors… but I figured picocolors is nice because it’s already a dependency of clack.

Related #1764.

Fil commented 1 month ago

It works in local tests (with say, yarn docs:build | tee build.log), but doesn't work at all on cloud: my logs are full of color codes. https://observablehq.com/projects/@observablehq/pangea/deploys/e9b695e6f5001670

logs

When I look at the source code, the logic is defaulting to using colors when !!env.CI. In other words, it is expected that CI always supports ANSI colors. https://github.com/alexeyraspopov/picocolors/blob/7249f8c5d4825550f70bc1ea98652639933d3bbd/picocolors.js#L4

I think it's a fair assumption, and that we should merge this in nonetheless, when we're ready.

mbostock commented 3 weeks ago

That’s a pre-existing problem with Cloud logs, right? E.g., this oss-analytics deploy. This makes it worse, but seems like something that shouldn’t block this PR.

Screenshot 2024-10-25 at 7 42 08 PM
Fil commented 3 weeks ago

OK then!