Compare commits

..

2 Commits

Author SHA1 Message Date
AJ ONeal
6859ab4c2b feat: add sshd / sshd-service-install 2024-09-13 08:32:31 +00:00
AJ ONeal
f216ab69b4 WIP: sshd 2024-09-13 08:32:30 +00:00
182 changed files with 1788 additions and 5170 deletions

21
.gitignore vendored
View File

@@ -1,24 +1,7 @@
# generated artifacts
.env
node_modules
install-*.sh
install-*.bat
install-*.ps1
# local config
.env.*
*.env
.env
!example.env
# caches
_cache/
node_modules/
# temporary & backup files
.*.sw*
*.bak
*.bak.*
# other
.DS_Store
desktop.ini
.directory

View File

@@ -1,7 +1,4 @@
{
"globals": {
"AbortController": false
},
"browser": true,
"node": true,
"esversion": 11,

View File

@@ -145,8 +145,8 @@ It looks like this:
`releases.js`:
```js
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
// if you need to do something special, you can do it here
// ...
return all;

View File

@@ -1,62 +1,64 @@
'use strict';
let Fetcher = require('../_common/fetcher.js');
/**
* Gets releases from 'brew'.
* Gets a releases from 'brew'.
*
* @param {null} _
* @param request
* @param {string} formula
* @returns {Promise<any>}
* @returns {PromiseLike<any> | Promise<any>}
*/
async function getDistributables(_, formula) {
function getAllReleases(request, formula) {
if (!formula) {
return Promise.reject('missing formula for brew');
}
let resp;
try {
let url = `https://formulae.brew.sh/api/formula/${formula}.json`;
resp = await Fetcher.fetch(url, {
headers: { Accept: 'application/json' },
});
} catch (e) {
/** @type {Error & { code: string, response: { status: number, body: string } }} */ //@ts-expect-error
let err = e;
if (err.code === 'E_FETCH_RELEASES') {
err.message = `failed to fetch '${formula}' release data from 'brew': ${err.response.status} ${err.response.body}`;
}
throw e;
}
let body = JSON.parse(resp.body);
var ver = body.versions.stable;
var dl = (
body.bottle.stable.files.high_sierra || body.bottle.stable.files.catalina
).url.replace(new RegExp(ver.replace(/\./g, '\\.'), 'g'), '{{ v }}');
return [
{
version: ver,
download: dl.replace(/{{ v }}/g, ver),
},
].concat(
body.versioned_formulae.map(
/** @param {String} f */
function (f) {
var ver = f.replace(/.*@/, '');
return {
return request({
url: 'https://formulae.brew.sh/api/formula/' + formula + '.json',
fail: true, // https://git.coolaj86.com/coolaj86/request.js/issues/2
json: true,
})
.then(failOnBadStatus)
.then(function (resp) {
var ver = resp.body.versions.stable;
var dl = (
resp.body.bottle.stable.files.high_sierra ||
resp.body.bottle.stable.files.catalina
).url.replace(new RegExp(ver.replace(/\./g, '\\.'), 'g'), '{{ v }}');
return [
{
version: ver,
download: dl,
};
},
),
);
download: dl.replace(/{{ v }}/g, ver),
},
].concat(
resp.body.versioned_formulae.map(function (f) {
var ver = f.replace(/.*@/, '');
return {
version: ver,
download: dl,
};
}),
);
})
.catch(function (err) {
console.error('Error fetching MariaDB versions (brew)');
console.error(err);
return [];
});
}
module.exports = getDistributables;
function failOnBadStatus(resp) {
if (resp.statusCode >= 400) {
var err = new Error('Non-successful status code: ' + resp.statusCode);
err.code = 'ESTATUS';
err.response = resp;
throw err;
}
return resp;
}
module.exports = getAllReleases;
if (module === require.main) {
getDistributables(null, 'mariadb').then(function (all) {
getAllReleases(require('@root/request'), 'mariadb').then(function (all) {
console.info(JSON.stringify(all, null, 2));
});
}

View File

@@ -1,56 +0,0 @@
'use strict';
let Fetcher = module.exports;
/**
* @typedef ResponseSummary
* @prop {Boolean} ok
* @prop {Headers} headers
* @prop {Number} status
* @prop {String} body
*/
/**
* @param {String} url
* @param {RequestInit} opts
* @returns {Promise<ResponseSummary>}
*/
Fetcher.fetch = async function (url, opts) {
let resp = await fetch(url, opts);
let summary = Fetcher.throwIfNotOk(resp);
return summary;
};
/**
* @param {Response} resp
* @returns {Promise<ResponseSummary>}
*/
Fetcher.throwIfNotOk = async function (resp) {
let text = await resp.text();
if (!resp.ok) {
let headers = Array.from(resp.headers);
console.error('[Fetcher] error: Response Headers:', headers);
console.error('[Fetcher] error: Response Text:', text);
let err = new Error(`fetch was not ok`);
Object.assign({
status: 503,
code: 'E_FETCH_RELEASES',
response: {
status: resp.status,
headers: headers,
body: text,
},
});
throw err;
}
let summary = {
ok: resp.ok,
headers: resp.headers,
status: resp.status,
body: text,
};
return summary;
};

View File

@@ -115,7 +115,7 @@ Repos.getCommitInfo = async function (repoPath, commitish) {
* @param {string} gitUrl
* @returns {PromiseLike<any> | Promise<any>}
*/
async function getDistributables(gitUrl) {
async function getAllReleases(gitUrl) {
let all = {
releases: [],
download: '',
@@ -190,7 +190,7 @@ async function getDistributables(gitUrl) {
return all;
}
module.exports = getDistributables;
module.exports = getAllReleases;
if (module === require.main) {
(async function main() {
@@ -203,7 +203,7 @@ if (module === require.main) {
//'https://github.com/dense-analysis/ale.git',
];
for (let url of testRepos) {
let all = await getDistributables(url);
let all = await getAllReleases(url);
all = require('../_webi/normalize.js')(all);
console.info(JSON.stringify(all, null, 2));

View File

@@ -5,15 +5,15 @@ var GitHubish = require('./githubish.js');
/**
* Lists Gitea Releases (w/ uploaded assets)
*
* @param {null} _ - deprecated
* @param {any} _request - deprecated
* @param {String} owner
* @param {String} repo
* @param {String} baseurl
* @param {String} [username]
* @param {String} [token]
*/
async function getDistributables(
_,
async function getAllReleases(
_request,
owner,
repo,
baseurl,
@@ -21,7 +21,7 @@ async function getDistributables(
token = '',
) {
baseurl = `${baseurl}/api/v1`;
let all = await GitHubish.getDistributables({
let all = await GitHubish.getAllReleases({
owner,
repo,
baseurl,
@@ -31,17 +31,20 @@ async function getDistributables(
return all;
}
module.exports = getDistributables;
module.exports = getAllReleases;
if (module === require.main) {
getDistributables(
getAllReleases(
null,
'root',
'pathman',
'https://git.rootprojects.org',
'',
'',
).then(function (all) {
console.info(JSON.stringify(all, null, 2));
});
).then(
//getAllReleases(require('@root/request'), 'root', 'serviceman', 'https://git.rootprojects.org').then(
function (all) {
console.info(JSON.stringify(all, null, 2));
},
);
}

View File

@@ -1,40 +1,133 @@
'use strict';
require('dotenv').config({ path: '.env' });
let GitHubSource = module.exports;
let GitHubishSource = require('./githubish-source.js');
require('dotenv').config();
/**
* @param {Object} opts
* @param {String} opts.owner
* @param {String} opts.repo
* @param {String} [opts.baseurl]
* @param {String} [opts.username]
* @param {String} [opts.token]
* Gets the releases for 'ripgrep'. This function could be trimmed down and made
* for use with any github release.
*
* @param request
* @param {string} owner
* @param {string} repo
* @returns {PromiseLike<any> | Promise<any>}
*/
GitHubSource.getDistributables = async function ({
async function getAllReleases(
request,
owner,
repo,
oses,
arches,
baseurl = 'https://api.github.com',
username = process.env.GITHUB_USERNAME || '',
token = process.env.GITHUB_TOKEN || '',
}) {
let all = await GitHubishSource.getDistributables({
owner,
repo,
baseurl,
username,
token,
});
) {
if (!owner) {
return Promise.reject('missing owner for repo');
}
if (!repo) {
return Promise.reject('missing repo name');
}
let req = {
url: `${baseurl}/repos/${owner}/${repo}/releases`,
json: true,
};
// TODO I really don't like global config, find a way to do better
if (process.env.GITHUB_USERNAME) {
req.auth = {
user: process.env.GITHUB_USERNAME,
pass: process.env.GITHUB_TOKEN,
};
}
let resp = await request(req);
let gHubResp = resp.body;
let all = {
releases: [],
// TODO make this ':baseurl' + ':releasename'
download: '',
};
for (let release of gHubResp) {
// TODO tags aren't always semver / sensical
let tag = release['tag_name'];
let lts = /(\b|_)(lts)(\b|_)/.test(release['tag_name']);
let channel = 'stable';
if (release['prerelease']) {
channel = 'beta';
}
let date = release['published_at'] || '';
date = date.replace(/T.*/, '');
let urls = [release.tarball_url, release.zipball_url];
for (let url of urls) {
let resp = await request({
method: 'HEAD',
followRedirect: true,
followAllRedirects: true,
followOriginalHttpMethod: true,
url: url,
stream: true,
});
// Workaround for bug where method changes to GET
resp.destroy();
// content-disposition: attachment; filename=BeyondCodeBootcamp-DuckDNS.sh-v1.0.1-0-ga2f4bde.zip
let name = resp.headers['content-disposition'].replace(
/.*filename=([^;]+)(;|$)/,
'$1',
);
all.releases.push({
name: name,
version: tag,
lts: lts,
channel: channel,
date: date,
os: '', // will be guessed by download filename
arch: '', // will be guessed by download filename
ext: '', // will be normalized
download: resp.request.uri.href,
});
}
}
if (oses) {
return combinate(all, oses, arches);
}
return all;
};
}
function combinate(all, oses, arches) {
let releases = all.releases;
// ex: arches = ['amd64', 'arm64', 'armv7l', 'armv6l', 'x86'];
// ex: oses = ['macos', 'linux', 'bsd', 'posix'];
let combos = [];
for (let release of releases) {
for (let arch of arches) {
for (let os of oses) {
let combo = {
arch: arch,
os: os,
};
let rel = Object.assign({}, release, combo);
combos.push(rel);
}
}
}
all.releases = combos;
return all;
}
module.exports = getAllReleases;
if (module === require.main) {
GitHubSource.getDistributables(null, 'BeyondCodeBootcamp', 'DuckDNS.sh').then(
function (all) {
console.info(JSON.stringify(all, null, 2));
},
);
getAllReleases(
require('@root/request'),
'BeyondCodeBootcamp',
'DuckDNS.sh',
).then(function (all) {
console.info(JSON.stringify(all, null, 2));
});
}

View File

@@ -7,22 +7,22 @@ let GitHubish = require('./githubish.js');
/**
* Lists GitHub Releases (w/ uploaded assets)
*
* @param {null} _ - deprecated
* @param {any} _request - deprecated
* @param {String} owner
* @param {String} repo
* @param {String} [baseurl]
* @param {String} [username]
* @param {String} [token]
*/
module.exports = async function (
_,
async function getAllReleases(
_request,
owner,
repo,
baseurl = 'https://api.github.com',
username = process.env.GITHUB_USERNAME || '',
token = process.env.GITHUB_TOKEN || '',
) {
let all = await GitHubish.getDistributables({
let all = await GitHubish.getAllReleases({
owner,
repo,
baseurl,
@@ -30,13 +30,12 @@ module.exports = async function (
token,
});
return all;
};
}
let GitHub = module.exports;
GitHub.getDistributables = module.exports;
module.exports = getAllReleases;
if (module === require.main) {
GitHub.getDistributables(null, 'BurntSushi', 'ripgrep').then(function (all) {
getAllReleases(null, 'BurntSushi', 'ripgrep').then(function (all) {
console.info(JSON.stringify(all, null, 2));
});
}

View File

@@ -1,174 +0,0 @@
'use strict';
let Fetcher = require('../_common/fetcher.js');
let GitHubishSource = module.exports;
/**
* Lists GitHub-Like Releases (source tarball & zip)
*
* @param {Object} opts
* @param {String} opts.owner
* @param {String} opts.repo
* @param {String} opts.baseurl
* @param {String} [opts.username]
* @param {String} [opts.token]
*/
GitHubishSource.getDistributables = async function ({
owner,
repo,
baseurl,
username = '',
token = '',
}) {
if (!owner) {
throw new Error('missing owner for repo');
}
if (!repo) {
throw new Error('missing repo name');
}
if (!baseurl) {
throw new Error('missing baseurl');
}
let url = `${baseurl}/repos/${owner}/${repo}/releases`;
let opts = {
headers: {
'Content-Type': 'appplication/json',
},
};
if (token) {
let userpass = `${username}:${token}`;
let basicAuth = btoa(userpass);
Object.assign(opts.headers, {
Authorization: `Basic ${basicAuth}`,
});
}
let resp;
try {
resp = await Fetcher.fetch(url, opts);
} catch (e) {
/** @type {Error & { code: string, response: { status: number, body: string } }} */ //@ts-expect-error
let err = e;
if (err.code === 'E_FETCH_RELEASES') {
err.message = `failed to fetch '${baseurl}' (githubish-source, user '${username}) release data: ${err.response.status} ${err.response.body}`;
}
throw e;
}
let gHubResp = JSON.parse(resp.body);
let all = {
/** @type {Array<BuildInfo>} */
releases: [],
download: '',
};
for (let release of gHubResp) {
let dists = GitHubishSource.releaseToDistributables(release);
for (let dist of dists) {
let updates =
await GitHubishSource.followDistributableDownloadAttachment(dist);
Object.assign(dist, updates);
all.releases.push(dist);
}
}
return all;
};
/**
* @typedef BuildInfo
* @prop {String} [name] - name to use instead of filename for hash urls
* @prop {String} version
* @prop {String} [_version]
* @prop {String} [arch]
* @prop {String} channel
* @prop {String} date
* @prop {String} download
* @prop {String} [ext]
* @prop {String} [_filename]
* @prop {String} [hash]
* @prop {String} [libc]
* @prop {Boolean} [_musl]
* @prop {Boolean} [lts]
* @prop {String} [size]
* @prop {String} os
*/
/**
* @param {any} ghRelease - TODO
* @returns {Array<BuildInfo>}
*/
GitHubishSource.releaseToDistributables = function (ghRelease) {
let ghTag = ghRelease['tag_name']; // TODO tags aren't always semver / sensical
let lts = /(\b|_)(lts)(\b|_)/.test(ghRelease['tag_name']);
let channel = 'stable';
if (ghRelease['prerelease']) {
channel = 'beta';
}
let date = ghRelease['published_at'] || '';
date = date.replace(/T.*/, '');
let urls = [ghRelease.tarball_url, ghRelease.zipball_url];
/** @type {Array<BuildInfo>} */
let dists = [];
for (let url of urls) {
dists.push({
name: '',
version: ghTag,
lts: lts,
channel: channel,
date: date,
os: '*',
arch: '*',
libc: '',
ext: '',
download: url,
});
}
return dists;
};
/**
* @param {BuildInfo} dist
*/
GitHubishSource.followDistributableDownloadAttachment = async function (dist) {
let abortCtrl = new AbortController();
let resp = await fetch(dist.download, {
method: 'HEAD',
redirect: 'follow',
signal: abortCtrl.signal,
});
let headers = Object.fromEntries(resp.headers);
// Workaround for bug where METHOD changes to GET
abortCtrl.abort();
await resp.text().catch(function (err) {
if (err.name !== 'AbortError') {
throw err;
}
});
// ex: content-disposition: attachment; filename=BeyondCodeBootcamp-DuckDNS.sh-v1.0.1-0-ga2f4bde.zip
// => BeyondCodeBootcamp-DuckDNS.sh-v1.0.1-0-ga2f4bde.zip
let name = headers['content-disposition'].replace(
/.*filename=([^;]+)(;|$)/,
'$1',
);
let download = resp.url;
return { name, download };
};
if (module === require.main) {
GitHubishSource.getDistributables({
owner: 'BeyondCodeBootcamp',
repo: 'DuckDNS.sh',
baseurl: 'https://api.github.com',
}).then(function (all) {
console.info(JSON.stringify(all, null, 2));
});
}

View File

@@ -1,20 +1,5 @@
'use strict';
let Fetcher = require('../_common/fetcher.js');
/**
* @typedef DistributableRaw
* @prop {String} name
* @prop {String} version
* @prop {Boolean} lts
* @prop {String} [channel]
* @prop {String} date
* @prop {String} os
* @prop {String} arch
* @prop {String} ext
* @prop {String} download
*/
let GitHubish = module.exports;
/**
@@ -27,7 +12,7 @@ let GitHubish = module.exports;
* @param {String} [opts.username]
* @param {String} [opts.token]
*/
GitHubish.getDistributables = async function ({
GitHubish.getAllReleases = async function ({
owner,
repo,
baseurl,
@@ -59,21 +44,28 @@ GitHubish.getDistributables = async function ({
});
}
let resp;
try {
resp = await Fetcher.fetch(url, opts);
} catch (e) {
/** @type {Error & { code: string, response: { status: number, body: string } }} */ //@ts-expect-error
let err = e;
if (err.code === 'E_FETCH_RELEASES') {
err.message = `failed to fetch '${baseurl}' (githubish, user '${username}) release data: ${err.response.status} ${err.response.body}`;
}
throw e;
let resp = await fetch(url, opts);
if (!resp.ok) {
let headers = Array.from(resp.headers);
console.error('Bad Resp Headers:', headers);
let text = await resp.text();
console.error('Bad Resp Body:', text);
let msg = `failed to fetch releases from '${baseurl}' with user '${username}'`;
throw new Error(msg);
}
let respText = await resp.text();
let gHubResp;
try {
gHubResp = JSON.parse(respText);
} catch (e) {
console.error('Bad Resp JSON:', respText);
console.error(e.message);
let msg = `failed to parse releases from '${baseurl}' with user '${username}'`;
throw new Error(msg);
}
let gHubResp = JSON.parse(resp.body);
let all = {
/** @type {Array<DistributableRaw>} */
releases: [],
// todo make this ':baseurl' + ':releasename'
download: '',
@@ -82,18 +74,13 @@ GitHubish.getDistributables = async function ({
try {
gHubResp.forEach(transformReleases);
} catch (e) {
/** @type {Error & { code: string, response: { status: number, body: string } }} */ //@ts-expect-error
let err = e;
console.error(err.message);
console.error(e.message);
console.error('Error Headers:', resp.headers);
console.error('Error Body:', resp.body);
let msg = `failed to transform releases from '${baseurl}' with user '${username}'`;
throw new Error(msg);
}
/**
* @param {any} release - TODO
*/
function transformReleases(release) {
for (let asset of release['assets']) {
let name = asset['name'];
@@ -127,7 +114,7 @@ GitHubish.getDistributables = async function ({
};
if (module === require.main) {
GitHubish.getDistributables({
GitHubish.getAllReleases({
owner: 'BurntSushi',
repo: 'ripgrep',
baseurl: 'https://api.github.com',

View File

@@ -12,26 +12,19 @@ var repo = 'ripgrep';
/** **/
/******************************************************************************/
let Releases = module.exports;
Releases.latest = async function () {
let all = await github(null, owner, repo);
return all;
};
Releases.sample = async function () {
let normalize = require('../_webi/normalize.js');
let all = await Releases.latest();
all = normalize(all);
// just select the first 5 for demonstration
all.releases = all.releases.slice(0, 5);
module.exports = async function (request) {
let all = await github(request, owner, repo);
return all;
};
if (module === require.main) {
(async function () {
let samples = await Releases.sample();
console.info(JSON.stringify(samples, null, 2));
let request = require('@root/request');
let normalize = require('../_webi/normalize.js');
let all = await module.exports(request);
all = normalize(all);
// just select the first 5 for demonstration
all.releases = all.releases.slice(0, 5);
console.info(JSON.stringify(all, null, 2));
})();
}

View File

@@ -4,6 +4,7 @@
//var pkg = require('../package.json');
var os = require('os');
//var request = require('@root/request');
//var promisify = require('util').promisify;
//var exec = promisify(require('child_process').exec);
var exec = require('child_process').exec;

View File

@@ -9,6 +9,8 @@ let HostTargets = require('./build-classifier/host-targets.js');
let Lexver = require('./build-classifier/lexver.js');
let Triplet = require('./build-classifier/triplet.js');
let request = require('@root/request');
var ALIAS_RE = /^alias: (\w+)$/m;
var LEGACY_ARCH_MAP = {
@@ -151,7 +153,7 @@ async function getLatestBuilds(Releases, installersDir, cacheDir, name, date) {
}
async function getLatestBuildsInner(Releases, cacheDir, name, date) {
let data = await Releases.latest();
let data = await Releases.latest(request);
if (!date) {
date = new Date();
@@ -398,21 +400,15 @@ BuildsCacher.create = function ({ ALL_TERMS, installers, caches }) {
return;
}
projInfo = await getLatestBuilds(Releases, installersDir, cacheDir, name)
.then(function () {
let latestProjInfo = BuildsCacher.transformAndUpdate(
name,
projInfo,
meta,
date,
bc,
);
bc._caches[name] = latestProjInfo;
})
.catch(function (err) {
console.error(`Fail when fetching latest builds for '${name}'`);
console.error(err);
});
projInfo = await getLatestBuilds(Releases, installersDir, cacheDir, name);
let latestProjInfo = BuildsCacher.transformAndUpdate(
name,
projInfo,
meta,
date,
bc,
);
bc._caches[name] = latestProjInfo;
});
return projInfo;
@@ -598,8 +594,9 @@ BuildsCacher.create = function ({ ALL_TERMS, installers, caches }) {
/**
* @param {ProjectInfo} projInfo
* @param {HostTarget} hostTarget
*/
bc.enumerateLatestVersions = function (projInfo) {
bc.enumerateLatestVersions = function (projInfo, hostTarget) {
let lexPrefix = '';
let matchInfo = Lexver.matchSorted(projInfo.lexvers, lexPrefix);
let verInfo = {
@@ -729,9 +726,9 @@ BuildsCacher.create = function ({ ALL_TERMS, installers, caches }) {
if (hostTarget.os === 'windows') {
oses = ['ANYOS', 'windows'];
} else if (hostTarget.os === 'android') {
oses = ['ANYOS', 'posix_2017', 'posix_2024', 'android', 'linux'];
oses = ['ANYOS', 'posix_2017', 'android', 'linux'];
} else {
oses = ['ANYOS', 'posix_2017', 'posix_2024', hostTarget.os];
oses = ['ANYOS', 'posix_2017', hostTarget.os];
}
let waterfall = HostTargets.WATERFALL[hostTarget.os] || {};

View File

@@ -6,6 +6,8 @@ let Path = require('node:path');
let BuildsCacher = require('./builds-cacher.js');
let Triplet = require('./build-classifier/triplet.js');
let request = require('@root/request');
async function main() {
let projName = process.argv[2];
if (!projName) {
@@ -45,7 +47,7 @@ async function main() {
Releases.latest = Releases;
}
let projInfo = await Releases.latest();
let projInfo = await Releases.latest(request);
// let packages = await Builds.getPackage({ name: projName });
// console.log(packages);

View File

@@ -16,7 +16,7 @@ var BAD_SH_RE = /[<>'"`$\\]/;
Installers.renderBash = async function (
pkgdir,
rel,
{ baseurl, pkg, tag, ver, os = '', arch = '', libc = '', formats },
{ baseurl, pkg, tag, ver, os = '', arch = '', libc = '', formats, latest },
) {
if (!Array.isArray(formats)) {
formats = [];
@@ -99,12 +99,11 @@ Installers.renderBash = async function (
['WEBI_PKG_PATHNAME', pkgFile],
['WEBI_PKG_FILE', pkgFile], // TODO replace with pathname
['PKG_NAME', pkg],
['PKG_STABLE', rel.stable],
['PKG_LATEST', rel.latest],
['PKG_OSES', (rel.oses || []).join(' ')],
['PKG_ARCHES', (rel.arches || []).join(' ')],
['PKG_LIBCS', (rel.libcs || []).join(' ')],
['PKG_FORMATS', (rel.formats || []).join(' ')],
['PKG_LATEST', latest],
];
for (let env of envReplacements) {

View File

@@ -57,7 +57,7 @@ var archMap = {
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|i?386)([_\-]?bit)?(\b|_)/i,
x86: /(\b|_|amd|(dar)?win(dows)?|mac(os)?|linux|osx|x)(86|32)([_\-]?bit)(\b|_)/i,
ppc64le: /(\b|_)(ppc64le)/i,
ppc64: /(\b|_)(ppc64)(\b|_)/i,
s390x: /(\b|_)(s390x)/i,
@@ -211,8 +211,7 @@ function normalize(all) {
// won't match:
// - v1.0beta
// - v1.0-beta1b
let isBetaRe =
/(\b|_)(alpha|beta|dev|developer|prev|preview|rc)(\d+)(\b|_)/;
let isBetaRe = /(\b|_)(preview|rc|beta|alpha)(\d+)(\b|_)/;
let isBeta = isBetaRe.test(rel.name);
if (isBeta) {
rel.channel = 'beta';

View File

@@ -88,7 +88,7 @@ function Get-UserAgent {
IF ($my_arch -eq "AMD64") {
# Because PowerShell is sometimes AMD64 on Windows 10 ARM
# See https://oofhours.com/2020/02/04/powershell-on-windows-10-arm64/
$my_os_arch = (Get-CimInstance -ClassName Win32_OperatingSystem).OSArchitecture
$my_os_arch = wmic os get osarchitecture
# Using -clike because of the trailing newline
IF ($my_os_arch -clike "ARM 64*") {

View File

@@ -27,7 +27,6 @@ __bootstrap_webi() {
#PKG_LIBCS=
#PKG_FORMATS=
#PKG_LATEST=
#PKG_STABLE=
WEBI_PKG_DOWNLOAD=""
WEBI_DOWNLOAD_DIR="${HOME}/Downloads"
if command -v xdg-user-dir > /dev/null; then
@@ -37,7 +36,7 @@ __bootstrap_webi() {
fi
fi
WEBI_PKG_PATH="${WEBI_DOWNLOAD_DIR}/webi/${PKG_NAME:-error}/${WEBI_VERSION:-stable}"
WEBI_PKG_PATH="${WEBI_DOWNLOAD_DIR}/webi/${PKG_NAME:-error}/${WEBI_VERSION:-latest}"
# get the special formatted version
# (i.e. "go is go1.14" while node is "node v12.10.8")
@@ -128,10 +127,7 @@ __bootstrap_webi() {
echo ""
echo " $(t_err "Error: no '${PKG_NAME:-"Unknown Package"}@${WEBI_TAG:-"Unknown Tag"}' release for '${WEBI_OS:-"Unknown OS"}' (${WEBI_LIBC:-"Unknown Libc"}) on '${WEBI_ARCH:-"Unknown CPU"}' as one of '${WEBI_FORMATS:-"Unknown File Type"}'")"
echo ""
echo " Latest Stable: ${PKG_STABLE}"
if test "${PKG_LATEST}" != "${PKG_STABLE}"; then
echo " Next Version: ${PKG_LATEST}"
fi
echo " Latest Version: ${PKG_LATEST}"
echo " CPUs: $PKG_ARCHES"
echo " OSes: $PKG_OSES"
echo " libcs: $PKG_LIBCS"

View File

@@ -70,20 +70,18 @@ InstallerServer.helper = async function ({
console.log(`dbg: Get Project Installer Type for '${projectName}':`);
let proj = await Builds.getProjectType(projectName);
if (proj.type === 'alias') {
console.log(`dbg: alias`, proj);
projectName = proj.detail;
proj = await Builds.getProjectType(projectName); // an alias should never resolve to an alias
}
console.log(`dbg: proj`, proj);
console.log(proj);
let validTypes = ['selfhosted', 'valid'];
let validTypes = ['alias', 'selfhosted', 'valid'];
if (!validTypes.includes(proj.type)) {
let msg = `'${projectName}' doesn't have an installer: '${proj.type}': '${proj.detail}'`;
let err = new Error(msg);
err.code = 'ENOENT';
throw err;
}
if (proj.type === 'alias') {
projectName = proj.detail;
}
let tmplParams = {
pkg: projectName,
@@ -122,7 +120,8 @@ InstallerServer.helper = async function ({
name: projectName,
date: new Date(),
});
let latestVersions = Builds.enumerateLatestVersions(projInfo);
let latest = projInfo.versions[0];
Object.assign(tmplParams, { latest });
//console.log('projInfo', projInfo);
let buildTargetInfo = {
@@ -131,27 +130,12 @@ InstallerServer.helper = async function ({
arches: projInfo.arches,
libcs: projInfo.libcs,
formats: projInfo.formats,
latest: latestVersions.latest,
stable: latestVersions.stable,
};
// TODO .findMatchingPackages() should probably account for this
let hasOs = projInfo.oses.includes(hostTarget.os);
let maybePosix = !hasOs && hostTarget.os !== 'windows';
if (maybePosix) {
let posixes = ['posix_2017', 'posix_2024'];
for (let posixYear of posixes) {
let hasPosix = projInfo.oses.includes(posixYear);
if (hasPosix) {
hasOs = true;
break;
}
}
}
if (!hasOs) {
hasOs = projInfo.oses.includes('ANYOS');
}
if (!hasOs) {
let pkg1 = Object.assign(buildTargetInfo, errPackage);
return [pkg1, tmplParams];

View File

@@ -3,6 +3,7 @@
var Releases = module.exports;
var path = require('path');
var request = require('@root/request');
var _normalize = require('./normalize.js');
var cache = {};
@@ -16,18 +17,14 @@ let installerDir = path.join(__dirname, '..');
Releases.get = async function (pkgdir) {
let get;
try {
get = require(`${pkgdir}/releases.js`);
// TODO update all releases files with module.exports.xxxx = 'foo';
if (!get.latest) {
get.latest = get;
}
get = require(path.join(pkgdir, 'releases.js'));
} catch (e) {
let err = new Error('no releases.js for', pkgdir.split(/[\/\\]+/).pop());
err.code = 'E_NO_RELEASE';
throw err;
}
let all = await get.latest();
let all = await get(request);
return _normalize(all);
};

View File

@@ -1,21 +1,29 @@
'use strict';
let Releases = module.exports;
var githubSource = require('../_common/github-source.js');
var owner = 'BeyondCodeBootcamp';
var repo = 'aliasman';
let GitHubSource = require('../_common/github-source.js');
let owner = 'BeyondCodeBootcamp';
let repo = 'aliasman';
Releases.latest = async function () {
let all = await GitHubSource.getDistributables({ owner, repo });
for (let pkg of all.releases) {
pkg.os = 'posix_2017';
}
return all;
module.exports = function (request) {
let arches = [
'amd64',
'arm64',
'armv6l',
'armv7l',
'ppc64le',
'ppc64',
's390x',
'x86',
];
let oses = ['freebsd', 'linux', 'macos', 'posix'];
return githubSource(request, owner, repo, oses, arches).then(function (all) {
all._names = ['aliasman', 'legacy'];
return all;
});
};
if (module === require.main) {
Releases.latest().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
console.info(JSON.stringify(all, null, 2));
});

View File

@@ -4,15 +4,15 @@ var github = require('../_common/github.js');
var owner = 'mholt';
var repo = 'archiver';
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
all._names = ['archiver', 'arc'];
return all;
});
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
// just select the first 5 for demonstration
all.releases = all.releases.slice(0, 5);

View File

@@ -32,8 +32,8 @@ let targets = {
},
};
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
for (let rel of all.releases) {
let windows32 = rel.name.includes('WindowsX86.');
if (windows32) {
@@ -71,7 +71,7 @@ module.exports = function () {
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
console.info(JSON.stringify(all));
//console.info(JSON.stringify(all, null, 2));

View File

@@ -4,8 +4,8 @@ var github = require('../_common/github.js');
var owner = 'wallix';
var repo = 'awless';
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
// remove checksums and .deb
all.releases = all.releases.filter(function (rel) {
return !/(\.txt)|(\.deb)$/i.test(rel.name);
@@ -15,7 +15,7 @@ module.exports = function () {
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
console.info(JSON.stringify(all));
});

View File

@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
var owner = 'sharkdp';
var repo = 'bat';
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
return all;
});
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
all.releases = all.releases.slice(0, 10);
//console.info(JSON.stringify(all));

View File

@@ -7,13 +7,13 @@ main() { (
chmod a+x ~/.local/bin/brew-update-hourly
echo "Checking for serviceman..."
~/.local/bin/webi serviceman
if ! command -v serviceman > /dev/null; then
"$HOME/.local/bin/webi" serviceman
export PATH="$HOME/.local/bin:$PATH"
serviceman --version
fi
serviceman --version
serviceman add --agent \
env PATH="$PATH" serviceman add --user \
--workdir ~/.local/opt/brew/ \
--name sh.brew.updater -- \
~/.local/bin/brew-update-hourly

View File

@@ -132,7 +132,9 @@ file)
```
3. Add your project to the system launcher, running as the current user
```sh
serviceman add --name 'my-project' --daemon -- \
sudo env PATH="$PATH" \
serviceman add --path="$PATH" --system \
--username "$(whoami)" --name my-project -- \
bun run ./my-project.js
```
4. Restart the logging service
@@ -153,6 +155,6 @@ For **macOS**:
```
3. Add your project to the system launcher, running as the current user
```sh
serviceman add --agent --name 'my-project' -- \
serviceman add --path="$PATH" --user --name my-project -- \
bun run ./my-project.js
```

View File

@@ -4,8 +4,8 @@ var github = require('../_common/github.js');
var owner = 'oven-sh';
var repo = 'bun';
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
all.releases = all.releases
.filter(function (r) {
let isDebug = r.name.includes('-profile');
@@ -18,14 +18,6 @@ module.exports = function () {
return false;
}
let isMusl = r.name.includes('-musl');
if (isMusl) {
r._musl = true;
r.libc = 'musl';
} else if (r.os === 'linux') {
r.libc = 'gnu';
}
return true;
})
.map(function (r) {
@@ -38,7 +30,7 @@ module.exports = function () {
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
// just select the first 5 for demonstration
all.releases = all.releases.slice(0, 5);

View File

@@ -819,10 +819,10 @@ To avoid the nitty-gritty details of `launchd` plist files, you can use
2. Use Serviceman to create a _launchd_ plist file
```sh
my_username="$(id -u -n)"
my_username="$( id -u -n )"
serviceman add --agent --name 'caddy' --workdir ./ -- \
caddy run --envfile ~/.config/caddy/env --config ./Caddyfile --adapter caddyfile
serviceman add --user --name caddy -- \
caddy run --config ./Caddyfile --envfile ~/.config/caddy/env
```
(this will create `~/Library/LaunchAgents/caddy.plist`)
@@ -837,8 +837,8 @@ This process creates a _User-Level_ service in `~/Library/LaunchAgents`. To
create a _System-Level_ service in `/Library/LaunchDaemons/` instead:
```sh
serviceman add --name 'caddy' --workdir ./ --daemon -- \
caddy run --envfile ~/.config/caddy/env --config ./Caddyfile --adapter caddyfile
sudo serviceman add --system --name caddy -- \
caddy run --config ./Caddyfile --envfile ~/.config/caddy/env
```
### How to run Caddy as a Windows Service
@@ -856,7 +856,7 @@ serviceman add --name 'caddy' --workdir ./ --daemon -- \
3. Create a **Startup Registry Entry** with Serviceman.
```sh
serviceman.exe add --name caddy -- \
caddy run --envfile ~/.config/caddy/env --config ./Caddyfile --adapter caddyfile
caddy run --config ./Caddyfile --envfile ~/.config/caddy/env
```
4. You can manage the service directly with Serviceman. For example:
```sh
@@ -901,8 +901,10 @@ See the notes below to run as a **User Service** or use the JSON Config.
```
4. Use Serviceman to create a _systemd_ config file.
```sh
serviceman add --name 'caddy' --daemon -- \
caddy run --envfile ~/.config/caddy/env --config ./Caddyfile --adapter caddyfile
my_username="$( id -u -n )"
sudo env PATH="$PATH" \
serviceman add --system --username "${my_username}" --name caddy -- \
caddy run --config ./Caddyfile --envfile ~/.config/caddy/env
```
(this will create `/etc/systemd/system/caddy.service`)
5. Manage the service with `systemctl` and `journalctl`:
@@ -913,10 +915,10 @@ See the notes below to run as a **User Service** or use the JSON Config.
To create a **User Service** instead:
- use `--agent` when running `serviceman`:
- don't use `sudo`, but do use `--user` when running `serviceman`:
```sh
serviceman add --agent --name caddy -- \
caddy run --envfile ~/.config/caddy/env --config ./Caddyfile --adapter caddyfile
serviceman add --user --name caddy -- \
caddy run --config ./Caddyfile --envfile ~/.config/caddy/env
```
(this will create `~/.config/systemd/user/`)
- user the `--user` flag to manage services and logs:
@@ -1361,13 +1363,19 @@ See also: <https://caddyserver.com/docs/running>
2. Generate the `service` file: \
- JSON Config
```sh
serviceman add --name 'caddy' --daemon -- \
caddy run --resume --envfile ./caddy.env
my_app_user="$( id -u -n )"
sudo env PATH="${PATH}" \
serviceman add --system --cap-net-bind \
--username "${my_app_user}" --name caddy -- \
caddy run --resume --envfile ./caddy.env
```
- Caddyfile
```sh
serviceman add --name 'caddy' --daemon -- \
caddy run --config ./Caddyfile --envfile ./caddy.env
my_app_user="$( id -u -n )"
sudo env PATH="${PATH}" \
serviceman add --system --cap-net-bind \
--username "${my_app_user}" --name caddy -- \
caddy run --config ./Caddyfile --envfile ./caddy.env
```
3. Reload `systemd` config files, the logging service (it may not be started on
a new VPS), and caddy

View File

@@ -4,8 +4,8 @@ var github = require('../_common/github.js');
var owner = 'caddyserver';
var repo = 'caddy';
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
// remove checksums and .deb
all.releases = all.releases.filter(function (rel) {
let isOneOffAsset = rel.download.includes('buildable-artifact');
@@ -20,7 +20,7 @@ module.exports = function () {
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
console.info(JSON.stringify(all));
});

View File

@@ -1,9 +1,7 @@
'use strict';
let Fetcher = require('../_common/fetcher.js');
// See <https://googlechromelabs.github.io/chrome-for-testing/>
const releaseApiUrl =
var releaseApiUrl =
'https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json';
// {
@@ -42,24 +40,14 @@ const releaseApiUrl =
// ]
// }
module.exports = async function () {
let resp;
try {
resp = await Fetcher.fetch(releaseApiUrl, {
headers: { Accept: 'application/json' },
});
} catch (e) {
/** @type {Error & { code: string, response: { status: number, body: string } }} */ //@ts-expect-error
let err = e;
if (err.code === 'E_FETCH_RELEASES') {
err.message = `failed to fetch 'chromedriver' release data: ${err.response.status} ${err.response.body}`;
}
throw e;
}
let data = JSON.parse(resp.body);
module.exports = async function (request) {
let resp = await request({
url: releaseApiUrl,
json: true,
});
let builds = [];
for (let release of data.versions) {
for (let release of resp.body.versions) {
if (!release.downloads.chromedriver) {
continue;
}
@@ -70,7 +58,7 @@ module.exports = async function () {
version: version,
download: asset.url,
// I' not sure that this is actually statically built but it
// seems to be and at worst we'll just get bug reports for Alpine
// seems to be and at worst we'll just get bug reports for Apline
libc: 'none',
};
@@ -87,15 +75,10 @@ module.exports = async function () {
};
if (module === require.main) {
module
.exports()
.then(function (all) {
all = require('../_webi/normalize.js')(all);
// just select the latest 20 for demonstration
all.releases = all.releases.slice(-20);
console.info(JSON.stringify(all, null, 2));
})
.catch(function (err) {
console.error('Error:', err);
});
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
// just select the latest 5 for demonstration
all.releases = all.releases.slice(-20);
console.info(JSON.stringify(all, null, 2));
});
}

View File

@@ -4,15 +4,16 @@ var github = require('../_common/github.js');
var owner = 'cilium';
var repo = 'cilium-cli';
module.exports = async function () {
let all = await github(null, owner, repo);
module.exports = async function (request) {
let all = await github(request, owner, repo);
return all;
};
if (module === require.main) {
(async function () {
let request = require('@root/request');
let normalize = require('../_webi/normalize.js');
let all = await module.exports();
let all = await module.exports(request);
all = normalize(all);
// just select the first 5 for demonstration
all.releases = all.releases.slice(0, 5);

View File

@@ -4,8 +4,8 @@ var github = require('../_common/github.js');
var owner = 'Kitware';
var repo = 'CMake';
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
for (let rel of all.releases) {
if (rel.version.startsWith('v')) {
rel._version = rel.version.slice(1);
@@ -44,7 +44,7 @@ module.exports = function () {
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
// just select the first 5 for demonstration
all.releases = all.releases.slice(0, 5);

View File

@@ -6,8 +6,8 @@ var repo = 'comrak';
var ODDITIES = ['-musleabihf.1-'];
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
let builds = [];
loopBuilds: for (let build of all.releases) {
@@ -31,7 +31,7 @@ module.exports = function () {
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
all.releases = all.releases.slice(0, 10);
//console.info(JSON.stringify(all));

View File

@@ -4,8 +4,8 @@ var github = require('../_common/github.js');
var owner = 'sstadick';
var repo = 'crabz';
module.exports = async function () {
let all = await github(null, owner, repo);
module.exports = async function (request) {
let all = await github(request, owner, repo);
let releases = [];
for (let rel of all.releases) {
@@ -22,7 +22,7 @@ module.exports = async function () {
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
// just select the first 5 for demonstration
all.releases = all.releases.slice(0, 5);

View File

@@ -4,15 +4,15 @@ var github = require('../_common/github.js');
var owner = 'rs';
var repo = 'curlie';
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
all._names = ['curlie', 'curl-httpie'];
return all;
});
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
all.releases = all.releases.slice(0, 10);
//console.info(JSON.stringify(all));

View File

@@ -100,7 +100,8 @@ mkdir -p ~/.dashcore/wallets/
mkdir -p /mnt/slc1_vol_100g/dashcore/_data
mkdir -p /mnt/slc1_vol_100g/dashcore/_caches
serviceman add --name 'dashd' --daemon -- \
sudo env PATH="$PATH" serviceman add \
--system --user "$my_user" --path "$PATH" --name dashd --force -- \
dashd \
-usehd \
-conf="$HOME/.dashcore/dash.conf" \

View File

@@ -84,8 +84,20 @@ fn_srv_install() { (
my_name="dashd-${my_netname}"
fi
my_system_args=""
my_kernel="$(
uname -s
)"
if test "Darwin" != "${my_kernel}"; then
my_user="$(
id -u -n
)"
my_system_args="--system --username ${my_user}"
fi
# shellcheck disable=SC2016,SC1090
echo "serviceman add --name \"${my_name}\" --" \
echo 'sudo env PATH="$PATH"' \
"serviceman add ${my_system_args} --path \"\$PATH\" --name \"${my_name}\" --force --" \
"dashd " \
"${my_net_flag}" \
-usehd \
@@ -95,16 +107,16 @@ fn_srv_install() { (
"-datadir=\"${my_datadir}\"" \
"-blocksdir=\"${my_blocksdir}\""
echo ""
echo "Installing latest 'serviceman'..."
echo ""
"$HOME/.local/bin/webi" serviceman > /dev/null
if ! command -v serviceman > /dev/null; then
export PATH="$HOME/.local/bin:$PATH"
fi
serviceman --version
if ! command -v dashd > /dev/null; then
export PATH="$HOME/.local/opt/dashcore/bin:$PATH"
echo ""
echo "Installing 'serviceman'..."
echo ""
{
"$HOME/.local/bin/webi" serviceman
} > /dev/null
# shellcheck disable=SC1090
. ~/.config/envman/PATH.env || true
fi
mkdir -p "$HOME/.dashcore/wallets/"
@@ -119,7 +131,8 @@ fn_srv_install() { (
cd "${my_vol}" || return 1
# leave options unquoted so they're interpreted separately
# shellcheck disable=SC2086
serviceman add --name "${my_name}" -- \
sudo env PATH="${PATH}" \
serviceman add ${my_system_args} --path "${PATH}" --name "${my_name}" --force -- \
dashd \
${my_net_flag} \
-usehd \

View File

@@ -4,8 +4,8 @@ var github = require('../_common/github.js');
var owner = 'dashpay';
var repo = 'dash';
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
all.releases.forEach(function (rel) {
if (rel.name.includes('osx64')) {
rel.os = 'macos';
@@ -22,7 +22,7 @@ module.exports = function () {
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
// just select the first 5 for demonstration
all.releases = all.releases.slice(0, 5);

View File

@@ -219,7 +219,14 @@ You can use [`serviceman`](../serviceman/):
**Linux**
```sh
serviceman add --name 'dashd' -- \
sudo env PATH="$PATH" \
serviceman add \
--system \
--username "$(id -n -u)" \
--path "$PATH" \
--name dashd \
--force \
-- \
dashd \
-usehd \
-conf="$HOME/.dashcore/dash.conf" \
@@ -232,7 +239,11 @@ serviceman add --name 'dashd' -- \
**Mac**
```sh
serviceman add --name 'dashd' -- \
serviceman add \
--path "$PATH" \
--name dashd \
--force \
-- \
dashd \
-usehd \
-conf="$HOME/.dashcore/dash.conf" \

View File

@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
var owner = 'dashhive';
var repo = 'dashmsg';
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
return all;
});
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
console.info(JSON.stringify(all, null, 2));
});

View File

@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
var owner = 'dandavison';
var repo = 'delta';
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
return all;
});
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
// just select the first 15 for demonstration
all.releases = all.releases.slice(0, 15);

View File

@@ -6,8 +6,8 @@ var github = require('../_common/github.js');
var owner = 'denoland';
var repo = 'deno';
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
// remove checksums and .deb
all.releases = all.releases
.filter(function (rel) {
@@ -35,7 +35,7 @@ module.exports = function () {
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
console.info(JSON.stringify(all, null, 2));
});

View File

@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
var owner = 'dotenv-linter';
var repo = 'dotenv-linter';
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
return all;
});
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
// just select the first 5 for demonstration
all.releases = all.releases.slice(0, 5);

View File

@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
var owner = 'therootcompany';
var repo = 'dotenv';
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
return all;
});
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
console.info(JSON.stringify(all));
});

View File

@@ -1,21 +1,29 @@
'use strict';
let Releases = module.exports;
var githubSource = require('../_common/github-source.js');
var owner = 'BeyondCodeBootcamp';
var repo = 'DuckDNS.sh';
let GitHubSource = require('../_common/github-source.js');
let owner = 'BeyondCodeBootcamp';
let repo = 'DuckDNS.sh';
Releases.latest = async function () {
let all = await GitHubSource.getDistributables({ owner, repo });
for (let pkg of all.releases) {
pkg.os = 'posix_2017';
}
return all;
module.exports = function (request) {
let arches = [
'amd64',
'arm64',
'armv6l',
'armv7l',
'ppc64le',
'ppc64',
's390x',
'x86',
];
let oses = ['freebsd', 'linux', 'macos', 'posix'];
return githubSource(request, owner, repo, oses, arches).then(function (all) {
all._names = ['DuckDNS.sh', 'duckdns.sh', 'legacy'];
return all;
});
};
if (module === require.main) {
Releases.latest().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
console.info(JSON.stringify(all, null, 2));
});

View File

@@ -2,16 +2,10 @@
set -e
set -u
echo "'duckdns@${WEBI_TAG:-stable}' is reserved for future use."
echo
echo "Did you mean 'duckdns.sh@${WEBI_VERSION-}'?"
WEBI_HOST=${WEBI_HOST:-"https://webi.sh"}
echo ""
echo "ERROR"
echo " installer name 'duckdns' is reserved for future use"
echo ""
echo "SOLUTION"
echo " Did you mean 'duckdns.sh'?"
echo ""
echo " curl -fsSL '$WEBI_HOST/duckdns.sh' | sh"
echo ""
echo " curl -fsSL '$WEBI_HOST/duckdns.sh@${WEBI_VERSION-}' | sh"
exit 1

View File

@@ -4,8 +4,8 @@ var github = require('../_common/github.js');
var owner = 'sharkdp';
var repo = 'fd';
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
let builds = [];
for (let build of all.releases) {
@@ -22,7 +22,7 @@ module.exports = function () {
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
all.releases = all.releases.slice(0, 10);
//console.info(JSON.stringify(all));

View File

@@ -6,8 +6,8 @@ var github = require('../_common/github.js');
var owner = 'eugeneware';
var repo = 'ffmpeg-static';
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
all.releases = all.releases
.filter(function (rel) {
let isFfmpeg = rel.name.includes('ffmpeg');
@@ -38,7 +38,7 @@ module.exports = function () {
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
console.info(JSON.stringify(all));
});

View File

@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
var owner = 'ffuf';
var repo = 'ffuf';
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
return all;
});
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
// just select the first 5 for demonstration
all.releases = all.releases.slice(0, 5);

View File

@@ -43,7 +43,7 @@ the file:
```sh
#!/bin/bash
echo "Who am I? I'm $(id -u -n)."
echo "Who am I? I'm $(whoami)."
```
You can also run bash explicitly:
@@ -99,7 +99,7 @@ You should use `chsh` to change your shell:
```sh
#!/bin/sh
sudo chsh -s "$(command -v fish)" "$(id -u -n)"
sudo chsh -s "$(command -v fish)" "$(whoami)"
```
If vim uses `fish` instead of `bash`, annoying errors will happen.

View File

@@ -6,8 +6,8 @@ var repo = 'fish-shell';
var ODDITIES = ['bundledpcre'];
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
all.releases = all.releases
.map(function (rel) {
for (let oddity of ODDITIES) {
@@ -30,7 +30,7 @@ module.exports = function () {
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
// just select the first 5 for demonstration
all.releases = all.releases.slice(0, 5);

View File

@@ -1,14 +1,9 @@
'use strict';
let Fetcher = require('../_common/fetcher.js');
var FLUTTER_OSES = ['macos', 'linux', 'windows'];
let FLUTTER_OSES = ['macos', 'linux', 'windows'];
/**
* stable, beta, dev
* @type {Object.<String, Boolean>}
*/
let channelMap = {};
// stable, beta, dev
var channelMap = {};
// This can be spot-checked against
// https://docs.flutter.dev/release/archive?tab=windows
@@ -58,45 +53,21 @@ let channelMap = {};
// ]
// }
/**
* @typedef BuildInfo
* @prop {String} version
* @prop {String} [_version]
* @prop {Boolean} lts
* @prop {String} channel
* @prop {String} date
* @prop {String} download
* @prop {String} [_filename]
*/
module.exports = async function () {
module.exports = async function (request) {
let all = {
download: '',
/** @type {Array<BuildInfo>} */
releases: [],
/** @type {Array<String>} */
channels: [],
};
for (let osname of FLUTTER_OSES) {
let resp;
try {
let url = `https://storage.googleapis.com/flutter_infra_release/releases/releases_${osname}.json`;
resp = await Fetcher.fetch(url, {
headers: { Accept: 'application/json' },
});
} catch (e) {
/** @type {Error & { code: string, response: { status: number, body: string } }} */ //@ts-expect-error
let err = e;
if (err.code === 'E_FETCH_RELEASES') {
err.message = `failed to fetch 'flutter' release data for ${osname}: ${err.response.status} ${err.response.body}`;
}
throw e;
}
let data = JSON.parse(resp.body);
let resp = await request({
url: `https://storage.googleapis.com/flutter_infra_release/releases/releases_${osname}.json`,
json: true,
});
let osBaseUrl = data.base_url;
let osReleases = data.releases;
let osBaseUrl = resp.body.base_url;
let osReleases = resp.body.releases;
for (let asset of osReleases) {
if (!channelMap[asset.channel]) {
@@ -109,6 +80,7 @@ module.exports = async function () {
lts: false,
channel: asset.channel,
date: asset.release_date.replace(/T.*/, ''),
//sha256: asset.sha256,
download: `${osBaseUrl}/${asset.archive}`,
_filename: asset.archive,
});
@@ -125,7 +97,7 @@ module.exports = async function () {
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all.releases = all.releases.slice(25);
console.info(JSON.stringify(all, null, 2));
});

View File

@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
var owner = 'junegunn';
var repo = 'fzf';
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
return all;
});
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
all.releases = all.releases.slice(0, 10);
//console.info(JSON.stringify(all));

View File

@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
var owner = 'cli';
var repo = 'cli';
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
return all;
});
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
// just select the first 5 for demonstration
all.releases = all.releases.slice(0, 5);

View File

@@ -21,10 +21,9 @@ is a good place to get started if you're new to git.
- Files
- Commit Files
- Ignore Files
- Reasonable Defaults
- Create Branch
- Rebase by Default
- Rebase
- Auth via SSH
- Auth via Token
### Files
@@ -67,49 +66,9 @@ This will branch from the branch you're currently on.
git switch -c my-branch-name
```
### Reasonable Defaults for Git Config
- use SSH instead of HTTPS
- default to 'main'
- create on 'push'
- stash on 'rebase'
- default to 'rebase' (modern)
### How to rebase by default
```sh
#####################
# ENFORCE SSH #
#####################
# replace HTTPS urls with SSH urls (to always use keys rather than tokens)
git config --global url."ssh://git@example.com/".insteadOf "https://example.com/"
git config --global url."ssh://git@github.com/".insteadOf "https://github.com/"
######################
# DEFAULT BRANCH #
######################
# Set the default branch for new repos (ex: 'main')
git config --global init.defaultBranch 'main'
######################
# AUTOMATIC BRANCHES #
######################
# make 'git push' create branches if they don't exist on the remote
git config --global push.autoSetupRemote true
######################
# REBASE AUTO-STASH #
######################
# stash immediately before rebase and unstash immediately after
git config --global rebase.autoStash true
######################
# REBASE BY DEFAULT #
######################
# use 'rebase' rather than 'merge' or 'ff-only'
git config --global pull.rebase true
```
@@ -143,26 +102,6 @@ git add ./my-merged-file
git rebase --continue
```
### How to authenticate git with SSH keys by default
```sh
# Git, Gitea, etc
git config --global url."ssh://git@git.example.com/".insteadOf "https://git.example.com/"
git config --global url."ssh://git@git.example.com.com/".insteadOf "git@git.example.com.com:"
# GitHub
git config --global url."ssh://git@github.com/".insteadOf "https://github.com/"
git config --global url."ssh://git@github.com/".insteadOf "git@github.com:"
# GitLab
git config --global url."ssh://git@gitlab.com/".insteadOf "https://gitlab.com/"
git config --global url."ssh://git@gitlab.com/".insteadOf "git@gitlab.com:"
# BitBucket
git config --global url."ssh://git@bitbucket.com/".insteadOf "https://bitbucket.com/"
git config --global url."ssh://git@bitbucket.com/".insteadOf "git@bitbucket.com:"
```
### How to authenticate git with deploy tokens
Abbreviated from

View File

@@ -4,9 +4,9 @@ var github = require('../_common/github.js');
var owner = 'git-for-windows';
var repo = 'git';
module.exports = function () {
module.exports = function (request) {
// TODO support mac and linux tarballs
return github(null, owner, repo).then(function (all) {
return github(request, owner, repo).then(function (all) {
// See https://github.com/git-for-windows/git/wiki/MinGit
// also consider https://github.com/git-for-windows/git/wiki/Silent-or-Unattended-Installation
all.releases = all.releases
@@ -26,7 +26,7 @@ module.exports = function () {
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
console.info(JSON.stringify(all, null, 2));
});

View File

@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
var owner = 'therootcompany';
var repo = 'gitdeploy';
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
return all;
});
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
console.info(JSON.stringify(all));
});

View File

@@ -6,8 +6,8 @@ var repo = 'gitea';
var ODDITIES = ['-gogit-', '-docs-'];
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
// remove checksums and .deb
all.releases = all.releases.filter(function (rel) {
for (let oddity of ODDITIES) {
@@ -27,7 +27,7 @@ module.exports = function () {
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
console.info(JSON.stringify(all));
});

View File

@@ -17,6 +17,7 @@ including:
- [godoc](https://pkg.go.dev/golang.org/x/tools/cmd/godoc)
- [gopls](https://pkg.go.dev/golang.org/x/tools/gopls)
- [guru](https://pkg.go.dev/golang.org/x/tools/cmd/guru)
- [golint](https://pkg.go.dev/golang.org/x/lint/golint)
- [goimports](https://pkg.go.dev/golang.org/x/tools/cmd/goimports)
- [gomvpkg](https://pkg.go.dev/golang.org/x/tools/cmd/gomvpkg)

View File

@@ -16,6 +16,10 @@ Write-Output ""
Write-Output gopls
& go install golang.org/x/tools/gopls@latest
Write-Output ""
Write-Output guru
& go install golang.org/x/tools/guru@latest
Write-Output ""
Write-Output golint
& go install golang.org/x/lint/golint@latest

View File

@@ -44,6 +44,10 @@ __run_go_essentials() {
echo gopls
go "${my_install}" golang.org/x/tools/gopls@latest > /dev/null #2>/dev/null
echo ""
echo guru
go "${my_install}" golang.org/x/tools/cmd/guru@latest > /dev/null #2>/dev/null
echo ""
echo golint
go "${my_install}" golang.org/x/lint/golint@latest > /dev/null #2>/dev/null

View File

@@ -80,7 +80,8 @@ webi serviceman
pushd ./hello/
# swap 'hello' and './hello' for the name of your project and binary
serviceman add --name 'hello' -- \
sudo env PATH="$PATH" \
serviceman add --system --username "$(whoami)" --name hello -- \
./hello
# Restart the logging service

View File

@@ -1,21 +1,14 @@
'use strict';
let Fetcher = require('../_common/fetcher.js');
/** @type {Object.<String, String>} */
let osMap = {
var osMap = {
darwin: 'macos',
};
/** @type {Object.<String, String>} */
let archMap = {
var archMap = {
386: 'x86',
};
let ODDITIES = ['bootstrap', '-arm6.'];
/**
* @param {String} filename
*/
function isOdd(filename) {
for (let oddity of ODDITIES) {
let isOddity = filename.includes(oddity);
@@ -25,22 +18,7 @@ function isOdd(filename) {
}
}
/**
* @typedef BuildInfo
* @prop {String} version
* @prop {String} [_version]
* @prop {String} arch
* @prop {String} channel
* @prop {String} date
* @prop {String} download
* @prop {String} ext
* @prop {String} [_filename]
* @prop {String} hash
* @prop {Boolean} lts
* @prop {String} os
*/
async function getDistributables() {
function getAllReleases(request) {
/*
{
version: 'go1.13.8',
@@ -59,71 +37,60 @@ async function getDistributables() {
]
};
*/
return request({
url: 'https://golang.org/dl/?mode=json&include=all',
json: true,
}).then((resp) => {
var goReleases = resp.body;
var all = {
releases: [],
download: '',
};
let resp;
try {
let url = 'https://golang.org/dl/?mode=json&include=all';
resp = await Fetcher.fetch(url, {
headers: { Accept: 'application/json' },
});
} catch (e) {
/** @type {Error & { code: string, response: { status: number, body: string } }} */ //@ts-expect-error
let err = e;
if (err.code === 'E_FETCH_RELEASES') {
err.message = `failed to fetch 'Go' release data: ${err.response.status} ${err.response.body}`;
}
throw e;
}
let goReleases = JSON.parse(resp.body);
let all = {
/** @type {Array<BuildInfo>} */
releases: [],
download: '',
};
for (let release of goReleases) {
// Strip 'go' prefix, standardize version
let parts = release.version.slice(2).split('.');
while (parts.length < 3) {
parts.push('0');
}
let version = parts.join('.');
let fileversion = release.version.slice(2);
for (let asset of release.files) {
if (isOdd(asset.filename)) {
continue;
goReleases.forEach((release) => {
// strip 'go' prefix, standardize version
var parts = release.version.slice(2).split('.');
while (parts.length < 3) {
parts.push('0');
}
var version = parts.join('.');
// nix 'go' prefix
var fileversion = release.version.slice(2);
let filename = asset.filename;
let os = osMap[asset.os] || asset.os || '-';
let arch = archMap[asset.arch] || asset.arch || '-';
let build = {
version: version,
_version: fileversion,
lts: (parts[0] > 0 && release.stable) || false,
channel: (release.stable && 'stable') || 'beta',
date: '1970-01-01', // the world may never know
os: os,
arch: arch,
ext: '', // let normalize run the split/test/join
hash: '-', // not ready to standardize this yet
download: `https://dl.google.com/go/${filename}`,
};
all.releases.push(build);
}
}
release.files.forEach((asset) => {
let odd = isOdd(asset.filename);
if (odd) {
return;
}
return all;
var filename = asset.filename;
var os = osMap[asset.os] || asset.os || '-';
var arch = archMap[asset.arch] || asset.arch || '-';
all.releases.push({
version: version,
_version: fileversion,
// all go versions >= 1.0.0 are effectively LTS
lts: (parts[0] > 0 && release.stable) || false,
channel: (release.stable && 'stable') || 'beta',
date: '1970-01-01', // the world may never know
os: os,
arch: arch,
ext: '', // let normalize run the split/test/join
hash: '-', // not ready to standardize this yet
download: `https://dl.google.com/go/${filename}`,
});
});
});
return all;
});
}
module.exports = getDistributables;
module.exports = getAllReleases;
if (module === require.main) {
getDistributables().then(function (all) {
getAllReleases(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
//@ts-expect-error
all.releases = all.releases.slice(0, 10);
console.info(JSON.stringify(all, null, 2));
});

View File

@@ -85,7 +85,8 @@ webi serviceman
pushd ./hello/
# swap 'hello' and './hello' for the name of your project and binary
serviceman add --name 'hello' -- \
sudo env PATH="$PATH" \
serviceman add --system --username "$(whoami)" --name hello -- \
./hello
# Restart the logging service

View File

@@ -4,15 +4,15 @@ var github = require('../_common/github.js');
var owner = 'goreleaser';
var repo = 'goreleaser';
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
all._names = ['goreleaser', '1'];
return all;
});
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
// just select the first 5 for demonstration
all.releases = all.releases.slice(0, 5);

View File

@@ -1,7 +1,5 @@
'use strict';
let Fetcher = require('../_common/fetcher.js');
let ltsRe = /GnuPG-(2\.2\.[\d\.]+)/;
function createRssMatcher() {
@@ -18,42 +16,12 @@ function createUrlMatcher() {
);
}
/**
* @typedef BuildInfo
* @prop {String} version
* @prop {String} [_version]
* @prop {String} arch
* @prop {String} channel
* @prop {String} date
* @prop {String} download
* @prop {String} ext
* @prop {String} [_filename]
* @prop {String} hash
* @prop {Boolean} lts
* @prop {String} os
*/
async function getRawReleases() {
let resp;
try {
let url = 'https://sourceforge.net/projects/gpgosx/rss?path=/';
resp = await Fetcher.fetch(url, {
headers: { Accept: 'application/rss+xml' },
});
} catch (e) {
/** @type {Error & { code: string, response: { status: number, body: string } }} */ //@ts-expect-error
let err = e;
if (err.code === 'E_FETCH_RELEASES') {
err.message = `failed to fetch 'gpg' release data: ${err.response.status} ${err.response.body}`;
}
throw e;
}
let contentType = resp.headers.get('Content-Type');
if (!contentType?.includes('xml')) {
throw new Error(`Unexpected content type: ${contentType}`);
}
async function getRawReleases(request) {
let matcher = createRssMatcher();
let resp = await request({
url: 'https://sourceforge.net/projects/gpgosx/rss?path=/',
});
let links = [];
for (;;) {
let m = matcher.exec(resp.body);
@@ -62,66 +30,62 @@ async function getRawReleases() {
}
links.push(m[1]);
}
return links;
}
/**
* @param {Array<String>} links
*/
function transformReleases(links) {
//console.log(JSON.stringify(links, null, 2));
//console.log(links.length);
let matcher = createUrlMatcher();
let builds = [];
for (let link of links) {
let isLts = ltsRe.test(link);
let parts = link.match(matcher);
if (!parts || !parts[2]) {
continue;
}
let releases = links
.map(function (link) {
let isLts = ltsRe.test(link);
let parts = link.match(matcher);
if (!parts || !parts[2]) {
return null;
}
let segs = parts[2].split('.');
let version = segs.slice(0, 3).join('.');
if (segs.length > 3) {
version += '+' + segs.slice(3);
}
let fileversion = segs.join('.');
let segs = parts[2].split('.');
let version = segs.slice(0, 3).join('.');
if (segs.length > 3) {
version += '+' + segs.slice(3);
}
let fileversion = segs.join('.');
let build = {
name: parts[1],
version: version,
_version: fileversion,
lts: isLts,
channel: 'stable',
// TODO <pubDate>Sat, 19 Nov 2016 16:17:33 UT</pubDate>
date: '1970-01-01', // the world may never know
os: 'macos',
arch: 'amd64',
ext: 'dmg',
download: link,
};
builds.push(build);
}
return {
name: parts[1],
version: version,
_version: fileversion,
// all go versions >= 1.0.0 are effectively LTS
lts: isLts,
channel: 'stable',
// TODO <pubDate>Sat, 19 Nov 2016 16:17:33 UT</pubDate>
date: '1970-01-01', // the world may never know
os: 'macos',
arch: 'amd64',
ext: 'dmg',
download: link,
};
})
.filter(Boolean);
return {
_names: ['GnuPG', 'gpgosx'],
releases: builds,
releases: releases,
};
}
async function getDistributables() {
let releases = await getRawReleases();
async function getAllReleases(request) {
let releases = await getRawReleases(request);
let all = transformReleases(releases);
return all;
}
module.exports = getDistributables;
module.exports = getAllReleases;
if (module === require.main) {
getDistributables().then(function (all) {
getAllReleases(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
all.releases = all.releases.slice(0, 10000);
console.info(JSON.stringify(all, null, 2));

View File

@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
var owner = 'creedasaurus';
var repo = 'gprox';
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
return all;
});
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
// just select the first 5 for demonstration
all.releases = all.releases.slice(0, 5);

View File

@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
var owner = 'anchore';
var repo = 'grype';
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
return all;
});
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
// just select the first 5 for demonstration
all.releases = all.releases.slice(0, 5);

View File

@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
var owner = 'sharkdp';
var repo = 'hexyl';
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
return all;
});
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
all.releases = all.releases.slice(0, 10);
//console.info(JSON.stringify(all));

View File

@@ -4,8 +4,8 @@ var github = require('../_common/github.js');
var owner = 'gohugoio';
var repo = 'hugo';
module.exports = async function () {
let all = await github(null, owner, repo);
module.exports = async function (request) {
let all = await github(request, owner, repo);
all.releases = all.releases.filter(function (rel) {
let isExtended = rel.name.includes('_extended_');
@@ -25,7 +25,7 @@ module.exports = async function () {
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
console.info(JSON.stringify(all));
});

View File

@@ -4,8 +4,8 @@ var github = require('../_common/github.js');
var owner = 'gohugoio';
var repo = 'hugo';
module.exports = async function () {
let all = await github(null, owner, repo);
module.exports = async function (request) {
let all = await github(request, owner, repo);
all.releases = all.releases.filter(function (rel) {
let isExtended = rel.name.includes('_extended_');
@@ -25,7 +25,7 @@ module.exports = async function () {
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
console.info(JSON.stringify(all));
});

View File

@@ -1,91 +1,73 @@
'use strict';
let Fetcher = require('../_common/fetcher.js');
async function getRawReleases() {
let resp;
try {
let url = 'https://iterm2.com/downloads.html';
resp = await Fetcher.fetch(url, {
headers: { Accept: 'text/html' },
});
} catch (e) {
/** @type {Error & { code: string, response: { status: number, body: string } }} */ //@ts-expect-error
let err = e;
if (err.code === 'E_FETCH_RELEASES') {
err.message = `failed to fetch 'iterm2' release data: ${err.response.status} ${err.response.body}`;
}
throw e;
}
let contentType = resp.headers.get('Content-Type');
if (!contentType || !contentType.includes('text/html')) {
throw new Error(`Unexpected Content-Type: ${contentType}`);
}
let lines = resp.body.split(/[<>]+/g);
/** @type {Array<String>} */
let links = [];
for (let str of lines) {
let m = str.match(/href="(https:\/\/iterm2\.com\/downloads\/.*\.zip)"/);
if (m && /iTerm2-[34]/.test(m[1])) {
if (m[1]) {
links.push(m[1]);
}
}
}
return links;
function getRawReleases(request) {
return request({ url: 'https://iterm2.com/downloads.html' }).then(
function (resp) {
var links = resp.body
.split(/[<>]+/g)
.map(function (str) {
var m = str.match(
/href="(https:\/\/iterm2\.com\/downloads\/.*\.zip)"/,
);
if (m && /iTerm2-[34]/.test(m[1])) {
return m[1];
}
})
.filter(Boolean);
return links;
},
);
}
/**
* @param {Array<String>} links
*/
function transformReleases(links) {
let builds = [];
for (let link of links) {
let channel = /\/stable\//.test(link) ? 'stable' : 'beta';
let parts = link.replace(/.*\/iTerm2[-_]v?(\d_.*)\.zip/, '$1').split('_');
let version = parts.join('.').replace(/([_-])?beta/, '-beta');
// ex: 3.5.0-beta17 => 3_5_0beta17
// ex: 3.0.2-preview => 3_0_2-preview
let fileversion = version.replace(/\./g, '_');
fileversion = fileversion.replace(/-beta/g, 'beta');
let build = {
version: version,
_version: fileversion,
lts: 'stable' === channel,
channel: channel,
date: '1970-01-01', // the world may never know
os: 'macos',
arch: 'amd64',
ext: '', // let normalize run the split/test/join
download: link,
};
builds.push(build);
}
//console.log(JSON.stringify(links, null, 2));
//console.log(links.length);
return {
_names: ['iTerm2', 'iterm2'],
releases: builds,
releases: links
.map(function (link) {
var channel = /\/stable\//.test(link) ? 'stable' : 'beta';
var parts = link
.replace(/.*\/iTerm2[-_]v?(\d_.*)\.zip/, '$1')
.split('_');
var version = parts.join('.').replace(/([_-])?beta/, '-beta');
// ex: 3.5.0-beta17 => 3_5_0beta17
// ex: 3.0.2-preview => 3_0_2-preview
let fileversion = version.replace(/\./g, '_');
fileversion = fileversion.replace(/-beta/g, 'beta');
return {
version: version,
_version: fileversion,
// all go versions >= 1.0.0 are effectively LTS
lts: 'stable' === channel,
channel: channel,
date: '1970-01-01', // the world may never know
os: 'macos',
arch: 'amd64',
ext: '', // let normalize run the split/test/join
download: link,
};
})
.filter(Boolean),
};
}
async function getDistributables() {
let rawReleases = await getRawReleases();
let all = transformReleases(rawReleases);
return all;
function getAllReleases(request) {
return getRawReleases(request)
.then(transformReleases)
.then(function (all) {
return all;
});
}
module.exports = getDistributables;
module.exports = getAllReleases;
if (module === require.main) {
getDistributables().then(function (all) {
getAllReleases(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
all.releases = all.releases.slice(0, 10000);
console.info(JSON.stringify(all, null, 2));

View File

@@ -15,8 +15,8 @@ function isOdd(build) {
}
}
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
let builds = [];
for (let build of all.releases) {
@@ -35,7 +35,7 @@ module.exports = function () {
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
console.info(JSON.stringify(all));
//console.info(JSON.stringify(all, null, 2));

View File

@@ -1,114 +0,0 @@
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig to read more about this file */
/* Projects */
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
/* Language and Environment */
"target": "es2022", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
/* Modules */
"module": "commonjs", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
"typeRoots": ["./typings","./node_modules/@types"], /* Specify multiple folders that act like './node_modules/@types'. */
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
// "resolveJsonModule": true, /* Enable importing .json files. */
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
/* JavaScript Support */
"allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
"checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
/* Emit */
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
// "outDir": "./", /* Specify an output folder for all emitted files. */
// "removeComments": true, /* Disable emitting comments. */
"noEmit": true, /* Disable emitting files from a compilation. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
// "newLine": "crlf", /* Set the newline character for emitting files. */
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
/* Interop Constraints */
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
/* Type Checking */
"strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
"alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
},
"include": [
"*.js",
"*/*.js"
],
"exclude": ["node_modules"]
}

View File

@@ -1,61 +1,31 @@
'use strict';
let Fetcher = require('../_common/fetcher.js');
/** @type {Object.<String, String>} */
let osMap = {
var osMap = {
winnt: 'windows',
mac: 'darwin',
};
/** @type {Object.<String, String>} */
let archMap = {
var archMap = {
armv7l: 'armv7',
i686: 'x86',
powerpc64le: 'ppc64le',
};
/**
* @typedef BuildInfo
* @prop {String} version
* @prop {String} [_version]
* @prop {String} [arch]
* @prop {String} channel
* @prop {String} date
* @prop {String} download
* @prop {String} [ext]
* @prop {String} [_filename]
* @prop {String} [hash]
* @prop {String} [libc]
* @prop {Boolean} [_musl]
* @prop {Boolean} [lts]
* @prop {String} [size]
* @prop {String} os
*/
async function getDistributables() {
async function getAllReleases() {
let all = {
/** @type {Array<BuildInfo>} */
releases: [],
download: '',
_names: ['julia', 'macaarch64'],
};
let resp;
try {
let url = 'https://julialang-s3.julialang.org/bin/versions.json';
resp = await Fetcher.fetch(url, {
headers: { Accept: 'application/json' },
});
} catch (e) {
/** @type {Error & { code: string, response: { status: number, body: string } }} */ //@ts-expect-error
let err = e;
if (err.code === 'E_FETCH_RELEASES') {
err.message = `failed to fetch 'julia' release data: ${err.response.status} ${err.response.body}`;
}
throw e;
}
let buildsByVersion = JSON.parse(resp.body);
let resp = await fetch(
'https://julialang-s3.julialang.org/bin/versions.json',
{
headers: {
Accept: 'application/json',
},
},
);
let buildsByVersion = await resp.json();
/*
{
@@ -135,12 +105,6 @@ async function getDistributables() {
return all;
}
/**
* @param {Object} a
* @param {String} a.version
* @param {Object} b
* @param {String} b.version
*/
function sortByVersion(a, b) {
let [aVer, aPre] = a.version.split('-');
let [bVer, bPre] = b.version.split('-');
@@ -170,10 +134,10 @@ function sortByVersion(a, b) {
return 0;
}
module.exports = getDistributables;
module.exports = getAllReleases;
if (module === require.main) {
getDistributables().then(function (all) {
getAllReleases().then(function (all) {
all = require('../_webi/normalize.js')(all);
all.releases = all.releases.slice(0, 10);
console.info(JSON.stringify(all, null, 2));

View File

@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
var owner = 'derailed';
var repo = 'k9s';
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
return all;
});
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
// just select the first 5 for demonstration
all.releases = all.releases.slice(0, 5);

View File

@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
var owner = 'therootcompany';
var repo = 'keypairs';
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
return all;
});
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
console.info(JSON.stringify(all, null, 2));
});

View File

@@ -12,14 +12,14 @@ var repo = 'kind';
/** **/
/******************************************************************************/
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
return all;
});
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
// just select the first 5 for demonstration
all.releases = all.releases.slice(0, 5);

View File

@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
var owner = 'cococonscious';
var repo = 'koji';
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
return all;
});
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
console.info(JSON.stringify(all));
});

View File

@@ -4,8 +4,8 @@ var github = require('../_common/github.js');
var owner = 'ahmetb';
var repo = 'kubectx';
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
let builds = [];
for (let build of all.releases) {
@@ -28,7 +28,7 @@ module.exports = function () {
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
// just select the first 5 for demonstration
all.releases = all.releases.slice(0, 5);

View File

@@ -4,8 +4,8 @@ var github = require('../_common/github.js');
var owner = 'ahmetb';
var repo = 'kubectx';
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
let builds = [];
for (let build of all.releases) {
@@ -28,7 +28,7 @@ module.exports = function () {
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
// just select the first 5 for demonstration
all.releases = all.releases.slice(0, 5);

View File

@@ -4,8 +4,8 @@ var github = require('../_common/github.js');
var owner = 'gokcehan';
var repo = 'lf';
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
all.releases = all.releases.map(function (r) {
// r21 -> 0.21.0
if (/^r/.test(r.version)) {
@@ -18,7 +18,7 @@ module.exports = function () {
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')._debug(all);
console.info(JSON.stringify(all, null, 2));
});

View File

@@ -4,8 +4,8 @@ var github = require('../_common/github.js');
var owner = 'lsd-rs';
var repo = 'lsd';
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
all.releases = all.releases.filter(function (rel) {
return !/(-msvc\.)|(\.deb$)/.test(rel.name);
});
@@ -14,7 +14,7 @@ module.exports = function () {
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
// just select the first 5 for demonstration
all.releases = all.releases.slice(0, 5);

View File

@@ -1,8 +1,6 @@
'use strict';
let Fetcher = require('../_common/fetcher.js');
let oses = [
var oses = [
{
name: 'macOS Sierra',
version: '10.12.6',
@@ -27,7 +25,7 @@ let oses = [
},
];
let headers = {
var headers = {
Connection: 'keep-alive',
'Cache-Control': 'max-age=0',
'Upgrade-Insecure-Requests': '1',
@@ -42,103 +40,55 @@ let headers = {
'Accept-Language': 'en-US,en;q=0.9,sq;q=0.8',
};
/**
* @param {typeof oses[0]} os
*/
async function fetchReleasesForOS(os) {
let resp;
try {
resp = await Fetcher.fetch(os.url, {
headers: headers,
});
} catch (e) {
/** @type {Error & { code: string, response: { status: number, body: string } }} */ //@ts-expect-error
let err = e;
if (err.code === 'E_FETCH_RELEASES') {
err.message = `failed to fetch 'macos' release data: ${err.response.status} ${err.response.body}`;
}
throw e;
}
// Extract the download link
let match = resp.body.match(/(http[^>]+Install[^>]+\.dmg)/);
if (match) {
return match[1];
}
}
/**
* @typedef BuildInfo
* @prop {String} version
* @prop {String} [_version]
* @prop {String} arch
* @prop {String} channel
* @prop {String} date
* @prop {String} download
* @prop {String} ext
* @prop {String} [_filename]
* @prop {String} hash
* @prop {Boolean} lts
* @prop {String} os
*/
let osnames = ['macos', 'linux'];
async function getDistributables() {
let all = {
module.exports = function (request) {
var all = {
_names: ['InstallOS'],
download: '',
/** @type {Array<BuildInfo>} */
releases: [],
};
// Fetch data for each OS and populate the releases array
for (let os of oses) {
let download = await fetchReleasesForOS(os);
if (!download) {
continue;
}
// Add releases for macOS and Linux
for (let osname of osnames) {
let build = {
version: os.version,
lts: os.lts || false,
channel: os.channel || 'beta',
date: os.date,
os: osname,
arch: 'amd64',
ext: 'dmg',
hash: '-',
download: download,
};
all.releases.push(build);
}
}
// Sort releases
all.releases.sort(function (a, b) {
if (a.version === '10.11.6') {
return -1;
}
if (a.date > b.date) {
return 1;
} else if (a.date < b.date) {
return -1;
}
return 0;
return Promise.all(
oses.map(function (os) {
return request({
method: 'GET',
url: os.url,
headers: headers,
}).then(function (resp) {
var m = resp.body.match(/(http[^>]+Install[^>]+.dmg)/);
var download = m && m[1];
['macos', 'linux'].forEach(function (osname) {
all.releases.push({
version: os.version,
lts: os.lts || false,
channel: os.channel || 'beta',
date: os.date,
os: osname,
arch: 'amd64',
ext: 'dmg',
hash: '-',
download: download,
});
});
});
}),
).then(function () {
all.releases.sort(function (a, b) {
if ('10.11.6' === a.version) {
return -1;
}
if (a.date > b.date) {
return 1;
}
if (a.date < b.date) {
return -1;
}
});
return all;
});
return all;
}
module.exports = getDistributables;
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
console.info(JSON.stringify(all, null, 2));
});
}

View File

@@ -1,11 +0,0 @@
---
title: MariaDB Server (MariaDB alias)
homepage: https://webinstall.dev/mariadb
tagline: |
Alias for https://webinstall.dev/mariadb
alias: mariadb
description: |
See https://webinstall.dev/mariadb
---
Alias for https://webinstall.dev/mariadb

View File

@@ -1,12 +0,0 @@
#!/bin/sh
set -e
set -u
__redirect_alias_mariadb() {
echo "'mariadb-server' is an alias for 'mariadb'"
sleep 2.5
WEBI_HOST=${WEBI_HOST:-"https://webi.sh"}
curl -fsSL "$WEBI_HOST/mariadb@${WEBI_VERSION-}" | sh
}
__redirect_alias_mariadb

View File

@@ -1,220 +0,0 @@
---
title: MariaDB (MySQL)
homepage: https://mariadb.com/
tagline: |
MariaDB: The original MySQL, renamed due to Oracle acquiring the trademark
---
To update or switch versions, run `webi mariadb@stable` (or `@v11`, `@lts`,
etc).
### Files
These are the files / directories that are created and/or modified with this
install:
```text
~/.config/envman/PATH.env
~/.local/opt/mariadb/
~/.local/share/mariadb/
~/.my.cnf
~/.config/mariadb/my.cnf
~/.local/share/mariadb/my.cnf
```
## Cheat Sheet
> MariaDB is the original authors' successor to MySQL, after Oracle's
> acquisition of the MySQL trademark. Although [Postgres](../postgres/) is
> generally recommended for new projects, projects that previously used MySQL or
> MariaDB can continue to gain benefit from the continued development of
> MariaDB.
Connect as the default admin, the root admin, or a remote (`%`) user:
```sh
mysql 'dbname'
sudo mysql -u root 'dbname'
mysql -u 'dbuser' -p -h '127.0.0.1' -P 3306 'dbname'
```
Manage MariaDB as a system service with [serviceman](../serviceman/):
```sh
curl https://webi.sh/serviceman | sh
# Linux and macOS
serviceman add --name 'mysqld' --workdir ~/.local/opt/mariadb/ -- \
mariadbd --defaults-file="$HOME/.local/share/mariadb/my.cnf"
# On Linux, with systemd
sudo systemctl restart systemd-journald
sudo systemctl restart 'mysqld'
sudo journalctl -xef --unit 'mysqld'
```
## Table of Contents
- Use UTF-8 (not Swedish)
- Vertical Rows
- Create an App User and DB
- Backup and Restore
- Connect via SSH Proxy
- Remove default users
### Switch from Swedish to UTF-8
This is done automatically if installed by Webi, and in MariaDB 11.6+.
Edit your `my.cnf` files as follows:
```sh
[server]
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init-connect = 'SET NAMES utf8mb4'
```
```sh
[client]
default-character-set = utf8mb4
```
You can then update old tables:
```sql
ALTER DATABASE your_database_name CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
```
See <https://chatgpt.com/c/67941f5a-9390-800e-86e7-2e8bd56117f7>.
In some cases it may be simpler better to **backup and restore** (see table of
contents) the databases due to foreign key constraints.
### How to View Rows Vertically
Use `\G` instead of `;` for a single query
```sh
SELECT * FROM `mysql`.`global_priv` \G
```
### How to Create an App User + DB
You create a database, a user (typically of the same name), a password
(typically random via `xxd` or <https://pw.bnna.net>), and grant the app admin
privileges on its database.
```sql
USE `mysql`;
CREATE DATABASE `appdb`;
CREATE USER 'appuser'@'%' IDENTIFIED BY 'super-secret';
GRANT ALL PRIVILEGES ON `appdb`.* TO 'appuser'@'%';
FLUSH PRIVILEGES;
```
Here's a script for doing the same:
```sh
mariadb-create-app 'foobar'
```
```sh
#!/bin/sh
set -e
set -u
# USAGE
# mariadb-create-app [app-name]
#
# EXAMPLE
# mariadb-create-app 'foobar'
main() {(
b_appname="${1:-$(hostname)}"
b_dbname="${b_appname}"
b_user="${b_dbname}"
b_password="$(xxd -l8 -p /dev/urandom | sed 's/..../&-/g; s/-$//')"
mariadb -e "
USE \`mysql\`;
CREATE DATABASE IF NOT EXISTS \`${b_dbname}\`;
CREATE USER '${b_user}'@'%' IDENTIFIED BY '${b_password}';
GRANT ALL PRIVILEGES ON \`${b_dbname}\`.* TO '${b_user}'@'%';
FLUSH PRIVILEGES;
"
echo "${b_password}" > ./"${b_appname}-password.txt"
echo ""
echo "Password in ./${b_appname}-password.txt"
echo ""
echo "mysql://${b_user}:********@localhost:3306/${b_dbname}"
echo "mariadb -u ${b_user} -p ${b_dbname}"
echo ""
)}
```
### How to Backup and Restore
Backup a single database:
```sh
my_ts="$(date "+%F_%H.%M.%S")"
mysqldump -u username -p --force --hex-blob --databases 'dbname' \
--triggers --routines --events \
--add-drop-table --add-drop-triggers \
--skip-set-charset --single-transaction > ./"backup.${ts}.sql"
```
Notes:
- `--force` **is always necessary** and should be the default - it will continue
the backup in the case that inconsistencies are found - such as a _View_
referencing a column that no longer exists (which is not checked during
`ALTER TABLE`)
- `--skip-set-charset` to accept the default `utf8` rather than accidentally
recreating tables as legacy `latin1-swedish`
- `--add-drop-table` and `--add-drop-triggers` do not need to be used if your
user has the ability to drop and recreate the database
- `--databases 'dbname'` omits ``USE `dbname`;``, which allows you to easily
restore to a different database name
Destructive Restore (drop that database and then restore it):
```sh
mysql -u username -p -e 'DROP DATABASE `dbname`';
mysql -u username -p 'dbname' < ./backup.sql
```
### Connect via SSH Proxy
1. Create a proxy (ignore warnings)
```sh
#ssh user@server -fnNT -L <local-port>:<remote-host>:<remote-port>
ssh ${USER}@${b_hostname} -fnNT -L 13306:localhost:3306
```
2. Connect via `mysql`, `mariadb`, Sequel Ace, etc:
```sh
mysql -u remote-user -h 127.0.0.1 -P 13306
```
**Notes**
- connect with a user that has the host `%` and DOES NOT have a `localhost` or
`127.0.0.1` entry - otherwise the client may "upgrade" to a socket connection
and fail.
- you may need to remove the wildcard `localhost` users (see below)
### Remove Default Access `localhost` Users
You may not be able to connect via an SSH proxy if the default users exist. \
(it may match `` `%`@`localhost` `` instead of `` `app`@`%` `` and deny the
password)
```sql
USE `mysql`;
DELETE FROM `global_priv` WHERE `User` = '';
FLUSH PRIVILEGES;
```

View File

@@ -1,165 +0,0 @@
#!/bin/sh
# shellcheck disable=SC2034
__init_mariadb() {
set -e
set -u
###################
# Install mariadb #
###################
# Every package should define these 6 variables
pkg_cmd_name="mariadb"
pkg_dst_cmd="${HOME}/.local/opt/mariadb/bin/mariadb"
pkg_dst_bin="${HOME}/.local/opt/mariadb/bin"
pkg_dst_dir="${HOME}/.local/opt/mariadb"
pkg_dst="${pkg_dst_dir}"
pkg_src_cmd="${HOME}/.local/opt/mariadb-v${WEBI_VERSION}/bin/mariadb"
pkg_src_dir="${HOME}/.local/opt/mariadb-v${WEBI_VERSION}"
pkg_src="${pkg_src_dir}"
pkg_get_current_version() {
# 'mariadb --version' has output in this format:
# mariadb (mariadbQL) 17.0
# This trims it down to just the version number:
# 17.0
mariadb --version 2> /dev/null | head -n 1 | cut -d' ' -f3
}
pkg_install() {
# mkdir -p $HOME/.local/opt
mkdir -p "$(dirname "$pkg_src")"
# mv ./mariadb-11.4.4-linux-systemd-x86_64 "$HOME/.local/opt/mariadb-v11.4.4"
mv ./"mariadb-"* "$pkg_src"
}
pkg_link() {
# ln -s "$HOME/.local/opt/mariadb-v17.0" "$HOME/.local/opt/mariadb"
# for the old mariadb version
ln -s "$pkg_src" "$pkg_dst"
if ! test -d ~/.local/opt/mysql; then
rm -f ~/.local/opt/mysql
ln -s "mariadb-v${WEBI_VERSION}" ~/.local/opt/mysql
fi
}
#shellcheck disable=SC2059
pkg_post_install() {
b_hostname="$(hostname)"
if ! test -e ~/.config/mariadb; then
mkdir -p ~/.config/mariadb
chmod 0700 ~/.config/mariadb/
fi
if ! test -e ~/.local/share/mariadb; then
mkdir -p ~/.local/share/mariadb/
chmod 0700 ~/.local/share/mariadb/
mkdir -p ~/.local/share/mariadb/run/
chmod 0750 ~/.local/share/mariadb/run/
mkdir -p ~/.local/share/mariadb/var/
chmod 0750 ~/.local/share/mariadb/var/
else
mkdir -p ~/.local/share/mariadb/run/
mkdir -p ~/.local/share/mariadb/data/
mkdir -p ~/.local/share/mariadb/var/
fi
printf " $(t_path '~''/.my.cnf') $(t_dim '(sources client & server config)') "
if test -e ~/.my.cnf; then
printf -- "$(t_dim 'Found')\n"
else
{
echo '[client]'
echo '!include /home/app/.config/mariadb/my.cnf'
echo ''
echo '[server]'
echo '!include /home/app/.local/share/mariadb/my.cnf'
} > ~/.my.cnf
printf -- "Created\n"
fi
printf " $(t_path '~''/.config/mariadb/my.cnf') $(t_dim '(client config)') "
if test -e ~/.config/mariadb/my.cnf; then
printf -- "$(t_dim 'Found')\n"
else
{
echo '[client]'
echo ' default-character-set = utf8mb4'
echo ''
echo " socket = $HOME/.local/share/mariadb/run/mariadbd.sock"
echo " #host = ${b_hostname}"
echo ' #port = 3306'
echo " #user = ${USER}"
echo " #password = (none)"
echo " #database = (none)"
} > ~/.config/mariadb/my.cnf
printf -- "Created\n"
fi
printf " $(t_path '~''/.local/share/mariadb/my.cnf') $(t_dim '(server config)') "
if test -e ~/.local/share/mariadb/my.cnf; then
printf -- "$(t_dim 'Found')\n"
else
{
echo '[server]'
echo " character-set-server = utf8mb4"
echo " collation-server = utf8mb4_unicode_ci"
echo " init-connect = 'SET NAMES utf8mb4'"
echo ''
echo " bind-address = 127.0.0.1"
echo " port = 3306"
echo " socket = $HOME/.local/share/mariadb/run/mariadbd.sock"
echo ''
echo " basedir = $HOME/.local/opt/mariadb/"
echo " datadir = $HOME/.local/share/mariadb/data/"
echo " pid-file = $HOME/.local/share/mariadb/run/mariadbd.pid"
echo " #log-error = $HOME/.local/share/mariadb/var/error.log"
} > ~/.local/share/mariadb/my.cnf
printf -- "Created\n"
fi
printf " $(t_path '~''/.local/share/mariadb/data/') $(t_dim '(database)') "
if test -e ~/.local/share/mariadb/data; then
printf -- "$(t_dim 'Found')\n"
else
printf -- "Initializing ... "
mkdir -p ~/.local/share/mariadb/data/
chmod 0700 ~/.local/share/mariadb/data/
# echo ""
# echo " Consider joining MariaDB's strong and vibrant community:"
# echo " https://mariadb.org/get-involved/"
# echo ""
~/.local/opt/mariadb/scripts/mariadb-install-db --defaults-file="$HOME/.my.cnf" > /dev/null
printf -- "OK\n"
fi
webi_path_add "$(dirname "$pkg_dst_cmd")"
}
pkg_done_message() {
b_hostname="$(hostname)"
echo ""
echo " Installed $(t_pkg "mariadb") $(t_dim "(mysql)") as $(t_link '~''/.local/opt/mariadb/bin/mariadb')"
echo ""
echo "To run manually"
echo " $(t_cmd 'mariadbd-safe') --defaults-file=\"$(t_path "$HOME/.my.cnf")\""
#mariadbd-safe --defaults-file=$HOME/.my.cnf --print-defaults
echo ""
echo "To install as a system service"
# export MARIADB_HOME=$HOME/.local/opt/mariadb/
echo " $(t_cmd 'serviceman') add --name mariadb --workdir $(t_path '~''/.local/opt/mariadb/') -- \\"
echo " $(t_cmd 'mariadbd') --defaults-file=\"$(t_path "$HOME/.my.cnf")\""
echo ""
echo "To connect with a client:"
echo " $(t_cmd 'mariadb') -u 'root' -h 'localhost' $(t_dim '# all-privileges admin')"
echo " $(t_cmd 'mariadb') -u '${USER}' -h 'localhost' $(t_dim '# all-privileges admin')"
}
}
__init_mariadb

View File

@@ -1,181 +1,210 @@
'use strict';
let Fetcher = require('../_common/fetcher.js');
var brewReleases = require('../_common/brew.js');
let Releases = module.exports;
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.
//
let PRODUCT = `mariadb`;
// `https://downloads.mariadb.org/rest-api/${PRODUCT}/${minor}/`
// `https://downloads.mariadb.org/rest-api/mariadb/10.5/`
// https://github.com/MariaDB/mariadb-documentation/issues/41
var promises = [mariaReleases(), brewReleases(request, 'mariadb')];
return Promise.all(promises).then(function (many) {
var versions = many[0];
var brews = many[1];
Releases.latest = async function () {
let packages = [];
let versionData = await getVersionIds();
for (let verData of versionData.major_releases) {
let isVersion = /^\d+[.]\d+$/.test(verData.release_id);
if (!isVersion) {
continue;
}
var all = { download: '', releases: [] };
let releaseData = await getReleases(verData.release_id);
let versions = Object.keys(releaseData.releases);
for (let ver of versions) {
let relData = releaseData.releases[ver];
for (let fileData of relData.files) {
let packageData = pluckData(verData, relData, fileData);
if (!packageData) {
continue;
// 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;
}
packages.push(packageData);
}
}
}
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;
});
});
let all = { releases: packages };
return all;
};
/** @type {Object.<String?, String>} */
let channelsMap = {
// 'Long Term Support': 'stable',
// 'Short Term Support': 'stable',
// 'Rolling': null,
Stable: 'stable',
RC: 'rc',
Alpha: 'preview',
null: 'preview',
};
/** @type {Object.<String, String>} */
let cpusMap = {
x86_64: 'amd64',
};
/**
* @param {MajorRelease} verData
* @param {Release} relData
* @param {File} fileData
*/
function pluckData(verData, relData, fileData) {
let lts =
verData.release_status === 'Stable' &&
verData.release_support_type === 'Long Term Support';
let cpu = fileData.cpu || '';
cpu = cpu.trim();
let isNotBinary = !fileData.os || !cpu; // "Source" or some such
if (isNotBinary) {
return null;
}
let isDebug = /debug/.test(fileData.file_name);
if (isDebug) {
return null;
}
let pkgData = {
name: fileData.file_name,
version: relData.release_id,
lts: lts,
channel: channelsMap[verData.release_status],
date: relData.date_of_release,
os: fileData.os?.toLowerCase(),
arch: cpusMap[cpu] || cpu,
hash: fileData.checksum.sha256sum,
download: fileData.file_download_url,
};
return pkgData;
}
/**
* @typedef {String} ISODate - YYYY-MM-DD (ISO 8601 format)
*/
/**
* @typedef MajorRelease
* @prop {String} release_id - version-like for stable versions, otherwise a title
* @prop {String} release_name - same as id for MariaDB
* @prop {String} release_status - Stable|RC|Alpha
* @prop {String?} release_support_type - Long Term Support|Short Term Support|Rolling|null
* @prop {ISODate?} release_eol_date
*/
/**
* @typedef MajorReleasesWrapper
* @prop {Array<MajorRelease>} major_releases
*/
/**
* @typedef Release
* @prop {String} release_id - "11.4.4" or "11.6.0 Vector"
* @prop {String} release_name - "MariaDB Server 11.8.0 Preview"
* @prop {ISODate} date_of_release
* @prop {String} release_notes_url
* @prop {String} change_log
* @prop {Array<File>} files - release assets (packages, docs, etc)
*/
/**
* @typedef ReleasesWrapper
* @prop {Object.<String, Release>} releases
*/
/**
* @typedef File
* @prop {Number} file_id
* @prop {String} file_name
* @prop {String?} package_type - "gzipped tar file" or "ZIP file"
* @prop {String?} os - "Linux" or "Windows"
* @prop {String?} cpu - "x86_64" (or null)
* @prop {Checksum} checksum
* @prop {String} file_download_url
* @prop {String?} signature
* @prop {String} checksum_url
* @prop {String} signature_url
*/
/**
* @typedef Checksum
* @prop {String?} md5sum
* @prop {String?} sha1sum
* @prop {String?} sha256sum
* @prop {String?} sha512sum
*/
/**
* @returns {Promise<MajorReleasesWrapper>}
*/
async function getVersionIds() {
let url = `https://downloads.mariadb.org/rest-api/${PRODUCT}/`;
let resp = await Fetcher.fetch(url, {
headers: { Accept: 'application/json' },
return all;
});
let result = JSON.parse(resp.body);
return result;
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;
//
// <tr>
// <td><a href="/mariadb/10.0.38/">10.0.38</a></td>
// <td>2019-01-31</td>
// <td>Stable</td>
// </tr>
// To this:
var reLine = /\s*(<(tr|td)[^>]*>)\s*/g;
//
// <tr><tr><td><a href="/mariadb/10.0.38/">10.0.38</a></td><td>2019-01-31</td><td>Stable</td>
// </tr><tr><td><a href="/mariadb/10.0.37/">10.0.37</a></td><td>2018-11-01</td><td>Stable</td>
// </tr><tr><td><a href="/mariadb/10.0.36/">10.0.36</a></td><td>2018-08-01</td><td>Stable</td>
//
// To this:
var reVer =
/<tr>.*mariadb\/(10[^\/]+)\/">.*(20\d\d-\d\d-\d\d)<\/td><td>(\w+)<\/td>/;
//
// { "version": "10.0.36", "date": "2018-08-01", "channel": "stable" }
return html
.replace(reLine, '$1')
.split(/\n/)
.map(function (line) {
var m = line.match(reVer);
if (!m) {
return;
}
return {
version: m[1],
channel: mapChannel(m[3].toLowerCase()),
date: m[2],
};
})
.filter(Boolean);
})
.catch(function (err) {
console.error('Error fetching (official) MariaDB versions');
console.error(err);
return [];
});
}
};
function mapChannel(ch) {
if ('alpha' === ch) {
return 'dev';
}
// stable,rc,beta
return ch;
}
/**
* @param {String} verId
* @returns {Promise<ReleasesWrapper>}
*/
async function getReleases(verId) {
let url = `https://downloads.mariadb.org/rest-api/${PRODUCT}/${verId}`;
let resp = await Fetcher.fetch(url, {
headers: { Accept: 'application/json' },
});
let result = JSON.parse(resp.body);
return result;
function failOnBadStatus(resp) {
if (resp.statusCode >= 400) {
var err = new Error('Non-successful status code: ' + resp.statusCode);
err.code = 'ESTATUS';
err.response = resp;
throw err;
}
return resp;
}
if (module === require.main) {
Releases.latest().then(function (all) {
let normalize = require('../_webi/normalize.js');
all = normalize(all);
let json = JSON.stringify(all, null, 2);
console.info(json);
module.exports(require('@root/request')).then(function (all) {
console.info('official releases look like:');
console.info(JSON.stringify(all.releases.slice(0, 2), null, 2));
console.info('Homebrew releases look like:');
console.info(
JSON.stringify(
all.releases
.filter(function (rel) {
return 'macos' === rel.os;
})
.slice(0, 2),
null,
2,
),
);
});
}

View File

@@ -1,11 +0,0 @@
---
title: MariaDB Server (MariaDB alias)
homepage: https://webinstall.dev/mariadb
tagline: |
Alias for https://webinstall.dev/mariadb
alias: mariadb
description: |
See https://webinstall.dev/mariadb
---
Alias for https://webinstall.dev/mariadb

View File

@@ -1,12 +0,0 @@
#!/bin/sh
set -e
set -u
__redirect_alias_mariadb() {
echo "'mariadbd' is an alias for 'mariadb'"
sleep 2.5
WEBI_HOST=${WEBI_HOST:-"https://webi.sh"}
curl -fsSL "$WEBI_HOST/mariadb@${WEBI_VERSION-}" | sh
}
__redirect_alias_mariadb

View File

@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
var owner = 'mutagen-io';
var repo = 'mutagen';
module.exports = function () {
return github(null, owner, repo).then(function (all) {
module.exports = function (request) {
return github(request, owner, repo).then(function (all) {
return all;
});
};
if (module === require.main) {
module.exports().then(function (all) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')._debug(all);
console.info(JSON.stringify(all, null, 2));
});

View File

@@ -1,15 +0,0 @@
---
title: MySQL (MariaDB alias)
homepage: https://webinstall.dev/mariadb
tagline: |
Alias for https://webinstall.dev/mariadb
alias: mariadb
description: |
See https://webinstall.dev/mariadb
---
`mysql` is ambiguous, and therefore a reserved installer name.
Currently an alias for <https://webinstall.dev/mariadb>.
That may change in the future, such as if an Oracle MySQL installer is created.

View File

@@ -1,17 +0,0 @@
#!/bin/sh
set -e
set -u
WEBI_HOST=${WEBI_HOST:-"https://webi.sh"}
echo ""
echo "ERROR"
echo " 'mysql' is ambiguous and therefore reserved for future use"
echo ""
echo "SOLUTION"
echo " Did you mean 'mariadb'?"
echo ""
echo " curl -fsSL '$WEBI_HOST/mariadb' | sh"
echo ""
exit 1

View File

@@ -1,15 +0,0 @@
---
title: MySQL Server (MariaDB Server alias)
homepage: https://webinstall.dev/mariadb
tagline: |
Alias for https://webinstall.dev/mariadb
alias: mariadb
description: |
See https://webinstall.dev/mariadb
---
`mysqld` is ambiguous, and therefore a reserved installer name.
Currently an alias for <https://webinstall.dev/mariadb>.
That may change in the future, such as if an Oracle MySQL installer is created.

View File

@@ -1,17 +0,0 @@
#!/bin/sh
set -e
set -u
WEBI_HOST=${WEBI_HOST:-"https://webi.sh"}
echo ""
echo "ERROR"
echo " 'mysqld' is ambiguous and therefore reserved for future use"
echo ""
echo "SOLUTION"
echo " Did you mean 'mariadb'?"
echo ""
echo " curl -fsSL '$WEBI_HOST/mariadb' | sh"
echo ""
exit 1

View File

@@ -17,9 +17,6 @@ install:
```text
~/.config/envman/PATH.env
~/.local/opt/node/
~/.node/
~/.node_repl_history
~/.npm/
~/.npmrc
```
@@ -227,9 +224,9 @@ Node app as a Non-System (Unprivileged) Service on Mac, Windows, and Linux:
or _User Unit_ (Linux):
```sh
my_username="$(id -u -n)"
my_username="$( id -u -n )"
serviceman add --agent --name my-node-project -- \
serviceman add --user --name my-node-project -- \
caddy run --config ./Caddyfile --envfile ~/.config/caddy/env
```
@@ -275,8 +272,11 @@ Node app as a Non-System (Unprivileged) Service on Mac, Windows, and Linux:
```sh
pushd ./my-node-project/
serviceman add --name 'my-node-project' -- \
npm run start
my_username="$( id -u -n )"
sudo env PATH="$PATH" \
serviceman add --system --path "$PATH" --cap-net-bind \
--name my-node-project --username "${my_username}" -- \
npm run start
```
#### ... with auto-reload in Dev
@@ -284,8 +284,10 @@ serviceman add --name 'my-node-project' -- \
```sh
pushd ./my-node-project/
serviceman add --name 'my-node-project' -- \
npx -p nodemon@3 -- nodemon ./server.js
sudo env PATH="$PATH" \
serviceman add --system --path "$PATH" --cap-net-bind \
--name my-node-project --username "$(id -u -n)" -- \
npx -p nodemon@3 -- nodemon ./server.js
```
#### View Logs & Restart
@@ -362,17 +364,3 @@ jobs:
- run: npm run lint
- run: npm run test
```
### How to Install Node's Linux Dependencies
Typically Node just needs `openssl` and `libstdc++`.
```sh
# Apline
sudo apk add --no-cache libstdc++ libssl3
```
```sh
# Debian / Ubuntu
sudo apt-get install -y libstdc++6 libssl3
```

Some files were not shown because too many files have changed in this diff Show More