Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
renovate
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SmartDataLab
public
applications
renovate
Commits
123d8b44
Unverified
Commit
123d8b44
authored
Feb 6, 2022
by
Sergei Zharinov
Committed by
GitHub
Feb 6, 2022
Browse files
Options
Downloads
Patches
Plain Diff
refactor(versioning/hashicorp): Enable strict null checks (#14030)
parent
4fa5eeb8
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/versioning/hashicorp/index.ts
+29
-15
29 additions, 15 deletions
lib/versioning/hashicorp/index.ts
tsconfig.strict.json
+0
-4
0 additions, 4 deletions
tsconfig.strict.json
with
29 additions
and
19 deletions
lib/versioning/hashicorp/index.ts
+
29
−
15
View file @
123d8b44
...
@@ -15,8 +15,9 @@ function hashicorp2npm(input: string): string {
...
@@ -15,8 +15,9 @@ function hashicorp2npm(input: string): string {
return
input
.
replace
(
regEx
(
/~>
(\s
*
\d
+
\.\d
+$
)
/
),
'
^$1
'
).
replace
(
'
,
'
,
''
);
return
input
.
replace
(
regEx
(
/~>
(\s
*
\d
+
\.\d
+$
)
/
),
'
^$1
'
).
replace
(
'
,
'
,
''
);
}
}
const
isLessThanRange
=
(
version
:
string
,
range
:
string
):
boolean
=>
function
isLessThanRange
(
version
:
string
,
range
:
string
):
boolean
{
npm
.
isLessThanRange
(
hashicorp2npm
(
version
),
hashicorp2npm
(
range
));
return
!!
npm
.
isLessThanRange
?.(
hashicorp2npm
(
version
),
hashicorp2npm
(
range
));
}
export
const
isValid
=
(
input
:
string
):
boolean
=>
export
const
isValid
=
(
input
:
string
):
boolean
=>
!!
input
&&
npm
.
isValid
(
hashicorp2npm
(
input
));
!!
input
&&
npm
.
isValid
(
hashicorp2npm
(
input
));
...
@@ -24,29 +25,42 @@ export const isValid = (input: string): boolean =>
...
@@ -24,29 +25,42 @@ export const isValid = (input: string): boolean =>
const
matches
=
(
version
:
string
,
range
:
string
):
boolean
=>
const
matches
=
(
version
:
string
,
range
:
string
):
boolean
=>
npm
.
matches
(
hashicorp2npm
(
version
),
hashicorp2npm
(
range
));
npm
.
matches
(
hashicorp2npm
(
version
),
hashicorp2npm
(
range
));
const
getSatisfyingVersion
=
(
versions
:
string
[],
range
:
string
):
string
=>
function
getSatisfyingVersion
(
npm
.
getSatisfyingVersion
(
versions
.
map
(
hashicorp2npm
),
hashicorp2npm
(
range
));
versions
:
string
[],
range
:
string
):
string
|
null
{
return
npm
.
getSatisfyingVersion
(
versions
.
map
(
hashicorp2npm
),
hashicorp2npm
(
range
)
);
}
const
minSatisfyingVersion
=
(
versions
:
string
[],
range
:
string
):
string
=>
function
minSatisfyingVersion
(
npm
.
minSatisfyingVersion
(
versions
.
map
(
hashicorp2npm
),
hashicorp2npm
(
range
));
versions
:
string
[],
range
:
string
):
string
|
null
{
return
npm
.
minSatisfyingVersion
(
versions
.
map
(
hashicorp2npm
),
hashicorp2npm
(
range
)
);
}
function
getNewValue
({
function
getNewValue
({
currentValue
,
currentValue
,
rangeStrategy
,
rangeStrategy
,
currentVersion
,
currentVersion
,
newVersion
,
newVersion
,
}:
NewValueConfig
):
string
{
}:
NewValueConfig
):
string
|
null
{
if
([
'
replace
'
,
'
update-lockfile
'
].
includes
(
rangeStrategy
))
{
if
([
'
replace
'
,
'
update-lockfile
'
].
includes
(
rangeStrategy
))
{
if
(
const
minor
=
npm
.
getMinor
(
newVersion
);
regEx
(
/~>
\s
*0
\.\d
+/
).
test
(
currentValue
)
&&
const
major
=
npm
.
getMajor
(
newVersion
);
npm
.
getMajor
(
newVersion
)
===
0
if
(
regEx
(
/~>
\s
*0
\.\d
+/
).
test
(
currentValue
)
&&
major
===
0
&&
minor
)
{
)
{
const
testFullVersion
=
regEx
(
/
(
~>
\s
*0
\.)(\d
+
)\.\d
$/
);
const
testFullVersion
=
regEx
(
/
(
~>
\s
*0
\.)(\d
+
)\.\d
$/
);
let
replaceValue
=
''
;
let
replaceValue
=
''
;
if
(
testFullVersion
.
test
(
currentValue
))
{
if
(
testFullVersion
.
test
(
currentValue
))
{
replaceValue
=
`$<prefix>
${
npm
.
getMinor
(
newVersion
)
}
.0`
;
replaceValue
=
`$<prefix>
${
minor
}
.0`
;
}
else
{
}
else
{
replaceValue
=
`$<prefix>
${
npm
.
getMinor
(
newVersion
)
}
$<suffix>`
;
replaceValue
=
`$<prefix>
${
minor
}
$<suffix>`
;
}
}
return
currentValue
.
replace
(
return
currentValue
.
replace
(
regEx
(
`(?<prefix>~>
\\
s*0
\\
.)
\\
d+(?<suffix>.*)$`
),
regEx
(
`(?<prefix>~>
\\
s*0
\\
.)
\\
d+(?<suffix>.*)$`
),
...
@@ -54,10 +68,10 @@ function getNewValue({
...
@@ -54,10 +68,10 @@ function getNewValue({
);
);
}
}
// handle special ~> 1.2 case
// handle special ~> 1.2 case
if
(
regEx
(
/
(
~>
\s
*
)\d
+
\.\d
+$/
).
test
(
currentValue
))
{
if
(
major
&&
regEx
(
/
(
~>
\s
*
)\d
+
\.\d
+$/
).
test
(
currentValue
))
{
return
currentValue
.
replace
(
return
currentValue
.
replace
(
regEx
(
`(?<prefix>~>
\\
s*)
\\
d+
\\
.
\\
d+$`
),
regEx
(
`(?<prefix>~>
\\
s*)
\\
d+
\\
.
\\
d+$`
),
`$<prefix>
${
npm
.
getMajor
(
newVersion
)
}
.0`
`$<prefix>
${
major
}
.0`
);
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
tsconfig.strict.json
+
0
−
4
View file @
123d8b44
...
@@ -386,11 +386,7 @@
...
@@ -386,11 +386,7 @@
"lib/util/merge-confidence/index.ts"
,
"lib/util/merge-confidence/index.ts"
,
"lib/util/package-rules.ts"
,
"lib/util/package-rules.ts"
,
"lib/versioning/api.ts"
,
"lib/versioning/api.ts"
,
"lib/versioning/aws-machine-image/index.ts"
,
"lib/versioning/common.ts"
,
"lib/versioning/common.ts"
,
"lib/versioning/generic.ts"
,
"lib/versioning/git/index.ts"
,
"lib/versioning/hashicorp/index.ts"
,
"lib/versioning/helm/index.ts"
,
"lib/versioning/helm/index.ts"
,
"lib/versioning/index.ts"
,
"lib/versioning/index.ts"
,
"lib/versioning/poetry/index.ts"
,
"lib/versioning/poetry/index.ts"
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment