Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Replace colors with chalk to fix infinite loop. #250

Closed
wants to merge 1 commit into from

Conversation

jwalton
Copy link

@jwalton jwalton commented Jan 8, 2022

This replaces the colors library with chalk after the author of colors added an infinite loop to colors/lib/index.js as a protest.

The transition is pretty straightforward, although I had to skip a couple of tests where the ANSI gneerated by chalk was subtly different than the ANSI generated by the old cli-table library, or where the home-grown "truncate" function produced different output than chalk generated natively.

@Trott
Copy link

Trott commented Jan 9, 2022

@jwalton If you're in the zone on this kind of thing, you might want to open a similar pull request to https://github.com/Automattic/cli-table, which also uses colors and which this package has as a dependency.

@jwalton
Copy link
Author

jwalton commented Jan 9, 2022

@Trott cli-table is actually OK, because they have pegged colors to 1.0.3. cli-table3 is vulnerable because they use ^ in the version number, so you’ll automatically get the new version.

@Trott
Copy link

Trott commented Jan 9, 2022

@Trott cli-table is actually OK, because they have pegged colors to 1.0.3. cli-table3 is vulnerable because they use ^ in the version number, so you’ll automatically get the new version.

While that's true, it's probably good to just get colors out of dependencies in widely-used packages in general. (But it's also not your obligation to do that or anything, of course.) The less use it has, the fewer downloads, the less likely people are to pick it for new projects.

@jwalton
Copy link
Author

jwalton commented Jan 9, 2022

The other part of it is that cli-table3 exists because cli-table2 wasn't being maintained, and cli-table2 exists because cli-table wasn't being maintained. So I was a bit worried a PR wouldn't get looked at in cli-table (although it's last release is a month ago, and this project's last release was two years ago, so maybe I have that backwards.) Also also, cli-table is only a dev-dependency of this project, and only for backward compatibility testing. But, I'll go do a PR for cli-table, and see how it goes. :)

@DanielRuf
Copy link
Contributor

DanielRuf commented Jan 9, 2022

Copy link
Contributor

@JJ JJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better than #251

@DanielRuf
Copy link
Contributor

The transition is pretty straightforward, although I had to skip a couple of tests where the ANSI gneerated by chalk was subtly different than the ANSI generated by the old cli-table library, or where the home-grown "truncate" function produced different output than chalk generated natively.

Imho this is mostly a breaking change. Especially if some other library parses the output.

Much better than #251

I don't fully agree but the current maintainers can decide.

Personally I'm a bigger fan of smaller changes to resolve issues (less conflicts and issues with other projects, less breaking changes).

@jwalton
Copy link
Author

jwalton commented Jan 9, 2022

Imho this is mostly a breaking change. Especially if some other library parses the output.

Just to clarify my comment; ANSI has escape sequences for setting the foreground color and the backgrond color. The tests I marked as "skip" were cases where instead of "reset foreground;reset background", we were now emitting "reset background;reset foreground". Any ANSI parser will treat these identically. Anyone who is parsing the output without a "real" ANSI parser will probably strip all the colors anyways.

I wouldn't consider it a breaking change. We are changing the output slightly, but any bug fix to any project changes something about its behavior.

@jwalton
Copy link
Author

jwalton commented Jan 9, 2022

If we wanted to be execessively cautious we could pin the version and release a 0.6.1, and then merge this and release a 0.7.0, so we get the best of both worlds.

@DanielRuf
Copy link
Contributor

DanielRuf commented Jan 9, 2022

If we wanted to be execessively cautious we could pin the version and release a 0.6.1

Already done, see #251 (comment)

@jwalton
Copy link
Author

jwalton commented Jan 9, 2022

@Trott I raised Automattic/cli-table#166 for the original cli-table.

askvortsov1 added a commit to askvortsov1/typescript-coverage-report that referenced this pull request Jan 9, 2022
It is better maintained, and has already pinned the `colors` library to v1.4.0. It also seems that they will move away from colors in the near future: cli-table/cli-table3#250.
@DABH
Copy link
Contributor

DABH commented Feb 19, 2022

Please see #263 -- we can use the same colors interface and not be relying on a potentially compromised dependency. Hopefully this solution is the best of both worlds :)

@speedytwenty
Copy link
Collaborator

speedytwenty commented Mar 24, 2022

Thanks for your efforts on this, @jwalton! It looks like #263 supersedes this PR so closing this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants