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

feat: more sensible counter and version color #86

Merged
merged 2 commits into from
Nov 23, 2023

Conversation

a1mersnow
Copy link
Contributor

It's important to determine what major,minor,patch mean.

Case 1: If major refers to the change of x of x.y.z(this is what semver.diff use):

change type
0.3.4 -> 0.3.7 patch
0.3.4 -> 0.4.6 minor
0.0.3 -> 0.0.4 patch

Note: semver.diff has other types: premajor, preminor, prepatch, prerelease, e.g.:

image

Case 2: If major refers to "break the ^"(this is what changeVersionRange use):

change type
0.3.4 -> 0.3.7 patch
0.3.4 -> 0.4.6 major
0.0.3 -> 0.0.4 major

Note: ^ simply means allowing changes that do not modify the left-most non-zero version number.

Case 3: If major refers to "any change below 1.0.0"(this is what colorizeVersionDiff use):

change type
0.3.4 -> 0.3.7 major
0.3.4 -> 0.4.6 major
0.0.3 -> 0.0.4 major

colorizeVersionDiff:

export function colorizeVersionDiff(from: string, to: string, hightlightRange = true) {
  // ...
  // major = red (or any change before 1.0.0)
  // minor = cyan
  // patch = green
  const color = (i === 0 || partsToColor[0] === '0')
    ? 'red'
    : i === 1
      ? 'cyan'
      : 'green'
  // ...

Which one is more sensible?

Solution

From the aspect of user, when I run taze major, I'm saying I can accept breaking change,
when I run taze minor, I'm saying I cannot accept breaking change but I want more features, when I run taze patch, I'm saying I want only fixes.

The first one I want to eliminate is Case 1. At first, it's not a thing users care much. Secondly, the design of npm-semver's ReleaseType has many pitfalls, as to cause many issues about it.

Case 3 is a safer one. It's always good to use a safer one but it's a little bit conservative. And, I don't think it's a good idea to change the meanings of today's mode, but it's ok to change only the UI part.

So, this pr picks the Case 2.

@a1mersnow a1mersnow marked this pull request as ready for review November 23, 2023 02:44
@antfu
Copy link
Member

antfu commented Nov 23, 2023

Making sense, thanks for the PR and detailed explaintation!

@antfu antfu merged commit 483ac6f into antfu-collective:main Nov 23, 2023
5 checks passed
@a1mersnow a1mersnow deleted the what-is-major-minor-patch branch November 24, 2023 06:34
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.

2 participants