The Node.js® Website
at main 2.9 kB view raw
1'use strict'; 2 3import semVer from 'semver'; 4 5const downloadOptions = [ 6 { 7 title: 'Windows 32-bit Installer', 8 templateUrl: 'https://nodejs.org/dist/v%version%/node-v%version%-x86.msi', 9 }, 10 { 11 title: 'Windows 64-bit Installer', 12 templateUrl: 'https://nodejs.org/dist/v%version%/node-v%version%-x64.msi', 13 }, 14 { 15 title: 'Windows ARM 64-bit Installer', 16 templateUrl: 'https://nodejs.org/dist/v%version%/node-v%version%-arm64.msi', 17 }, 18 { 19 title: 'Windows 32-bit Binary', 20 templateUrl: 'https://nodejs.org/dist/v%version%/win-x86/node.exe', 21 }, 22 { 23 title: 'Windows 64-bit Binary', 24 templateUrl: 'https://nodejs.org/dist/v%version%/win-x64/node.exe', 25 }, 26 { 27 title: 'Windows ARM 64-bit Binary', 28 templateUrl: 'https://nodejs.org/dist/v%version%/win-arm64/node.exe', 29 }, 30 { 31 title: 'macOS 64-bit Installer', 32 templateUrl: 'https://nodejs.org/dist/v%version%/node-v%version%.pkg', 33 }, 34 { 35 title: 'macOS Apple Silicon 64-bit Binary', 36 templateUrl: 37 'https://nodejs.org/dist/v%version%/node-v%version%-darwin-arm64.tar.gz', 38 }, 39 { 40 title: 'macOS Intel 64-bit Binary', 41 templateUrl: 42 'https://nodejs.org/dist/v%version%/node-v%version%-darwin-x64.tar.gz', 43 }, 44 { 45 title: 'Linux 64-bit Binary', 46 templateUrl: 47 'https://nodejs.org/dist/v%version%/node-v%version%-linux-x64.tar.xz', 48 }, 49 { 50 title: 'Linux PPC LE 64-bit Binary', 51 templateUrl: 52 'https://nodejs.org/dist/v%version%/node-v%version%-linux-ppc64le.tar.xz', 53 }, 54 { 55 title: 'Linux s390x 64-bit Binary', 56 templateUrl: 57 'https://nodejs.org/dist/v%version%/node-v%version%-linux-s390x.tar.xz', 58 }, 59 { 60 title: 'AIX 64-bit Binary', 61 templateUrl: 62 'https://nodejs.org/dist/v%version%/node-v%version%-aix-ppc64.tar.gz', 63 }, 64 { 65 title: 'ARMv7 32-bit Binary', 66 templateUrl: 67 'https://nodejs.org/dist/v%version%/node-v%version%-linux-armv7l.tar.xz', 68 }, 69 { 70 title: 'ARMv8 64-bit Binary', 71 templateUrl: 72 'https://nodejs.org/dist/v%version%/node-v%version%-linux-arm64.tar.xz', 73 }, 74 { 75 title: 'Source Code', 76 templateUrl: 'https://nodejs.org/dist/v%version%/node-v%version%.tar.gz', 77 }, 78]; 79 80const resolveUrl = (item, version) => { 81 const url = item.templateUrl.replace(/%version%/g, version); 82 return Object.assign({ url }, item); 83}; 84 85const resolveDownloads = version => { 86 let downloads = downloadOptions; 87 88 if (semVer.satisfies(version, '< 16.0.0')) { 89 downloads = downloads.filter( 90 ver => ver.title !== 'macOS Apple Silicon 64-bit Binary' 91 ); 92 } 93 94 if (semVer.satisfies(version, '< 19.9.0')) { 95 downloads = downloads.filter( 96 ver => 97 ver.title !== 'Windows ARM 64-bit Installer' && 98 ver.title !== 'Windows ARM 64-bit Binary' 99 ); 100 } 101 102 return downloads; 103}; 104 105export const downloadsTable = version => 106 resolveDownloads(version).map(item => resolveUrl(item, version));