// Writes updates/latest.json, the feed Kaleido's updater reads, from a published release: // each platform's updater artifact and signature are taken from the release's assets, so // the feed only ever points at this version's files, whichever machine runs it. // Usage: node scripts/update-manifest.mjs [--allow-missing] [notesFile] // Every platform in PLATFORMS must be in the release (publish from each OS first); // --allow-missing writes the feed anyway, leaving the missing platforms out of it, so // their installs simply see no update until the feed is regenerated. import fs from 'node:fs'; import path from 'node:path'; import { api, download, releaseNotes, root } from './release-common.mjs'; const args = process.argv.slice(2); const allowMissing = args.includes('--allow-missing'); const [version, notesFile] = args.filter((a) => !a.startsWith('--')); if (!version) { console.error('usage: node scripts/update-manifest.mjs [--allow-missing] [notesFile]'); process.exit(1); } /** Tauri updater platform keys and the release asset each one installs. */ const PLATFORMS = [ { key: 'windows-x86_64', match: (f) => f === `Kaleido_${version}_x64-setup.exe` }, { key: 'darwin-aarch64', match: (f) => f === `Kaleido_${version}_aarch64.app.tar.gz` }, ]; const release = await api('GET', `/releases/tags/v${version}`).catch(() => null); if (!release) throw new Error(`No release v${version}; publish it with scripts/publish-release.mjs first.`); const assets = release.assets ?? []; const platforms = {}; const missing = []; for (const p of PLATFORMS) { const artifact = assets.find((a) => p.match(a.name)); const sig = artifact && assets.find((a) => a.name === `${artifact.name}.sig`); if (!artifact || !sig) { missing.push(p.key); continue; } platforms[p.key] = { signature: (await download(sig.browser_download_url)).trim(), url: artifact.browser_download_url }; console.log(`${p.key}: ${artifact.name}`); } if (missing.length && !allowMissing) { console.error(`v${version} has no build for ${missing.join(', ')}. Publish it from that OS, or pass --allow-missing.`); process.exit(1); } if (!Object.keys(platforms).length) throw new Error(`v${version} has no updater artifacts.`); const manifest = { version, notes: notesFile ? fs.readFileSync(notesFile, 'utf8').trim() : releaseNotes(version), pub_date: new Date().toISOString(), platforms, }; const manifestPath = path.join(root, 'updates/latest.json'); fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2) + '\n'); console.log(`Wrote ${path.relative(root, manifestPath)}${missing.length ? ` (without ${missing.join(', ')})` : ''}`);