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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
Renovate Bot
renovate
Commits
db6b4872
Unverified
Commit
db6b4872
authored
4 years ago
by
Sergei Zharinov
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
fix(node): Use better "isStable" function (#7157)
parent
c98a537f
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/versioning/node/index.spec.ts
+34
-1
34 additions, 1 deletion
lib/versioning/node/index.spec.ts
lib/versioning/node/index.ts
+15
-0
15 additions, 0 deletions
lib/versioning/node/index.ts
with
49 additions
and
1 deletion
lib/versioning/node/index.spec.ts
+
34
−
1
View file @
db6b4872
import
{
api
as
nodever
}
from
'
.
'
;
import
{
DateTime
}
from
'
luxon
'
;
import
{
isStable
,
api
as
nodever
}
from
'
.
'
;
describe
(
'
semver.getNewValue()
'
,
()
=>
{
describe
(
'
semver.getNewValue()
'
,
()
=>
{
let
dtLocal
:
any
;
beforeEach
(()
=>
{
dtLocal
=
DateTime
.
local
;
});
afterEach
(()
=>
{
DateTime
.
local
=
dtLocal
;
});
it
(
'
returns normalized toVersion
'
,
()
=>
{
it
(
'
returns normalized toVersion
'
,
()
=>
{
expect
(
expect
(
nodever
.
getNewValue
({
nodever
.
getNewValue
({
...
@@ -21,4 +29,29 @@ describe('semver.getNewValue()', () => {
...
@@ -21,4 +29,29 @@ describe('semver.getNewValue()', () => {
})
})
).
toEqual
(
'
~8.2.0
'
);
).
toEqual
(
'
~8.2.0
'
);
});
});
it
(
'
isStable
'
,
()
=>
{
const
t1
=
DateTime
.
fromISO
(
'
2020-09-01
'
);
const
t2
=
DateTime
.
fromISO
(
'
2021-06-01
'
);
[
[
'
16.0.0
'
,
t1
,
false
],
[
'
15.0.0
'
,
t1
,
false
],
[
'
14.9.0
'
,
t1
,
false
],
[
'
14.0.0
'
,
t2
,
true
],
[
'
12.0.3
'
,
t1
,
true
],
[
'
v12.0.3
'
,
t1
,
true
],
[
'
12.0.3a
'
,
t1
,
false
],
[
'
11.0.0
'
,
t1
,
false
],
[
'
10.0.0
'
,
t1
,
true
],
[
'
10.0.999
'
,
t1
,
true
],
[
'
10.1.0
'
,
t1
,
true
],
[
'
10.0.0a
'
,
t1
,
false
],
[
'
9.0.0
'
,
t1
,
false
],
].
forEach
(([
version
,
time
,
result
])
=>
{
DateTime
.
local
=
(...
args
)
=>
args
.
length
?
dtLocal
.
apply
(
DateTime
,
args
)
:
time
;
expect
(
isStable
(
version
as
string
)).
toBe
(
result
);
});
});
});
});
This diff is collapsed.
Click to expand it.
lib/versioning/node/index.ts
+
15
−
0
View file @
db6b4872
import
{
DateTime
}
from
'
luxon
'
;
import
{
NewValueConfig
,
VersioningApi
}
from
'
../common
'
;
import
{
NewValueConfig
,
VersioningApi
}
from
'
../common
'
;
import
npm
,
{
isValid
,
isVersion
}
from
'
../npm
'
;
import
npm
,
{
isValid
,
isVersion
}
from
'
../npm
'
;
import
{
nodeSchedule
}
from
'
./schedule
'
;
export
const
id
=
'
node
'
;
export
const
id
=
'
node
'
;
export
const
displayName
=
'
Node.js
'
;
export
const
displayName
=
'
Node.js
'
;
...
@@ -27,8 +29,21 @@ function getNewValue({
...
@@ -27,8 +29,21 @@ function getNewValue({
export
{
isValid
};
export
{
isValid
};
export
function
isStable
(
version
:
string
):
boolean
{
if
(
npm
.
isStable
(
version
))
{
const
major
=
npm
.
getMajor
(
version
);
const
schedule
=
nodeSchedule
[
`v
${
major
}
`
];
if
(
schedule
?.
lts
)
{
// TODO: use the exact release that started LTS
return
DateTime
.
local
()
>
DateTime
.
fromISO
(
schedule
.
lts
);
}
}
return
false
;
}
export
const
api
:
VersioningApi
=
{
export
const
api
:
VersioningApi
=
{
...
npm
,
...
npm
,
isStable
,
getNewValue
,
getNewValue
,
};
};
export
default
api
;
export
default
api
;
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