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"
'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,
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 = [
};
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(/.*\//, '');
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;
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) {
.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='" +
rel.os +
'&arch=' +
rel.arch +
+ '&formats=' +
+ formats.join(',') +
'&pretty=true' +
"'"
)
/^#?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 + "'"
#WEBI_LTS=
#WEBI_CHANNEL=
#WEBI_EXT=
+#WEBI_FORMATS=
#WEBI_PKG_URL=
#WEBI_PKG_FILE=
WEBI_UA="$(uname -a)"
# 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"