Skip to content

Commit

Permalink
fix(yarn): support v4 lock file detection and add forwards compatibil…
Browse files Browse the repository at this point in the history
…ity (#27835)
  • Loading branch information
rarkins committed Mar 11, 2024
1 parent 8900944 commit 33959ef
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/modules/manager/npm/extract/yarn.spec.ts
Expand Up @@ -58,6 +58,12 @@ describe('modules/manager/npm/extract/yarn', () => {

it('getYarnVersionFromLock', () => {
expect(getYarnVersionFromLock({ isYarn1: true })).toBe('^1.22.18');
expect(
getYarnVersionFromLock({ isYarn1: false, lockfileVersion: 12 }),
).toBe('>=4.0.0');
expect(
getYarnVersionFromLock({ isYarn1: false, lockfileVersion: 10 }),
).toBe('^4.0.0');
expect(getYarnVersionFromLock({ isYarn1: false, lockfileVersion: 8 })).toBe(
'^3.0.0',
);
Expand Down
7 changes: 7 additions & 0 deletions lib/modules/manager/npm/extract/yarn.ts
Expand Up @@ -104,6 +104,13 @@ export function getYarnVersionFromLock(lockfile: LockFile): string {
if (isYarn1) {
return '^1.22.18';
}
if (lockfileVersion && lockfileVersion >= 12) {
// This will probably be v5
return '>=4.0.0';
}
if (lockfileVersion && lockfileVersion >= 10) {
return '^4.0.0';
}
if (lockfileVersion && lockfileVersion >= 8) {
// https://github.com/yarnpkg/berry/commit/9bcd27ae34aee77a567dd104947407532fa179b3
return '^3.0.0';
Expand Down

0 comments on commit 33959ef

Please sign in to comment.