'use strict'; var brewReleases = require('../_common/brew.js'); module.exports = function (request) { // So many places to get (incomplete) release info... // // MariaDB official // - https://downloads.mariadb.org/mariadb/+releases/ // - http://archive.mariadb.org/ // Brew // - https://formulae.brew.sh/api/formula/mariadb@10.3.json // - https://formulae.brew.sh/docs/api/ // - https://formulae.brew.sh/formula/mariadb@10.2#default // // Note: This could be very fragile due to using the html // as an API. It's pretty rather than minified, but that // doesn't guarantee that it's meant as a consumable API. // var promises = [mariaReleases(), brewReleases(request, 'mariadb')]; return Promise.all(promises).then(function (many) { var versions = many[0]; var brews = many[1]; var all = { download: '', releases: [] }; // linux x86 // linux x64 // windows x86 // windows x64 // (and mac, wedged-in from Homebrew) versions.forEach(function (ver) { all.releases.push({ version: ver.version, lts: false, channel: ver.channel, date: ver.date, os: 'linux', arch: 'amd64', download: 'http://archive.mariadb.org/mariadb-{{ v }}/bintar-linux-x86_64/mariadb-{{ v }}-linux-x86_64.tar.gz'.replace( /{{ v }}/g, ver.version, ), }); all.releases.push({ version: ver.version, lts: false, channel: ver.channel, date: ver.date, os: 'linux', arch: 'amd64', download: 'http://archive.mariadb.org/mariadb-{{ v }}/bintar-linux-x86/mariadb-{{ v }}-linux-x86.tar.gz'.replace( /{{ v }}/g, ver.version, ), }); // windows all.releases.push({ version: ver.version, lts: false, channel: ver.channel, date: ver.date, os: 'windows', arch: 'amd64', download: 'http://archive.mariadb.org/mariadb-{{ v }}/winx64-packages/mariadb-{{ v }}-winx64.zip'.replace( /{{ v }}/g, ver.version, ), }); all.releases.push({ version: ver.version, lts: false, channel: ver.channel, date: ver.date, os: 'windows', arch: 'x86', download: 'http://archive.mariadb.org/mariadb-{{ v }}/win32-packages/mariadb-{{ v }}-win32.zip'.replace( /{{ v }}/g, ver.version, ), }); // Note: versions are sorted most-recent first. // We just assume that the brew version is most recent stable // ... but we can't really know for sure // TODO brews.some(function (brew, i) { // 10.3 => ^10.2(\b|\.) var reBrewVer = new RegExp( '^' + brew.version.replace(/\./, '\\.') + '(\\b|\\.)', 'g', ); if (!ver.version.match(reBrewVer)) { return; } all.releases.push({ version: ver.version, lts: false, channel: ver.channel, date: ver.date, os: 'macos', arch: 'amd64', download: brew.download.replace(/{{ v }}/g, ver.version), }); brews.splice(i, 1); // remove return true; }); }); return all; }); function mariaReleases() { return request({ url: 'https://downloads.mariadb.org/mariadb/+releases/', fail: true, // https://git.coolaj86.com/coolaj86/request.js/issues/2 }) .then(failOnBadStatus) .then(function (resp) { // fragile, but simple // Make release info go from this: var html = resp.body; // //