forked from nodejs/nodejs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdownloads.js
202 lines (189 loc) · 5.29 KB
/
downloads.js
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
'use strict';
const semver = require('semver');
const allDownloads = [
{
title: 'Windows 32-bit Installer',
templateUrl: 'https://nodejs.org/dist/v%version%/node-v%version%-x86.msi'
},
{
title: 'Windows 64-bit Installer',
templateUrl: 'https://nodejs.org/dist/v%version%/node-v%version%-x64.msi'
},
{
title: 'Windows 32-bit Binary',
templateUrl: 'https://nodejs.org/dist/v%version%/win-x86/node.exe'
},
{
title: 'Windows 64-bit Binary',
templateUrl: 'https://nodejs.org/dist/v%version%/win-x64/node.exe'
},
{
title: 'macOS 64-bit Installer',
templateUrl: 'https://nodejs.org/dist/v%version%/node-v%version%.pkg'
},
{
title: 'macOS Apple Silicon 64-bit Binary',
templateUrl:
'https://nodejs.org/dist/v%version%/node-v%version%-darwin-arm64.tar.gz'
},
{
title: 'macOS Intel 64-bit Binary',
templateUrl:
'https://nodejs.org/dist/v%version%/node-v%version%-darwin-x64.tar.gz'
},
{
title: 'Linux 32-bit Binary',
templateUrl:
'https://nodejs.org/dist/v%version%/node-v%version%-linux-x86.tar.xz'
},
{
title: 'Linux 64-bit Binary',
templateUrl:
'https://nodejs.org/dist/v%version%/node-v%version%-linux-x64.tar.xz'
},
{
title: 'Linux PPC LE 64-bit Binary',
templateUrl:
'https://nodejs.org/dist/v%version%/node-v%version%-linux-ppc64le.tar.xz'
},
{
title: 'Linux PPC BE 64-bit Binary',
templateUrl:
'https://nodejs.org/dist/v%version%/node-v%version%-linux-ppc64.tar.xz'
},
{
title: 'Linux s390x 64-bit Binary',
templateUrl:
'https://nodejs.org/dist/v%version%/node-v%version%-linux-s390x.tar.xz'
},
{
title: 'AIX 64-bit Binary',
templateUrl:
'https://nodejs.org/dist/v%version%/node-v%version%-aix-ppc64.tar.gz'
},
{
title: 'SmartOS 32-bit Binary',
templateUrl:
'https://nodejs.org/dist/v%version%/node-v%version%-sunos-x86.tar.xz'
},
{
title: 'SmartOS 64-bit Binary',
templateUrl:
'https://nodejs.org/dist/v%version%/node-v%version%-sunos-x64.tar.xz'
},
{
title: 'ARMv6 32-bit Binary',
templateUrl:
'https://nodejs.org/dist/v%version%/node-v%version%-linux-armv6l.tar.xz'
},
{
title: 'ARMv7 32-bit Binary',
templateUrl:
'https://nodejs.org/dist/v%version%/node-v%version%-linux-armv7l.tar.xz'
},
{
title: 'ARMv8 64-bit Binary',
templateUrl:
'https://nodejs.org/dist/v%version%/node-v%version%-linux-arm64.tar.xz'
},
{
title: 'Source Code',
templateUrl: 'https://nodejs.org/dist/v%version%/node-v%version%.tar.gz'
}
];
// v0.x of Node.js
const legacyDownloads = [
{
title: 'Windows 32-bit Installer',
templateUrl: 'https://nodejs.org/dist/v%version%/node-v%version%-x86.msi'
},
{
title: 'Windows 64-bit Installer',
templateUrl:
'https://nodejs.org/dist/v%version%/x64/node-v%version%-x64.msi'
},
{
title: 'Windows 32-bit Binary',
templateUrl: 'https://nodejs.org/dist/v%version%/node.exe'
},
{
title: 'Windows 64-bit Binary',
templateUrl: 'https://nodejs.org/dist/v%version%/x64/node.exe'
},
{
title: 'macOS Universal Installer',
templateUrl: 'https://nodejs.org/dist/v%version%/node-v%version%.pkg'
},
{
title: 'macOS 64-bit Binary',
templateUrl:
'https://nodejs.org/dist/v%version%/node-v%version%-darwin-x64.tar.gz'
},
{
title: 'macOS 32-bit Binary',
templateUrl:
'https://nodejs.org/dist/v%version%/node-v%version%-darwin-x86.tar.gz'
},
{
title: 'Linux 32-bit Binary',
templateUrl:
'https://nodejs.org/dist/v%version%/node-v%version%-linux-x86.tar.gz'
},
{
title: 'Linux 64-bit Binary',
templateUrl:
'https://nodejs.org/dist/v%version%/node-v%version%-linux-x64.tar.gz'
},
{
title: 'SmartOS 32-bit Binary',
templateUrl:
'https://nodejs.org/dist/v%version%/node-v%version%-sunos-x86.tar.gz'
},
{
title: 'SmartOS 64-bit Binary',
templateUrl:
'https://nodejs.org/dist/v%version%/node-v%version%-sunos-x64.tar.gz'
},
{
title: 'Source Code',
templateUrl: 'https://nodejs.org/dist/v%version%/node-v%version%.tar.gz'
}
];
const resolveUrl = (item, version) => {
const url = item.templateUrl.replace(/%version%/g, version);
return Object.assign({ url }, item);
};
const resolveDownloads = (version) => {
let downloads = allDownloads;
if (semver.satisfies(version, '< 1.0.0')) {
return legacyDownloads;
}
if (semver.satisfies(version, '>= 8.0.0')) {
downloads = downloads.filter(
(ver) => ver.title !== 'Linux PPC BE 64-bit Binary'
);
}
if (semver.satisfies(version, '>= 10.0.0')) {
downloads = downloads.filter(
(ver) =>
ver.title !== 'Linux 32-bit Binary' &&
ver.title !== 'SmartOS 32-bit Binary'
);
}
if (semver.satisfies(version, '>= 12.0.0')) {
downloads = downloads.filter((ver) => ver.title !== 'ARMv6 32-bit Binary');
}
if (semver.satisfies(version, '>= 14.0.0')) {
downloads = downloads.filter(
(ver) => ver.title !== 'SmartOS 64-bit Binary'
);
}
if (semver.satisfies(version, '< 16.0.0')) {
downloads = downloads.filter(
(ver) => ver.title !== 'macOS Apple Silicon 64-bit Binary'
);
}
return downloads;
};
module.exports = (version) =>
resolveDownloads(version).map((item) => resolveUrl(item, version));