3 // Map from node conventions to webinstall conventions
29 function getAllReleases(request) {
31 url: 'https://nodejs.org/dist/index.json',
33 }).then(function (resp) {
37 download: '' // node's download URLs are unpredictable
40 // https://blog.risingstack.com/update-nodejs-8-end-of-life-no-support/
41 // 6 mos "current" + 18 mos LTS "active" + 12 mos LTS "maintenance"
42 //var endOfLife = 3 * 366 * 24 * 60 * 60 * 1000;
43 // If there have been no updates in 12 months, it's almost certainly end-of-life
44 var endOfLife = 366 * 24 * 60 * 60 * 1000;
46 rels.forEach(function (rel) {
47 if (Date.now() - new Date(rel.date).valueOf() > endOfLife) {
50 rel.files.forEach(function (file) {
51 if ('src' === file || 'headers' === file) {
54 var parts = file.split(/-/);
55 var os = map[parts[0]];
57 console.warn('node versions: unknown os "%s"', parts[0]);
59 var arch = map[parts[1]];
61 console.warn('node versions: unknown arch "%s"', parts[1]);
63 var ext = map[parts[2] || 'tar'];
65 console.warn('node versions: unknown ext "%s"', parts[2]);
68 // node exe files are not self-extracting installers
72 var even = 0 === rel.version.slice(1).split('.')[0] % 2;
77 // historically odd releases have been beta and even have been stable
78 channel: even ? 'stable' : 'beta',
83 // See https://nodejs.org/dist/v14.0.0/
84 // usually like https://nodejs.org/dist/v14.0.0/node-{version}-{plat}-{arch}.{ext}
86 'https://nodejs.org/dist/' + rel.version + '/node-' + rel.version
90 // handle all the special cases (which there are many)
96 if ('amd64' === arch) {
97 r.download += '-x64.msi';
99 r.download += '-x86.msi';
104 if ('macos' === os) {
105 r.download += '-darwin';
106 } else if ('win' === os) {
107 r.download += '-win';
109 r.download += '-' + os;
112 if ('amd64' === arch) {
113 r.download += '-x64';
115 r.download += '-' + arch;
119 r.download += '.tar.gz';
123 r.download += '.' + ext;
125 if ('tar.gz' === ext) {
128 all.releases.push(JSON.parse(JSON.stringify(r)));
129 r.download = r.download.replace(/\.xz$/, '.gz');
138 module.exports = getAllReleases;
140 if (module === require.main) {
141 getAllReleases(require('@root/request')).then(function (all) {
142 console.log(JSON.stringify(all));
143 //console.log(JSON.stringify(all, null, 2));