Hub 2.0 step 3: releases per product, with requirements

- Release.product and requires; unique (product, version); latest version
  per product (latest_version stays Cross Events' latest)
- Release sources per product (Releases page): repository, tag prefix,
  notes file. Defaults: every product from crosscode-platform plus Cross
  Events' v1.2.3 tags from hope-events. A product's releases are only
  removed when all its sources were read and found tags
- "— requires accounts 1.2.0" in a notes heading: Request update answers
  409 REQUIREMENT_NOT_MET until the church's install of that product is new
  enough; install page and Releases page show it; v2 replies carry requires
- @crosscode/contracts 1.1.0 vendored (optional requires on releases)
- Alerts, dashboard and install lists compare against each product's latest

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-04 15:57:46 +02:00
co-authored by Claude Opus 5.5
parent 0318b4f6f4
commit 816452e1c2
21 changed files with 821 additions and 201 deletions
+15 -3
View File
@@ -70,15 +70,27 @@ function problems(install, settings, now = new Date()) {
else if (left <= s.expiryDays * DAY) out.push({ type: 'licence_expiring', level: 'warning', message: `Licence expires ${new Date(lic.expiresAt).toISOString().slice(0, 10)}` });
}
if (settings.latest_version && install.version && compareVersions(install.version, settings.latest_version) < 0) {
out.push({ type: 'behind', level: 'info', message: `Runs ${install.version}; latest is ${settings.latest_version}` });
// Hub 2.0: the latest version of the install's product (settings.latest_versions, a map); before
// that, latest_version was Cross Events'.
const latest = settings.latest_versions ? settings.latest_versions[install.product || 'events'] : settings.latest_version;
if (latest && install.version && compareVersions(install.version, latest) < 0) {
out.push({ type: 'behind', level: 'info', message: `Runs ${install.version}; latest is ${latest}` });
}
return out;
}
/** Run the checks for every install: open new alerts (emailed unless info), resolve cleared ones. */
/** The latest version of each product ({ events: '2.1.1', … }), read here rather than from releases.js (which needs this file). */
async function latestVersionsNow() {
const out = {};
for (const r of await prisma.release.findMany({ select: { product: true, version: true } })) {
if (!out[r.product] || compareVersions(r.version, out[r.product]) > 0) out[r.product] = r.version;
}
return out;
}
async function runAlerts(now = new Date()) {
const settings = await getSettings();
const settings = { ...(await getSettings()), latest_versions: await latestVersionsNow() };
const installs = await prisma.install.findMany({
where: { releasedAt: null },
include: { licence: true, customer: { select: { name: true } }, events: { where: { resolvedAt: null } } },