Desktop D5: one desktop version (package.json desktopVersion) checked in CI; updater public key; NSIS per user with the WebView2 bootstrapper

This commit is contained in:
CRTkafa 2026-10-10 21:16:59 +00:00
parent fa6215ebbe
commit 32c7f5a16b
4 changed files with 85 additions and 2 deletions

View file

@ -2,7 +2,7 @@
"$schema": "https://schema.tauri.app/config/2",
"productName": "storebound",
"mainBinaryName": "storebound-desktop",
"version": "../package.json",
"version": "0.1.0",
"identifier": "dev.storebound.desktop",
"build": {
"frontendDist": "../dist",
@ -69,6 +69,13 @@
],
"macOS": {
"minimumSystemVersion": "11.0"
},
"windows": {
"webviewInstallMode": { "type": "embedBootstrapper" },
"nsis": { "installMode": "currentUser" }
},
"linux": {
"deb": { "section": "devel" }
}
},
"plugins": {
@ -79,7 +86,7 @@
},
"updater": {
"endpoints": ["https://storebound.dev/desktop/latest.json"],
"pubkey": "PLACEHOLDER-minisign-public-key-set-in-D5"
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDQ0Rjc4QTc4RDlFRjM4MkEKUldRcU9PL1plSXIzUkJtb2x0L2Z4MTA4bTg5UU5FVW5kUlRGcnVjangwQ0JNb2VGYjcveGhydlcK"
}
}
}

View file

@ -1,6 +1,7 @@
{
"name": "storebound",
"version": "0.5.0",
"desktopVersion": "0.1.0",
"description": "Take a mobile app or game from nothing to Submit for review on Google Play and the App Store: app records, listings in every language, in-app products and subscriptions with regional prices, every store questionnaire (incl. account deletion and App Review demo accounts), privacy, icons, screenshots and previews, TestFlight. After launch: crash vitals, review replies, price sheets, analytics and Product Page Optimization. One config, a Bun CLI, an MCP server and Agent Skills for your AI coding agent.",
"license": "MIT",
"author": "CRTkafa",

View file

@ -10,6 +10,8 @@ const tauri = join(root, 'apps/desktop/src-tauri');
const cargo = process.env.STOREBOUND_CI_RUST === '0' ? null : Bun.which('cargo');
const steps: [string, string[], string?][] = [
['adapters', ['bun', 'tools/gen-adapters.ts', '--check']],
// one desktop version: package.json desktopVersion = apps/desktop/package.json = tauri.conf.json = Cargo.toml / .lock
['desktop version', ['bun', 'tools/desktop-version.ts']],
['tests', ['bun', 'test']],
['typecheck', ['bunx', 'tsc', '--noEmit']],
['desktop i18n', ['bun', 'tools/i18n-check.ts']],

73
tools/desktop-version.ts Normal file
View file

@ -0,0 +1,73 @@
#!/usr/bin/env bun
// One version for the desktop app. The authority is `desktopVersion` in the root package.json (the npm package's
// own `version` is the CLI's and moves on its own); it is copied into apps/desktop/package.json,
// src-tauri/tauri.conf.json, src-tauri/Cargo.toml and the app's entry in src-tauri/Cargo.lock.
// bun tools/desktop-version.ts check: exit 1 when any copy drifted (CI runs this)
// bun tools/desktop-version.ts --set 0.1.1 write the new version into the authority and every copy
// bun tools/desktop-version.ts --print print the version
import { readFileSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';
export const ROOT = join(import.meta.dir, '..');
const TAURI = 'apps/desktop/src-tauri';
export const SEMVER = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
export interface Copy { file: string; read(text: string): string | null; write(text: string, v: string): string }
const jsonVersion = (key: string): Pick<Copy, 'read' | 'write'> => ({
read: t => { const v = (JSON.parse(t) as Record<string, unknown>)[key]; return typeof v === 'string' ? v : null; },
write: (t, v) => t.replace(new RegExp(`("${key}"\\s*:\\s*)"[^"]*"`), `$1"${v}"`),
});
/** The authority first, then every copy. */
export const COPIES: Copy[] = [
{ file: 'package.json', ...jsonVersion('desktopVersion') },
{ file: 'apps/desktop/package.json', ...jsonVersion('version') },
{ file: `${TAURI}/tauri.conf.json`, ...jsonVersion('version') },
{
file: `${TAURI}/Cargo.toml`,
// the [package] table's version (the first `version =` line of the file, before any dependency table)
read: t => /^\[package\][^[]*?^version\s*=\s*"([^"]+)"/ms.exec(t)?.[1] ?? null,
write: (t, v) => t.replace(/^(\[package\][^[]*?^version\s*=\s*)"[^"]+"/ms, `$1"${v}"`),
},
{
file: `${TAURI}/Cargo.lock`,
read: t => /^name = "storebound-desktop"\nversion = "([^"]+)"/m.exec(t)?.[1] ?? null,
write: (t, v) => t.replace(/^(name = "storebound-desktop"\nversion = )"[^"]+"/m, `$1"${v}"`),
},
];
export interface Drift { file: string; found: string | null }
export function versions(root = ROOT): { version: string | null; drift: Drift[] } {
const [authority, ...copies] = COPIES.map(c => ({ file: c.file, found: c.read(readFileSync(join(root, c.file), 'utf8')) }));
const version = authority!.found;
return { version, drift: copies.filter(c => c.found !== version) };
}
export function setVersion(v: string, root = ROOT): void {
if (!SEMVER.test(v)) throw new Error(`not a version: ${v}`);
for (const c of COPIES) {
const p = join(root, c.file);
const before = readFileSync(p, 'utf8');
const after = c.write(before, v);
if (c.read(after) !== v) throw new Error(`could not set the version in ${c.file}`);
if (after !== before) writeFileSync(p, after);
}
}
if (import.meta.main) {
const argv = process.argv.slice(2);
const i = argv.indexOf('--set');
if (i >= 0) {
setVersion(argv[i + 1] ?? '');
console.log(`desktop version ${argv[i + 1]} written to ${COPIES.map(c => c.file).join(', ')}`);
process.exit(0);
}
const { version, drift } = versions();
if (argv.includes('--print')) { console.log(version ?? ''); process.exit(version ? 0 : 1); }
if (!version || !SEMVER.test(version)) { console.error('desktop version: package.json has no valid "desktopVersion"'); process.exit(1); }
for (const d of drift) console.error(`desktop version drift: ${d.file} has ${d.found ?? 'no version'}, package.json desktopVersion is ${version}`);
if (drift.length) { console.error('fix: bun tools/desktop-version.ts --set ' + version); process.exit(1); }
console.log(`desktop version ${version}: ${COPIES.length - 1} copies match`);
}