3 // this may need customizations between packages
5 macos: /(\b|_)(apple|os\s?x\b|mac|darwin|iPhone|iOS|iPad)/i,
6 linux: /(\b|_)(linux)/i,
7 freebsd: /(\b|_)(freebsd)/i,
8 windows: /(\b|_)(win|microsoft|msft)/i,
19 Object.keys(osMap).forEach(function (name) {
20 maps.oses[name] = true;
23 var formats = ['zip', 'xz', 'tar', 'pkg', 'msi', 'git', 'exe', 'dmg'];
24 formats.forEach(function (name) {
25 maps.formats[name] = true;
28 // evaluation order matters
29 // (i.e. otherwise x86 and x64 can cross match)
31 'amd64', // first and most likely match
41 amd64: /(amd.?64|x64|[_\-]64)/i,
43 ppc64le: /(\b|_)(ppc64le)/i,
44 ppc64: /(\b|_)(ppc64)(\b|_)/i,
45 arm64: /(\b|_)(arm64|arm)/i,
46 armv7l: /(\b|_)(armv?7l)/i,
47 armv6l: /(\b|_)(armv?6l)/i,
48 s390x: /(\b|_)(s390x)/i
50 arches.forEach(function (name) {
51 maps.arches[name] = true;
54 function normalize(all) {
61 all.releases.forEach(function (rel) {
62 rel.version = rel.version.replace(/^v/i, '');
64 rel.name = rel.download.replace(/.*\//, '');
68 Object.keys(osMap).find(function (regKey) {
69 return osMap[regKey].test(rel.name || rel.download);
72 supported.oses[rel.os] = true;
75 arches.some(function (regKey) {
76 var arch = (rel.name || rel.download).match(archMap[regKey]) && regKey;
83 supported.arches[rel.arch] = true;
86 // pkg-v1.0.tar.gz => ['gz', 'tar', '0', 'pkg-v1']
87 // pkg-v1.0.tar => ['tar', '0' ,'pkg-v1']
88 // pkg-v1.0.zip => ['zip', '0', 'pkg-v1']
89 var exts = (rel.name || rel.download).split('.').reverse().slice(0, 2);
91 if ('tar' === exts[1]) {
92 rel.ext = exts.reverse().join('.');
93 } else if ('tgz' == exts[0]) {
99 supported.formats[rel.ext] = true;
102 rel.download = all.download.replace(/{{ download }}/, rel.download);
106 all.oses = Object.keys(supported.oses).filter(function (name) {
107 return maps.oses[name];
109 all.arches = Object.keys(supported.arches).filter(function (name) {
110 return maps.arches[name];
112 all.formats = Object.keys(supported.formats).filter(function (name) {
113 return maps.formats[name];
119 module.exports = normalize;
120 // NOT in order of priority (which would be tar, xz, zip, ...)
121 module.exports.formats = formats;
122 module.exports.arches = arches;
123 module.exports.formatsMap = maps.formats;