demo knacksicherer: edition im code + launcher prüft dateien

- edition.json entfällt; die Edition steckt als Marker im Code
  (const BUILD_EDITION). build.ps1 -Demo flippt ihn nur in der gestagten
  Kopie auf 'demo'; die Quelle bleibt 'full'. Keine lösch-/editierbare
  Extra-Datei mehr.
- Launcher: beim Auspacken wird ein Fingerabdruck (SHA-256 über server.js,
  package.json, lib\, public\, tools\) in .ok gespeichert und bei JEDEM
  Start neu geprüft. Wurde im entpackten App-Ordner etwas geändert oder
  gelöscht (z. B. der Demo-Marker zurückgesetzt), wird automatisch das
  Original neu ausgepackt. node_modules/node bleiben aussen vor (gross,
  nicht Teil der Demo-Logik → schneller Start).

Getestet: Marker im entpackten server.js auf 'full' gepatcht → nach
Neustart wieder 'full'->'demo', Server meldet wieder Demo.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 09:47:17 +01:00
parent d9c20fa076
commit ca9bde64f7
3 changed files with 47 additions and 13 deletions

View File

@@ -50,12 +50,14 @@ const HOST = '127.0.0.1'
const PORT = Number(process.env.DASHBOARD_PORT) || 4848
const ALLOWED_HOSTS = new Set([`localhost:${PORT}`, `127.0.0.1:${PORT}`])
// Edition: the demo build ships an edition.json next to this file (build.ps1 -Release -Demo).
// The demo shows at most DEMO_LIMIT projects; everything else works. DASHBOARD_DEMO=1 tests it from source.
const EDITION = (() => { try { return JSON.parse(fs.readFileSync(path.join(__dirname, 'edition.json'), 'utf8').replace(/^\uFEFF/, '')) } catch { return {} } })()
const DEMO = EDITION.demo === true || process.env.DASHBOARD_DEMO === '1'
const DEMO_LIMIT = Number(EDITION.limit) > 0 ? Number(EDITION.limit) : 6
const BUY_URL = typeof EDITION.buyUrl === 'string' && EDITION.buyUrl ? EDITION.buyUrl : 'https://sn09.itch.io/project-dashboard'
// Edition is baked into the code, not a separate file (which anyone could delete). build.ps1 -Demo
// rewrites 'full' -> 'demo' in the staged copy only; the launcher re-checks the unpacked files on every
// start, so editing this back out doesn't stick. DASHBOARD_DEMO=1 tests the demo from the source folder.
// Keep the next line in this exact single-line form \u2013 the build's text replace matches it literally.
const BUILD_EDITION = 'full'
const DEMO = BUILD_EDITION === 'demo' || process.env.DASHBOARD_DEMO === '1'
const DEMO_LIMIT = 6
const BUY_URL = 'https://sn09.itch.io/project-dashboard'
let demoTotal = 0 // all project folders found (the demo shows DEMO_LIMIT of them)
const STATUSES = ['idea', 'active', 'paused', 'done', 'archived']