Speed up downloads by combining multiple network connections in parallel
TypeScript bandwidth-aggregationcross-platformdesktop-appdownloaderdownloadmanagerlinuxmacosmulticonnectionparallel-downloadswindows
feat: label every download clearly on the site and in release notes
Anmol Kapil8daba374e1fc
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex fa21a2b..ee52abf 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -48,6 +48,21 @@ Tests build the app first; set `PLEXO_E2E_SKIP_BUILD=1` when `out/` is already f- If you're changing download/networking behavior (`src/main/download/`, `src/main/network/`), explain the reasoning in the PR — a lot of the logic there (resume/retry/stall handling) exists to avoid subtle data-corruption bugs, so tradeoffs matter more than usual.- UI changes: a screenshot or short screen recording in the PR description is very helpful.+## Releasing++A release ships seven files: `Plexo` for macOS (Apple silicon and Intel `.dmg`), Windows (one installer for x64 and ARM64) and Linux (`AppImage` and `.deb`, x86_64 and ARM64). The download page (`docs/`, served by GitHub Pages) reads them from the latest GitHub Release and labels each one from its file name (`docs/downloads.js`), so keep the naming in `electron-builder.yml` intact.++```bash+npm version <version> --no-git-tag-version # e.g. 1.0.0-rc.8+npm run build:mac && npm run build:win && npm run build:linux++node scripts/release-notes.mjs v<version> notes.md > body.md # your notes + the downloads table+gh release create v<version> --prerelease --title v<version> --notes-file body.md \+ $(node scripts/release-notes.mjs v<version> --files)+```++The script only picks up files the download page knows how to describe, so the update metadata and blockmaps electron-builder leaves in `dist/` are never uploaded.+## Reporting bugsOpen a GitHub issue with:diff --git a/docs/downloads.js b/docs/downloads.jsnew file mode 100644index 0000000..dcc08d0--- /dev/null+++ b/docs/downloads.js@@ -0,0 +1,285 @@+/*+ * What Plexo's download page and its GitHub Release notes say about each file we ship, and which+ * one to put in front of a visitor. Plain ES5 so the page can load it as-is; the release-notes+ * script and the tests load it with require().+ *+ * Everything is derived from the release's file names (see electron-builder.yml for how they're+ * made), so a file that isn't recognised — update metadata, blockmaps, a snap — is simply left+ * out, and a new build shows up as soon as its name says what it is.+ */+;(function (root) {+ 'use strict'++ var OS_ORDER = ['mac', 'win', 'linux']+ var OS_LABEL = { mac: 'macOS', win: 'Windows', linux: 'Linux' }++ // Shown under each OS's downloads. `code` spans are wrapped in backticks.+ var NOTES = {+ mac: [+ 'Plexo isn’t signed with an Apple Developer certificate yet, so macOS asks you to confirm the first launch: open the app once, then go to System Settings → Privacy & Security and choose Open Anyway.',+ 'If macOS says the app is damaged or can’t be opened, run `xattr -dr com.apple.quarantine /Applications/Plexo.app` in Terminal and open it again.',+ 'Not sure which Mac you have? Apple menu → About This Mac: “Chip: Apple M…” is Apple silicon, “Processor: Intel…” is Intel.'+ ],+ win: [+ 'The installer isn’t code-signed yet, so Windows may say “Windows protected your PC”. Choose More info, then Run anyway.',+ 'One installer covers both regular (x64) and ARM PCs.'+ ],+ linux: [+ 'AppImage: `chmod +x plexo-*.AppImage`, then run it. Recent Ubuntu needs FUSE 2 first: `sudo apt install libfuse2t64` (older releases call it `libfuse2`) — or use the .deb, which needs nothing extra.',+ '.deb: `sudo apt install ./plexo_*.deb`.',+ 'Using more than one network needs Linux kernel 5.7 or newer (any current distro); on older kernels Plexo can only use the default network.'+ ]+ }++ /** Says what a release file is, from its name; null for anything we don't offer as a download. */+ function describe(name) {+ var n = String(name).toLowerCase()+ var arch = /(arm64|aarch64)/.test(n) ? 'arm64' : /(x86_64|x64|amd64)/.test(n) ? 'x64' : 'any'++ if (/\.dmg$/.test(n)) {+ if (arch === 'arm64') return mk('mac', arch, 'dmg', 'Apple silicon', 'M1 and later · .dmg', 0)+ if (arch === 'x64') return mk('mac', arch, 'dmg', 'Intel', 'Intel Macs · .dmg', 1)+ return mk('mac', arch, 'dmg', 'macOS', '.dmg', 2)+ }+ if (/\.exe$/.test(n)) {+ // Our installer carries no architecture in its name because one file holds both.+ if (arch === 'any') {+ return mk('win', arch, 'exe', 'Windows 10 and 11', 'Installer · x64 and ARM64', 0)+ }+ if (arch === 'x64') {+ return mk('win', arch, 'exe', 'Windows · x64', 'Installer · Intel and AMD PCs', 1)+ }+ return mk('win', arch, 'exe', 'Windows on ARM', 'Installer · ARM PCs', 2)+ }+ if (/\.appimage$/.test(n)) {+ return mk(+ 'linux',+ arch,+ 'appimage',+ 'AppImage' + archSuffix(arch),+ 'Runs on any distro, no install',+ arch === 'arm64' ? 2 : 0+ )+ }+ if (/\.deb$/.test(n)) {+ return mk(+ 'linux',+ arch,+ 'deb',+ 'Debian / Ubuntu' + archSuffix(arch),+ '.deb package · Debian, Ubuntu, Mint',+ arch === 'arm64' ? 3 : 1+ )+ }+ if (/\.rpm$/.test(n)) {+ return mk(+ 'linux',+ arch,+ 'rpm',+ 'Fedora / RHEL' + archSuffix(arch),+ '.rpm package · Fedora, RHEL, openSUSE',+ arch === 'arm64' ? 5 : 4+ )+ }+ return null+ }++ function archSuffix(arch) {+ return arch === 'arm64' ? ' · ARM64' : arch === 'x64' ? ' · x86_64' : ''+ }++ function mk(os, arch, kind, title, detail, sort) {+ return { os: os, arch: arch, kind: kind, title: title, detail: detail, sort: sort }+ }++ /**+ * Which OS and CPU the visitor is on, as far as the browser will say. `nav` is what the page has+ * on `navigator`; `hint` is the result of userAgentData.getHighEntropyValues(['architecture']),+ * which only Chromium browsers provide. `arch` is null when there is no evidence, and the page+ * must not pretend otherwise: Safari and Firefox never say what chip a Mac has.+ */+ function detectEnvironment(nav, hint) {+ var ua = String((nav && nav.userAgent) || '')+ var platform = String((nav && nav.platform) || '')+ var s = ua + ' ' + platform+ var touch = Number((nav && nav.maxTouchPoints) || 0)++ // iPadOS reports itself as a Mac, with a touch screen.+ if (/Android|iPhone|iPad|iPod/i.test(s) || (/Mac/i.test(platform) && touch > 1)) {+ return { os: 'mobile', arch: null }+ }+ if (/CrOS/.test(s)) return { os: 'other', arch: null }++ var os = /Windows|Win32|Win64/i.test(s)+ ? 'win'+ : /Macintosh|MacIntel|Mac OS X/i.test(s)+ ? 'mac'+ : /Linux|X11/i.test(s)+ ? 'linux'+ : 'other'++ var arch = null+ if (hint && hint.architecture) {+ arch = hint.architecture === 'arm' ? 'arm64' : hint.architecture === 'x86' ? 'x64' : null+ } else if (os === 'linux') {+ arch = /aarch64|arm64|armv8/i.test(s) ? 'arm64' : /x86_64|x64|amd64/i.test(s) ? 'x64' : null+ }+ return { os: os, arch: arch }+ }++ function formatSize(bytes) {+ if (!bytes) return ''+ var mb = bytes / 1048576+ return mb >= 1024 ? (mb / 1024).toFixed(2) + ' GB' : mb.toFixed(mb >= 100 ? 0 : 1) + ' MB'+ }++ function byArch(assets, arch) {+ for (var i = 0; i < assets.length; i++) if (assets[i].arch === arch) return assets[i]+ return null+ }++ /** The download to put in the big button, plus the ways out if it's the wrong one. */+ function choose(assets, env) {+ var mine = assets.filter(function (a) {+ return a.os === env.os+ })+ if (!mine.length) return null+ var alternates = []+ var hint = null+ var primary++ if (env.os === 'mac') {+ // Only Apple silicon Macs are still sold, and macOS 27 needs one, so that is the default+ // when the browser can't say. Either way the other chip is one click away.+ var want = env.arch || 'arm64'+ primary = byArch(mine, want) || mine[0]+ var other = mine.filter(function (a) {+ return a !== primary+ })[0]+ if (other) {+ alternates.push({+ text:+ primary.arch === 'x64'+ ? 'On an Apple silicon Mac? Get the Apple silicon build'+ : 'On an Intel Mac? Get the Intel build',+ asset: other+ })+ }+ if (!env.arch) hint = 'Not sure which? Apple menu → About This Mac.'+ } else if (env.os === 'win') {+ primary = byArch(mine, env.arch || 'any') || byArch(mine, 'any') || mine[0]+ mine.forEach(function (a) {+ if (a !== primary) alternates.push({ text: 'Get ' + a.title, asset: a })+ })+ } else {+ var arch = env.arch || 'x64'+ var images = mine.filter(function (a) {+ return a.kind === 'appimage'+ })+ primary = byArch(images, arch) || images[0] || mine[0]+ var pkg = mine.filter(function (a) {+ return a.kind === 'deb' && a.arch === primary.arch+ })[0]+ if (pkg) alternates.push({ text: 'On Debian or Ubuntu? Get the .deb', asset: pkg })+ if (!env.arch) {+ var arm = byArch(images, 'arm64')+ if (arm && arm !== primary) {+ alternates.push({ text: 'On an ARM64 machine? Get the ARM64 AppImage', asset: arm })+ }+ }+ }+ return { primary: primary, alternates: alternates, hint: hint }+ }++ /**+ * Everything the page shows for a release: the recommended download, its alternatives, and every+ * file grouped by OS with the notes that go with it. `release` is a GitHub release object.+ */+ function build(release, env) {+ var assets = ((release && release.assets) || [])+ .map(function (a) {+ var d = describe(a.name)+ if (!d) return null+ d.file = a.name+ d.size = a.size || 0+ d.sizeText = formatSize(a.size)+ d.url = a.browser_download_url+ return d+ })+ .filter(Boolean)++ var chosen = choose(assets, env || { os: 'other', arch: null })+ var primary = chosen && chosen.primary++ var groups = OS_ORDER.map(function (os) {+ var rows = assets+ .filter(function (a) {+ return a.os === os+ })+ .sort(function (a, b) {+ return a.sort - b.sort+ })+ .map(function (a) {+ a.recommended = a === primary+ return a+ })+ return { os: os, label: OS_LABEL[os], rows: rows, notes: NOTES[os] }+ }).filter(function (g) {+ return g.rows.length > 0+ })++ var desktop = env && (env.os === 'mac' || env.os === 'win' || env.os === 'linux')+ return {+ groups: groups,+ primary: primary+ ? {+ asset: primary,+ title: 'Download for ' + OS_LABEL[env.os],+ meta: primary.title + (primary.sizeText ? ' · ' + primary.sizeText : '')+ }+ : null,+ alternates: chosen ? chosen.alternates : [],+ hint: chosen ? chosen.hint : null,+ desktop: !!desktop,+ empty: assets.length === 0+ }+ }++ /**+ * The downloads table for a GitHub Release's notes — the same names and descriptions as the+ * page. `files` is [{ name, size, url }].+ */+ function markdown(files, siteUrl) {+ var model = build(+ {+ assets: files.map(function (f) {+ return { name: f.name, size: f.size, browser_download_url: f.url }+ })+ },+ { os: 'other', arch: null }+ )+ var out = ['## Downloads', '']+ model.groups.forEach(function (g) {+ out.push('**' + g.label + '**', '', '| Download | For | Size |', '|---|---|---|')+ g.rows.forEach(function (r) {+ out.push('| [' + r.title + '](' + r.url + ') | ' + r.detail + ' | ' + r.sizeText + ' |')+ })+ out.push('')+ })+ out.push(+ 'Not signed yet, so macOS and Windows ask you to confirm the first launch — how, and what ' ++ 'Linux needs: ' ++ siteUrl ++ '#downloads'+ )+ return out.join('\n')+ }++ root.PlexoDownloads = {+ describe: describe,+ detectEnvironment: detectEnvironment,+ build: build,+ markdown: markdown,+ formatSize: formatSize+ }+})(typeof window !== 'undefined' ? window : module.exports)diff --git a/docs/index.html b/docs/index.htmlindex 331dcd8..4aa4adf 100644--- a/docs/index.html+++ b/docs/index.html@@ -350,6 +350,95 @@monospace;color: #6f7479;}+ .cta-alt {+ display: flex;+ flex-direction: column;+ gap: 5px;+ font:+ 500 12.5px/1.5 Manrope,+ sans-serif;+ color: #a9adb2;+ }+ .cta-alt a {+ color: #d8a44c;+ text-decoration: underline;+ text-underline-offset: 3px;+ }+ .cta-alt a:hover {+ color: #e8bb6d;+ }+ .cta-alt .hint {+ font:+ 400 11.5px/1.5 'Roboto Mono',+ monospace;+ color: #6f7479;+ }+ .groups {+ display: flex;+ flex-direction: column;+ gap: 30px;+ }+ .os-group {+ display: flex;+ flex-direction: column;+ gap: 12px;+ }+ .os-group h3 {+ margin: 0;+ font:+ 700 15px/1.2 Manrope,+ sans-serif;+ letter-spacing: -0.01em;+ color: #f5f2ed;+ }+ .asset-table .asset-row:last-child {+ border-bottom: 0;+ }+ .asset-row.recommended {+ background: #202428;+ }+ .asset-row .platform .detail {+ display: block;+ margin-top: 2px;+ font:+ 400 11.5px/1.4 Manrope,+ sans-serif;+ color: #8d9196;+ }+ .asset-row .platform .rec {+ display: inline-block;+ margin-left: 8px;+ padding: 2px 7px;+ border-radius: 999px;+ background: rgba(216, 164, 76, 0.14);+ color: #d8a44c;+ font:+ 600 10px/1.3 'Roboto Mono',+ monospace;+ letter-spacing: 0.02em;+ vertical-align: 1px;+ }+ .os-notes {+ margin: 0;+ padding: 0 4px 0 18px;+ font:+ 400 12.5px/1.6 Manrope,+ sans-serif;+ color: #8d9196;+ }+ .os-notes li {+ margin: 5px 0;+ }+ .os-notes code {+ padding: 1px 6px;+ border-radius: 5px;+ background: #23262a;+ color: #c9ccd0;+ font:+ 400 11.5px/1.5 'Roboto Mono',+ monospace;+ overflow-wrap: anywhere;+ }footer {display: flex;align-items: center;@@ -452,8 +541,9 @@<span class="meta" id="primary-meta">Loading latest release…</span></span></a>- <a href="#downloads">Other platforms</a>+ <a href="#downloads">All downloads</a></div>+ <div class="cta-alt" id="cta-alt"></div><div class="release-line" id="release-line">Checking GitHub for the latest release…</div></section>@@ -517,7 +607,7 @@<div class="title">All downloads</div><div class="source" id="asset-source">PUBLISHED ON GITHUB RELEASES</div></div>- <div class="asset-table" id="asset-table">+ <div class="groups" id="asset-groups"><div class="asset-note">Loading releases…</div></div></section>@@ -530,6 +620,7 @@</footer></div>+ <script src="downloads.js"></script><script>;(function () {var track = document.getElementById('shots-track')@@ -556,73 +647,96 @@;(function () {var REPO = 'anmolkapil/plexo'var repoUrl = 'https://github.com/' + REPO- var labels = { mac: 'macOS', win: 'Windows', linux: 'Linux' }+ var D = window.PlexoDownloads- function osKey() {- var ua = (navigator.userAgent || '') + ' ' + (navigator.platform || '')- if (/Win/i.test(ua)) return 'win'- if (/Linux|X11/i.test(ua) && !/Android/i.test(ua)) return 'linux'- return 'mac'+ function $(id) {+ return document.getElementById(id)}- function fmtSize(bytes) {- if (!bytes) return ''- var mb = bytes / 1048576- return mb >= 1024 ? (mb / 1024).toFixed(2) + ' GB' : mb.toFixed(1) + ' MB'+ function el(tag, className, text) {+ var node = document.createElement(tag)+ if (className) node.className = className+ if (text) node.textContent = text+ return node}- // ponytail: extension-based classifier, good enough for electron-builder's default output names.- function classify(name) {- var n = name.toLowerCase()- if (/\.dmg$/.test(n)) return 'mac'- if (/\.(exe|msi)$/.test(n)) return 'win'- if (/\.(appimage|deb|rpm)$/.test(n)) return 'linux'- return null+ // Text with `code` spans, built without innerHTML.+ function withCode(node, text) {+ text.split('`').forEach(function (part, i) {+ if (!part) return+ node.appendChild(i % 2 ? el('code', '', part) : document.createTextNode(part))+ })+ return node}- function render(release) {- var key = osKey()- var assets = []+ // Only Chromium browsers will say what chip this is; the rest leave it null.+ function environment() {+ var uaData = navigator.userAgentData+ var hint =+ uaData && uaData.getHighEntropyValues+ ? uaData.getHighEntropyValues(['architecture']).catch(function () {+ return null+ })+ : Promise.resolve(null)+ return hint.then(function (h) {+ return D.detectEnvironment(navigator, h)+ })+ }- if (release) {- assets = (release.assets || [])- .map(function (a) {- var k = classify(a.name)- if (!k) return null- return {- key: k,- platform:- labels[k] +- (k === 'mac' && /arm64|aarch64/i.test(a.name) ? ' · Apple silicon' : ''),- file: a.name,- size: fmtSize(a.size),- url: a.browser_download_url- }- })- .filter(Boolean)- }+ function row(asset) {+ var r = el('div', 'asset-row' + (asset.recommended ? ' recommended' : ''))+ var platform = el('div', 'platform', asset.title)+ if (asset.recommended) platform.appendChild(el('span', 'rec', 'FOR YOUR COMPUTER'))+ platform.appendChild(el('span', 'detail', asset.detail))+ var file = el('div', 'file', asset.file + ' ')+ if (asset.sizeText) file.appendChild(el('span', 'size', '· ' + asset.sizeText))+ var dl = el('a', 'dl', 'Download')+ dl.href = asset.url+ r.appendChild(platform)+ r.appendChild(file)+ r.appendChild(dl)+ return r+ }- var table = document.getElementById('asset-table')- var sourceEl = document.getElementById('asset-source')- var releaseLine = document.getElementById('release-line')- var versionEl = document.getElementById('version-label')- var primaryTitle = document.getElementById('primary-title')- var primaryMeta = document.getElementById('primary-meta')- var primaryBtn = document.getElementById('primary-btn')+ // Nothing to offer (no release yet, GitHub unreachable, or this page's own script missing):+ // send the visitor to the Releases page rather than leave a spinner up.+ function fallback(failed) {+ $('asset-groups').textContent = ''+ $('cta-alt').textContent = ''+ $('asset-groups').appendChild(+ el(+ 'div',+ 'asset-note',+ failed+ ? 'Couldn’t load the latest release from GitHub — get Plexo from the Releases page.'+ : 'No published build assets yet — check the Releases page on GitHub.'+ )+ )+ $('asset-source').textContent = REPO.toUpperCase()+ $('release-line').textContent = failed+ ? 'Couldn’t check for the latest release.'+ : 'No release published yet.'+ $('version-label').textContent = 'PLEXO'+ $('primary-title').textContent = 'View releases on GitHub'+ $('primary-meta').textContent = repoUrl+ $('primary-btn').href = repoUrl + '/releases'+ }- if (!release || !assets.length) {- table.innerHTML =- '<div class="asset-note">No published build assets yet — check the <a href="' +- repoUrl +- '/releases">Releases page</a> on GitHub.</div>'- sourceEl.textContent = REPO.toUpperCase()- releaseLine.textContent = 'No release published yet.'- versionEl.textContent = 'PLEXO'- primaryTitle.textContent = 'View releases on GitHub'- primaryMeta.textContent = repoUrl- primaryBtn.href = repoUrl + '/releases'- return- }+ function render(release, env) {+ var groupsEl = $('asset-groups')+ var sourceEl = $('asset-source')+ var releaseLine = $('release-line')+ var versionEl = $('version-label')+ var primaryTitle = $('primary-title')+ var primaryMeta = $('primary-meta')+ var primaryBtn = $('primary-btn')+ var alt = $('cta-alt')+ var model = D.build(release, env)++ groupsEl.textContent = ''+ alt.textContent = ''++ if (!release || model.empty) return fallback()var version = release.tag_namevar date = release.published_at@@ -640,48 +754,72 @@(release.prerelease ? 'pre-release' : 'stable') +(date ? ' · ' + date : '')- var primary =- assets.filter(function (a) {- return a.key === key- })[0] || assets[0]- primaryTitle.textContent = 'Download for ' + labels[key]- primaryMeta.textContent = primary.file + (primary.size ? ' · ' + primary.size : '')- primaryBtn.href = primary.url+ if (model.primary) {+ primaryTitle.textContent = model.primary.title+ primaryMeta.textContent = model.primary.meta+ primaryBtn.href = model.primary.asset.url+ } else {+ // Phones, tablets and anything we don't build for.+ primaryTitle.textContent = model.desktop+ ? 'Choose a download'+ : 'Plexo is a desktop app'+ primaryMeta.textContent = model.desktop+ ? 'Nothing published for your system yet'+ : 'Open this page on a Mac, Windows or Linux computer'+ primaryBtn.href = '#downloads'+ }- table.innerHTML = ''- assets.forEach(function (a) {- var row = document.createElement('div')- row.className = 'asset-row'- row.innerHTML =- '<div class="platform"></div>' +- '<div class="file"></div>' +- '<a class="dl">Download</a>'- row.children[0].textContent = a.platform- row.children[1].textContent = a.file + ' '- var size = document.createElement('span')- size.className = 'size'- size.textContent = '· ' + a.size- row.children[1].appendChild(size)- row.children[2].href = a.url- table.appendChild(row)+ model.alternates.forEach(function (a) {+ var link = el('a', '', a.text + ' →')+ link.href = a.asset.url+ alt.appendChild(link)})- var note = document.createElement('div')- note.className = 'asset-note'- note.textContent = release.prerelease- ? 'Pre-release build. Expect rough edges, and file an issue if something breaks.'- : ''- if (note.textContent) table.appendChild(note)+ if (model.hint) alt.appendChild(el('div', 'hint', model.hint))++ model.groups.forEach(function (g) {+ var section = el('section', 'os-group')+ section.appendChild(el('h3', '', g.label))+ var table = el('div', 'asset-table')+ g.rows.forEach(function (asset) {+ table.appendChild(row(asset))+ })+ section.appendChild(table)+ var notes = el('ul', 'os-notes')+ g.notes.forEach(function (text) {+ notes.appendChild(withCode(el('li'), text))+ })+ section.appendChild(notes)+ groupsEl.appendChild(section)+ })++ if (release.prerelease) {+ groupsEl.appendChild(+ el(+ 'div',+ 'asset-note',+ 'Pre-release build. Expect rough edges, and file an issue if something breaks.'+ )+ )+ }+ }++ if (!D) {+ fallback(true)+ return}- fetch('https://api.github.com/repos/' + REPO + '/releases?per_page=5')- .then(function (r) {+ Promise.all([+ fetch('https://api.github.com/repos/' + REPO + '/releases?per_page=5').then(function (r) {return r.ok ? r.json() : Promise.reject()- })- .then(function (list) {- render(Array.isArray(list) ? list[0] : null)+ }),+ environment()+ ])+ .then(function (results) {+ var list = results[0]+ render(Array.isArray(list) ? list[0] : null, results[1])}).catch(function () {- render(null)+ fallback(true)})})()</script>diff --git a/e2e/downloads.spec.ts b/e2e/downloads.spec.tsnew file mode 100644index 0000000..d331de5--- /dev/null+++ b/e2e/downloads.spec.ts@@ -0,0 +1,496 @@+import { createRequire } from 'node:module'+import { resolve } from 'node:path'+import { _electron as electron, expect, test, type Page } from '@playwright/test'++// M. The download page: what each file is called, which one a visitor is offered, and that the+// page says so. The logic lives in docs/downloads.js; the page is checked by loading the real+// docs/index.html in a hidden window as a visitor with a given browser would see it.++interface Asset {+ os: 'mac' | 'win' | 'linux'+ arch: 'arm64' | 'x64' | 'any'+ kind: string+ title: string+ detail: string+ file: string+ url: string+ recommended: boolean+}+interface Model {+ groups: { os: string; label: string; rows: Asset[]; notes: string[] }[]+ primary: { asset: Asset; title: string; meta: string } | null+ alternates: { text: string; asset: Asset }[]+ hint: string | null+ desktop: boolean+ empty: boolean+}+interface Env {+ os: string+ arch: 'arm64' | 'x64' | null+}+const D = createRequire(__filename)('../docs/downloads.js').PlexoDownloads as {+ describe: (name: string) => Omit<Asset, 'file' | 'url' | 'recommended'> | null+ detectEnvironment: (+ nav: { userAgent: string; platform: string; maxTouchPoints?: number },+ hint?: { architecture: string } | null+ ) => Env+ build: (release: unknown, env: Env) => Model+ markdown: (files: { name: string; size: number; url: string }[], site: string) => string+}++// What a release actually contains (rc.7's file names), plus what electron-builder leaves lying+// around in dist/ that must never be offered.+const SHIPPED = [+ 'plexo-1.0.0-rc.7-arm64.AppImage',+ 'plexo-1.0.0-rc.7-arm64.dmg',+ 'plexo-1.0.0-rc.7-setup.exe',+ 'plexo-1.0.0-rc.7-x64.dmg',+ 'plexo-1.0.0-rc.7-x86_64.AppImage',+ 'plexo_1.0.0-rc.7_amd64.deb',+ 'plexo_1.0.0-rc.7_arm64.deb'+]+const NOISE = [+ 'latest.yml',+ 'latest-mac.yml',+ 'plexo-1.0.0-rc.7-arm64.dmg.blockmap',+ 'plexo-1.0.0-rc.7-setup.exe.blockmap',+ 'plexo_1.0.0-rc.7_amd64.snap',+ 'Plexo-1.0.0-rc.4-arm64-mac.zip'+]+const BASE = 'https://github.com/anmolkapil/plexo/releases/download/v1.0.0-rc.7/'+const release = (names: string[] = [...SHIPPED, ...NOISE]): unknown => ({+ tag_name: 'v1.0.0-rc.7',+ prerelease: true,+ published_at: '2026-09-19T08:34:03Z',+ assets: names.map((name, i) => ({+ name,+ size: (90 + i) * 1048576,+ browser_download_url: BASE + name+ }))+})++// Browsers as they really introduce themselves. Note that Chrome on an Apple silicon Mac still+// says "Intel" in its user agent — only its client hints tell the truth.+const BROWSERS = {+ chromeMac: {+ userAgent:+ 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36',+ platform: 'MacIntel'+ },+ safariMac: {+ userAgent:+ 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Safari/605.1.15',+ platform: 'MacIntel'+ },+ firefoxLinux: {+ userAgent: 'Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0',+ platform: 'Linux x86_64'+ },+ chromeLinuxArm: {+ userAgent:+ 'Mozilla/5.0 (X11; Linux aarch64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36',+ platform: 'Linux aarch64'+ },+ chromeWindows: {+ userAgent:+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36',+ platform: 'Win32'+ },+ iphone: {+ userAgent:+ 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1',+ platform: 'iPhone'+ },+ ipadDesktopMode: {+ userAgent:+ 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Safari/605.1.15',+ platform: 'MacIntel',+ maxTouchPoints: 5+ },+ android: {+ userAgent:+ 'Mozilla/5.0 (Linux; Android 14; Pixel 8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Mobile Safari/537.36',+ platform: 'Linux armv81'+ },+ chromeOs: {+ userAgent:+ 'Mozilla/5.0 (X11; CrOS x86_64 15662.76.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36',+ platform: 'Linux x86_64'+ }+} as const++test.describe('what each file is', () => {+ const expected: Record<string, [string, string, string]> = {+ 'plexo-1.0.0-rc.7-arm64.dmg': ['mac', 'arm64', 'Apple silicon'],+ 'plexo-1.0.0-rc.7-x64.dmg': ['mac', 'x64', 'Intel'],+ 'plexo-1.0.0-rc.7-setup.exe': ['win', 'any', 'Windows 10 and 11'],+ 'plexo-1.0.0-rc.7-x86_64.AppImage': ['linux', 'x64', 'AppImage · x86_64'],+ 'plexo-1.0.0-rc.7-arm64.AppImage': ['linux', 'arm64', 'AppImage · ARM64'],+ 'plexo_1.0.0-rc.7_amd64.deb': ['linux', 'x64', 'Debian / Ubuntu · x86_64'],+ 'plexo_1.0.0-rc.7_arm64.deb': ['linux', 'arm64', 'Debian / Ubuntu · ARM64']+ }++ for (const [file, [os, arch, title]] of Object.entries(expected)) {+ test(`${file} → ${title}`, () => {+ expect(D.describe(file)).toMatchObject({ os, arch, title })+ })+ }++ test('update metadata, blockmaps, snaps and zips are never offered', () => {+ for (const name of NOISE) expect(D.describe(name), name).toBeNull()+ })++ test('a Windows installer with an architecture in its name is described as that one', () => {+ expect(D.describe('plexo-2.0.0-x64-setup.exe')).toMatchObject({+ arch: 'x64',+ title: 'Windows · x64'+ })+ expect(D.describe('plexo-2.0.0-arm64-setup.exe')).toMatchObject({ arch: 'arm64' })+ })+})++test.describe('which browser is on which system', () => {+ const nav = (b: { userAgent: string; platform: string; maxTouchPoints?: number }): typeof b => b++ test('a Mac stays undecided unless the browser says what chip it has', () => {+ expect(D.detectEnvironment(nav(BROWSERS.safariMac))).toEqual({ os: 'mac', arch: null })+ expect(D.detectEnvironment(nav(BROWSERS.chromeMac), null)).toEqual({ os: 'mac', arch: null })+ expect(D.detectEnvironment(nav(BROWSERS.chromeMac), { architecture: 'arm' })).toEqual({+ os: 'mac',+ arch: 'arm64'+ })+ expect(D.detectEnvironment(nav(BROWSERS.chromeMac), { architecture: 'x86' })).toEqual({+ os: 'mac',+ arch: 'x64'+ })+ })++ test('Linux says its architecture in the platform string', () => {+ expect(D.detectEnvironment(nav(BROWSERS.firefoxLinux))).toEqual({ os: 'linux', arch: 'x64' })+ expect(D.detectEnvironment(nav(BROWSERS.chromeLinuxArm))).toEqual({+ os: 'linux',+ arch: 'arm64'+ })+ })++ test('Windows, phones, tablets and Chromebooks', () => {+ expect(D.detectEnvironment(nav(BROWSERS.chromeWindows)).os).toBe('win')+ expect(D.detectEnvironment(nav(BROWSERS.iphone)).os).toBe('mobile')+ expect(D.detectEnvironment(nav(BROWSERS.android)).os).toBe('mobile') // not Linux+ expect(D.detectEnvironment(nav(BROWSERS.ipadDesktopMode)).os).toBe('mobile') // not a Mac+ expect(D.detectEnvironment(nav(BROWSERS.chromeOs)).os).toBe('other') // not Linux+ })+})++test.describe('which download is offered', () => {+ const offered = (env: Env): string | undefined => D.build(release(), env).primary?.asset.file++ test('the right build for every system we can identify', () => {+ expect(offered({ os: 'win', arch: null })).toBe('plexo-1.0.0-rc.7-setup.exe')+ expect(offered({ os: 'mac', arch: 'arm64' })).toBe('plexo-1.0.0-rc.7-arm64.dmg')+ expect(offered({ os: 'mac', arch: 'x64' })).toBe('plexo-1.0.0-rc.7-x64.dmg')+ expect(offered({ os: 'linux', arch: 'x64' })).toBe('plexo-1.0.0-rc.7-x86_64.AppImage')+ expect(offered({ os: 'linux', arch: 'arm64' })).toBe('plexo-1.0.0-rc.7-arm64.AppImage')+ })++ test('an undecided Mac gets Apple silicon, with the Intel build one click away and a hint', () => {+ const model = D.build(release(), { os: 'mac', arch: null })+ expect(model.primary?.asset.arch).toBe('arm64')+ expect(model.alternates.map((a) => a.asset.file)).toEqual(['plexo-1.0.0-rc.7-x64.dmg'])+ expect(model.hint).toMatch(/About This Mac/)+ })++ test('a build for a detected chip is never swapped for the other one', () => {+ for (const arch of ['arm64', 'x64'] as const) {+ for (const os of ['mac', 'linux'] as const) {+ expect(D.build(release(), { os, arch }).primary?.asset.arch).toBe(arch)+ }+ }+ })++ test('Linux offers the .deb beside the AppImage, of the same architecture', () => {+ const arm = D.build(release(), { os: 'linux', arch: 'arm64' })+ expect(arm.alternates.map((a) => a.asset.file)).toEqual(['plexo_1.0.0-rc.7_arm64.deb'])+ const unknown = D.build(release(), { os: 'linux', arch: null })+ expect(unknown.alternates.map((a) => a.asset.file)).toEqual([+ 'plexo_1.0.0-rc.7_amd64.deb',+ 'plexo-1.0.0-rc.7-arm64.AppImage'+ ])+ })++ test('phones and other systems get no download button, and every file is still listed', () => {+ const model = D.build(release(), { os: 'mobile', arch: null })+ expect(model.primary).toBeNull()+ expect(model.desktop).toBe(false)+ expect(model.groups.flatMap((g) => g.rows)).toHaveLength(SHIPPED.length)+ })++ test('a release missing a platform leaves it out, and a Windows-only visitor still gets the installer', () => {+ const windowsOnly = release(['plexo-1.0.0-rc.7-setup.exe'])+ expect(D.build(windowsOnly, { os: 'win', arch: null }).primary?.asset.os).toBe('win')+ expect(D.build(windowsOnly, { os: 'mac', arch: null }).primary).toBeNull()+ expect(D.build(windowsOnly, { os: 'mac', arch: null }).groups.map((g) => g.os)).toEqual(['win'])+ expect(D.build({ assets: [] }, { os: 'win', arch: null }).empty).toBe(true)+ })++ test('grouped by OS, in a fixed order, exactly one row recommended', () => {+ const model = D.build(release(), { os: 'linux', arch: 'x64' })+ expect(model.groups.map((g) => `${g.label}:${g.rows.length}`)).toEqual([+ 'macOS:2',+ 'Windows:1',+ 'Linux:4'+ ])+ expect(model.groups[2].rows.map((r) => r.file)).toEqual([+ 'plexo-1.0.0-rc.7-x86_64.AppImage',+ 'plexo_1.0.0-rc.7_amd64.deb',+ 'plexo-1.0.0-rc.7-arm64.AppImage',+ 'plexo_1.0.0-rc.7_arm64.deb'+ ])+ expect(model.groups.flatMap((g) => g.rows).filter((r) => r.recommended)).toHaveLength(1)+ for (const group of model.groups) expect(group.notes.length).toBeGreaterThan(0)+ })++ test('release notes list every shipped file, once, under its name, and nothing else', () => {+ const files = SHIPPED.concat(NOISE).map((name) => ({+ name,+ size: 100 * 1048576,+ url: BASE + name+ }))+ const text = D.markdown(files, 'https://anmolkapil.github.io/plexo/')+ for (const name of SHIPPED) expect(text.split(BASE + name + ')')).toHaveLength(2)+ for (const name of NOISE) expect(text).not.toContain(name)+ expect(text).toContain('[Apple silicon]')+ expect(text).toContain('https://anmolkapil.github.io/plexo/#downloads')+ })+})++// --- the page itself -----------------------------------------------------------------------++async function openPage(+ browser: { userAgent: string; platform: string; maxTouchPoints?: number },+ options: { architecture?: 'arm' | 'x86'; releases?: unknown; apiStatus?: number } = {}+): Promise<{ page: Page; close: () => Promise<void> }> {+ const app = await electron.launch({+ args: [+ resolve(__dirname, 'page-host/main.cjs'),+ ...(process.platform === 'linux' ? ['--no-sandbox'] : [])+ ],+ env: {+ ...(process.env as Record<string, string>),+ PAGE_SCENARIO: JSON.stringify({+ ...browser,+ architecture: options.architecture,+ apiStatus: options.apiStatus ?? 200,+ releases: options.releases ?? [release()]+ })+ }+ })+ const page = await app.firstWindow()+ await page.waitForFunction(+ () => !document.querySelector('#asset-groups .asset-note')?.textContent?.startsWith('Loading')+ )+ return { page, close: () => app.close() }+}++const alternates = (page: Page): Promise<string[]> =>+ page+ .locator('#cta-alt a')+ .evaluateAll((links) => links.map((a) => `${a.textContent} ${(a as HTMLAnchorElement).href}`))++test.describe('the download page', () => {+ test('Chrome on an Apple silicon Mac: the Apple silicon build, Intel one click away', async () => {+ const { page, close } = await openPage(BROWSERS.chromeMac, { architecture: 'arm' })+ try {+ await expect(page.locator('#primary-title')).toHaveText('Download for macOS')+ await expect(page.locator('#primary-meta')).toContainText('Apple silicon')+ await expect(page.locator('#primary-btn')).toHaveAttribute(+ 'href',+ BASE + 'plexo-1.0.0-rc.7-arm64.dmg'+ )+ expect(await alternates(page)).toEqual([+ `On an Intel Mac? Get the Intel build → ${BASE}plexo-1.0.0-rc.7-x64.dmg`+ ])+ await expect(page.locator('#cta-alt .hint')).toHaveCount(0)+ } finally {+ await close()+ }+ })++ test('Safari on a Mac cannot say what chip it has, so the page says so instead of guessing quietly', async () => {+ const { page, close } = await openPage(BROWSERS.safariMac)+ try {+ await expect(page.locator('#primary-btn')).toHaveAttribute(+ 'href',+ BASE + 'plexo-1.0.0-rc.7-arm64.dmg'+ )+ await expect(page.locator('#cta-alt a')).toHaveText('On an Intel Mac? Get the Intel build →')+ await expect(page.locator('#cta-alt .hint')).toContainText('About This Mac')+ } finally {+ await close()+ }+ })++ test('an Intel Mac that identifies itself gets the Intel build', async () => {+ const { page, close } = await openPage(BROWSERS.chromeMac, { architecture: 'x86' })+ try {+ await expect(page.locator('#primary-btn')).toHaveAttribute(+ 'href',+ BASE + 'plexo-1.0.0-rc.7-x64.dmg'+ )+ await expect(page.locator('#cta-alt a')).toHaveText(+ 'On an Apple silicon Mac? Get the Apple silicon build →'+ )+ } finally {+ await close()+ }+ })++ test('Windows: the one installer, no questions', async () => {+ const { page, close } = await openPage(BROWSERS.chromeWindows)+ try {+ await expect(page.locator('#primary-title')).toHaveText('Download for Windows')+ await expect(page.locator('#primary-meta')).toContainText('Windows 10 and 11')+ await expect(page.locator('#primary-btn')).toHaveAttribute(+ 'href',+ BASE + 'plexo-1.0.0-rc.7-setup.exe'+ )+ await expect(page.locator('#cta-alt a')).toHaveCount(0)+ } finally {+ await close()+ }+ })++ test('Linux x86_64: the AppImage, with the .deb offered', async () => {+ const { page, close } = await openPage(BROWSERS.firefoxLinux)+ try {+ await expect(page.locator('#primary-btn')).toHaveAttribute(+ 'href',+ BASE + 'plexo-1.0.0-rc.7-x86_64.AppImage'+ )+ expect(await alternates(page)).toEqual([+ `On Debian or Ubuntu? Get the .deb → ${BASE}plexo_1.0.0-rc.7_amd64.deb`+ ])+ } finally {+ await close()+ }+ })++ test('Linux ARM64: the ARM64 AppImage, not the x86_64 one', async () => {+ const { page, close } = await openPage(BROWSERS.chromeLinuxArm)+ try {+ await expect(page.locator('#primary-btn')).toHaveAttribute(+ 'href',+ BASE + 'plexo-1.0.0-rc.7-arm64.AppImage'+ )+ } finally {+ await close()+ }+ })++ test('a phone is told this is a desktop app, and can still see every download', async () => {+ const { page, close } = await openPage(BROWSERS.iphone)+ try {+ await expect(page.locator('#primary-title')).toHaveText('Plexo is a desktop app')+ await expect(page.locator('#primary-btn')).toHaveAttribute('href', '#downloads')+ await expect(page.locator('.asset-row')).toHaveCount(SHIPPED.length)+ } finally {+ await close()+ }+ })++ test('every download is listed under its OS with what it is, its size and the right link', async () => {+ const { page, close } = await openPage(BROWSERS.chromeWindows)+ try {+ await expect(page.locator('.os-group h3')).toHaveText(['macOS', 'Windows', 'Linux'])+ await expect(page.locator('.asset-row')).toHaveCount(SHIPPED.length)++ const rows = await page.locator('.asset-row').evaluateAll((els) =>+ els.map((row) => ({+ title: row.querySelector('.platform')?.childNodes[0]?.textContent,+ detail: row.querySelector('.detail')?.textContent,+ file: row.querySelector('.file')?.textContent,+ href: (row.querySelector('a.dl') as HTMLAnchorElement).href+ }))+ )+ expect(rows.map((r) => r.title)).toEqual([+ 'Apple silicon',+ 'Intel',+ 'Windows 10 and 11',+ 'AppImage · x86_64',+ 'Debian / Ubuntu · x86_64',+ 'AppImage · ARM64',+ 'Debian / Ubuntu · ARM64'+ ])+ expect(rows[2].detail).toBe('Installer · x64 and ARM64')+ expect(rows[0].file).toMatch(/plexo-1\.0\.0-rc\.7-arm64\.dmg · \d+(\.\d)? MB/)+ expect(rows.map((r) => r.href.split('/').pop())).toEqual([+ 'plexo-1.0.0-rc.7-arm64.dmg',+ 'plexo-1.0.0-rc.7-x64.dmg',+ 'plexo-1.0.0-rc.7-setup.exe',+ 'plexo-1.0.0-rc.7-x86_64.AppImage',+ 'plexo_1.0.0-rc.7_amd64.deb',+ 'plexo-1.0.0-rc.7-arm64.AppImage',+ 'plexo_1.0.0-rc.7_arm64.deb'+ ])+ // The one meant for this visitor is marked, and only that one.+ await expect(page.locator('.asset-row.recommended')).toHaveCount(1)+ await expect(page.locator('.asset-row.recommended .rec')).toHaveText('FOR YOUR COMPUTER')+ await expect(page.locator('.asset-row.recommended .platform')).toContainText(+ 'Windows 10 and 11'+ )+ } finally {+ await close()+ }+ })++ test('each OS explains its first launch, with commands set apart as code', async () => {+ const { page, close } = await openPage(BROWSERS.chromeWindows)+ try {+ const notes = page.locator('.os-group').nth(0).locator('.os-notes')+ await expect(notes).toContainText('Open Anyway')+ await expect(notes.locator('code').first()).toHaveText(+ 'xattr -dr com.apple.quarantine /Applications/Plexo.app'+ )+ await expect(page.locator('.os-group').nth(1).locator('.os-notes')).toContainText(+ 'Run anyway'+ )+ await expect(page.locator('.os-group').nth(2).locator('.os-notes')).toContainText(+ 'libfuse2t64'+ )+ await expect(page.locator('.os-group').nth(2).locator('.os-notes')).toContainText(+ 'kernel 5.7'+ )+ await expect(page.locator('.asset-note')).toContainText('Pre-release build')+ } finally {+ await close()+ }+ })++ test('a file name cannot inject markup into the page', async () => {+ const hostile = release([+ 'plexo-<img src=x onerror=document.title=1>-x64.dmg',+ 'plexo-1.0.0-setup.exe'+ ])+ const { page, close } = await openPage(BROWSERS.chromeWindows, { releases: [hostile] })+ try {+ await expect(page.locator('.asset-row img')).toHaveCount(0)+ await expect(page.locator('.asset-row').first()).toContainText('<img src=x onerror=')+ } finally {+ await close()+ }+ })++ test('GitHub unreachable: the page falls back to the Releases page', async () => {+ const { page, close } = await openPage(BROWSERS.chromeWindows, { apiStatus: 500 })+ try {+ await expect(page.locator('#primary-title')).toHaveText('View releases on GitHub')+ await expect(page.locator('#asset-groups')).toContainText('Couldn’t load the latest release')+ await expect(page.locator('#primary-btn')).toHaveAttribute(+ 'href',+ 'https://github.com/anmolkapil/plexo/releases'+ )+ } finally {+ await close()+ }+ })+})diff --git a/e2e/page-host/main.cjs b/e2e/page-host/main.cjsnew file mode 100644index 0000000..e4d0abd--- /dev/null+++ b/e2e/page-host/main.cjs@@ -0,0 +1,29 @@+// Opens the real docs/index.html in a hidden window, as a visitor with a given browser would see+// it. The scenario (PAGE_SCENARIO) says what GitHub's API answers and what the browser reports.+const { app, BrowserWindow, session } = require('electron')+const path = require('node:path')++const scenario = JSON.parse(process.env.PAGE_SCENARIO)++app.whenReady().then(async () => {+ session.defaultSession.protocol.handle('https', (request) => {+ if (new URL(request.url).hostname === 'api.github.com') {+ return scenario.apiStatus === 200+ ? Response.json(scenario.releases)+ : new Response('', { status: scenario.apiStatus })+ }+ return new Response('', { status: 404 }) // fonts and anything else: not needed+ })++ const win = new BrowserWindow({+ show: false,+ webPreferences: {+ // The preload has to change what the page's own scripts see.+ contextIsolation: false,+ sandbox: false,+ preload: path.join(__dirname, 'preload.cjs')+ }+ })+ win.webContents.setUserAgent(scenario.userAgent)+ await win.loadFile(path.resolve(__dirname, '../../docs/index.html'))+})diff --git a/e2e/page-host/preload.cjs b/e2e/page-host/preload.cjsnew file mode 100644index 0000000..a49a1d2--- /dev/null+++ b/e2e/page-host/preload.cjs@@ -0,0 +1,12 @@+const scenario = JSON.parse(process.env.PAGE_SCENARIO)+const define = (name, value) => Object.defineProperty(navigator, name, { get: () => value })++define('platform', scenario.platform)+define('maxTouchPoints', scenario.maxTouchPoints ?? 0)+// Chromium answers; Safari and Firefox have no userAgentData at all.+define(+ 'userAgentData',+ scenario.architecture+ ? { getHighEntropyValues: async () => ({ architecture: scenario.architecture }) }+ : undefined+)diff --git a/electron-builder.yml b/electron-builder.ymlindex 141b800..c2869e8 100644--- a/electron-builder.yml+++ b/electron-builder.yml@@ -20,6 +20,8 @@ win:- target: nsisarch: [x64, arm64]nsis:+ # No ${arch} on purpose: one installer holds both x64 and ARM64, and docs/downloads.js reads an+ # installer with no architecture in its name as exactly that. Add one here and update it there.artifactName: ${name}-${version}-setup.${ext}shortcutName: ${productName}uninstallDisplayName: ${productName}diff --git a/eslint.config.mjs b/eslint.config.mjsindex a5a55e4..4806791 100644--- a/eslint.config.mjs+++ b/eslint.config.mjs@@ -34,5 +34,15 @@ export default defineConfig(files: ['e2e/**'],rules: { 'react-hooks/rules-of-hooks': 'off' }},+ {+ // Plain JavaScript that runs as-is — the download page's script, and the CommonJS and ES module+ // scripts that Electron and node load directly — so TypeScript's conventions (return types,+ // import syntax) don't apply.+ files: ['docs/**/*.js', 'e2e/page-host/*.cjs', 'scripts/**/*.mjs'],+ rules: {+ '@typescript-eslint/explicit-function-return-type': 'off',+ '@typescript-eslint/no-require-imports': 'off'+ }+ },eslintConfigPrettier)diff --git a/scripts/release-notes.mjs b/scripts/release-notes.mjsnew file mode 100644index 0000000..6c0c4e7--- /dev/null+++ b/scripts/release-notes.mjs@@ -0,0 +1,51 @@+#!/usr/bin/env node+// Builds a GitHub Release from the files in dist/, so the Releases page describes each file the+// same way the download page does (both use docs/downloads.js).+//+// node scripts/release-notes.mjs v1.0.0-rc.8 [notes.md] the release body: your notes, then the+// downloads table+// node scripts/release-notes.mjs v1.0.0-rc.8 --files the files to upload, one per line+//+// Only files the download page knows how to describe are included, so update metadata, blockmaps+// and anything else electron-builder leaves in dist/ never reach a release.+import { readFileSync, readdirSync, statSync } from 'node:fs'+import { createRequire } from 'node:module'+import { join } from 'node:path'+import { fileURLToPath } from 'node:url'++const { PlexoDownloads: downloads } = createRequire(import.meta.url)('../docs/downloads.js')++const REPO = 'anmolkapil/plexo'+const SITE = 'https://anmolkapil.github.io/plexo/'++const [tag, arg] = process.argv.slice(2)+if (!tag || !/^v\d/.test(tag)) {+ console.error('usage: release-notes.mjs <tag, e.g. v1.0.0-rc.8> [notes.md | --files]')+ process.exit(2)+}++const version = tag.slice(1)+const dist = fileURLToPath(new URL('../dist/', import.meta.url))+const files = readdirSync(dist)+ .filter((name) => name.includes(version) && downloads.describe(name))+ .map((name) => ({+ name,+ path: join(dist, name),+ size: statSync(join(dist, name)).size,+ url: `https://github.com/${REPO}/releases/download/${tag}/${name}`+ }))++if (files.length === 0) {+ console.error(+ `No ${version} builds in dist/ — run the build:mac, build:win and build:linux scripts.`+ )+ process.exit(1)+}++if (arg === '--files') {+ console.log(files.map((file) => file.path).join('\n'))+} else {+ const notes = arg ? readFileSync(arg, 'utf-8').trim() + '\n\n' : ''+ console.log(notes + downloads.markdown(files, SITE))+ console.error(`${files.length} files: ${files.map((file) => file.name).join(', ')}`)+}