mirror of
https://github.com/webinstall/webi-installers.git
synced 2026-08-19 12:06:25 +00:00
better error handling when vailable formats mismatch
This commit is contained in:
@@ -46,6 +46,8 @@ if [ -n "\$(command -v unxz)" ]; then
|
||||
fi
|
||||
if [ -n "\$(command -v unzip)" ]; then
|
||||
my_ext="zip,\$my_ext"
|
||||
else
|
||||
echo "WARN: 'unzip' not found"
|
||||
fi
|
||||
if [ -n "\$(command -v tar)" ]; then
|
||||
my_ext="tar,\$my_ext"
|
||||
|
||||
+19
-1
@@ -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;
|
||||
|
||||
+13
-1
@@ -18,6 +18,12 @@ Releases.renderBash = function (
|
||||
rel,
|
||||
{ baseurl, pkg, tag, ver, os, arch, formats }
|
||||
) {
|
||||
if (!Array.isArray(formats)) {
|
||||
formats = [];
|
||||
}
|
||||
if (!tag) {
|
||||
tag = '';
|
||||
}
|
||||
return fs.promises
|
||||
.readFile(path.join(pkgdir, 'install.sh'), 'utf8')
|
||||
.then(function (installTxt) {
|
||||
@@ -40,7 +46,7 @@ Releases.renderBash = function (
|
||||
.replace(/^#?WEBI_HOST=.*/m, "WEBI_HOST='" + baseurl + "'")
|
||||
.replace(/^#?WEBI_OS=.*/m, "WEBI_OS='" + (os || '') + "'")
|
||||
.replace(/^#?WEBI_ARCH=.*/m, "WEBI_ARCH='" + (arch || '') + "'")
|
||||
.replace(/^#?WEBI_TAG=.*/m, "WEBI_TAG='" + (tag || '') + "'")
|
||||
.replace(/^#?WEBI_TAG=.*/m, "WEBI_TAG='" + tag + "'")
|
||||
.replace(
|
||||
/^#?WEBI_RELEASES=.*/m,
|
||||
"WEBI_RELEASES='" +
|
||||
@@ -53,6 +59,8 @@ Releases.renderBash = function (
|
||||
rel.os +
|
||||
'&arch=' +
|
||||
rel.arch +
|
||||
'&formats=' +
|
||||
formats.join(',') +
|
||||
'&pretty=true' +
|
||||
"'"
|
||||
)
|
||||
@@ -90,6 +98,10 @@ Releases.renderBash = function (
|
||||
/^#?WEBI_EXT=.*/m,
|
||||
'WEBI_EXT=' + rel.ext.replace(/tar.*/, 'tar')
|
||||
)
|
||||
.replace(
|
||||
/^#?WEBI_FORMATS=.*/m,
|
||||
"WEBI_FORMATS='" + formats.join(',') + "'"
|
||||
)
|
||||
.replace(
|
||||
/^#?WEBI_PKG_URL=.*/m,
|
||||
"WEBI_PKG_URL='" + rel.download + "'"
|
||||
|
||||
@@ -22,6 +22,7 @@ set -u
|
||||
#WEBI_LTS=
|
||||
#WEBI_CHANNEL=
|
||||
#WEBI_EXT=
|
||||
#WEBI_FORMATS=
|
||||
#WEBI_PKG_URL=
|
||||
#WEBI_PKG_FILE=
|
||||
WEBI_UA="$(uname -a)"
|
||||
@@ -128,6 +129,12 @@ webi_download() {
|
||||
# TODO pass back requested OS / Arch / Version
|
||||
echo "Error: no '$WEBI_NAME' release found for the given OS and architecture by that tag or version"
|
||||
echo " (check that the package name and version are correct)"
|
||||
echo "See $WEBI_RELEASES"
|
||||
echo " WEBI_PKG=$WEBI_PKG"
|
||||
echo " WEBI_NAME=$WEBI_NAME"
|
||||
echo " WEBI_VERSION=$WEBI_VERSION"
|
||||
echo " WEBI_EXT=$WEBI_EXT"
|
||||
echo " WEBI_FORMATS=$WEBI_FORMATS"
|
||||
exit 1
|
||||
fi
|
||||
my_url="$WEBI_PKG_URL"
|
||||
|
||||
Reference in New Issue
Block a user