mirror of
https://github.com/webinstall/webi-installers.git
synced 2026-05-31 13:02:46 +00:00
Compare commits
41 Commits
chore-cach
...
list-relea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f0471206ec | ||
|
|
d0c0805a1f | ||
|
|
edfb064075 | ||
|
|
22d48c12cb | ||
|
|
3b3df248d1 | ||
|
|
00e828645b | ||
|
|
9b9dc6d4c9 | ||
|
|
5509686fba | ||
|
|
76e21b6e0a | ||
|
|
060f9b7026 | ||
|
|
f28bd86ce8 | ||
|
|
d4458c1076 | ||
|
|
619d77c6fa | ||
|
|
0111df7bb7 | ||
|
|
ce9c111fa9 | ||
|
|
48ca227feb | ||
|
|
8d8f809563 | ||
|
|
70121fc60c | ||
|
|
d0d2dce17c | ||
|
|
1eb28c7d22 | ||
|
|
c6fe0f7fb6 | ||
|
|
fb74b98960 | ||
|
|
867fe16f27 | ||
|
|
40766bea4c | ||
|
|
65c27afe49 | ||
|
|
36c3de2ffc | ||
|
|
1b10b18454 | ||
|
|
8abff3f0b9 | ||
|
|
14bb497303 | ||
|
|
2a785a86dc | ||
|
|
1d3f733cc4 | ||
|
|
1f1ea2b8ba | ||
|
|
8f92da28bb | ||
|
|
d102f18480 | ||
|
|
e85db4ecc4 | ||
|
|
f5b1de7751 | ||
|
|
f93ca34e68 | ||
|
|
de92e02bb1 | ||
|
|
c11bc55d5b | ||
|
|
f24df1a731 | ||
|
|
fca66feb3e |
7
.github/workflows/node.js.yml
vendored
7
.github/workflows/node.js.yml
vendored
@@ -23,15 +23,10 @@ jobs:
|
||||
sh ./_scripts/install-ci-deps
|
||||
echo "${HOME}/.local/bin" >> $GITHUB_PATH
|
||||
echo "${HOME}/.local/opt/pwsh" >> $GITHUB_PATH
|
||||
- run: |
|
||||
git submodule init
|
||||
git submodule update
|
||||
- run: shfmt --version
|
||||
- run: shellcheck -V
|
||||
- run: node --version
|
||||
- run: npm run fmt
|
||||
- run: npm ci
|
||||
- run: npm run lint
|
||||
- env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
run: npm run test
|
||||
- run: npm run test
|
||||
|
||||
21
.gitignore
vendored
21
.gitignore
vendored
@@ -1,24 +1,7 @@
|
||||
# generated artifacts
|
||||
.env
|
||||
node_modules
|
||||
install-*.sh
|
||||
install-*.bat
|
||||
install-*.ps1
|
||||
|
||||
# local config
|
||||
.env.*
|
||||
*.env
|
||||
.env
|
||||
!example.env
|
||||
|
||||
# caches
|
||||
_cache/
|
||||
node_modules/
|
||||
|
||||
# temporary & backup files
|
||||
.*.sw*
|
||||
*.bak
|
||||
*.bak.*
|
||||
|
||||
# other
|
||||
.DS_Store
|
||||
desktop.ini
|
||||
.directory
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
{
|
||||
"globals": {
|
||||
"AbortController": false
|
||||
},
|
||||
"browser": true,
|
||||
"node": true,
|
||||
"esversion": 11,
|
||||
|
||||
11
README.md
11
README.md
@@ -98,10 +98,9 @@ You just fill in the blanks.
|
||||
Just create an empty directory and run the tests until you get a good result.
|
||||
|
||||
```sh
|
||||
git clone git@github.com:webinstall/webi-installers.git
|
||||
pushd ./webi-installers/
|
||||
git submodule update --init
|
||||
npm clean-install
|
||||
git clone git@github.com:webinstall/packages.git
|
||||
pushd packages
|
||||
npm install
|
||||
```
|
||||
|
||||
```sh
|
||||
@@ -145,8 +144,8 @@ It looks like this:
|
||||
`releases.js`:
|
||||
|
||||
```js
|
||||
module.exports = function () {
|
||||
return github(null, owner, repo).then(function (all) {
|
||||
module.exports = function (request) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
// if you need to do something special, you can do it here
|
||||
// ...
|
||||
return all;
|
||||
|
||||
@@ -1,62 +1,64 @@
|
||||
'use strict';
|
||||
|
||||
let Fetcher = require('../_common/fetcher.js');
|
||||
|
||||
/**
|
||||
* Gets releases from 'brew'.
|
||||
* Gets a releases from 'brew'.
|
||||
*
|
||||
* @param {null} _
|
||||
* @param request
|
||||
* @param {string} formula
|
||||
* @returns {Promise<any>}
|
||||
* @returns {PromiseLike<any> | Promise<any>}
|
||||
*/
|
||||
async function getDistributables(_, formula) {
|
||||
function getAllReleases(request, formula) {
|
||||
if (!formula) {
|
||||
return Promise.reject('missing formula for brew');
|
||||
}
|
||||
|
||||
let resp;
|
||||
try {
|
||||
let url = `https://formulae.brew.sh/api/formula/${formula}.json`;
|
||||
resp = await Fetcher.fetch(url, {
|
||||
headers: { Accept: 'application/json' },
|
||||
});
|
||||
} catch (e) {
|
||||
/** @type {Error & { code: string, response: { status: number, body: string } }} */ //@ts-expect-error
|
||||
let err = e;
|
||||
if (err.code === 'E_FETCH_RELEASES') {
|
||||
err.message = `failed to fetch '${formula}' release data from 'brew': ${err.response.status} ${err.response.body}`;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
let body = JSON.parse(resp.body);
|
||||
|
||||
var ver = body.versions.stable;
|
||||
var dl = (
|
||||
body.bottle.stable.files.high_sierra || body.bottle.stable.files.catalina
|
||||
).url.replace(new RegExp(ver.replace(/\./g, '\\.'), 'g'), '{{ v }}');
|
||||
return [
|
||||
{
|
||||
version: ver,
|
||||
download: dl.replace(/{{ v }}/g, ver),
|
||||
},
|
||||
].concat(
|
||||
body.versioned_formulae.map(
|
||||
/** @param {String} f */
|
||||
function (f) {
|
||||
var ver = f.replace(/.*@/, '');
|
||||
return {
|
||||
return request({
|
||||
url: 'https://formulae.brew.sh/api/formula/' + formula + '.json',
|
||||
fail: true, // https://git.coolaj86.com/coolaj86/request.js/issues/2
|
||||
json: true,
|
||||
})
|
||||
.then(failOnBadStatus)
|
||||
.then(function (resp) {
|
||||
var ver = resp.body.versions.stable;
|
||||
var dl = (
|
||||
resp.body.bottle.stable.files.high_sierra ||
|
||||
resp.body.bottle.stable.files.catalina
|
||||
).url.replace(new RegExp(ver.replace(/\./g, '\\.'), 'g'), '{{ v }}');
|
||||
return [
|
||||
{
|
||||
version: ver,
|
||||
download: dl,
|
||||
};
|
||||
},
|
||||
),
|
||||
);
|
||||
download: dl.replace(/{{ v }}/g, ver),
|
||||
},
|
||||
].concat(
|
||||
resp.body.versioned_formulae.map(function (f) {
|
||||
var ver = f.replace(/.*@/, '');
|
||||
return {
|
||||
version: ver,
|
||||
download: dl,
|
||||
};
|
||||
}),
|
||||
);
|
||||
})
|
||||
.catch(function (err) {
|
||||
console.error('Error fetching MariaDB versions (brew)');
|
||||
console.error(err);
|
||||
return [];
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = getDistributables;
|
||||
function failOnBadStatus(resp) {
|
||||
if (resp.statusCode >= 400) {
|
||||
var err = new Error('Non-successful status code: ' + resp.statusCode);
|
||||
err.code = 'ESTATUS';
|
||||
err.response = resp;
|
||||
throw err;
|
||||
}
|
||||
return resp;
|
||||
}
|
||||
|
||||
module.exports = getAllReleases;
|
||||
|
||||
if (module === require.main) {
|
||||
getDistributables(null, 'mariadb').then(function (all) {
|
||||
getAllReleases(require('@root/request'), 'mariadb').then(function (all) {
|
||||
console.info(JSON.stringify(all, null, 2));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
let Fetcher = module.exports;
|
||||
|
||||
/**
|
||||
* @typedef ResponseSummary
|
||||
* @prop {Boolean} ok
|
||||
* @prop {Headers} headers
|
||||
* @prop {Number} status
|
||||
* @prop {String} body
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {String} url
|
||||
* @param {RequestInit} opts
|
||||
* @returns {Promise<ResponseSummary>}
|
||||
*/
|
||||
Fetcher.fetch = async function (url, opts) {
|
||||
let resp = await fetch(url, opts);
|
||||
let summary = Fetcher.throwIfNotOk(resp);
|
||||
|
||||
return summary;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Response} resp
|
||||
* @returns {Promise<ResponseSummary>}
|
||||
*/
|
||||
Fetcher.throwIfNotOk = async function (resp) {
|
||||
let text = await resp.text();
|
||||
|
||||
if (!resp.ok) {
|
||||
let headers = Array.from(resp.headers);
|
||||
console.error('[Fetcher] error: Response Headers:', headers);
|
||||
console.error('[Fetcher] error: Response Text:', text);
|
||||
let err = new Error(`fetch was not ok`);
|
||||
Object.assign({
|
||||
status: 503,
|
||||
code: 'E_FETCH_RELEASES',
|
||||
response: {
|
||||
status: resp.status,
|
||||
headers: headers,
|
||||
body: text,
|
||||
},
|
||||
});
|
||||
throw err;
|
||||
}
|
||||
|
||||
let summary = {
|
||||
ok: resp.ok,
|
||||
headers: resp.headers,
|
||||
status: resp.status,
|
||||
body: text,
|
||||
};
|
||||
return summary;
|
||||
};
|
||||
@@ -115,7 +115,7 @@ Repos.getCommitInfo = async function (repoPath, commitish) {
|
||||
* @param {string} gitUrl
|
||||
* @returns {PromiseLike<any> | Promise<any>}
|
||||
*/
|
||||
async function getDistributables(gitUrl) {
|
||||
async function getAllReleases(gitUrl) {
|
||||
let all = {
|
||||
releases: [],
|
||||
download: '',
|
||||
@@ -190,7 +190,7 @@ async function getDistributables(gitUrl) {
|
||||
return all;
|
||||
}
|
||||
|
||||
module.exports = getDistributables;
|
||||
module.exports = getAllReleases;
|
||||
|
||||
if (module === require.main) {
|
||||
(async function main() {
|
||||
@@ -203,7 +203,7 @@ if (module === require.main) {
|
||||
//'https://github.com/dense-analysis/ale.git',
|
||||
];
|
||||
for (let url of testRepos) {
|
||||
let all = await getDistributables(url);
|
||||
let all = await getAllReleases(url);
|
||||
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
console.info(JSON.stringify(all, null, 2));
|
||||
|
||||
@@ -1,47 +1,39 @@
|
||||
'use strict';
|
||||
|
||||
var GitHubish = require('./githubish.js');
|
||||
var ghRelease = require('./github.js');
|
||||
|
||||
/**
|
||||
* Lists Gitea Releases (w/ uploaded assets)
|
||||
* Gets the releases for 'ripgrep'. This function could be trimmed down and made
|
||||
* for use with any github release.
|
||||
*
|
||||
* @param {null} _ - deprecated
|
||||
* @param {String} owner
|
||||
* @param {String} repo
|
||||
* @param {String} baseurl
|
||||
* @param {String} [username]
|
||||
* @param {String} [token]
|
||||
* @param request
|
||||
* @param {string} owner
|
||||
* @param {string} repo
|
||||
* @returns {PromiseLike<any> | Promise<any>}
|
||||
*/
|
||||
async function getDistributables(
|
||||
_,
|
||||
owner,
|
||||
repo,
|
||||
baseurl,
|
||||
username = '',
|
||||
token = '',
|
||||
) {
|
||||
baseurl = `${baseurl}/api/v1`;
|
||||
let all = await GitHubish.getDistributables({
|
||||
owner,
|
||||
repo,
|
||||
baseurl,
|
||||
username,
|
||||
token,
|
||||
});
|
||||
return all;
|
||||
function getAllReleases(request, owner, repo, baseurl) {
|
||||
if (!baseurl) {
|
||||
return Promise.reject('missing baseurl');
|
||||
}
|
||||
return ghRelease(request, owner, repo, baseurl + '/api/v1').then(
|
||||
function (all) {
|
||||
return all;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = getDistributables;
|
||||
module.exports = getAllReleases;
|
||||
|
||||
if (module === require.main) {
|
||||
getDistributables(
|
||||
null,
|
||||
'root',
|
||||
'pathman',
|
||||
'https://git.rootprojects.org',
|
||||
'',
|
||||
'',
|
||||
).then(function (all) {
|
||||
console.info(JSON.stringify(all, null, 2));
|
||||
});
|
||||
getAllReleases(
|
||||
require('@root/request'),
|
||||
'coolaj86',
|
||||
'go-pathman',
|
||||
'https://git.coolaj86.com',
|
||||
).then(
|
||||
//getAllReleases(require('@root/request'), 'root', 'serviceman', 'https://git.rootprojects.org').then(
|
||||
function (all) {
|
||||
console.info(JSON.stringify(all, null, 2));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,40 +1,133 @@
|
||||
'use strict';
|
||||
|
||||
require('dotenv').config({ path: '.env' });
|
||||
|
||||
let GitHubSource = module.exports;
|
||||
|
||||
let GitHubishSource = require('./githubish-source.js');
|
||||
require('dotenv').config();
|
||||
|
||||
/**
|
||||
* @param {Object} opts
|
||||
* @param {String} opts.owner
|
||||
* @param {String} opts.repo
|
||||
* @param {String} [opts.baseurl]
|
||||
* @param {String} [opts.username]
|
||||
* @param {String} [opts.token]
|
||||
* Gets the releases for 'ripgrep'. This function could be trimmed down and made
|
||||
* for use with any github release.
|
||||
*
|
||||
* @param request
|
||||
* @param {string} owner
|
||||
* @param {string} repo
|
||||
* @returns {PromiseLike<any> | Promise<any>}
|
||||
*/
|
||||
GitHubSource.getDistributables = async function ({
|
||||
async function getAllReleases(
|
||||
request,
|
||||
owner,
|
||||
repo,
|
||||
oses,
|
||||
arches,
|
||||
baseurl = 'https://api.github.com',
|
||||
username = process.env.GITHUB_USERNAME || '',
|
||||
token = process.env.GITHUB_TOKEN || '',
|
||||
}) {
|
||||
let all = await GitHubishSource.getDistributables({
|
||||
owner,
|
||||
repo,
|
||||
baseurl,
|
||||
username,
|
||||
token,
|
||||
});
|
||||
) {
|
||||
if (!owner) {
|
||||
return Promise.reject('missing owner for repo');
|
||||
}
|
||||
if (!repo) {
|
||||
return Promise.reject('missing repo name');
|
||||
}
|
||||
|
||||
let req = {
|
||||
url: `${baseurl}/repos/${owner}/${repo}/releases`,
|
||||
json: true,
|
||||
};
|
||||
|
||||
// TODO I really don't like global config, find a way to do better
|
||||
if (process.env.GITHUB_USERNAME) {
|
||||
req.auth = {
|
||||
user: process.env.GITHUB_USERNAME,
|
||||
pass: process.env.GITHUB_TOKEN,
|
||||
};
|
||||
}
|
||||
|
||||
let resp = await request(req);
|
||||
let gHubResp = resp.body;
|
||||
let all = {
|
||||
releases: [],
|
||||
// TODO make this ':baseurl' + ':releasename'
|
||||
download: '',
|
||||
};
|
||||
|
||||
for (let release of gHubResp) {
|
||||
// TODO tags aren't always semver / sensical
|
||||
let tag = release['tag_name'];
|
||||
let lts = /(\b|_)(lts)(\b|_)/.test(release['tag_name']);
|
||||
let channel = 'stable';
|
||||
if (release['prerelease']) {
|
||||
channel = 'beta';
|
||||
}
|
||||
let date = release['published_at'] || '';
|
||||
date = date.replace(/T.*/, '');
|
||||
|
||||
let urls = [release.tarball_url, release.zipball_url];
|
||||
for (let url of urls) {
|
||||
let resp = await request({
|
||||
method: 'HEAD',
|
||||
followRedirect: true,
|
||||
followAllRedirects: true,
|
||||
followOriginalHttpMethod: true,
|
||||
url: url,
|
||||
stream: true,
|
||||
});
|
||||
// Workaround for bug where method changes to GET
|
||||
resp.destroy();
|
||||
|
||||
// content-disposition: attachment; filename=BeyondCodeBootcamp-DuckDNS.sh-v1.0.1-0-ga2f4bde.zip
|
||||
let name = resp.headers['content-disposition'].replace(
|
||||
/.*filename=([^;]+)(;|$)/,
|
||||
'$1',
|
||||
);
|
||||
all.releases.push({
|
||||
name: name,
|
||||
version: tag,
|
||||
lts: lts,
|
||||
channel: channel,
|
||||
date: date,
|
||||
os: '', // will be guessed by download filename
|
||||
arch: '', // will be guessed by download filename
|
||||
ext: '', // will be normalized
|
||||
download: resp.request.uri.href,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (oses) {
|
||||
return combinate(all, oses, arches);
|
||||
}
|
||||
|
||||
return all;
|
||||
};
|
||||
}
|
||||
|
||||
function combinate(all, oses, arches) {
|
||||
let releases = all.releases;
|
||||
// ex: arches = ['amd64', 'arm64', 'armv7l', 'armv6l', 'x86'];
|
||||
// ex: oses = ['macos', 'linux', 'bsd', 'posix'];
|
||||
|
||||
let combos = [];
|
||||
for (let release of releases) {
|
||||
for (let arch of arches) {
|
||||
for (let os of oses) {
|
||||
let combo = {
|
||||
arch: arch,
|
||||
os: os,
|
||||
};
|
||||
let rel = Object.assign({}, release, combo);
|
||||
combos.push(rel);
|
||||
}
|
||||
}
|
||||
}
|
||||
all.releases = combos;
|
||||
|
||||
return all;
|
||||
}
|
||||
|
||||
module.exports = getAllReleases;
|
||||
|
||||
if (module === require.main) {
|
||||
GitHubSource.getDistributables(null, 'BeyondCodeBootcamp', 'DuckDNS.sh').then(
|
||||
function (all) {
|
||||
console.info(JSON.stringify(all, null, 2));
|
||||
},
|
||||
);
|
||||
getAllReleases(
|
||||
require('@root/request'),
|
||||
'BeyondCodeBootcamp',
|
||||
'DuckDNS.sh',
|
||||
).then(function (all) {
|
||||
console.info(JSON.stringify(all, null, 2));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,42 +1,102 @@
|
||||
'use strict';
|
||||
|
||||
require('dotenv').config({ path: '.env' });
|
||||
|
||||
let GitHubish = require('./githubish.js');
|
||||
require('dotenv').config();
|
||||
|
||||
/**
|
||||
* Lists GitHub Releases (w/ uploaded assets)
|
||||
*
|
||||
* @param {null} _ - deprecated
|
||||
* @param {String} owner
|
||||
* @param {String} repo
|
||||
* @param {String} [baseurl]
|
||||
* @param {String} [username]
|
||||
* @param {String} [token]
|
||||
* @param request
|
||||
* @param {string} owner
|
||||
* @param {string} repo
|
||||
* @returns {PromiseLike<any> | Promise<any>}
|
||||
*/
|
||||
module.exports = async function (
|
||||
_,
|
||||
async function getAllReleases(
|
||||
request,
|
||||
owner,
|
||||
repo,
|
||||
baseurl = 'https://api.github.com',
|
||||
username = process.env.GITHUB_USERNAME || '',
|
||||
token = process.env.GITHUB_TOKEN || '',
|
||||
) {
|
||||
let all = await GitHubish.getDistributables({
|
||||
owner,
|
||||
repo,
|
||||
baseurl,
|
||||
username,
|
||||
token,
|
||||
});
|
||||
return all;
|
||||
};
|
||||
if (!owner) {
|
||||
throw new Error('missing owner for repo');
|
||||
}
|
||||
if (!repo) {
|
||||
throw new Error('missing repo name');
|
||||
}
|
||||
|
||||
let GitHub = module.exports;
|
||||
GitHub.getDistributables = module.exports;
|
||||
var req = {
|
||||
url: `${baseurl}/repos/${owner}/${repo}/releases`,
|
||||
json: true,
|
||||
};
|
||||
|
||||
// TODO I really don't like global config, find a way to do better
|
||||
if (process.env.GITHUB_USERNAME) {
|
||||
req.auth = {
|
||||
user: process.env.GITHUB_USERNAME,
|
||||
pass: process.env.GITHUB_TOKEN,
|
||||
};
|
||||
}
|
||||
|
||||
let resp = await request(req);
|
||||
if (!resp.ok) {
|
||||
console.error('Bad Resp Headers:', resp.headers);
|
||||
console.error('Bad Resp Body:', resp.body);
|
||||
throw new Error('the elusive releases BOOGEYMAN strikes again');
|
||||
}
|
||||
|
||||
let gHubResp = resp.body;
|
||||
let all = {
|
||||
releases: [],
|
||||
// todo make this ':baseurl' + ':releasename'
|
||||
download: '',
|
||||
};
|
||||
|
||||
try {
|
||||
gHubResp.forEach(transformReleases);
|
||||
} catch (e) {
|
||||
console.error(e.message);
|
||||
console.error('Error Headers:', resp.headers);
|
||||
console.error('Error Body:', resp.body);
|
||||
throw e;
|
||||
}
|
||||
|
||||
function transformReleases(release) {
|
||||
for (let asset of release['assets']) {
|
||||
let name = asset['name'];
|
||||
let date = release['published_at']?.replace(/T.*/, '');
|
||||
let download = asset['browser_download_url'];
|
||||
|
||||
// TODO tags aren't always semver / sensical
|
||||
let version = release['tag_name'];
|
||||
let channel;
|
||||
if (release['prerelease']) {
|
||||
// -rcX, -preview, -beta, etc will be checked in _webi/normalize.js
|
||||
channel = 'beta';
|
||||
}
|
||||
let lts = /(\b|_)(lts)(\b|_)/.test(release['tag_name']);
|
||||
|
||||
all.releases.push({
|
||||
name: name,
|
||||
version: version,
|
||||
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: download,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return all;
|
||||
}
|
||||
|
||||
module.exports = getAllReleases;
|
||||
|
||||
if (module === require.main) {
|
||||
GitHub.getDistributables(null, 'BurntSushi', 'ripgrep').then(function (all) {
|
||||
console.info(JSON.stringify(all, null, 2));
|
||||
});
|
||||
getAllReleases(require('@root/request'), 'BurntSushi', 'ripgrep').then(
|
||||
function (all) {
|
||||
console.info(JSON.stringify(all, null, 2));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,174 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
let Fetcher = require('../_common/fetcher.js');
|
||||
|
||||
let GitHubishSource = module.exports;
|
||||
|
||||
/**
|
||||
* Lists GitHub-Like Releases (source tarball & zip)
|
||||
*
|
||||
* @param {Object} opts
|
||||
* @param {String} opts.owner
|
||||
* @param {String} opts.repo
|
||||
* @param {String} opts.baseurl
|
||||
* @param {String} [opts.username]
|
||||
* @param {String} [opts.token]
|
||||
*/
|
||||
GitHubishSource.getDistributables = async function ({
|
||||
owner,
|
||||
repo,
|
||||
baseurl,
|
||||
username = '',
|
||||
token = '',
|
||||
}) {
|
||||
if (!owner) {
|
||||
throw new Error('missing owner for repo');
|
||||
}
|
||||
if (!repo) {
|
||||
throw new Error('missing repo name');
|
||||
}
|
||||
if (!baseurl) {
|
||||
throw new Error('missing baseurl');
|
||||
}
|
||||
|
||||
let url = `${baseurl}/repos/${owner}/${repo}/releases`;
|
||||
let opts = {
|
||||
headers: {
|
||||
'Content-Type': 'appplication/json',
|
||||
},
|
||||
};
|
||||
|
||||
if (token) {
|
||||
let userpass = `${username}:${token}`;
|
||||
let basicAuth = btoa(userpass);
|
||||
Object.assign(opts.headers, {
|
||||
Authorization: `Basic ${basicAuth}`,
|
||||
});
|
||||
}
|
||||
|
||||
let resp;
|
||||
try {
|
||||
resp = await Fetcher.fetch(url, opts);
|
||||
} catch (e) {
|
||||
/** @type {Error & { code: string, response: { status: number, body: string } }} */ //@ts-expect-error
|
||||
let err = e;
|
||||
if (err.code === 'E_FETCH_RELEASES') {
|
||||
err.message = `failed to fetch '${baseurl}' (githubish-source, user '${username}) release data: ${err.response.status} ${err.response.body}`;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
let gHubResp = JSON.parse(resp.body);
|
||||
|
||||
let all = {
|
||||
/** @type {Array<BuildInfo>} */
|
||||
releases: [],
|
||||
download: '',
|
||||
};
|
||||
|
||||
for (let release of gHubResp) {
|
||||
let dists = GitHubishSource.releaseToDistributables(release);
|
||||
for (let dist of dists) {
|
||||
let updates =
|
||||
await GitHubishSource.followDistributableDownloadAttachment(dist);
|
||||
Object.assign(dist, updates);
|
||||
all.releases.push(dist);
|
||||
}
|
||||
}
|
||||
|
||||
return all;
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef BuildInfo
|
||||
* @prop {String} [name] - name to use instead of filename for hash urls
|
||||
* @prop {String} version
|
||||
* @prop {String} [_version]
|
||||
* @prop {String} [arch]
|
||||
* @prop {String} channel
|
||||
* @prop {String} date
|
||||
* @prop {String} download
|
||||
* @prop {String} [ext]
|
||||
* @prop {String} [_filename]
|
||||
* @prop {String} [hash]
|
||||
* @prop {String} [libc]
|
||||
* @prop {Boolean} [_musl]
|
||||
* @prop {Boolean} [lts]
|
||||
* @prop {String} [size]
|
||||
* @prop {String} os
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {any} ghRelease - TODO
|
||||
* @returns {Array<BuildInfo>}
|
||||
*/
|
||||
GitHubishSource.releaseToDistributables = function (ghRelease) {
|
||||
let ghTag = ghRelease['tag_name']; // TODO tags aren't always semver / sensical
|
||||
let lts = /(\b|_)(lts)(\b|_)/.test(ghRelease['tag_name']);
|
||||
let channel = 'stable';
|
||||
if (ghRelease['prerelease']) {
|
||||
channel = 'beta';
|
||||
}
|
||||
let date = ghRelease['published_at'] || '';
|
||||
date = date.replace(/T.*/, '');
|
||||
|
||||
let urls = [ghRelease.tarball_url, ghRelease.zipball_url];
|
||||
/** @type {Array<BuildInfo>} */
|
||||
let dists = [];
|
||||
for (let url of urls) {
|
||||
dists.push({
|
||||
name: '',
|
||||
version: ghTag,
|
||||
lts: lts,
|
||||
channel: channel,
|
||||
date: date,
|
||||
os: '*',
|
||||
arch: '*',
|
||||
libc: '',
|
||||
ext: '',
|
||||
download: url,
|
||||
});
|
||||
}
|
||||
|
||||
return dists;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {BuildInfo} dist
|
||||
*/
|
||||
GitHubishSource.followDistributableDownloadAttachment = async function (dist) {
|
||||
let abortCtrl = new AbortController();
|
||||
let resp = await fetch(dist.download, {
|
||||
method: 'HEAD',
|
||||
redirect: 'follow',
|
||||
signal: abortCtrl.signal,
|
||||
});
|
||||
let headers = Object.fromEntries(resp.headers);
|
||||
|
||||
// Workaround for bug where METHOD changes to GET
|
||||
abortCtrl.abort();
|
||||
await resp.text().catch(function (err) {
|
||||
if (err.name !== 'AbortError') {
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
|
||||
// ex: content-disposition: attachment; filename=BeyondCodeBootcamp-DuckDNS.sh-v1.0.1-0-ga2f4bde.zip
|
||||
// => BeyondCodeBootcamp-DuckDNS.sh-v1.0.1-0-ga2f4bde.zip
|
||||
let name = headers['content-disposition'].replace(
|
||||
/.*filename=([^;]+)(;|$)/,
|
||||
'$1',
|
||||
);
|
||||
let download = resp.url;
|
||||
|
||||
return { name, download };
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
GitHubishSource.getDistributables({
|
||||
owner: 'BeyondCodeBootcamp',
|
||||
repo: 'DuckDNS.sh',
|
||||
baseurl: 'https://api.github.com',
|
||||
}).then(function (all) {
|
||||
console.info(JSON.stringify(all, null, 2));
|
||||
});
|
||||
}
|
||||
@@ -1,137 +0,0 @@
|
||||
'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;
|
||||
|
||||
/**
|
||||
* Lists GitHub-Like Releases (w/ uploaded assets)
|
||||
*
|
||||
* @param {Object} opts
|
||||
* @param {String} opts.owner
|
||||
* @param {String} opts.repo
|
||||
* @param {String} opts.baseurl
|
||||
* @param {String} [opts.username]
|
||||
* @param {String} [opts.token]
|
||||
*/
|
||||
GitHubish.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, user '${username}) release data: ${err.response.status} ${err.response.body}`;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
let gHubResp = JSON.parse(resp.body);
|
||||
|
||||
let all = {
|
||||
/** @type {Array<DistributableRaw>} */
|
||||
releases: [],
|
||||
// todo make this ':baseurl' + ':releasename'
|
||||
download: '',
|
||||
};
|
||||
|
||||
try {
|
||||
gHubResp.forEach(transformReleases);
|
||||
} catch (e) {
|
||||
/** @type {Error & { code: string, response: { status: number, body: string } }} */ //@ts-expect-error
|
||||
let err = e;
|
||||
console.error(err.message);
|
||||
console.error('Error Headers:', resp.headers);
|
||||
console.error('Error Body:', resp.body);
|
||||
let msg = `failed to transform releases from '${baseurl}' with user '${username}'`;
|
||||
throw new Error(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} release - TODO
|
||||
*/
|
||||
function transformReleases(release) {
|
||||
for (let asset of release['assets']) {
|
||||
let name = asset['name'];
|
||||
let date = release['published_at']?.replace(/T.*/, '');
|
||||
let download = asset['browser_download_url'];
|
||||
|
||||
// TODO tags aren't always semver / sensical
|
||||
let version = release['tag_name'];
|
||||
let channel;
|
||||
if (release['prerelease']) {
|
||||
// -rcX, -preview, -beta, etc will be checked in _webi/normalize.js
|
||||
channel = 'beta';
|
||||
}
|
||||
let lts = /(\b|_)(lts)(\b|_)/.test(release['tag_name']);
|
||||
|
||||
all.releases.push({
|
||||
name: name,
|
||||
version: version,
|
||||
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: download,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return all;
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
GitHubish.getDistributables({
|
||||
owner: 'BurntSushi',
|
||||
repo: 'ripgrep',
|
||||
baseurl: 'https://api.github.com',
|
||||
}).then(function (all) {
|
||||
console.info(JSON.stringify(all, null, 2));
|
||||
});
|
||||
}
|
||||
@@ -23,7 +23,7 @@ install:
|
||||
```text
|
||||
~/.config/envman/PATH.env
|
||||
~/.local/bin/foo
|
||||
~/.local/opt/foo/
|
||||
~/.local/opt/foo
|
||||
```
|
||||
|
||||
## Cheat Sheet
|
||||
|
||||
@@ -12,26 +12,17 @@ var repo = 'ripgrep';
|
||||
/** **/
|
||||
/******************************************************************************/
|
||||
|
||||
let Releases = module.exports;
|
||||
|
||||
Releases.latest = async function () {
|
||||
let all = await github(null, owner, repo);
|
||||
return all;
|
||||
};
|
||||
|
||||
Releases.sample = async function () {
|
||||
let normalize = require('../_webi/normalize.js');
|
||||
let all = await Releases.latest();
|
||||
all = normalize(all);
|
||||
// just select the first 5 for demonstration
|
||||
all.releases = all.releases.slice(0, 5);
|
||||
return all;
|
||||
module.exports = function (request) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
return all;
|
||||
});
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
(async function () {
|
||||
let samples = await Releases.sample();
|
||||
|
||||
console.info(JSON.stringify(samples, null, 2));
|
||||
})();
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
// just select the first 5 for demonstration
|
||||
all.releases = all.releases.slice(0, 5);
|
||||
console.info(JSON.stringify(all, null, 2));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
//var pkg = require('../package.json');
|
||||
var os = require('os');
|
||||
//var request = require('@root/request');
|
||||
//var promisify = require('util').promisify;
|
||||
//var exec = promisify(require('child_process').exec);
|
||||
var exec = require('child_process').exec;
|
||||
|
||||
Submodule _webi/build-classifier updated: 1b24d834b9...f6b55f8d5a
@@ -1,73 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
let Path = require('node:path');
|
||||
|
||||
let BuildsCacher = require('./builds-cacher.js');
|
||||
// let Parallel = require('./parallel.js');
|
||||
|
||||
var INSTALLERS_DIR = Path.join(__dirname, '..');
|
||||
var CACHE_DIR = Path.join(__dirname, '../_cache');
|
||||
|
||||
async function main() {
|
||||
let bc = BuildsCacher.create({
|
||||
caches: CACHE_DIR,
|
||||
installers: INSTALLERS_DIR,
|
||||
});
|
||||
bc.freshenRandomPackage(600 * 1000);
|
||||
|
||||
// let dirs = await bc.getProjectsByType();
|
||||
// let projNames = Object.keys(dirs.valid);
|
||||
|
||||
let lastUpdate;
|
||||
|
||||
let projName = 'k9s';
|
||||
{
|
||||
let packages = await bc.getPackages({
|
||||
//Releases: Releases,
|
||||
name: projName,
|
||||
date: new Date(),
|
||||
});
|
||||
lastUpdate = packages.updated;
|
||||
console.info(
|
||||
`Last update for '${projName}': ${packages.updated} (${packages.releases.length} assets)`,
|
||||
);
|
||||
}
|
||||
|
||||
console.info('Waiting 5s');
|
||||
{
|
||||
setTimeout(async function () {
|
||||
let packages = await bc.getPackages({
|
||||
//Releases: Releases,
|
||||
name: projName,
|
||||
date: new Date(),
|
||||
});
|
||||
console.info(
|
||||
`Last update for '${projName}': ${packages.updated} (${packages.releases.length} assets)`,
|
||||
);
|
||||
if (lastUpdate < packages.updated) {
|
||||
console.info(`PASS`);
|
||||
} else {
|
||||
console.info(`MAYBE fail`);
|
||||
}
|
||||
}, 5 * 1000);
|
||||
}
|
||||
|
||||
//let parallel = 25;
|
||||
//await Parallel.run(parallel, projNames, getAll);
|
||||
//async function getAll(name) {
|
||||
// void (await bc.getPackages({
|
||||
// //Releases: Releases,
|
||||
// name: name,
|
||||
// date: new Date(),
|
||||
// }));
|
||||
//}
|
||||
}
|
||||
|
||||
main()
|
||||
.then(function () {
|
||||
console.log('Done');
|
||||
})
|
||||
.catch(function (e) {
|
||||
console.error(e.stack || e);
|
||||
process.exit(1);
|
||||
});
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,41 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
let Builds = module.exports;
|
||||
|
||||
let Path = require('node:path');
|
||||
|
||||
let BuildsCacher = require('./builds-cacher.js');
|
||||
// let HostTargets = require('./build-classifier/host-targets.js');
|
||||
let Parallel = require('./parallel.js');
|
||||
|
||||
var INSTALLERS_DIR = Path.join(__dirname, '..');
|
||||
var CACHE_DIR = Path.join(__dirname, '../_cache');
|
||||
|
||||
let bc = BuildsCacher.create({
|
||||
caches: CACHE_DIR,
|
||||
installers: INSTALLERS_DIR,
|
||||
});
|
||||
bc.freshenRandomPackage(600 * 1000);
|
||||
|
||||
Builds.init = async function () {
|
||||
bc.freshenRandomPackage(600 * 1000);
|
||||
|
||||
let dirs = await bc.getProjectsByType();
|
||||
let projNames = Object.keys(dirs.valid);
|
||||
|
||||
let parallel = 25;
|
||||
await Parallel.run(parallel, projNames, getAll);
|
||||
async function getAll(name) {
|
||||
void (await bc.getPackages({
|
||||
//Releases: Releases,
|
||||
name: name,
|
||||
date: new Date(),
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
Builds.enumerateLatestVersions = bc.enumerateLatestVersions;
|
||||
Builds.findMatchingPackages = bc.findMatchingPackages;
|
||||
Builds.getPackage = bc.getPackages;
|
||||
Builds.getProjectType = bc.getProjectType;
|
||||
Builds.selectPackage = bc.selectPackage;
|
||||
@@ -1,90 +0,0 @@
|
||||
'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);
|
||||
});
|
||||
@@ -267,23 +267,12 @@ webi_bootstrap() { (
|
||||
fn_checksum() {
|
||||
a_filepath="${1}"
|
||||
|
||||
if command -v sha1sum > /dev/null; then
|
||||
sha1sum "${a_filepath}" | cut -d' ' -f1 | cut -c 1-8
|
||||
return 0
|
||||
fi
|
||||
|
||||
cmd_shasum='sha1sum'
|
||||
if command -v shasum > /dev/null; then
|
||||
shasum "${a_filepath}" | cut -d' ' -f1 | cut -c 1-8
|
||||
return 0
|
||||
cmd_shasum='shasum'
|
||||
fi
|
||||
|
||||
if command -v sha1 > /dev/null; then
|
||||
sha1 "${a_filepath}" | cut -d'=' -f2 | cut -c 2-9
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo >&2 " warn: no sha1 sum program"
|
||||
date '+%F %H:%M'
|
||||
$cmd_shasum "${a_filepath}" | cut -d' ' -f1 | cut -c 1-8
|
||||
}
|
||||
|
||||
##############################################
|
||||
|
||||
@@ -93,18 +93,16 @@ Installers.renderBash = async function (
|
||||
['WEBI_GIT_TAG', rel.git_tag], // TODO replace with branch
|
||||
['WEBI_LTS', rel.lts],
|
||||
['WEBI_CHANNEL', rel.channel],
|
||||
['WEBI_EXT', rel.ext],
|
||||
['WEBI_EXT', rel.ext.replace(/tar.*/, 'tar')],
|
||||
['WEBI_FORMATS', formats.join(',')],
|
||||
['WEBI_PKG_URL', rel.download],
|
||||
['WEBI_PKG_PATHNAME', pkgFile],
|
||||
['WEBI_PKG_FILE', pkgFile], // TODO replace with pathname
|
||||
['PKG_NAME', pkg],
|
||||
['PKG_STABLE', rel.stable],
|
||||
['PKG_LATEST', rel.latest],
|
||||
['PKG_OSES', (rel.oses || []).join(' ')],
|
||||
['PKG_ARCHES', (rel.arches || []).join(' ')],
|
||||
['PKG_LIBCS', (rel.libcs || []).join(' ')],
|
||||
['PKG_FORMATS', (rel.formats || []).join(' ')],
|
||||
['PKG_OSES', rel.oses],
|
||||
['PKG_ARCHES', rel.arches],
|
||||
['PKG_LIBCS', rel.libcs],
|
||||
['PKG_FORMATS', (rel.formats || []).join(',')],
|
||||
];
|
||||
|
||||
for (let env of envReplacements) {
|
||||
|
||||
@@ -124,20 +124,184 @@ let bc = BuildsCacher.create({
|
||||
installers: INSTALLERS_DIR,
|
||||
});
|
||||
|
||||
async function getPackagesWithBuilds(installersDir, pkgNames, parallel = 25) {
|
||||
let packages = [];
|
||||
|
||||
await Parallel.run(parallel, pkgNames, getAll);
|
||||
|
||||
async function getAll(name, i) {
|
||||
let Releases = require(`${installersDir}/${name}/releases.js`);
|
||||
let pkg = await bc.getBuilds({
|
||||
Releases: Releases,
|
||||
name: name,
|
||||
date: new Date(),
|
||||
});
|
||||
packages[i] = pkg;
|
||||
}
|
||||
|
||||
return packages;
|
||||
}
|
||||
|
||||
function getBuildsByTarget(packages) {
|
||||
let packagesByName = {};
|
||||
|
||||
for (let pkg of packages) {
|
||||
let buildsByOs = getBuildsByOs(pkg);
|
||||
packagesByName[pkg.name] = buildsByOs;
|
||||
}
|
||||
|
||||
return packagesByName;
|
||||
}
|
||||
|
||||
function getBuildsByOs(pkg) {
|
||||
let buildsByOs = {};
|
||||
|
||||
for (let build of pkg.releases) {
|
||||
// TODO check targets cache
|
||||
let target = bc.classify(pkg, build);
|
||||
if (!target) {
|
||||
// ignore known, non-package extensions
|
||||
continue;
|
||||
}
|
||||
|
||||
if (target.error) {
|
||||
let err = target.error;
|
||||
let code = err.code || '';
|
||||
console.error(`[ERROR]: ${code} ${pkg.name}: ${build.name}`);
|
||||
console.error(`>>> ${err.message} <<<`);
|
||||
console.error(pkg);
|
||||
console.error(build);
|
||||
console.error(`^^^ ${err.message} ^^^`);
|
||||
console.error(err.stack);
|
||||
continue;
|
||||
}
|
||||
|
||||
let buildsByRelease = getBuildsByRelease(build, buildsByOs, target);
|
||||
buildsByRelease.push(build);
|
||||
}
|
||||
|
||||
return buildsByOs;
|
||||
}
|
||||
|
||||
function getBuildsByRelease(build, buildsByOs, target) {
|
||||
let archLibc = `${target.arch}-${target.libc}`;
|
||||
|
||||
if (!buildsByOs[target.os]) {
|
||||
buildsByOs[target.os] = {};
|
||||
}
|
||||
|
||||
let buildsByVersion = buildsByOs[target.os];
|
||||
if (!buildsByVersion[build.version]) {
|
||||
buildsByVersion[build.version] = {};
|
||||
}
|
||||
|
||||
let buildsByArchLibc = buildsByVersion[build.version];
|
||||
if (!buildsByArchLibc[archLibc]) {
|
||||
buildsByArchLibc[archLibc] = [];
|
||||
}
|
||||
|
||||
let buildsByRelease = buildsByArchLibc[archLibc];
|
||||
return buildsByRelease;
|
||||
}
|
||||
|
||||
function matchBuildsByTarget(pkg, buildsTree, target) {
|
||||
let oses = [];
|
||||
let targetOs = target.os;
|
||||
if (target.os === 'windows') {
|
||||
oses = ['ANYOS', 'windows'];
|
||||
//buildsByOs = buildsTree.ANYOS || buildsTree[target.os];
|
||||
} else if (target.os === 'android') {
|
||||
oses = ['ANYOS', 'posix_2017', 'android', 'linux'];
|
||||
// buildsByOs =
|
||||
// buildsTree.ANYOS || buildsTree.posix_2017 || buildsTree[target.os];
|
||||
// if (!buildsByOs) {
|
||||
// targetOs = 'linux';
|
||||
// buildsByOs = buildsTree.linux;
|
||||
// }
|
||||
} else {
|
||||
oses = ['ANYOS', 'posix_2017', target.os];
|
||||
// buildsByOs =
|
||||
// buildsTree.ANYOS || buildsTree.posix_2017 || buildsTree[target.os];
|
||||
}
|
||||
|
||||
// TODO can we move sortByOsAndArchLibc(builds, anything) down to the lib?
|
||||
// and then the matcher
|
||||
// and make the waterfall more optional?
|
||||
|
||||
let waterfall = HostTargets.WATERFALL[target.os] || {};
|
||||
let arches = waterfall[target.arch] ||
|
||||
HostTargets.WATERFALL.ANYOS[target.arch] || [target.arch];
|
||||
arches = ['ANYARCH'].concat(arches);
|
||||
let libcs = waterfall[target.libc] ||
|
||||
HostTargets.WATERFALL.ANYOS[target.libc] || [target.libc];
|
||||
|
||||
//console.log('waterfalls', arches, libcs);
|
||||
|
||||
// TODO flatten earlier and precache?
|
||||
let duplets = [];
|
||||
for (let arch of arches) {
|
||||
for (let libc of libcs) {
|
||||
let duplet = `${arch}-${libc}`;
|
||||
duplets.push(duplet);
|
||||
}
|
||||
}
|
||||
|
||||
let duplet;
|
||||
let targetBuilds;
|
||||
for (let os of oses) {
|
||||
let buildsByOs = buildsTree[os];
|
||||
if (!buildsByOs) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// TODO
|
||||
// - latest supported triplets
|
||||
// - historical supported triplets
|
||||
|
||||
// TODO sort versions first, get channel (or 'stable' or 'latest') from user
|
||||
for (let version of pkg.versions) {
|
||||
let versionBuilds = buildsByOs[version];
|
||||
if (!versionBuilds) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (let _duplet of duplets) {
|
||||
targetBuilds = versionBuilds[_duplet];
|
||||
//console.log(` duplet: ${_duplet}`, versionBuilds, targetBuilds);
|
||||
if (targetBuilds?.length > 0) {
|
||||
targetOs = os;
|
||||
duplet = _duplet;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (targetBuilds?.length > 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (targetBuilds?.length > 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!targetBuilds?.length) {
|
||||
// console.log(' no builds:', buildsByOs);
|
||||
targetBuilds = [];
|
||||
}
|
||||
|
||||
let match = { triplet: `${targetOs}-${duplet}`, builds: targetBuilds };
|
||||
return match;
|
||||
}
|
||||
|
||||
async function main() {
|
||||
/* jshint maxcomplexity: 25 */
|
||||
// TODO
|
||||
// node ./_webi/lint-builds.js caddy@beta 'x86_64/unknown Darwin libc'
|
||||
//
|
||||
//let [projName, userAgent] = process.argv.slice(2);
|
||||
let projName = process.argv[2];
|
||||
// create test case for zoxide, goreleaser, go, yq, caddy, rg
|
||||
// let [pkgName, userAgent] = process.argv[2].slice(0);
|
||||
// create test case for zoxide, caddy, rg
|
||||
|
||||
let dirs = await bc.getProjectsByType();
|
||||
if (!projName) {
|
||||
showDirs(dirs);
|
||||
console.info('');
|
||||
}
|
||||
let dirs = await bc.getPackages();
|
||||
showDirs(dirs);
|
||||
console.info('');
|
||||
|
||||
bc.freshenRandomPackage(600 * 1000);
|
||||
|
||||
@@ -145,106 +309,86 @@ async function main() {
|
||||
let triples = [];
|
||||
let valids = Object.keys(dirs.valid);
|
||||
|
||||
if (projName) {
|
||||
if (!valids.includes(projName)) {
|
||||
throw new Error(`'${projName}' is not a valid installable project`);
|
||||
}
|
||||
valids = [projName];
|
||||
let index = valids.indexOf('webi');
|
||||
if (index >= 0) {
|
||||
// TODO fix the webi faux package
|
||||
// (not sure why I even created it)
|
||||
void valids.splice(index, 1);
|
||||
}
|
||||
|
||||
let parallel = 25;
|
||||
//valids = ['atomicparsley', 'caddy', 'macos'];
|
||||
//valids = ['atomicparsley'];
|
||||
let packages = await getPackagesWithBuilds(INSTALLERS_DIR, valids, parallel);
|
||||
|
||||
console.info('');
|
||||
console.info(`Fetching project release assets`);
|
||||
let parallel = 25;
|
||||
let projects = [];
|
||||
await Parallel.run(parallel, valids, getAll);
|
||||
async function getAll(name, i) {
|
||||
console.info(` ${name}`);
|
||||
let projInfo = await bc.getPackages({
|
||||
//Releases: Releases,
|
||||
name: name,
|
||||
date: new Date(),
|
||||
});
|
||||
projects[i] = projInfo;
|
||||
}
|
||||
console.info(`Fetching builds for`);
|
||||
for (let pkg of packages) {
|
||||
console.info(` ${pkg.name}`);
|
||||
|
||||
console.info(`Classifying build assets for...`);
|
||||
for (let projInfo of projects) {
|
||||
console.info(` ${projInfo.name}`);
|
||||
|
||||
let nStr = projInfo.releases.length.toString();
|
||||
let nStr = pkg.releases.length.toString();
|
||||
let n = nStr.padStart(5, ' ');
|
||||
let row = `##### ${n}\t${projInfo.name}\tv`;
|
||||
let row = `##### ${n}\t${pkg.name}\tv`;
|
||||
rows.push(row);
|
||||
|
||||
// ignore known, non-package extensions
|
||||
for (let build of projInfo.releases) {
|
||||
let target = bc.classify(projInfo, build);
|
||||
for (let build of pkg.releases) {
|
||||
let target = bc.classify(pkg, build);
|
||||
if (!target) {
|
||||
// non-build file
|
||||
continue;
|
||||
}
|
||||
|
||||
if (target.error) {
|
||||
let e = target.error;
|
||||
if (e.code === 'E_BUILD_NO_PATTERN') {
|
||||
console.warn(`>>> ${e.message} <<<`);
|
||||
console.warn(projInfo);
|
||||
console.warn(pkg);
|
||||
console.warn(build);
|
||||
console.warn(`^^^ ${e.message} ^^^`);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
|
||||
if (target.unknownTerms?.length) {
|
||||
let msg = `${projInfo.name}: unrecognized term(s) '${target.unknownTerms}' in '${build.download}'`;
|
||||
let err = new Error(msg);
|
||||
throw err;
|
||||
}
|
||||
|
||||
triples.push(target.triplet);
|
||||
// if (!build.version) {
|
||||
// throw new Error(`no version for ${pkg.name} ${build.name}`);
|
||||
// }
|
||||
// // For debug printing versions
|
||||
// console.error(build.version);
|
||||
rows.push(`${target.triplet}\t${projInfo.name}\t${build.version}`);
|
||||
rows.push(`${target.triplet}\t${pkg.name}\t${build.version}`);
|
||||
}
|
||||
}
|
||||
|
||||
console.info(`Fetching builds for`);
|
||||
for (let projInfo of projects) {
|
||||
console.info('');
|
||||
console.info('');
|
||||
console.info(` ${projInfo.name}`);
|
||||
let packagesTree = getBuildsByTarget(packages);
|
||||
//console.log(`packagesTree`, packagesTree);
|
||||
|
||||
for (let pkg of packages) {
|
||||
console.log('');
|
||||
console.log('');
|
||||
console.log('pkg', pkg.name);
|
||||
let buildsTree = packagesTree[pkg.name];
|
||||
console.log(buildsTree);
|
||||
for (let target of uaTargets) {
|
||||
let libc = target.libc || 'libc';
|
||||
let hostTriplet = `${target.os}-${target.arch}-${libc}`;
|
||||
console.info('');
|
||||
console.info(` target: ${hostTriplet}`);
|
||||
let match = bc.findMatchingPackages(projInfo, target, {
|
||||
ver: '',
|
||||
});
|
||||
console.log('');
|
||||
console.log(`target: ${hostTriplet}`);
|
||||
let match = matchBuildsByTarget(pkg, buildsTree, target);
|
||||
if (!match) {
|
||||
console.info(
|
||||
` project: ${projInfo.name}: missing build for os '${target.os}'`,
|
||||
console.log(
|
||||
` pkg: ${pkg.name}: missing build for os '${target.os}'`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!match.releases) {
|
||||
console.info(
|
||||
` project: ${projInfo.name}: missing build for os '${target.os}-${target.arch}-${libc}'`,
|
||||
if (match.builds.length === 0) {
|
||||
console.log(
|
||||
` pkg: ${pkg.name}: missing build for os '${target.os}-${target.arch}-${libc}'`,
|
||||
);
|
||||
} else if (match.triplet === hostTriplet) {
|
||||
let releaseNames = Object.keys(match.releases);
|
||||
console.info(` selected ${releaseNames.length}`);
|
||||
console.log(` selected ${match.builds.length}`);
|
||||
} else {
|
||||
let releaseNames = Object.keys(match.releases);
|
||||
console.info(
|
||||
` selected ${releaseNames.length} (${match.triplet} fallback)`,
|
||||
console.log(
|
||||
` selected ${match.builds.length} (${match.triplet} fallback)`,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -286,18 +430,6 @@ async function main() {
|
||||
}
|
||||
|
||||
console.info('');
|
||||
console.info('Formats:');
|
||||
if (bc.formats.length) {
|
||||
let formats = bc.formats.slice();
|
||||
formats.sort();
|
||||
if (!formats[0]) {
|
||||
formats[0] = '(bin)';
|
||||
}
|
||||
console.warn(' ', formats.join('\n '));
|
||||
} else {
|
||||
console.info(' (none)');
|
||||
}
|
||||
|
||||
// sort -u -k1 builds.tsv | rg -v '^#|^https?:' | rg -i arm
|
||||
// cut -f1 builds.tsv | sort -u -k1 | rg -v '^#|^https?:' | rg -i arm
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ var archMap = {
|
||||
amd64:
|
||||
/(\b|_|amd|(dar)?win(dows)?|mac(os)?|linux|osx|x)64([_\-]?bit)?(\b|_)/i,
|
||||
//x86: /(86)(\b|_)/i,
|
||||
x86: /(\b|_|amd|(dar)?win(dows)?|mac(os)?|linux|osx|x)(86|32|i?386)([_\-]?bit)?(\b|_)/i,
|
||||
x86: /(\b|_|amd|(dar)?win(dows)?|mac(os)?|linux|osx|x)(86|32)([_\-]?bit)(\b|_)/i,
|
||||
ppc64le: /(\b|_)(ppc64le)/i,
|
||||
ppc64: /(\b|_)(ppc64)(\b|_)/i,
|
||||
s390x: /(\b|_)(s390x)/i,
|
||||
@@ -211,8 +211,7 @@ function normalize(all) {
|
||||
// won't match:
|
||||
// - v1.0beta
|
||||
// - v1.0-beta1b
|
||||
let isBetaRe =
|
||||
/(\b|_)(alpha|beta|dev|developer|prev|preview|rc)(\d+)(\b|_)/;
|
||||
let isBetaRe = /(\b|_)(preview|rc|beta|alpha)(\d+)(\b|_)/;
|
||||
let isBeta = isBetaRe.test(rel.name);
|
||||
if (isBeta) {
|
||||
rel.channel = 'beta';
|
||||
|
||||
@@ -88,7 +88,7 @@ function Get-UserAgent {
|
||||
IF ($my_arch -eq "AMD64") {
|
||||
# Because PowerShell is sometimes AMD64 on Windows 10 ARM
|
||||
# See https://oofhours.com/2020/02/04/powershell-on-windows-10-arm64/
|
||||
$my_os_arch = (Get-CimInstance -ClassName Win32_OperatingSystem).OSArchitecture
|
||||
$my_os_arch = wmic os get osarchitecture
|
||||
|
||||
# Using -clike because of the trailing newline
|
||||
IF ($my_os_arch -clike "ARM 64*") {
|
||||
|
||||
@@ -27,7 +27,6 @@ __bootstrap_webi() {
|
||||
#PKG_LIBCS=
|
||||
#PKG_FORMATS=
|
||||
#PKG_LATEST=
|
||||
#PKG_STABLE=
|
||||
WEBI_PKG_DOWNLOAD=""
|
||||
WEBI_DOWNLOAD_DIR="${HOME}/Downloads"
|
||||
if command -v xdg-user-dir > /dev/null; then
|
||||
@@ -37,7 +36,7 @@ __bootstrap_webi() {
|
||||
fi
|
||||
fi
|
||||
|
||||
WEBI_PKG_PATH="${WEBI_DOWNLOAD_DIR}/webi/${PKG_NAME:-error}/${WEBI_VERSION:-stable}"
|
||||
WEBI_PKG_PATH="${WEBI_DOWNLOAD_DIR}/webi/${PKG_NAME:-error}/${WEBI_VERSION:-latest}"
|
||||
|
||||
# get the special formatted version
|
||||
# (i.e. "go is go1.14" while node is "node v12.10.8")
|
||||
@@ -128,10 +127,6 @@ __bootstrap_webi() {
|
||||
echo ""
|
||||
echo " $(t_err "Error: no '${PKG_NAME:-"Unknown Package"}@${WEBI_TAG:-"Unknown Tag"}' release for '${WEBI_OS:-"Unknown OS"}' (${WEBI_LIBC:-"Unknown Libc"}) on '${WEBI_ARCH:-"Unknown CPU"}' as one of '${WEBI_FORMATS:-"Unknown File Type"}'")"
|
||||
echo ""
|
||||
echo " Latest Stable: ${PKG_STABLE}"
|
||||
if test "${PKG_LATEST}" != "${PKG_STABLE}"; then
|
||||
echo " Next Version: ${PKG_LATEST}"
|
||||
fi
|
||||
echo " CPUs: $PKG_ARCHES"
|
||||
echo " OSes: $PKG_OSES"
|
||||
echo " libcs: $PKG_LIBCS"
|
||||
@@ -201,32 +196,20 @@ __bootstrap_webi() {
|
||||
my_dl_rel="$(
|
||||
fn_sub_home "${WEBI_PKG_PATH}/${WEBI_PKG_FILE}"
|
||||
)"
|
||||
if test "$WEBI_EXT" = "tar.zst"; then
|
||||
echo " Extracting $(t_path "${my_dl_rel}")"
|
||||
unzstd -c --keep "${WEBI_PKG_PATH}/$WEBI_PKG_FILE" | tar xf -
|
||||
elif test "$WEBI_EXT" = "tar.xz"; then
|
||||
echo " Extracting $(t_path "${my_dl_rel}")"
|
||||
unxz -c -k "${WEBI_PKG_PATH}/$WEBI_PKG_FILE" | tar xf -
|
||||
elif test "$WEBI_EXT" = "tar.gz"; then
|
||||
echo " Extracting $(t_path "${my_dl_rel}")"
|
||||
tar xzf "${WEBI_PKG_PATH}/$WEBI_PKG_FILE"
|
||||
elif test "$WEBI_EXT" = "tar.bz2"; then
|
||||
echo " Extracting $(t_path "${my_dl_rel}")"
|
||||
tar xjf "${WEBI_PKG_PATH}/$WEBI_PKG_FILE"
|
||||
elif test "$WEBI_EXT" = "tar"; then
|
||||
if [ "tar" = "$WEBI_EXT" ]; then
|
||||
echo " Extracting $(t_path "${my_dl_rel}")"
|
||||
tar xf "${WEBI_PKG_PATH}/$WEBI_PKG_FILE"
|
||||
elif test "$WEBI_EXT" = "zip" || test "$WEBI_EXT" = "app.zip"; then
|
||||
elif [ "zip" = "$WEBI_EXT" ]; then
|
||||
echo " Extracting $(t_path "${my_dl_rel}")"
|
||||
unzip "${WEBI_PKG_PATH}/$WEBI_PKG_FILE" > __unzip__.log
|
||||
elif test "$WEBI_EXT" = "exe"; then
|
||||
elif [ "exe" = "$WEBI_EXT" ]; then
|
||||
echo " Moving $(t_path "${my_dl_rel}")"
|
||||
echo " to $(t_path "$(fn_sub_home "$(pwd)")")"
|
||||
mv "${WEBI_PKG_PATH}/$WEBI_PKG_FILE" .
|
||||
elif test "$WEBI_EXT" = "git"; then
|
||||
elif [ "git" = "$WEBI_EXT" ]; then
|
||||
echo " Moving $(t_path "${my_dl_rel}")"
|
||||
mv "${WEBI_PKG_PATH}/$WEBI_PKG_FILE" .
|
||||
elif test "$WEBI_EXT" = "xz"; then
|
||||
elif [ "xz" = "$WEBI_EXT" ]; then
|
||||
echo " Inflating $(t_path "${my_dl_rel}")"
|
||||
unxz -c "${WEBI_PKG_PATH}/$WEBI_PKG_FILE" > "$(basename "$WEBI_PKG_FILE")"
|
||||
else
|
||||
@@ -239,6 +222,8 @@ __bootstrap_webi() {
|
||||
webi_path_add() {
|
||||
my_path="${1}"
|
||||
|
||||
fn_envman_init
|
||||
|
||||
# \v was chosen as it is extremely unlikely for a filename
|
||||
# \1 could be an even better choice, but needs more testing.
|
||||
# (currently tested working on: linux & mac)
|
||||
@@ -401,6 +386,7 @@ __bootstrap_webi() {
|
||||
export _webi_tmp="${_webi_tmp:-"$HOME/.local/opt/webi-tmp.d"}"
|
||||
|
||||
mkdir -p "${WEBI_PKG_PATH}"
|
||||
mkdir -p "$HOME/.local/bin"
|
||||
mkdir -p "$HOME/.local/opt"
|
||||
|
||||
if test -e ~/.local/bin; then
|
||||
@@ -409,7 +395,6 @@ __bootstrap_webi() {
|
||||
echo " Creating$(t_path ' ~/.local/bin')"
|
||||
mkdir -p "$HOME/.local/bin"
|
||||
fi
|
||||
fn_envman_init
|
||||
|
||||
##
|
||||
##
|
||||
@@ -790,23 +775,12 @@ webi_upgrade() { (
|
||||
fn_checksum() {
|
||||
a_filepath="${1}"
|
||||
|
||||
if command -v sha1sum > /dev/null; then
|
||||
sha1sum "${a_filepath}" | cut -d' ' -f1 | cut -c 1-8
|
||||
return 0
|
||||
fi
|
||||
|
||||
cmd_shasum='sha1sum'
|
||||
if command -v shasum > /dev/null; then
|
||||
shasum "${a_filepath}" | cut -d' ' -f1 | cut -c 1-8
|
||||
return 0
|
||||
cmd_shasum='shasum'
|
||||
fi
|
||||
|
||||
if command -v sha1 > /dev/null; then
|
||||
sha1 "${a_filepath}" | cut -d'=' -f2 | cut -c 2-9
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo >&2 " warn: no sha1 sum program"
|
||||
date '+%F %H:%M'
|
||||
$cmd_shasum "${a_filepath}" | cut -d' ' -f1 | cut -c 1-8
|
||||
}
|
||||
|
||||
##############################################
|
||||
|
||||
@@ -2,14 +2,17 @@
|
||||
|
||||
var InstallerServer = module.exports;
|
||||
|
||||
let Fs = require('fs/promises');
|
||||
let Path = require('path');
|
||||
var Fs = require('fs/promises');
|
||||
var path = require('path');
|
||||
|
||||
let HostTargets = require('./build-classifier/host-targets.js');
|
||||
let Builds = require('./builds.js');
|
||||
let Installers = require('./installers.js');
|
||||
var uaDetect = require('./ua-detect.js');
|
||||
var Projects = require('./projects.js');
|
||||
var Installers = require('./installers.js');
|
||||
|
||||
InstallerServer.INSTALLERS_DIR = Path.join(__dirname, '..');
|
||||
// handlers caching and transformation, probably should be broken down
|
||||
var Releases = require('./transform-releases.js');
|
||||
|
||||
InstallerServer.INSTALLERS_DIR = path.join(__dirname, '..');
|
||||
InstallerServer.serveInstaller = async function (
|
||||
baseurl,
|
||||
ua,
|
||||
@@ -19,210 +22,113 @@ InstallerServer.serveInstaller = async function (
|
||||
formats,
|
||||
libc,
|
||||
) {
|
||||
let unameAgent = ua;
|
||||
let projectName = pkg;
|
||||
let [rel, tmplParams] = await InstallerServer.helper({
|
||||
unameAgent,
|
||||
projectName,
|
||||
let [rel, opts] = await InstallerServer.helper({
|
||||
ua,
|
||||
pkg,
|
||||
tag,
|
||||
formats,
|
||||
libc,
|
||||
});
|
||||
Object.assign(tmplParams, {
|
||||
Object.assign(opts, {
|
||||
baseurl,
|
||||
});
|
||||
|
||||
var pkgdir = Path.join(InstallerServer.INSTALLERS_DIR, projectName);
|
||||
var pkgdir = path.join(InstallerServer.INSTALLERS_DIR, pkg);
|
||||
if ('ps1' === ext) {
|
||||
return Installers.renderPowerShell(pkgdir, rel, tmplParams);
|
||||
return Installers.renderPowerShell(pkgdir, rel, opts);
|
||||
}
|
||||
return Installers.renderBash(pkgdir, rel, tmplParams);
|
||||
return Installers.renderBash(pkgdir, rel, opts);
|
||||
};
|
||||
InstallerServer.helper = async function ({ ua, pkg, tag, formats, libc }) {
|
||||
// TODO put some of this in a middleware? or common function?
|
||||
|
||||
// TODO put some of this in a middleware? or common function?
|
||||
// TODO maybe move package/version/lts/channel detection into getReleases
|
||||
InstallerServer.helper = async function ({
|
||||
unameAgent,
|
||||
projectName,
|
||||
tag,
|
||||
formats,
|
||||
libc,
|
||||
}) {
|
||||
console.log(`dbg: Installer User-Agent: ${unameAgent}`);
|
||||
// TODO maybe move package/version/lts/channel detection into getReleases
|
||||
var ver = tag.replace(/^v/, '');
|
||||
var lts;
|
||||
var channel;
|
||||
|
||||
let releaseTarget = toReleaseTarget(tag);
|
||||
let hostFormats = formats;
|
||||
let terms = unameAgent.split(/[\s\/]+/g);
|
||||
let hostTarget = {};
|
||||
try {
|
||||
void HostTargets.termsToTarget(hostTarget, terms);
|
||||
} catch (e) {
|
||||
// if we can't guarantee the results...
|
||||
// "in the face of ambiguity, refuse the temptation to guess"
|
||||
throw e;
|
||||
}
|
||||
console.log(`dbg: Installer Host Target:`);
|
||||
console.log(hostTarget);
|
||||
|
||||
if (!hostTarget.os) {
|
||||
throw new Error(`OS could not be identified by User-Agent '${unameAgent}'`);
|
||||
switch (ver) {
|
||||
case 'latest':
|
||||
ver = '';
|
||||
channel = 'stable';
|
||||
break;
|
||||
case 'lts':
|
||||
lts = true;
|
||||
channel = 'stable';
|
||||
ver = '';
|
||||
break;
|
||||
case 'stable':
|
||||
channel = 'stable';
|
||||
ver = '';
|
||||
break;
|
||||
case 'beta':
|
||||
channel = 'beta';
|
||||
ver = '';
|
||||
break;
|
||||
case 'dev':
|
||||
channel = 'dev';
|
||||
ver = '';
|
||||
break;
|
||||
}
|
||||
|
||||
console.log(`dbg: Get Project Installer Type for '${projectName}':`);
|
||||
let proj = await Builds.getProjectType(projectName);
|
||||
if (proj.type === 'alias') {
|
||||
console.log(`dbg: alias`, proj);
|
||||
projectName = proj.detail;
|
||||
proj = await Builds.getProjectType(projectName); // an alias should never resolve to an alias
|
||||
var myOs = uaDetect.os(ua);
|
||||
var myArch = uaDetect.arch(ua);
|
||||
var myLibc;
|
||||
if (libc) {
|
||||
myLibc = uaDetect.libc(libc);
|
||||
}
|
||||
console.log(`dbg: proj`, proj);
|
||||
|
||||
let validTypes = ['selfhosted', 'valid'];
|
||||
if (!validTypes.includes(proj.type)) {
|
||||
let msg = `'${projectName}' doesn't have an installer: '${proj.type}': '${proj.detail}'`;
|
||||
let err = new Error(msg);
|
||||
err.code = 'ENOENT';
|
||||
throw err;
|
||||
if (!myLibc) {
|
||||
myLibc = uaDetect.libc(ua);
|
||||
}
|
||||
if (!myLibc) {
|
||||
myLibc = 'libc';
|
||||
}
|
||||
|
||||
let tmplParams = {
|
||||
pkg: projectName,
|
||||
tag: tag,
|
||||
os: hostTarget.os,
|
||||
arch: hostTarget.arch,
|
||||
libc: hostTarget.libc,
|
||||
formats: hostFormats,
|
||||
let cfg = await Projects.get(pkg);
|
||||
let releaseQuery = {
|
||||
pkg: cfg.alias || pkg,
|
||||
ver,
|
||||
os: myOs,
|
||||
arch: myArch,
|
||||
libc: myLibc,
|
||||
lts,
|
||||
channel,
|
||||
// TODO use formats for sorting, not exclusion
|
||||
// (it's better to install xz or report an error to install zip)
|
||||
formats,
|
||||
limit: 1,
|
||||
};
|
||||
Object.assign(tmplParams, releaseTarget);
|
||||
console.log('tmplParams', tmplParams);
|
||||
|
||||
let errPackage = {
|
||||
name: 'doesntexist.ext',
|
||||
version: '0.0.0',
|
||||
lts: '-',
|
||||
channel: 'error',
|
||||
date: '1970-01-01',
|
||||
os: hostTarget.os || '-',
|
||||
arch: hostTarget.arch || '-',
|
||||
libc: hostTarget.libc || '-',
|
||||
ext: 'err',
|
||||
download: 'https://example.com/doesntexist.ext',
|
||||
comment:
|
||||
'No matches found. Could be bad or missing version info' +
|
||||
',' +
|
||||
"Check query parameters. Should be something like '/api/releases/{package}@{version}.tab?os={macos|linux|windows|-}&arch={amd64|x86|aarch64|arm64|armv7l|-}&libc={musl|gnu|msvc|libc|static}&limit=10'",
|
||||
let rels = await Releases.getReleases(releaseQuery);
|
||||
|
||||
var rel = rels.releases[0];
|
||||
var opts = {
|
||||
pkg: cfg.alias || pkg,
|
||||
ver,
|
||||
tag,
|
||||
os: myOs,
|
||||
arch: myArch,
|
||||
libc: myLibc,
|
||||
lts,
|
||||
channel,
|
||||
formats,
|
||||
limit: 1,
|
||||
};
|
||||
|
||||
if (proj.type === 'selfhosted') {
|
||||
return [errPackage, tmplParams];
|
||||
}
|
||||
|
||||
let projInfo = await Builds.getPackage({
|
||||
name: projectName,
|
||||
date: new Date(),
|
||||
});
|
||||
let latestVersions = Builds.enumerateLatestVersions(projInfo);
|
||||
//console.log('projInfo', projInfo);
|
||||
|
||||
let buildTargetInfo = {
|
||||
triplets: projInfo.triplets,
|
||||
oses: projInfo.oses,
|
||||
arches: projInfo.arches,
|
||||
libcs: projInfo.libcs,
|
||||
formats: projInfo.formats,
|
||||
latest: latestVersions.latest,
|
||||
stable: latestVersions.stable,
|
||||
};
|
||||
|
||||
// TODO .findMatchingPackages() should probably account for this
|
||||
let hasOs = projInfo.oses.includes(hostTarget.os);
|
||||
let maybePosix = !hasOs && hostTarget.os !== 'windows';
|
||||
if (maybePosix) {
|
||||
let posixes = ['posix_2017', 'posix_2024'];
|
||||
for (let posixYear of posixes) {
|
||||
let hasPosix = projInfo.oses.includes(posixYear);
|
||||
if (hasPosix) {
|
||||
hasOs = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!hasOs) {
|
||||
hasOs = projInfo.oses.includes('ANYOS');
|
||||
}
|
||||
|
||||
if (!hasOs) {
|
||||
let pkg1 = Object.assign(buildTargetInfo, errPackage);
|
||||
return [pkg1, tmplParams];
|
||||
}
|
||||
|
||||
let targetRelease = Builds.findMatchingPackages(
|
||||
projInfo,
|
||||
hostTarget,
|
||||
releaseTarget,
|
||||
rel = Object.assign(
|
||||
{
|
||||
oses: rels.oses,
|
||||
arches: rels.arches,
|
||||
libcs: rels.libcs,
|
||||
formats: rels.formats,
|
||||
},
|
||||
rel,
|
||||
);
|
||||
// { triplet: `${os}-${arch}-${libc}`, packages: targetPackages
|
||||
// , latest: projInfo.versions[0], versions: matchInfo
|
||||
// }
|
||||
|
||||
if (!targetRelease?.packages) {
|
||||
let pkg1 = Object.assign(buildTargetInfo, errPackage);
|
||||
return [pkg1, tmplParams];
|
||||
}
|
||||
|
||||
let buildPkg = Builds.selectPackage(targetRelease.packages, hostFormats);
|
||||
let ext = buildPkg.ext || '.exe';
|
||||
if (ext.startsWith('.')) {
|
||||
ext = ext.slice(1);
|
||||
}
|
||||
|
||||
let version = targetRelease.version;
|
||||
if (version.startsWith('v')) {
|
||||
version = version.slice(1);
|
||||
}
|
||||
|
||||
buildPkg = Object.assign(buildTargetInfo, buildPkg, { ext, version });
|
||||
console.log('dbg: buildPkg', buildPkg);
|
||||
console.log('dbg: tmplParams', tmplParams);
|
||||
return [buildPkg, tmplParams];
|
||||
return [rel, opts];
|
||||
};
|
||||
|
||||
let channelNames = [
|
||||
'stable',
|
||||
// 'hotfix',
|
||||
'latest',
|
||||
'rc',
|
||||
'preview',
|
||||
'pre',
|
||||
'dev',
|
||||
'beta',
|
||||
'alpha',
|
||||
];
|
||||
|
||||
function toReleaseTarget(tag) {
|
||||
tag = tag.replace(/^v/, '');
|
||||
|
||||
let releaseTarget = {
|
||||
channel: '',
|
||||
lts: false,
|
||||
version: '',
|
||||
};
|
||||
|
||||
if (tag === 'lts') {
|
||||
releaseTarget.lts = true;
|
||||
releaseTarget.channel = 'stable';
|
||||
} else if (channelNames.includes(tag)) {
|
||||
releaseTarget.channel = tag;
|
||||
} else {
|
||||
releaseTarget.version = tag;
|
||||
}
|
||||
|
||||
return releaseTarget;
|
||||
}
|
||||
|
||||
var CURL_PIPE_PS1_BOOT = Path.join(__dirname, 'curl-pipe-bootstrap.tpl.ps1');
|
||||
var CURL_PIPE_SH_BOOT = Path.join(__dirname, 'curl-pipe-bootstrap.tpl.sh');
|
||||
var CURL_PIPE_PS1_BOOT = path.join(__dirname, 'curl-pipe-bootstrap.tpl.ps1');
|
||||
var CURL_PIPE_SH_BOOT = path.join(__dirname, 'curl-pipe-bootstrap.tpl.sh');
|
||||
var BAD_SH_RE = /[<>'"`$\\]/;
|
||||
|
||||
InstallerServer.getPosixCurlPipeBootstrap = async function ({
|
||||
@@ -244,6 +150,7 @@ InstallerServer.getPosixCurlPipeBootstrap = async function ({
|
||||
let name = env[0];
|
||||
let value = env[1];
|
||||
|
||||
// TODO create REs once, in higher scope
|
||||
let envRe = new RegExp(
|
||||
`^[ \\t]*#?[ \\t]*(export[ \\t])?[ \\t]*(${name})=.*`,
|
||||
'm',
|
||||
@@ -291,6 +198,9 @@ InstallerServer.getPwshCurlPipeBootstrap = async function ({
|
||||
let tplRe = new RegExp(`{{ (${name}) }}`, 'g');
|
||||
bootTxt = bootTxt.replace(tplRe, `${value}`);
|
||||
|
||||
// let envRe = new RegExp(`^[ \\t]*#?[ \\t]*($$${name})[ \\t]*=.*`, 'im');
|
||||
// bootTxt = bootTxt.replace(envRe, `$$${name} = '${value}'`);
|
||||
|
||||
let setRe = new RegExp(
|
||||
`(#[ \\t]*)?(\\$${name})[ \\t]*=[ \\t]['"].*['"][ \\t]`,
|
||||
'im',
|
||||
|
||||
@@ -32,7 +32,7 @@ if (/\b-?-h(elp)?\b/.test(process.argv.join(' '))) {
|
||||
var os = require('os');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var Builds = require('./builds.js');
|
||||
var Releases = require('./transform-releases.js');
|
||||
var Installers = require('./installers.js');
|
||||
var ServeInstaller = require('./serve-installer.js');
|
||||
|
||||
@@ -65,8 +65,7 @@ console.info('Has the necessary files?');
|
||||
});
|
||||
|
||||
console.info('');
|
||||
let projName = pkgdir.split('/').filter(Boolean).pop();
|
||||
Builds.getPackage({ name: projName }).then(async function (/*projInfo*/) {
|
||||
Releases.get(path.join(process.cwd(), pkgdir)).then(async function (all) {
|
||||
var pkgname = path.basename(pkgdir.replace(/\/$/, ''));
|
||||
var nodeOs = os.platform();
|
||||
var nodeOsRelease = os.release();
|
||||
@@ -83,8 +82,8 @@ Builds.getPackage({ name: projName }).then(async function (/*projInfo*/) {
|
||||
var formats = ['exe', 'xz', 'tar', 'zip', 'git'];
|
||||
|
||||
let [rel, opts] = await ServeInstaller.helper({
|
||||
unameAgent: `${nodeOs}/${nodeOsRelease} ${nodeArch}/unknown ${nodeLibc}`,
|
||||
projectName: pkgname,
|
||||
ua: `${nodeOs}/${nodeOsRelease} ${nodeArch}/unknown ${nodeLibc}`,
|
||||
pkg: pkgname,
|
||||
tag: pkgtag || '',
|
||||
formats: formats,
|
||||
libc: nodeLibc,
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
var Releases = module.exports;
|
||||
|
||||
var path = require('path');
|
||||
var request = require('@root/request');
|
||||
var _normalize = require('./normalize.js');
|
||||
|
||||
var cache = {};
|
||||
@@ -16,18 +17,14 @@ let installerDir = path.join(__dirname, '..');
|
||||
Releases.get = async function (pkgdir) {
|
||||
let get;
|
||||
try {
|
||||
get = require(`${pkgdir}/releases.js`);
|
||||
// TODO update all releases files with module.exports.xxxx = 'foo';
|
||||
if (!get.latest) {
|
||||
get.latest = get;
|
||||
}
|
||||
get = require(path.join(pkgdir, 'releases.js'));
|
||||
} catch (e) {
|
||||
let err = new Error('no releases.js for', pkgdir.split(/[\/\\]+/).pop());
|
||||
err.code = 'E_NO_RELEASE';
|
||||
throw err;
|
||||
}
|
||||
|
||||
let all = await get.latest();
|
||||
let all = await get(request);
|
||||
|
||||
return _normalize(all);
|
||||
};
|
||||
|
||||
@@ -1,21 +1,29 @@
|
||||
'use strict';
|
||||
|
||||
let Releases = module.exports;
|
||||
var githubSource = require('../_common/github-source.js');
|
||||
var owner = 'BeyondCodeBootcamp';
|
||||
var repo = 'aliasman';
|
||||
|
||||
let GitHubSource = require('../_common/github-source.js');
|
||||
let owner = 'BeyondCodeBootcamp';
|
||||
let repo = 'aliasman';
|
||||
|
||||
Releases.latest = async function () {
|
||||
let all = await GitHubSource.getDistributables({ owner, repo });
|
||||
for (let pkg of all.releases) {
|
||||
pkg.os = 'posix_2017';
|
||||
}
|
||||
return all;
|
||||
module.exports = function (request) {
|
||||
let arches = [
|
||||
'amd64',
|
||||
'arm64',
|
||||
'armv6l',
|
||||
'armv7l',
|
||||
'ppc64le',
|
||||
'ppc64',
|
||||
's390x',
|
||||
'x86',
|
||||
];
|
||||
let oses = ['freebsd', 'linux', 'macos', 'posix'];
|
||||
return githubSource(request, owner, repo, oses, arches).then(function (all) {
|
||||
all._names = ['aliasman', 'legacy'];
|
||||
return all;
|
||||
});
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
Releases.latest().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
console.info(JSON.stringify(all, null, 2));
|
||||
});
|
||||
|
||||
@@ -4,15 +4,15 @@ var github = require('../_common/github.js');
|
||||
var owner = 'mholt';
|
||||
var repo = 'archiver';
|
||||
|
||||
module.exports = function () {
|
||||
return github(null, owner, repo).then(function (all) {
|
||||
module.exports = function (request) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
all._names = ['archiver', 'arc'];
|
||||
return all;
|
||||
});
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
// just select the first 5 for demonstration
|
||||
all.releases = all.releases.slice(0, 5);
|
||||
|
||||
@@ -32,8 +32,8 @@ let targets = {
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = function () {
|
||||
return github(null, owner, repo).then(function (all) {
|
||||
module.exports = function (request) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
for (let rel of all.releases) {
|
||||
let windows32 = rel.name.includes('WindowsX86.');
|
||||
if (windows32) {
|
||||
@@ -71,7 +71,7 @@ module.exports = function () {
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
console.info(JSON.stringify(all));
|
||||
//console.info(JSON.stringify(all, null, 2));
|
||||
|
||||
@@ -4,8 +4,8 @@ var github = require('../_common/github.js');
|
||||
var owner = 'wallix';
|
||||
var repo = 'awless';
|
||||
|
||||
module.exports = function () {
|
||||
return github(null, owner, repo).then(function (all) {
|
||||
module.exports = function (request) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
// remove checksums and .deb
|
||||
all.releases = all.releases.filter(function (rel) {
|
||||
return !/(\.txt)|(\.deb)$/i.test(rel.name);
|
||||
@@ -15,7 +15,7 @@ module.exports = function () {
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
console.info(JSON.stringify(all));
|
||||
});
|
||||
|
||||
@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
|
||||
var owner = 'sharkdp';
|
||||
var repo = 'bat';
|
||||
|
||||
module.exports = function () {
|
||||
return github(null, owner, repo).then(function (all) {
|
||||
module.exports = function (request) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
return all;
|
||||
});
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
all.releases = all.releases.slice(0, 10);
|
||||
//console.info(JSON.stringify(all));
|
||||
|
||||
@@ -6,23 +6,15 @@ main() { (
|
||||
sed '1,/^#~\/.local\/bin\/brew-updater/d' "${0}" > ~/.local/bin/brew-update-hourly
|
||||
chmod a+x ~/.local/bin/brew-update-hourly
|
||||
|
||||
echo "Checking for serviceman..."
|
||||
~/.local/bin/webi serviceman
|
||||
if ! command -v serviceman > /dev/null; then
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
fi
|
||||
serviceman --version
|
||||
|
||||
serviceman add --agent \
|
||||
env PATH="$PATH" serviceman add --user \
|
||||
--workdir ~/.local/opt/brew/ \
|
||||
--name sh.brew.updater -- \
|
||||
~/.local/bin/brew-update-hourly
|
||||
); }
|
||||
|
||||
if ! main; then
|
||||
exit 1
|
||||
if main; then
|
||||
exit 0
|
||||
fi
|
||||
exit 0
|
||||
|
||||
#~/.local/bin/brew-updater
|
||||
#!/bin/sh
|
||||
|
||||
@@ -132,7 +132,9 @@ file)
|
||||
```
|
||||
3. Add your project to the system launcher, running as the current user
|
||||
```sh
|
||||
serviceman add --name 'my-project' --daemon -- \
|
||||
sudo env PATH="$PATH" \
|
||||
serviceman add --path="$PATH" --system \
|
||||
--username "$(whoami)" --name my-project -- \
|
||||
bun run ./my-project.js
|
||||
```
|
||||
4. Restart the logging service
|
||||
@@ -153,6 +155,6 @@ For **macOS**:
|
||||
```
|
||||
3. Add your project to the system launcher, running as the current user
|
||||
```sh
|
||||
serviceman add --agent --name 'my-project' -- \
|
||||
serviceman add --path="$PATH" --user --name my-project -- \
|
||||
bun run ./my-project.js
|
||||
```
|
||||
|
||||
@@ -4,8 +4,8 @@ var github = require('../_common/github.js');
|
||||
var owner = 'oven-sh';
|
||||
var repo = 'bun';
|
||||
|
||||
module.exports = function () {
|
||||
return github(null, owner, repo).then(function (all) {
|
||||
module.exports = function (request) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
all.releases = all.releases
|
||||
.filter(function (r) {
|
||||
let isDebug = r.name.includes('-profile');
|
||||
@@ -18,14 +18,6 @@ module.exports = function () {
|
||||
return false;
|
||||
}
|
||||
|
||||
let isMusl = r.name.includes('-musl');
|
||||
if (isMusl) {
|
||||
r._musl = true;
|
||||
r.libc = 'musl';
|
||||
} else if (r.os === 'linux') {
|
||||
r.libc = 'gnu';
|
||||
}
|
||||
|
||||
return true;
|
||||
})
|
||||
.map(function (r) {
|
||||
@@ -38,7 +30,7 @@ module.exports = function () {
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
// just select the first 5 for demonstration
|
||||
all.releases = all.releases.slice(0, 5);
|
||||
|
||||
@@ -819,10 +819,10 @@ To avoid the nitty-gritty details of `launchd` plist files, you can use
|
||||
2. Use Serviceman to create a _launchd_ plist file
|
||||
|
||||
```sh
|
||||
my_username="$(id -u -n)"
|
||||
my_username="$( id -u -n )"
|
||||
|
||||
serviceman add --agent --name 'caddy' --workdir ./ -- \
|
||||
caddy run --envfile ~/.config/caddy/env --config ./Caddyfile --adapter caddyfile
|
||||
serviceman add --user --name caddy -- \
|
||||
caddy run --config ./Caddyfile --envfile ~/.config/caddy/env
|
||||
```
|
||||
|
||||
(this will create `~/Library/LaunchAgents/caddy.plist`)
|
||||
@@ -837,8 +837,8 @@ This process creates a _User-Level_ service in `~/Library/LaunchAgents`. To
|
||||
create a _System-Level_ service in `/Library/LaunchDaemons/` instead:
|
||||
|
||||
```sh
|
||||
serviceman add --name 'caddy' --workdir ./ --daemon -- \
|
||||
caddy run --envfile ~/.config/caddy/env --config ./Caddyfile --adapter caddyfile
|
||||
sudo serviceman add --system --name caddy -- \
|
||||
caddy run --config ./Caddyfile --envfile ~/.config/caddy/env
|
||||
```
|
||||
|
||||
### How to run Caddy as a Windows Service
|
||||
@@ -856,7 +856,7 @@ serviceman add --name 'caddy' --workdir ./ --daemon -- \
|
||||
3. Create a **Startup Registry Entry** with Serviceman.
|
||||
```sh
|
||||
serviceman.exe add --name caddy -- \
|
||||
caddy run --envfile ~/.config/caddy/env --config ./Caddyfile --adapter caddyfile
|
||||
caddy run --config ./Caddyfile --envfile ~/.config/caddy/env
|
||||
```
|
||||
4. You can manage the service directly with Serviceman. For example:
|
||||
```sh
|
||||
@@ -901,8 +901,10 @@ See the notes below to run as a **User Service** or use the JSON Config.
|
||||
```
|
||||
4. Use Serviceman to create a _systemd_ config file.
|
||||
```sh
|
||||
serviceman add --name 'caddy' --daemon -- \
|
||||
caddy run --envfile ~/.config/caddy/env --config ./Caddyfile --adapter caddyfile
|
||||
my_username="$( id -u -n )"
|
||||
sudo env PATH="$PATH" \
|
||||
serviceman add --system --username "${my_username}" --name caddy -- \
|
||||
caddy run --config ./Caddyfile --envfile ~/.config/caddy/env
|
||||
```
|
||||
(this will create `/etc/systemd/system/caddy.service`)
|
||||
5. Manage the service with `systemctl` and `journalctl`:
|
||||
@@ -913,10 +915,10 @@ See the notes below to run as a **User Service** or use the JSON Config.
|
||||
|
||||
To create a **User Service** instead:
|
||||
|
||||
- use `--agent` when running `serviceman`:
|
||||
- don't use `sudo`, but do use `--user` when running `serviceman`:
|
||||
```sh
|
||||
serviceman add --agent --name caddy -- \
|
||||
caddy run --envfile ~/.config/caddy/env --config ./Caddyfile --adapter caddyfile
|
||||
serviceman add --user --name caddy -- \
|
||||
caddy run --config ./Caddyfile --envfile ~/.config/caddy/env
|
||||
```
|
||||
(this will create `~/.config/systemd/user/`)
|
||||
- user the `--user` flag to manage services and logs:
|
||||
@@ -1361,13 +1363,19 @@ See also: <https://caddyserver.com/docs/running>
|
||||
2. Generate the `service` file: \
|
||||
- JSON Config
|
||||
```sh
|
||||
serviceman add --name 'caddy' --daemon -- \
|
||||
caddy run --resume --envfile ./caddy.env
|
||||
my_app_user="$( id -u -n )"
|
||||
sudo env PATH="${PATH}" \
|
||||
serviceman add --system --cap-net-bind \
|
||||
--username "${my_app_user}" --name caddy -- \
|
||||
caddy run --resume --envfile ./caddy.env
|
||||
```
|
||||
- Caddyfile
|
||||
```sh
|
||||
serviceman add --name 'caddy' --daemon -- \
|
||||
caddy run --config ./Caddyfile --envfile ./caddy.env
|
||||
my_app_user="$( id -u -n )"
|
||||
sudo env PATH="${PATH}" \
|
||||
serviceman add --system --cap-net-bind \
|
||||
--username "${my_app_user}" --name caddy -- \
|
||||
caddy run --config ./Caddyfile --envfile ./caddy.env
|
||||
```
|
||||
3. Reload `systemd` config files, the logging service (it may not be started on
|
||||
a new VPS), and caddy
|
||||
|
||||
@@ -4,8 +4,8 @@ var github = require('../_common/github.js');
|
||||
var owner = 'caddyserver';
|
||||
var repo = 'caddy';
|
||||
|
||||
module.exports = function () {
|
||||
return github(null, owner, repo).then(function (all) {
|
||||
module.exports = function (request) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
// remove checksums and .deb
|
||||
all.releases = all.releases.filter(function (rel) {
|
||||
let isOneOffAsset = rel.download.includes('buildable-artifact');
|
||||
@@ -20,7 +20,7 @@ module.exports = function () {
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
console.info(JSON.stringify(all));
|
||||
});
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
let Fetcher = require('../_common/fetcher.js');
|
||||
|
||||
// See <https://googlechromelabs.github.io/chrome-for-testing/>
|
||||
const releaseApiUrl =
|
||||
var releaseApiUrl =
|
||||
'https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json';
|
||||
|
||||
// {
|
||||
@@ -42,24 +40,14 @@ const releaseApiUrl =
|
||||
// ]
|
||||
// }
|
||||
|
||||
module.exports = async function () {
|
||||
let resp;
|
||||
try {
|
||||
resp = await Fetcher.fetch(releaseApiUrl, {
|
||||
headers: { Accept: 'application/json' },
|
||||
});
|
||||
} catch (e) {
|
||||
/** @type {Error & { code: string, response: { status: number, body: string } }} */ //@ts-expect-error
|
||||
let err = e;
|
||||
if (err.code === 'E_FETCH_RELEASES') {
|
||||
err.message = `failed to fetch 'chromedriver' release data: ${err.response.status} ${err.response.body}`;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
let data = JSON.parse(resp.body);
|
||||
module.exports = async function (request) {
|
||||
let resp = await request({
|
||||
url: releaseApiUrl,
|
||||
json: true,
|
||||
});
|
||||
|
||||
let builds = [];
|
||||
for (let release of data.versions) {
|
||||
for (let release of resp.body.versions) {
|
||||
if (!release.downloads.chromedriver) {
|
||||
continue;
|
||||
}
|
||||
@@ -70,7 +58,7 @@ module.exports = async function () {
|
||||
version: version,
|
||||
download: asset.url,
|
||||
// I' not sure that this is actually statically built but it
|
||||
// seems to be and at worst we'll just get bug reports for Alpine
|
||||
// seems to be and at worst we'll just get bug reports for Apline
|
||||
libc: 'none',
|
||||
};
|
||||
|
||||
@@ -87,15 +75,10 @@ module.exports = async function () {
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module
|
||||
.exports()
|
||||
.then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
// just select the latest 20 for demonstration
|
||||
all.releases = all.releases.slice(-20);
|
||||
console.info(JSON.stringify(all, null, 2));
|
||||
})
|
||||
.catch(function (err) {
|
||||
console.error('Error:', err);
|
||||
});
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
// just select the latest 5 for demonstration
|
||||
all.releases = all.releases.slice(-20);
|
||||
console.info(JSON.stringify(all, null, 2));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
---
|
||||
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
|
||||
```
|
||||
@@ -1,45 +0,0 @@
|
||||
#!/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
|
||||
@@ -1,39 +0,0 @@
|
||||
#!/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
|
||||
@@ -1,21 +0,0 @@
|
||||
'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 repo = 'CMake';
|
||||
|
||||
module.exports = function () {
|
||||
return github(null, owner, repo).then(function (all) {
|
||||
module.exports = function (request) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
for (let rel of all.releases) {
|
||||
if (rel.version.startsWith('v')) {
|
||||
rel._version = rel.version.slice(1);
|
||||
@@ -44,7 +44,7 @@ module.exports = function () {
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
// just select the first 5 for demonstration
|
||||
all.releases = all.releases.slice(0, 5);
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
---
|
||||
title: XCode Command Line Tools
|
||||
homepage: https://webinstall.dev/commandlinetools
|
||||
tagline: |
|
||||
The XCode Command Line Tools include git, swift, make, clang, and other developer tools
|
||||
---
|
||||
|
||||
## Cheat Sheet
|
||||
|
||||
> The developer tools provided by Apple for macOS.
|
||||
|
||||
- git
|
||||
- swift
|
||||
- make
|
||||
- clang
|
||||
- etc
|
||||
|
||||
This is also part of [webi-essentials](../webi-essentials/).
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- Files
|
||||
- Manual Install
|
||||
- macOS
|
||||
- Linux
|
||||
- Alpine
|
||||
- Windows
|
||||
|
||||
### Files
|
||||
|
||||
These are the files / directories that are created and/or modified with this
|
||||
install:
|
||||
|
||||
```sh
|
||||
/Library/Developer/CommandLineTools/
|
||||
```
|
||||
|
||||
### How to Install Manually
|
||||
|
||||
It's very easy to start the installer:
|
||||
|
||||
```sh
|
||||
xcode-select --install
|
||||
```
|
||||
|
||||
The trick is to also have a mechanism to know when it has finished:
|
||||
|
||||
```sh
|
||||
while ! test -x /Library/Developer/CommandLineTools/usr/bin/git ||
|
||||
! test -x /Library/Developer/CommandLineTools/usr/bin/make; do
|
||||
sleep 0.25
|
||||
done
|
||||
|
||||
echo "Command Line Tools Installed"
|
||||
```
|
||||
@@ -1,62 +0,0 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
set -u
|
||||
|
||||
fn_install_xcode_commandlinetools() { (
|
||||
b_os="$(uname -s)"
|
||||
if test "${b_os}" != 'Darwin'; then
|
||||
echo >&2 'XCode Command Line Tools are for macOS only'
|
||||
return 1
|
||||
fi
|
||||
|
||||
# streamline the output to be pretty
|
||||
fn_check_pkg '/Library/Developer/CommandLineTools/usr/bin/clang' 'clang'
|
||||
fn_check_pkg '/Library/Developer/CommandLineTools/usr/bin/git' 'git'
|
||||
fn_check_pkg '/Library/Developer/CommandLineTools/usr/bin/make' 'make'
|
||||
echo >&2 ""
|
||||
|
||||
# git
|
||||
if xcode-select -p > /dev/null 2> /dev/null; then
|
||||
echo ""
|
||||
return 0
|
||||
fi
|
||||
|
||||
cmd_xcode_cli_tools_install="xcode-select --install"
|
||||
echo " Running $(t_cmd "${cmd_xcode_cli_tools_install}")"
|
||||
$cmd_xcode_cli_tools_install 2> /dev/null
|
||||
echo ""
|
||||
echo ">>> $(t_attn 'ACTION REQUIRED') <<<"
|
||||
echo ""
|
||||
echo " $(t_attn "Click") '$(t_bold 'Install')' $(t_attn "in the pop-up")"
|
||||
echo " (it may appear $(t_em 'under') this window)"
|
||||
echo ""
|
||||
echo "^^^ $(t_attn 'ACTION REQUIRED') ^^^"
|
||||
echo ""
|
||||
printf " waiting %s to finish installing Command Line Developer Tools ..." "$(t_em 'for you')"
|
||||
while ! test -x /Library/Developer/CommandLineTools/usr/bin/git ||
|
||||
! test -x /Library/Developer/CommandLineTools/usr/bin/make; do
|
||||
sleep 0.25
|
||||
done
|
||||
echo " $(t_info 'OK')"
|
||||
echo " Installed to $(t_path '/Library/Developer/CommandLineTools/')"
|
||||
sleep 1
|
||||
); }
|
||||
|
||||
fn_check_pkg() { (
|
||||
a_pkg="${1}"
|
||||
a_pkgname="${2:-$a_pkg}"
|
||||
|
||||
printf >&2 ' %s %s %s' \
|
||||
"$(t_dim "Checking for")" \
|
||||
"$(t_pkg "${a_pkgname}")" \
|
||||
"$(t_dim "...")"
|
||||
|
||||
if command -v "${a_pkg}" > /dev/null; then
|
||||
echo >&2 " $(t_dim 'OK')"
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo >&2 ' missing'
|
||||
); }
|
||||
|
||||
fn_install_xcode_commandlinetools
|
||||
@@ -6,8 +6,8 @@ var repo = 'comrak';
|
||||
|
||||
var ODDITIES = ['-musleabihf.1-'];
|
||||
|
||||
module.exports = function () {
|
||||
return github(null, owner, repo).then(function (all) {
|
||||
module.exports = function (request) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
let builds = [];
|
||||
|
||||
loopBuilds: for (let build of all.releases) {
|
||||
@@ -31,7 +31,7 @@ module.exports = function () {
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
all.releases = all.releases.slice(0, 10);
|
||||
//console.info(JSON.stringify(all));
|
||||
|
||||
@@ -4,8 +4,8 @@ var github = require('../_common/github.js');
|
||||
var owner = 'sstadick';
|
||||
var repo = 'crabz';
|
||||
|
||||
module.exports = async function () {
|
||||
let all = await github(null, owner, repo);
|
||||
module.exports = async function (request) {
|
||||
let all = await github(request, owner, repo);
|
||||
|
||||
let releases = [];
|
||||
for (let rel of all.releases) {
|
||||
@@ -22,7 +22,7 @@ module.exports = async function () {
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
// just select the first 5 for demonstration
|
||||
all.releases = all.releases.slice(0, 5);
|
||||
|
||||
@@ -4,15 +4,15 @@ var github = require('../_common/github.js');
|
||||
var owner = 'rs';
|
||||
var repo = 'curlie';
|
||||
|
||||
module.exports = function () {
|
||||
return github(null, owner, repo).then(function (all) {
|
||||
module.exports = function (request) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
all._names = ['curlie', 'curl-httpie'];
|
||||
return all;
|
||||
});
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
all.releases = all.releases.slice(0, 10);
|
||||
//console.info(JSON.stringify(all));
|
||||
|
||||
@@ -100,7 +100,8 @@ mkdir -p ~/.dashcore/wallets/
|
||||
mkdir -p /mnt/slc1_vol_100g/dashcore/_data
|
||||
mkdir -p /mnt/slc1_vol_100g/dashcore/_caches
|
||||
|
||||
serviceman add --name 'dashd' --daemon -- \
|
||||
sudo env PATH="$PATH" serviceman add \
|
||||
--system --user "$my_user" --path "$PATH" --name dashd --force -- \
|
||||
dashd \
|
||||
-usehd \
|
||||
-conf="$HOME/.dashcore/dash.conf" \
|
||||
|
||||
@@ -1,14 +1,7 @@
|
||||
# for exposing RPCs, building APIs
|
||||
txindex=1
|
||||
addressindex=1
|
||||
timestampindex=1
|
||||
spentindex=1
|
||||
# listen as server (explicit default)
|
||||
listen=1
|
||||
# because its already run as a service (systemd, openrc)
|
||||
daemon=0
|
||||
# for evonodes
|
||||
#server=1
|
||||
|
||||
[main]
|
||||
rpcuser=RPCUSER_MAIN
|
||||
|
||||
@@ -17,7 +17,7 @@ fn_usage() { (
|
||||
); }
|
||||
|
||||
fn_datadir_help() { (
|
||||
my_vol="${1}"
|
||||
my_vol="${1:-}"
|
||||
my_user="$(
|
||||
id -n -u
|
||||
)"
|
||||
@@ -25,7 +25,6 @@ fn_datadir_help() { (
|
||||
id -n -g
|
||||
)"
|
||||
|
||||
my_mount="$(dirname "${my_vol}")"
|
||||
echo >&2 ""
|
||||
echo >&2 "ERROR"
|
||||
echo >&2 " '${my_vol}' is not writable"
|
||||
@@ -33,8 +32,8 @@ fn_datadir_help() { (
|
||||
echo >&2 "SOLUTION"
|
||||
echo >&2 " 1. Mount a large (50gb+) volume"
|
||||
echo >&2 ""
|
||||
echo >&2 " sudo mkdir -p ${my_mount}"
|
||||
echo >&2 " sudo mount /dev/sdx1 ${my_mount}"
|
||||
echo >&2 " sudo mkdir -p /mnt/EXAMPLE"
|
||||
echo >&2 " sudo mount /dev/sdx1 /mnt/EXAMPLE"
|
||||
echo >&2 ""
|
||||
echo >&2 " 2. Create a 'dashcore' inside of it"
|
||||
echo >&2 ""
|
||||
@@ -84,8 +83,20 @@ fn_srv_install() { (
|
||||
my_name="dashd-${my_netname}"
|
||||
fi
|
||||
|
||||
my_system_args=""
|
||||
my_kernel="$(
|
||||
uname -s
|
||||
)"
|
||||
if test "Darwin" != "${my_kernel}"; then
|
||||
my_user="$(
|
||||
id -u -n
|
||||
)"
|
||||
my_system_args="--system --username ${my_user}"
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2016,SC1090
|
||||
echo "serviceman add --name \"${my_name}\" --" \
|
||||
echo 'sudo env PATH="$PATH"' \
|
||||
"serviceman add ${my_system_args} --path \"\$PATH\" --name \"${my_name}\" --force --" \
|
||||
"dashd " \
|
||||
"${my_net_flag}" \
|
||||
-usehd \
|
||||
@@ -95,16 +106,16 @@ fn_srv_install() { (
|
||||
"-datadir=\"${my_datadir}\"" \
|
||||
"-blocksdir=\"${my_blocksdir}\""
|
||||
|
||||
echo ""
|
||||
echo "Installing latest 'serviceman'..."
|
||||
echo ""
|
||||
"$HOME/.local/bin/webi" serviceman > /dev/null
|
||||
if ! command -v serviceman > /dev/null; then
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
fi
|
||||
serviceman --version
|
||||
if ! command -v dashd > /dev/null; then
|
||||
export PATH="$HOME/.local/opt/dashcore/bin:$PATH"
|
||||
echo ""
|
||||
echo "Installing 'serviceman'..."
|
||||
echo ""
|
||||
{
|
||||
curl -fsSL "${WEBI_HOST}/serviceman" | sh
|
||||
} > /dev/null
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
. ~/.config/envman/PATH.env || true
|
||||
fi
|
||||
|
||||
mkdir -p "$HOME/.dashcore/wallets/"
|
||||
@@ -119,7 +130,8 @@ fn_srv_install() { (
|
||||
cd "${my_vol}" || return 1
|
||||
# leave options unquoted so they're interpreted separately
|
||||
# shellcheck disable=SC2086
|
||||
serviceman add --name "${my_name}" -- \
|
||||
sudo env PATH="${PATH}" \
|
||||
serviceman add ${my_system_args} --path "${PATH}" --name "${my_name}" --force -- \
|
||||
dashd \
|
||||
${my_net_flag} \
|
||||
-usehd \
|
||||
|
||||
@@ -5,38 +5,32 @@ set -u
|
||||
__install_dashcore_utils() {
|
||||
webi_download \
|
||||
"$WEBI_HOST/packages/dashcore-utils/dash-qt-hd" \
|
||||
"$HOME/.local/bin/dash-qt-hd" \
|
||||
"dash-qt-hd"
|
||||
"$HOME/.local/bin/dash-qt-hd"
|
||||
chmod a+x "$HOME/.local/bin/dash-qt-hd"
|
||||
|
||||
webi_download \
|
||||
"$WEBI_HOST/packages/dashcore-utils/dash-qt-testnet" \
|
||||
"$HOME/.local/bin/dash-qt-testnet" \
|
||||
"dash-qt-testnet"
|
||||
"$HOME/.local/bin/dash-qt-testnet"
|
||||
chmod a+x "$HOME/.local/bin/dash-qt-testnet"
|
||||
|
||||
webi_download \
|
||||
"$WEBI_HOST/packages/dashcore-utils/dashd-hd" \
|
||||
"$HOME/.local/bin/dashd-hd" \
|
||||
"dashd-hd"
|
||||
"$HOME/.local/bin/dashd-hd"
|
||||
chmod a+x "$HOME/.local/bin/dashd-hd"
|
||||
|
||||
webi_download \
|
||||
"$WEBI_HOST/packages/dashcore-utils/dashd-testnet" \
|
||||
"$HOME/.local/bin/dashd-testnet" \
|
||||
"dashd-testnet"
|
||||
"$HOME/.local/bin/dashd-testnet"
|
||||
chmod a+x "$HOME/.local/bin/dashd-testnet"
|
||||
|
||||
webi_download \
|
||||
"$WEBI_HOST/packages/dashcore-utils/dashd-hd-service-install" \
|
||||
"$HOME/.local/bin/dashd-hd-service-install" \
|
||||
"dashd-hd-service-install"
|
||||
"$HOME/.local/bin/dashd-hd-service-install"
|
||||
chmod a+x "$HOME/.local/bin/dashd-hd-service-install"
|
||||
|
||||
webi_download \
|
||||
"$WEBI_HOST/packages/dashcore-utils/dashd-testnet-service-install" \
|
||||
"$HOME/.local/bin/dashd-testnet-service-install" \
|
||||
"dashd-testnet-service-install"
|
||||
"$HOME/.local/bin/dashd-testnet-service-install"
|
||||
chmod a+x "$HOME/.local/bin/dashd-testnet-service-install"
|
||||
|
||||
if ! test -e "${HOME}/.dashcore"; then
|
||||
@@ -50,8 +44,7 @@ __install_dashcore_utils() {
|
||||
|
||||
webi_download \
|
||||
"$WEBI_HOST/packages/dashcore-utils/dash.example.conf" \
|
||||
"$HOME/.dashcore/dash.example.conf" \
|
||||
"dash.example.conf"
|
||||
"$HOME/.dashcore/dash.example.conf"
|
||||
|
||||
if ! grep -q rpcuser ~/.dashcore/dash.conf; then
|
||||
cat ~/.dashcore/dash.example.conf >> ~/.dashcore/dash.conf
|
||||
|
||||
@@ -4,8 +4,8 @@ var github = require('../_common/github.js');
|
||||
var owner = 'dashpay';
|
||||
var repo = 'dash';
|
||||
|
||||
module.exports = function () {
|
||||
return github(null, owner, repo).then(function (all) {
|
||||
module.exports = function (request) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
all.releases.forEach(function (rel) {
|
||||
if (rel.name.includes('osx64')) {
|
||||
rel.os = 'macos';
|
||||
@@ -22,7 +22,7 @@ module.exports = function () {
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
// just select the first 5 for demonstration
|
||||
all.releases = all.releases.slice(0, 5);
|
||||
|
||||
@@ -24,7 +24,7 @@ install:
|
||||
~/.config/envman/PATH.env
|
||||
~/.dashcore/dash.conf
|
||||
~/.dashcore/wallets/
|
||||
~/.local/bin/dashd-hd-service-install
|
||||
~/.local/bin/bin/dashd-hd-service-install
|
||||
~/.local/opt/dashcore/
|
||||
/mnt/<BLK_VOL>/dashcore/
|
||||
```
|
||||
@@ -219,7 +219,14 @@ You can use [`serviceman`](../serviceman/):
|
||||
**Linux**
|
||||
|
||||
```sh
|
||||
serviceman add --name 'dashd' -- \
|
||||
sudo env PATH="$PATH" \
|
||||
serviceman add \
|
||||
--system \
|
||||
--username "$(id -n -u)" \
|
||||
--path "$PATH" \
|
||||
--name dashd \
|
||||
--force \
|
||||
-- \
|
||||
dashd \
|
||||
-usehd \
|
||||
-conf="$HOME/.dashcore/dash.conf" \
|
||||
@@ -232,7 +239,11 @@ serviceman add --name 'dashd' -- \
|
||||
**Mac**
|
||||
|
||||
```sh
|
||||
serviceman add --name 'dashd' -- \
|
||||
serviceman add \
|
||||
--path "$PATH" \
|
||||
--name dashd \
|
||||
--force \
|
||||
-- \
|
||||
dashd \
|
||||
-usehd \
|
||||
-conf="$HOME/.dashcore/dash.conf" \
|
||||
|
||||
@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
|
||||
var owner = 'dashhive';
|
||||
var repo = 'dashmsg';
|
||||
|
||||
module.exports = function () {
|
||||
return github(null, owner, repo).then(function (all) {
|
||||
module.exports = function (request) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
return all;
|
||||
});
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
console.info(JSON.stringify(all, null, 2));
|
||||
});
|
||||
|
||||
@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
|
||||
var owner = 'dandavison';
|
||||
var repo = 'delta';
|
||||
|
||||
module.exports = function () {
|
||||
return github(null, owner, repo).then(function (all) {
|
||||
module.exports = function (request) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
return all;
|
||||
});
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
// just select the first 15 for demonstration
|
||||
all.releases = all.releases.slice(0, 15);
|
||||
|
||||
@@ -18,7 +18,7 @@ etc).
|
||||
The obligatory Hello World
|
||||
|
||||
```sh
|
||||
deno run https://docs.deno.com/examples/scripts/hello_world.ts
|
||||
deno run https://deno.land/std/examples/welcome.ts
|
||||
```
|
||||
|
||||
Run a local file
|
||||
|
||||
@@ -6,8 +6,8 @@ var github = require('../_common/github.js');
|
||||
var owner = 'denoland';
|
||||
var repo = 'deno';
|
||||
|
||||
module.exports = function () {
|
||||
return github(null, owner, repo).then(function (all) {
|
||||
module.exports = function (request) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
// remove checksums and .deb
|
||||
all.releases = all.releases
|
||||
.filter(function (rel) {
|
||||
@@ -35,7 +35,7 @@ module.exports = function () {
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
console.info(JSON.stringify(all, null, 2));
|
||||
});
|
||||
|
||||
@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
|
||||
var owner = 'dotenv-linter';
|
||||
var repo = 'dotenv-linter';
|
||||
|
||||
module.exports = function () {
|
||||
return github(null, owner, repo).then(function (all) {
|
||||
module.exports = function (request) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
return all;
|
||||
});
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
// just select the first 5 for demonstration
|
||||
all.releases = all.releases.slice(0, 5);
|
||||
|
||||
@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
|
||||
var owner = 'therootcompany';
|
||||
var repo = 'dotenv';
|
||||
|
||||
module.exports = function () {
|
||||
return github(null, owner, repo).then(function (all) {
|
||||
module.exports = function (request) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
return all;
|
||||
});
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
console.info(JSON.stringify(all));
|
||||
});
|
||||
|
||||
@@ -1,21 +1,29 @@
|
||||
'use strict';
|
||||
|
||||
let Releases = module.exports;
|
||||
var githubSource = require('../_common/github-source.js');
|
||||
var owner = 'BeyondCodeBootcamp';
|
||||
var repo = 'DuckDNS.sh';
|
||||
|
||||
let GitHubSource = require('../_common/github-source.js');
|
||||
let owner = 'BeyondCodeBootcamp';
|
||||
let repo = 'DuckDNS.sh';
|
||||
|
||||
Releases.latest = async function () {
|
||||
let all = await GitHubSource.getDistributables({ owner, repo });
|
||||
for (let pkg of all.releases) {
|
||||
pkg.os = 'posix_2017';
|
||||
}
|
||||
return all;
|
||||
module.exports = function (request) {
|
||||
let arches = [
|
||||
'amd64',
|
||||
'arm64',
|
||||
'armv6l',
|
||||
'armv7l',
|
||||
'ppc64le',
|
||||
'ppc64',
|
||||
's390x',
|
||||
'x86',
|
||||
];
|
||||
let oses = ['freebsd', 'linux', 'macos', 'posix'];
|
||||
return githubSource(request, owner, repo, oses, arches).then(function (all) {
|
||||
all._names = ['DuckDNS.sh', 'duckdns.sh', 'legacy'];
|
||||
return all;
|
||||
});
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
Releases.latest().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
console.info(JSON.stringify(all, null, 2));
|
||||
});
|
||||
|
||||
@@ -2,16 +2,10 @@
|
||||
set -e
|
||||
set -u
|
||||
|
||||
echo "'duckdns@${WEBI_TAG:-stable}' is reserved for future use."
|
||||
echo
|
||||
echo "Did you mean 'duckdns.sh@${WEBI_VERSION-}'?"
|
||||
WEBI_HOST=${WEBI_HOST:-"https://webi.sh"}
|
||||
|
||||
echo ""
|
||||
echo "ERROR"
|
||||
echo " installer name 'duckdns' is reserved for future use"
|
||||
echo ""
|
||||
echo "SOLUTION"
|
||||
echo " Did you mean 'duckdns.sh'?"
|
||||
echo ""
|
||||
echo " curl -fsSL '$WEBI_HOST/duckdns.sh' | sh"
|
||||
echo ""
|
||||
|
||||
echo " curl -fsSL '$WEBI_HOST/duckdns.sh@${WEBI_VERSION-}' | sh"
|
||||
exit 1
|
||||
|
||||
@@ -4,8 +4,8 @@ var github = require('../_common/github.js');
|
||||
var owner = 'sharkdp';
|
||||
var repo = 'fd';
|
||||
|
||||
module.exports = function () {
|
||||
return github(null, owner, repo).then(function (all) {
|
||||
module.exports = function (request) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
let builds = [];
|
||||
|
||||
for (let build of all.releases) {
|
||||
@@ -22,7 +22,7 @@ module.exports = function () {
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
all.releases = all.releases.slice(0, 10);
|
||||
//console.info(JSON.stringify(all));
|
||||
|
||||
@@ -6,8 +6,8 @@ var github = require('../_common/github.js');
|
||||
var owner = 'eugeneware';
|
||||
var repo = 'ffmpeg-static';
|
||||
|
||||
module.exports = function () {
|
||||
return github(null, owner, repo).then(function (all) {
|
||||
module.exports = function (request) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
all.releases = all.releases
|
||||
.filter(function (rel) {
|
||||
let isFfmpeg = rel.name.includes('ffmpeg');
|
||||
@@ -38,7 +38,7 @@ module.exports = function () {
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
console.info(JSON.stringify(all));
|
||||
});
|
||||
|
||||
@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
|
||||
var owner = 'ffuf';
|
||||
var repo = 'ffuf';
|
||||
|
||||
module.exports = function () {
|
||||
return github(null, owner, repo).then(function (all) {
|
||||
module.exports = function (request) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
return all;
|
||||
});
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
// just select the first 5 for demonstration
|
||||
all.releases = all.releases.slice(0, 5);
|
||||
|
||||
@@ -43,7 +43,7 @@ the file:
|
||||
```sh
|
||||
#!/bin/bash
|
||||
|
||||
echo "Who am I? I'm $(id -u -n)."
|
||||
echo "Who am I? I'm $(whoami)."
|
||||
```
|
||||
|
||||
You can also run bash explicitly:
|
||||
@@ -99,7 +99,7 @@ You should use `chsh` to change your shell:
|
||||
```sh
|
||||
#!/bin/sh
|
||||
|
||||
sudo chsh -s "$(command -v fish)" "$(id -u -n)"
|
||||
sudo chsh -s "$(command -v fish)" "$(whoami)"
|
||||
```
|
||||
|
||||
If vim uses `fish` instead of `bash`, annoying errors will happen.
|
||||
|
||||
@@ -6,8 +6,8 @@ var repo = 'fish-shell';
|
||||
|
||||
var ODDITIES = ['bundledpcre'];
|
||||
|
||||
module.exports = function () {
|
||||
return github(null, owner, repo).then(function (all) {
|
||||
module.exports = function (request) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
all.releases = all.releases
|
||||
.map(function (rel) {
|
||||
for (let oddity of ODDITIES) {
|
||||
@@ -30,7 +30,7 @@ module.exports = function () {
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
// just select the first 5 for demonstration
|
||||
all.releases = all.releases.slice(0, 5);
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
let Fetcher = require('../_common/fetcher.js');
|
||||
var FLUTTER_OSES = ['macos', 'linux', 'windows'];
|
||||
|
||||
let FLUTTER_OSES = ['macos', 'linux', 'windows'];
|
||||
|
||||
/**
|
||||
* stable, beta, dev
|
||||
* @type {Object.<String, Boolean>}
|
||||
*/
|
||||
let channelMap = {};
|
||||
// stable, beta, dev
|
||||
var channelMap = {};
|
||||
|
||||
// This can be spot-checked against
|
||||
// https://docs.flutter.dev/release/archive?tab=windows
|
||||
@@ -58,47 +53,23 @@ let channelMap = {};
|
||||
// ]
|
||||
// }
|
||||
|
||||
/**
|
||||
* @typedef BuildInfo
|
||||
* @prop {String} version
|
||||
* @prop {String} [_version]
|
||||
* @prop {Boolean} lts
|
||||
* @prop {String} channel
|
||||
* @prop {String} date
|
||||
* @prop {String} download
|
||||
* @prop {String} [_filename]
|
||||
*/
|
||||
|
||||
module.exports = async function () {
|
||||
module.exports = async function (request) {
|
||||
let all = {
|
||||
download: '',
|
||||
/** @type {Array<BuildInfo>} */
|
||||
releases: [],
|
||||
/** @type {Array<String>} */
|
||||
channels: [],
|
||||
};
|
||||
|
||||
for (let osname of FLUTTER_OSES) {
|
||||
let resp;
|
||||
try {
|
||||
let url = `https://storage.googleapis.com/flutter_infra_release/releases/releases_${osname}.json`;
|
||||
resp = await Fetcher.fetch(url, {
|
||||
headers: { Accept: 'application/json' },
|
||||
});
|
||||
} catch (e) {
|
||||
/** @type {Error & { code: string, response: { status: number, body: string } }} */ //@ts-expect-error
|
||||
let err = e;
|
||||
if (err.code === 'E_FETCH_RELEASES') {
|
||||
err.message = `failed to fetch 'flutter' release data for ${osname}: ${err.response.status} ${err.response.body}`;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
let data = JSON.parse(resp.body);
|
||||
let resp = await request({
|
||||
url: `https://storage.googleapis.com/flutter_infra_release/releases/releases_${osname}.json`,
|
||||
json: true,
|
||||
});
|
||||
|
||||
let osBaseUrl = data.base_url;
|
||||
let osReleases = data.releases;
|
||||
let body = resp.body;
|
||||
all.download = `${body.base_url}/{{ download }}`;
|
||||
|
||||
for (let asset of osReleases) {
|
||||
for (let asset of body.releases) {
|
||||
if (!channelMap[asset.channel]) {
|
||||
channelMap[asset.channel] = true;
|
||||
}
|
||||
@@ -109,8 +80,8 @@ module.exports = async function () {
|
||||
lts: false,
|
||||
channel: asset.channel,
|
||||
date: asset.release_date.replace(/T.*/, ''),
|
||||
download: `${osBaseUrl}/${asset.archive}`,
|
||||
_filename: asset.archive,
|
||||
//sha256: asset.sha256,
|
||||
download: asset.archive,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -125,7 +96,7 @@ module.exports = async function () {
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all.releases = all.releases.slice(25);
|
||||
console.info(JSON.stringify(all, null, 2));
|
||||
});
|
||||
|
||||
@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
|
||||
var owner = 'junegunn';
|
||||
var repo = 'fzf';
|
||||
|
||||
module.exports = function () {
|
||||
return github(null, owner, repo).then(function (all) {
|
||||
module.exports = function (request) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
return all;
|
||||
});
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
all.releases = all.releases.slice(0, 10);
|
||||
//console.info(JSON.stringify(all));
|
||||
|
||||
@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
|
||||
var owner = 'cli';
|
||||
var repo = 'cli';
|
||||
|
||||
module.exports = function () {
|
||||
return github(null, owner, repo).then(function (all) {
|
||||
module.exports = function (request) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
return all;
|
||||
});
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
// just select the first 5 for demonstration
|
||||
all.releases = all.releases.slice(0, 5);
|
||||
|
||||
@@ -21,10 +21,9 @@ is a good place to get started if you're new to git.
|
||||
- Files
|
||||
- Commit Files
|
||||
- Ignore Files
|
||||
- Reasonable Defaults
|
||||
- Create Branch
|
||||
- Rebase by Default
|
||||
- Rebase
|
||||
- Auth via SSH
|
||||
- Auth via Token
|
||||
|
||||
### Files
|
||||
@@ -67,49 +66,9 @@ This will branch from the branch you're currently on.
|
||||
git switch -c my-branch-name
|
||||
```
|
||||
|
||||
### Reasonable Defaults for Git Config
|
||||
|
||||
- use SSH instead of HTTPS
|
||||
- default to 'main'
|
||||
- create on 'push'
|
||||
- stash on 'rebase'
|
||||
- default to 'rebase' (modern)
|
||||
### How to rebase by default
|
||||
|
||||
```sh
|
||||
#####################
|
||||
# ENFORCE SSH #
|
||||
#####################
|
||||
# replace HTTPS urls with SSH urls (to always use keys rather than tokens)
|
||||
|
||||
git config --global url."ssh://git@example.com/".insteadOf "https://example.com/"
|
||||
git config --global url."ssh://git@github.com/".insteadOf "https://github.com/"
|
||||
|
||||
######################
|
||||
# DEFAULT BRANCH #
|
||||
######################
|
||||
# Set the default branch for new repos (ex: 'main')
|
||||
|
||||
git config --global init.defaultBranch 'main'
|
||||
|
||||
######################
|
||||
# AUTOMATIC BRANCHES #
|
||||
######################
|
||||
# make 'git push' create branches if they don't exist on the remote
|
||||
|
||||
git config --global push.autoSetupRemote true
|
||||
|
||||
######################
|
||||
# REBASE AUTO-STASH #
|
||||
######################
|
||||
# stash immediately before rebase and unstash immediately after
|
||||
|
||||
git config --global rebase.autoStash true
|
||||
|
||||
######################
|
||||
# REBASE BY DEFAULT #
|
||||
######################
|
||||
# use 'rebase' rather than 'merge' or 'ff-only'
|
||||
|
||||
git config --global pull.rebase true
|
||||
```
|
||||
|
||||
@@ -143,26 +102,6 @@ git add ./my-merged-file
|
||||
git rebase --continue
|
||||
```
|
||||
|
||||
### How to authenticate git with SSH keys by default
|
||||
|
||||
```sh
|
||||
# Git, Gitea, etc
|
||||
git config --global url."ssh://git@git.example.com/".insteadOf "https://git.example.com/"
|
||||
git config --global url."ssh://git@git.example.com.com/".insteadOf "git@git.example.com.com:"
|
||||
|
||||
# GitHub
|
||||
git config --global url."ssh://git@github.com/".insteadOf "https://github.com/"
|
||||
git config --global url."ssh://git@github.com/".insteadOf "git@github.com:"
|
||||
|
||||
# GitLab
|
||||
git config --global url."ssh://git@gitlab.com/".insteadOf "https://gitlab.com/"
|
||||
git config --global url."ssh://git@gitlab.com/".insteadOf "git@gitlab.com:"
|
||||
|
||||
# BitBucket
|
||||
git config --global url."ssh://git@bitbucket.com/".insteadOf "https://bitbucket.com/"
|
||||
git config --global url."ssh://git@bitbucket.com/".insteadOf "git@bitbucket.com:"
|
||||
```
|
||||
|
||||
### How to authenticate git with deploy tokens
|
||||
|
||||
Abbreviated from
|
||||
|
||||
@@ -4,9 +4,9 @@ var github = require('../_common/github.js');
|
||||
var owner = 'git-for-windows';
|
||||
var repo = 'git';
|
||||
|
||||
module.exports = function () {
|
||||
module.exports = function (request) {
|
||||
// TODO support mac and linux tarballs
|
||||
return github(null, owner, repo).then(function (all) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
// See https://github.com/git-for-windows/git/wiki/MinGit
|
||||
// also consider https://github.com/git-for-windows/git/wiki/Silent-or-Unattended-Installation
|
||||
all.releases = all.releases
|
||||
@@ -26,7 +26,7 @@ module.exports = function () {
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
console.info(JSON.stringify(all, null, 2));
|
||||
});
|
||||
|
||||
@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
|
||||
var owner = 'therootcompany';
|
||||
var repo = 'gitdeploy';
|
||||
|
||||
module.exports = function () {
|
||||
return github(null, owner, repo).then(function (all) {
|
||||
module.exports = function (request) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
return all;
|
||||
});
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
console.info(JSON.stringify(all));
|
||||
});
|
||||
|
||||
@@ -6,8 +6,8 @@ var repo = 'gitea';
|
||||
|
||||
var ODDITIES = ['-gogit-', '-docs-'];
|
||||
|
||||
module.exports = function () {
|
||||
return github(null, owner, repo).then(function (all) {
|
||||
module.exports = function (request) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
// remove checksums and .deb
|
||||
all.releases = all.releases.filter(function (rel) {
|
||||
for (let oddity of ODDITIES) {
|
||||
@@ -27,7 +27,7 @@ module.exports = function () {
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
console.info(JSON.stringify(all));
|
||||
});
|
||||
|
||||
@@ -17,6 +17,7 @@ including:
|
||||
|
||||
- [godoc](https://pkg.go.dev/golang.org/x/tools/cmd/godoc)
|
||||
- [gopls](https://pkg.go.dev/golang.org/x/tools/gopls)
|
||||
- [guru](https://pkg.go.dev/golang.org/x/tools/cmd/guru)
|
||||
- [golint](https://pkg.go.dev/golang.org/x/lint/golint)
|
||||
- [goimports](https://pkg.go.dev/golang.org/x/tools/cmd/goimports)
|
||||
- [gomvpkg](https://pkg.go.dev/golang.org/x/tools/cmd/gomvpkg)
|
||||
|
||||
@@ -16,6 +16,10 @@ Write-Output ""
|
||||
Write-Output gopls
|
||||
& go install golang.org/x/tools/gopls@latest
|
||||
|
||||
Write-Output ""
|
||||
Write-Output guru
|
||||
& go install golang.org/x/tools/guru@latest
|
||||
|
||||
Write-Output ""
|
||||
Write-Output golint
|
||||
& go install golang.org/x/lint/golint@latest
|
||||
|
||||
@@ -3,7 +3,7 @@ set -e
|
||||
set -u
|
||||
|
||||
__run_go_essentials() {
|
||||
if ! command -v go > /dev/null; then
|
||||
if ! command -v go 2> /dev/null; then
|
||||
"$HOME/.local/bin/webi" "go@${WEBI_TAG}"
|
||||
fi
|
||||
|
||||
@@ -44,6 +44,10 @@ __run_go_essentials() {
|
||||
echo gopls
|
||||
go "${my_install}" golang.org/x/tools/gopls@latest > /dev/null #2>/dev/null
|
||||
|
||||
echo ""
|
||||
echo guru
|
||||
go "${my_install}" golang.org/x/tools/cmd/guru@latest > /dev/null #2>/dev/null
|
||||
|
||||
echo ""
|
||||
echo golint
|
||||
go "${my_install}" golang.org/x/lint/golint@latest > /dev/null #2>/dev/null
|
||||
|
||||
@@ -80,7 +80,8 @@ webi serviceman
|
||||
pushd ./hello/
|
||||
|
||||
# swap 'hello' and './hello' for the name of your project and binary
|
||||
serviceman add --name 'hello' -- \
|
||||
sudo env PATH="$PATH" \
|
||||
serviceman add --system --username "$(whoami)" --name hello -- \
|
||||
./hello
|
||||
|
||||
# Restart the logging service
|
||||
|
||||
129
go/releases.js
129
go/releases.js
@@ -1,21 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
let Fetcher = require('../_common/fetcher.js');
|
||||
|
||||
/** @type {Object.<String, String>} */
|
||||
let osMap = {
|
||||
var osMap = {
|
||||
darwin: 'macos',
|
||||
};
|
||||
/** @type {Object.<String, String>} */
|
||||
let archMap = {
|
||||
var archMap = {
|
||||
386: 'x86',
|
||||
};
|
||||
|
||||
let ODDITIES = ['bootstrap', '-arm6.'];
|
||||
|
||||
/**
|
||||
* @param {String} filename
|
||||
*/
|
||||
function isOdd(filename) {
|
||||
for (let oddity of ODDITIES) {
|
||||
let isOddity = filename.includes(oddity);
|
||||
@@ -25,22 +18,7 @@ function isOdd(filename) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef BuildInfo
|
||||
* @prop {String} version
|
||||
* @prop {String} [_version]
|
||||
* @prop {String} arch
|
||||
* @prop {String} channel
|
||||
* @prop {String} date
|
||||
* @prop {String} download
|
||||
* @prop {String} ext
|
||||
* @prop {String} [_filename]
|
||||
* @prop {String} hash
|
||||
* @prop {Boolean} lts
|
||||
* @prop {String} os
|
||||
*/
|
||||
|
||||
async function getDistributables() {
|
||||
function getAllReleases(request) {
|
||||
/*
|
||||
{
|
||||
version: 'go1.13.8',
|
||||
@@ -59,71 +37,60 @@ async function getDistributables() {
|
||||
]
|
||||
};
|
||||
*/
|
||||
return request({
|
||||
url: 'https://golang.org/dl/?mode=json&include=all',
|
||||
json: true,
|
||||
}).then((resp) => {
|
||||
var goReleases = resp.body;
|
||||
var all = {
|
||||
releases: [],
|
||||
download: 'https://dl.google.com/go/{{ download }}',
|
||||
};
|
||||
|
||||
let resp;
|
||||
try {
|
||||
let url = 'https://golang.org/dl/?mode=json&include=all';
|
||||
resp = await Fetcher.fetch(url, {
|
||||
headers: { Accept: 'application/json' },
|
||||
});
|
||||
} catch (e) {
|
||||
/** @type {Error & { code: string, response: { status: number, body: string } }} */ //@ts-expect-error
|
||||
let err = e;
|
||||
if (err.code === 'E_FETCH_RELEASES') {
|
||||
err.message = `failed to fetch 'Go' release data: ${err.response.status} ${err.response.body}`;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
let goReleases = JSON.parse(resp.body);
|
||||
|
||||
let all = {
|
||||
/** @type {Array<BuildInfo>} */
|
||||
releases: [],
|
||||
download: '',
|
||||
};
|
||||
|
||||
for (let release of goReleases) {
|
||||
// Strip 'go' prefix, standardize version
|
||||
let parts = release.version.slice(2).split('.');
|
||||
while (parts.length < 3) {
|
||||
parts.push('0');
|
||||
}
|
||||
let version = parts.join('.');
|
||||
let fileversion = release.version.slice(2);
|
||||
|
||||
for (let asset of release.files) {
|
||||
if (isOdd(asset.filename)) {
|
||||
continue;
|
||||
goReleases.forEach((release) => {
|
||||
// strip 'go' prefix, standardize version
|
||||
var parts = release.version.slice(2).split('.');
|
||||
while (parts.length < 3) {
|
||||
parts.push('0');
|
||||
}
|
||||
var version = parts.join('.');
|
||||
// nix 'go' prefix
|
||||
var fileversion = release.version.slice(2);
|
||||
|
||||
let filename = asset.filename;
|
||||
let os = osMap[asset.os] || asset.os || '-';
|
||||
let arch = archMap[asset.arch] || asset.arch || '-';
|
||||
let build = {
|
||||
version: version,
|
||||
_version: fileversion,
|
||||
lts: (parts[0] > 0 && release.stable) || false,
|
||||
channel: (release.stable && 'stable') || 'beta',
|
||||
date: '1970-01-01', // the world may never know
|
||||
os: os,
|
||||
arch: arch,
|
||||
ext: '', // let normalize run the split/test/join
|
||||
hash: '-', // not ready to standardize this yet
|
||||
download: `https://dl.google.com/go/${filename}`,
|
||||
};
|
||||
all.releases.push(build);
|
||||
}
|
||||
}
|
||||
release.files.forEach((asset) => {
|
||||
let odd = isOdd(asset.filename);
|
||||
if (odd) {
|
||||
return;
|
||||
}
|
||||
|
||||
return all;
|
||||
var filename = asset.filename;
|
||||
var os = osMap[asset.os] || asset.os || '-';
|
||||
var arch = archMap[asset.arch] || asset.arch || '-';
|
||||
all.releases.push({
|
||||
version: version,
|
||||
_version: fileversion,
|
||||
// all go versions >= 1.0.0 are effectively LTS
|
||||
lts: (parts[0] > 0 && release.stable) || false,
|
||||
channel: (release.stable && 'stable') || 'beta',
|
||||
date: '1970-01-01', // the world may never know
|
||||
os: os,
|
||||
arch: arch,
|
||||
ext: '', // let normalize run the split/test/join
|
||||
hash: '-', // not ready to standardize this yet
|
||||
download: filename,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
return all;
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = getDistributables;
|
||||
module.exports = getAllReleases;
|
||||
|
||||
if (module === require.main) {
|
||||
getDistributables().then(function (all) {
|
||||
getAllReleases(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
//@ts-expect-error
|
||||
all.releases = all.releases.slice(0, 10);
|
||||
console.info(JSON.stringify(all, null, 2));
|
||||
});
|
||||
|
||||
@@ -85,7 +85,8 @@ webi serviceman
|
||||
pushd ./hello/
|
||||
|
||||
# swap 'hello' and './hello' for the name of your project and binary
|
||||
serviceman add --name 'hello' -- \
|
||||
sudo env PATH="$PATH" \
|
||||
serviceman add --system --username "$(whoami)" --name hello -- \
|
||||
./hello
|
||||
|
||||
# Restart the logging service
|
||||
|
||||
@@ -4,15 +4,15 @@ var github = require('../_common/github.js');
|
||||
var owner = 'goreleaser';
|
||||
var repo = 'goreleaser';
|
||||
|
||||
module.exports = function () {
|
||||
return github(null, owner, repo).then(function (all) {
|
||||
module.exports = function (request) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
all._names = ['goreleaser', '1'];
|
||||
return all;
|
||||
});
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
// just select the first 5 for demonstration
|
||||
all.releases = all.releases.slice(0, 5);
|
||||
|
||||
114
gpg/releases.js
114
gpg/releases.js
@@ -1,7 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
let Fetcher = require('../_common/fetcher.js');
|
||||
|
||||
let ltsRe = /GnuPG-(2\.2\.[\d\.]+)/;
|
||||
|
||||
function createRssMatcher() {
|
||||
@@ -18,42 +16,12 @@ function createUrlMatcher() {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef BuildInfo
|
||||
* @prop {String} version
|
||||
* @prop {String} [_version]
|
||||
* @prop {String} arch
|
||||
* @prop {String} channel
|
||||
* @prop {String} date
|
||||
* @prop {String} download
|
||||
* @prop {String} ext
|
||||
* @prop {String} [_filename]
|
||||
* @prop {String} hash
|
||||
* @prop {Boolean} lts
|
||||
* @prop {String} os
|
||||
*/
|
||||
|
||||
async function getRawReleases() {
|
||||
let resp;
|
||||
try {
|
||||
let url = 'https://sourceforge.net/projects/gpgosx/rss?path=/';
|
||||
resp = await Fetcher.fetch(url, {
|
||||
headers: { Accept: 'application/rss+xml' },
|
||||
});
|
||||
} catch (e) {
|
||||
/** @type {Error & { code: string, response: { status: number, body: string } }} */ //@ts-expect-error
|
||||
let err = e;
|
||||
if (err.code === 'E_FETCH_RELEASES') {
|
||||
err.message = `failed to fetch 'gpg' release data: ${err.response.status} ${err.response.body}`;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
let contentType = resp.headers.get('Content-Type');
|
||||
if (!contentType?.includes('xml')) {
|
||||
throw new Error(`Unexpected content type: ${contentType}`);
|
||||
}
|
||||
|
||||
async function getRawReleases(request) {
|
||||
let matcher = createRssMatcher();
|
||||
|
||||
let resp = await request({
|
||||
url: 'https://sourceforge.net/projects/gpgosx/rss?path=/',
|
||||
});
|
||||
let links = [];
|
||||
for (;;) {
|
||||
let m = matcher.exec(resp.body);
|
||||
@@ -62,66 +30,62 @@ async function getRawReleases() {
|
||||
}
|
||||
links.push(m[1]);
|
||||
}
|
||||
|
||||
return links;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Array<String>} links
|
||||
*/
|
||||
function transformReleases(links) {
|
||||
//console.log(JSON.stringify(links, null, 2));
|
||||
//console.log(links.length);
|
||||
|
||||
let matcher = createUrlMatcher();
|
||||
|
||||
let builds = [];
|
||||
for (let link of links) {
|
||||
let isLts = ltsRe.test(link);
|
||||
let parts = link.match(matcher);
|
||||
if (!parts || !parts[2]) {
|
||||
continue;
|
||||
}
|
||||
let releases = links
|
||||
.map(function (link) {
|
||||
let isLts = ltsRe.test(link);
|
||||
let parts = link.match(matcher);
|
||||
if (!parts || !parts[2]) {
|
||||
return null;
|
||||
}
|
||||
let segs = parts[2].split('.');
|
||||
let version = segs.slice(0, 3).join('.');
|
||||
if (segs.length > 3) {
|
||||
version += '+' + segs.slice(3);
|
||||
}
|
||||
let fileversion = segs.join('.');
|
||||
|
||||
let segs = parts[2].split('.');
|
||||
let version = segs.slice(0, 3).join('.');
|
||||
if (segs.length > 3) {
|
||||
version += '+' + segs.slice(3);
|
||||
}
|
||||
let fileversion = segs.join('.');
|
||||
|
||||
let build = {
|
||||
name: parts[1],
|
||||
version: version,
|
||||
_version: fileversion,
|
||||
lts: isLts,
|
||||
channel: 'stable',
|
||||
// TODO <pubDate>Sat, 19 Nov 2016 16:17:33 UT</pubDate>
|
||||
date: '1970-01-01', // the world may never know
|
||||
os: 'macos',
|
||||
arch: 'amd64',
|
||||
ext: 'dmg',
|
||||
download: link,
|
||||
};
|
||||
builds.push(build);
|
||||
}
|
||||
return {
|
||||
name: parts[1],
|
||||
version: version,
|
||||
_version: fileversion,
|
||||
// all go versions >= 1.0.0 are effectively LTS
|
||||
lts: isLts,
|
||||
channel: 'stable',
|
||||
// TODO <pubDate>Sat, 19 Nov 2016 16:17:33 UT</pubDate>
|
||||
date: '1970-01-01', // the world may never know
|
||||
os: 'macos',
|
||||
arch: 'amd64',
|
||||
ext: 'dmg',
|
||||
download: link,
|
||||
};
|
||||
})
|
||||
.filter(Boolean);
|
||||
|
||||
return {
|
||||
_names: ['GnuPG', 'gpgosx'],
|
||||
releases: builds,
|
||||
releases: releases,
|
||||
};
|
||||
}
|
||||
|
||||
async function getDistributables() {
|
||||
let releases = await getRawReleases();
|
||||
async function getAllReleases(request) {
|
||||
let releases = await getRawReleases(request);
|
||||
let all = transformReleases(releases);
|
||||
return all;
|
||||
}
|
||||
|
||||
module.exports = getDistributables;
|
||||
module.exports = getAllReleases;
|
||||
|
||||
if (module === require.main) {
|
||||
getDistributables().then(function (all) {
|
||||
getAllReleases(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
all.releases = all.releases.slice(0, 10000);
|
||||
console.info(JSON.stringify(all, null, 2));
|
||||
|
||||
@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
|
||||
var owner = 'creedasaurus';
|
||||
var repo = 'gprox';
|
||||
|
||||
module.exports = function () {
|
||||
return github(null, owner, repo).then(function (all) {
|
||||
module.exports = function (request) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
return all;
|
||||
});
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
// just select the first 5 for demonstration
|
||||
all.releases = all.releases.slice(0, 5);
|
||||
|
||||
@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
|
||||
var owner = 'anchore';
|
||||
var repo = 'grype';
|
||||
|
||||
module.exports = function () {
|
||||
return github(null, owner, repo).then(function (all) {
|
||||
module.exports = function (request) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
return all;
|
||||
});
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
// just select the first 5 for demonstration
|
||||
all.releases = all.releases.slice(0, 5);
|
||||
|
||||
@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
|
||||
var owner = 'sharkdp';
|
||||
var repo = 'hexyl';
|
||||
|
||||
module.exports = function () {
|
||||
return github(null, owner, repo).then(function (all) {
|
||||
module.exports = function (request) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
return all;
|
||||
});
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
all.releases = all.releases.slice(0, 10);
|
||||
//console.info(JSON.stringify(all));
|
||||
|
||||
@@ -4,8 +4,8 @@ var github = require('../_common/github.js');
|
||||
var owner = 'gohugoio';
|
||||
var repo = 'hugo';
|
||||
|
||||
module.exports = async function () {
|
||||
let all = await github(null, owner, repo);
|
||||
module.exports = async function (request) {
|
||||
let all = await github(request, owner, repo);
|
||||
|
||||
all.releases = all.releases.filter(function (rel) {
|
||||
let isExtended = rel.name.includes('_extended_');
|
||||
@@ -25,7 +25,7 @@ module.exports = async function () {
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
console.info(JSON.stringify(all));
|
||||
});
|
||||
|
||||
@@ -4,8 +4,8 @@ var github = require('../_common/github.js');
|
||||
var owner = 'gohugoio';
|
||||
var repo = 'hugo';
|
||||
|
||||
module.exports = async function () {
|
||||
let all = await github(null, owner, repo);
|
||||
module.exports = async function (request) {
|
||||
let all = await github(request, owner, repo);
|
||||
|
||||
all.releases = all.releases.filter(function (rel) {
|
||||
let isExtended = rel.name.includes('_extended_');
|
||||
@@ -25,7 +25,7 @@ module.exports = async function () {
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
console.info(JSON.stringify(all));
|
||||
});
|
||||
|
||||
@@ -1,91 +1,73 @@
|
||||
'use strict';
|
||||
|
||||
let Fetcher = require('../_common/fetcher.js');
|
||||
|
||||
async function getRawReleases() {
|
||||
let resp;
|
||||
try {
|
||||
let url = 'https://iterm2.com/downloads.html';
|
||||
resp = await Fetcher.fetch(url, {
|
||||
headers: { Accept: 'text/html' },
|
||||
});
|
||||
} catch (e) {
|
||||
/** @type {Error & { code: string, response: { status: number, body: string } }} */ //@ts-expect-error
|
||||
let err = e;
|
||||
if (err.code === 'E_FETCH_RELEASES') {
|
||||
err.message = `failed to fetch 'iterm2' release data: ${err.response.status} ${err.response.body}`;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
|
||||
let contentType = resp.headers.get('Content-Type');
|
||||
if (!contentType || !contentType.includes('text/html')) {
|
||||
throw new Error(`Unexpected Content-Type: ${contentType}`);
|
||||
}
|
||||
|
||||
let lines = resp.body.split(/[<>]+/g);
|
||||
|
||||
/** @type {Array<String>} */
|
||||
let links = [];
|
||||
for (let str of lines) {
|
||||
let m = str.match(/href="(https:\/\/iterm2\.com\/downloads\/.*\.zip)"/);
|
||||
if (m && /iTerm2-[34]/.test(m[1])) {
|
||||
if (m[1]) {
|
||||
links.push(m[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return links;
|
||||
function getRawReleases(request) {
|
||||
return request({ url: 'https://iterm2.com/downloads.html' }).then(
|
||||
function (resp) {
|
||||
var links = resp.body
|
||||
.split(/[<>]+/g)
|
||||
.map(function (str) {
|
||||
var m = str.match(
|
||||
/href="(https:\/\/iterm2\.com\/downloads\/.*\.zip)"/,
|
||||
);
|
||||
if (m && /iTerm2-[34]/.test(m[1])) {
|
||||
return m[1];
|
||||
}
|
||||
})
|
||||
.filter(Boolean);
|
||||
return links;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Array<String>} links
|
||||
*/
|
||||
function transformReleases(links) {
|
||||
let builds = [];
|
||||
for (let link of links) {
|
||||
let channel = /\/stable\//.test(link) ? 'stable' : 'beta';
|
||||
|
||||
let parts = link.replace(/.*\/iTerm2[-_]v?(\d_.*)\.zip/, '$1').split('_');
|
||||
let version = parts.join('.').replace(/([_-])?beta/, '-beta');
|
||||
|
||||
// ex: 3.5.0-beta17 => 3_5_0beta17
|
||||
// ex: 3.0.2-preview => 3_0_2-preview
|
||||
let fileversion = version.replace(/\./g, '_');
|
||||
fileversion = fileversion.replace(/-beta/g, 'beta');
|
||||
|
||||
let build = {
|
||||
version: version,
|
||||
_version: fileversion,
|
||||
lts: 'stable' === channel,
|
||||
channel: channel,
|
||||
date: '1970-01-01', // the world may never know
|
||||
os: 'macos',
|
||||
arch: 'amd64',
|
||||
ext: '', // let normalize run the split/test/join
|
||||
download: link,
|
||||
};
|
||||
builds.push(build);
|
||||
}
|
||||
//console.log(JSON.stringify(links, null, 2));
|
||||
//console.log(links.length);
|
||||
|
||||
return {
|
||||
_names: ['iTerm2', 'iterm2'],
|
||||
releases: builds,
|
||||
releases: links
|
||||
.map(function (link) {
|
||||
var channel = /\/stable\//.test(link) ? 'stable' : 'beta';
|
||||
|
||||
var parts = link
|
||||
.replace(/.*\/iTerm2[-_]v?(\d_.*)\.zip/, '$1')
|
||||
.split('_');
|
||||
var version = parts.join('.').replace(/([_-])?beta/, '-beta');
|
||||
|
||||
// ex: 3.5.0-beta17 => 3_5_0beta17
|
||||
// ex: 3.0.2-preview => 3_0_2-preview
|
||||
let fileversion = version.replace(/\./g, '_');
|
||||
fileversion = fileversion.replace(/-beta/g, 'beta');
|
||||
|
||||
return {
|
||||
version: version,
|
||||
_version: fileversion,
|
||||
// all go versions >= 1.0.0 are effectively LTS
|
||||
lts: 'stable' === channel,
|
||||
channel: channel,
|
||||
date: '1970-01-01', // the world may never know
|
||||
os: 'macos',
|
||||
arch: 'amd64',
|
||||
ext: '', // let normalize run the split/test/join
|
||||
download: link,
|
||||
};
|
||||
})
|
||||
.filter(Boolean),
|
||||
};
|
||||
}
|
||||
|
||||
async function getDistributables() {
|
||||
let rawReleases = await getRawReleases();
|
||||
let all = transformReleases(rawReleases);
|
||||
|
||||
return all;
|
||||
function getAllReleases(request) {
|
||||
return getRawReleases(request)
|
||||
.then(transformReleases)
|
||||
.then(function (all) {
|
||||
return all;
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = getDistributables;
|
||||
module.exports = getAllReleases;
|
||||
|
||||
if (module === require.main) {
|
||||
getDistributables().then(function (all) {
|
||||
getAllReleases(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
all.releases = all.releases.slice(0, 10000);
|
||||
console.info(JSON.stringify(all, null, 2));
|
||||
|
||||
@@ -15,8 +15,8 @@ function isOdd(build) {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = function () {
|
||||
return github(null, owner, repo).then(function (all) {
|
||||
module.exports = function (request) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
let builds = [];
|
||||
|
||||
for (let build of all.releases) {
|
||||
@@ -35,7 +35,7 @@ module.exports = function () {
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
console.info(JSON.stringify(all));
|
||||
//console.info(JSON.stringify(all, null, 2));
|
||||
|
||||
114
jsconfig.json
114
jsconfig.json
@@ -1,114 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
/* Visit https://aka.ms/tsconfig to read more about this file */
|
||||
|
||||
/* Projects */
|
||||
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
||||
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
||||
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
||||
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
||||
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
||||
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
||||
|
||||
/* Language and Environment */
|
||||
"target": "es2022", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
||||
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
||||
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
||||
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
|
||||
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
||||
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
||||
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
||||
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
||||
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
||||
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
||||
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
||||
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
||||
|
||||
/* Modules */
|
||||
"module": "commonjs", /* Specify what module code is generated. */
|
||||
// "rootDir": "./", /* Specify the root folder within your source files. */
|
||||
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
|
||||
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
||||
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
||||
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
||||
"typeRoots": ["./typings","./node_modules/@types"], /* Specify multiple folders that act like './node_modules/@types'. */
|
||||
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
||||
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
||||
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
||||
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
|
||||
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
|
||||
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
|
||||
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
|
||||
// "resolveJsonModule": true, /* Enable importing .json files. */
|
||||
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
|
||||
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
||||
|
||||
/* JavaScript Support */
|
||||
"allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
||||
"checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
||||
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
||||
|
||||
/* Emit */
|
||||
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
||||
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
||||
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
||||
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
||||
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
||||
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
||||
// "outDir": "./", /* Specify an output folder for all emitted files. */
|
||||
// "removeComments": true, /* Disable emitting comments. */
|
||||
"noEmit": true, /* Disable emitting files from a compilation. */
|
||||
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
||||
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
|
||||
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
||||
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
||||
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
||||
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
||||
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
||||
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
||||
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
||||
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
||||
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
||||
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
||||
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
||||
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
|
||||
|
||||
/* Interop Constraints */
|
||||
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
||||
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
|
||||
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
||||
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
||||
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
||||
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
||||
|
||||
/* Type Checking */
|
||||
"strict": true, /* Enable all strict type-checking options. */
|
||||
"noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
||||
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
||||
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
||||
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
||||
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
||||
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
||||
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
||||
"alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
||||
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
||||
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
||||
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
||||
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
||||
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
||||
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
||||
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
||||
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
||||
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
||||
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
||||
|
||||
/* Completeness */
|
||||
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
||||
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
||||
},
|
||||
"include": [
|
||||
"*.js",
|
||||
"*/*.js"
|
||||
],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
128
julia/README.md
128
julia/README.md
@@ -1,128 +0,0 @@
|
||||
---
|
||||
title: Julia
|
||||
homepage: https://julialang.org/
|
||||
tagline: |
|
||||
Julia: A Language for Data Science, Visualization, and Machine Learning
|
||||
---
|
||||
|
||||
To update or switch versions, run `webi julia@stable` (or `@v1.10`, `@beta`,
|
||||
etc).
|
||||
|
||||
## Cheat Sheet
|
||||
|
||||
> Julia is a programming language for Data Science - a far better alternative to
|
||||
> (or plugin for) Python when performance matters.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- Files
|
||||
- Hello World
|
||||
- Compile for Distribution
|
||||
- Vim Plugin
|
||||
|
||||
### Files
|
||||
|
||||
These are the files / directories that are created and/or modified with this
|
||||
install:
|
||||
|
||||
```text
|
||||
~/.config/envman/PATH.env
|
||||
~/.local/opt/julia/
|
||||
```
|
||||
|
||||
### How to create a Hello World with Julia
|
||||
|
||||
Try out the REPL by coping and pasting the code below (it'll print some nice
|
||||
ASCII art to the console):
|
||||
|
||||
```sh
|
||||
julia -i
|
||||
```
|
||||
|
||||
```julia
|
||||
function mandelbrot(a)
|
||||
z = 0
|
||||
for i=1:50
|
||||
z = z^2 + a
|
||||
end
|
||||
return z
|
||||
end
|
||||
|
||||
for y=1.0:-0.05:-1.0
|
||||
for x=-2.0:0.0315:0.5
|
||||
abs(mandelbrot(complex(x, y))) < 2 ? print("*") : print(" ")
|
||||
end
|
||||
println()
|
||||
end
|
||||
```
|
||||
|
||||
Or write the program to `./mandelbrot.jl` and run it:
|
||||
|
||||
```sh
|
||||
julia ./mandelbrot.jl
|
||||
```
|
||||
|
||||
## How to Build a Distributable Binary with Julia
|
||||
|
||||
Here's an example project that you can build:
|
||||
|
||||
1. Clone and enter the example project
|
||||
```sh
|
||||
git clone --depth=1 https://github.com/JuliaLang/PackageCompiler.jl ./PackageCompiler
|
||||
pushd ./PackageCompiler/examples
|
||||
```
|
||||
2. Run Julia in project mode
|
||||
```sh
|
||||
julia -q --project
|
||||
```
|
||||
3. Compile the binary
|
||||
```julia
|
||||
using PackageCompiler
|
||||
create_app("MyApp", "MyAppCompiled")
|
||||
exit()
|
||||
```
|
||||
4. Test & Enjoy
|
||||
```sh
|
||||
./MyAppCompiled/bin/MyApp foo bar --julia-args -t4
|
||||
```
|
||||
|
||||
See also:
|
||||
|
||||
- <https://docs.juliahub.com/PackageCompiler/MMV8C/2.1.16/apps.html>
|
||||
- <https://github.com/JuliaLang/PackageCompiler.jl/tree/master/examples/MyApp>
|
||||
|
||||
## How to Install the Language Server (for VSCode, Vim, etc)
|
||||
|
||||
Open the Julia REPL and add `LanguageServer`:
|
||||
|
||||
```sh
|
||||
julia -i
|
||||
```
|
||||
|
||||
```jl
|
||||
using Pkg
|
||||
Pkg.add("LanguageServer")
|
||||
Pkg.add("SymbolServer")
|
||||
```
|
||||
|
||||
You'll need to reinstall if you switch environments.
|
||||
|
||||
## How to Install the Julia Vim Plugin
|
||||
|
||||
`julia-vim` adds support for:
|
||||
|
||||
- Latex-to-Unicode
|
||||
- jumping from between start and end of blocks with `%` \
|
||||
(and other block jump sequences)
|
||||
|
||||
```sh
|
||||
mkdir -p ~/.vim/pack/plugins/start
|
||||
git clone https://github.com/JuliaEditorSupport/julia-vim.git \
|
||||
~/.vim/pack/plugins/start/julia-vim
|
||||
```
|
||||
|
||||
Usage Examples:
|
||||
|
||||
- `\alpha<tab>` will produce `α` \
|
||||
(meaning typing `\alpha` and hitting the `tab` key)
|
||||
- Hitting `%` on an `end` will take you to the `function` or `for`, etc
|
||||
@@ -1,56 +0,0 @@
|
||||
#!/usr/bin/env pwsh
|
||||
|
||||
#################
|
||||
# Install julia #
|
||||
#################
|
||||
|
||||
# Every package should define these variables
|
||||
$pkg_cmd_name = "julia"
|
||||
|
||||
$pkg_dst_cmd = "$Env:USERPROFILE\.local\opt\julia\bin\julia.exe"
|
||||
$pkg_dst_bin = "$Env:USERPROFILE\.local\opt\julia\bin"
|
||||
$pkg_dst_dir = "$Env:USERPROFILE\.local\opt\julia"
|
||||
$pkg_dst = "$pkg_dst_dir"
|
||||
|
||||
$pkg_src_cmd = "$Env:USERPROFILE\.local\opt\julia-v$Env:WEBI_VERSION\bin\julia.exe"
|
||||
$pkg_src_dir = "$Env:USERPROFILE\.local\opt\julia-v$Env:WEBI_VERSION"
|
||||
$pkg_src = "$pkg_src_dir"
|
||||
|
||||
New-Item "$Env:USERPROFILE\Downloads\webi" -ItemType Directory -Force | Out-Null
|
||||
$pkg_download = "$Env:USERPROFILE\Downloads\webi\$Env:WEBI_PKG_FILE"
|
||||
|
||||
# Fetch archive
|
||||
IF (!(Test-Path -Path "$pkg_download")) {
|
||||
Write-Output "Downloading julia 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_dir")) {
|
||||
Write-Output "Installing julia"
|
||||
|
||||
# TODO: create package-specific temp directory
|
||||
# Enter tmp
|
||||
Push-Location .local\tmp
|
||||
|
||||
# Remove any leftover tmp cruft
|
||||
Remove-Item -Path ".\julia*" -Recurse -ErrorAction Ignore
|
||||
|
||||
# Unpack archive file into this temporary directory
|
||||
# Windows BSD-tar handles zip. Imagine that.
|
||||
Write-Output "Unpacking $pkg_download"
|
||||
& tar xf "$pkg_download"
|
||||
|
||||
# Settle unpacked archive into place
|
||||
Write-Output "Install Location: $pkg_src_cmd"
|
||||
Move-Item -Path ".\julia*" -Destination "$pkg_src_dir"
|
||||
|
||||
# Exit tmp
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
Write-Output "Copying into '$pkg_dst' from '$pkg_src'"
|
||||
Remove-Item -Path "$pkg_dst" -Recurse -ErrorAction Ignore | Out-Null
|
||||
Copy-Item -Path "$pkg_src" -Destination "$pkg_dst" -Recurse
|
||||
webi_path_add "$pkg_dst_bin"
|
||||
& "$pkg_dst_cmd" --version
|
||||
@@ -1,47 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# shellcheck disable=SC2034
|
||||
# "'pkg_cmd_name' appears unused. Verify it or export it."
|
||||
|
||||
__init_julia() {
|
||||
set -e
|
||||
set -u
|
||||
|
||||
##################
|
||||
# Install julia #
|
||||
##################
|
||||
|
||||
# Every package should define these 6 variables
|
||||
pkg_cmd_name="julia"
|
||||
|
||||
pkg_dst_cmd="$HOME/.local/opt/julia/bin/julia"
|
||||
pkg_dst_dir="$HOME/.local/opt/julia"
|
||||
pkg_dst="$pkg_dst_dir"
|
||||
|
||||
pkg_src_cmd="$HOME/.local/opt/julia-v$WEBI_VERSION/bin/julia"
|
||||
pkg_src_dir="$HOME/.local/opt/julia-v$WEBI_VERSION"
|
||||
pkg_src="$pkg_src_dir"
|
||||
|
||||
# pkg_install must be defined by every package
|
||||
pkg_install() {
|
||||
# ~/.local/opt/julia-v3.27.0/
|
||||
mkdir -p "$(dirname "${pkg_src_dir}")"
|
||||
|
||||
# mv ./julia-*/ ~/.local/opt/julia-v3.27.0/
|
||||
mv ./julia-*/ "${pkg_src_dir}"
|
||||
}
|
||||
|
||||
# pkg_get_current_version is recommended, but not required
|
||||
pkg_get_current_version() {
|
||||
# 'julia --version' has output in this format:
|
||||
# julia version 1.10.0-rc1
|
||||
# This trims it down to just the version number:
|
||||
# 1.10.0-rc1
|
||||
julia --version 2> /dev/null |
|
||||
head -n 1 |
|
||||
cut -d ' ' -f 3
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
__init_julia
|
||||
@@ -1,181 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
let Fetcher = require('../_common/fetcher.js');
|
||||
|
||||
/** @type {Object.<String, String>} */
|
||||
let osMap = {
|
||||
winnt: 'windows',
|
||||
mac: 'darwin',
|
||||
};
|
||||
|
||||
/** @type {Object.<String, String>} */
|
||||
let archMap = {
|
||||
armv7l: 'armv7',
|
||||
i686: 'x86',
|
||||
powerpc64le: 'ppc64le',
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef BuildInfo
|
||||
* @prop {String} version
|
||||
* @prop {String} [_version]
|
||||
* @prop {String} [arch]
|
||||
* @prop {String} channel
|
||||
* @prop {String} date
|
||||
* @prop {String} download
|
||||
* @prop {String} [ext]
|
||||
* @prop {String} [_filename]
|
||||
* @prop {String} [hash]
|
||||
* @prop {String} [libc]
|
||||
* @prop {Boolean} [_musl]
|
||||
* @prop {Boolean} [lts]
|
||||
* @prop {String} [size]
|
||||
* @prop {String} os
|
||||
*/
|
||||
|
||||
async function getDistributables() {
|
||||
let all = {
|
||||
/** @type {Array<BuildInfo>} */
|
||||
releases: [],
|
||||
download: '',
|
||||
_names: ['julia', 'macaarch64'],
|
||||
};
|
||||
|
||||
let resp;
|
||||
try {
|
||||
let url = 'https://julialang-s3.julialang.org/bin/versions.json';
|
||||
resp = await Fetcher.fetch(url, {
|
||||
headers: { Accept: 'application/json' },
|
||||
});
|
||||
} catch (e) {
|
||||
/** @type {Error & { code: string, response: { status: number, body: string } }} */ //@ts-expect-error
|
||||
let err = e;
|
||||
if (err.code === 'E_FETCH_RELEASES') {
|
||||
err.message = `failed to fetch 'julia' release data: ${err.response.status} ${err.response.body}`;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
let buildsByVersion = JSON.parse(resp.body);
|
||||
|
||||
/*
|
||||
{
|
||||
"url": "https://julialang-s3.julialang.org/bin/mac/aarch64/1.9/julia-1.9.4-macaarch64.tar.gz",
|
||||
"triplet": "aarch64-apple-darwin14",
|
||||
"kind": "archive",
|
||||
"arch": "aarch64",
|
||||
"asc": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEENnPfUp2QSUd/drN1ZuPH3APW5JUFAmVTQBcACgkQZuPH3APW\n5JWUqw//QF/CJLAxXZdcXqpBulLUs/AX+x/8aERGcKxZqfeYOwA5efOzma8sASa/\nUzYCLp9E31x/RMDoZah6vPRRjBR+uVI6CLlXCCCmbAJP3lD2vlcY9LKe2/7s3Ba8\nhwITRaL6R5zNr+YfSHW1Hoj2tWgAQh9Y+Te7bP3jzwp5dlFygFO0pzoN+aeJbPNA\nbgT0ry8tgh78/tgNjgt4Ev3E2t3ehhrDGK4tgkkKieO6sdFz8jOacZVZkR1kLVEg\nMBIqmqZfk+5/HMf/6gHwd5GOXW8+GakN7vYXO+9VFETA2EiD5Z5k4Edq/VrNCn4O\npC6WHpBmVBBYX4aQtHkJyQaV8PtFd1j9338jUWlDaa6BVtX2hjRtU1k1oLZB1TTX\nl4awzYgFqdCRnFmOtzTdMDBcfedOiIHdTyxXPjJCX3i0GXmeuk89e5dE4P6sTT9n\n24GeBVQgMaXuNorg9L0oKrsQ8RDT20yEnVbfhy4Cvoq7dNIks6IxLZt10tjJFp1j\n0oJ5f6KucGyqFM9UhXRcuLj8Z+Q+JDzBs5c2pPe/bEzv6nChRNv252e5dve17esg\nK7tHkhXzM+6wl60oyRtpWghOubXyBDsNu1MH3qC9lWy3wmWuMN7no+yX0vGFyhMT\naxjLJSeYdccKD3SuzYotp3XwBKk05PFX9lWy0vuIjVj1sGWcES8=\n=G1tO\n-----END PGP SIGNATURE-----\n",
|
||||
"sha256": "67542975e86102eec95bc4bb7c30c5d8c7ea9f9a0b388f0e10f546945363b01a",
|
||||
"size": 119559478,
|
||||
"version": "1.9.4",
|
||||
"os": "mac",
|
||||
"extension": "tar.gz"
|
||||
}
|
||||
*/
|
||||
|
||||
let versions = Object.keys(buildsByVersion);
|
||||
for (let version of versions) {
|
||||
let release = buildsByVersion[version];
|
||||
|
||||
// let odd = isOdd(asset.filename);
|
||||
// if (odd) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
for (let build of release.files) {
|
||||
// // For debugging
|
||||
// let paths = build.url.split('/');
|
||||
// let extlen = build.extension.length + 1;
|
||||
// let name = paths.at(-1);
|
||||
// name = name.replace(`-${build.version}`, '');
|
||||
// name = name.slice('julia-'.length);
|
||||
// name = name.slice(0, -extlen);
|
||||
// console.log(`name: ${name}`);
|
||||
|
||||
// console.log(`triplet: ${build.triplet}`);
|
||||
// console.log(`arch: ${build.arch}`);
|
||||
// console.log(`os: ${build.os}`);
|
||||
// console.log(`kind: ${build.kind}`);
|
||||
// console.log(`extension: ${build.extension}`);
|
||||
// console.log(`version: ${build.version}`);
|
||||
|
||||
if (build.kind === 'installer') {
|
||||
continue;
|
||||
}
|
||||
|
||||
let arch = archMap[build.arch] || build.arch || '-';
|
||||
let os = osMap[build.os] || build.os || '-';
|
||||
let libc = '';
|
||||
let hardMusl = /\b(musl)\b/.test(build.url);
|
||||
if (hardMusl) {
|
||||
libc = 'musl';
|
||||
} else if (os === 'linux') {
|
||||
libc = 'gnu';
|
||||
}
|
||||
|
||||
let webiBuild = {
|
||||
version: build.version,
|
||||
_version: build.version,
|
||||
lts: false,
|
||||
channel: '', // autodetect by filename (-beta1, -alpha1, -rc1)
|
||||
date: '1970-01-01', // the world may never know
|
||||
os: os,
|
||||
arch: arch,
|
||||
libc: libc,
|
||||
_musl: hardMusl,
|
||||
ext: '', // let normalize run the split/test/join
|
||||
hash: '-', // build.sha256 not ready to standardize this yet
|
||||
download: build.url,
|
||||
};
|
||||
all.releases.push(webiBuild);
|
||||
}
|
||||
}
|
||||
|
||||
all.releases.sort(sortByVersion);
|
||||
|
||||
return all;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Object} a
|
||||
* @param {String} a.version
|
||||
* @param {Object} b
|
||||
* @param {String} b.version
|
||||
*/
|
||||
function sortByVersion(a, b) {
|
||||
let [aVer, aPre] = a.version.split('-');
|
||||
let [bVer, bPre] = b.version.split('-');
|
||||
|
||||
let aVers = aVer.split('.');
|
||||
let bVers = bVer.split('.');
|
||||
for (let i = 0; i < 3; i += 1) {
|
||||
aVers[i] = aVers[i].padStart(4, '0');
|
||||
bVers[i] = bVers[i].padStart(4, '0');
|
||||
}
|
||||
|
||||
aVer = aVers.join('.');
|
||||
if (aPre) {
|
||||
aVer += `-${aPre}`;
|
||||
}
|
||||
bVer = bVers.join('.');
|
||||
if (bPre) {
|
||||
bVer += `-${aPre}`;
|
||||
}
|
||||
|
||||
if (aVer > bVer) {
|
||||
return -1;
|
||||
}
|
||||
if (aVer < bVer) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
module.exports = getDistributables;
|
||||
|
||||
if (module === require.main) {
|
||||
getDistributables().then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
all.releases = all.releases.slice(0, 10);
|
||||
console.info(JSON.stringify(all, null, 2));
|
||||
});
|
||||
}
|
||||
@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
|
||||
var owner = 'derailed';
|
||||
var repo = 'k9s';
|
||||
|
||||
module.exports = function () {
|
||||
return github(null, owner, repo).then(function (all) {
|
||||
module.exports = function (request) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
return all;
|
||||
});
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
// just select the first 5 for demonstration
|
||||
all.releases = all.releases.slice(0, 5);
|
||||
|
||||
@@ -4,14 +4,14 @@ var github = require('../_common/github.js');
|
||||
var owner = 'therootcompany';
|
||||
var repo = 'keypairs';
|
||||
|
||||
module.exports = function () {
|
||||
return github(null, owner, repo).then(function (all) {
|
||||
module.exports = function (request) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
return all;
|
||||
});
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
console.info(JSON.stringify(all, null, 2));
|
||||
});
|
||||
|
||||
@@ -12,14 +12,14 @@ var repo = 'kind';
|
||||
/** **/
|
||||
/******************************************************************************/
|
||||
|
||||
module.exports = function () {
|
||||
return github(null, owner, repo).then(function (all) {
|
||||
module.exports = function (request) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
return all;
|
||||
});
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports().then(function (all) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
// just select the first 5 for demonstration
|
||||
all.releases = all.releases.slice(0, 5);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: koji
|
||||
homepage: https://github.com/cococonscious/koji
|
||||
homepage: https://github.com/its-danny/koji
|
||||
tagline: |
|
||||
🦊 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].
|
||||
|
||||

|
||||

|
||||
|
||||
[cc]: https://conventionalcommits.org/en/v1.0.0/
|
||||
|
||||
@@ -26,7 +26,7 @@ You can use koji in one of two ways:
|
||||
Here's the shortlist of options we've found most useful:
|
||||
|
||||
```text
|
||||
-e, --emoji - use emoji for commit summary (ex: `feat: ✨ ...`)
|
||||
-e, --emoji - use emoji for commit type (ex: `✨ feat:`)
|
||||
-a, --autocomplete - guess 'scope' based on commit history (slow on large projects)
|
||||
--hook - expect to be run from 'git commit', rather than wrap it
|
||||
```
|
||||
@@ -72,8 +72,8 @@ git commit
|
||||
|
||||
### How to use Emoji
|
||||
|
||||
You can use `-e` (or `--emoji`) to prepend your commit message summary with the
|
||||
relevant emoji for the commit type:
|
||||
You can use `-e` (or `--emoji`) to prepend your commit message with the relevant
|
||||
emoji for the commit type:
|
||||
|
||||
```sh
|
||||
koji -e
|
||||
@@ -91,20 +91,18 @@ koji --emoji --hook
|
||||
You can also use _shortcodes_ (`:pinched_fingers:`) in the scope, summary, or
|
||||
body.
|
||||
|
||||
### How to configure koji
|
||||
### How to configure Koji (custom emoji)
|
||||
|
||||
You can configure koji via a custom config passed with `--config`, a
|
||||
`.koji.toml` file in the project root, or a user config at
|
||||
`~/.config/koji/config.toml`.
|
||||
You can add custom commit types via a `koji.toml` in the project directory.
|
||||
|
||||
Here's an example of a custom commit type:
|
||||
For example:
|
||||
|
||||
```toml
|
||||
[[commit_types]]
|
||||
name = "cust"
|
||||
name = "feat"
|
||||
emoji = "✨"
|
||||
description = "A custom commit type"
|
||||
description = "A new feature"
|
||||
```
|
||||
|
||||
The default configuration can be seen in
|
||||
[default.toml](https://github.com/cococonscious/koji/blob/main/meta/config/default.toml).
|
||||
The default emoji can be seen in
|
||||
[koji-default.toml](https://github.com/its-danny/koji/blob/main/meta/config/koji-default.toml).
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user