X-Git-Url: https://git.josue.xyz/?a=blobdiff_plain;f=_webi%2Fnormalize.js;h=16c60b80dfda711bf00011942e3137548e2b2dc6;hb=ef49c0287cc890f1394ddbbb192e9a98c0a53759;hp=dac09020a7f4473ebfd917ecf3144bb3a0ac1791;hpb=5dfce0406c11350465b6004a336d63614f2103a1;p=webi-installers%2F.git diff --git a/_webi/normalize.js b/_webi/normalize.js index dac0902..16c60b8 100644 --- a/_webi/normalize.js +++ b/_webi/normalize.js @@ -1,7 +1,7 @@ 'use strict'; // this may need customizations between packages -const osMap = { +var osMap = { macos: /(\b|_)(apple|mac|darwin|iPhone|iOS|iPad)/i, linux: /(\b|_)(linux)/i, freebsd: /(\b|_)(freebsd)/i, @@ -10,6 +10,12 @@ const osMap = { aix: /(\b|_)(aix)/i }; +var formats = ['zip', 'xz', 'tar', 'pkg', 'msi', 'git', 'exe', 'dmg']; +var formatsMap = {}; +formats.forEach(function (ext) { + formatsMap[ext] = true; +}); + // evaluation order matters // (i.e. otherwise x86 and x64 can cross match) var archArr = [ @@ -34,7 +40,10 @@ var archMap = { }; function normalize(all) { + var supportedFormats = {}; + all.releases.forEach(function (rel) { + supportedFormats[rel.ext] = true; rel.version = rel.version.replace(/^v/i, ''); if (!rel.name) { rel.name = rel.download.replace(/.*\//, ''); @@ -85,7 +94,16 @@ function normalize(all) { rel.download = all.download.replace(/{{ download }}/, rel.download); } }); + + all.formats = Object.keys(supportedFormats).filter(function (ext) { + return formatsMap[ext]; + }); + return all; } module.exports = normalize; +// NOT in order of priority (which would be tar, xz, zip, ...) +module.exports.formats = formats; +module.exports.arches = archArr; +module.exports.formatsMap = formatsMap;