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

Migrate to colorette 2.0.x #2956

Closed
wants to merge 1 commit into from
Closed

Migrate to colorette 2.0.x #2956

wants to merge 1 commit into from

Conversation

kibertoad
Copy link

fixes #2955

Update colorette to a new semver major version.

Did you add tests for your changes?

Not relevant.

If relevant, did you update the documentation?

Not relevant.

Summary

This ensures webpack-cli is staying on up-to-date dependency version, and also removes reliance on global state, which is never a good idea.

Does this PR introduce a breaking change?

It shouldn't, although there was a change in colorette behavior: it no longer generates colouring for empty strings, which is unlikely to be an issue for majority of users.

@kibertoad kibertoad requested a review from a team as a code owner September 18, 2021 20:33
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Sep 18, 2021

CLA Signed

The committers are authorized under a signed CLA.

@@ -1,6 +1,22 @@
let colorette = null;
Copy link
Member

Choose a reason for hiding this comment

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

Why we need this?

Copy link
Author

Choose a reason for hiding this comment

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

To avoid recreating colorette instance on every getter call. We could simply import default colouring operations, but these would default to always on and ignore configuration overrides.

Choose a reason for hiding this comment

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

We decided to classify the always-color behavior as a bug after all (jorgebucaran/colorette#72). If you don't really care about the new createColors API, you may continue using Colorette as you were before, just upgrade to 2.0.5 or later.

const col = require('colorette');
const options = {
changed: false,
enabled: colorette? colorette.options.enabled : true,
Copy link
Member

Choose a reason for hiding this comment

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

It seems some weird, colorette already has logic for enabled, why we need check colorette?

Copy link
Author

Choose a reason for hiding this comment

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

See existing code at

cli.utils.colors.options.changed = true;

From my understanding this is an existing solution to trigger changes in the behaviour of instance, returned by getter. Alternatively, we can expose a method that would instantly recreate instance, stored here, to avoid this.

Copy link
Member

Choose a reason for hiding this comment

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

We should rewrite logic, because we already cache module, we can keep changed on object level

Copy link
Author

Choose a reason for hiding this comment

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

caching module is not enough, we need to store initialized coloretto instance as well

@codecov
Copy link

codecov bot commented Sep 20, 2021

Codecov Report

Merging #2956 (3813e7a) into master (2e8d5c8) will not change coverage.
The diff coverage is n/a.

❗ Current head 3813e7a differs from pull request most recent head 0fd161f. Consider uploading reports for the commit 0fd161f to get more accurate results
Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2956   +/-   ##
=======================================
  Coverage   95.13%   95.13%           
=======================================
  Files          31       31           
  Lines        1684     1684           
  Branches      483      483           
=======================================
  Hits         1602     1602           
  Misses         82       82           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2e8d5c8...0fd161f. Read the comment docs.

@@ -1,6 +1,22 @@
let colorette = null;

Choose a reason for hiding this comment

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

We decided to classify the always-color behavior as a bug after all (jorgebucaran/colorette#72). If you don't really care about the new createColors API, you may continue using Colorette as you were before, just upgrade to 2.0.5 or later.

@jorgebucaran
Copy link

2.x is largely compatible with 1.x as is. createColors is probably not needed here. There was an issue, but we fixed it a few days ago (jorgebucaran/colorette#72).

cc @alexander-akait @kibertoad 👋

@kibertoad
Copy link
Author

superseded by #2966

@kibertoad kibertoad closed this Sep 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate to new API in Colorette 2.0.x
4 participants