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): deprecate SemVerRange, introduce Range #4161

Merged
merged 16 commits into from
Jan 14, 2024

Conversation

timreichen
Copy link
Contributor

This PR does a bunch of things. While some things could theoretically be split up into separate PRs (ref: #4059), some stand-alone PRs might look redundant.

  • deprecates SemVerRange type in favour of Range.
  • deprecates isSemVerRange() in favour of isRange()
  • makes Comparator.semver property optional in favour of Comparator extending SemVer that allows a simpler and less nested Range type.
    Note: Comparator might become be deprecated (ref: deprecation(semver): deprecate Comparator.semver property #4059 (comment)), but because SemVerRange is dependent on its structure, it needs to be changed in order to avoid breaking changes.

@timreichen timreichen requested a review from kt3k as a code owner January 10, 2024 20:34
@timreichen timreichen mentioned this pull request Jan 10, 2024
13 tasks
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, Tim. Can you please resolve the merge conflicts? I also noticed that the removal version for some added deprecation notices is 0.213.0 and others 0.214.0. Can you please only have one version so removals can happen all at the same time?

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.

I mostly agree with this PR. The only part I'm slightly uncertain about is having Comparator extend SemVer. Either way. I left a few suggestions.

Also, I notice we still use some deprecated functions within other functions. We should look into switching to the updated functions in those cases. Probably best done after this PR, separately.

semver/is_range.ts Outdated Show resolved Hide resolved
@@ -12,5 +12,5 @@ import { format } from "./format.ts";
*/
export function comparatorFormat(comparator: Comparator): string {
const { semver, operator } = comparator;
return `${operator}${format(semver)}`;
return `${operator}${format(semver ?? comparator)}`;
Copy link
Contributor

@iuioiua iuioiua Jan 11, 2024

Choose a reason for hiding this comment

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

Nice. Can we please have tests for added functionality? We want to ensure that both SemVer and Comparator inputs work fine on all these functions, including those in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How do you mean exactly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added some test cases. PTAL.

@@ -47,5 +47,5 @@ export function parseComparator(comparator: string): Comparator {
}
: ANY;

return { operator, semver };
return { operator, ...semver, semver };
Copy link
Contributor

Choose a reason for hiding this comment

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

I forsee the output of this object being confusing to users during the deprecation period. But I don't see another viable way of doing this. Food for thought...

@timreichen
Copy link
Contributor Author

timreichen commented Jan 11, 2024

I mostly agree with this PR. The only part I'm slightly uncertain about is having Comparator extend SemVer. Either way. I left a few suggestions.

i don't see a better way to remove the semver in Comparator prop without breaking changes. But I am open for suggestions.

Also, I notice we still use some deprecated functions within other functions. We should look into switching to the updated functions in those cases. Probably best done after this PR, separately.

I'll have a look at that after this PR. I think we might be best of putting all comparator code into one _comparator.ts.

timreichen and others added 2 commits January 11, 2024 10:09
Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
@timreichen
Copy link
Contributor Author

Sorry, Tim. Can you please resolve the merge conflicts? I also noticed that the removal version for some added deprecation notices is 0.213.0 and others 0.214.0. Can you please only have one version so removals can happen all at the same time?

Done

@kt3k
Copy link
Member

kt3k commented Jan 12, 2024

This looks like an immediate breaking change to me. parseRange(">=1.2.3 <2.0.0") now returns:

[
  [
    {
      operator: ">=",
      major: 1,
      minor: 2,
      patch: 3,
      prerelease: [],
      build: [],
      semver: { major: 1, minor: 2, patch: 3, prerelease: [], build: [] }
    },
    {
      operator: "<",
      major: 2,
      minor: 0,
      patch: 0,
      prerelease: [],
      build: [],
      semver: { major: 2, minor: 0, patch: 0, prerelease: [], build: [] }
    }
  ]
]

instead of:

{
  ranges: [
    [
      {
        operator: ">=",
        semver: { major: 1, minor: 2, patch: 3, prerelease: [], build: [] }
      },
      {
        operator: "<",
        semver: { major: 2, minor: 0, patch: 0, prerelease: [], build: [] }
      }
    ]
  ]
}

It's typed like both are supported, but actually only Range is supported.

@kt3k
Copy link
Member

kt3k commented Jan 12, 2024

I feel this kind of thing can't be done in a non-breaking way.

@timreichen
Copy link
Contributor Author

timreichen commented Jan 12, 2024

This looks like an immediate breaking change to me. parseRange(">=1.2.3 <2.0.0") now returns:

[
  [
    {
      operator: ">=",
      major: 1,
      minor: 2,
      patch: 3,
      prerelease: [],
      build: [],
      semver: { major: 1, minor: 2, patch: 3, prerelease: [], build: [] }
    },
    {
      operator: "<",
      major: 2,
      minor: 0,
      patch: 0,
      prerelease: [],
      build: [],
      semver: { major: 2, minor: 0, patch: 0, prerelease: [], build: [] }
    }
  ]
]

instead of:

{
  ranges: [
    [
      {
        operator: ">=",
        semver: { major: 1, minor: 2, patch: 3, prerelease: [], build: [] }
      },
      {
        operator: "<",
        semver: { major: 2, minor: 0, patch: 0, prerelease: [], build: [] }
      }
    ]
  ]
}

It's typed like both are supported, but actually only Range is supported.

parseRange() actually returns with the ranges property. it is not enummerated, but if you do console.log((ranges as SemVerRange).range); it is set properly. If you like we can make it enumerable: Object.defineProperty(ranges, "ranges", { enumerable: true, value: ranges }) so also shows in the log.

@kt3k
Copy link
Member

kt3k commented Jan 14, 2024

Ah, ok. Sorry I missed Object.defineProperty part in parseRange..

semver/types.ts Outdated Show resolved Hide resolved
semver/types.ts Outdated Show resolved Hide resolved
semver/is_semver_range.ts Outdated Show resolved Hide resolved
timreichen and others added 3 commits January 14, 2024 12:32
Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
@kt3k kt3k changed the title deprecation(semver): rename SemVerRange to Range deprecation(semver): deprecate SemVerRange, introduce Range Jan 14, 2024
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

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! Nice work, Tim! Thank you.

@iuioiua iuioiua enabled auto-merge (squash) January 14, 2024 21:17
@iuioiua iuioiua merged commit aa3f026 into denoland:main Jan 14, 2024
12 checks passed
@timreichen timreichen deleted the semver_deprecate_semver_range branch January 14, 2024 21:46
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