Files
Termix/scripts/fix-update-info.cjs
T
62ac931468 v26.10.1 (#1599)
* feat: AI translations at release, 7 new languages and regional fallback

* fix: proper plural forms for count strings and full translations

* fix: plural forms for selected, hidden and active counts

* fix: synced plugin updates failing on desktop and server-only plugins shown as stopped

* fix: restore rounded corners on app icons and favicon

* feat: desktop app auto updates with automatic, ask first or never modes

* feat: community and custom plugin registries

* feat: plugin guide for AI tools in the SDK with a lint check

* fix: keep the terminal WebSocket open past nginx's 60s default (#1588)

* chore: update changelog

* feat: show plugin download counts only and stop CI builds inflating them

* feat: hide installed plugins in the browse tab by default

* chore: pin bundled plugins to latest releases

* chore: update translations

* fix: focusing a saved password field and saving no longer erases it

* fix: tell desktop users when their 2.8 data needs 2.9 first

* fix: point windows update info at the x64 installer

* fix: keep desktop client tunnel sockets alive behind proxies

* chore: pin bundled plugins to latest releases

* fix: cover client tunnel keepalive in the c2s runtime tests

* fix: typing after opening a host no longer goes to the host search

* fix: accept tab and = separators in SSH config import (#1598)

* chore: update changelog

* chore: drop plugin versions from core changelog

* chore: update translations

* chore: lint, format, and bump version to 26.10.1

---------

Co-authored-by: Darnel Hunter <68697450+innotelinc@users.noreply.github.com>
Co-authored-by: Iain <Iain1970@protonmail.com>
2026-10-12 11:35:48 -05:00

65 lines
2.1 KiB
JavaScript

#!/usr/bin/env node
/**
* Fixes electron-builder's update files (latest.yml and friends) after the
* build, so the desktop updater gets the right download:
*
* --drop <text> remove entries whose file name contains text
* (the ia32 installer, the combined Windows
* installer, the universal mac zip)
* --rename <old=new> follow an artifact the workflow renamed
*
* Usage: node scripts/fix-update-info.cjs [--drop x] [--rename a=b] files...
*/
const fs = require("node:fs");
const yaml = require("js-yaml");
function fixUpdateInfo(info, { drop = [], rename = {} } = {}) {
const rewrite = (name) => rename[name] ?? name;
const seen = new Set();
// electron-builder can list the same file more than once.
const files = (info.files ?? [])
.filter((file) => !drop.some((text) => file.url.includes(text)))
.map((file) => ({ ...file, url: rewrite(file.url) }))
.filter((file) => !seen.has(file.url) && seen.add(file.url));
if (files.length === 0) {
throw new Error("no files left in update info");
}
return { ...info, files, path: files[0].url, sha512: files[0].sha512 };
}
function parseArgs(argv) {
const options = { drop: [], rename: {}, files: [] };
for (let i = 0; i < argv.length; i++) {
const arg = argv[i];
if (arg === "--drop") options.drop.push(argv[++i]);
else if (arg === "--rename") {
const [from, to] = String(argv[++i]).split("=");
if (!from || !to) throw new Error(`bad --rename ${argv[i]}`);
options.rename[from] = to;
} else options.files.push(arg);
}
return options;
}
function main() {
const options = parseArgs(process.argv.slice(2));
for (const file of options.files) {
if (!fs.existsSync(file)) continue;
const info = yaml.load(fs.readFileSync(file, "utf8"));
fs.writeFileSync(file, yaml.dump(fixUpdateInfo(info, options)));
console.log(`Fixed ${file}`);
}
}
if (require.main === module) {
try {
main();
} catch (error) {
console.error(error.message);
process.exit(1);
}
}
module.exports = { fixUpdateInfo, parseArgs };