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

deprecation(semver): rename isSemVerComparator() #3957

Merged
merged 11 commits into from
Dec 18, 2023

Conversation

timreichen
Copy link
Contributor

@timreichen timreichen commented Dec 13, 2023

renames
SemVerComparator => Comparator
isSemVerComparator() => isComparator()
isSemVerRange() => isRange()
SemVerRange => Range
All old functions and interfaces are deprecated.

semver/is_semver_comparator_test.ts Outdated Show resolved Hide resolved
semver/is_semver_range.ts Outdated Show resolved Hide resolved
semver/is_semver_comparator.ts Outdated Show resolved Hide resolved
semver/types.ts Outdated Show resolved Hide resolved
@iuioiua iuioiua changed the title chore(semver): rename isSemVerRange and isSemVerComparator deprecation(semver): rename isSemVerRange() and isSemVerComparator() Dec 14, 2023
@timreichen
Copy link
Contributor Author

@iuioiua Before merging: There is also an opportunity to simplify Range and lose the single ranges property:

before

export interface Range {
  // The outer array is OR while each inner array is AND
  ranges: SemVerRangeOr;
}

after

// The outer array is OR while each inner array is AND
export type Range = Comparator[][];

WDYT?

Copy link
Contributor

@iuioiua iuioiua left a comment

Choose a reason for hiding this comment

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

Sorry, I missed a couple of nits.

semver/is_semver_comparator.ts Outdated Show resolved Hide resolved
semver/is_semver_range.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@iuioiua iuioiua left a comment

Choose a reason for hiding this comment

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

Sorry, I missed a couple of nits.

@timreichen
Copy link
Contributor Author

No problem.

@iuioiua Before merging: There is also an opportunity to simplify Range and lose the single ranges property:

before

export interface Range {
  // The outer array is OR while each inner array is AND
  ranges: SemVerRangeOr;
}

after

// The outer array is OR while each inner array is AND
export type Range = Comparator[][];

What is your opinion on this?

@timreichen
Copy link
Contributor Author

Actually, looking into Range a bit more, it seems that the current implementation is kinda strange.
It is defined like multiple segments on a line. Imo Range implies to be a single segment.

@iuioiua
Copy link
Contributor

iuioiua commented Dec 14, 2023

Yeah, it is strange. I see repeated use of range.ranges. It should probably be just ranges (without the ranges property).

@timreichen
Copy link
Contributor Author

How about we redefine Range to export type Range = Comparator[] and remove one OR layer. The OR layer is based on parseRange implementation which can parse range || range, but it should actually return Range[] instead of Range and be called parseRanges instead of parseRange.

@iuioiua
Copy link
Contributor

iuioiua commented Dec 15, 2023

The first solution sounds better. But maybe worth doing in another PR.

@timreichen
Copy link
Contributor Author

timreichen commented Dec 15, 2023

Yeah, it is strange. I see repeated use of range.ranges. It should probably be just ranges (without the ranges property).

The more I investigate about the Range implementation, the more am I convinced that the two renames

  • isSemVerRange() => isRange()
  • SemVerRange => Range

are misleading.

Their actual definition of SemVerRange is not a single Range but an array of Ranges.
Instead of renaming Ranges, we should implement Range and also adjust the API functions to accept Range instead of Ranges. Basically all range* functions (rangeFormat, rangeMin, rangeMax, rangeIntersects, minSatisfying, maxSatisfying, testRange, etc.) just loop over the Range array anyway. So instead I would suggest changing these to accept a single Range and get rid of all these loops.

Some of the function names for Range are now used for Ranges. As a solution, we could rename these to *Ranges and deprecate the *Range, then reuse the *Range name after the deprecation deadline is over.
For example:

  1. testRange(r:Ranges) =>testRanges(r:Ranges), deprecate testRange(r:Ranges)
  2. after deprecation deadline: redefine testRange(r:Range)

WDYT?

Please do not merge until this fundamental problem is solved.

@iuioiua
Copy link
Contributor

iuioiua commented Dec 15, 2023

Are you able to open a new issue focusing on this weird nested range design? There may be a reason (or there may not be) for this design decision.

Either way, let's proceed with this PR as it focuses on removing the SemVer portion of these symbol names.

@timreichen
Copy link
Contributor Author

timreichen commented Dec 15, 2023

@iuioiua I have opened an issue on this. This misnomer is also present in the npm semver. Even the bnf file in node-semver calls it range-set.

Would you be ok if I reduced this PR to

  • isSemVerComparator() => isComparator()
  • SemVerComparator => Comparator

so it can be merged?
Else we potentially would need to re-deprecate the Range later again and wait a cycle until we can fix the problem.

@iuioiua
Copy link
Contributor

iuioiua commented Dec 17, 2023

Yep, let's reduce the PR 👍🏾

@timreichen timreichen changed the title deprecation(semver): rename isSemVerRange() and isSemVerComparator() deprecation(semver): rename isSemVerComparator() Dec 17, 2023
@timreichen
Copy link
Contributor Author

Yep, let's reduce the PR 👍🏾

done

Copy link
Contributor

@iuioiua iuioiua left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks! Let's see what Yoshiya thinks.

Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

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

LGTM

@iuioiua iuioiua merged commit 4e75a00 into denoland:main Dec 18, 2023
12 checks passed
@timreichen timreichen deleted the rename-comparator-and-range branch December 18, 2023 18:14
@timreichen timreichen mentioned this pull request Jan 4, 2024
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants