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(versioning/hashicorp): allow numbered unstable versions #21334

Merged
merged 1 commit into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/modules/versioning/hashicorp/convertor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe('modules/versioning/hashicorp/convertor', () => {
${'< 4.0'} | ${'<4.0'}
${'> 4.0, < 5.0'} | ${'>4.0 <5.0'}
${'~> 2.3.4'} | ${'~2.3.4'}
${'0.1.0-beta.0'} | ${'0.1.0-beta.0'}
`(
'hashicorp2npm("$hashicorp") === $npm && npm2hashicorp("$npm") === $hashicorp',
({ hashicorp, npm }) => {
Expand Down
6 changes: 4 additions & 2 deletions lib/modules/versioning/hashicorp/convertor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export function hashicorp2npm(input: string): string {
.split(',')
.map((single) => {
const r = single.match(
regEx(/^\s*(|=|!=|>|<|>=|<=|~>)\s*v?((\d+)(\.\d+){0,2}[\w-+]*)\s*$/)
regEx(
/^\s*(|=|!=|>|<|>=|<=|~>)\s*v?((\d+)(\.\d+){0,2}[\w-+]*(\.\d+)*)\s*$/
)
);
if (!r) {
logger.warn(
Expand Down Expand Up @@ -64,7 +66,7 @@ export function npm2hashicorp(input: string): string {
.split(' ')
.map((single) => {
const r = single.match(
regEx(/^(|>|<|>=|<=|~|\^)v?((\d+)(\.\d+){0,2}[\w-]*)$/)
regEx(/^(|>|<|>=|<=|~|\^)v?((\d+)(\.\d+){0,2}[\w-]*(\.\d+)*)$/)
);
if (!r) {
throw new Error('invalid npm constraint');
Expand Down
1 change: 1 addition & 0 deletions lib/modules/versioning/hashicorp/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ describe('modules/versioning/hashicorp/index', () => {
${'>=4.1'} | ${true}
${'<=4.1.2'} | ${true}
${''} | ${false}
${'0.1.0-beta.0'} | ${true}
`('isValid("$input") === $expected', ({ input, expected }) => {
const res = !!semver.isValid(input);
expect(res).toBe(expected);
Expand Down