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 Jul 7, 2024
1 parent 4402927 commit 4ca6b54
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/lib/upgradePackageDefinitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,24 @@ const checkIfInPeerViolation = (
upgradedPeerDependencies: Index<Index<VersionSpec>>,
): CheckIfInPeerViolationResult => {
const upgradedDependencies = { ...currentDependencies, ...filteredUpgradedDependencies }
const violatedDependencies = new Set<string>()
const filteredUpgradedDependenciesAfterPeers = pickBy(filteredUpgradedDependencies, (spec, dep) => {
const peerDeps = upgradedPeerDependencies[dep]
if (!peerDeps) {
return true
}
const valid = Object.entries(peerDeps).every(
return Object.entries(peerDeps).every(
([peer, peerSpec]) =>
upgradedDependencies[peer] === undefined || intersects(upgradedDependencies[peer], peerSpec),
)
if (!valid) {
violatedDependencies.add(dep)
}
return valid
})
const violated = violatedDependencies.size > 0
const violated =
Object.keys(filteredUpgradedDependencies).length > Object.keys(filteredUpgradedDependenciesAfterPeers).length
let filteredUpgradedPeerDependencies = upgradedPeerDependencies
if (violated) {
filteredUpgradedPeerDependencies = pickBy(upgradedPeerDependencies, (spec, dep) => !violatedDependencies.has(dep))
filteredUpgradedPeerDependencies = pickBy(
upgradedPeerDependencies,
(spec, dep) => filteredUpgradedDependenciesAfterPeers[dep] || !filteredUpgradedDependencies[dep],
)
}
return {
violated,
Expand Down

0 comments on commit 4ca6b54

Please sign in to comment.