3 // Map from node conventions to webinstall conventions
8 win: 'windows', // windows
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;
75 version: rel.version.slice(1),
78 // historically odd releases have been beta and even have been stable
79 channel: even ? 'stable' : 'beta',
84 // See https://nodejs.org/dist/v14.0.0/
85 // usually like https://nodejs.org/dist/v14.0.0/node-{version}-{plat}-{arch}.{ext}
87 'https://nodejs.org/dist/' + rel.version + '/node-' + rel.version
91 // handle all the special cases (which there are many)
97 if ('amd64' === arch) {
98 r.download += '-x64.msi';
100 r.download += '-x86.msi';
105 if ('macos' === os) {
106 r.download += '-darwin';
107 } else if ('windows' === os) {
108 r.download += '-win';
110 r.download += '-' + os;
113 if ('amd64' === arch) {
114 r.download += '-x64';
116 r.download += '-' + arch;
120 r.download += '.tar.gz';
124 r.download += '.' + ext;
126 if ('tar.gz' === ext) {
127 r.download = r.download.replace(/\.tar\.gz$/, '.tar.xz');
129 all.releases.push(JSON.parse(JSON.stringify(r)));
130 r.download = r.download.replace(/\.tar\.xz$/, '.tar.gz');
139 module.exports = getAllReleases;
141 if (module === require.main) {
142 getAllReleases(require('@root/request')).then(function (all) {
143 all = require('../_webi/normalize.js')(all);
144 console.info(JSON.stringify(all));
145 //console.info(JSON.stringify(all, null, 2));