Compare commits

..

10 Commits

Author SHA1 Message Date
AJ ONeal
9fa3ac5796 wip: reorg some vars 2023-12-31 02:29:04 -07:00
AJ ONeal
a249238af3 WIP: chore: things 2023-12-31 02:28:43 -07:00
AJ ONeal
51ede48ece feat(webi): show latest project release version on error 2023-12-31 01:53:50 -07:00
AJ ONeal
1fa5746ccd ref(webi): show supported OSes, etc with space rather than comma 2023-12-31 01:53:50 -07:00
AJ ONeal
27959ca3ca fix(installer): accept 'ANYOS' if no explicit OS matches 2023-12-31 01:53:50 -07:00
AJ ONeal
5909757a5b feat(installer): replace getReleases with new builds classifier 2023-12-31 01:53:50 -07:00
AJ ONeal
e5fb31a5a2 fix(webi): remove bogus ./webi/releases.js 2023-12-31 01:53:50 -07:00
AJ ONeal
b620c3de0d ref(classify): parallelize release downloads to fetch *much* faster 2023-12-31 01:53:49 -07:00
AJ ONeal
ef8828bbf4 feat: add builds classifier, and lint all builds 2023-12-31 01:53:49 -07:00
AJ ONeal
df0284f1b5 chore(ci): add git submodule 2023-12-31 01:53:49 -07:00
4 changed files with 44 additions and 78 deletions

View File

