Skip to content

Commit

Permalink
fix(volta): make sure volta uses the same yarn package overwrite (#18893
Browse files Browse the repository at this point in the history
)

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
  • Loading branch information
pataar and viceice authored Nov 16, 2022
1 parent a27a7fa commit 7adc861
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 5 deletions.
44 changes: 44 additions & 0 deletions lib/modules/manager/npm/extract/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,50 @@ 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',
depType: 'volta',
prettyDepType: 'volta',
packageName: '@yarnpkg/cli',
},
],
});
});

it('extracts non-npmjs', async () => {
const pJson = {
dependencies: {
Expand Down
14 changes: 9 additions & 5 deletions lib/modules/manager/npm/extract/index.ts
Original file line number Diff line number Diff line change
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

0 comments on commit 7adc861

Please sign in to comment.