Skip to content

Commit

Permalink
fix: don’t pin upgrades (#19612)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Dec 30, 2022
1 parent fb99f4e commit 0fb2d26
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
33 changes: 15 additions & 18 deletions lib/workers/repository/process/lookup/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ describe('workers/repository/process/lookup/index', () => {
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
expect((await lookup.lookupUpdates(config)).updates).toMatchObject([
{ newValue: '0.4.4', updateType: 'pin' },
{ newValue: '0.9.7', updateType: 'minor' },
{ newValue: '1.4.1', updateType: 'major' },
{ newValue: '^0.9.0', updateType: 'minor' },
{ newValue: '^1.0.0', updateType: 'major' },
]);
});

Expand Down Expand Up @@ -167,8 +167,8 @@ describe('workers/repository/process/lookup/index', () => {
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
expect((await lookup.lookupUpdates(config)).updates).toMatchObject([
{ newValue: '0.4.4', updateType: 'pin' },
{ newValue: '0.9.7', updateType: 'minor' },
{ newValue: '1.4.1', updateType: 'major' },
{ newValue: '^0.9.0', updateType: 'minor' },
{ newValue: '^1.0.0', updateType: 'major' },
]);
});

Expand Down Expand Up @@ -294,7 +294,7 @@ describe('workers/repository/process/lookup/index', () => {
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
expect((await lookup.lookupUpdates(config)).updates).toMatchObject([
{ newValue: '0.4.4', updateType: 'pin' },
{ newValue: '1.4.1', updateType: 'major' },
{ newValue: '^1.0.0', updateType: 'major' },
]);
});

Expand Down Expand Up @@ -329,17 +329,16 @@ describe('workers/repository/process/lookup/index', () => {
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
expect((await lookup.lookupUpdates(config)).updates).toMatchObject([
{ newValue: '0.4.4', updateType: 'pin' },
{ newValue: '0.9.7', updateType: 'minor' },
{ newValue: '1.4.1', updateType: 'major' },
{ newValue: '~0.9.0', updateType: 'minor' },
{ newValue: '~1.4.0', updateType: 'major' },
]);
});

it.each`
strategy | updates
${'update-lockfile'} | ${[{ isLockfileUpdate: true, newValue: '*', newVersion: '0.9.7', updateType: 'minor' }, { isLockfileUpdate: true, newValue: '*', newVersion: '1.4.1', updateType: 'major' }]}
${'pin'} | ${[{ newValue: '0.4.0', updateType: 'pin' }, { newValue: '0.9.7', updateType: 'minor' }, { newValue: '1.4.1', updateType: 'major' }]}
strategy | updates
${'pin'} | ${[{ newValue: '0.4.0', updateType: 'pin' }]}
`(
'supports for x-range-all for replaceStrategy = $strategy (with lockfile)',
'supports for x-range-all for replaceStrategy = $strategy (with lockfile) abcd',
async ({ strategy, updates }) => {
config.currentValue = '*';
config.rangeStrategy = strategy;
Expand Down Expand Up @@ -424,7 +423,7 @@ describe('workers/repository/process/lookup/index', () => {
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
expect((await lookup.lookupUpdates(config)).updates).toMatchObject([
{ newValue: '0.9.7', updateType: 'pin' },
{ newValue: '1.4.1', updateType: 'major' },
{ newValue: '~1.4.0', updateType: 'major' },
]);
});

Expand All @@ -436,7 +435,7 @@ describe('workers/repository/process/lookup/index', () => {
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
expect((await lookup.lookupUpdates(config)).updates).toMatchObject([
{ newValue: '1.0.1', updateType: 'pin' },
{ newValue: '1.4.1', updateType: 'minor' },
{ newValue: '~1.4.0', updateType: 'minor' },
]);
});

Expand Down Expand Up @@ -583,7 +582,6 @@ describe('workers/repository/process/lookup/index', () => {
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
expect((await lookup.lookupUpdates(config)).updates).toMatchObject([
{ newValue: '1.0.0', updateType: 'pin' },
{ newValue: '1.4.1', updateType: 'minor' },
]);
});

Expand Down Expand Up @@ -614,7 +612,7 @@ describe('workers/repository/process/lookup/index', () => {
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
expect((await lookup.lookupUpdates(config)).updates).toMatchObject([
{ newValue: '1.3.0', updateType: 'pin' },
{ newValue: '1.4.1', updateType: 'minor' },
{ newValue: '~1.4.0', updateType: 'minor' },
]);
});

Expand All @@ -626,7 +624,7 @@ describe('workers/repository/process/lookup/index', () => {
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
expect((await lookup.lookupUpdates(config)).updates).toMatchObject([
{ newValue: '1.3.0', updateType: 'pin' },
{ newValue: '1.4.1', updateType: 'minor' },
{ newValue: '1.4.x', updateType: 'minor' },
]);
});

Expand Down Expand Up @@ -1416,8 +1414,7 @@ describe('workers/repository/process/lookup/index', () => {
const res = await lookup.lookupUpdates(config);
expect(res.updates).toMatchObject([
{ newValue: '==0.9.4', updateType: 'pin' },
{ newValue: '==0.9.7', updateType: 'patch' },
{ newValue: '==1.4.1', updateType: 'major' },
{ newValue: '~=1.4', updateType: 'major' },
]);
});

Expand Down
5 changes: 5 additions & 0 deletions lib/workers/repository/process/lookup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ export async function lookupUpdates(
newMajor: versioning.getMajor(currentVersion)!,
});
}
if (rangeStrategy === 'pin') {
// Fall back to replace once pinning logic is done
rangeStrategy = 'replace';
}
// istanbul ignore if
if (!versioning.isVersion(currentVersion!)) {
res.skipReason = 'invalid-version';
Expand Down Expand Up @@ -396,6 +400,7 @@ export async function lookupUpdates(
}
// Strip out any non-changed ones
res.updates = res.updates
.filter((update) => update.newValue !== null || currentValue === null)
.filter((update) => update.newDigest !== null)
.filter(
(update) =>
Expand Down

0 comments on commit 0fb2d26

Please sign in to comment.