-
Notifications
You must be signed in to change notification settings - Fork 177
fix #648 #709
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
Merged
Merged
fix #648 #709
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
310d2cd
fix #648
conico974 1f5c532
changeset
conico974 acafafb
fix incomplete version
conico974 d6cb381
fix issue, add comment and throw on incorrect params
conico974 8be865c
Update packages/open-next/src/build/helper.ts
conico974 8e31e84
review
conico974 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 hidden or 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,5 @@ | ||
| --- | ||
| "@opennextjs/aws": patch | ||
| --- | ||
|
|
||
| use correct version for applying stableIncrementalCache (It failed for next 14.0.4) | ||
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -275,6 +275,15 @@ export function getNextVersion(appPath: string): string { | |
| return version.split("-")[0]; | ||
| } | ||
|
|
||
| /** | ||
| * Compare two semver versions. | ||
conico974 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * @param v1 - First version. Can be "latest", otherwise it should be a valid semver version in the format of `major.minor.patch`. Usually is the next version from the package.json without canary suffix. If minor or patch are missing, they are considered 0. | ||
| * @param v2 - Second version. Should not be "latest", it should be a valid semver version in the format of `major.minor.patch`. If minor or patch are missing, they are considered 0. | ||
| * @see | ||
|
||
| * - | ||
| * @example | ||
| * compareSemver("1.0.0", "1.0.0") // 0 | ||
| */ | ||
| export function compareSemver(v1: string, v2: string): number { | ||
| if (v1 === "latest") return 1; | ||
| if (/^[^\d]/.test(v1)) { | ||
|
|
@@ -285,8 +294,11 @@ export function compareSemver(v1: string, v2: string): number { | |
| // biome-ignore lint/style/noParameterAssign: | ||
| v2 = v2.substring(1); | ||
| } | ||
| const [major1, minor1, patch1] = v1.split(".").map(Number); | ||
| const [major2, minor2, patch2] = v2.split(".").map(Number); | ||
| const [major1, minor1 = 0, patch1 = 0] = v1.split(".").map(Number); | ||
| const [major2, minor2 = 0, patch2 = 0] = v2.split(".").map(Number); | ||
| if (Number.isNaN(major1) || Number.isNaN(major2)) { | ||
| throw new Error("The major version is required."); | ||
| } | ||
|
|
||
| if (major1 !== major2) return major1 - major2; | ||
| if (minor1 !== minor2) return minor1 - minor2; | ||
|
|
||
This file contains hidden or 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,34 @@ | ||
| import { compareSemver } from "@opennextjs/aws/build/helper.js"; | ||
|
|
||
| // We don't need to test canary versions, they are stripped out | ||
| describe("compareSemver", () => { | ||
| it("should return 0 when versions are equal", () => { | ||
| expect(compareSemver("1.0.0", "1.0.0")).toBe(0); | ||
| }); | ||
|
|
||
| it("should return 1 when first version is greater", () => { | ||
| expect(compareSemver("1.0.1", "1.0.0")).toBe(1); | ||
| }); | ||
|
|
||
| it("should return -1 when first version is smaller", () => { | ||
| expect(compareSemver("1.0.0", "1.0.1")).toBe(-1); | ||
| }); | ||
|
|
||
| it("should work with latest", () => { | ||
| expect(compareSemver("latest", "1.0.0")).toBe(1); | ||
| }); | ||
|
|
||
| it("should work with incomplete version for patch", () => { | ||
| expect(compareSemver("14.1.0", "14.1")).toBe(0); | ||
| expect(compareSemver("14.1", "14.1.0")).toBe(0); | ||
| }); | ||
|
|
||
| it("should work with incomplete version for minor", () => { | ||
| expect(compareSemver("14.0.0", "14")).toBe(0); | ||
| }); | ||
|
|
||
| it("should throw if the major version is missing", () => { | ||
| expect(() => compareSemver("incorrect", "14.0.0")).toThrow(); | ||
| expect(() => compareSemver("14.0.0", "latest")).toThrow(); | ||
| }); | ||
| }); |
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.
Uh oh!
There was an error while loading. Please reload this page.