Releases from git tags and WHATS-NEW.md; docs, changelog (1.4.0)

The Hub reads the Cross Events repo's v* tags (each a release, the newest the
latest version) and the client notes from WHATS-NEW.md as of the newest tag,
every 15 minutes and on Sync now. Urgent/security in a version heading marks it
urgent. Repo address, notes path and an optional encrypted token on the
Releases page; manual releases only when no repo is set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-28 09:13:30 +02:00
co-authored by Claude Opus 5.5
parent 1449e5046e
commit 0adb304024
13 changed files with 380 additions and 38 deletions
+31 -9
View File
@@ -17,29 +17,45 @@ const DEFAULTS = {
smtp_user: '',
smtp_pass: '',
smtp_from: '',
// Releases and their notes are read from git (utils/releaseSync.js) when a repo is set.
release_repo_url: 'https://c-git.crosscode.co.za/joshua/hope-events',
release_notes_path: 'WHATS-NEW.md',
release_repo_token: '',
// Written by the sync, not the Settings page.
release_synced_at: '',
release_sync_error: '',
};
// Stored encrypted and never sent to the browser: only "is one saved" (<key>_set).
const SECRETS = ['smtp_pass', 'release_repo_token'];
async function rawSettings() {
const rows = await prisma.setting.findMany();
const saved = Object.fromEntries(rows.map(r => [r.key, r.value]));
return { ...DEFAULTS, ...saved };
}
/** Settings for the Settings page: the SMTP password only as "is one saved". */
/** Settings for the Settings page: secrets (SMTP password, repo token) only as "is one saved". */
async function getSettings() {
const { smtp_pass, ...settings } = await rawSettings();
return { ...settings, smtp_pass_set: smtp_pass ? 'true' : '' };
const settings = await rawSettings();
for (const key of SECRETS) {
settings[`${key}_set`] = settings[key] ? 'true' : '';
delete settings[key];
}
return settings;
}
/**
* Save settings. A blank smtp_pass keeps the saved password (the page never has it);
* smtp_pass_clear removes it.
* Save settings. A blank secret keeps the saved one (the page never has it); <key>_clear
* removes it.
*/
async function setSettings(values) {
const input = { ...(values || {}) };
if (input.smtp_pass_clear) input.smtp_pass = '';
else if (input.smtp_pass) input.smtp_pass = encrypt(input.smtp_pass);
else delete input.smtp_pass;
for (const key of SECRETS) {
if (input[`${key}_clear`]) input[key] = '';
else if (input[key]) input[key] = encrypt(input[key]);
else delete input[key];
}
const updates = Object.entries(input).filter(([k]) => k in DEFAULTS);
for (const [key, value] of updates) {
await prisma.setting.upsert({ where: { key }, update: { value: String(value ?? '') }, create: { key, value: String(value ?? '') } });
@@ -83,4 +99,10 @@ async function importSmtpFromEnv() {
return true;
}
module.exports = { DEFAULTS, getSettings, setSettings, smtpSettings, importSmtpFromEnv };
/** The saved repo token, decrypted ('' when none). */
async function releaseRepoToken() {
const { release_repo_token } = await rawSettings();
return release_repo_token ? decrypt(release_repo_token) : '';
}
module.exports = { DEFAULTS, getSettings, setSettings, smtpSettings, importSmtpFromEnv, releaseRepoToken };