Compare commits

..

21 Commits

Author SHA1 Message Date
AJ ONeal
722df7641d WIP: ref(installer): use new names for template vars 2023-12-30 23:40:14 -07:00
AJ ONeal
6e3eb1d9ad fix(webi): remove bogus ./webi/releases.js 2023-12-30 23:38:41 -07:00
AJ ONeal
d01ce48f47 chore(ci): add git submodule 2023-12-30 23:38:40 -07:00
AJ ONeal
57fe6648c4 fix(installer): return rather than error for self-hosted installers (no releases.js) 2023-12-30 23:38:40 -07:00
AJ ONeal
0516aec7b2 chore(installer): remove duplicate check of targetRelease.packages 2023-12-30 23:38:36 -07:00
AJ ONeal
3df90b70b0 fix(installer): handle non-existant installers as 404 2023-12-30 23:38:35 -07:00
AJ ONeal
ca183af847 fix(classifier): name => projInfo.name 2023-12-30 23:38:35 -07:00
AJ ONeal
f9b6719a2d feat(webi): show latest project release version on error 2023-12-30 23:38:35 -07:00
AJ ONeal
8522dea6a5 ref(webi): show supported OSes, etc with space rather than comma 2023-12-30 23:38:35 -07:00
AJ ONeal
f414fa78aa feat(installer): replace getReleases with new builds classifier 2023-12-30 23:38:26 -07:00
AJ ONeal
9d3675396c ref(classify): parallelize release downloads to fetch *much* faster 2023-12-30 23:38:26 -07:00
AJ ONeal
d3fee8f00d feat: add builds classifier, and lint all builds 2023-12-30 23:38:26 -07:00
AJ ONeal
65c365c24a feat: add build-classifier submodule 2023-12-30 23:38:26 -07:00
AJ ONeal
e9f46c355e chore: add package.json.scripts.bump 2023-12-30 23:38:26 -07:00
AJ ONeal
7bb8040404 fix(ollama-darwin): filter out .app, manually set arch for universal 2023-12-28 02:04:26 -07:00
AJ ONeal
3ae143e48b fix(goreleaser): handle extraneous build term '1' 2023-12-28 02:04:26 -07:00
AJ ONeal
2cd242c945 fix(watchexec): remove 'cli-' prefix from literal version 2023-12-28 02:04:26 -07:00
AJ ONeal
5b32ecdf08 ref(shellcheck): remove superfluous target matching 2023-12-28 02:04:26 -07:00
AJ ONeal
6b25145795 fix(zoxide): remove incorrect arch detection 2023-12-28 02:04:26 -07:00
AJ ONeal
9a3cfbb573 fix(zig): filter out legacy armv6kz (RPi 1) one-off 2023-12-17 03:20:48 -07:00
AJ ONeal
50069182eb fix(pwsh): arch = 'musl' should be libc = 'musl' 2023-12-17 03:20:24 -07:00
9 changed files with 106 additions and 118 deletions

View File

@@ -23,6 +23,9 @@ 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

View File

