demo-version: höchstens 6 projekte

- edition.json (nur im Demo-Build) bzw. DASHBOARD_DEMO=1 schaltet die Demo
  ein. projectList() gibt dann fest nach Name die ersten 6 Projekte aus;
  Board, Galerie, Liste, Kennzahlen, Speicher, Aktivität, Details,
  Aktionen, Löschen und Aufräumen kennen damit nur diese 6.
- Backup: robocopy schließt in der Demo alle übrigen Projektordner per
  /XD aus (auch die automatische Sicherung).
- Neu/Klonen: Server lehnt ab Grenze ab, Oberfläche zeigt einen Kauf-Hinweis.
- Demo-Banner "Demo – 6 von N Projekten sichtbar" + "Vollversion holen",
  Demo-Badge und Kauf-Button unter Einstellungen → Über. EN/DE.
- build.ps1 -Demo → release\ProjectDashboard-Demo.exe und
  ProjectDashboard-Demo-Setup.exe; der Installer nutzt dieselbe AppId wie
  die Vollversion, die ihn später am selben Ort ersetzt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-24 22:29:59 +01:00
parent 76aad18646
commit d9c20fa076
7 changed files with 131 additions and 19 deletions

View File

@@ -86,16 +86,41 @@ function config(targetId) {
return { t, excludeDirs: s.backup.excludeDirs, excludeFiles: s.backup.excludeFiles }
}
function baseArgs(cfg) {
// extraXd: full paths to skip as well (demo: the projects it doesn't show)
function baseArgs(cfg, extraXd = []) {
return ['/E', '/FFT', '/XJ', '/R:2', '/W:5', '/COPY:DAT', '/DCOPY:T',
'/XD', ...cfg.excludeDirs, '/XF', ...cfg.excludeFiles]
'/XD', ...cfg.excludeDirs, ...extraXd, '/XF', ...cfg.excludeFiles]
}
// Demo edition: only these projects may be backed up. Map rootPath (lower) -> Set of
// allowed top-level folder names (lower); null = no limit (full version).
let allow = null
function limitTo(list) {
if (!list) { allow = null; return }
allow = new Map()
for (const p of list) {
const r = path.resolve(p.root).toLowerCase()
if (!allow.has(r)) allow.set(r, new Set())
allow.get(r).add(String(p.folder).split(/[\\/]/)[0].toLowerCase())
}
}
// top-level folders of a projects folder that the demo doesn't cover (full paths, for /XD)
function blockedIn(root) {
const ok = allow?.get(path.resolve(root).toLowerCase())
if (!ok) return []
try {
return fs.readdirSync(root, { withFileTypes: true })
.filter((e) => e.isDirectory() && !ok.has(e.name.toLowerCase()))
.map((e) => path.join(root, e.name))
} catch { return [] }
}
// robocopy runs of a job: one per projects folder (the shown ones, or `rootList`),
// or one for a single project
function itemsFor(t, scope, rootList = roots) {
if (scope) return [{ root: scope.root, source: path.join(scope.root, scope.folder), target: path.join(destOf(t, scope.root), scope.folder) }]
return rootList.map((root) => ({ root, source: root, target: destOf(t, root) }))
const list = allow ? rootList.filter((root) => allow.has(path.resolve(root).toLowerCase())) : rootList
return list.map((root) => ({ root, source: root, target: destOf(t, root), xd: allow ? blockedIn(root) : [] }))
}
const stamp = () => new Date().toISOString().slice(0, 16).replace('T', '_').replace(':', '-')
@@ -193,7 +218,7 @@ function check(scope = null, autoCopy = false, targetId = null, opts = {}) {
fs.mkdirSync(it.target, { recursive: true })
const checkLog = path.join(logDir, `pruefung-${stamp()}-${cfg.t.id}${slug(scope?.folder ?? (items.length > 1 ? path.basename(it.root) : ''))}.log`)
const src = it.source
const rc = await robocopy([src, it.target, ...baseArgs(cfg), '/L', '/X', '/NJH', '/NJS', '/NDL', '/NP', '/FP', '/BYTES'], checkLog, (line) => {
const rc = await robocopy([src, it.target, ...baseArgs(cfg, it.xd), '/L', '/X', '/NJH', '/NJS', '/NDL', '/NP', '/FP', '/BYTES'], checkLog, (line) => {
const p = parseLine(line)
if (!p) return
if (p.cls.includes('EXTRA')) { extra.n++; extra.b += p.size; return }
@@ -246,7 +271,7 @@ function startCopy() {
const log = path.join(logDir, `backup-${stamp()}-${cfg.t.id}${slug(scope?.folder ?? (items.length > 1 ? path.basename(it.root) : ''))}.log`)
const failed = new Set() // project folders with copy errors
const before = { files: state.progress.files, bytes: state.progress.bytes }
const rc = await robocopy([it.source, it.target, ...baseArgs(cfg), '/MT:16', '/NJH', '/NDL', '/NP', '/FP', '/BYTES'], log, (line) => {
const rc = await robocopy([it.source, it.target, ...baseArgs(cfg, it.xd), '/MT:16', '/NJH', '/NDL', '/NP', '/FP', '/BYTES'], log, (line) => {
const err = line.match(ERR_RE)
if (err) { const pr = projectOfPath(err[1].trim(), it.source, it.target, scope?.folder); if (pr) failed.add(pr); return }
const p = parseLine(line)
@@ -346,4 +371,4 @@ function getState() {
return { ...state, source: roots.join(' + '), targets: list }
}
module.exports = { init, check, copy, cancel, getState, lastFor, lastOnAllTargets, busy }
module.exports = { init, check, copy, cancel, getState, lastFor, lastOnAllTargets, busy, limitTo }