@@ -14,11 +14,16 @@ function padScript(txt) {
var BAD_SH_RE = /[<>'"`$\\]/; var BAD_SH_RE = /[<>'"`$\\]/;
Installers.renderBash = async function ( Installers.renderBash = async function (
baseurl, pkgdir,
posixTemplate, rel,
buildRequest, { baseurl, pkg, tag, ver, os = '', arch = '', libc = '', formats, latest },
buildMatch,
) { ) {
if (!Array.isArray(formats)) {
formats = [];
}
if (!tag) {
tag = '';
}
let installTxt = await Fs.readFile(path.join(pkgdir, 'install.sh'), 'utf8'); let installTxt = await Fs.readFile(path.join(pkgdir, 'install.sh'), 'utf8');
installTxt = padScript(installTxt); installTxt = padScript(installTxt);
var vers = rel.version.split('.'); var vers = rel.version.split('.');
@@ -126,18 +131,17 @@ Installers.renderBash = async function (
return tplTxt; return tplTxt;
}; };
/**
* @param {String} pkgdir
* @param {String} baseurl
* @param {BuildRequest} buildRequest
* @param {BuildMatch} buildMatch
*/
Installers.renderPowerShell = async function ( Installers.renderPowerShell = async function (
baseurl, pkgdir,
pwshTemplate, rel,
buildRequest, { baseurl, pkg, tag, ver, os, arch, libc = '', formats },
buildMatch,
) { ) {
if (!Array.isArray(formats)) {
formats = [];
}
if (!tag) {
tag = '';
}
let installTxt = await Fs.readFile(path.join(pkgdir, 'install.ps1'), 'utf8'); let installTxt = await Fs.readFile(path.join(pkgdir, 'install.ps1'), 'utf8');
installTxt = padScript(installTxt); installTxt = padScript(installTxt);
/* /*

View File

@@ -10,53 +10,25 @@ let Builds = require('./builds.js');
let Installers = require('./installers.js'); let Installers = require('./installers.js');
InstallerServer.INSTALLERS_DIR = Path.join(__dirname, '..'); InstallerServer.INSTALLERS_DIR = Path.join(__dirname, '..');
/**
* @typedef BuildRequest
* @prop {String} unameAgent
* @prop {String} projectName
* @prop {String} tag
* @prop {Array<String>} formats
*/
InstallerServer.serveInstaller = async function ( InstallerServer.serveInstaller = async function (
baseurl, baseurl,
ua, // TODO nix ua,
unameAgent, pkg,
pkg, // TODO nix
projectName,
tag, tag,
ext, // TODO nix ext,
installerType,
formats, formats,
) { ) {
if (!unameAgent) { let unameAgent = ua;
unameAgent = ua; let projectName = pkg;
} let [rel, tmplParams] = await InstallerServer.helper({
if (!projectName) {
projectName = pkg;
}
if (!installerType) {
installerType = ext;
}
let buildRequest = {
projectName, projectName,
tag, tag,
unameAgent, unameAgent,
formats, formats,
}; });
Object.assign(tmplParams, {
let hostTarget = {}; baseurl,
let buildMatch; });
{
let terms = unameAgent.split(/[\s\/]+/g);
void HostTargets.termsToTarget(hostTarget, terms);
buildMatch = await InstallerServer.getBuild(buildRequest, hostTarget);
}
Object.assign(tmplParams, { baseurl, });
console.log('dbg: buildPkg', rel);
console.log('dbg: tmplParams', tmplParams);
var pkgdir = Path.join(InstallerServer.INSTALLERS_DIR, projectName); var pkgdir = Path.join(InstallerServer.INSTALLERS_DIR, projectName);
if ('ps1' === ext) { if ('ps1' === ext) {
@@ -67,10 +39,6 @@ InstallerServer.serveInstaller = async function (
// 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 // TODO maybe move package/version/lts/channel detection into getReleases
/**
* @param {BuildRequest}
* @returns {BuildMatch}
*/
InstallerServer.helper = async function ({ InstallerServer.helper = async function ({
unameAgent, unameAgent,
projectName, projectName,
@@ -162,6 +130,9 @@ InstallerServer.helper = async function ({
}; };
let hasOs = projInfo.oses.includes(hostTarget.os); let hasOs = projInfo.oses.includes(hostTarget.os);
if (!hasOs) {
hasOs = projInfo.oses.includes('ANYOS');
}
if (!hasOs) { if (!hasOs) {
let pkg1 = Object.assign(buildTargetInfo, errPackage); let pkg1 = Object.assign(buildTargetInfo, errPackage);
return [pkg1, tmplParams]; return [pkg1, tmplParams];
@@ -191,11 +162,10 @@ InstallerServer.helper = async function ({
if (version.startsWith('v')) { if (version.startsWith('v')) {
version = version.slice(1); version = version.slice(1);
} }
let ver = version;
buildPkg = Object.assign(buildTargetInfo, buildPkg, { ext, version, tag }); buildPkg = Object.assign(buildTargetInfo, buildPkg, { ext, version });
Object.assign(tmplParams, { tag, ext, ver, version }); console.log('dbg: buildPkg', buildPkg);
//console.log(`VERSION: ${version}`, ext); console.log('dbg: tmplParams', tmplParams);
return [buildPkg, tmplParams]; return [buildPkg, tmplParams];
}; };

View File

@@ -81,29 +81,19 @@ Releases.get(path.join(process.cwd(), pkgdir)).then(async function (all) {
} }
var formats = ['exe', 'xz', 'tar', 'zip', 'git']; var formats = ['exe', 'xz', 'tar', 'zip', 'git'];
let unameAgent = `${nodeOs}/${nodeOsRelease} ${nodeArch}/unknown ${nodeLibc}`;
console.log(`DEBUG: ${unameAgent}`);
let [rel, opts] = await ServeInstaller.helper({ let [rel, opts] = await ServeInstaller.helper({
unameAgent: unameAgent,
projectName: pkgname, projectName: pkgname,
tag: pkgtag || '', tag: pkgtag || '',
unameAgent: `${nodeOs}/${nodeOsRelease} ${nodeArch}/unknown ${nodeLibc}`,
formats: formats, formats: formats,
libc: nodeLibc,
}); });
console.log('DEBUG opts:');
console.log(opts);
Object.assign( Object.assign(
rel,
{ {
version: '{test-version}', ver: '',
git_tag: '{test-git-tag}',
git_commit_hash: '{test-git-commit-hash}',
lts: null, lts: null,
channel: '{test-channel}', channel: '',
date: '1970-01-01T00:00:00Z', os: '',
os: '{test-os}', arch: '',
arch: '{test-arch}',
ext: '{test-ext}',
limit: 0, limit: 0,
}, },
opts, opts,

View File

@@ -7,18 +7,20 @@
"scripts": { "scripts": {
"bump": "npm version -m \"chore(release): bump to v%s\"", "bump": "npm version -m \"chore(release): bump to v%s\"",
"fmt": "npm run prettier && npm run shfmt && npm run pwsh-fmt", "fmt": "npm run prettier && npm run shfmt && npm run pwsh-fmt",
"lint": "npm run shellcheck && npm run jshint && npm run pwsh-lint", "lint": "npm run shellcheck && npm run jshint && npm run pwsh-lint && npm run tsc",
"prepare": "npm run tooling-init && npm run git-hooks-init", "prepare": "npm run tooling-init && npm run git-hooks-init",
"test": "node _webi/test.js ./node/", "test": "node _webi/test.js ./node/",
"----": "------------------------------------", "----": "------------------------------------",
"git-hooks-init": "node ./_scripts/git-hooks-init.js", "git-hooks-init": "node ./_scripts/git-hooks-init.js",
"jshint": "npx -p jshint@2.x -- jshint -c ./.jshintrc --exclude 'node_modules/**/*' */*.js */*/*.js", "jshint": "npx -p jshint@2.x -- jshint -c ./.jshintrc --exclude 'node_modules/**/*' *.js */*.js",
"prettier": "npx -p prettier@3.x -- prettier -w '**/*.{js,md,html}'", "prettier": "npx -p prettier@3.x -- prettier -w '**/*.{js,md,html}'",
"pwsh-fmt": "pwsh ./_scripts/pwsh-fmt.ps1", "pwsh-fmt": "pwsh ./_scripts/pwsh-fmt.ps1",
"pwsh-lint": "pwsh ./_scripts/pwsh-lint.ps1", "pwsh-lint": "pwsh ./_scripts/pwsh-lint.ps1",
"shellcheck": "shellcheck -s sh -S style --exclude=SC2154,SC2034 */*.sh", "shellcheck": "shellcheck -s sh -S style --exclude=SC2154,SC2034 */*.sh",
"shfmt": "shfmt -w -i 4 -sr -ci -s ./", "shfmt": "shfmt -w -i 4 -sr -ci -s ./",
"tooling-init": "node ./_scripts/tooling-init.js" "tsc": "npx -p typescript@5.x -- tsc -p ./jsconfig.json",
"tooling-init": "node ./_scripts/tooling-init.js",
"prepublish": "npx -p jswt@1.x -- reexport"
}, },
"repository": { "repository": {
"type": "git", "type": "git",