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

fix: Update semver logic #4459

Merged
merged 1 commit into from
Aug 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions packages/build/src/plugins/compatibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const getExpectedVersion = async function ({ versions, nodeVersion, packa
// - After their first successful run, plugins are pinned by their major
// version which is passed as `pinnedVersion` to the next builds.
// When the plugin does not have a `pinnedVersion`, we use the most recent
// `compatibility` entry whith a successful condition.
// `compatibility` entry with a successful condition.
// When the plugin has a `pinnedVersion`, we do not use the `compatibility`
// conditions. Instead, we just use the most recent entry with a `version`
// matching `pinnedVersion`.
Expand All @@ -42,7 +42,12 @@ export const getExpectedVersion = async function ({ versions, nodeVersion, packa
// - Otherwise, use `latestVersion`
const getCompatibleEntry = async function ({ versions, nodeVersion, packageJson, buildDir, pinnedVersion }) {
if (pinnedVersion !== undefined) {
return versions.find(({ version }) => semver.satisfies(version, pinnedVersion)) || { version: pinnedVersion }
// invalid semver versions are coerced to valid ones (e.g 4.17.1-runtime.7 -> 4.17.1)
return (
versions.find(({ version }) => semver.satisfies(semver.coerce(version), pinnedVersion)) || {
Copy link
Contributor

@ascorbic ascorbic Aug 20, 2022

Choose a reason for hiding this comment

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

Suggested change
versions.find(({ version }) => semver.satisfies(semver.coerce(version), pinnedVersion)) || {
versions.find(({ version }) => semver.satisfies(version, pinnedVersion, { includePrerelease: true })) || {

This should work

version: pinnedVersion,
}
)
}

const versionsWithConditions = versions.filter(hasConditions)
Expand Down