Files
vpinball/scripts/bump-sw-version.mjs
T
valknarandClaude Sonnet 5 e493a12e68 Add vpinball: a browser Visual Pinball player
Next.js app that plays real .vpx tables via @valknar/vpinball-wasm
(WebAssembly Visual Pinball). Demo mode with the bundled default
table, drag-and-drop custom table upload, a cabinet-styled UI with a
coin-door HUD (fullscreen/stats/info/eject), a custom 404 page, PWA
support (hand-rolled service worker), and a static Docker Compose
deployment behind nginx.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012hQoM3jJT1Lx7CMTciMzvD
2026-08-23 05:25:15 +02:00

22 lines
902 B
JavaScript

#!/usr/bin/env node
// Bumps public/sw.js's CACHE_VERSION so a deploy invalidates old caches —
// run this before cutting a release that changes the app shell or updates
// the vendored vpinball-wasm engine build.
import { readFile, writeFile } from "node:fs/promises";
import path from "node:path";
import { fileURLToPath } from "node:url";
const rootDir = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
const swPath = path.join(rootDir, "public", "sw.js");
const contents = await readFile(swPath, "utf8");
const match = contents.match(/CACHE_VERSION = "v(\d+)"/);
if (!match) {
console.error(`Couldn't find CACHE_VERSION in ${swPath}`);
process.exit(1);
}
const next = Number(match[1]) + 1;
const updated = contents.replace(/CACHE_VERSION = "v\d+"/, `CACHE_VERSION = "v${next}"`);
await writeFile(swPath, updated);
console.log(`Bumped service worker CACHE_VERSION to v${next}`);