/
index.ts
49 lines (44 loc) · 1.1 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { DateTime } from 'luxon';
import npm, { isValid, isVersion } from '../npm';
import type { NewValueConfig, VersioningApi } from '../types';
import { nodeSchedule } from './schedule';
export const id = 'node';
export const displayName = 'Node.js';
export const urls = [];
export const supportsRanges = false;
function getNewValue({
currentValue,
rangeStrategy,
currentVersion,
newVersion,
}: NewValueConfig): string {
const res = npm.getNewValue({
currentValue,
rangeStrategy,
currentVersion,
newVersion,
});
if (isVersion(res)) {
// normalize out any 'v' prefix
return isVersion(res);
}
return res;
}
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: https://github.com/renovatebot/renovate/issues/9716
return DateTime.local() > DateTime.fromISO(schedule.lts);
}
}
return false;
}
export const api: VersioningApi = {
...npm,
isStable,
getNewValue,
};
export default api;