-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: yarn constraint determination #27741
Conversation
Apparently we fall back to Yarn 2 right now: renovate/lib/modules/manager/npm/extract/yarn.ts Lines 102 to 116 in 66db519
|
Pull request was converted to draft
@@ -409,6 +409,47 @@ describe('modules/manager/npm/post-update/yarn', () => { | |||
expect(res.lockFile).toBe('package-lock-contents'); | |||
}); | |||
|
|||
it('falls back to Yarn v1 for undefined constraint', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently we default to Yarn v2 due to this:
renovate/lib/modules/manager/npm/extract/yarn.ts
Lines 102 to 116 in 66db519
export function getYarnVersionFromLock(lockfile: LockFile): string { | |
const { lockfileVersion, isYarn1 } = lockfile; | |
if (isYarn1) { | |
return '^1.22.18'; | |
} | |
if (lockfileVersion && lockfileVersion >= 8) { | |
// https://github.com/yarnpkg/berry/commit/9bcd27ae34aee77a567dd104947407532fa179b3 | |
return '^3.0.0'; | |
} else if (lockfileVersion && lockfileVersion >= 6) { | |
// https://github.com/yarnpkg/berry/commit/f753790380cbda5b55d028ea84b199445129f9ba | |
return '^2.2.0'; | |
} | |
return '^2.0.0'; | |
} |
logger.debug('No yarn constraint found'); | ||
return undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These lines are unreachable due to
renovate/lib/modules/manager/npm/extract/yarn.ts
Lines 102 to 116 in 66db519
export function getYarnVersionFromLock(lockfile: LockFile): string { | |
const { lockfileVersion, isYarn1 } = lockfile; | |
if (isYarn1) { | |
return '^1.22.18'; | |
} | |
if (lockfileVersion && lockfileVersion >= 8) { | |
// https://github.com/yarnpkg/berry/commit/9bcd27ae34aee77a567dd104947407532fa179b3 | |
return '^3.0.0'; | |
} else if (lockfileVersion && lockfileVersion >= 6) { | |
// https://github.com/yarnpkg/berry/commit/f753790380cbda5b55d028ea84b199445129f9ba | |
return '^2.2.0'; | |
} | |
return '^2.0.0'; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so simply return lock constraint?
logger.debug('Using yarn update newValue as constraint'); | ||
return yarnUpdate.newValue; | ||
} | ||
if (config.constraints?.yarn) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
didn't we agree to use this first?
logger.debug('No yarn constraint found'); | ||
return undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so simply return lock constraint?
we should latest yarn if no constraints can be found. |
Changes
Refactors and adds a test for yarn constraint determination.
Context
Preparing for #27656
Documentation (please check one with an [x])
How I've tested my work (please select one)
I have verified these changes via: