Skip to content

Commit

Permalink
feat(hex): support update-lockfile strategy (#27915)
Browse files Browse the repository at this point in the history
  • Loading branch information
pdm-jd authored Jun 12, 2024
1 parent cfee1c8 commit 4c3d970
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
38 changes: 20 additions & 18 deletions lib/modules/versioning/hex/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,26 @@ describe('modules/versioning/hex/index', () => {
);

it.each`
currentValue | rangeStrategy | currentVersion | newVersion | expected
${'== 1.2.3'} | ${'pin'} | ${'1.2.3'} | ${'2.0.7'} | ${'== 2.0.7'}
${'== 3.6.1'} | ${'bump'} | ${'3.6.1'} | ${'3.6.2'} | ${'== 3.6.2'}
${'== 3.6.1'} | ${'replace'} | ${'3.6.1'} | ${'3.6.2'} | ${'== 3.6.2'}
${'~> 1.2'} | ${'replace'} | ${'1.2.3'} | ${'2.0.7'} | ${'~> 2.0'}
${'~> 1.2'} | ${'pin'} | ${'1.2.3'} | ${'2.0.7'} | ${'== 2.0.7'}
${'~> 1.2'} | ${'bump'} | ${'1.2.3'} | ${'2.0.7'} | ${'~> 2.0'}
${'~> 1.2'} | ${'bump'} | ${'1.2.3'} | ${'1.3.1'} | ${'~> 1.3'}
${'~> 1.2.0'} | ${'replace'} | ${'1.2.3'} | ${'2.0.7'} | ${'~> 2.0.0'}
${'~> 1.2.0'} | ${'pin'} | ${'1.2.3'} | ${'2.0.7'} | ${'== 2.0.7'}
${'~> 1.2.0'} | ${'bump'} | ${'1.2.3'} | ${'2.0.7'} | ${'~> 2.0.7'}
${'>= 1.0.0 and <= 2.0.0'} | ${'widen'} | ${'1.2.3'} | ${'2.0.7'} | ${'>= 1.0.0 and <= 2.0.7'}
${'>= 1.0.0 and <= 2.0.0'} | ${'replace'} | ${'1.2.3'} | ${'2.0.7'} | ${'<= 2.0.7'}
${'>= 1.0.0 and <= 2.0.0'} | ${'pin'} | ${'1.2.3'} | ${'2.0.7'} | ${'== 2.0.7'}
${'>= 1.0.0 or <= 2.0.0'} | ${'widen'} | ${'1.2.3'} | ${'2.0.7'} | ${'>= 1.0.0 or <= 2.0.0'}
${'>= 1.0.0 or <= 2.0.0'} | ${'replace'} | ${'1.2.3'} | ${'2.0.7'} | ${'<= 2.0.7'}
${'>= 1.0.0 or <= 2.0.0'} | ${'pin'} | ${'1.2.3'} | ${'2.0.7'} | ${'== 2.0.7'}
${'~> 0.4'} | ${'replace'} | ${'0.4.2'} | ${'0.6.0'} | ${'~> 0.6'}
currentValue | rangeStrategy | currentVersion | newVersion | expected
${'== 1.2.3'} | ${'pin'} | ${'1.2.3'} | ${'2.0.7'} | ${'== 2.0.7'}
${'== 3.6.1'} | ${'bump'} | ${'3.6.1'} | ${'3.6.2'} | ${'== 3.6.2'}
${'== 3.6.1'} | ${'replace'} | ${'3.6.1'} | ${'3.6.2'} | ${'== 3.6.2'}
${'~> 1.2'} | ${'replace'} | ${'1.2.3'} | ${'2.0.7'} | ${'~> 2.0'}
${'~> 1.2'} | ${'pin'} | ${'1.2.3'} | ${'2.0.7'} | ${'== 2.0.7'}
${'~> 1.2'} | ${'bump'} | ${'1.2.3'} | ${'2.0.7'} | ${'~> 2.0'}
${'~> 1.2'} | ${'bump'} | ${'1.2.3'} | ${'1.3.1'} | ${'~> 1.3'}
${'~> 1.1'} | ${'update-lockfile'} | ${'1.2.0'} | ${'1.3.0'} | ${'~> 1.1'}
${'~> 1.1'} | ${'update-lockfile'} | ${'1.2.0'} | ${'2.0.0'} | ${'~> 2.0'}
${'~> 1.2.0'} | ${'replace'} | ${'1.2.3'} | ${'2.0.7'} | ${'~> 2.0.0'}
${'~> 1.2.0'} | ${'pin'} | ${'1.2.3'} | ${'2.0.7'} | ${'== 2.0.7'}
${'~> 1.2.0'} | ${'bump'} | ${'1.2.3'} | ${'2.0.7'} | ${'~> 2.0.7'}
${'>= 1.0.0 and <= 2.0.0'} | ${'widen'} | ${'1.2.3'} | ${'2.0.7'} | ${'>= 1.0.0 and <= 2.0.7'}
${'>= 1.0.0 and <= 2.0.0'} | ${'replace'} | ${'1.2.3'} | ${'2.0.7'} | ${'<= 2.0.7'}
${'>= 1.0.0 and <= 2.0.0'} | ${'pin'} | ${'1.2.3'} | ${'2.0.7'} | ${'== 2.0.7'}
${'>= 1.0.0 or <= 2.0.0'} | ${'widen'} | ${'1.2.3'} | ${'2.0.7'} | ${'>= 1.0.0 or <= 2.0.0'}
${'>= 1.0.0 or <= 2.0.0'} | ${'replace'} | ${'1.2.3'} | ${'2.0.7'} | ${'<= 2.0.7'}
${'>= 1.0.0 or <= 2.0.0'} | ${'pin'} | ${'1.2.3'} | ${'2.0.7'} | ${'== 2.0.7'}
${'~> 0.4'} | ${'replace'} | ${'0.4.2'} | ${'0.6.0'} | ${'~> 0.6'}
`(
'getNewValue("$currentValue", "$rangeStrategy", "$currentVersion", "$newVersion") === "$expected"',
({ currentValue, rangeStrategy, currentVersion, newVersion, expected }) => {
Expand Down
1 change: 1 addition & 0 deletions lib/modules/versioning/hex/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const supportedRangeStrategies: RangeStrategy[] = [
'widen',
'pin',
'replace',
'update-lockfile',
];

function hex2npm(input: string): string {
Expand Down

0 comments on commit 4c3d970

Please sign in to comment.