mirror of
https://github.com/webinstall/webi-installers.git
synced 2026-06-07 08:16:35 +00:00
Compare commits
94 Commits
next
...
fix-backgr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b135d5c48f | ||
|
|
480169beac | ||
|
|
625168156f | ||
|
|
75e39c54a2 | ||
|
|
cac2e62da8 | ||
|
|
b6ab62c13f | ||
|
|
d666a860d1 | ||
|
|
7ff40e175f | ||
|
|
45e7dc314b | ||
|
|
976602236b | ||
|
|
83a214a032 | ||
|
|
cc66f930b0 | ||
|
|
afe35f9198 | ||
|
|
910fa48278 | ||
|
|
5544ff9f1b | ||
|
|
d3f3ad1688 | ||
|
|
4eff5b6cbe | ||
|
|
7b8f882d80 | ||
|
|
117ee6117d | ||
|
|
ce18bd5e61 | ||
|
|
6aeb60008b | ||
|
|
83a6d02d50 | ||
|
|
40316a866c | ||
|
|
e2ad197067 | ||
|
|
3995b7e568 | ||
|
|
de71f667a0 | ||
|
|
6320c519dc | ||
|
|
f1d1027701 | ||
|
|
fe59a2f35c | ||
|
|
a5ed5dbe91 | ||
|
|
217d61ed34 | ||
|
|
14cebeeb61 | ||
|
|
ba94ad883b | ||
|
|
801df24541 | ||
|
|
d6fc5cec97 | ||
|
|
1f3e7b5bf0 | ||
|
|
c94b4cf5c7 | ||
|
|
d7a4aaf6b7 | ||
|
|
93be13f388 | ||
|
|
257adec36d | ||
|
|
aa3f468989 | ||
|
|
553380e64c | ||
|
|
231b6d12e4 | ||
|
|
f4ec7ca640 | ||
|
|
5d28f7333a | ||
|
|
2010c62226 | ||
|
|
93e6c64349 | ||
|
|
ea0762c3ea | ||
|
|
f2c4694647 | ||
|
|
d8fffe0dc3 | ||
|
|
6924baca2b | ||
|
|
3c9609457b | ||
|
|
731beff35c | ||
|
|
b375bd8d7e | ||
|
|
502e3d6aa0 | ||
|
|
a2034c99e9 | ||
|
|
8f436dcedd | ||
|
|
500b69e70c | ||
|
|
c503f105fb | ||
|
|
b7a113a001 | ||
|
|
3385ceaa02 | ||
|
|
005ca9f7da | ||
|
|
efe3df6453 | ||
|
|
c4a6d74776 | ||
|
|
4628cc0333 | ||
|
|
deb8f37f8f | ||
|
|
7c62699a43 | ||
|
|
62c9fcc1ba | ||
|
|
90eb1587ba | ||
|
|
e6dcbfb83a | ||
|
|
35a1d08d3a | ||
|
|
fbd5211cd8 | ||
|
|
54fc06904d | ||
|
|
fc3fef8a89 | ||
|
|
566ea0fc9a | ||
|
|
b2c62dc6b6 | ||
|
|
f19fcc361a | ||
|
|
8f39617bcd | ||
|
|
5bb2832ad9 | ||
|
|
81605ddf61 | ||
|
|
13ac3e32fc | ||
|
|
e3e61ca256 | ||
|
|
3364dcb075 | ||
|
|
58be5ce649 | ||
|
|
87b308550d | ||
|
|
15098ba1d2 | ||
|
|
941453677e | ||
|
|
556697ad67 | ||
|
|
595a0b8ef9 | ||
|
|
66ba82181c | ||
|
|
9d1cde0ced | ||
|
|
566b5c047f | ||
|
|
c71126fcd8 | ||
|
|
3263196360 |
21
.gitignore
vendored
21
.gitignore
vendored
@@ -1,7 +1,24 @@
|
|||||||
.env
|
# generated artifacts
|
||||||
node_modules
|
|
||||||
install-*.sh
|
install-*.sh
|
||||||
install-*.bat
|
install-*.bat
|
||||||
install-*.ps1
|
install-*.ps1
|
||||||
|
|
||||||
|
# local config
|
||||||
|
.env.*
|
||||||
|
*.env
|
||||||
|
.env
|
||||||
|
!example.env
|
||||||
|
|
||||||
|
# caches
|
||||||
|
_cache/
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# temporary & backup files
|
||||||
.*.sw*
|
.*.sw*
|
||||||
*.bak
|
*.bak
|
||||||
|
*.bak.*
|
||||||
|
|
||||||
|
# other
|
||||||
|
.DS_Store
|
||||||
|
desktop.ini
|
||||||
|
.directory
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
{
|
{
|
||||||
|
"globals": {
|
||||||
|
"AbortController": false
|
||||||
|
},
|
||||||
"browser": true,
|
"browser": true,
|
||||||
"node": true,
|
"node": true,
|
||||||
"esversion": 11,
|
"esversion": 11,
|
||||||
|
|||||||
@@ -145,8 +145,8 @@ It looks like this:
|
|||||||
`releases.js`:
|
`releases.js`:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
// if you need to do something special, you can do it here
|
// if you need to do something special, you can do it here
|
||||||
// ...
|
// ...
|
||||||
return all;
|
return all;
|
||||||
|
|||||||
@@ -1,64 +1,62 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
let Fetcher = require('../_common/fetcher.js');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a releases from 'brew'.
|
* Gets releases from 'brew'.
|
||||||
*
|
*
|
||||||
* @param request
|
* @param {null} _
|
||||||
* @param {string} formula
|
* @param {string} formula
|
||||||
* @returns {PromiseLike<any> | Promise<any>}
|
* @returns {Promise<any>}
|
||||||
*/
|
*/
|
||||||
function getAllReleases(request, formula) {
|
async function getDistributables(_, formula) {
|
||||||
if (!formula) {
|
if (!formula) {
|
||||||
return Promise.reject('missing formula for brew');
|
return Promise.reject('missing formula for brew');
|
||||||
}
|
}
|
||||||
return request({
|
|
||||||
url: 'https://formulae.brew.sh/api/formula/' + formula + '.json',
|
let resp;
|
||||||
fail: true, // https://git.coolaj86.com/coolaj86/request.js/issues/2
|
try {
|
||||||
json: true,
|
let url = `https://formulae.brew.sh/api/formula/${formula}.json`;
|
||||||
})
|
resp = await Fetcher.fetch(url, {
|
||||||
.then(failOnBadStatus)
|
headers: { Accept: 'application/json' },
|
||||||
.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.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 [];
|
|
||||||
});
|
});
|
||||||
}
|
} catch (e) {
|
||||||
|
/** @type {Error & { code: string, response: { status: number, body: string } }} */ //@ts-expect-error
|
||||||
function failOnBadStatus(resp) {
|
let err = e;
|
||||||
if (resp.statusCode >= 400) {
|
if (err.code === 'E_FETCH_RELEASES') {
|
||||||
var err = new Error('Non-successful status code: ' + resp.statusCode);
|
err.message = `failed to fetch '${formula}' release data from 'brew': ${err.response.status} ${err.response.body}`;
|
||||||
err.code = 'ESTATUS';
|
}
|
||||||
err.response = resp;
|
throw e;
|
||||||
throw err;
|
|
||||||
}
|
}
|
||||||
return resp;
|
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 {
|
||||||
|
version: ver,
|
||||||
|
download: dl,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = getAllReleases;
|
module.exports = getDistributables;
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
getAllReleases(require('@root/request'), 'mariadb').then(function (all) {
|
getDistributables(null, 'mariadb').then(function (all) {
|
||||||
console.info(JSON.stringify(all, null, 2));
|
console.info(JSON.stringify(all, null, 2));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
56
_common/fetcher.js
Normal file
56
_common/fetcher.js
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
'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;
|
||||||
|
};
|
||||||
@@ -115,7 +115,7 @@ Repos.getCommitInfo = async function (repoPath, commitish) {
|
|||||||
* @param {string} gitUrl
|
* @param {string} gitUrl
|
||||||
* @returns {PromiseLike<any> | Promise<any>}
|
* @returns {PromiseLike<any> | Promise<any>}
|
||||||
*/
|
*/
|
||||||
async function getAllReleases(gitUrl) {
|
async function getDistributables(gitUrl) {
|
||||||
let all = {
|
let all = {
|
||||||
releases: [],
|
releases: [],
|
||||||
download: '',
|
download: '',
|
||||||
@@ -190,7 +190,7 @@ async function getAllReleases(gitUrl) {
|
|||||||
return all;
|
return all;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = getAllReleases;
|
module.exports = getDistributables;
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
(async function main() {
|
(async function main() {
|
||||||
@@ -203,7 +203,7 @@ if (module === require.main) {
|
|||||||
//'https://github.com/dense-analysis/ale.git',
|
//'https://github.com/dense-analysis/ale.git',
|
||||||
];
|
];
|
||||||
for (let url of testRepos) {
|
for (let url of testRepos) {
|
||||||
let all = await getAllReleases(url);
|
let all = await getDistributables(url);
|
||||||
|
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
console.info(JSON.stringify(all, null, 2));
|
console.info(JSON.stringify(all, null, 2));
|
||||||
|
|||||||
@@ -5,15 +5,15 @@ var GitHubish = require('./githubish.js');
|
|||||||
/**
|
/**
|
||||||
* Lists Gitea Releases (w/ uploaded assets)
|
* Lists Gitea Releases (w/ uploaded assets)
|
||||||
*
|
*
|
||||||
* @param {any} _request - deprecated
|
* @param {null} _ - deprecated
|
||||||
* @param {String} owner
|
* @param {String} owner
|
||||||
* @param {String} repo
|
* @param {String} repo
|
||||||
* @param {String} baseurl
|
* @param {String} baseurl
|
||||||
* @param {String} [username]
|
* @param {String} [username]
|
||||||
* @param {String} [token]
|
* @param {String} [token]
|
||||||
*/
|
*/
|
||||||
async function getAllReleases(
|
async function getDistributables(
|
||||||
_request,
|
_,
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
baseurl,
|
baseurl,
|
||||||
@@ -21,7 +21,7 @@ async function getAllReleases(
|
|||||||
token = '',
|
token = '',
|
||||||
) {
|
) {
|
||||||
baseurl = `${baseurl}/api/v1`;
|
baseurl = `${baseurl}/api/v1`;
|
||||||
let all = await GitHubish.getAllReleases({
|
let all = await GitHubish.getDistributables({
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
baseurl,
|
baseurl,
|
||||||
@@ -31,20 +31,17 @@ async function getAllReleases(
|
|||||||
return all;
|
return all;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = getAllReleases;
|
module.exports = getDistributables;
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
getAllReleases(
|
getDistributables(
|
||||||
null,
|
null,
|
||||||
'root',
|
'root',
|
||||||
'pathman',
|
'pathman',
|
||||||
'https://git.rootprojects.org',
|
'https://git.rootprojects.org',
|
||||||
'',
|
'',
|
||||||
'',
|
'',
|
||||||
).then(
|
).then(function (all) {
|
||||||
//getAllReleases(require('@root/request'), 'root', 'serviceman', 'https://git.rootprojects.org').then(
|
console.info(JSON.stringify(all, null, 2));
|
||||||
function (all) {
|
});
|
||||||
console.info(JSON.stringify(all, null, 2));
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,133 +1,40 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
require('dotenv').config();
|
require('dotenv').config({ path: '.env' });
|
||||||
|
|
||||||
|
let GitHubSource = module.exports;
|
||||||
|
|
||||||
|
let GitHubishSource = require('./githubish-source.js');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the releases for 'ripgrep'. This function could be trimmed down and made
|
* @param {Object} opts
|
||||||
* for use with any github release.
|
* @param {String} opts.owner
|
||||||
*
|
* @param {String} opts.repo
|
||||||
* @param request
|
* @param {String} [opts.baseurl]
|
||||||
* @param {string} owner
|
* @param {String} [opts.username]
|
||||||
* @param {string} repo
|
* @param {String} [opts.token]
|
||||||
* @returns {PromiseLike<any> | Promise<any>}
|
|
||||||
*/
|
*/
|
||||||
async function getAllReleases(
|
GitHubSource.getDistributables = async function ({
|
||||||
request,
|
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
oses,
|
|
||||||
arches,
|
|
||||||
baseurl = 'https://api.github.com',
|
baseurl = 'https://api.github.com',
|
||||||
) {
|
username = process.env.GITHUB_USERNAME || '',
|
||||||
if (!owner) {
|
token = process.env.GITHUB_TOKEN || '',
|
||||||
return Promise.reject('missing owner for repo');
|
}) {
|
||||||
}
|
let all = await GitHubishSource.getDistributables({
|
||||||
if (!repo) {
|
owner,
|
||||||
return Promise.reject('missing repo name');
|
repo,
|
||||||
}
|
baseurl,
|
||||||
|
username,
|
||||||
let req = {
|
token,
|
||||||
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;
|
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) {
|
if (module === require.main) {
|
||||||
getAllReleases(
|
GitHubSource.getDistributables(null, 'BeyondCodeBootcamp', 'DuckDNS.sh').then(
|
||||||
require('@root/request'),
|
function (all) {
|
||||||
'BeyondCodeBootcamp',
|
console.info(JSON.stringify(all, null, 2));
|
||||||
'DuckDNS.sh',
|
},
|
||||||
).then(function (all) {
|
);
|
||||||
console.info(JSON.stringify(all, null, 2));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,22 +7,22 @@ let GitHubish = require('./githubish.js');
|
|||||||
/**
|
/**
|
||||||
* Lists GitHub Releases (w/ uploaded assets)
|
* Lists GitHub Releases (w/ uploaded assets)
|
||||||
*
|
*
|
||||||
* @param {any} _request - deprecated
|
* @param {null} _ - deprecated
|
||||||
* @param {String} owner
|
* @param {String} owner
|
||||||
* @param {String} repo
|
* @param {String} repo
|
||||||
* @param {String} [baseurl]
|
* @param {String} [baseurl]
|
||||||
* @param {String} [username]
|
* @param {String} [username]
|
||||||
* @param {String} [token]
|
* @param {String} [token]
|
||||||
*/
|
*/
|
||||||
async function getAllReleases(
|
module.exports = async function (
|
||||||
_request,
|
_,
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
baseurl = 'https://api.github.com',
|
baseurl = 'https://api.github.com',
|
||||||
username = process.env.GITHUB_USERNAME || '',
|
username = process.env.GITHUB_USERNAME || '',
|
||||||
token = process.env.GITHUB_TOKEN || '',
|
token = process.env.GITHUB_TOKEN || '',
|
||||||
) {
|
) {
|
||||||
let all = await GitHubish.getAllReleases({
|
let all = await GitHubish.getDistributables({
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
baseurl,
|
baseurl,
|
||||||
@@ -30,12 +30,13 @@ async function getAllReleases(
|
|||||||
token,
|
token,
|
||||||
});
|
});
|
||||||
return all;
|
return all;
|
||||||
}
|
};
|
||||||
|
|
||||||
module.exports = getAllReleases;
|
let GitHub = module.exports;
|
||||||
|
GitHub.getDistributables = module.exports;
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
getAllReleases(null, 'BurntSushi', 'ripgrep').then(function (all) {
|
GitHub.getDistributables(null, 'BurntSushi', 'ripgrep').then(function (all) {
|
||||||
console.info(JSON.stringify(all, null, 2));
|
console.info(JSON.stringify(all, null, 2));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
174
_common/githubish-source.js
Normal file
174
_common/githubish-source.js
Normal file
@@ -0,0 +1,174 @@
|
|||||||
|
'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));
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -1,5 +1,20 @@
|
|||||||
'use strict';
|
'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;
|
let GitHubish = module.exports;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -12,7 +27,7 @@ let GitHubish = module.exports;
|
|||||||
* @param {String} [opts.username]
|
* @param {String} [opts.username]
|
||||||
* @param {String} [opts.token]
|
* @param {String} [opts.token]
|
||||||
*/
|
*/
|
||||||
GitHubish.getAllReleases = async function ({
|
GitHubish.getDistributables = async function ({
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
baseurl,
|
baseurl,
|
||||||
@@ -40,32 +55,25 @@ GitHubish.getAllReleases = async function ({
|
|||||||
let userpass = `${username}:${token}`;
|
let userpass = `${username}:${token}`;
|
||||||
let basicAuth = btoa(userpass);
|
let basicAuth = btoa(userpass);
|
||||||
Object.assign(opts.headers, {
|
Object.assign(opts.headers, {
|
||||||
Authentication: `Basic ${basicAuth}`,
|
Authorization: `Basic ${basicAuth}`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let resp = await fetch(url, opts);
|
let resp;
|
||||||
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 {
|
try {
|
||||||
gHubResp = JSON.parse(respText);
|
resp = await Fetcher.fetch(url, opts);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Bad Resp JSON:', respText);
|
/** @type {Error & { code: string, response: { status: number, body: string } }} */ //@ts-expect-error
|
||||||
console.error(e.message);
|
let err = e;
|
||||||
let msg = `failed to parse releases from '${baseurl}' with user '${username}'`;
|
if (err.code === 'E_FETCH_RELEASES') {
|
||||||
throw new Error(msg);
|
err.message = `failed to fetch '${baseurl}' (githubish, user '${username}) release data: ${err.response.status} ${err.response.body}`;
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
|
let gHubResp = JSON.parse(resp.body);
|
||||||
|
|
||||||
let all = {
|
let all = {
|
||||||
|
/** @type {Array<DistributableRaw>} */
|
||||||
releases: [],
|
releases: [],
|
||||||
// todo make this ':baseurl' + ':releasename'
|
// todo make this ':baseurl' + ':releasename'
|
||||||
download: '',
|
download: '',
|
||||||
@@ -74,13 +82,18 @@ GitHubish.getAllReleases = async function ({
|
|||||||
try {
|
try {
|
||||||
gHubResp.forEach(transformReleases);
|
gHubResp.forEach(transformReleases);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e.message);
|
/** @type {Error & { code: string, response: { status: number, body: string } }} */ //@ts-expect-error
|
||||||
|
let err = e;
|
||||||
|
console.error(err.message);
|
||||||
console.error('Error Headers:', resp.headers);
|
console.error('Error Headers:', resp.headers);
|
||||||
console.error('Error Body:', resp.body);
|
console.error('Error Body:', resp.body);
|
||||||
let msg = `failed to transform releases from '${baseurl}' with user '${username}'`;
|
let msg = `failed to transform releases from '${baseurl}' with user '${username}'`;
|
||||||
throw new Error(msg);
|
throw new Error(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {any} release - TODO
|
||||||
|
*/
|
||||||
function transformReleases(release) {
|
function transformReleases(release) {
|
||||||
for (let asset of release['assets']) {
|
for (let asset of release['assets']) {
|
||||||
let name = asset['name'];
|
let name = asset['name'];
|
||||||
@@ -114,7 +127,7 @@ GitHubish.getAllReleases = async function ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
GitHubish.getAllReleases({
|
GitHubish.getDistributables({
|
||||||
owner: 'BurntSushi',
|
owner: 'BurntSushi',
|
||||||
repo: 'ripgrep',
|
repo: 'ripgrep',
|
||||||
baseurl: 'https://api.github.com',
|
baseurl: 'https://api.github.com',
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ install:
|
|||||||
```text
|
```text
|
||||||
~/.config/envman/PATH.env
|
~/.config/envman/PATH.env
|
||||||
~/.local/bin/foo
|
~/.local/bin/foo
|
||||||
~/.local/opt/foo
|
~/.local/opt/foo/
|
||||||
```
|
```
|
||||||
|
|
||||||
## Cheat Sheet
|
## Cheat Sheet
|
||||||
|
|||||||
@@ -12,17 +12,26 @@ var repo = 'ripgrep';
|
|||||||
/** **/
|
/** **/
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
module.exports = function (request) {
|
let Releases = module.exports;
|
||||||
return github(request, owner, repo).then(function (all) {
|
|
||||||
return all;
|
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);
|
||||||
|
return all;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
(async function () {
|
||||||
all = require('../_webi/normalize.js')(all);
|
let samples = await Releases.sample();
|
||||||
// just select the first 5 for demonstration
|
|
||||||
all.releases = all.releases.slice(0, 5);
|
console.info(JSON.stringify(samples, null, 2));
|
||||||
console.info(JSON.stringify(all, null, 2));
|
})();
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
//var pkg = require('../package.json');
|
//var pkg = require('../package.json');
|
||||||
var os = require('os');
|
var os = require('os');
|
||||||
//var request = require('@root/request');
|
|
||||||
//var promisify = require('util').promisify;
|
//var promisify = require('util').promisify;
|
||||||
//var exec = promisify(require('child_process').exec);
|
//var exec = promisify(require('child_process').exec);
|
||||||
var exec = require('child_process').exec;
|
var exec = require('child_process').exec;
|
||||||
|
|||||||
Submodule _webi/build-classifier updated: 54843f08f4...20e001829a
@@ -9,8 +9,6 @@ let HostTargets = require('./build-classifier/host-targets.js');
|
|||||||
let Lexver = require('./build-classifier/lexver.js');
|
let Lexver = require('./build-classifier/lexver.js');
|
||||||
let Triplet = require('./build-classifier/triplet.js');
|
let Triplet = require('./build-classifier/triplet.js');
|
||||||
|
|
||||||
let request = require('@root/request');
|
|
||||||
|
|
||||||
var ALIAS_RE = /^alias: (\w+)$/m;
|
var ALIAS_RE = /^alias: (\w+)$/m;
|
||||||
|
|
||||||
var LEGACY_ARCH_MAP = {
|
var LEGACY_ARCH_MAP = {
|
||||||
@@ -153,7 +151,7 @@ async function getLatestBuilds(Releases, installersDir, cacheDir, name, date) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getLatestBuildsInner(Releases, cacheDir, name, date) {
|
async function getLatestBuildsInner(Releases, cacheDir, name, date) {
|
||||||
let data = await Releases.latest(request);
|
let data = await Releases.latest();
|
||||||
|
|
||||||
if (!date) {
|
if (!date) {
|
||||||
date = new Date();
|
date = new Date();
|
||||||
@@ -189,9 +187,10 @@ BuildsCacher.create = function ({ ALL_TERMS, installers, caches }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let bc = {};
|
let bc = {};
|
||||||
bc.usedTerms = {};
|
bc.ALL_TERMS = ALL_TERMS;
|
||||||
bc.orphanTerms = Object.assign({}, ALL_TERMS);
|
bc.orphanTerms = Object.assign({}, bc.ALL_TERMS);
|
||||||
bc.unknownTerms = {};
|
bc.unknownTerms = {};
|
||||||
|
bc.usedTerms = {};
|
||||||
bc.formats = [];
|
bc.formats = [];
|
||||||
bc._triplets = {};
|
bc._triplets = {};
|
||||||
bc._targetsByBuildIdCache = {};
|
bc._targetsByBuildIdCache = {};
|
||||||
@@ -381,7 +380,14 @@ BuildsCacher.create = function ({ ALL_TERMS, installers, caches }) {
|
|||||||
if (!projInfo) {
|
if (!projInfo) {
|
||||||
projInfo = await getLatestBuilds(Releases, installersDir, cacheDir, name);
|
projInfo = await getLatestBuilds(Releases, installersDir, cacheDir, name);
|
||||||
}
|
}
|
||||||
transformAndUpdate(name, projInfo, meta, tsDate);
|
let latestProjInfo = await BuildsCacher.transformAndUpdate(
|
||||||
|
name,
|
||||||
|
projInfo,
|
||||||
|
meta,
|
||||||
|
tsDate,
|
||||||
|
bc,
|
||||||
|
);
|
||||||
|
bc._caches[name] = latestProjInfo;
|
||||||
|
|
||||||
process.nextTick(async function () {
|
process.nextTick(async function () {
|
||||||
let now = date.valueOf();
|
let now = date.valueOf();
|
||||||
@@ -392,104 +398,26 @@ BuildsCacher.create = function ({ ALL_TERMS, installers, caches }) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
projInfo = await getLatestBuilds(Releases, installersDir, cacheDir, name);
|
projInfo = await getLatestBuilds(Releases, installersDir, cacheDir, name)
|
||||||
transformAndUpdate(name, projInfo, meta, date);
|
.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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
return projInfo;
|
return projInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
function transformAndUpdate(name, projInfo, meta, date) {
|
|
||||||
meta.packages = [];
|
|
||||||
|
|
||||||
let updated = date.valueOf();
|
|
||||||
|
|
||||||
Object.assign(projInfo, { name, updated }, meta);
|
|
||||||
for (let build of projInfo.releases) {
|
|
||||||
let buildTarget = bc.classify(projInfo, build);
|
|
||||||
if (!buildTarget) {
|
|
||||||
// ignore known, non-package extensions
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (buildTarget.error) {
|
|
||||||
let err = buildTarget.error;
|
|
||||||
let code = err.code || '';
|
|
||||||
console.error(`[ERROR]: ${code} ${projInfo.name}: ${build.name}`);
|
|
||||||
console.error(`>>> ${err.message} <<<`);
|
|
||||||
console.error(projInfo);
|
|
||||||
console.error(build);
|
|
||||||
console.error(`^^^ ${err.message} ^^^`);
|
|
||||||
console.error(err.stack);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!build.name) {
|
|
||||||
build.name = build.download.replace(/.*\//, '');
|
|
||||||
}
|
|
||||||
|
|
||||||
build.target = buildTarget;
|
|
||||||
meta.packages.push(build);
|
|
||||||
}
|
|
||||||
|
|
||||||
updateReleasesByTriplet(meta);
|
|
||||||
updateAndSortVersions(projInfo, meta);
|
|
||||||
|
|
||||||
Object.assign(projInfo, { name, updated }, meta);
|
|
||||||
bc._caches[name] = projInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateReleasesByTriplet(meta) {
|
|
||||||
for (let build of meta.packages) {
|
|
||||||
let target = build.target;
|
|
||||||
|
|
||||||
let triplet = `${target.os}-${target.arch}-${target.libc}`;
|
|
||||||
if (!meta.releasesByTriplet[triplet]) {
|
|
||||||
meta.releasesByTriplet[triplet] = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
let buildsByRelease = meta.releasesByTriplet[triplet];
|
|
||||||
if (!buildsByRelease[build.version]) {
|
|
||||||
buildsByRelease[build.version] = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
let packages = buildsByRelease[build.version];
|
|
||||||
packages.push(build);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO
|
|
||||||
// - tag channels
|
|
||||||
function updateAndSortVersions(projInfo, meta) {
|
|
||||||
for (let build of projInfo.packages) {
|
|
||||||
let hasVersion = meta.versions.includes(build.version);
|
|
||||||
if (!hasVersion) {
|
|
||||||
build.lexver = Lexver.parseVersion(build.version);
|
|
||||||
meta.lexversMap[build.lexver] = build.version;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
meta.lexvers = Object.keys(meta.lexversMap);
|
|
||||||
meta.lexvers.sort();
|
|
||||||
meta.lexvers.reverse();
|
|
||||||
|
|
||||||
meta.versions = [];
|
|
||||||
for (let lexver of meta.lexvers) {
|
|
||||||
let version = meta.lexversMap[lexver];
|
|
||||||
meta.versions.push(version);
|
|
||||||
}
|
|
||||||
|
|
||||||
projInfo.packages.sort(function (a, b) {
|
|
||||||
if (a.lexver > b.lexver) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (a.lexver < b.lexver) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Makes sure that packages are updated once an hour, on average
|
// Makes sure that packages are updated once an hour, on average
|
||||||
bc._staleNames = [];
|
bc._staleNames = [];
|
||||||
bc._freshenTimeout = null;
|
bc._freshenTimeout = null;
|
||||||
@@ -525,134 +453,6 @@ BuildsCacher.create = function ({ ALL_TERMS, installers, caches }) {
|
|||||||
bc._freshenTimeout.unref();
|
bc._freshenTimeout.unref();
|
||||||
};
|
};
|
||||||
|
|
||||||
bc.classify = function (projInfo, build) {
|
|
||||||
/* jshint maxcomplexity: 25 */
|
|
||||||
let maybeInstallable = Triplet.maybeInstallable(projInfo, build);
|
|
||||||
if (!maybeInstallable) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (LEGACY_OS_MAP[build.os]) {
|
|
||||||
build.os = LEGACY_OS_MAP[build.os];
|
|
||||||
}
|
|
||||||
if (LEGACY_ARCH_MAP[build.arch]) {
|
|
||||||
build.arch = LEGACY_ARCH_MAP[build.arch];
|
|
||||||
}
|
|
||||||
|
|
||||||
// because some packages are shimmed to match a single download against
|
|
||||||
let preTarget = Object.assign({ os: '', arch: '', libc: '' }, build);
|
|
||||||
|
|
||||||
let targetId = `${preTarget.os}:${preTarget.arch}:${preTarget.libc}`;
|
|
||||||
let buildId = `${projInfo.name}:${targetId}@${build.download}`;
|
|
||||||
let target = bc._targetsByBuildIdCache[buildId];
|
|
||||||
if (target) {
|
|
||||||
Object.assign(build, { target: target, triplet: target.triplet });
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
|
|
||||||
let pattern = Triplet.toPattern(projInfo, build);
|
|
||||||
if (!pattern) {
|
|
||||||
let err = new Error(`no pattern generated for ${projInfo.name}`);
|
|
||||||
err.code = 'E_BUILD_NO_PATTERN';
|
|
||||||
target = { error: err };
|
|
||||||
bc._targetsByBuildIdCache[buildId] = target;
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
|
|
||||||
let rawTerms = pattern.split(/[_\{\}\/\.\-]+/g);
|
|
||||||
for (let term of rawTerms) {
|
|
||||||
delete bc.orphanTerms[term];
|
|
||||||
bc.usedTerms[term] = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// {NAME}/{NAME}-{VER}-Windows-x86_64_v2-musl.exe =>
|
|
||||||
// {NAME}.windows.x86_64v2.musl.exe
|
|
||||||
let terms = Triplet.patternToTerms(pattern);
|
|
||||||
if (!terms.length) {
|
|
||||||
let err = new Error(`'${terms}' was trimmed to ''`);
|
|
||||||
target = { error: err };
|
|
||||||
bc._targetsByBuildIdCache[buildId] = target;
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let term of terms) {
|
|
||||||
if (!term) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ALL_TERMS[term]) {
|
|
||||||
delete bc.orphanTerms[term];
|
|
||||||
bc.usedTerms[term] = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
bc.unknownTerms[term] = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// {NAME}.windows.x86_64v2.musl.exe
|
|
||||||
// windows-x86_64_v2-musl
|
|
||||||
target = { triplet: '' };
|
|
||||||
void Triplet.termsToTarget(target, projInfo, build, terms);
|
|
||||||
|
|
||||||
target.triplet = `${target.arch}-${target.vendor}-${target.os}-${target.libc}`;
|
|
||||||
|
|
||||||
{
|
|
||||||
// TODO I don't love this hidden behavior
|
|
||||||
// perhaps classify should just happen when the package is loaded
|
|
||||||
// (and the sanity error should be removed, or thrown after the loop is complete)
|
|
||||||
let hasTriplet = projInfo.triplets.includes(target.triplet);
|
|
||||||
if (!hasTriplet) {
|
|
||||||
projInfo.triplets.push(target.triplet);
|
|
||||||
}
|
|
||||||
let hasOs = projInfo.oses.includes(target.os);
|
|
||||||
if (!hasOs) {
|
|
||||||
projInfo.oses.push(target.os);
|
|
||||||
}
|
|
||||||
let hasArch = projInfo.arches.includes(target.arch);
|
|
||||||
if (!hasArch) {
|
|
||||||
projInfo.arches.push(target.arch);
|
|
||||||
}
|
|
||||||
let hasLibc = projInfo.libcs.includes(target.libc);
|
|
||||||
if (!hasLibc) {
|
|
||||||
projInfo.libcs.push(target.libc);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!build.ext) {
|
|
||||||
build.ext = Triplet.buildToPackageType(build);
|
|
||||||
}
|
|
||||||
if (build.ext) {
|
|
||||||
if (!build.ext.startsWith('.')) {
|
|
||||||
build.ext = `.${build.ext}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let hasExt = projInfo.formats.includes(build.ext);
|
|
||||||
if (!hasExt) {
|
|
||||||
projInfo.formats.push(build.ext);
|
|
||||||
}
|
|
||||||
let hasGlobalExt = bc.formats.includes(build.ext);
|
|
||||||
if (!hasGlobalExt) {
|
|
||||||
bc.formats.push(build.ext);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bc._triplets[target.triplet] = true;
|
|
||||||
bc._targetsByBuildIdCache[buildId] = target;
|
|
||||||
|
|
||||||
let triple = [target.arch, target.vendor, target.os, target.libc];
|
|
||||||
for (let term of triple) {
|
|
||||||
if (!ALL_TERMS[term]) {
|
|
||||||
throw new Error(
|
|
||||||
`[SANITY FAIL] '${projInfo.name}' '${target.triplet}' generated unknown term '${term}'`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete bc.orphanTerms[term];
|
|
||||||
bc.usedTerms[term] = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return target;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a list of acceptable formats, get the sorted list of of formats.
|
* Given a list of acceptable formats, get the sorted list of of formats.
|
||||||
* Actually used (as per node _webi/lint-builds.js):
|
* Actually used (as per node _webi/lint-builds.js):
|
||||||
@@ -798,9 +598,8 @@ BuildsCacher.create = function ({ ALL_TERMS, installers, caches }) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ProjectInfo} projInfo
|
* @param {ProjectInfo} projInfo
|
||||||
* @param {HostTarget} hostTarget
|
|
||||||
*/
|
*/
|
||||||
bc.enumerateLatestVersions = function (projInfo, hostTarget) {
|
bc.enumerateLatestVersions = function (projInfo) {
|
||||||
let lexPrefix = '';
|
let lexPrefix = '';
|
||||||
let matchInfo = Lexver.matchSorted(projInfo.lexvers, lexPrefix);
|
let matchInfo = Lexver.matchSorted(projInfo.lexvers, lexPrefix);
|
||||||
let verInfo = {
|
let verInfo = {
|
||||||
@@ -930,9 +729,9 @@ BuildsCacher.create = function ({ ALL_TERMS, installers, caches }) {
|
|||||||
if (hostTarget.os === 'windows') {
|
if (hostTarget.os === 'windows') {
|
||||||
oses = ['ANYOS', 'windows'];
|
oses = ['ANYOS', 'windows'];
|
||||||
} else if (hostTarget.os === 'android') {
|
} else if (hostTarget.os === 'android') {
|
||||||
oses = ['ANYOS', 'posix_2017', 'android', 'linux'];
|
oses = ['ANYOS', 'posix_2017', 'posix_2024', 'android', 'linux'];
|
||||||
} else {
|
} else {
|
||||||
oses = ['ANYOS', 'posix_2017', hostTarget.os];
|
oses = ['ANYOS', 'posix_2017', 'posix_2024', hostTarget.os];
|
||||||
}
|
}
|
||||||
|
|
||||||
let waterfall = HostTargets.WATERFALL[hostTarget.os] || {};
|
let waterfall = HostTargets.WATERFALL[hostTarget.os] || {};
|
||||||
@@ -967,3 +766,233 @@ BuildsCacher.create = function ({ ALL_TERMS, installers, caches }) {
|
|||||||
|
|
||||||
return bc;
|
return bc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
BuildsCacher._classify = function (bc, projInfo, build) {
|
||||||
|
/* jshint maxcomplexity: 25 */
|
||||||
|
let maybeInstallable = Triplet.maybeInstallable(projInfo, build);
|
||||||
|
if (!maybeInstallable) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (LEGACY_OS_MAP[build.os]) {
|
||||||
|
build.os = LEGACY_OS_MAP[build.os];
|
||||||
|
}
|
||||||
|
if (LEGACY_ARCH_MAP[build.arch]) {
|
||||||
|
build.arch = LEGACY_ARCH_MAP[build.arch];
|
||||||
|
}
|
||||||
|
|
||||||
|
// because some packages are shimmed to match a single download against
|
||||||
|
let preTarget = Object.assign({ os: '', arch: '', libc: '' }, build);
|
||||||
|
|
||||||
|
let targetId = `${preTarget.os}:${preTarget.arch}:${preTarget.libc}`;
|
||||||
|
let buildId = `${projInfo.name}:${targetId}@${build.download}`;
|
||||||
|
//console.log(`dbg: buildId`, buildId);
|
||||||
|
let target = bc._targetsByBuildIdCache[buildId];
|
||||||
|
if (target) {
|
||||||
|
Object.assign(build, { target: target, triplet: target.triplet });
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
let pattern = Triplet.toPattern(projInfo, build);
|
||||||
|
//console.log(`dbg: pattern`, pattern);
|
||||||
|
if (!pattern) {
|
||||||
|
let err = new Error(`no pattern generated for ${projInfo.name}`);
|
||||||
|
err.code = 'E_BUILD_NO_PATTERN';
|
||||||
|
target = { error: err };
|
||||||
|
bc._targetsByBuildIdCache[buildId] = target;
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
let rawTerms = pattern.split(/[_\{\}\/\.\-]+/g);
|
||||||
|
//console.log(`dbg: rawTerms`, rawTerms);
|
||||||
|
for (let term of rawTerms) {
|
||||||
|
delete bc.orphanTerms[term];
|
||||||
|
bc.usedTerms[term] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// {NAME}/{NAME}-{VER}-Windows-x86_64_v2-musl.exe =>
|
||||||
|
// {NAME}.windows.x86_64v2.musl.exe
|
||||||
|
let terms = Triplet.patternToTerms(pattern);
|
||||||
|
//console.log(`dbg: terms`, terms);
|
||||||
|
if (!terms.length) {
|
||||||
|
let err = new Error(`'${terms}' was trimmed to ''`);
|
||||||
|
target = { error: err };
|
||||||
|
bc._targetsByBuildIdCache[buildId] = target;
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let term of terms) {
|
||||||
|
if (!term) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bc.ALL_TERMS[term]) {
|
||||||
|
delete bc.orphanTerms[term];
|
||||||
|
bc.usedTerms[term] = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
bc.unknownTerms[term] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// {NAME}.windows.x86_64v2.musl.exe
|
||||||
|
// windows-x86_64_v2-musl
|
||||||
|
target = { triplet: '' };
|
||||||
|
try {
|
||||||
|
void Triplet.termsToTarget(target, projInfo, build, terms);
|
||||||
|
} catch (e) {
|
||||||
|
console.error(`PACKAGE FORMAT CHANGE for '${projInfo.name}':`);
|
||||||
|
console.error(e.message);
|
||||||
|
console.error(build);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
target.triplet = `${target.arch}-${target.vendor}-${target.os}-${target.libc}`;
|
||||||
|
|
||||||
|
{
|
||||||
|
// TODO I don't love this hidden behavior
|
||||||
|
// perhaps classify should just happen when the package is loaded
|
||||||
|
// (and the sanity error should be removed, or thrown after the loop is complete)
|
||||||
|
let hasTriplet = projInfo.triplets.includes(target.triplet);
|
||||||
|
if (!hasTriplet) {
|
||||||
|
projInfo.triplets.push(target.triplet);
|
||||||
|
}
|
||||||
|
let hasOs = projInfo.oses.includes(target.os);
|
||||||
|
if (!hasOs) {
|
||||||
|
projInfo.oses.push(target.os);
|
||||||
|
}
|
||||||
|
let hasArch = projInfo.arches.includes(target.arch);
|
||||||
|
if (!hasArch) {
|
||||||
|
projInfo.arches.push(target.arch);
|
||||||
|
}
|
||||||
|
let hasLibc = projInfo.libcs.includes(target.libc);
|
||||||
|
if (!hasLibc) {
|
||||||
|
projInfo.libcs.push(target.libc);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!build.ext) {
|
||||||
|
build.ext = Triplet.buildToPackageType(build);
|
||||||
|
}
|
||||||
|
if (build.ext) {
|
||||||
|
if (!build.ext.startsWith('.')) {
|
||||||
|
build.ext = `.${build.ext}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let hasExt = projInfo.formats.includes(build.ext);
|
||||||
|
if (!hasExt) {
|
||||||
|
projInfo.formats.push(build.ext);
|
||||||
|
}
|
||||||
|
let hasGlobalExt = bc.formats.includes(build.ext);
|
||||||
|
if (!hasGlobalExt) {
|
||||||
|
bc.formats.push(build.ext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bc._triplets[target.triplet] = true;
|
||||||
|
bc._targetsByBuildIdCache[buildId] = target;
|
||||||
|
|
||||||
|
let triple = [target.arch, target.vendor, target.os, target.libc];
|
||||||
|
for (let term of triple) {
|
||||||
|
if (!bc.ALL_TERMS[term]) {
|
||||||
|
throw new Error(
|
||||||
|
`[SANITY FAIL] '${projInfo.name}' '${target.triplet}' generated unknown term '${term}'`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete bc.orphanTerms[term];
|
||||||
|
bc.usedTerms[term] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return target;
|
||||||
|
};
|
||||||
|
|
||||||
|
BuildsCacher.transformAndUpdate = function (name, projInfo, meta, date, bc) {
|
||||||
|
meta.packages = [];
|
||||||
|
|
||||||
|
let updated = date.valueOf();
|
||||||
|
|
||||||
|
Object.assign(projInfo, { name, updated }, meta);
|
||||||
|
for (let build of projInfo.releases) {
|
||||||
|
let buildTarget = BuildsCacher._classify(bc, projInfo, build);
|
||||||
|
if (!buildTarget) {
|
||||||
|
// ignore known, non-package extensions
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buildTarget.error) {
|
||||||
|
let err = buildTarget.error;
|
||||||
|
let code = err.code || '';
|
||||||
|
console.error(`[ERROR]: ${code} ${projInfo.name}: ${build.name}`);
|
||||||
|
console.error(`>>> ${err.message} <<<`);
|
||||||
|
console.error(projInfo);
|
||||||
|
console.error(build);
|
||||||
|
console.error(`^^^ ${err.message} ^^^`);
|
||||||
|
console.error(err.stack);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!build.name) {
|
||||||
|
build.name = build.download.replace(/.*\//, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
build.target = buildTarget;
|
||||||
|
meta.packages.push(build);
|
||||||
|
}
|
||||||
|
|
||||||
|
BuildsCacher.updateReleasesByTriplet(meta);
|
||||||
|
BuildsCacher.updateAndSortVersions(projInfo, meta);
|
||||||
|
|
||||||
|
Object.assign(projInfo, { name, updated }, meta);
|
||||||
|
return projInfo;
|
||||||
|
};
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
// - tag channels
|
||||||
|
BuildsCacher.updateAndSortVersions = function (projInfo, meta) {
|
||||||
|
for (let build of projInfo.packages) {
|
||||||
|
let hasVersion = meta.versions.includes(build.version);
|
||||||
|
if (!hasVersion) {
|
||||||
|
build.lexver = Lexver.parseVersion(build.version);
|
||||||
|
meta.lexversMap[build.lexver] = build.version;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
meta.lexvers = Object.keys(meta.lexversMap);
|
||||||
|
meta.lexvers.sort();
|
||||||
|
meta.lexvers.reverse();
|
||||||
|
|
||||||
|
meta.versions = [];
|
||||||
|
for (let lexver of meta.lexvers) {
|
||||||
|
let version = meta.lexversMap[lexver];
|
||||||
|
meta.versions.push(version);
|
||||||
|
}
|
||||||
|
|
||||||
|
projInfo.packages.sort(function (a, b) {
|
||||||
|
if (a.lexver > b.lexver) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (a.lexver < b.lexver) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
BuildsCacher.updateReleasesByTriplet = function (meta) {
|
||||||
|
for (let build of meta.packages) {
|
||||||
|
let target = build.target;
|
||||||
|
|
||||||
|
let triplet = `${target.os}-${target.arch}-${target.libc}`;
|
||||||
|
if (!meta.releasesByTriplet[triplet]) {
|
||||||
|
meta.releasesByTriplet[triplet] = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
let buildsByRelease = meta.releasesByTriplet[triplet];
|
||||||
|
if (!buildsByRelease[build.version]) {
|
||||||
|
buildsByRelease[build.version] = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
let packages = buildsByRelease[build.version];
|
||||||
|
packages.push(build);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
90
_webi/classify-one.js
Normal file
90
_webi/classify-one.js
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
let Path = require('node:path');
|
||||||
|
|
||||||
|
// let Builds = require('./builds.js');
|
||||||
|
let BuildsCacher = require('./builds-cacher.js');
|
||||||
|
let Triplet = require('./build-classifier/triplet.js');
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
let projName = process.argv[2];
|
||||||
|
if (!projName) {
|
||||||
|
console.error(``);
|
||||||
|
console.error(`USAGE`);
|
||||||
|
console.error(``);
|
||||||
|
console.error(` classify-one <project-name>`);
|
||||||
|
console.error(``);
|
||||||
|
console.error(`EXAMPLE`);
|
||||||
|
console.error(``);
|
||||||
|
console.error(` classify-one caddy`);
|
||||||
|
console.error(``);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let tsDate = new Date(0);
|
||||||
|
let meta = {
|
||||||
|
// version info
|
||||||
|
versions: [],
|
||||||
|
lexvers: [],
|
||||||
|
lexversMap: {},
|
||||||
|
// culled release assets
|
||||||
|
packages: [],
|
||||||
|
releasesByTriplet: {},
|
||||||
|
// target info
|
||||||
|
triplets: [],
|
||||||
|
oses: [],
|
||||||
|
arches: [],
|
||||||
|
libcs: [],
|
||||||
|
formats: [],
|
||||||
|
// TODO channels: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
let installersDir = Path.join(__dirname, '..');
|
||||||
|
let Releases = require(`${installersDir}/${projName}/releases.js`);
|
||||||
|
if (!Releases.latest) {
|
||||||
|
Releases.latest = Releases;
|
||||||
|
}
|
||||||
|
|
||||||
|
let projInfo = await Releases.latest();
|
||||||
|
|
||||||
|
// let packages = await Builds.getPackage({ name: projName });
|
||||||
|
// console.log(packages);
|
||||||
|
|
||||||
|
let bc = {};
|
||||||
|
bc.ALL_TERMS = Triplet.TERMS_PRIMARY_MAP;
|
||||||
|
bc.orphanTerms = Object.assign({}, bc.ALL_TERMS);
|
||||||
|
bc.unknownTerms = {};
|
||||||
|
bc.usedTerms = {};
|
||||||
|
bc.formats = [];
|
||||||
|
bc._targetsByBuildIdCache = {};
|
||||||
|
bc._triplets = {};
|
||||||
|
|
||||||
|
let transformed = BuildsCacher.transformAndUpdate(
|
||||||
|
projName,
|
||||||
|
projInfo,
|
||||||
|
meta,
|
||||||
|
tsDate,
|
||||||
|
bc,
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(`[DEBUG] transformed`);
|
||||||
|
let sample = transformed.packages.slice(0, 20);
|
||||||
|
console.log('packages:', sample, ':packages');
|
||||||
|
console.log(
|
||||||
|
'releasesByTriplet:',
|
||||||
|
transformed.releasesByTriplet['linux-x86_64-none'][transformed.versions[0]],
|
||||||
|
':releasesByTriplet',
|
||||||
|
);
|
||||||
|
console.log('versions:', transformed.versions, ':versions');
|
||||||
|
console.log('triplets:', transformed.triplets, ':triplets');
|
||||||
|
console.log('oses:', transformed.oses, ':oses');
|
||||||
|
console.log('arches:', transformed.arches, ':arches');
|
||||||
|
console.log('libcs:', transformed.libcs, ':libcs');
|
||||||
|
console.log('formats:', transformed.formats, ':formats');
|
||||||
|
console.log(Object.keys(transformed));
|
||||||
|
}
|
||||||
|
|
||||||
|
main().catch(function (err) {
|
||||||
|
console.error('Error:');
|
||||||
|
console.error(err);
|
||||||
|
});
|
||||||
@@ -16,7 +16,7 @@ var BAD_SH_RE = /[<>'"`$\\]/;
|
|||||||
Installers.renderBash = async function (
|
Installers.renderBash = async function (
|
||||||
pkgdir,
|
pkgdir,
|
||||||
rel,
|
rel,
|
||||||
{ baseurl, pkg, tag, ver, os = '', arch = '', libc = '', formats, latest },
|
{ baseurl, pkg, tag, ver, os = '', arch = '', libc = '', formats },
|
||||||
) {
|
) {
|
||||||
if (!Array.isArray(formats)) {
|
if (!Array.isArray(formats)) {
|
||||||
formats = [];
|
formats = [];
|
||||||
@@ -99,11 +99,12 @@ Installers.renderBash = async function (
|
|||||||
['WEBI_PKG_PATHNAME', pkgFile],
|
['WEBI_PKG_PATHNAME', pkgFile],
|
||||||
['WEBI_PKG_FILE', pkgFile], // TODO replace with pathname
|
['WEBI_PKG_FILE', pkgFile], // TODO replace with pathname
|
||||||
['PKG_NAME', pkg],
|
['PKG_NAME', pkg],
|
||||||
|
['PKG_STABLE', rel.stable],
|
||||||
|
['PKG_LATEST', rel.latest],
|
||||||
['PKG_OSES', (rel.oses || []).join(' ')],
|
['PKG_OSES', (rel.oses || []).join(' ')],
|
||||||
['PKG_ARCHES', (rel.arches || []).join(' ')],
|
['PKG_ARCHES', (rel.arches || []).join(' ')],
|
||||||
['PKG_LIBCS', (rel.libcs || []).join(' ')],
|
['PKG_LIBCS', (rel.libcs || []).join(' ')],
|
||||||
['PKG_FORMATS', (rel.formats || []).join(' ')],
|
['PKG_FORMATS', (rel.formats || []).join(' ')],
|
||||||
['PKG_LATEST', latest],
|
|
||||||
];
|
];
|
||||||
|
|
||||||
for (let env of envReplacements) {
|
for (let env of envReplacements) {
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ var archMap = {
|
|||||||
amd64:
|
amd64:
|
||||||
/(\b|_|amd|(dar)?win(dows)?|mac(os)?|linux|osx|x)64([_\-]?bit)?(\b|_)/i,
|
/(\b|_|amd|(dar)?win(dows)?|mac(os)?|linux|osx|x)64([_\-]?bit)?(\b|_)/i,
|
||||||
//x86: /(86)(\b|_)/i,
|
//x86: /(86)(\b|_)/i,
|
||||||
x86: /(\b|_|amd|(dar)?win(dows)?|mac(os)?|linux|osx|x)(86|32)([_\-]?bit)(\b|_)/i,
|
x86: /(\b|_|amd|(dar)?win(dows)?|mac(os)?|linux|osx|x)(86|32|i?386)([_\-]?bit)?(\b|_)/i,
|
||||||
ppc64le: /(\b|_)(ppc64le)/i,
|
ppc64le: /(\b|_)(ppc64le)/i,
|
||||||
ppc64: /(\b|_)(ppc64)(\b|_)/i,
|
ppc64: /(\b|_)(ppc64)(\b|_)/i,
|
||||||
s390x: /(\b|_)(s390x)/i,
|
s390x: /(\b|_)(s390x)/i,
|
||||||
@@ -211,7 +211,8 @@ function normalize(all) {
|
|||||||
// won't match:
|
// won't match:
|
||||||
// - v1.0beta
|
// - v1.0beta
|
||||||
// - v1.0-beta1b
|
// - v1.0-beta1b
|
||||||
let isBetaRe = /(\b|_)(preview|rc|beta|alpha)(\d+)(\b|_)/;
|
let isBetaRe =
|
||||||
|
/(\b|_)(alpha|beta|dev|developer|prev|preview|rc)(\d+)(\b|_)/;
|
||||||
let isBeta = isBetaRe.test(rel.name);
|
let isBeta = isBetaRe.test(rel.name);
|
||||||
if (isBeta) {
|
if (isBeta) {
|
||||||
rel.channel = 'beta';
|
rel.channel = 'beta';
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ function Get-UserAgent {
|
|||||||
IF ($my_arch -eq "AMD64") {
|
IF ($my_arch -eq "AMD64") {
|
||||||
# Because PowerShell is sometimes AMD64 on Windows 10 ARM
|
# Because PowerShell is sometimes AMD64 on Windows 10 ARM
|
||||||
# See https://oofhours.com/2020/02/04/powershell-on-windows-10-arm64/
|
# See https://oofhours.com/2020/02/04/powershell-on-windows-10-arm64/
|
||||||
$my_os_arch = wmic os get osarchitecture
|
$my_os_arch = (Get-CimInstance -ClassName Win32_OperatingSystem).OSArchitecture
|
||||||
|
|
||||||
# Using -clike because of the trailing newline
|
# Using -clike because of the trailing newline
|
||||||
IF ($my_os_arch -clike "ARM 64*") {
|
IF ($my_os_arch -clike "ARM 64*") {
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ __bootstrap_webi() {
|
|||||||
#PKG_LIBCS=
|
#PKG_LIBCS=
|
||||||
#PKG_FORMATS=
|
#PKG_FORMATS=
|
||||||
#PKG_LATEST=
|
#PKG_LATEST=
|
||||||
|
#PKG_STABLE=
|
||||||
WEBI_PKG_DOWNLOAD=""
|
WEBI_PKG_DOWNLOAD=""
|
||||||
WEBI_DOWNLOAD_DIR="${HOME}/Downloads"
|
WEBI_DOWNLOAD_DIR="${HOME}/Downloads"
|
||||||
if command -v xdg-user-dir > /dev/null; then
|
if command -v xdg-user-dir > /dev/null; then
|
||||||
@@ -36,7 +37,7 @@ __bootstrap_webi() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
WEBI_PKG_PATH="${WEBI_DOWNLOAD_DIR}/webi/${PKG_NAME:-error}/${WEBI_VERSION:-latest}"
|
WEBI_PKG_PATH="${WEBI_DOWNLOAD_DIR}/webi/${PKG_NAME:-error}/${WEBI_VERSION:-stable}"
|
||||||
|
|
||||||
# get the special formatted version
|
# get the special formatted version
|
||||||
# (i.e. "go is go1.14" while node is "node v12.10.8")
|
# (i.e. "go is go1.14" while node is "node v12.10.8")
|
||||||
@@ -127,7 +128,10 @@ __bootstrap_webi() {
|
|||||||
echo ""
|
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 " $(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 ""
|
||||||
echo " Latest Version: ${PKG_LATEST}"
|
echo " Latest Stable: ${PKG_STABLE}"
|
||||||
|
if test "${PKG_LATEST}" != "${PKG_STABLE}"; then
|
||||||
|
echo " Next Version: ${PKG_LATEST}"
|
||||||
|
fi
|
||||||
echo " CPUs: $PKG_ARCHES"
|
echo " CPUs: $PKG_ARCHES"
|
||||||
echo " OSes: $PKG_OSES"
|
echo " OSes: $PKG_OSES"
|
||||||
echo " libcs: $PKG_LIBCS"
|
echo " libcs: $PKG_LIBCS"
|
||||||
@@ -235,8 +239,6 @@ __bootstrap_webi() {
|
|||||||
webi_path_add() {
|
webi_path_add() {
|
||||||
my_path="${1}"
|
my_path="${1}"
|
||||||
|
|
||||||
fn_envman_init
|
|
||||||
|
|
||||||
# \v was chosen as it is extremely unlikely for a filename
|
# \v was chosen as it is extremely unlikely for a filename
|
||||||
# \1 could be an even better choice, but needs more testing.
|
# \1 could be an even better choice, but needs more testing.
|
||||||
# (currently tested working on: linux & mac)
|
# (currently tested working on: linux & mac)
|
||||||
@@ -399,7 +401,6 @@ __bootstrap_webi() {
|
|||||||
export _webi_tmp="${_webi_tmp:-"$HOME/.local/opt/webi-tmp.d"}"
|
export _webi_tmp="${_webi_tmp:-"$HOME/.local/opt/webi-tmp.d"}"
|
||||||
|
|
||||||
mkdir -p "${WEBI_PKG_PATH}"
|
mkdir -p "${WEBI_PKG_PATH}"
|
||||||
mkdir -p "$HOME/.local/bin"
|
|
||||||
mkdir -p "$HOME/.local/opt"
|
mkdir -p "$HOME/.local/opt"
|
||||||
|
|
||||||
if test -e ~/.local/bin; then
|
if test -e ~/.local/bin; then
|
||||||
@@ -408,6 +409,7 @@ __bootstrap_webi() {
|
|||||||
echo " Creating$(t_path ' ~/.local/bin')"
|
echo " Creating$(t_path ' ~/.local/bin')"
|
||||||
mkdir -p "$HOME/.local/bin"
|
mkdir -p "$HOME/.local/bin"
|
||||||
fi
|
fi
|
||||||
|
fn_envman_init
|
||||||
|
|
||||||
##
|
##
|
||||||
##
|
##
|
||||||
|
|||||||
@@ -70,18 +70,20 @@ InstallerServer.helper = async function ({
|
|||||||
|
|
||||||
console.log(`dbg: Get Project Installer Type for '${projectName}':`);
|
console.log(`dbg: Get Project Installer Type for '${projectName}':`);
|
||||||
let proj = await Builds.getProjectType(projectName);
|
let proj = await Builds.getProjectType(projectName);
|
||||||
console.log(proj);
|
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);
|
||||||
|
|
||||||
let validTypes = ['alias', 'selfhosted', 'valid'];
|
let validTypes = ['selfhosted', 'valid'];
|
||||||
if (!validTypes.includes(proj.type)) {
|
if (!validTypes.includes(proj.type)) {
|
||||||
let msg = `'${projectName}' doesn't have an installer: '${proj.type}': '${proj.detail}'`;
|
let msg = `'${projectName}' doesn't have an installer: '${proj.type}': '${proj.detail}'`;
|
||||||
let err = new Error(msg);
|
let err = new Error(msg);
|
||||||
err.code = 'ENOENT';
|
err.code = 'ENOENT';
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
if (proj.type === 'alias') {
|
|
||||||
projectName = proj.detail;
|
|
||||||
}
|
|
||||||
|
|
||||||
let tmplParams = {
|
let tmplParams = {
|
||||||
pkg: projectName,
|
pkg: projectName,
|
||||||
@@ -120,8 +122,7 @@ InstallerServer.helper = async function ({
|
|||||||
name: projectName,
|
name: projectName,
|
||||||
date: new Date(),
|
date: new Date(),
|
||||||
});
|
});
|
||||||
let latest = projInfo.versions[0];
|
let latestVersions = Builds.enumerateLatestVersions(projInfo);
|
||||||
Object.assign(tmplParams, { latest });
|
|
||||||
//console.log('projInfo', projInfo);
|
//console.log('projInfo', projInfo);
|
||||||
|
|
||||||
let buildTargetInfo = {
|
let buildTargetInfo = {
|
||||||
@@ -130,12 +131,27 @@ InstallerServer.helper = async function ({
|
|||||||
arches: projInfo.arches,
|
arches: projInfo.arches,
|
||||||
libcs: projInfo.libcs,
|
libcs: projInfo.libcs,
|
||||||
formats: projInfo.formats,
|
formats: projInfo.formats,
|
||||||
|
latest: latestVersions.latest,
|
||||||
|
stable: latestVersions.stable,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO .findMatchingPackages() should probably account for this
|
||||||
let hasOs = projInfo.oses.includes(hostTarget.os);
|
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) {
|
if (!hasOs) {
|
||||||
hasOs = projInfo.oses.includes('ANYOS');
|
hasOs = projInfo.oses.includes('ANYOS');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasOs) {
|
if (!hasOs) {
|
||||||
let pkg1 = Object.assign(buildTargetInfo, errPackage);
|
let pkg1 = Object.assign(buildTargetInfo, errPackage);
|
||||||
return [pkg1, tmplParams];
|
return [pkg1, tmplParams];
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
var Releases = module.exports;
|
var Releases = module.exports;
|
||||||
|
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var request = require('@root/request');
|
|
||||||
var _normalize = require('./normalize.js');
|
var _normalize = require('./normalize.js');
|
||||||
|
|
||||||
var cache = {};
|
var cache = {};
|
||||||
@@ -17,14 +16,18 @@ let installerDir = path.join(__dirname, '..');
|
|||||||
Releases.get = async function (pkgdir) {
|
Releases.get = async function (pkgdir) {
|
||||||
let get;
|
let get;
|
||||||
try {
|
try {
|
||||||
get = require(path.join(pkgdir, 'releases.js'));
|
get = require(`${pkgdir}/releases.js`);
|
||||||
|
// TODO update all releases files with module.exports.xxxx = 'foo';
|
||||||
|
if (!get.latest) {
|
||||||
|
get.latest = get;
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
let err = new Error('no releases.js for', pkgdir.split(/[\/\\]+/).pop());
|
let err = new Error('no releases.js for', pkgdir.split(/[\/\\]+/).pop());
|
||||||
err.code = 'E_NO_RELEASE';
|
err.code = 'E_NO_RELEASE';
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
||||||
let all = await get(request);
|
let all = await get.latest();
|
||||||
|
|
||||||
return _normalize(all);
|
return _normalize(all);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,29 +1,21 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var githubSource = require('../_common/github-source.js');
|
let Releases = module.exports;
|
||||||
var owner = 'BeyondCodeBootcamp';
|
|
||||||
var repo = 'aliasman';
|
|
||||||
|
|
||||||
module.exports = function (request) {
|
let GitHubSource = require('../_common/github-source.js');
|
||||||
let arches = [
|
let owner = 'BeyondCodeBootcamp';
|
||||||
'amd64',
|
let repo = 'aliasman';
|
||||||
'arm64',
|
|
||||||
'armv6l',
|
Releases.latest = async function () {
|
||||||
'armv7l',
|
let all = await GitHubSource.getDistributables({ owner, repo });
|
||||||
'ppc64le',
|
for (let pkg of all.releases) {
|
||||||
'ppc64',
|
pkg.os = 'posix_2017';
|
||||||
's390x',
|
}
|
||||||
'x86',
|
return all;
|
||||||
];
|
|
||||||
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) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
Releases.latest().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
console.info(JSON.stringify(all, null, 2));
|
console.info(JSON.stringify(all, null, 2));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,15 +4,15 @@ var github = require('../_common/github.js');
|
|||||||
var owner = 'mholt';
|
var owner = 'mholt';
|
||||||
var repo = 'archiver';
|
var repo = 'archiver';
|
||||||
|
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
all._names = ['archiver', 'arc'];
|
all._names = ['archiver', 'arc'];
|
||||||
return all;
|
return all;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
// just select the first 5 for demonstration
|
// just select the first 5 for demonstration
|
||||||
all.releases = all.releases.slice(0, 5);
|
all.releases = all.releases.slice(0, 5);
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ let targets = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
for (let rel of all.releases) {
|
for (let rel of all.releases) {
|
||||||
let windows32 = rel.name.includes('WindowsX86.');
|
let windows32 = rel.name.includes('WindowsX86.');
|
||||||
if (windows32) {
|
if (windows32) {
|
||||||
@@ -71,7 +71,7 @@ module.exports = function (request) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
console.info(JSON.stringify(all));
|
console.info(JSON.stringify(all));
|
||||||
//console.info(JSON.stringify(all, null, 2));
|
//console.info(JSON.stringify(all, null, 2));
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ var github = require('../_common/github.js');
|
|||||||
var owner = 'wallix';
|
var owner = 'wallix';
|
||||||
var repo = 'awless';
|
var repo = 'awless';
|
||||||
|
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
// remove checksums and .deb
|
// remove checksums and .deb
|
||||||
all.releases = all.releases.filter(function (rel) {
|
all.releases = all.releases.filter(function (rel) {
|
||||||
return !/(\.txt)|(\.deb)$/i.test(rel.name);
|
return !/(\.txt)|(\.deb)$/i.test(rel.name);
|
||||||
@@ -15,7 +15,7 @@ module.exports = function (request) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
console.info(JSON.stringify(all));
|
console.info(JSON.stringify(all));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
|
|||||||
var owner = 'sharkdp';
|
var owner = 'sharkdp';
|
||||||
var repo = 'bat';
|
var repo = 'bat';
|
||||||
|
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
return all;
|
return all;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
all.releases = all.releases.slice(0, 10);
|
all.releases = all.releases.slice(0, 10);
|
||||||
//console.info(JSON.stringify(all));
|
//console.info(JSON.stringify(all));
|
||||||
|
|||||||
@@ -7,13 +7,13 @@ main() { (
|
|||||||
chmod a+x ~/.local/bin/brew-update-hourly
|
chmod a+x ~/.local/bin/brew-update-hourly
|
||||||
|
|
||||||
echo "Checking for serviceman..."
|
echo "Checking for serviceman..."
|
||||||
|
~/.local/bin/webi serviceman
|
||||||
if ! command -v serviceman > /dev/null; then
|
if ! command -v serviceman > /dev/null; then
|
||||||
"$HOME/.local/bin/webi" serviceman
|
|
||||||
export PATH="$HOME/.local/bin:$PATH"
|
export PATH="$HOME/.local/bin:$PATH"
|
||||||
serviceman --version
|
|
||||||
fi
|
fi
|
||||||
|
serviceman --version
|
||||||
|
|
||||||
env PATH="$PATH" serviceman add --user \
|
serviceman add --agent \
|
||||||
--workdir ~/.local/opt/brew/ \
|
--workdir ~/.local/opt/brew/ \
|
||||||
--name sh.brew.updater -- \
|
--name sh.brew.updater -- \
|
||||||
~/.local/bin/brew-update-hourly
|
~/.local/bin/brew-update-hourly
|
||||||
|
|||||||
@@ -132,9 +132,7 @@ file)
|
|||||||
```
|
```
|
||||||
3. Add your project to the system launcher, running as the current user
|
3. Add your project to the system launcher, running as the current user
|
||||||
```sh
|
```sh
|
||||||
sudo env PATH="$PATH" \
|
serviceman add --name 'my-project' --daemon -- \
|
||||||
serviceman add --path="$PATH" --system \
|
|
||||||
--username "$(whoami)" --name my-project -- \
|
|
||||||
bun run ./my-project.js
|
bun run ./my-project.js
|
||||||
```
|
```
|
||||||
4. Restart the logging service
|
4. Restart the logging service
|
||||||
@@ -155,6 +153,6 @@ For **macOS**:
|
|||||||
```
|
```
|
||||||
3. Add your project to the system launcher, running as the current user
|
3. Add your project to the system launcher, running as the current user
|
||||||
```sh
|
```sh
|
||||||
serviceman add --path="$PATH" --user --name my-project -- \
|
serviceman add --agent --name 'my-project' -- \
|
||||||
bun run ./my-project.js
|
bun run ./my-project.js
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ var github = require('../_common/github.js');
|
|||||||
var owner = 'oven-sh';
|
var owner = 'oven-sh';
|
||||||
var repo = 'bun';
|
var repo = 'bun';
|
||||||
|
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
all.releases = all.releases
|
all.releases = all.releases
|
||||||
.filter(function (r) {
|
.filter(function (r) {
|
||||||
let isDebug = r.name.includes('-profile');
|
let isDebug = r.name.includes('-profile');
|
||||||
@@ -18,6 +18,14 @@ module.exports = function (request) {
|
|||||||
return false;
|
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;
|
return true;
|
||||||
})
|
})
|
||||||
.map(function (r) {
|
.map(function (r) {
|
||||||
@@ -30,7 +38,7 @@ module.exports = function (request) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
// just select the first 5 for demonstration
|
// just select the first 5 for demonstration
|
||||||
all.releases = all.releases.slice(0, 5);
|
all.releases = all.releases.slice(0, 5);
|
||||||
|
|||||||
@@ -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
|
2. Use Serviceman to create a _launchd_ plist file
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
my_username="$( id -u -n )"
|
my_username="$(id -u -n)"
|
||||||
|
|
||||||
serviceman add --user --name caddy -- \
|
serviceman add --agent --name 'caddy' --workdir ./ -- \
|
||||||
caddy run --config ./Caddyfile --envfile ~/.config/caddy/env
|
caddy run --envfile ~/.config/caddy/env --config ./Caddyfile --adapter caddyfile
|
||||||
```
|
```
|
||||||
|
|
||||||
(this will create `~/Library/LaunchAgents/caddy.plist`)
|
(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:
|
create a _System-Level_ service in `/Library/LaunchDaemons/` instead:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
sudo serviceman add --system --name caddy -- \
|
serviceman add --name 'caddy' --workdir ./ --daemon -- \
|
||||||
caddy run --config ./Caddyfile --envfile ~/.config/caddy/env
|
caddy run --envfile ~/.config/caddy/env --config ./Caddyfile --adapter caddyfile
|
||||||
```
|
```
|
||||||
|
|
||||||
### How to run Caddy as a Windows Service
|
### How to run Caddy as a Windows Service
|
||||||
@@ -856,7 +856,7 @@ sudo serviceman add --system --name caddy -- \
|
|||||||
3. Create a **Startup Registry Entry** with Serviceman.
|
3. Create a **Startup Registry Entry** with Serviceman.
|
||||||
```sh
|
```sh
|
||||||
serviceman.exe add --name caddy -- \
|
serviceman.exe add --name caddy -- \
|
||||||
caddy run --config ./Caddyfile --envfile ~/.config/caddy/env
|
caddy run --envfile ~/.config/caddy/env --config ./Caddyfile --adapter caddyfile
|
||||||
```
|
```
|
||||||
4. You can manage the service directly with Serviceman. For example:
|
4. You can manage the service directly with Serviceman. For example:
|
||||||
```sh
|
```sh
|
||||||
@@ -901,10 +901,8 @@ See the notes below to run as a **User Service** or use the JSON Config.
|
|||||||
```
|
```
|
||||||
4. Use Serviceman to create a _systemd_ config file.
|
4. Use Serviceman to create a _systemd_ config file.
|
||||||
```sh
|
```sh
|
||||||
my_username="$( id -u -n )"
|
serviceman add --name 'caddy' --daemon -- \
|
||||||
sudo env PATH="$PATH" \
|
caddy run --envfile ~/.config/caddy/env --config ./Caddyfile --adapter caddyfile
|
||||||
serviceman add --system --username "${my_username}" --name caddy -- \
|
|
||||||
caddy run --config ./Caddyfile --envfile ~/.config/caddy/env
|
|
||||||
```
|
```
|
||||||
(this will create `/etc/systemd/system/caddy.service`)
|
(this will create `/etc/systemd/system/caddy.service`)
|
||||||
5. Manage the service with `systemctl` and `journalctl`:
|
5. Manage the service with `systemctl` and `journalctl`:
|
||||||
@@ -915,10 +913,10 @@ See the notes below to run as a **User Service** or use the JSON Config.
|
|||||||
|
|
||||||
To create a **User Service** instead:
|
To create a **User Service** instead:
|
||||||
|
|
||||||
- don't use `sudo`, but do use `--user` when running `serviceman`:
|
- use `--agent` when running `serviceman`:
|
||||||
```sh
|
```sh
|
||||||
serviceman add --user --name caddy -- \
|
serviceman add --agent --name caddy -- \
|
||||||
caddy run --config ./Caddyfile --envfile ~/.config/caddy/env
|
caddy run --envfile ~/.config/caddy/env --config ./Caddyfile --adapter caddyfile
|
||||||
```
|
```
|
||||||
(this will create `~/.config/systemd/user/`)
|
(this will create `~/.config/systemd/user/`)
|
||||||
- user the `--user` flag to manage services and logs:
|
- user the `--user` flag to manage services and logs:
|
||||||
@@ -1363,19 +1361,13 @@ See also: <https://caddyserver.com/docs/running>
|
|||||||
2. Generate the `service` file: \
|
2. Generate the `service` file: \
|
||||||
- JSON Config
|
- JSON Config
|
||||||
```sh
|
```sh
|
||||||
my_app_user="$( id -u -n )"
|
serviceman add --name 'caddy' --daemon -- \
|
||||||
sudo env PATH="${PATH}" \
|
caddy run --resume --envfile ./caddy.env
|
||||||
serviceman add --system --cap-net-bind \
|
|
||||||
--username "${my_app_user}" --name caddy -- \
|
|
||||||
caddy run --resume --envfile ./caddy.env
|
|
||||||
```
|
```
|
||||||
- Caddyfile
|
- Caddyfile
|
||||||
```sh
|
```sh
|
||||||
my_app_user="$( id -u -n )"
|
serviceman add --name 'caddy' --daemon -- \
|
||||||
sudo env PATH="${PATH}" \
|
caddy run --config ./Caddyfile --envfile ./caddy.env
|
||||||
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
|
3. Reload `systemd` config files, the logging service (it may not be started on
|
||||||
a new VPS), and caddy
|
a new VPS), and caddy
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ var github = require('../_common/github.js');
|
|||||||
var owner = 'caddyserver';
|
var owner = 'caddyserver';
|
||||||
var repo = 'caddy';
|
var repo = 'caddy';
|
||||||
|
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
// remove checksums and .deb
|
// remove checksums and .deb
|
||||||
all.releases = all.releases.filter(function (rel) {
|
all.releases = all.releases.filter(function (rel) {
|
||||||
let isOneOffAsset = rel.download.includes('buildable-artifact');
|
let isOneOffAsset = rel.download.includes('buildable-artifact');
|
||||||
@@ -20,7 +20,7 @@ module.exports = function (request) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
console.info(JSON.stringify(all));
|
console.info(JSON.stringify(all));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
let Fetcher = require('../_common/fetcher.js');
|
||||||
|
|
||||||
// See <https://googlechromelabs.github.io/chrome-for-testing/>
|
// See <https://googlechromelabs.github.io/chrome-for-testing/>
|
||||||
var releaseApiUrl =
|
const releaseApiUrl =
|
||||||
'https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json';
|
'https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json';
|
||||||
|
|
||||||
// {
|
// {
|
||||||
@@ -40,14 +42,24 @@ var releaseApiUrl =
|
|||||||
// ]
|
// ]
|
||||||
// }
|
// }
|
||||||
|
|
||||||
module.exports = async function (request) {
|
module.exports = async function () {
|
||||||
let resp = await request({
|
let resp;
|
||||||
url: releaseApiUrl,
|
try {
|
||||||
json: true,
|
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);
|
||||||
|
|
||||||
let builds = [];
|
let builds = [];
|
||||||
for (let release of resp.body.versions) {
|
for (let release of data.versions) {
|
||||||
if (!release.downloads.chromedriver) {
|
if (!release.downloads.chromedriver) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -58,7 +70,7 @@ module.exports = async function (request) {
|
|||||||
version: version,
|
version: version,
|
||||||
download: asset.url,
|
download: asset.url,
|
||||||
// I' not sure that this is actually statically built but it
|
// I' not sure that this is actually statically built but it
|
||||||
// seems to be and at worst we'll just get bug reports for Apline
|
// seems to be and at worst we'll just get bug reports for Alpine
|
||||||
libc: 'none',
|
libc: 'none',
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -75,10 +87,15 @@ module.exports = async function (request) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module
|
||||||
all = require('../_webi/normalize.js')(all);
|
.exports()
|
||||||
// just select the latest 5 for demonstration
|
.then(function (all) {
|
||||||
all.releases = all.releases.slice(-20);
|
all = require('../_webi/normalize.js')(all);
|
||||||
console.info(JSON.stringify(all, null, 2));
|
// 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);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
47
cilium/README.md
Normal file
47
cilium/README.md
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
---
|
||||||
|
title: cilium
|
||||||
|
homepage: https://github.com/cilium/cilium-cli
|
||||||
|
tagline: |
|
||||||
|
cilium: manage & troubleshoot Kubernetes clusters running Cilium
|
||||||
|
---
|
||||||
|
|
||||||
|
To update or switch versions, run `webi cilium@stable` (or `@v2`, `@beta`,etc).
|
||||||
|
|
||||||
|
### Files
|
||||||
|
|
||||||
|
These are the files / directories that are created and/or modified with this
|
||||||
|
install:
|
||||||
|
|
||||||
|
```text
|
||||||
|
~/.config/envman/PATH.env
|
||||||
|
~/.local/bin/cilium
|
||||||
|
~/.local/opt/cilium/
|
||||||
|
```
|
||||||
|
|
||||||
|
## Cheat Sheet
|
||||||
|
|
||||||
|
> Cilium is an open source, cloud native solution for providing, securing, and
|
||||||
|
> observing network connectivity between workloads, fueled by the revolutionary
|
||||||
|
> Kernel technology eBPF.
|
||||||
|
|
||||||
|
Quick Start User Guide:
|
||||||
|
|
||||||
|
<https://docs.cilium.io/en/stable/gettingstarted/k8s-install-default/#k8s-install-quick>
|
||||||
|
|
||||||
|
To install the default version of the Cilium image:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cilium install
|
||||||
|
```
|
||||||
|
|
||||||
|
To upgrade to a specific version of the Cilium image:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cilium upgrade --version v1.15.3
|
||||||
|
```
|
||||||
|
|
||||||
|
To check the status of the current Cilium deployment:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cilium status
|
||||||
|
```
|
||||||
45
cilium/install.ps1
Normal file
45
cilium/install.ps1
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
#!/usr/bin/env pwsh
|
||||||
|
|
||||||
|
##################
|
||||||
|
# Install cilium #
|
||||||
|
##################
|
||||||
|
|
||||||
|
$pkg_cmd_name = "cilium"
|
||||||
|
|
||||||
|
$pkg_dst_cmd = "$Env:USERPROFILE\.local\bin\cilium.exe"
|
||||||
|
$pkg_dst = "$pkg_dst_cmd"
|
||||||
|
|
||||||
|
$pkg_src_cmd = "$Env:USERPROFILE\.local\opt\cilium-v$Env:WEBI_VERSION\bin\cilium.exe"
|
||||||
|
$pkg_src_bin = "$Env:USERPROFILE\.local\opt\cilium-v$Env:WEBI_VERSION\bin"
|
||||||
|
$pkg_src_dir = "$Env:USERPROFILE\.local\opt\cilium-v$Env:WEBI_VERSION"
|
||||||
|
$pkg_src = "$pkg_src_cmd"
|
||||||
|
|
||||||
|
New-Item "$Env:USERPROFILE\Downloads\webi" -ItemType Directory -Force | Out-Null
|
||||||
|
$pkg_download = "$Env:USERPROFILE\Downloads\webi\$Env:WEBI_PKG_FILE"
|
||||||
|
|
||||||
|
IF (!(Test-Path -Path "$Env:USERPROFILE\Downloads\webi\$Env:WEBI_PKG_FILE")) {
|
||||||
|
Write-Output "Downloading cilium from $Env:WEBI_PKG_URL to $pkg_download"
|
||||||
|
& curl.exe -A "$Env:WEBI_UA" -fsSL "$Env:WEBI_PKG_URL" -o "$pkg_download.part"
|
||||||
|
& Move-Item "$pkg_download.part" "$pkg_download"
|
||||||
|
}
|
||||||
|
|
||||||
|
IF (!(Test-Path -Path "$pkg_src_cmd")) {
|
||||||
|
Write-Output "Installing cilium"
|
||||||
|
Push-Location .local\tmp
|
||||||
|
|
||||||
|
Remove-Item -Path ".\cilium-v*" -Recurse -ErrorAction Ignore
|
||||||
|
Remove-Item -Path ".\cilium.exe" -Recurse -ErrorAction Ignore
|
||||||
|
|
||||||
|
Write-Output "Unpacking $pkg_download"
|
||||||
|
& tar xf "$pkg_download"
|
||||||
|
|
||||||
|
Write-Output "Install Location: $pkg_src_cmd"
|
||||||
|
New-Item "$pkg_src_bin" -ItemType Directory -Force
|
||||||
|
Move-Item -Path ".\cilium-*\cilium.exe" -Destination "$pkg_src_bin"
|
||||||
|
|
||||||
|
Pop-Location
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Output "Copying into '$pkg_dst_cmd' from '$pkg_src_cmd'"
|
||||||
|
Remove-Item -Path "$pkg_dst_cmd" -Recurse -ErrorAction Ignore
|
||||||
|
Copy-Item -Path "$pkg_src" -Destination "$pkg_dst" -Recurse
|
||||||
39
cilium/install.sh
Normal file
39
cilium/install.sh
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
__init_cilium() {
|
||||||
|
set -e
|
||||||
|
set -u
|
||||||
|
|
||||||
|
##################
|
||||||
|
# Install cilium #
|
||||||
|
##################
|
||||||
|
|
||||||
|
pkg_cmd_name="cilium"
|
||||||
|
|
||||||
|
pkg_dst_cmd="$HOME/.local/bin/cilium"
|
||||||
|
pkg_dst="$pkg_dst_cmd"
|
||||||
|
|
||||||
|
pkg_src_cmd="$HOME/.local/opt/cilium-v$WEBI_VERSION/bin/cilium"
|
||||||
|
pkg_src_dir="$HOME/.local/opt/cilium-v$WEBI_VERSION"
|
||||||
|
pkg_src="$pkg_src_cmd"
|
||||||
|
|
||||||
|
WEBI_SINGLE=true
|
||||||
|
|
||||||
|
# pkg_install must be defined by every package
|
||||||
|
pkg_install() {
|
||||||
|
# ~/.local/opt/cilium-v0.16.16/bin
|
||||||
|
mkdir -p "$(dirname "${pkg_src_cmd}")"
|
||||||
|
|
||||||
|
# mv ./hugo ~/.local/opt/cilium-v0.16.16/bin/
|
||||||
|
mv ./cilium "${pkg_src_cmd}"
|
||||||
|
}
|
||||||
|
|
||||||
|
pkg_get_current_version() {
|
||||||
|
cilium version 2> /dev/null |
|
||||||
|
head -n 1 |
|
||||||
|
cut -d ' ' -f 2
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
__init_cilium
|
||||||
21
cilium/releases.js
Normal file
21
cilium/releases.js
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var github = require('../_common/github.js');
|
||||||
|
var owner = 'cilium';
|
||||||
|
var repo = 'cilium-cli';
|
||||||
|
|
||||||
|
module.exports = async function () {
|
||||||
|
let all = await github(null, owner, repo);
|
||||||
|
return all;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (module === require.main) {
|
||||||
|
(async function () {
|
||||||
|
let normalize = require('../_webi/normalize.js');
|
||||||
|
let all = await module.exports();
|
||||||
|
all = normalize(all);
|
||||||
|
// just select the first 5 for demonstration
|
||||||
|
all.releases = all.releases.slice(0, 5);
|
||||||
|
console.info(JSON.stringify(all, null, 2));
|
||||||
|
})();
|
||||||
|
}
|
||||||
@@ -4,8 +4,8 @@ var github = require('../_common/github.js');
|
|||||||
var owner = 'Kitware';
|
var owner = 'Kitware';
|
||||||
var repo = 'CMake';
|
var repo = 'CMake';
|
||||||
|
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
for (let rel of all.releases) {
|
for (let rel of all.releases) {
|
||||||
if (rel.version.startsWith('v')) {
|
if (rel.version.startsWith('v')) {
|
||||||
rel._version = rel.version.slice(1);
|
rel._version = rel.version.slice(1);
|
||||||
@@ -44,7 +44,7 @@ module.exports = function (request) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
// just select the first 5 for demonstration
|
// just select the first 5 for demonstration
|
||||||
all.releases = all.releases.slice(0, 5);
|
all.releases = all.releases.slice(0, 5);
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ var repo = 'comrak';
|
|||||||
|
|
||||||
var ODDITIES = ['-musleabihf.1-'];
|
var ODDITIES = ['-musleabihf.1-'];
|
||||||
|
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
let builds = [];
|
let builds = [];
|
||||||
|
|
||||||
loopBuilds: for (let build of all.releases) {
|
loopBuilds: for (let build of all.releases) {
|
||||||
@@ -31,7 +31,7 @@ module.exports = function (request) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
all.releases = all.releases.slice(0, 10);
|
all.releases = all.releases.slice(0, 10);
|
||||||
//console.info(JSON.stringify(all));
|
//console.info(JSON.stringify(all));
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ var github = require('../_common/github.js');
|
|||||||
var owner = 'sstadick';
|
var owner = 'sstadick';
|
||||||
var repo = 'crabz';
|
var repo = 'crabz';
|
||||||
|
|
||||||
module.exports = async function (request) {
|
module.exports = async function () {
|
||||||
let all = await github(request, owner, repo);
|
let all = await github(null, owner, repo);
|
||||||
|
|
||||||
let releases = [];
|
let releases = [];
|
||||||
for (let rel of all.releases) {
|
for (let rel of all.releases) {
|
||||||
@@ -22,7 +22,7 @@ module.exports = async function (request) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
// just select the first 5 for demonstration
|
// just select the first 5 for demonstration
|
||||||
all.releases = all.releases.slice(0, 5);
|
all.releases = all.releases.slice(0, 5);
|
||||||
|
|||||||
@@ -4,15 +4,15 @@ var github = require('../_common/github.js');
|
|||||||
var owner = 'rs';
|
var owner = 'rs';
|
||||||
var repo = 'curlie';
|
var repo = 'curlie';
|
||||||
|
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
all._names = ['curlie', 'curl-httpie'];
|
all._names = ['curlie', 'curl-httpie'];
|
||||||
return all;
|
return all;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
all.releases = all.releases.slice(0, 10);
|
all.releases = all.releases.slice(0, 10);
|
||||||
//console.info(JSON.stringify(all));
|
//console.info(JSON.stringify(all));
|
||||||
|
|||||||
@@ -100,8 +100,7 @@ mkdir -p ~/.dashcore/wallets/
|
|||||||
mkdir -p /mnt/slc1_vol_100g/dashcore/_data
|
mkdir -p /mnt/slc1_vol_100g/dashcore/_data
|
||||||
mkdir -p /mnt/slc1_vol_100g/dashcore/_caches
|
mkdir -p /mnt/slc1_vol_100g/dashcore/_caches
|
||||||
|
|
||||||
sudo env PATH="$PATH" serviceman add \
|
serviceman add --name 'dashd' --daemon -- \
|
||||||
--system --user "$my_user" --path "$PATH" --name dashd --force -- \
|
|
||||||
dashd \
|
dashd \
|
||||||
-usehd \
|
-usehd \
|
||||||
-conf="$HOME/.dashcore/dash.conf" \
|
-conf="$HOME/.dashcore/dash.conf" \
|
||||||
|
|||||||
@@ -84,20 +84,8 @@ fn_srv_install() { (
|
|||||||
my_name="dashd-${my_netname}"
|
my_name="dashd-${my_netname}"
|
||||||
fi
|
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
|
# shellcheck disable=SC2016,SC1090
|
||||||
echo 'sudo env PATH="$PATH"' \
|
echo "serviceman add --name \"${my_name}\" --" \
|
||||||
"serviceman add ${my_system_args} --path \"\$PATH\" --name \"${my_name}\" --force --" \
|
|
||||||
"dashd " \
|
"dashd " \
|
||||||
"${my_net_flag}" \
|
"${my_net_flag}" \
|
||||||
-usehd \
|
-usehd \
|
||||||
@@ -107,16 +95,16 @@ fn_srv_install() { (
|
|||||||
"-datadir=\"${my_datadir}\"" \
|
"-datadir=\"${my_datadir}\"" \
|
||||||
"-blocksdir=\"${my_blocksdir}\""
|
"-blocksdir=\"${my_blocksdir}\""
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "Installing latest 'serviceman'..."
|
||||||
|
echo ""
|
||||||
|
"$HOME/.local/bin/webi" serviceman > /dev/null
|
||||||
if ! command -v serviceman > /dev/null; then
|
if ! command -v serviceman > /dev/null; then
|
||||||
echo ""
|
export PATH="$HOME/.local/bin:$PATH"
|
||||||
echo "Installing 'serviceman'..."
|
fi
|
||||||
echo ""
|
serviceman --version
|
||||||
{
|
if ! command -v dashd > /dev/null; then
|
||||||
"$HOME/.local/bin/webi" serviceman
|
export PATH="$HOME/.local/opt/dashcore/bin:$PATH"
|
||||||
} > /dev/null
|
|
||||||
|
|
||||||
# shellcheck disable=SC1090
|
|
||||||
. ~/.config/envman/PATH.env || true
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p "$HOME/.dashcore/wallets/"
|
mkdir -p "$HOME/.dashcore/wallets/"
|
||||||
@@ -131,8 +119,7 @@ fn_srv_install() { (
|
|||||||
cd "${my_vol}" || return 1
|
cd "${my_vol}" || return 1
|
||||||
# leave options unquoted so they're interpreted separately
|
# leave options unquoted so they're interpreted separately
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
sudo env PATH="${PATH}" \
|
serviceman add --name "${my_name}" -- \
|
||||||
serviceman add ${my_system_args} --path "${PATH}" --name "${my_name}" --force -- \
|
|
||||||
dashd \
|
dashd \
|
||||||
${my_net_flag} \
|
${my_net_flag} \
|
||||||
-usehd \
|
-usehd \
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ var github = require('../_common/github.js');
|
|||||||
var owner = 'dashpay';
|
var owner = 'dashpay';
|
||||||
var repo = 'dash';
|
var repo = 'dash';
|
||||||
|
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
all.releases.forEach(function (rel) {
|
all.releases.forEach(function (rel) {
|
||||||
if (rel.name.includes('osx64')) {
|
if (rel.name.includes('osx64')) {
|
||||||
rel.os = 'macos';
|
rel.os = 'macos';
|
||||||
@@ -22,7 +22,7 @@ module.exports = function (request) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
// just select the first 5 for demonstration
|
// just select the first 5 for demonstration
|
||||||
all.releases = all.releases.slice(0, 5);
|
all.releases = all.releases.slice(0, 5);
|
||||||
|
|||||||
@@ -219,14 +219,7 @@ You can use [`serviceman`](../serviceman/):
|
|||||||
**Linux**
|
**Linux**
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
sudo env PATH="$PATH" \
|
serviceman add --name 'dashd' -- \
|
||||||
serviceman add \
|
|
||||||
--system \
|
|
||||||
--username "$(id -n -u)" \
|
|
||||||
--path "$PATH" \
|
|
||||||
--name dashd \
|
|
||||||
--force \
|
|
||||||
-- \
|
|
||||||
dashd \
|
dashd \
|
||||||
-usehd \
|
-usehd \
|
||||||
-conf="$HOME/.dashcore/dash.conf" \
|
-conf="$HOME/.dashcore/dash.conf" \
|
||||||
@@ -239,11 +232,7 @@ sudo env PATH="$PATH" \
|
|||||||
**Mac**
|
**Mac**
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
serviceman add \
|
serviceman add --name 'dashd' -- \
|
||||||
--path "$PATH" \
|
|
||||||
--name dashd \
|
|
||||||
--force \
|
|
||||||
-- \
|
|
||||||
dashd \
|
dashd \
|
||||||
-usehd \
|
-usehd \
|
||||||
-conf="$HOME/.dashcore/dash.conf" \
|
-conf="$HOME/.dashcore/dash.conf" \
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
|
|||||||
var owner = 'dashhive';
|
var owner = 'dashhive';
|
||||||
var repo = 'dashmsg';
|
var repo = 'dashmsg';
|
||||||
|
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
return all;
|
return all;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
console.info(JSON.stringify(all, null, 2));
|
console.info(JSON.stringify(all, null, 2));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
|
|||||||
var owner = 'dandavison';
|
var owner = 'dandavison';
|
||||||
var repo = 'delta';
|
var repo = 'delta';
|
||||||
|
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
return all;
|
return all;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
// just select the first 15 for demonstration
|
// just select the first 15 for demonstration
|
||||||
all.releases = all.releases.slice(0, 15);
|
all.releases = all.releases.slice(0, 15);
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ var github = require('../_common/github.js');
|
|||||||
var owner = 'denoland';
|
var owner = 'denoland';
|
||||||
var repo = 'deno';
|
var repo = 'deno';
|
||||||
|
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
// remove checksums and .deb
|
// remove checksums and .deb
|
||||||
all.releases = all.releases
|
all.releases = all.releases
|
||||||
.filter(function (rel) {
|
.filter(function (rel) {
|
||||||
@@ -35,7 +35,7 @@ module.exports = function (request) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
console.info(JSON.stringify(all, null, 2));
|
console.info(JSON.stringify(all, null, 2));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
|
|||||||
var owner = 'dotenv-linter';
|
var owner = 'dotenv-linter';
|
||||||
var repo = 'dotenv-linter';
|
var repo = 'dotenv-linter';
|
||||||
|
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
return all;
|
return all;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
// just select the first 5 for demonstration
|
// just select the first 5 for demonstration
|
||||||
all.releases = all.releases.slice(0, 5);
|
all.releases = all.releases.slice(0, 5);
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
|
|||||||
var owner = 'therootcompany';
|
var owner = 'therootcompany';
|
||||||
var repo = 'dotenv';
|
var repo = 'dotenv';
|
||||||
|
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
return all;
|
return all;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
console.info(JSON.stringify(all));
|
console.info(JSON.stringify(all));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,29 +1,21 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var githubSource = require('../_common/github-source.js');
|
let Releases = module.exports;
|
||||||
var owner = 'BeyondCodeBootcamp';
|
|
||||||
var repo = 'DuckDNS.sh';
|
|
||||||
|
|
||||||
module.exports = function (request) {
|
let GitHubSource = require('../_common/github-source.js');
|
||||||
let arches = [
|
let owner = 'BeyondCodeBootcamp';
|
||||||
'amd64',
|
let repo = 'DuckDNS.sh';
|
||||||
'arm64',
|
|
||||||
'armv6l',
|
Releases.latest = async function () {
|
||||||
'armv7l',
|
let all = await GitHubSource.getDistributables({ owner, repo });
|
||||||
'ppc64le',
|
for (let pkg of all.releases) {
|
||||||
'ppc64',
|
pkg.os = 'posix_2017';
|
||||||
's390x',
|
}
|
||||||
'x86',
|
return all;
|
||||||
];
|
|
||||||
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) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
Releases.latest().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
console.info(JSON.stringify(all, null, 2));
|
console.info(JSON.stringify(all, null, 2));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,10 +2,16 @@
|
|||||||
set -e
|
set -e
|
||||||
set -u
|
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"}
|
WEBI_HOST=${WEBI_HOST:-"https://webi.sh"}
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo " curl -fsSL '$WEBI_HOST/duckdns.sh@${WEBI_VERSION-}' | sh"
|
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 ""
|
||||||
|
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ var github = require('../_common/github.js');
|
|||||||
var owner = 'sharkdp';
|
var owner = 'sharkdp';
|
||||||
var repo = 'fd';
|
var repo = 'fd';
|
||||||
|
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
let builds = [];
|
let builds = [];
|
||||||
|
|
||||||
for (let build of all.releases) {
|
for (let build of all.releases) {
|
||||||
@@ -22,7 +22,7 @@ module.exports = function (request) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
all.releases = all.releases.slice(0, 10);
|
all.releases = all.releases.slice(0, 10);
|
||||||
//console.info(JSON.stringify(all));
|
//console.info(JSON.stringify(all));
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ var github = require('../_common/github.js');
|
|||||||
var owner = 'eugeneware';
|
var owner = 'eugeneware';
|
||||||
var repo = 'ffmpeg-static';
|
var repo = 'ffmpeg-static';
|
||||||
|
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
all.releases = all.releases
|
all.releases = all.releases
|
||||||
.filter(function (rel) {
|
.filter(function (rel) {
|
||||||
let isFfmpeg = rel.name.includes('ffmpeg');
|
let isFfmpeg = rel.name.includes('ffmpeg');
|
||||||
@@ -38,7 +38,7 @@ module.exports = function (request) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
console.info(JSON.stringify(all));
|
console.info(JSON.stringify(all));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
var path = require('path');
|
|
||||||
|
|
||||||
var github = require('../_common/github.js');
|
|
||||||
var owner = 'eugeneware';
|
|
||||||
var repo = 'ffmpeg-static';
|
|
||||||
|
|
||||||
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');
|
|
||||||
if (!isFfmpeg) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove README and LICENSE
|
|
||||||
return !['.README', '.LICENSE'].includes(path.extname(rel.name));
|
|
||||||
})
|
|
||||||
.map(function (rel) {
|
|
||||||
rel.version = rel.version.replace(/^b/, '');
|
|
||||||
|
|
||||||
if (/win32/.test(rel.name)) {
|
|
||||||
rel.os = 'windows';
|
|
||||||
rel.ext = 'exe';
|
|
||||||
}
|
|
||||||
if (/ia32/.test(rel.name)) {
|
|
||||||
rel.arch = '386';
|
|
||||||
} else if (/x64/.test(rel.name)) {
|
|
||||||
rel.arch = 'amd64';
|
|
||||||
}
|
|
||||||
|
|
||||||
return rel;
|
|
||||||
});
|
|
||||||
return all;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
if (module === require.main) {
|
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
|
||||||
all = require('../_webi/normalize.js')(all);
|
|
||||||
console.info(JSON.stringify(all));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
|
|||||||
var owner = 'ffuf';
|
var owner = 'ffuf';
|
||||||
var repo = 'ffuf';
|
var repo = 'ffuf';
|
||||||
|
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
return all;
|
return all;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
// just select the first 5 for demonstration
|
// just select the first 5 for demonstration
|
||||||
all.releases = all.releases.slice(0, 5);
|
all.releases = all.releases.slice(0, 5);
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ the file:
|
|||||||
```sh
|
```sh
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
echo "Who am I? I'm $(whoami)."
|
echo "Who am I? I'm $(id -u -n)."
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also run bash explicitly:
|
You can also run bash explicitly:
|
||||||
@@ -99,7 +99,7 @@ You should use `chsh` to change your shell:
|
|||||||
```sh
|
```sh
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
sudo chsh -s "$(command -v fish)" "$(whoami)"
|
sudo chsh -s "$(command -v fish)" "$(id -u -n)"
|
||||||
```
|
```
|
||||||
|
|
||||||
If vim uses `fish` instead of `bash`, annoying errors will happen.
|
If vim uses `fish` instead of `bash`, annoying errors will happen.
|
||||||
|
|||||||
@@ -3,51 +3,17 @@ set -e
|
|||||||
set -u
|
set -u
|
||||||
|
|
||||||
if command -v fish > /dev/null; then
|
if command -v fish > /dev/null; then
|
||||||
if ! test -r ~/.config/fish/config.fish; then
|
if [ ! -e ~/.config/fish/config.fish ]; then
|
||||||
mkdir -p ~/.config/fish
|
mkdir -p ~/.config/fish
|
||||||
touch ~/.config/fish/config.fish
|
touch ~/.config/fish/config.fish
|
||||||
chmod 0600 ~/.config/fish/config.fish
|
chmod 0600 ~/.config/fish/config.fish
|
||||||
fi
|
fi
|
||||||
else
|
fi
|
||||||
if command -v sudo > /dev/null; then
|
|
||||||
my_answer='n'
|
|
||||||
if command -v apt > /dev/null; then
|
|
||||||
echo ""
|
|
||||||
echo "ERROR"
|
|
||||||
echo " No Webi installer for fish on Linux yet."
|
|
||||||
echo ""
|
|
||||||
echo "SOLUTION"
|
|
||||||
echo " Would you like to install with apt?"
|
|
||||||
echo " sudo apt install -y fish"
|
|
||||||
echo ""
|
|
||||||
printf "Install with sudo and apt [Y/n]? "
|
|
||||||
elif command -v apk > /dev/null; then
|
|
||||||
echo ""
|
|
||||||
echo "ERROR"
|
|
||||||
echo " No Webi installer for fish on Alpine yet."
|
|
||||||
echo ""
|
|
||||||
echo "SOLUTION"
|
|
||||||
echo " Would you like to install with apk?"
|
|
||||||
echo " sudo apk add --no-cache fish"
|
|
||||||
echo ""
|
|
||||||
printf "Install with sudo and apk [Y/n]? "
|
|
||||||
elif test "Darwin" != "$(uname -s)"; then
|
|
||||||
echo "No fish installer for Linux yet."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
read -r my_answer < /dev/tty
|
if [ "Darwin" != "$(uname -s)" ]; then
|
||||||
if test -z "${my_answer}" ||
|
echo "No fish installer for Linux yet. Try this instead:"
|
||||||
test "${my_answer}" = "Y" ||
|
echo " sudo apt install -y fish"
|
||||||
test "${my_answer}" = "y"; then
|
exit 1
|
||||||
sudo apt install -y fish
|
|
||||||
else
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
elif test "Darwin" != "$(uname -s)"; then
|
|
||||||
echo "No fish installer for Linux yet."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
################
|
################
|
||||||
@@ -71,10 +37,6 @@ pkg_src="$pkg_src_cmd"
|
|||||||
# pkg_install must be defined by every package
|
# pkg_install must be defined by every package
|
||||||
|
|
||||||
_macos_post_install() {
|
_macos_post_install() {
|
||||||
if test "Darwin" != "$(uname -s)"; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! [ -e "$HOME/.local/bin/fish" ]; then
|
if ! [ -e "$HOME/.local/bin/fish" ]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
@@ -109,10 +71,8 @@ _macos_post_install() {
|
|||||||
killall cfprefsd
|
killall cfprefsd
|
||||||
}
|
}
|
||||||
|
|
||||||
if test "Darwin" = "$(uname -s)"; then
|
# always try to reset the default shells
|
||||||
# always try to reset the default shells
|
_macos_post_install
|
||||||
_macos_post_install
|
|
||||||
fi
|
|
||||||
|
|
||||||
pkg_install() {
|
pkg_install() {
|
||||||
mv fish.app/Contents/Resources/base/usr/local "$HOME/.local/opt/fish-v${WEBI_VERSION}"
|
mv fish.app/Contents/Resources/base/usr/local "$HOME/.local/opt/fish-v${WEBI_VERSION}"
|
||||||
@@ -124,10 +84,7 @@ pkg_post_install() {
|
|||||||
webi_post_install
|
webi_post_install
|
||||||
|
|
||||||
# try again to update default shells, now that all files should exist
|
# try again to update default shells, now that all files should exist
|
||||||
if test "Darwin" = "$(uname -s)"; then
|
_macos_post_install
|
||||||
# always try to reset the default shells
|
|
||||||
_macos_post_install
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -e ~/.config/fish/config.fish ]; then
|
if [ ! -e ~/.config/fish/config.fish ]; then
|
||||||
mkdir -p ~/.config/fish
|
mkdir -p ~/.config/fish
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ var repo = 'fish-shell';
|
|||||||
|
|
||||||
var ODDITIES = ['bundledpcre'];
|
var ODDITIES = ['bundledpcre'];
|
||||||
|
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
all.releases = all.releases
|
all.releases = all.releases
|
||||||
.map(function (rel) {
|
.map(function (rel) {
|
||||||
for (let oddity of ODDITIES) {
|
for (let oddity of ODDITIES) {
|
||||||
@@ -30,7 +30,7 @@ module.exports = function (request) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
// just select the first 5 for demonstration
|
// just select the first 5 for demonstration
|
||||||
all.releases = all.releases.slice(0, 5);
|
all.releases = all.releases.slice(0, 5);
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var FLUTTER_OSES = ['macos', 'linux', 'windows'];
|
let Fetcher = require('../_common/fetcher.js');
|
||||||
|
|
||||||
// stable, beta, dev
|
let FLUTTER_OSES = ['macos', 'linux', 'windows'];
|
||||||
var channelMap = {};
|
|
||||||
|
/**
|
||||||
|
* stable, beta, dev
|
||||||
|
* @type {Object.<String, Boolean>}
|
||||||
|
*/
|
||||||
|
let channelMap = {};
|
||||||
|
|
||||||
// This can be spot-checked against
|
// This can be spot-checked against
|
||||||
// https://docs.flutter.dev/release/archive?tab=windows
|
// https://docs.flutter.dev/release/archive?tab=windows
|
||||||
@@ -53,21 +58,45 @@ var channelMap = {};
|
|||||||
// ]
|
// ]
|
||||||
// }
|
// }
|
||||||
|
|
||||||
module.exports = async function (request) {
|
/**
|
||||||
|
* @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 () {
|
||||||
let all = {
|
let all = {
|
||||||
download: '',
|
download: '',
|
||||||
|
/** @type {Array<BuildInfo>} */
|
||||||
releases: [],
|
releases: [],
|
||||||
|
/** @type {Array<String>} */
|
||||||
channels: [],
|
channels: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
for (let osname of FLUTTER_OSES) {
|
for (let osname of FLUTTER_OSES) {
|
||||||
let resp = await request({
|
let resp;
|
||||||
url: `https://storage.googleapis.com/flutter_infra_release/releases/releases_${osname}.json`,
|
try {
|
||||||
json: true,
|
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 osBaseUrl = resp.body.base_url;
|
let osBaseUrl = data.base_url;
|
||||||
let osReleases = resp.body.releases;
|
let osReleases = data.releases;
|
||||||
|
|
||||||
for (let asset of osReleases) {
|
for (let asset of osReleases) {
|
||||||
if (!channelMap[asset.channel]) {
|
if (!channelMap[asset.channel]) {
|
||||||
@@ -80,7 +109,6 @@ module.exports = async function (request) {
|
|||||||
lts: false,
|
lts: false,
|
||||||
channel: asset.channel,
|
channel: asset.channel,
|
||||||
date: asset.release_date.replace(/T.*/, ''),
|
date: asset.release_date.replace(/T.*/, ''),
|
||||||
//sha256: asset.sha256,
|
|
||||||
download: `${osBaseUrl}/${asset.archive}`,
|
download: `${osBaseUrl}/${asset.archive}`,
|
||||||
_filename: asset.archive,
|
_filename: asset.archive,
|
||||||
});
|
});
|
||||||
@@ -97,7 +125,7 @@ module.exports = async function (request) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all.releases = all.releases.slice(25);
|
all.releases = all.releases.slice(25);
|
||||||
console.info(JSON.stringify(all, null, 2));
|
console.info(JSON.stringify(all, null, 2));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
|
|||||||
var owner = 'junegunn';
|
var owner = 'junegunn';
|
||||||
var repo = 'fzf';
|
var repo = 'fzf';
|
||||||
|
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
return all;
|
return all;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
all.releases = all.releases.slice(0, 10);
|
all.releases = all.releases.slice(0, 10);
|
||||||
//console.info(JSON.stringify(all));
|
//console.info(JSON.stringify(all));
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
|
|||||||
var owner = 'cli';
|
var owner = 'cli';
|
||||||
var repo = 'cli';
|
var repo = 'cli';
|
||||||
|
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
return all;
|
return all;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
// just select the first 5 for demonstration
|
// just select the first 5 for demonstration
|
||||||
all.releases = all.releases.slice(0, 5);
|
all.releases = all.releases.slice(0, 5);
|
||||||
|
|||||||
@@ -21,9 +21,10 @@ is a good place to get started if you're new to git.
|
|||||||
- Files
|
- Files
|
||||||
- Commit Files
|
- Commit Files
|
||||||
- Ignore Files
|
- Ignore Files
|
||||||
|
- Reasonable Defaults
|
||||||
- Create Branch
|
- Create Branch
|
||||||
- Rebase by Default
|
|
||||||
- Rebase
|
- Rebase
|
||||||
|
- Auth via SSH
|
||||||
- Auth via Token
|
- Auth via Token
|
||||||
|
|
||||||
### Files
|
### Files
|
||||||
@@ -66,9 +67,49 @@ This will branch from the branch you're currently on.
|
|||||||
git switch -c my-branch-name
|
git switch -c my-branch-name
|
||||||
```
|
```
|
||||||
|
|
||||||
### How to rebase by default
|
### Reasonable Defaults for Git Config
|
||||||
|
|
||||||
|
- use SSH instead of HTTPS
|
||||||
|
- default to 'main'
|
||||||
|
- create on 'push'
|
||||||
|
- stash on 'rebase'
|
||||||
|
- default to 'rebase' (modern)
|
||||||
|
|
||||||
```sh
|
```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
|
git config --global pull.rebase true
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -102,6 +143,26 @@ git add ./my-merged-file
|
|||||||
git rebase --continue
|
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
|
### How to authenticate git with deploy tokens
|
||||||
|
|
||||||
Abbreviated from
|
Abbreviated from
|
||||||
|
|||||||
@@ -14,57 +14,11 @@ __init_git() {
|
|||||||
echo >&2 " for example, try: xcode-select --install"
|
echo >&2 " for example, try: xcode-select --install"
|
||||||
# sudo xcodebuild -license accept
|
# sudo xcodebuild -license accept
|
||||||
else
|
else
|
||||||
fn_prompt_sudo_install git
|
echo >&2 "Error: to install 'git' on Linux use the built-in package manager."
|
||||||
|
echo >&2 " for example, try: sudo apt install -y git"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
fn_prompt_sudo_install() {
|
|
||||||
a_pkg="${1}"
|
|
||||||
|
|
||||||
if command -v sudo > /dev/null; then
|
|
||||||
my_answer='n'
|
|
||||||
cmd_pkg_add=''
|
|
||||||
if command -v apt > /dev/null; then
|
|
||||||
echo ""
|
|
||||||
echo "ERROR"
|
|
||||||
echo " No Webi installer for ${a_pkg} on Linux yet."
|
|
||||||
echo ""
|
|
||||||
echo "SOLUTION"
|
|
||||||
echo " Would you like to install with apt?"
|
|
||||||
echo " sudo apt install -y ${a_pkg}"
|
|
||||||
echo ""
|
|
||||||
printf "Install with sudo and apt [Y/n]? "
|
|
||||||
cmd_pkg_add='sudo apt install -y'
|
|
||||||
elif command -v apk > /dev/null; then
|
|
||||||
echo ""
|
|
||||||
echo "ERROR"
|
|
||||||
echo " No Webi installer for ${a_pkg} on Alpine yet."
|
|
||||||
echo ""
|
|
||||||
echo "SOLUTION"
|
|
||||||
echo " Would you like to install with apk?"
|
|
||||||
echo " sudo apk add --no-cache ${a_pkg}"
|
|
||||||
echo ""
|
|
||||||
printf "Install with sudo and apk [Y/n]? "
|
|
||||||
cmd_pkg_add='sudo apk add --no-cache'
|
|
||||||
elif test "Darwin" != "$(uname -s)"; then
|
|
||||||
echo "No ${a_pkg} installer for Linux yet."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
read -r my_answer < /dev/tty
|
|
||||||
if test -z "${my_answer}" ||
|
|
||||||
test "${my_answer}" = "Y" ||
|
|
||||||
test "${my_answer}" = "y"; then
|
|
||||||
$cmd_pkg_add "${a_pkg}"
|
|
||||||
else
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
elif test "Darwin" != "$(uname -s)"; then
|
|
||||||
echo "No ${a_pkg} installer for Linux yet."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
__init_git
|
__init_git
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ var github = require('../_common/github.js');
|
|||||||
var owner = 'git-for-windows';
|
var owner = 'git-for-windows';
|
||||||
var repo = 'git';
|
var repo = 'git';
|
||||||
|
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
// TODO support mac and linux tarballs
|
// TODO support mac and linux tarballs
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
// See https://github.com/git-for-windows/git/wiki/MinGit
|
// See https://github.com/git-for-windows/git/wiki/MinGit
|
||||||
// also consider https://github.com/git-for-windows/git/wiki/Silent-or-Unattended-Installation
|
// also consider https://github.com/git-for-windows/git/wiki/Silent-or-Unattended-Installation
|
||||||
all.releases = all.releases
|
all.releases = all.releases
|
||||||
@@ -26,7 +26,7 @@ module.exports = function (request) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
console.info(JSON.stringify(all, null, 2));
|
console.info(JSON.stringify(all, null, 2));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
|
|||||||
var owner = 'therootcompany';
|
var owner = 'therootcompany';
|
||||||
var repo = 'gitdeploy';
|
var repo = 'gitdeploy';
|
||||||
|
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
return all;
|
return all;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
console.info(JSON.stringify(all));
|
console.info(JSON.stringify(all));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ var repo = 'gitea';
|
|||||||
|
|
||||||
var ODDITIES = ['-gogit-', '-docs-'];
|
var ODDITIES = ['-gogit-', '-docs-'];
|
||||||
|
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
// remove checksums and .deb
|
// remove checksums and .deb
|
||||||
all.releases = all.releases.filter(function (rel) {
|
all.releases = all.releases.filter(function (rel) {
|
||||||
for (let oddity of ODDITIES) {
|
for (let oddity of ODDITIES) {
|
||||||
@@ -27,7 +27,7 @@ module.exports = function (request) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
console.info(JSON.stringify(all));
|
console.info(JSON.stringify(all));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ including:
|
|||||||
|
|
||||||
- [godoc](https://pkg.go.dev/golang.org/x/tools/cmd/godoc)
|
- [godoc](https://pkg.go.dev/golang.org/x/tools/cmd/godoc)
|
||||||
- [gopls](https://pkg.go.dev/golang.org/x/tools/gopls)
|
- [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)
|
- [golint](https://pkg.go.dev/golang.org/x/lint/golint)
|
||||||
- [goimports](https://pkg.go.dev/golang.org/x/tools/cmd/goimports)
|
- [goimports](https://pkg.go.dev/golang.org/x/tools/cmd/goimports)
|
||||||
- [gomvpkg](https://pkg.go.dev/golang.org/x/tools/cmd/gomvpkg)
|
- [gomvpkg](https://pkg.go.dev/golang.org/x/tools/cmd/gomvpkg)
|
||||||
|
|||||||
@@ -16,10 +16,6 @@ Write-Output ""
|
|||||||
Write-Output gopls
|
Write-Output gopls
|
||||||
& go install golang.org/x/tools/gopls@latest
|
& 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 ""
|
||||||
Write-Output golint
|
Write-Output golint
|
||||||
& go install golang.org/x/lint/golint@latest
|
& go install golang.org/x/lint/golint@latest
|
||||||
|
|||||||
@@ -44,10 +44,6 @@ __run_go_essentials() {
|
|||||||
echo gopls
|
echo gopls
|
||||||
go "${my_install}" golang.org/x/tools/gopls@latest > /dev/null #2>/dev/null
|
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 ""
|
||||||
echo golint
|
echo golint
|
||||||
go "${my_install}" golang.org/x/lint/golint@latest > /dev/null #2>/dev/null
|
go "${my_install}" golang.org/x/lint/golint@latest > /dev/null #2>/dev/null
|
||||||
|
|||||||
@@ -80,8 +80,7 @@ webi serviceman
|
|||||||
pushd ./hello/
|
pushd ./hello/
|
||||||
|
|
||||||
# swap 'hello' and './hello' for the name of your project and binary
|
# swap 'hello' and './hello' for the name of your project and binary
|
||||||
sudo env PATH="$PATH" \
|
serviceman add --name 'hello' -- \
|
||||||
serviceman add --system --username "$(whoami)" --name hello -- \
|
|
||||||
./hello
|
./hello
|
||||||
|
|
||||||
# Restart the logging service
|
# Restart the logging service
|
||||||
|
|||||||
131
go/releases.js
131
go/releases.js
@@ -1,14 +1,21 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var osMap = {
|
let Fetcher = require('../_common/fetcher.js');
|
||||||
|
|
||||||
|
/** @type {Object.<String, String>} */
|
||||||
|
let osMap = {
|
||||||
darwin: 'macos',
|
darwin: 'macos',
|
||||||
};
|
};
|
||||||
var archMap = {
|
/** @type {Object.<String, String>} */
|
||||||
|
let archMap = {
|
||||||
386: 'x86',
|
386: 'x86',
|
||||||
};
|
};
|
||||||
|
|
||||||
let ODDITIES = ['bootstrap', '-arm6.'];
|
let ODDITIES = ['bootstrap', '-arm6.'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {String} filename
|
||||||
|
*/
|
||||||
function isOdd(filename) {
|
function isOdd(filename) {
|
||||||
for (let oddity of ODDITIES) {
|
for (let oddity of ODDITIES) {
|
||||||
let isOddity = filename.includes(oddity);
|
let isOddity = filename.includes(oddity);
|
||||||
@@ -18,7 +25,22 @@ function isOdd(filename) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAllReleases(request) {
|
/**
|
||||||
|
* @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() {
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
version: 'go1.13.8',
|
version: 'go1.13.8',
|
||||||
@@ -37,60 +59,71 @@ function getAllReleases(request) {
|
|||||||
]
|
]
|
||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
return request({
|
|
||||||
url: 'https://golang.org/dl/?mode=json&include=all',
|
|
||||||
json: true,
|
|
||||||
}).then((resp) => {
|
|
||||||
var goReleases = resp.body;
|
|
||||||
var all = {
|
|
||||||
releases: [],
|
|
||||||
download: '',
|
|
||||||
};
|
|
||||||
|
|
||||||
goReleases.forEach((release) => {
|
let resp;
|
||||||
// strip 'go' prefix, standardize version
|
try {
|
||||||
var parts = release.version.slice(2).split('.');
|
let url = 'https://golang.org/dl/?mode=json&include=all';
|
||||||
while (parts.length < 3) {
|
resp = await Fetcher.fetch(url, {
|
||||||
parts.push('0');
|
headers: { Accept: 'application/json' },
|
||||||
}
|
|
||||||
var version = parts.join('.');
|
|
||||||
// nix 'go' prefix
|
|
||||||
var fileversion = release.version.slice(2);
|
|
||||||
|
|
||||||
release.files.forEach((asset) => {
|
|
||||||
let odd = isOdd(asset.filename);
|
|
||||||
if (odd) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
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}`,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
} 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);
|
||||||
|
|
||||||
return all;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return all;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = getAllReleases;
|
module.exports = getDistributables;
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
getAllReleases(require('@root/request')).then(function (all) {
|
getDistributables().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
|
//@ts-expect-error
|
||||||
all.releases = all.releases.slice(0, 10);
|
all.releases = all.releases.slice(0, 10);
|
||||||
console.info(JSON.stringify(all, null, 2));
|
console.info(JSON.stringify(all, null, 2));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -85,8 +85,7 @@ webi serviceman
|
|||||||
pushd ./hello/
|
pushd ./hello/
|
||||||
|
|
||||||
# swap 'hello' and './hello' for the name of your project and binary
|
# swap 'hello' and './hello' for the name of your project and binary
|
||||||
sudo env PATH="$PATH" \
|
serviceman add --name 'hello' -- \
|
||||||
serviceman add --system --username "$(whoami)" --name hello -- \
|
|
||||||
./hello
|
./hello
|
||||||
|
|
||||||
# Restart the logging service
|
# Restart the logging service
|
||||||
|
|||||||
@@ -4,15 +4,15 @@ var github = require('../_common/github.js');
|
|||||||
var owner = 'goreleaser';
|
var owner = 'goreleaser';
|
||||||
var repo = 'goreleaser';
|
var repo = 'goreleaser';
|
||||||
|
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
all._names = ['goreleaser', '1'];
|
all._names = ['goreleaser', '1'];
|
||||||
return all;
|
return all;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
// just select the first 5 for demonstration
|
// just select the first 5 for demonstration
|
||||||
all.releases = all.releases.slice(0, 5);
|
all.releases = all.releases.slice(0, 5);
|
||||||
|
|||||||
114
gpg/releases.js
114
gpg/releases.js
@@ -1,5 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
let Fetcher = require('../_common/fetcher.js');
|
||||||
|
|
||||||
let ltsRe = /GnuPG-(2\.2\.[\d\.]+)/;
|
let ltsRe = /GnuPG-(2\.2\.[\d\.]+)/;
|
||||||
|
|
||||||
function createRssMatcher() {
|
function createRssMatcher() {
|
||||||
@@ -16,12 +18,42 @@ function createUrlMatcher() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getRawReleases(request) {
|
/**
|
||||||
let matcher = createRssMatcher();
|
* @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 resp = await request({
|
async function getRawReleases() {
|
||||||
url: 'https://sourceforge.net/projects/gpgosx/rss?path=/',
|
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}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
let matcher = createRssMatcher();
|
||||||
let links = [];
|
let links = [];
|
||||||
for (;;) {
|
for (;;) {
|
||||||
let m = matcher.exec(resp.body);
|
let m = matcher.exec(resp.body);
|
||||||
@@ -30,62 +62,66 @@ async function getRawReleases(request) {
|
|||||||
}
|
}
|
||||||
links.push(m[1]);
|
links.push(m[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return links;
|
return links;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Array<String>} links
|
||||||
|
*/
|
||||||
function transformReleases(links) {
|
function transformReleases(links) {
|
||||||
//console.log(JSON.stringify(links, null, 2));
|
//console.log(JSON.stringify(links, null, 2));
|
||||||
//console.log(links.length);
|
//console.log(links.length);
|
||||||
|
|
||||||
let matcher = createUrlMatcher();
|
let matcher = createUrlMatcher();
|
||||||
|
|
||||||
let releases = links
|
let builds = [];
|
||||||
.map(function (link) {
|
for (let link of links) {
|
||||||
let isLts = ltsRe.test(link);
|
let isLts = ltsRe.test(link);
|
||||||
let parts = link.match(matcher);
|
let parts = link.match(matcher);
|
||||||
if (!parts || !parts[2]) {
|
if (!parts || !parts[2]) {
|
||||||
return null;
|
continue;
|
||||||
}
|
}
|
||||||
let segs = parts[2].split('.');
|
|
||||||
let version = segs.slice(0, 3).join('.');
|
|
||||||
if (segs.length > 3) {
|
|
||||||
version += '+' + segs.slice(3);
|
|
||||||
}
|
|
||||||
let fileversion = segs.join('.');
|
|
||||||
|
|
||||||
return {
|
let segs = parts[2].split('.');
|
||||||
name: parts[1],
|
let version = segs.slice(0, 3).join('.');
|
||||||
version: version,
|
if (segs.length > 3) {
|
||||||
_version: fileversion,
|
version += '+' + segs.slice(3);
|
||||||
// all go versions >= 1.0.0 are effectively LTS
|
}
|
||||||
lts: isLts,
|
let fileversion = segs.join('.');
|
||||||
channel: 'stable',
|
|
||||||
// TODO <pubDate>Sat, 19 Nov 2016 16:17:33 UT</pubDate>
|
let build = {
|
||||||
date: '1970-01-01', // the world may never know
|
name: parts[1],
|
||||||
os: 'macos',
|
version: version,
|
||||||
arch: 'amd64',
|
_version: fileversion,
|
||||||
ext: 'dmg',
|
lts: isLts,
|
||||||
download: link,
|
channel: 'stable',
|
||||||
};
|
// TODO <pubDate>Sat, 19 Nov 2016 16:17:33 UT</pubDate>
|
||||||
})
|
date: '1970-01-01', // the world may never know
|
||||||
.filter(Boolean);
|
os: 'macos',
|
||||||
|
arch: 'amd64',
|
||||||
|
ext: 'dmg',
|
||||||
|
download: link,
|
||||||
|
};
|
||||||
|
builds.push(build);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
_names: ['GnuPG', 'gpgosx'],
|
_names: ['GnuPG', 'gpgosx'],
|
||||||
releases: releases,
|
releases: builds,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getAllReleases(request) {
|
async function getDistributables() {
|
||||||
let releases = await getRawReleases(request);
|
let releases = await getRawReleases();
|
||||||
let all = transformReleases(releases);
|
let all = transformReleases(releases);
|
||||||
return all;
|
return all;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = getAllReleases;
|
module.exports = getDistributables;
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
getAllReleases(require('@root/request')).then(function (all) {
|
getDistributables().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
all.releases = all.releases.slice(0, 10000);
|
all.releases = all.releases.slice(0, 10000);
|
||||||
console.info(JSON.stringify(all, null, 2));
|
console.info(JSON.stringify(all, null, 2));
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
|
|||||||
var owner = 'creedasaurus';
|
var owner = 'creedasaurus';
|
||||||
var repo = 'gprox';
|
var repo = 'gprox';
|
||||||
|
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
return all;
|
return all;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
// just select the first 5 for demonstration
|
// just select the first 5 for demonstration
|
||||||
all.releases = all.releases.slice(0, 5);
|
all.releases = all.releases.slice(0, 5);
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
|
|||||||
var owner = 'anchore';
|
var owner = 'anchore';
|
||||||
var repo = 'grype';
|
var repo = 'grype';
|
||||||
|
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
return all;
|
return all;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
// just select the first 5 for demonstration
|
// just select the first 5 for demonstration
|
||||||
all.releases = all.releases.slice(0, 5);
|
all.releases = all.releases.slice(0, 5);
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
|
|||||||
var owner = 'sharkdp';
|
var owner = 'sharkdp';
|
||||||
var repo = 'hexyl';
|
var repo = 'hexyl';
|
||||||
|
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
return all;
|
return all;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
all.releases = all.releases.slice(0, 10);
|
all.releases = all.releases.slice(0, 10);
|
||||||
//console.info(JSON.stringify(all));
|
//console.info(JSON.stringify(all));
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ var github = require('../_common/github.js');
|
|||||||
var owner = 'gohugoio';
|
var owner = 'gohugoio';
|
||||||
var repo = 'hugo';
|
var repo = 'hugo';
|
||||||
|
|
||||||
module.exports = async function (request) {
|
module.exports = async function () {
|
||||||
let all = await github(request, owner, repo);
|
let all = await github(null, owner, repo);
|
||||||
|
|
||||||
all.releases = all.releases.filter(function (rel) {
|
all.releases = all.releases.filter(function (rel) {
|
||||||
let isExtended = rel.name.includes('_extended_');
|
let isExtended = rel.name.includes('_extended_');
|
||||||
@@ -25,7 +25,7 @@ module.exports = async function (request) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
console.info(JSON.stringify(all));
|
console.info(JSON.stringify(all));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ var github = require('../_common/github.js');
|
|||||||
var owner = 'gohugoio';
|
var owner = 'gohugoio';
|
||||||
var repo = 'hugo';
|
var repo = 'hugo';
|
||||||
|
|
||||||
module.exports = async function (request) {
|
module.exports = async function () {
|
||||||
let all = await github(request, owner, repo);
|
let all = await github(null, owner, repo);
|
||||||
|
|
||||||
all.releases = all.releases.filter(function (rel) {
|
all.releases = all.releases.filter(function (rel) {
|
||||||
let isExtended = rel.name.includes('_extended_');
|
let isExtended = rel.name.includes('_extended_');
|
||||||
@@ -25,7 +25,7 @@ module.exports = async function (request) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
console.info(JSON.stringify(all));
|
console.info(JSON.stringify(all));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,73 +1,91 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function getRawReleases(request) {
|
let Fetcher = require('../_common/fetcher.js');
|
||||||
return request({ url: 'https://iterm2.com/downloads.html' }).then(
|
|
||||||
function (resp) {
|
async function getRawReleases() {
|
||||||
var links = resp.body
|
let resp;
|
||||||
.split(/[<>]+/g)
|
try {
|
||||||
.map(function (str) {
|
let url = 'https://iterm2.com/downloads.html';
|
||||||
var m = str.match(
|
resp = await Fetcher.fetch(url, {
|
||||||
/href="(https:\/\/iterm2\.com\/downloads\/.*\.zip)"/,
|
headers: { Accept: 'text/html' },
|
||||||
);
|
});
|
||||||
if (m && /iTerm2-[34]/.test(m[1])) {
|
} catch (e) {
|
||||||
return m[1];
|
/** @type {Error & { code: string, response: { status: number, body: string } }} */ //@ts-expect-error
|
||||||
}
|
let err = e;
|
||||||
})
|
if (err.code === 'E_FETCH_RELEASES') {
|
||||||
.filter(Boolean);
|
err.message = `failed to fetch 'iterm2' release data: ${err.response.status} ${err.response.body}`;
|
||||||
return links;
|
}
|
||||||
},
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Array<String>} links
|
||||||
|
*/
|
||||||
function transformReleases(links) {
|
function transformReleases(links) {
|
||||||
//console.log(JSON.stringify(links, null, 2));
|
let builds = [];
|
||||||
//console.log(links.length);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
_names: ['iTerm2', 'iterm2'],
|
_names: ['iTerm2', 'iterm2'],
|
||||||
releases: links
|
releases: builds,
|
||||||
.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),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAllReleases(request) {
|
async function getDistributables() {
|
||||||
return getRawReleases(request)
|
let rawReleases = await getRawReleases();
|
||||||
.then(transformReleases)
|
let all = transformReleases(rawReleases);
|
||||||
.then(function (all) {
|
|
||||||
return all;
|
return all;
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = getAllReleases;
|
module.exports = getDistributables;
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
getAllReleases(require('@root/request')).then(function (all) {
|
getDistributables().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
all.releases = all.releases.slice(0, 10000);
|
all.releases = all.releases.slice(0, 10000);
|
||||||
console.info(JSON.stringify(all, null, 2));
|
console.info(JSON.stringify(all, null, 2));
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ function isOdd(build) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
let builds = [];
|
let builds = [];
|
||||||
|
|
||||||
for (let build of all.releases) {
|
for (let build of all.releases) {
|
||||||
@@ -35,7 +35,7 @@ module.exports = function (request) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
console.info(JSON.stringify(all));
|
console.info(JSON.stringify(all));
|
||||||
//console.info(JSON.stringify(all, null, 2));
|
//console.info(JSON.stringify(all, null, 2));
|
||||||
|
|||||||
114
jsconfig.json
Normal file
114
jsconfig.json
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
{
|
||||||
|
"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"]
|
||||||
|
}
|
||||||
@@ -1,31 +1,61 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var osMap = {
|
let Fetcher = require('../_common/fetcher.js');
|
||||||
|
|
||||||
|
/** @type {Object.<String, String>} */
|
||||||
|
let osMap = {
|
||||||
winnt: 'windows',
|
winnt: 'windows',
|
||||||
mac: 'darwin',
|
mac: 'darwin',
|
||||||
};
|
};
|
||||||
var archMap = {
|
|
||||||
|
/** @type {Object.<String, String>} */
|
||||||
|
let archMap = {
|
||||||
armv7l: 'armv7',
|
armv7l: 'armv7',
|
||||||
i686: 'x86',
|
i686: 'x86',
|
||||||
powerpc64le: 'ppc64le',
|
powerpc64le: 'ppc64le',
|
||||||
};
|
};
|
||||||
|
|
||||||
async function getAllReleases() {
|
/**
|
||||||
|
* @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() {
|
||||||
let all = {
|
let all = {
|
||||||
|
/** @type {Array<BuildInfo>} */
|
||||||
releases: [],
|
releases: [],
|
||||||
download: '',
|
download: '',
|
||||||
_names: ['julia', 'macaarch64'],
|
_names: ['julia', 'macaarch64'],
|
||||||
};
|
};
|
||||||
|
|
||||||
let resp = await fetch(
|
let resp;
|
||||||
'https://julialang-s3.julialang.org/bin/versions.json',
|
try {
|
||||||
{
|
let url = 'https://julialang-s3.julialang.org/bin/versions.json';
|
||||||
headers: {
|
resp = await Fetcher.fetch(url, {
|
||||||
Accept: 'application/json',
|
headers: { Accept: 'application/json' },
|
||||||
},
|
});
|
||||||
},
|
} catch (e) {
|
||||||
);
|
/** @type {Error & { code: string, response: { status: number, body: string } }} */ //@ts-expect-error
|
||||||
let buildsByVersion = await resp.json();
|
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);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
@@ -105,6 +135,12 @@ async function getAllReleases() {
|
|||||||
return all;
|
return all;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Object} a
|
||||||
|
* @param {String} a.version
|
||||||
|
* @param {Object} b
|
||||||
|
* @param {String} b.version
|
||||||
|
*/
|
||||||
function sortByVersion(a, b) {
|
function sortByVersion(a, b) {
|
||||||
let [aVer, aPre] = a.version.split('-');
|
let [aVer, aPre] = a.version.split('-');
|
||||||
let [bVer, bPre] = b.version.split('-');
|
let [bVer, bPre] = b.version.split('-');
|
||||||
@@ -134,10 +170,10 @@ function sortByVersion(a, b) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = getAllReleases;
|
module.exports = getDistributables;
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
getAllReleases().then(function (all) {
|
getDistributables().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
all.releases = all.releases.slice(0, 10);
|
all.releases = all.releases.slice(0, 10);
|
||||||
console.info(JSON.stringify(all, null, 2));
|
console.info(JSON.stringify(all, null, 2));
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
|
|||||||
var owner = 'derailed';
|
var owner = 'derailed';
|
||||||
var repo = 'k9s';
|
var repo = 'k9s';
|
||||||
|
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
return all;
|
return all;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
// just select the first 5 for demonstration
|
// just select the first 5 for demonstration
|
||||||
all.releases = all.releases.slice(0, 5);
|
all.releases = all.releases.slice(0, 5);
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
|
|||||||
var owner = 'therootcompany';
|
var owner = 'therootcompany';
|
||||||
var repo = 'keypairs';
|
var repo = 'keypairs';
|
||||||
|
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
return all;
|
return all;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
console.info(JSON.stringify(all, null, 2));
|
console.info(JSON.stringify(all, null, 2));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,14 +12,14 @@ var repo = 'kind';
|
|||||||
/** **/
|
/** **/
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
return all;
|
return all;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
// just select the first 5 for demonstration
|
// just select the first 5 for demonstration
|
||||||
all.releases = all.releases.slice(0, 5);
|
all.releases = all.releases.slice(0, 5);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
title: koji
|
title: koji
|
||||||
homepage: https://github.com/its-danny/koji
|
homepage: https://github.com/cococonscious/koji
|
||||||
tagline: |
|
tagline: |
|
||||||
🦊 An interactive CLI for creating conventional commits.
|
🦊 An interactive CLI for creating conventional commits.
|
||||||
---
|
---
|
||||||
@@ -13,7 +13,7 @@ To update or switch versions, run `webi koji@stable` (or `@v2`, `@beta`, etc).
|
|||||||
|
|
||||||
> `koji` is an interactive CLI for creating [conventional commits][cc].
|
> `koji` is an interactive CLI for creating [conventional commits][cc].
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
[cc]: https://conventionalcommits.org/en/v1.0.0/
|
[cc]: https://conventionalcommits.org/en/v1.0.0/
|
||||||
|
|
||||||
@@ -105,4 +105,4 @@ description = "A new feature"
|
|||||||
```
|
```
|
||||||
|
|
||||||
The default emoji can be seen in
|
The default emoji can be seen in
|
||||||
[koji-default.toml](https://github.com/its-danny/koji/blob/main/meta/config/koji-default.toml).
|
[default.toml](https://github.com/cococonscious/koji/blob/main/meta/config/default.toml).
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var github = require('../_common/github.js');
|
var github = require('../_common/github.js');
|
||||||
var owner = 'its-danny';
|
var owner = 'cococonscious';
|
||||||
var repo = 'koji';
|
var repo = 'koji';
|
||||||
|
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
return all;
|
return all;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
console.info(JSON.stringify(all));
|
console.info(JSON.stringify(all));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ var github = require('../_common/github.js');
|
|||||||
var owner = 'ahmetb';
|
var owner = 'ahmetb';
|
||||||
var repo = 'kubectx';
|
var repo = 'kubectx';
|
||||||
|
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
let builds = [];
|
let builds = [];
|
||||||
|
|
||||||
for (let build of all.releases) {
|
for (let build of all.releases) {
|
||||||
@@ -28,7 +28,7 @@ module.exports = function (request) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
// just select the first 5 for demonstration
|
// just select the first 5 for demonstration
|
||||||
all.releases = all.releases.slice(0, 5);
|
all.releases = all.releases.slice(0, 5);
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ var github = require('../_common/github.js');
|
|||||||
var owner = 'ahmetb';
|
var owner = 'ahmetb';
|
||||||
var repo = 'kubectx';
|
var repo = 'kubectx';
|
||||||
|
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
let builds = [];
|
let builds = [];
|
||||||
|
|
||||||
for (let build of all.releases) {
|
for (let build of all.releases) {
|
||||||
@@ -28,7 +28,7 @@ module.exports = function (request) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
// just select the first 5 for demonstration
|
// just select the first 5 for demonstration
|
||||||
all.releases = all.releases.slice(0, 5);
|
all.releases = all.releases.slice(0, 5);
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ var github = require('../_common/github.js');
|
|||||||
var owner = 'gokcehan';
|
var owner = 'gokcehan';
|
||||||
var repo = 'lf';
|
var repo = 'lf';
|
||||||
|
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
all.releases = all.releases.map(function (r) {
|
all.releases = all.releases.map(function (r) {
|
||||||
// r21 -> 0.21.0
|
// r21 -> 0.21.0
|
||||||
if (/^r/.test(r.version)) {
|
if (/^r/.test(r.version)) {
|
||||||
@@ -18,7 +18,7 @@ module.exports = function (request) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')._debug(all);
|
all = require('../_webi/normalize.js')._debug(all);
|
||||||
console.info(JSON.stringify(all, null, 2));
|
console.info(JSON.stringify(all, null, 2));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ var github = require('../_common/github.js');
|
|||||||
var owner = 'lsd-rs';
|
var owner = 'lsd-rs';
|
||||||
var repo = 'lsd';
|
var repo = 'lsd';
|
||||||
|
|
||||||
module.exports = function (request) {
|
module.exports = function () {
|
||||||
return github(request, owner, repo).then(function (all) {
|
return github(null, owner, repo).then(function (all) {
|
||||||
all.releases = all.releases.filter(function (rel) {
|
all.releases = all.releases.filter(function (rel) {
|
||||||
return !/(-msvc\.)|(\.deb$)/.test(rel.name);
|
return !/(-msvc\.)|(\.deb$)/.test(rel.name);
|
||||||
});
|
});
|
||||||
@@ -14,7 +14,7 @@ module.exports = function (request) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
all = require('../_webi/normalize.js')(all);
|
all = require('../_webi/normalize.js')(all);
|
||||||
// just select the first 5 for demonstration
|
// just select the first 5 for demonstration
|
||||||
all.releases = all.releases.slice(0, 5);
|
all.releases = all.releases.slice(0, 5);
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var oses = [
|
let Fetcher = require('../_common/fetcher.js');
|
||||||
|
|
||||||
|
let oses = [
|
||||||
{
|
{
|
||||||
name: 'macOS Sierra',
|
name: 'macOS Sierra',
|
||||||
version: '10.12.6',
|
version: '10.12.6',
|
||||||
@@ -25,7 +27,7 @@ var oses = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
var headers = {
|
let headers = {
|
||||||
Connection: 'keep-alive',
|
Connection: 'keep-alive',
|
||||||
'Cache-Control': 'max-age=0',
|
'Cache-Control': 'max-age=0',
|
||||||
'Upgrade-Insecure-Requests': '1',
|
'Upgrade-Insecure-Requests': '1',
|
||||||
@@ -40,55 +42,103 @@ var headers = {
|
|||||||
'Accept-Language': 'en-US,en;q=0.9,sq;q=0.8',
|
'Accept-Language': 'en-US,en;q=0.9,sq;q=0.8',
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = function (request) {
|
/**
|
||||||
var all = {
|
* @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 = {
|
||||||
_names: ['InstallOS'],
|
_names: ['InstallOS'],
|
||||||
download: '',
|
download: '',
|
||||||
|
/** @type {Array<BuildInfo>} */
|
||||||
releases: [],
|
releases: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
return Promise.all(
|
// Fetch data for each OS and populate the releases array
|
||||||
oses.map(function (os) {
|
for (let os of oses) {
|
||||||
return request({
|
let download = await fetchReleasesForOS(os);
|
||||||
method: 'GET',
|
if (!download) {
|
||||||
url: os.url,
|
continue;
|
||||||
headers: headers,
|
}
|
||||||
}).then(function (resp) {
|
|
||||||
var m = resp.body.match(/(http[^>]+Install[^>]+.dmg)/);
|
// Add releases for macOS and Linux
|
||||||
var download = m && m[1];
|
for (let osname of osnames) {
|
||||||
['macos', 'linux'].forEach(function (osname) {
|
let build = {
|
||||||
all.releases.push({
|
version: os.version,
|
||||||
version: os.version,
|
lts: os.lts || false,
|
||||||
lts: os.lts || false,
|
channel: os.channel || 'beta',
|
||||||
channel: os.channel || 'beta',
|
date: os.date,
|
||||||
date: os.date,
|
os: osname,
|
||||||
os: osname,
|
arch: 'amd64',
|
||||||
arch: 'amd64',
|
ext: 'dmg',
|
||||||
ext: 'dmg',
|
hash: '-',
|
||||||
hash: '-',
|
download: download,
|
||||||
download: download,
|
};
|
||||||
});
|
|
||||||
});
|
all.releases.push(build);
|
||||||
});
|
}
|
||||||
}),
|
}
|
||||||
).then(function () {
|
|
||||||
all.releases.sort(function (a, b) {
|
// Sort releases
|
||||||
if ('10.11.6' === a.version) {
|
all.releases.sort(function (a, b) {
|
||||||
return -1;
|
if (a.version === '10.11.6') {
|
||||||
}
|
return -1;
|
||||||
if (a.date > b.date) {
|
}
|
||||||
return 1;
|
|
||||||
}
|
if (a.date > b.date) {
|
||||||
if (a.date < b.date) {
|
return 1;
|
||||||
return -1;
|
} else if (a.date < b.date) {
|
||||||
}
|
return -1;
|
||||||
});
|
}
|
||||||
return all;
|
|
||||||
|
return 0;
|
||||||
});
|
});
|
||||||
};
|
|
||||||
|
return all;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = getDistributables;
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
module.exports().then(function (all) {
|
||||||
console.info(JSON.stringify(all, null, 2));
|
console.info(JSON.stringify(all, null, 2));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
11
mariadb-server/README.md
Normal file
11
mariadb-server/README.md
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
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
|
||||||
12
mariadb-server/install.sh
Executable file
12
mariadb-server/install.sh
Executable file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/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
|
||||||
220
mariadb/README.md
Normal file
220
mariadb/README.md
Normal file
@@ -0,0 +1,220 @@
|
|||||||
|
---
|
||||||
|
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;
|
||||||
|
```
|
||||||
165
mariadb/install.sh
Executable file
165
mariadb/install.sh
Executable file
@@ -0,0 +1,165 @@
|
|||||||
|
#!/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
|
||||||
@@ -1,210 +1,181 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var brewReleases = require('../_common/brew.js');
|
let Fetcher = require('../_common/fetcher.js');
|
||||||
|
|
||||||
module.exports = function (request) {
|
let Releases = module.exports;
|
||||||
// So many places to get (incomplete) release info...
|
|
||||||
//
|
|
||||||
// MariaDB official
|
|
||||||
// - https://downloads.mariadb.org/mariadb/+releases/
|
|
||||||
// - http://archive.mariadb.org/
|
|
||||||
// Brew
|
|
||||||
// - https://formulae.brew.sh/api/formula/mariadb@10.3.json
|
|
||||||
// - https://formulae.brew.sh/docs/api/
|
|
||||||
// - https://formulae.brew.sh/formula/mariadb@10.2#default
|
|
||||||
//
|
|
||||||
// Note: This could be very fragile due to using the html
|
|
||||||
// as an API. It's pretty rather than minified, but that
|
|
||||||
// doesn't guarantee that it's meant as a consumable API.
|
|
||||||
//
|
|
||||||
|
|
||||||
var promises = [mariaReleases(), brewReleases(request, 'mariadb')];
|
let PRODUCT = `mariadb`;
|
||||||
return Promise.all(promises).then(function (many) {
|
// `https://downloads.mariadb.org/rest-api/${PRODUCT}/${minor}/`
|
||||||
var versions = many[0];
|
// `https://downloads.mariadb.org/rest-api/mariadb/10.5/`
|
||||||
var brews = many[1];
|
// https://github.com/MariaDB/mariadb-documentation/issues/41
|
||||||
|
|
||||||
var all = { download: '', releases: [] };
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
// linux x86
|
let releaseData = await getReleases(verData.release_id);
|
||||||
// linux x64
|
let versions = Object.keys(releaseData.releases);
|
||||||
// windows x86
|
for (let ver of versions) {
|
||||||
// windows x64
|
let relData = releaseData.releases[ver];
|
||||||
// (and mac, wedged-in from Homebrew)
|
for (let fileData of relData.files) {
|
||||||
versions.forEach(function (ver) {
|
let packageData = pluckData(verData, relData, fileData);
|
||||||
all.releases.push({
|
if (!packageData) {
|
||||||
version: ver.version,
|
continue;
|
||||||
lts: false,
|
|
||||||
channel: ver.channel,
|
|
||||||
date: ver.date,
|
|
||||||
os: 'linux',
|
|
||||||
arch: 'amd64',
|
|
||||||
download:
|
|
||||||
'http://archive.mariadb.org/mariadb-{{ v }}/bintar-linux-x86_64/mariadb-{{ v }}-linux-x86_64.tar.gz'.replace(
|
|
||||||
/{{ v }}/g,
|
|
||||||
ver.version,
|
|
||||||
),
|
|
||||||
});
|
|
||||||
all.releases.push({
|
|
||||||
version: ver.version,
|
|
||||||
lts: false,
|
|
||||||
channel: ver.channel,
|
|
||||||
date: ver.date,
|
|
||||||
os: 'linux',
|
|
||||||
arch: 'amd64',
|
|
||||||
download:
|
|
||||||
'http://archive.mariadb.org/mariadb-{{ v }}/bintar-linux-x86/mariadb-{{ v }}-linux-x86.tar.gz'.replace(
|
|
||||||
/{{ v }}/g,
|
|
||||||
ver.version,
|
|
||||||
),
|
|
||||||
});
|
|
||||||
|
|
||||||
// windows
|
|
||||||
all.releases.push({
|
|
||||||
version: ver.version,
|
|
||||||
lts: false,
|
|
||||||
channel: ver.channel,
|
|
||||||
date: ver.date,
|
|
||||||
os: 'windows',
|
|
||||||
arch: 'amd64',
|
|
||||||
download:
|
|
||||||
'http://archive.mariadb.org/mariadb-{{ v }}/winx64-packages/mariadb-{{ v }}-winx64.zip'.replace(
|
|
||||||
/{{ v }}/g,
|
|
||||||
ver.version,
|
|
||||||
),
|
|
||||||
});
|
|
||||||
all.releases.push({
|
|
||||||
version: ver.version,
|
|
||||||
lts: false,
|
|
||||||
channel: ver.channel,
|
|
||||||
date: ver.date,
|
|
||||||
os: 'windows',
|
|
||||||
arch: 'x86',
|
|
||||||
download:
|
|
||||||
'http://archive.mariadb.org/mariadb-{{ v }}/win32-packages/mariadb-{{ v }}-win32.zip'.replace(
|
|
||||||
/{{ v }}/g,
|
|
||||||
ver.version,
|
|
||||||
),
|
|
||||||
});
|
|
||||||
|
|
||||||
// Note: versions are sorted most-recent first.
|
|
||||||
// We just assume that the brew version is most recent stable
|
|
||||||
// ... but we can't really know for sure
|
|
||||||
|
|
||||||
// TODO
|
|
||||||
brews.some(function (brew, i) {
|
|
||||||
// 10.3 => ^10.2(\b|\.)
|
|
||||||
var reBrewVer = new RegExp(
|
|
||||||
'^' + brew.version.replace(/\./, '\\.') + '(\\b|\\.)',
|
|
||||||
'g',
|
|
||||||
);
|
|
||||||
if (!ver.version.match(reBrewVer)) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
all.releases.push({
|
packages.push(packageData);
|
||||||
version: ver.version,
|
}
|
||||||
lts: false,
|
}
|
||||||
channel: ver.channel,
|
|
||||||
date: ver.date,
|
|
||||||
os: 'macos',
|
|
||||||
arch: 'amd64',
|
|
||||||
download: brew.download.replace(/{{ v }}/g, ver.version),
|
|
||||||
});
|
|
||||||
brews.splice(i, 1); // remove
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return all;
|
|
||||||
});
|
|
||||||
|
|
||||||
function mariaReleases() {
|
|
||||||
return request({
|
|
||||||
url: 'https://downloads.mariadb.org/mariadb/+releases/',
|
|
||||||
fail: true, // https://git.coolaj86.com/coolaj86/request.js/issues/2
|
|
||||||
})
|
|
||||||
.then(failOnBadStatus)
|
|
||||||
.then(function (resp) {
|
|
||||||
// fragile, but simple
|
|
||||||
|
|
||||||
// Make release info go from this:
|
|
||||||
var html = resp.body;
|
|
||||||
//
|
|
||||||
// <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 [];
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let all = { releases: packages };
|
||||||
|
return all;
|
||||||
};
|
};
|
||||||
|
|
||||||
function mapChannel(ch) {
|
/** @type {Object.<String?, String>} */
|
||||||
if ('alpha' === ch) {
|
let channelsMap = {
|
||||||
return 'dev';
|
// '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;
|
||||||
}
|
}
|
||||||
// stable,rc,beta
|
|
||||||
return ch;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
function failOnBadStatus(resp) {
|
/**
|
||||||
if (resp.statusCode >= 400) {
|
* @typedef {String} ISODate - YYYY-MM-DD (ISO 8601 format)
|
||||||
var err = new Error('Non-successful status code: ' + resp.statusCode);
|
*/
|
||||||
err.code = 'ESTATUS';
|
|
||||||
err.response = resp;
|
/**
|
||||||
throw err;
|
* @typedef MajorRelease
|
||||||
}
|
* @prop {String} release_id - version-like for stable versions, otherwise a title
|
||||||
return resp;
|
* @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' },
|
||||||
|
});
|
||||||
|
|
||||||
|
let result = JSON.parse(resp.body);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
module.exports(require('@root/request')).then(function (all) {
|
Releases.latest().then(function (all) {
|
||||||
console.info('official releases look like:');
|
let normalize = require('../_webi/normalize.js');
|
||||||
console.info(JSON.stringify(all.releases.slice(0, 2), null, 2));
|
all = normalize(all);
|
||||||
console.info('Homebrew releases look like:');
|
let json = JSON.stringify(all, null, 2);
|
||||||
console.info(
|
console.info(json);
|
||||||
JSON.stringify(
|
|
||||||
all.releases
|
|
||||||
.filter(function (rel) {
|
|
||||||
return 'macos' === rel.os;
|
|
||||||
})
|
|
||||||
.slice(0, 2),
|
|
||||||
null,
|
|
||||||
2,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user