-
Notifications
You must be signed in to change notification settings - Fork 629
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
iuioiua
merged 16 commits into
denoland:main
from
timreichen:semver_deprecate_semver_range
Jan 14, 2024
Merged
Changes from 11 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
430ec37
initial commit
timreichen e220275
Merge branch 'main' into semver_deprecate_semver_range
timreichen 0fc17d9
Merge branch 'main' into semver_deprecate_semver_range
timreichen da6723a
Merge branch 'main' into semver_deprecate_semver_range
timreichen 5f96a4a
Merge branch 'main' into semver_deprecate_semver_range
timreichen 1b1d22f
Update semver/is_range.ts
timreichen d719fd3
bump deprecation notice
timreichen 86a9976
Merge branch 'main' into semver_deprecate_semver_range
timreichen 94e5fa5
Merge branch 'main' into semver_deprecate_semver_range
timreichen 3a0aa6d
add test cases
timreichen e1878f0
fmt
timreichen f118a57
Update types.ts
timreichen 6e0331f
Update types.ts
timreichen 3121795
Update is_semver_range.ts
timreichen 33256b2
Merge branch 'main' into semver_deprecate_semver_range
timreichen 5d6d7b6
Merge branch 'main' into semver_deprecate_semver_range
timreichen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. | ||
import type { SemVer, SemVerRange } from "./types.ts"; | ||
import type { Range, SemVer, SemVerRange } from "./types.ts"; | ||
import { rangeMax } from "./range_max.ts"; | ||
import { gt } from "./gt.ts"; | ||
|
||
/** Checks to see if the version is greater than all possible versions of the range. */ | ||
export function gtr( | ||
version: SemVer, | ||
range: SemVerRange, | ||
range: SemVerRange | Range, | ||
): boolean { | ||
return gt(version, rangeMax(range)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. | ||
import type { Range } from "./types.ts"; | ||
import { isComparator } from "./is_comparator.ts"; | ||
|
||
/** | ||
* Does a deep check on the object to determine if its a valid range. | ||
* | ||
* Objects with extra fields are still considered valid if they have at | ||
* least the correct fields. | ||
* | ||
* Adds a type assertion if true. | ||
* @param value The value to check if its a valid Range | ||
* @returns True if its a valid Range otherwise false. | ||
*/ | ||
export function isRange(value: unknown): value is Range { | ||
return Array.isArray(value) && | ||
value.every((r) => Array.isArray(r) && r.every((c) => isComparator(c))); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. | ||
import { assert } from "../assert/mod.ts"; | ||
import { ALL } from "./constants.ts"; | ||
import { isRange } from "./is_range.ts"; | ||
|
||
Deno.test({ | ||
name: "isRange()", | ||
fn: async (t) => { | ||
let i = 0; | ||
const ranges: unknown[] = [[ | ||
[ALL], | ||
]]; | ||
for (const r of ranges) { | ||
await t.step(`${(i++).toString().padStart(2, "0")}`, () => { | ||
const actual = isRange(r); | ||
assert(actual); | ||
}); | ||
} | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. | ||
import type { SemVer, SemVerRange } from "./types.ts"; | ||
import type { Range, SemVer, SemVerRange } from "./types.ts"; | ||
import { lt } from "./lt.ts"; | ||
import { rangeMin } from "./range_min.ts"; | ||
|
||
/** Less than range comparison */ | ||
export function ltr( | ||
version: SemVer, | ||
range: SemVerRange, | ||
range: SemVerRange | Range, | ||
): boolean { | ||
return lt(version, rangeMin(range)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,5 +47,5 @@ export function parseComparator(comparator: string): Comparator { | |
} | ||
: ANY; | ||
|
||
return { operator, semver }; | ||
return { operator, ...semver, semver }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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... |
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
andComparator
inputs work fine on all these functions, including those in this PR.There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.