@@ -490,7 +490,7 @@ BuildsCacher.create = function ({ ALL_TERMS, installers, caches }) {
let pattern = Triplet.toPattern(projInfo, build);
if (!pattern) {
let err = new Error(`no pattern generated for ${name}`);
let err = new Error(`no pattern generated for ${projInfo.name}`);
err.code = 'E_BUILD_NO_PATTERN';
target = { error: err };
bc._targetsByBuildIdCache[buildId] = target;

View File

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

View File

@@ -144,13 +144,6 @@ async function main() {
let triples = [];
let valids = Object.keys(dirs.valid);
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);
}
if (projName) {
if (!valids.includes(projName)) {
throw new Error(`'${projName}' is not a valid installable project`);

View File

@@ -10,27 +10,53 @@ let Builds = require('./builds.js');
let Installers = require('./installers.js');
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 (
baseurl,
ua,
pkg,
ua, // TODO nix
unameAgent,
pkg, // TODO nix
projectName,
tag,
ext,
ext, // TODO nix
installerType,
formats,
libc,
) {
let unameAgent = ua;
let projectName = pkg;
let [rel, tmplParams] = await InstallerServer.helper({
unameAgent,
if (!unameAgent) {
unameAgent = ua;
}
if (!projectName) {
projectName = pkg;
}
if (!installerType) {
installerType = ext;
}
let buildRequest = {
projectName,
tag,
unameAgent,
formats,
libc,
});
Object.assign(tmplParams, {
baseurl,
});
};
let hostTarget = {};
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);
if ('ps1' === ext) {
@@ -41,12 +67,15 @@ InstallerServer.serveInstaller = async function (
// TODO put some of this in a middleware? or common function?
// TODO maybe move package/version/lts/channel detection into getReleases
/**
* @param {BuildRequest}
* @returns {BuildMatch}
*/
InstallerServer.helper = async function ({
unameAgent,
projectName,
tag,
formats,
libc,
}) {
console.log(`dbg: Installer User-Agent: ${unameAgent}`);
@@ -74,28 +103,15 @@ InstallerServer.helper = async function ({
let validTypes = ['alias', 'selfhosted', 'valid'];
if (!validTypes.includes(proj.type)) {
throw new Error(
`'${projectName}' doesn't have an installer: '${proj.type}': '${proj.detail}'`,
);
let msg = `'${projectName}' doesn't have an installer: '${proj.type}': '${proj.detail}'`;
let err = new Error(msg);
err.code = 'ENOENT';
throw err;
}
if (proj.type === 'alias') {
projectName = proj.detail;
}
let projInfo = await Builds.getPackage({
name: projectName,
date: new Date(),
});
//console.log('projInfo', projInfo);
let buildTargetInfo = {
triplets: projInfo.triplets,
oses: projInfo.oses,
arches: projInfo.arches,
libcs: projInfo.libcs,
formats: projInfo.formats,
};
let tmplParams = {
pkg: projectName,
tag: tag,
@@ -105,8 +121,6 @@ InstallerServer.helper = async function ({
formats: hostFormats,
limit: 1,
};
let latest = projInfo.versions[0];
Object.assign(tmplParams, { latest });
Object.assign(tmplParams, releaseTarget);
console.log('tmplParams', tmplParams);
@@ -127,6 +141,26 @@ InstallerServer.helper = async function ({
"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'",
};
if (proj.type === 'selfhosted') {
return [errPackage, tmplParams];
}
let projInfo = await Builds.getPackage({
name: projectName,
date: new Date(),
});
let latest = projInfo.versions[0];
Object.assign(tmplParams, { latest });
//console.log('projInfo', projInfo);
let buildTargetInfo = {
triplets: projInfo.triplets,
oses: projInfo.oses,
arches: projInfo.arches,
libcs: projInfo.libcs,
formats: projInfo.formats,
};
let hasOs = projInfo.oses.includes(hostTarget.os);
if (!hasOs) {
let pkg1 = Object.assign(buildTargetInfo, errPackage);
@@ -147,11 +181,6 @@ InstallerServer.helper = async function ({
return [pkg1, tmplParams];
}
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('.')) {
@@ -162,10 +191,11 @@ InstallerServer.helper = async function ({
if (version.startsWith('v')) {
version = version.slice(1);
}
let ver = version;
buildPkg = Object.assign(buildTargetInfo, buildPkg, { ext, version });
console.log('dbg: buildPkg', buildPkg);
console.log('dbg: tmplParams', tmplParams);
buildPkg = Object.assign(buildTargetInfo, buildPkg, { ext, version, tag });
Object.assign(tmplParams, { tag, ext, ver, version });
//console.log(`VERSION: ${version}`, ext);
return [buildPkg, tmplParams];
};

View File

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

View File

@@ -5,6 +5,7 @@
"description": "webinstall script repository",
"main": "_webi/",
"scripts": {
"bump": "npm version -m \"chore(release): bump to v%s\"",
"fmt": "npm run prettier && npm run shfmt && npm run pwsh-fmt",
"lint": "npm run shellcheck && npm run jshint && npm run pwsh-lint",
"prepare": "npm run tooling-init && npm run git-hooks-init",

View File

@@ -1,43 +0,0 @@
'use strict';
module.exports = async function () {
return {
releases: [
{
name: 'webi.tar',
version: '0.0.0',
lts: false,
channel: 'stable',
date: '',
os: 'linux',
arch: 'amd64',
ext: 'tar',
download: '',
},
{
name: 'webi.tar',
version: '0.0.0',
lts: false,
channel: 'stable',
date: '',
os: 'macos',
arch: 'amd64',
ext: 'tar',
download: '',
},
{
name: 'webi.tar',
version: '0.0.0',
lts: false,
channel: 'stable',
date: '',
os: 'windows',
arch: 'amd64',
ext: 'tar',
download: '',
},
],
formats: [],
downloads: '',
};
};