From bc6d1e4a1f3b9355a5a56c721b8f317a31e99410 Mon Sep 17 00:00:00 2001 From: rbnayax <92677232+rbnayax@users.noreply.github.com> Date: Sun, 27 Oct 2024 19:37:48 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20yarn=20getPeerDependencies=20doesnt=20wo?= =?UTF-8?q?rk=20on=20private=20reporsitories=20wh=E2=80=A6=20(#1472)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/getIgnoredUpgradesDueToPeerDeps.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/lib/getIgnoredUpgradesDueToPeerDeps.ts b/src/lib/getIgnoredUpgradesDueToPeerDeps.ts index d77fa954..6bfa8ecc 100644 --- a/src/lib/getIgnoredUpgradesDueToPeerDeps.ts +++ b/src/lib/getIgnoredUpgradesDueToPeerDeps.ts @@ -1,4 +1,4 @@ -import { intersects, satisfies } from 'semver' +import { intersects, minVersion, satisfies, validRange } from 'semver' import { IgnoredUpgradeDueToPeerDeps } from '../types/IgnoredUpgradeDueToPeerDeps' import { Index } from '../types/IndexType' import { Options } from '../types/Options' @@ -24,7 +24,19 @@ export async function getIgnoredUpgradesDueToPeerDeps( peerDependencies: undefined, loglevel: 'silent', }) - const upgradedPeerDependenciesLatest = await getPeerDependenciesFromRegistry(upgradedLatestVersions, options) + const upgradedPeerDependenciesLatest = await getPeerDependenciesFromRegistry( + Object.fromEntries( + Object.entries(upgradedLatestVersions).map(([packageName, versionSpec]) => { + return [ + packageName, + // git urls and other non-semver versions are ignored. + // Make sure versionSpec is a valid semver range, otherwise minVersion will throw. + validRange(versionSpec) ? (minVersion(versionSpec)?.version ?? versionSpec) : versionSpec, + ] + }), + ), + options, + ) return Object.entries(upgradedLatestVersions) .filter(([pkgName, newVersion]) => upgraded[pkgName] !== newVersion) .reduce((accum, [pkgName, newVersion]) => {