diff --git a/build.ps1 b/build.ps1 index 2329267..c2e97d0 100644 --- a/build.ps1 +++ b/build.ps1 @@ -9,8 +9,12 @@ # and asks for the projects folder and the backup target. # # Needs the .NET 8+ SDK (and Node.js on this PC, which is copied into the release exe). -param([switch]$Release) +# +# powershell -ExecutionPolicy Bypass -File build.ps1 -Demo -> release\ProjectDashboard-Demo.exe (+ -Demo-Setup.exe) +# the free demo: at most 6 projects (edition.json in the payload). The full build is not touched. +param([switch]$Release, [switch]$Demo) $ErrorActionPreference = 'Stop' +if ($Demo) { $Release = [switch]$true } $here = $PSScriptRoot $launcher = Join-Path $here 'launcher' $csproj = Join-Path $launcher 'ProjectDashboard.csproj' @@ -69,6 +73,11 @@ Enthaltene Software: - Lucide Icons (ISC) - node_modules\lucide-static\LICENSE "@ +# demo edition: server.js reads edition.json (WriteAllText = UTF-8 without BOM) +if ($Demo) { + [IO.File]::WriteAllText((Join-Path $payload 'edition.json'), '{ "demo": true, "limit": 6, "buyUrl": "https://sn09.itch.io/project-dashboard" }') +} + Write-Host '2/3 Packen ...' if (Test-Path $zip) { Remove-Item $zip -Force } Add-Type -AssemblyName System.IO.Compression.FileSystem @@ -81,7 +90,7 @@ dotnet publish $csproj -c Release -p:Portable=true -o $stage --nologo -v q if ($LASTEXITCODE -ne 0) { throw "dotnet publish failed ($LASTEXITCODE)" } $outDir = Join-Path $here 'release' New-Item -ItemType Directory -Force $outDir | Out-Null -$out = Join-Path $outDir 'ProjectDashboard.exe' +$out = Join-Path $outDir $(if ($Demo) { 'ProjectDashboard-Demo.exe' } else { 'ProjectDashboard.exe' }) Copy-Item (Join-Path $stage 'ProjectDashboard.exe') $out -Force Remove-Item $stage, $payload, $zip -Recurse -Force @@ -95,9 +104,11 @@ $iscc = @("$env:LOCALAPPDATA\Programs\Inno Setup 6\ISCC.exe", "${env:ProgramFile if ($iscc) { Write-Host 'Setup bauen ...' $ver = (Get-Content (Join-Path $here 'package.json') -Raw | ConvertFrom-Json).version - & $iscc /Q "/DAppVer=$ver" (Join-Path $here 'installer\ProjectDashboard.iss') + $isccArgs = @('/Q', "/DAppVer=$ver") + if ($Demo) { $isccArgs += '/DDemo' } + & $iscc @isccArgs (Join-Path $here 'installer\ProjectDashboard.iss') if ($LASTEXITCODE -ne 0) { throw "Inno Setup failed ($LASTEXITCODE)" } - $setup = Join-Path $outDir 'ProjectDashboard-Setup.exe' + $setup = Join-Path $outDir $(if ($Demo) { 'ProjectDashboard-Demo-Setup.exe' } else { 'ProjectDashboard-Setup.exe' }) Write-Host ("-> {0} ({1:N0} MB)" -f $setup, ((Get-Item $setup).Length / 1MB)) } else { Write-Host 'Setup übersprungen: Inno Setup 6 nicht gefunden (winget install JRSoftware.InnoSetup).' diff --git a/installer/ProjectDashboard.iss b/installer/ProjectDashboard.iss index 42b524e..0507b26 100644 --- a/installer/ProjectDashboard.iss +++ b/installer/ProjectDashboard.iss @@ -11,12 +11,23 @@ #endif #define AppName "Project Dashboard" #define AppExe "ProjectDashboard.exe" +; /DDemo (build.ps1 -Demo): same AppId and folder as the full version, so installing the +; full version after buying replaces the demo in place (shortcuts and settings stay) +#ifdef Demo + #define SourceExe "ProjectDashboard-Demo.exe" + #define SetupName "ProjectDashboard-Demo-Setup" + #define ShownName "Project Dashboard (Demo)" +#else + #define SourceExe "ProjectDashboard.exe" + #define SetupName "ProjectDashboard-Setup" + #define ShownName "Project Dashboard" +#endif [Setup] AppId={{6F3C2E9A-4B1D-4E7A-9C55-2D8B0F1A7E31} AppName={#AppName} AppVersion={#AppVer} -AppVerName={#AppName} {#AppVer} +AppVerName={#ShownName} {#AppVer} AppPublisher=Michael Media AppPublisherURL=https://sn09.itch.io/project-dashboard AppSupportURL=https://discord.gg/Ej4JPmCZva @@ -29,10 +40,10 @@ DefaultGroupName={#AppName} DisableProgramGroupPage=yes DisableDirPage=auto OutputDir=..\release -OutputBaseFilename=ProjectDashboard-Setup +OutputBaseFilename={#SetupName} SetupIconFile=..\launcher\app.ico UninstallDisplayIcon={app}\{#AppExe} -UninstallDisplayName={#AppName} +UninstallDisplayName={#ShownName} WizardStyle=modern Compression=lzma2/max SolidCompression=yes @@ -55,7 +66,7 @@ german.DeleteData=Auch deine Einstellungen und Daten löschen (Liste der Projekt Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}" [Files] -Source: "..\release\{#AppExe}"; DestDir: "{app}"; Flags: ignoreversion +Source: "..\release\{#SourceExe}"; DestDir: "{app}"; DestName: "{#AppExe}"; Flags: ignoreversion [Icons] Name: "{group}\{#AppName}"; Filename: "{app}\{#AppExe}" diff --git a/lib/backup.js b/lib/backup.js index 1461145..b4648df 100644 --- a/lib/backup.js +++ b/lib/backup.js @@ -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 } diff --git a/public/app.js b/public/app.js index 7323b42..98cd060 100644 --- a/public/app.js +++ b/public/app.js @@ -250,6 +250,27 @@ let noneShown = false // deliberately no folder shown (dropdown "Keinen anzeig let FEATURES = { itch: false } const itchOn = () => !!FEATURES.itch +// demo edition (server: edition.json): { limit, total, buyUrl } or null in the full version +let DEMO = null +const demoFull = () => !!DEMO && DEMO.total >= DEMO.limit +function renderDemo() { + const on = !!DEMO + document.getElementById('demoBanner').hidden = !on + document.getElementById('spDemo').hidden = !on + document.getElementById('spBuy').hidden = !on + if (!on) return + document.getElementById('demoText').textContent = DEMO.total > DEMO.limit + ? t('demo.banner', { n: DEMO.limit, total: DEMO.total }) + : t('demo.bannerUpTo', { n: DEMO.limit }) + for (const id of ['demoBuy', 'spBuy']) document.getElementById(id).href = DEMO.buyUrl +} +// "New" / "Clone" in the demo once the limit is reached: hint instead of the dialog +function demoBlocksNew() { + if (!demoFull()) return false + toast(t('demo.newBlocked', { n: DEMO.limit }), 'rocket', () => window.open(DEMO.buyUrl, '_blank')) + return true +} + async function load() { const res = await fetch(`/api/projects?target=${encodeURIComponent(curTargetId())}`) const data = await res.json() @@ -265,6 +286,8 @@ async function load() { noneShown = !!data.noneShown document.getElementById('noneBox').hidden = !noneShown FEATURES = data.features ?? { itch: false } + DEMO = data.demo ?? null + renderDemo() document.body.classList.toggle('no-itch', !itchOn()) renderRootPicker() if (editing) editing = projects.find((p) => p.name === editing.name) ?? editing @@ -328,8 +351,8 @@ document.getElementById('nFrom').addEventListener('change', () => { syncNewDlg() }) document.getElementById('nCancel').onclick = () => newDlg.close() -document.getElementById('btnNew').onclick = () => openNewProject('') -document.getElementById('btnClone').onclick = () => { if (editing) openNewProject(editing.name) } +document.getElementById('btnNew').onclick = () => { if (!demoBlocksNew()) openNewProject('') } +document.getElementById('btnClone').onclick = () => { if (editing && !demoBlocksNew()) openNewProject(editing.name) } /* ── rename / move a project ──────────────────────────────────────────── */ @@ -3428,6 +3451,7 @@ function initLang() { try { render() } catch {} try { renderBackupButton() } catch {} try { renderRootPicker() } catch {} + try { renderDemo() } catch {} if (editing) try { openEditor(editing) } catch {} const sp = document.getElementById('spanel') if (sp.classList.contains('open')) { I18N.apply(sp); try { renderAutoStatus() } catch {} } diff --git a/public/index.html b/public/index.html index 1765428..0edd0e0 100644 --- a/public/index.html +++ b/public/index.html @@ -55,6 +55,14 @@ .updbanner[hidden] { display: none; } .updbanner span { flex: 1; min-width: 0; } .updbanner .btn { padding: 5px 12px; } + /* demo edition: slim upsell line under the header */ + .demobanner { display: flex; align-items: center; gap: 10px; padding: 6px 22px; background: var(--surface-2); color: var(--text); font-size: 12.5px; border-top: 1px solid var(--border); } + .demobanner[hidden] { display: none; } + .demobanner > .i { color: var(--accent-text); } + .demobanner span { flex: 1; min-width: 0; } + .demobanner .btn { padding: 4px 11px; font-size: 12.5px; text-decoration: none; } + .about .ver.demo { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; } + .about [hidden] { display: none !important; } .rootpick { position: relative; } #rootBtn { display: flex; align-items: center; gap: 5px; border: none; background: none; padding: 2px 6px; margin: -2px -6px; border-radius: 7px; cursor: pointer; max-width: 260px; } #rootBtn h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } @@ -817,7 +825,7 @@ .about { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); } .about .anm { color: var(--text); font-weight: 600; } .about .ver { font-size: 11px; background: var(--surface-3); color: var(--muted); padding: 1px 7px; border-radius: 9px; } - .about a.btn { margin-left: auto; } + .about a.btn { margin-left: auto; text-decoration: none; } #spanel .pfoot { align-items: center; } #spanel .pfoot .btn { flex: 0 0 auto; padding: 8px 14px; } .spdirty { font-size: 12px; color: var(--yellow); display: flex; align-items: center; gap: 6px; visibility: hidden; } @@ -949,6 +957,11 @@ +
@@ -1270,7 +1283,9 @@ diff --git a/public/lang.js b/public/lang.js index a24fb54..256c6d1 100644 --- a/public/lang.js +++ b/public/lang.js @@ -767,6 +767,11 @@ window.LANG = { 'help.prev': 'Back', 'help.next': 'Next', 'help.show': 'Show me this section', + 'demo.banner': 'Demo – {n} of {total} projects shown. The full version shows all of them.', + 'demo.bannerUpTo': 'Demo version – up to {n} projects.', + 'demo.buy': 'Get the full version', + 'demo.newBlocked': 'The demo is limited to {n} projects – click here to get the full version.', + 'demo.badge': 'Demo', 'help.g.setup': 'Setup', 'tour.setup.welcome': 'Welcome! Let’s set up the dashboard in three short steps: project folders, backup (optional) and general settings. Use “Next” whenever you’re ready.', 'tour.setup.folders': '1 · Project folders – enter the folder that holds your projects (or “Browse…”). Every subfolder becomes a project. You can add several.', @@ -1543,6 +1548,11 @@ window.LANG = { 'help.prev': 'Zurück', 'help.next': 'Weiter', 'help.show': 'Diesen Bereich zeigen', + 'demo.banner': 'Demo – {n} von {total} Projekten sichtbar. Die Vollversion zeigt alle.', + 'demo.bannerUpTo': 'Demo-Version – bis zu {n} Projekte.', + 'demo.buy': 'Vollversion holen', + 'demo.newBlocked': 'Die Demo ist auf {n} Projekte begrenzt – hier klicken für die Vollversion.', + 'demo.badge': 'Demo', 'help.g.setup': 'Einrichten', 'tour.setup.welcome': 'Willkommen! Wir richten das Dashboard in drei kurzen Schritten ein: Projektordner, Backup (optional) und Allgemein. Klick auf „Weiter“, wenn du bereit bist.', 'tour.setup.folders': '1 · Projektordner – trag den Ordner ein, in dem deine Projekte liegen (oder „Durchsuchen…“). Jeder Unterordner wird ein Projekt. Mehrere sind möglich.', diff --git a/server.js b/server.js index dd22ef7..f0a7827 100644 --- a/server.js +++ b/server.js @@ -50,6 +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' +let demoTotal = 0 // all project folders found (the demo shows DEMO_LIMIT of them) + const STATUSES = ['idea', 'active', 'paused', 'done', 'archived'] const PRIORITIES = ['low', 'medium', 'high'] @@ -239,8 +247,13 @@ function projectList() { used.add(key.toLowerCase()) return { key, folder: p.folder, root: p.root, parent: p.parent } }) - projMap = new Map(list.map((p) => [p.key, p])) - return list + demoTotal = list.length + // demo: a fixed set (by name, so touching a project doesn't swap it in) – every view, + // action and the backup only know these, since they all go through projMap + const shown = DEMO ? [...list].sort((a, b) => a.key.localeCompare(b.key, 'de', { sensitivity: 'base' })).slice(0, DEMO_LIMIT) : list + projMap = new Map(shown.map((p) => [p.key, p])) + backup.limitTo(DEMO ? shown.map((p) => ({ root: p.root.path, folder: p.folder })) : null) + return shown } function projectNames() { return projectList().map((p) => p.key) } @@ -415,6 +428,7 @@ app.get('/api/projects', handle(async (req, res) => { setupNeeded: !settings.get().roots.some((r) => fs.existsSync(r.path)), noneShown: !ROOTS.length && !!settings.get().noneShown, projects: list, + demo: DEMO ? { limit: DEMO_LIMIT, total: demoTotal, buyUrl: BUY_URL } : null, totals: { ...storage.totals(list.map((p) => ({ root: ROOTS.find((r) => r.id === p.root)?.path, folder: p.folder }))), noBackup: list.filter((p) => p.git.level === 'red').length }, scan: storage.state, cleanupAvailable: storage.available(), @@ -523,6 +537,8 @@ app.post('/api/roots/active', (req, res) => { app.post('/api/projects/new', handle(async (req, res) => { const s = settings.get() const b = req.body ?? {} + projectList() + if (DEMO && demoTotal >= DEMO_LIMIT) return res.status(403).json({ error: `Demo: maximal ${DEMO_LIMIT} Projekte – für mehr die Vollversion holen: ${BUY_URL}` }) const root = s.roots.find((r) => r.id === (b.root || s.activeRoot)) if (!root || !fs.existsSync(root.path)) return res.status(400).json({ error: 'Projektordner nicht gefunden.' }) let from = null