Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
renovate
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
Renovate Bot
renovate
Commits
37e247e1
Commit
37e247e1
authored
6 years ago
by
Rhys Arkins
Browse files
Options
Downloads
Patches
Plain Diff
refactor(npm): major minor handling
parent
cddd9cd8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/versioning/semver/range.js
+23
-22
23 additions, 22 deletions
lib/versioning/semver/range.js
with
23 additions
and
22 deletions
lib/versioning/semver/range.js
+
23
−
22
View file @
37e247e1
...
@@ -38,7 +38,8 @@ function getNewValue(currentValue, rangeStrategy, fromVersion, toVersion) {
...
@@ -38,7 +38,8 @@ function getNewValue(currentValue, rangeStrategy, fromVersion, toVersion) {
}
}
return
`
${
currentValue
}
||
${
newValue
}
`
;
return
`
${
currentValue
}
||
${
newValue
}
`
;
}
}
// console.log(range);
const
toVersionMajor
=
major
(
toVersion
);
const
toVersionMinor
=
minor
(
toVersion
);
// Simple range
// Simple range
if
(
rangeStrategy
===
'
bump
'
)
{
if
(
rangeStrategy
===
'
bump
'
)
{
if
(
parsedRange
.
length
===
1
)
{
if
(
parsedRange
.
length
===
1
)
{
...
@@ -46,11 +47,11 @@ function getNewValue(currentValue, rangeStrategy, fromVersion, toVersion) {
...
@@ -46,11 +47,11 @@ function getNewValue(currentValue, rangeStrategy, fromVersion, toVersion) {
const
split
=
currentValue
.
split
(
'
.
'
);
const
split
=
currentValue
.
split
(
'
.
'
);
if
(
split
.
length
===
1
)
{
if
(
split
.
length
===
1
)
{
// ^4
// ^4
return
'
^
'
+
major
(
toVersion
)
;
return
'
^
'
+
toVersion
Major
;
}
}
if
(
split
.
length
===
2
)
{
if
(
split
.
length
===
2
)
{
// ^4.1
// ^4.1
return
'
^
'
+
major
(
toVersion
)
+
'
.
'
+
minor
(
toVersion
)
;
return
'
^
'
+
toVersion
Major
+
'
.
'
+
toVersion
Minor
;
}
}
return
`^
${
toVersion
}
`
;
return
`^
${
toVersion
}
`
;
}
}
...
@@ -58,11 +59,11 @@ function getNewValue(currentValue, rangeStrategy, fromVersion, toVersion) {
...
@@ -58,11 +59,11 @@ function getNewValue(currentValue, rangeStrategy, fromVersion, toVersion) {
const
split
=
currentValue
.
split
(
'
.
'
);
const
split
=
currentValue
.
split
(
'
.
'
);
if
(
split
.
length
===
1
)
{
if
(
split
.
length
===
1
)
{
// ~4
// ~4
return
'
~
'
+
major
(
toVersion
)
;
return
'
~
'
+
toVersion
Major
;
}
}
if
(
split
.
length
===
2
)
{
if
(
split
.
length
===
2
)
{
// ~4.1
// ~4.1
return
'
~
'
+
major
(
toVersion
)
+
'
.
'
+
minor
(
toVersion
)
;
return
'
~
'
+
toVersion
Major
+
'
.
'
+
toVersion
Minor
;
}
}
return
`~
${
toVersion
}
`
;
return
`~
${
toVersion
}
`
;
}
}
...
@@ -84,31 +85,31 @@ function getNewValue(currentValue, rangeStrategy, fromVersion, toVersion) {
...
@@ -84,31 +85,31 @@ function getNewValue(currentValue, rangeStrategy, fromVersion, toVersion) {
if
(
!
fromVersion
)
{
if
(
!
fromVersion
)
{
return
`^
${
toVersion
}
`
;
return
`^
${
toVersion
}
`
;
}
}
if
(
major
(
toVersion
)
===
major
(
fromVersion
))
{
if
(
toVersion
Major
===
major
(
fromVersion
))
{
if
(
major
(
toVersion
)
===
0
)
{
if
(
toVersion
Major
===
0
)
{
if
(
minor
(
toVersion
)
===
0
)
{
if
(
toVersion
Minor
===
0
)
{
return
`^
${
toVersion
}
`
;
return
`^
${
toVersion
}
`
;
}
}
return
`^
${
major
(
toVersion
)}
.
${
minor
(
toVersion
)
}
.0`
;
return
`^
${
toVersion
Major
}
.
${
toVersion
Minor
}
.0`
;
}
}
return
`^
${
toVersion
}
`
;
return
`^
${
toVersion
}
`
;
}
}
return
`^
${
major
(
toVersion
)
}
.0.0`
;
return
`^
${
toVersion
Major
}
.0.0`
;
}
}
if
(
element
.
operator
===
'
=
'
)
{
if
(
element
.
operator
===
'
=
'
)
{
return
`=
${
toVersion
}
`
;
return
`=
${
toVersion
}
`
;
}
}
if
(
element
.
operator
===
'
~
'
)
{
if
(
element
.
operator
===
'
~
'
)
{
return
`~
${
major
(
toVersion
)}
.
${
minor
(
toVersion
)
}
.0`
;
return
`~
${
toVersion
Major
}
.
${
toVersion
Minor
}
.0`
;
}
}
if
(
element
.
operator
===
'
<=
'
)
{
if
(
element
.
operator
===
'
<=
'
)
{
let
res
;
let
res
;
if
(
element
.
patch
)
{
if
(
element
.
patch
)
{
res
=
`<=
${
toVersion
}
`
;
res
=
`<=
${
toVersion
}
`
;
}
else
if
(
element
.
minor
)
{
}
else
if
(
element
.
minor
)
{
res
=
`<=
${
major
(
toVersion
)}
.
${
minor
(
toVersion
)
}
`
;
res
=
`<=
${
toVersion
Major
}
.
${
toVersion
Minor
}
`
;
}
else
{
}
else
{
res
=
`<=
${
major
(
toVersion
)
}
`
;
res
=
`<=
${
toVersion
Major
}
`
;
}
}
if
(
currentValue
.
includes
(
'
<=
'
))
{
if
(
currentValue
.
includes
(
'
<=
'
))
{
res
=
res
.
replace
(
'
<=
'
,
'
<=
'
);
res
=
res
.
replace
(
'
<=
'
,
'
<=
'
);
...
@@ -118,14 +119,14 @@ function getNewValue(currentValue, rangeStrategy, fromVersion, toVersion) {
...
@@ -118,14 +119,14 @@ function getNewValue(currentValue, rangeStrategy, fromVersion, toVersion) {
if
(
element
.
operator
===
'
<
'
)
{
if
(
element
.
operator
===
'
<
'
)
{
let
res
;
let
res
;
if
(
currentValue
.
endsWith
(
'
.0.0
'
))
{
if
(
currentValue
.
endsWith
(
'
.0.0
'
))
{
const
newMajor
=
major
(
toVersion
)
+
1
;
const
newMajor
=
toVersion
Major
+
1
;
res
=
`<
${
newMajor
}
.0.0`
;
res
=
`<
${
newMajor
}
.0.0`
;
}
else
if
(
element
.
patch
)
{
}
else
if
(
element
.
patch
)
{
res
=
`<
${
increment
(
toVersion
,
'
patch
'
)}
`
;
res
=
`<
${
increment
(
toVersion
,
'
patch
'
)}
`
;
}
else
if
(
element
.
minor
)
{
}
else
if
(
element
.
minor
)
{
res
=
`<
${
major
(
toVersion
)}
.
${
minor
(
toVersion
)
+
1
}
`
;
res
=
`<
${
toVersion
Major
}
.
${
toVersion
Minor
+
1
}
`
;
}
else
{
}
else
{
res
=
`<
${
major
(
toVersion
)
+
1
}
`
;
res
=
`<
${
toVersion
Major
+
1
}
`
;
}
}
if
(
currentValue
.
includes
(
'
<
'
))
{
if
(
currentValue
.
includes
(
'
<
'
))
{
res
=
res
.
replace
(
'
<
'
,
'
<
'
);
res
=
res
.
replace
(
'
<
'
,
'
<
'
);
...
@@ -135,20 +136,20 @@ function getNewValue(currentValue, rangeStrategy, fromVersion, toVersion) {
...
@@ -135,20 +136,20 @@ function getNewValue(currentValue, rangeStrategy, fromVersion, toVersion) {
if
(
!
element
.
operator
)
{
if
(
!
element
.
operator
)
{
if
(
element
.
minor
)
{
if
(
element
.
minor
)
{
if
(
element
.
minor
===
'
x
'
)
{
if
(
element
.
minor
===
'
x
'
)
{
return
`
${
major
(
toVersion
)
}
.x`
;
return
`
${
toVersion
Major
}
.x`
;
}
}
if
(
element
.
minor
===
'
*
'
)
{
if
(
element
.
minor
===
'
*
'
)
{
return
`
${
major
(
toVersion
)
}
.*`
;
return
`
${
toVersion
Major
}
.*`
;
}
}
if
(
element
.
patch
===
'
x
'
)
{
if
(
element
.
patch
===
'
x
'
)
{
return
`
${
major
(
toVersion
)}
.
${
minor
(
toVersion
)
}
.x`
;
return
`
${
toVersion
Major
}
.
${
toVersion
Minor
}
.x`
;
}
}
if
(
element
.
patch
===
'
*
'
)
{
if
(
element
.
patch
===
'
*
'
)
{
return
`
${
major
(
toVersion
)}
.
${
minor
(
toVersion
)
}
.*`
;
return
`
${
toVersion
Major
}
.
${
toVersion
Minor
}
.*`
;
}
}
return
`
${
major
(
toVersion
)}
.
${
minor
(
toVersion
)
}
`
;
return
`
${
toVersion
Major
}
.
${
toVersion
Minor
}
`
;
}
}
return
`
${
major
(
toVersion
)
}
`
;
return
`
${
toVersion
Major
}
`
;
}
}
return
toVersion
;
return
toVersion
;
}
}
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