mirror of
https://github.com/renovatebot/renovate.git
synced 2026-11-01 10:09:50 +00:00
476d10a807
* test(manager/npm): add coverage for Yarn `resolutions` parsing As part of follow-up changes, we'll fix this, but should have existing test coverage first. Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io> * fix(manager/npm): don't include versions in extracted Yarn `resolutions`' `depName` As noted in #44768, given the following in our `package.json`: ```json { "resolutions": { "@cypress/request/qs@~6.14.1": "^6.15.1", "@verdaccio/core/ajv@8.17.1": "^8.18.0" } } ``` Previously, Renovate would treat `~6.14.1` as the `depName`, which was incorrect. We can instead handle this by adding custom handling here. Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io> --------- Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>
57 lines
1.9 KiB
TypeScript
57 lines
1.9 KiB
TypeScript
import { parseDepName } from './dependency.ts';
|
|
|
|
describe('modules/manager/npm/extract/common/dependency', () => {
|
|
describe('parseDepName', () => {
|
|
it('returns key unchanged for non-resolutions depTypes', () => {
|
|
expect(parseDepName('dependencies', '@cypress/request/qs@~6.14.1')).toBe(
|
|
'@cypress/request/qs@~6.14.1',
|
|
);
|
|
});
|
|
|
|
it('returns simple package name unchanged', () => {
|
|
expect(parseDepName('resolutions', 'left-pad')).toBe('left-pad');
|
|
});
|
|
|
|
it('returns scoped package name unchanged', () => {
|
|
expect(parseDepName('resolutions', '@angular/cli')).toBe('@angular/cli');
|
|
});
|
|
|
|
it('extracts child package name from nested path', () => {
|
|
expect(parseDepName('resolutions', 'config/glob')).toBe('glob');
|
|
});
|
|
|
|
it('extracts child package name from wildcard nested path', () => {
|
|
expect(parseDepName('resolutions', '**/config')).toBe('config');
|
|
});
|
|
|
|
it('extracts scoped child package name from wildcard nested path', () => {
|
|
expect(parseDepName('resolutions', '**/@angular/cli')).toBe(
|
|
'@angular/cli',
|
|
);
|
|
});
|
|
|
|
// https://github.com/renovatebot/renovate/discussions/44768
|
|
it('strips version discriminator from unscoped final segment', () => {
|
|
expect(parseDepName('resolutions', 'foo/bar@1.0.0')).toBe('bar');
|
|
});
|
|
|
|
it('strips version discriminator from scoped parent path', () => {
|
|
expect(parseDepName('resolutions', '@cypress/request/qs@~6.14.1')).toBe(
|
|
'qs',
|
|
);
|
|
});
|
|
|
|
it('strips version discriminator with plain semver final segment', () => {
|
|
expect(parseDepName('resolutions', '@verdaccio/core/ajv@8.17.1')).toBe(
|
|
'ajv',
|
|
);
|
|
});
|
|
|
|
it('strips version discriminator when final segment is itself scoped', () => {
|
|
expect(parseDepName('resolutions', 'foo/@babel/core@7.0.0')).toBe(
|
|
'@babel/core',
|
|
);
|
|
});
|
|
});
|
|
});
|