Skip to content

Commit

Permalink
fix: deal with pre-releases in plugins siteDependency constraints (#5563
Browse files Browse the repository at this point in the history
)

* fix: deal with pre-releases in plugins siteDependency constraints

* chore: cleanup
  • Loading branch information
lukasholzer committed Mar 28, 2024
1 parent a2191ab commit 83fc040
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
31 changes: 31 additions & 0 deletions packages/build/src/plugins/compatibility.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,37 @@ test('`getExpectedVersion` should retrieve the plugin based on conditions and fe
expect(version3).toBe('5.0.0-beta.1')
})

test('`getExpectedVersion` should work with rc versions inside the siteDependencies constraints', async () => {
const versions: PluginVersion[] = [
{
version: '5.0.0-beta.1',
conditions: [
{ type: 'nodeVersion', condition: '>= 18.0.0' },
{ type: 'siteDependencies', condition: { next: '>=13.5.0' } },
],
overridePinnedVersion: '>=4.0.0',
},
{
version: '4.42.0',
conditions: [{ type: 'siteDependencies', condition: { next: '>=10.0.9' } }],
},
{ version: '4.41.2', conditions: [] },
{
version: '3.9.2',
conditions: [{ type: 'siteDependencies', condition: { next: '<10.0.9' } }],
},
]

const { version } = await getExpectedVersion({
versions,
nodeVersion: '18.19.0',
packageJson: { dependencies: { next: '14.1.1-canary.36' } },
buildDir: '/some/path',
pinnedVersion: '4',
})
expect(version).toBe('5.0.0-beta.1')
})

test('`getExpectedVersion` should retrieve the plugin based on conditions and feature flag due to pinned version', async () => {
const versions: PluginVersion[] = [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/build/src/plugins/plugin_conditions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const siteDependencyTest = async function ({

// if this is a valid version we can apply the rule directly
if (semver.clean(siteDependency) !== null) {
return semver.satisfies(siteDependency, allowedVersion)
return semver.satisfies(siteDependency, allowedVersion, { includePrerelease: true })
}

try {
Expand Down

0 comments on commit 83fc040

Please sign in to comment.