X-Git-Url: https://git.josue.xyz/?a=blobdiff_plain;f=_webi%2Fnormalize.js;h=5fa9abb5895f3a04421ff287469d0a46518e3f0a;hb=ef1b4f03c8ab628f08db39d658c4425c2b5af8de;hp=06c1ceec81e5f6043008698722a53cee60e344c0;hpb=debcee7e199579466159d9e4fc3b0038ae5f0d20;p=webi-installers%2F.git diff --git a/_webi/normalize.js b/_webi/normalize.js index 06c1cee..5fa9abb 100644 --- a/_webi/normalize.js +++ b/_webi/normalize.js @@ -39,7 +39,8 @@ var arches = [ ]; var archMap = { //amd64: /(amd.?64|x64|[_\-]64)/i, - amd64: /(\b|_|amd|(dar)?win(dows)?|mac(os)?|linux|osx|x)64([_\-]?bit)?(\b|_)/i, + amd64: + /(\b|_|amd|(dar)?win(dows)?|mac(os)?|linux|osx|x)64([_\-]?bit)?(\b|_)/i, //x86: /(86)(\b|_)/i, x86: /(\b|_|amd|(dar)?win(dows)?|mac(os)?|linux|osx|x)(86|32)([_\-]?bit)(\b|_)/i, ppc64le: /(\b|_)(ppc64le)/i, @@ -71,6 +72,13 @@ function normalize(all) { return osMap[regKey].test(rel.name || rel.download); }) || 'unknown'; } + // Hacky-doo for musl + // TODO some sort of glibc vs musl tag? + if (!rel._musl) { + if (/(\b|\.|_|-)(musl)(\b|\.|_|-)/.test(rel.download)) { + rel._musl = true; + } + } supported.oses[rel.os] = true; if (!rel.arch) { @@ -80,10 +88,16 @@ function normalize(all) { rel.arch = arch; return true; } - })[0]; + }); + } + if (!rel.arch) { + if ('macos' === rel.os) { + rel.arch = 'amd64'; + } } supported.arches[rel.arch] = true; + var tarExt; if (!rel.ext) { // pkg-v1.0.tar.gz => ['gz', 'tar', '0', 'pkg-v1'] // pkg-v1.0.tar => ['tar', '0' ,'pkg-v1'] @@ -96,8 +110,10 @@ function normalize(all) { exts = exts.reverse().slice(0, 2); if ('tar' === exts[1]) { rel.ext = exts.reverse().join('.'); - } else if ('tgz' == exts[0]) { + tarExt = 'tar'; + } else if ('tgz' === exts[0]) { rel.ext = 'tar.gz'; + tarExt = 'tar'; } else { rel.ext = exts[0]; } @@ -106,7 +122,7 @@ function normalize(all) { rel.ext = 'exe'; } } - supported.formats[rel.ext] = true; + supported.formats[tarExt || rel.ext] = true; if (all.download) { rel.download = all.download.replace(/{{ download }}/, rel.download); @@ -127,6 +143,15 @@ function normalize(all) { } module.exports = normalize; +module.exports._debug = function (all) { + all = normalize(all); + all.releases = all.releases + .filter(function (r) { + return ['windows', 'macos', 'linux'].includes(r.os) && 'amd64' === r.arch; + }) + .slice(0, 10); + return all; +}; // NOT in order of priority (which would be tar, xz, zip, ...) module.exports.formats = formats; module.exports.arches = arches;