Skip to content
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

fix(volta): make sure volta uses the same yarn package overwrite #18893

Merged
merged 12 commits into from Nov 16, 2022
42 changes: 42 additions & 0 deletions lib/modules/manager/npm/extract/index.spec.ts
Expand Up @@ -483,6 +483,48 @@ describe('modules/manager/npm/extract/index', () => {
});
});

it('extracts volta yarn higher than 1', async () => {
const pJson = {
main: 'index.js',
engines: {
node: '16.0.0',
},
volta: {
node: '16.0.0',
yarn: '3.2.4',
},
};
const pJsonStr = JSON.stringify(pJson);
const res = await npmExtract.extractPackageFile(
pJsonStr,
'package.json',
defaultConfig
);
expect(res).toMatchObject({
deps: [
{},
{
commitMessageTopic: 'Node.js',
currentValue: '16.0.0',
datasource: 'github-tags',
depName: 'node',
depType: 'volta',
packageName: 'nodejs/node',
prettyDepType: 'volta',
versioning: 'node',
},
{
commitMessageTopic: 'Yarn',
currentValue: '3.2.4',
datasource: 'npm',
depName: 'yarn',
pataar marked this conversation as resolved.
Show resolved Hide resolved
depType: 'volta',
prettyDepType: 'volta',
},
],
});
});

it('extracts non-npmjs', async () => {
const pJson = {
dependencies: {
Expand Down
14 changes: 9 additions & 5 deletions lib/modules/manager/npm/extract/index.ts
Expand Up @@ -8,7 +8,7 @@ import { newlineRegex, regEx } from '../../../../util/regex';
import { GithubTagsDatasource } from '../../../datasource/github-tags';
import { NpmDatasource } from '../../../datasource/npm';
import * as nodeVersioning from '../../../versioning/node';
import { isValid, isVersion } from '../../../versioning/npm';
import { api, isValid, isVersion } from '../../../versioning/npm';
import type {
ExtractConfig,
NpmLockFiles,
Expand Down Expand Up @@ -200,10 +200,9 @@ export async function extractPackageFile(
dep.datasource = NpmDatasource.id;
dep.commitMessageTopic = 'Yarn';
constraints.yarn = dep.currentValue;
if (
dep.currentValue.startsWith('2') ||
dep.currentValue.startsWith('3')
) {
const major =
isVersion(dep.currentValue) && api.getMajor(dep.currentValue);
if (major && major > 1) {
dep.packageName = '@yarnpkg/cli';
}
} else if (depName === 'npm') {
Expand Down Expand Up @@ -235,6 +234,11 @@ export async function extractPackageFile(
} else if (depName === 'yarn') {
dep.datasource = NpmDatasource.id;
dep.commitMessageTopic = 'Yarn';
const major =
isVersion(dep.currentValue) && api.getMajor(dep.currentValue);
if (major && major > 1) {
dep.packageName = '@yarnpkg/cli';
}
} else if (depName === 'npm') {
dep.datasource = NpmDatasource.id;
} else {
Expand Down