Skip to content

Commit

Permalink
fix: Is there a way to not upgrade a package if it's peer depndencies…
Browse files Browse the repository at this point in the history
… are not currently met #1418
  • Loading branch information
rbnayax committed Jun 15, 2024
1 parent 108ad17 commit 2617700
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/lib/upgradePackageDefinitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ const checkIfInPeerViolation = (
): CheckIfInPeerViolationResult => {
const upgradedDependencies = { ...currentDependencies, ...filteredUpgradedDependencies }
const upgradedDependenciesVersions = Object.fromEntries(
Object.entries(upgradedDependencies).map(([packageName, versionSpec]) => {
return [packageName, minVersion(versionSpec)?.version ?? versionSpec]
}),
Object.entries(upgradedDependencies).map(([packageName, versionSpec]) => [
packageName,
minVersion(versionSpec)?.version ?? versionSpec,
]),
)
const filteredUpgradedPeerDependencies = { ...upgradedPeerDependencies }
let violated = false
const violatedDependencies = new Set<string>()
const filteredUpgradedDependenciesAfterPeers = pickBy(filteredUpgradedDependencies, (spec, dep) => {
const peerDeps = filteredUpgradedPeerDependencies[dep]
const peerDeps = upgradedPeerDependencies[dep]
if (!peerDeps) {
return true
}
Expand All @@ -46,11 +46,15 @@ const checkIfInPeerViolation = (
upgradedDependenciesVersions[peer] === undefined || satisfies(upgradedDependenciesVersions[peer], peerSpec),
)
if (!valid) {
violated = true
delete filteredUpgradedPeerDependencies[dep]
violatedDependencies.add(dep)
}
return valid
})
const violated = violatedDependencies.size > 0
let filteredUpgradedPeerDependencies = upgradedPeerDependencies
if (violated) {
filteredUpgradedPeerDependencies = pickBy(upgradedPeerDependencies, (spec, dep) => !violatedDependencies.has(dep))
}
return {
violated,
filteredUpgradedDependencies: filteredUpgradedDependenciesAfterPeers,
Expand Down

0 comments on commit 2617700

Please sign in to comment.