ci / rust (push) Successful in 11m30s
ci / typescript (push) Successful in 13m56s
desktop-release / build (--target universal-apple-darwin, dmg,app, darwin-universal, macos) (push) Successful in 18m40s
desktop-release / build (deb,appimage, linux-x86_64, ubuntu-latest) (push) Successful in 33m44s
The window always opens the interface from disk (no download to start, works offline). Each web deploy publishes ui-manifest.json; the app checks it in the background, downloads only the files that changed, verifies every hash and switches on the next start or reload. The installer's copy is the fallback and wins when newer. Claude-Session: https://claude.ai/code/session_01HT6iXLYUUp9pJz5Kza9xCW
33 lines
1.5 KiB
JavaScript
33 lines
1.5 KiB
JavaScript
// Writes dist/ui-manifest.json after `vite build`: every file of the build with its size and SHA-256, the version and
|
|
// when it was built. The desktop app keeps the interface on disk and reads this to download only what changed
|
|
// (apps/desktop/src-tauri/src/ui.rs).
|
|
import { createHash } from "node:crypto";
|
|
import { readdir, readFile, stat, writeFile } from "node:fs/promises";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const NAME = "ui-manifest.json";
|
|
const dist = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../dist");
|
|
|
|
async function walk(dir) {
|
|
const out = [];
|
|
for (const entry of await readdir(dir, { withFileTypes: true })) {
|
|
const full = path.join(dir, entry.name);
|
|
if (entry.isDirectory()) out.push(...(await walk(full)));
|
|
else if (entry.isFile()) out.push(full);
|
|
}
|
|
return out;
|
|
}
|
|
|
|
const files = [];
|
|
for (const full of (await walk(dist)).sort()) {
|
|
const rel = path.relative(dist, full).split(path.sep).join("/");
|
|
if (rel === NAME) continue;
|
|
const bytes = await readFile(full);
|
|
files.push({ path: rel, size: (await stat(full)).size, sha256: createHash("sha256").update(bytes).digest("hex") });
|
|
}
|
|
const content = createHash("sha256").update(files.map((f) => `${f.path}:${f.sha256}`).join("\n")).digest("hex").slice(0, 16);
|
|
const manifest = { version: process.env.VITE_APP_VERSION?.slice(0, 40) || content, builtAt: new Date().toISOString(), files };
|
|
await writeFile(path.join(dist, NAME), JSON.stringify(manifest));
|
|
console.log(`${NAME}: ${files.length} files, version ${manifest.version}`);
|