unterordner scanner

This commit is contained in:
2026-11-12 20:23:53 +01:00
parent 7824ddb6dc
commit 0a38884eac
8 changed files with 390 additions and 32 deletions

View File

@@ -77,6 +77,18 @@ Oben links neben dem Logo ist ein Auswahlmenü:
Sind mehrere Ordner sichtbar, steht auf jeder Karte, aus welchem sie stammt.
### Projekte in Unterordnern
Liegen Projekte eine Ebene tiefer (z. B. `Arduino Projekte\KlopfSchloss`, `Arduino Projekte\MusikBox`), findet sie
der Scanner: Ordner-Menü oben → **Projekte in Unterordnern suchen…** oder Einstellungen → Projektordner.
- Gesucht wird in **Sammelordnern** – Ordnern ohne eigene Projekt-Kennzeichen (kein `.git`, README, `package.json`,
`.sln`, `.ino` …), bis drei Ebenen tief. Neue Funde sind vorangekreuzt.
- **Auch in Projekten suchen** zeigt zusätzlich eigenständige Teile echter Projekte (z. B. `Tools\DownloaderTool`
mit eigener `.csproj`) – nicht vorangekreuzt, weil sie meist zum Projekt gehören.
- **Übernehmen:** Angekreuzte Ordner erscheinen als eigene Projekte (die Karte zeigt den Elternordner), ein reiner
Sammelordner wird ausgeblendet. Alles andere – Bearbeiten, Starten, Git, Backup, Aufräumen, Umbenennen –
funktioniert wie bei jedem Projekt. Auf der Platte ändert sich nichts.
- Gibt es neue Funde, die du noch nicht angesehen hast, erscheint einmal pro Sitzung ein Hinweis.
### Backup
Knopf **Backup** oben:
1. **Prüfen, was neu ist** – zeigt neue und geänderte Dateien pro Projekt.
@@ -219,6 +231,7 @@ Liegt das Dashboard in `<Projekte>\_Tools\ProjectDashboard`, wird `<Projekte>` a
| `lib\storage.js` | Größen-Scan mit Ordner-Aufteilung (Treemap) und Aufräumen über `cleanup.ps1` |
| `lib\scheduler.js` | Automatisches Backup nach Zeitplan (Stand in `auto-backup.json` im Datenordner) |
| `lib\archive.js` | Release-ZIP nach `<Projekt>\releases` (über `tar.exe` von Windows) |
| `lib\nested.js` | Scanner für Projekte in Unterordnern (Sammelordner, Kennzeichen, Hinweis) |
| `lib\itchpack.js` | itch.io-Paket (`docs\itchio`) lesen, Bilder ausliefern, Claude Code mit Skill `itchiocreater` starten |
| `lib\create.js` | Neu, Klonen, Umbenennen/Verschieben |
| `lib\git.js` · `lib\tech.js` · `lib\icons.js` | Git-Status, Technik-Erkennung + Aktionen, App-Icons |

View File

@@ -305,7 +305,8 @@ function lastFor(root, folder, targetId) {
else if (d.last) {
if (!Array.isArray(d.last.failed) && d.last.log) d.last.failed = failedFromLog(d.last.log, root, destOf(t, root)) ?? undefined
if (Array.isArray(d.last.failed)) {
full = d.last.failed.includes(folder)
// failed lists top-level folders; a project in a subfolder counts by its top folder
full = d.last.failed.includes(folder) || d.last.failed.includes(folder.split(path.sep)[0])
? { at: d.last.at, ok: false, how: 'Komplett-Backup – Fehler in diesem Projekt' }
: { at: d.last.at, ok: true, how: 'Komplett-Backup' }
}

116
lib/nested.js Normal file
View File

@@ -0,0 +1,116 @@
// Projects in subfolders: finds project folders below a projects folder's direct
// children, so they can be shown as projects of their own (chosen in the UI,
// stored per projects folder in settings: roots[].nested / nestedIgnored).
// - "collection" folders (no project markers themselves, e.g. "Arduino Projekte")
// are searched up to MAX_DEPTH; a hit is not searched further
// - deep: also sub-projects inside real projects (mostly parts of them, so the
// UI never preselects these)
const fs = require('fs')
const path = require('path')
const MAX_DEPTH = 3
const SKIP = new Set(['node_modules', 'library', 'temp', 'obj', 'bin', 'build', 'builds', 'dist', 'out', '.git', '.venv', 'venv', '__pycache__', 'packages', 'releases', 'docs', 'itchio', 'sprite-generator', 'spritegenerator'])
const STRONG = new Set(['git', 'dashboard', 'Unity', '.NET-sln', 'Unreal', 'Flutter'])
const APPS = new Set(['.NET', 'Node', 'Gradle', 'Flutter', 'Python', 'HTML', 'Arduino'])
const NOT_PROJECTS = new Set(['project-dashboard', '$recycle.bin', 'system volume information', 'recovery', 'config.msi'])
function ls(dir) {
try { return fs.readdirSync(dir, { withFileTypes: true }) } catch { return [] }
}
// project markers on the folder's own level (cheap: one readdir)
function markers(dir) {
const entries = ls(dir)
const names = new Set(entries.map((e) => e.name.toLowerCase()))
const files = entries.filter((e) => e.isFile()).map((e) => e.name.toLowerCase())
const m = []
if (names.has('.git')) m.push('git')
if (names.has('.dashboard.json')) m.push('dashboard')
if (names.has('assets') && names.has('projectsettings')) m.push('Unity')
if (names.has('package.json')) m.push('Node')
if (files.some((f) => f.endsWith('.sln'))) m.push('.NET-sln')
else if (files.some((f) => f.endsWith('.csproj'))) m.push('.NET')
if (names.has('pubspec.yaml')) m.push('Flutter')
if (names.has('build.gradle') || names.has('build.gradle.kts')) m.push('Gradle')
if (names.has('cmakelists.txt')) m.push('CMake')
if (names.has('platformio.ini') || files.some((f) => f.endsWith('.ino'))) m.push('Arduino')
if (names.has('cargo.toml')) m.push('Rust')
if (names.has('go.mod')) m.push('Go')
if (files.some((f) => f.endsWith('.py'))) m.push('Python')
if (names.has('index.html')) m.push('HTML')
if (files.some((f) => f.endsWith('.uproject'))) m.push('Unreal')
if (names.has('readme.md') || names.has('claude.md')) m.push('README')
return m
}
const isProject = (dir) => markers(dir).length > 0
const subdirs = (dir) => ls(dir).filter((e) => e.isDirectory() && !e.name.startsWith('.') && !SKIP.has(e.name.toLowerCase()))
// projects below `dir` (not `dir` itself), relative to `base`
function findBelow(base, dir, depth, maxDepth, out) {
if (depth > maxDepth) return
for (const e of subdirs(dir)) {
const full = path.join(dir, e.name)
const m = markers(full)
if (m.length) { out.push({ rel: path.relative(base, full), markers: m, depth }); continue }
findBelow(base, full, depth + 1, maxDepth, out)
}
}
// { containers: [{ rel, projects: [{ rel, markers }] }], inProjects: [{ rel, markers, parent }] }
function scan(rootPath, { deep = false } = {}) {
const containers = []
const inProjects = []
for (const e of ls(rootPath)) {
if (!e.isDirectory() || e.name.startsWith('.') || NOT_PROJECTS.has(e.name.toLowerCase()) || e.name === '_Tools') continue
const dir = path.join(rootPath, e.name)
if (!isProject(dir)) {
const found = []
findBelow(rootPath, dir, 1, MAX_DEPTH, found)
if (found.length) containers.push({ rel: e.name, projects: found.map(({ rel, markers }) => ({ rel, markers })) })
} else if (deep) {
// inside a real project almost every folder has some marker (Engine\CMakeLists,
// tools\*.py ...): only count what looks like a project of its own
const found = []
findBelow(rootPath, dir, 1, 2, found)
// (a solution, a repo ...), or an app one folder deeper, e.g. Tools\DownloaderTool
for (const f of found) {
if (f.markers.some((m) => STRONG.has(m)) || (f.depth >= 2 && f.markers.some((m) => APPS.has(m)))) inProjects.push({ rel: f.rel, markers: f.markers, parent: e.name })
}
}
}
return { containers, inProjects }
}
// "Arduino Projekte\KlopfSchloss" - normalised, inside the root, 2..MAX_DEPTH+1 levels, or null
function cleanRel(rootPath, rel) {
if (typeof rel !== 'string' || !rel.trim()) return null
const norm = path.normalize(rel.trim()).replace(/^[\\/]+|[\\/]+$/g, '')
const parts = norm.split(path.sep)
if (parts.length < 2 || parts.length > MAX_DEPTH + 1 || parts.some((x) => !x || x === '.' || x === '..')) return null
const full = path.resolve(rootPath, norm)
if (!full.toLowerCase().startsWith(path.resolve(rootPath).toLowerCase() + path.sep)) return null
return norm
}
// how many collection-folder finds are neither chosen nor dismissed (cached)
const hintCache = new Map()
function hint(roots) {
let n = 0
for (const r of roots) {
const key = `${r.path}|${(r.nested ?? []).join('|')}|${(r.nestedIgnored ?? []).join('|')}`
let c = hintCache.get(r.path)
if (!c || c.key !== key || Date.now() - c.at > 5 * 60 * 1000) {
const known = new Set([...(r.nested ?? []), ...(r.nestedIgnored ?? [])].map((x) => x.toLowerCase()))
let count = 0
try { for (const k of scan(r.path).containers) for (const p of k.projects) if (!known.has(p.rel.toLowerCase())) count++ } catch {}
c = { key, at: Date.now(), count }
hintCache.set(r.path, c)
}
n += c.count
}
return n
}
const forgetHint = () => hintCache.clear()
module.exports = { scan, markers, isProject, cleanRel, hint, forgetHint, MAX_DEPTH }

View File

@@ -87,6 +87,21 @@ function cleanAuto(a, old) {
let current = null
// projects in subfolders: { nested: chosen relative paths, nestedIgnored: seen, not chosen }
function nestedOf(r) {
const list = (v) => (Array.isArray(v) ? [...new Set(v.filter((x) => typeof x === 'string' && x && !x.split(/[\\/]/).includes('..')))].slice(0, 200) : [])
return { nested: list(r?.nested), nestedIgnored: list(r?.nestedIgnored) }
}
// Stores the scanner's choice for one projects folder (paths already checked by lib/nested.js).
function setNested(rootId, chosen, ignored) {
const s = get()
const roots = s.roots.map((r) => (r.id === rootId ? { ...r, ...nestedOf({ nested: chosen, nestedIgnored: ignored }) } : r))
current = { ...s, roots }
persist(current)
return current
}
function load() {
const d = defaults()
const saved = process.env.DASHBOARD_ROOT && !process.env.DASHBOARD_DATA ? null : readJson(FILE)
@@ -96,10 +111,13 @@ function load() {
backup.auto = cleanAuto(saved?.backup?.auto)
// older settings had one "projectsRoot"
let roots = Array.isArray(saved?.roots)
? saved.roots.filter((r) => r && typeof r.path === 'string' && r.path).map((r) => ({ id: String(r.id || newId()), name: String(r.name || rootName(r.path)), path: r.path }))
? saved.roots.filter((r) => r && typeof r.path === 'string' && r.path).map((r) => ({ id: String(r.id || newId()), name: String(r.name || rootName(r.path)), path: r.path, ...nestedOf(r) }))
: typeof saved?.projectsRoot === 'string' ? rootsFrom(saved.projectsRoot) : d.roots
// an explicit DASHBOARD_ROOT always wins (tests)
if (process.env.DASHBOARD_ROOT) roots = [{ id: 'env', name: rootName(path.resolve(process.env.DASHBOARD_ROOT)), path: path.resolve(process.env.DASHBOARD_ROOT) }]
if (process.env.DASHBOARD_ROOT) {
const envPath = path.resolve(process.env.DASHBOARD_ROOT)
roots = [{ id: 'env', name: rootName(envPath), path: envPath, ...nestedOf(roots.find((r) => samePath(r.path, envPath))) }]
}
current = withActive({
roots,
activeRoots: Array.isArray(saved?.activeRoots) ? saved.activeRoots : [saved?.activeRoot],
@@ -177,6 +195,8 @@ function save(input) {
id: old && samePath(old.path, p) ? old.id : newId(),
name: String(r.name ?? '').trim().slice(0, 40) || rootName(p),
path: p,
// projects in subfolders (chosen in the scanner) stay with the folder
...nestedOf(old && samePath(old.path, p) ? old : s.roots.find((x) => samePath(x.path, p))),
})
// a selected folder stays selected even if its path (and so its id) changed
if (r.id) renamed.set(String(r.id), roots.at(-1).id)
@@ -302,4 +322,4 @@ function subfolders(dir) {
return { path: p, folders: list.slice(0, 200) }
}
module.exports = { get, load, save, setActive, addRoots, activeRootList, subfolders, backupSubdir, configured, targetName, DATA_DIR, APP_DIR, DEFAULT_EXCLUDE_DIRS }
module.exports = { setNested, get, load, save, setActive, addRoots, activeRootList, subfolders, backupSubdir, configured, targetName, DATA_DIR, APP_DIR, DEFAULT_EXCLUDE_DIRS }

View File

@@ -57,8 +57,16 @@ function scriptFor(root) {
function available() { return true }
const cleanupAvailable = () => !!scriptFor(roots[0])
function psArgs(root, extra) {
return ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', scriptFor(root), '-Root', root, ...extra, '-Json']
// effRoot: the folder cleanup.ps1 treats as its root - for a project in a subfolder
// ("Sammel\A") its parent folder, because the script only knows direct children
function psArgs(root, extra, effRoot = root) {
return ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', scriptFor(root), '-Root', effRoot, ...extra, '-Json']
}
// { effRoot, project, prefix } for cleanup.ps1; prefix turns its paths into "<folder>\..."
function scriptTarget(root, folder) {
const parent = path.dirname(folder)
if (parent === '.' || !parent) return { effRoot: root, project: folder, prefix: '' }
return { effRoot: path.join(root, parent), project: path.basename(folder), prefix: parent + path.sep }
}
function parseJson(stdout) {
@@ -125,11 +133,12 @@ async function sizeTree(dir) {
async function scanProject(root, folder) {
const dir = path.join(root, folder)
const st = scriptTarget(root, folder)
const [split, cand] = await Promise.all([
sizeTree(dir),
scriptFor(root) ? run('powershell.exe', psArgs(root, ['-Project', folder, '-Tier', ALL_TIERS]), { timeout: 10 * 60 * 1000 }) : null,
scriptFor(root) ? run('powershell.exe', psArgs(root, ['-Project', st.project, '-Tier', ALL_TIERS], st.effRoot), { timeout: 10 * 60 * 1000 }) : null,
])
const candidates = cand ? parseJson(cand.stdout) : []
const candidates = (cand ? parseJson(cand.stdout) : []).map((c) => (st.prefix && typeof c.Path === 'string' ? { ...c, Path: st.prefix + c.Path } : c))
const deletable = { Cache: 0, Release: 0, Output: 0 }
for (const c of candidates) if (!c.Skip) deletable[c.Tier] += c.MB
const d = (all[rootKey(root)] ??= {})
@@ -159,7 +168,9 @@ async function clean(root, folder, paths) {
const only = paths.filter((p) => typeof p === 'string' && p.startsWith(prefix) && !p.includes('|'))
if (!only.length) throw new Error('nichts ausgewählt')
if (!scriptFor(root)) throw new Error('cleanup.ps1 nicht gefunden')
const r = await run('powershell.exe', psArgs(root, ['-Project', folder, '-Tier', ALL_TIERS, '-Only', only.join('|'), '-Apply']), { timeout: 30 * 60 * 1000 })
const st = scriptTarget(root, folder)
const rel = only.map((p) => p.slice(st.prefix.length))
const r = await run('powershell.exe', psArgs(root, ['-Project', st.project, '-Tier', ALL_TIERS, '-Only', rel.join('|'), '-Apply'], st.effRoot), { timeout: 30 * 60 * 1000 })
const result = parseJson(r.stdout)
await scanProject(root, folder)
return result

View File

@@ -169,10 +169,14 @@ function prioHtml(prio) {
}
// Which projects folder a project is from - only shown when several are on screen.
// A project from a subfolder (scanner) also names the folder it lies in.
function rootTag(p, short = false) {
if (!multiRoot() || !p.rootName) return ''
const parent = p.parent
? `<span class="rtag ptag" title="Liegt im Unterordner: ${escapeHtml(p.parent)}">${ic('folder-tree', 'sm')}${short ? '' : ' '}${escapeHtml(p.parent.split('\\').pop())}</span>`
: ''
if (!multiRoot() || !p.rootName) return parent
const path = roots.find((r) => r.id === p.root)?.path ?? ''
return `<span class="rtag" title="Projektordner: ${escapeHtml(p.rootName)}${path ? ` (${escapeHtml(path)})` : ''}">${ic('folder', 'sm')}${short ? '' : ' '}${escapeHtml(p.rootName)}</span>`
return `<span class="rtag" title="Projektordner: ${escapeHtml(p.rootName)}${path ? ` (${escapeHtml(path)})` : ''}">${ic('folder', 'sm')}${short ? '' : ' '}${escapeHtml(p.rootName)}</span>${parent}`
}
function techChips(types) {
@@ -220,6 +224,11 @@ async function load() {
clearTimeout(load.again)
if (data.activityPending > 0) load.again = setTimeout(load, 2500)
if (data.setupNeeded) openSettings(true) // first start: choose the projects folder
// projects found in subfolders that were never looked at: one hint per session
if (data.nestedHint > 0 && !load.nestedHinted && !data.setupNeeded) {
load.nestedHinted = true
setTimeout(() => toast(`${data.nestedHint} ${data.nestedHint === 1 ? 'Projekt' : 'Projekte'} in Unterordnern gefunden – Klick zum Ansehen`, 'folder-tree', openNested), 1500)
}
}
/* ── new project / clone ──────────────────────────────────────────────── */
@@ -371,6 +380,7 @@ function renderRootPicker() {
`${roots.length ? '<div class="sep"></div>' : ''}` +
(hasPicker ? `<button type="button" data-root-add><span class="chk">${ic('folder-plus', 'sm')}</span>Ordner hinzufügen…</button>` : '') +
`<button type="button" data-root-import><span class="chk">${ic('folders', 'sm')}</span>Mehrere Ordner einlesen…</button>
<button type="button" data-root-nested><span class="chk">${ic('folder-tree', 'sm')}</span>Projekte in Unterordnern suchen…</button>
<button type="button" data-root-manage><span class="chk">${ic('settings', 'sm')}</span>Projektordner verwalten…</button>`
}
@@ -466,6 +476,7 @@ rootMenu.addEventListener('click', (e) => {
if (b.hasAttribute('data-root-manage')) { toggleRootMenu(false); openSettings(false); return }
if (b.hasAttribute('data-root-add')) { toggleRootMenu(false); addRootByPicker(); return }
if (b.hasAttribute('data-root-import')) { toggleRootMenu(false); openRootImport(); return }
if (b.hasAttribute('data-root-nested')) { toggleRootMenu(false); openNested(); return }
if (b.hasAttribute('data-root-all')) { showRoots(roots.map((r) => r.id)); return }
const t = b.dataset.rootToggle
if (t) {
@@ -957,12 +968,16 @@ async function patchProject(name, body) {
return res.ok
}
function toast(text, icon = 'info') {
// onClick: the toast becomes clickable (and stays a bit longer)
function toast(text, icon = 'info', onClick = null) {
const el = document.getElementById('toast')
el.innerHTML = `${ic(icon)}<span>${escapeHtml(text)}</span>`
el.classList.add('show')
el.style.pointerEvents = onClick ? 'auto' : ''
el.style.cursor = onClick ? 'pointer' : ''
el.onclick = onClick ? () => { el.classList.remove('show'); onClick() } : null
clearTimeout(toast.t)
toast.t = setTimeout(() => el.classList.remove('show'), 3400)
toast.t = setTimeout(() => el.classList.remove('show'), onClick ? 8000 : 3400)
}
const runAction = async (name, id) => {
@@ -1173,7 +1188,7 @@ function cardHtml(p) {
${p.lastCommit ? `<div class="commit" title="${escapeHtml(p.lastCommit.message)}">${ic('git-commit-horizontal', 'sm')}<span>${escapeHtml(p.lastCommit.message)}</span></div>` : ''}
${factsHtml(p)}
<div class="row2">${gitHtml(p.git)}${cloudChip(p)}${pubChip(p)}</div>
${multiRoot() ? `<div class="rootline">${rootTag(p)}</div>` : ''}
${multiRoot() || p.parent ? `<div class="rootline">${rootTag(p)}</div>` : ''}
<div class="chips">${techChips(p.tech?.types)}${warnChips(p)}${tags}</div>
${p.notes ? `<div class="notes">${escapeHtml(p.notes)}</div>` : ''}
${total ? `<div class="taskbar">${ic('list-checks', 'sm')}<span>${done}/${total}</span><div class="bar"><div style="width:${Math.round((done / total) * 100)}%"></div></div></div>` : ''}`
@@ -1722,7 +1737,7 @@ function renderHogs() {
<tbody>${rows.map((r) => `<tr data-k="${escapeHtml(keyOf(r))}">
${can ? `<td><input type="checkbox" ${stSelected.has(keyOf(r)) ? 'checked' : ''} aria-label="Auswählen"></td>` : ''}
<td>${escapeHtml(r.p.name)}</td>
<td class="path">${escapeHtml(inProject(r.path))}</td>
<td class="path">${escapeHtml(inProject(r.path, r.p.folder))}</td>
<td><span class="sttier" title="${TIER[r.tier]?.hint ?? ''}"><i style="background:${tierVar(r.tier)}"></i>${TIER_SHORT[r.tier]}</span></td>
<td class="num">${fmtMB1(r.mb)}</td></tr>`).join('')}</tbody>`
: '<tbody><tr><td class="hint">Nichts zum Aufräumen gefunden (oder noch nicht gemessen).</td></tr></tbody>'
@@ -1747,7 +1762,7 @@ document.getElementById('stDelete').onclick = async () => {
const sel = (renderHogs.rows ?? []).filter((r) => stSelected.has(`${r.p.name}|${r.path}`))
if (!sel.length) return
const mb = sel.reduce((s, r) => s + r.mb, 0)
if (!confirm(`${sel.length} Ordner (${fmtMB1(mb)}) endgültig löschen?\n\n${sel.map((r) => `${r.p.name}: ${inProject(r.path)}`).join('\n')}\n\nSie lassen sich neu erzeugen (npm install, Build …).`)) return
if (!confirm(`${sel.length} Ordner (${fmtMB1(mb)}) endgültig löschen?\n\n${sel.map((r) => `${r.p.name}: ${inProject(r.path, r.p.folder)}`).join('\n')}\n\nSie lassen sich neu erzeugen (npm install, Build …).`)) return
const btn = document.getElementById('stDelete')
btn.disabled = true
btn.innerHTML = `${ic('loader')}Lösche…`
@@ -1905,7 +1920,11 @@ function addTaskFromInput() {
}
// cleanup paths are "<folder>\rest" (relative to the projects folder) → "rest"
const inProject = (p) => p.slice(p.indexOf('\\') + 1)
// (projects in subfolders: folder is "Sammel\A", so strip the whole folder, not up to the first \)
const inProject = (p, folder) => {
const pre = folder ? `${folder}\\` : ''
return pre && p.toLowerCase().startsWith(pre.toLowerCase()) ? p.slice(pre.length) : p.slice(p.indexOf('\\') + 1)
}
// opts: { id } for jump targets, { right } html at the end of the heading
function section(icon, title, body, opts = {}) {
@@ -2076,7 +2095,7 @@ function gitActionsHtml(name, d) {
function archiveHtml(name, d) {
const s = d.storage
const folder = editing?.folder ?? name
const releaseCands = new Set((s?.candidates ?? []).filter((c) => c.Tier === 'Release' && !c.Skip).map((c) => inProject(c.Path).toLowerCase()))
const releaseCands = new Set((s?.candidates ?? []).filter((c) => c.Tier === 'Release' && !c.Skip).map((c) => inProject(c.Path, folder).toLowerCase()))
const rd = d.releaseDirs ?? []
return `
<div class="pickrow">
@@ -2116,7 +2135,7 @@ function cleanHtml(d) {
body += rows.length
? `<table class="cand">${rows.map((c) => `<tr>
<td><input type="checkbox" class="candcb" data-path="${escapeHtml(c.Path)}" ${c.Skip ? 'disabled' : c.Tier === 'Cache' ? 'checked' : ''}></td>
<td>${escapeHtml(inProject(c.Path))}</td>
<td>${escapeHtml(inProject(c.Path, editing?.folder))}</td>
<td><span class="chip ${TIER[c.Tier].cls}" title="${TIER[c.Tier].hint}">${ic(TIER[c.Tier].icon, 'sm')}${TIER[c.Tier].label}</span>${c.Skip ? ` <span class="chip bad">${ic('lock', 'sm')}in git</span>` : ''}</td>
<td class="mb">${fmtMB(c.MB)}</td></tr>`).join('')}</table>
<div class="hint">Cache ist vorausgewählt (immer neu erzeugbar). Fertige Builds und Rohbilder nur bewusst anhaken.</div>`
@@ -2278,7 +2297,7 @@ function bindClean(name, d) {
const paths = [...document.querySelectorAll('.candcb:checked')].map((cb) => cb.dataset.path)
if (!paths.length) return toast('Nichts ausgewählt')
const mb = s.candidates.filter((c) => paths.includes(c.Path)).reduce((a, c) => a + c.MB, 0)
if (!confirm(`${paths.length} Ordner (${fmtMB(mb)}) in „${name}“ endgültig löschen?\n\n${paths.map(inProject).join('\n')}`)) return
if (!confirm(`${paths.length} Ordner (${fmtMB(mb)}) in „${name}“ endgültig löschen?\n\n${paths.map((x) => inProject(x, editing?.folder)).join('\n')}`)) return
clean.disabled = true
clean.innerHTML = `${ic('loader')}Lösche…`
try {
@@ -2290,6 +2309,74 @@ function bindClean(name, d) {
}
}
/* ── projects in subfolders (scanner, lib/nested.js) ──────────────────── */
let nestData = null
let nestDeep = false
async function openNested(deep = false) {
const dlg = document.getElementById('nestDlg')
nestDeep = deep
// keep what was ticked before a re-scan (deep)
const prev = new Map([...document.querySelectorAll('#nestBody input[data-rel]')].map((cb) => [`${cb.dataset.root}|${cb.dataset.rel}`, cb.checked]))
document.getElementById('nestBody').innerHTML = `<div class="hint">${ic('loader', 'sm')} Suche…</div>`
document.getElementById('nestDeep').hidden = deep
if (!dlg.open) dlg.showModal()
try {
const r = await fetch(`/api/nested/scan${deep ? '?deep=1' : ''}`)
nestData = await r.json()
if (!r.ok) throw new Error(nestData.error)
renderNested(dlg.open && deep ? prev : new Map())
} catch (e) {
document.getElementById('nestBody').innerHTML = `<div class="hint">Fehler: ${escapeHtml(e.message)}</div>`
}
}
function renderNested(prev) {
const item = (root, x, preset) => {
const k = `${root.id}|${x.rel}`
const on = prev.has(k) ? prev.get(k) : preset
const parts = x.rel.split('\\')
return `<label class="nitem">
<input type="checkbox" data-root="${escapeHtml(root.id)}" data-rel="${escapeHtml(x.rel)}" ${on ? 'checked' : ''}>
<span class="nrel" title="${escapeHtml(root.path)}\\${escapeHtml(x.rel)}"><span class="hint" style="margin:0">${escapeHtml(parts.slice(0, -1).join('\\'))}\\</span><b>${escapeHtml(parts.at(-1))}</b></span>
${x.markers.slice(0, 4).map((m) => `<span class="chip tech">${escapeHtml(m === '.NET-sln' ? '.NET' : m === 'dashboard' ? 'Dashboard' : m)}</span>`).join('')}
${x.chosen ? '<span class="chip ok">übernommen</span>' : x.ignored ? '<span class="chip neutral">ausgelassen</span>' : '<span class="chip warn">neu</span>'}
</label>`
}
const roots = nestData.roots ?? []
const html = roots.map((r) => {
const groups = r.containers.map((c) => `<div class="ngroup">
<div class="nghead">${ic('folder', 'sm')}${escapeHtml(c.rel)}<span class="hint">Sammelordner · wird ausgeblendet, wenn etwas übernommen ist</span></div>
${c.projects.map((x) => item(r, x, x.chosen || !x.ignored)).join('')}
</div>`).join('')
const inner = r.inProjects.length ? `<div class="ngroup">
<div class="nghead">${ic('folder-git-2', 'sm')}In Projekten<span class="hint">meist Teil des Projekts – nur bei Bedarf ankreuzen</span></div>
${r.inProjects.map((x) => item(r, x, x.chosen)).join('')}
</div>` : ''
const n = r.containers.reduce((a, c) => a + c.projects.length, 0) + r.inProjects.length
return `<div class="nroot"><h4>${ic('folders')}${escapeHtml(r.name)} <span class="hint">${escapeHtml(r.path)} · ${n} gefunden</span></h4>
${groups + inner || `<div class="hint">Keine Projekte in Unterordnern${nestDeep ? '' : ' (Sammelordner)'}.</div>`}</div>`
}).join('')
document.getElementById('nestBody').innerHTML = `
<div class="hint" style="margin-top:12px">Angekreuzte Ordner erscheinen als eigene Projekte. Ein Sammelordner ohne eigenes Projekt (kein git, README, package.json …) wird dann ausgeblendet. Auf der Platte ändert sich nichts.</div>
${html || '<div class="hint">Keine Projektordner eingerichtet.</div>'}`
}
async function saveNested() {
const out = {}
for (const r of nestData?.roots ?? []) out[r.id] = { chosen: [], ignored: [] }
for (const cb of document.querySelectorAll('#nestBody input[data-rel]')) out[cb.dataset.root]?.[cb.checked ? 'chosen' : 'ignored'].push(cb.dataset.rel)
const btn = document.getElementById('nestOk')
btn.disabled = true
try {
const r = await postJson('/api/nested', { roots: out })
document.getElementById('nestDlg').close()
await load()
toast(r.chosen ? `${r.chosen} ${r.chosen === 1 ? 'Projekt' : 'Projekte'} aus Unterordnern übernommen` : 'Keine Projekte aus Unterordnern', 'folder-tree')
} catch (e) { toast(e.message, 'triangle-alert') } finally { btn.disabled = false }
}
/* ── itch.io copy view (docs\itchio of the project, lib/itchpack.js) ───── */
let itchName = null
@@ -2868,6 +2955,11 @@ document.getElementById('btnCloseBackup').onclick = closeBackup
document.getElementById('search').addEventListener('input', (e) => { searchTerm = e.target.value; render() })
for (const btn of document.querySelectorAll('#tabs button')) btn.onclick = () => { setView(btn.dataset.view); render() }
for (const btn of document.querySelectorAll('#ptabs button')) btn.onclick = () => setSection(btn.dataset.sec)
document.getElementById('nestClose').onclick = () => document.getElementById('nestDlg').close()
document.getElementById('nestCancel').onclick = () => document.getElementById('nestDlg').close()
document.getElementById('nestDeep').onclick = () => openNested(true)
document.getElementById('nestOk').onclick = saveNested
document.getElementById('fNestedOpen').onclick = () => openNested()
document.getElementById('itchClose').onclick =() => document.getElementById('itchDlg').close()
document.getElementById('itchReload').onclick = () => itchName && openItch(itchName)
document.getElementById('itchOpenDir').onclick = () => itchName && postJson(api(itchName, 'itch/open')).catch((e) => toast(e.message, 'triangle-alert'))

View File

@@ -555,6 +555,23 @@
.card-sec h4 .h4r .i, .isec h4 .h4r .i { color: inherit; }
a.jump { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; color: var(--accent-text); text-decoration: none; }
a.jump:hover { text-decoration: underline; }
/* projects in subfolders (scanner dialog) */
#nestBody { padding: 4px 20px 12px; }
.nestfoot { display: flex; gap: 8px; align-items: center; padding: 12px 20px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--surface); }
.nestfoot .sp { flex: 1; }
.nroot { margin-top: 14px; }
.nroot > h4 { margin: 0 0 6px; font-size: 13px; display: flex; gap: 7px; align-items: center; }
.nroot > h4 .hint { margin: 0; font-weight: 400; }
.ngroup { border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); margin-top: 8px; overflow: hidden; }
.ngroup .nghead { display: flex; gap: 8px; align-items: center; padding: 8px 12px; font-size: 13px; font-weight: 600; border-bottom: 1px solid var(--border); }
.ngroup .nghead .hint { margin: 0 0 0 auto; font-weight: 400; }
.nitem { display: flex; gap: 10px; align-items: center; padding: 7px 12px; font-size: 13px; border-top: 1px solid var(--border); cursor: pointer; }
.nitem:first-of-type { border-top: 0; }
.nitem input { flex: 0 0 auto; }
.nitem .nrel { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nitem .nrel b { font-weight: 600; }
.nitem .chip { font-size: 10px; }
.card .rootline .rtag + .rtag { margin-left: 4px; }
.pdesc { font-size: 13px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.pdesc.muted { color: var(--muted); font-style: italic; }
.pdesc-edit textarea { width: 100%; min-height: 120px; resize: vertical; font: inherit; font-size: 13px; line-height: 1.5; }
@@ -971,6 +988,7 @@
<div class="rowbtns">
<button class="btn" id="fAddRoot" type="button"><svg class="i"><use href="/icons.svg#plus"/></svg>Ordner hinzufügen</button>
<button class="btn" id="fImportOpen" type="button"><svg class="i"><use href="/icons.svg#folder-plus"/></svg>Mehrere einlesen…</button>
<button class="btn" id="fNestedOpen" type="button" title="Projekte suchen, die eine Ebene tiefer liegen (z. B. in einem Sammelordner)"><svg class="i"><use href="/icons.svg#folder-tree"/></svg>Projekte in Unterordnern…</button>
</div>
<div class="importbox" id="fImport" hidden>
<div class="hint" style="margin:0 0 6px">Übergeordneten Ordner wählen – seine Unterordner werden als Projektordner angeboten.</div>
@@ -1121,6 +1139,21 @@
<div id="itchBody"></div>
</dialog>
<dialog id="nestDlg" class="dlg wide">
<div class="ihead">
<h3><svg class="i lg"><use href="/icons.svg#folder-tree"/></svg>Projekte in Unterordnern</h3>
<span class="sp"></span>
<button class="iconbtn" type="button" id="nestClose" title="Schließen (Esc)"><svg class="i"><use href="/icons.svg#x"/></svg></button>
</div>
<div id="nestBody"></div>
<div class="nestfoot">
<button class="btn" type="button" id="nestDeep" title="Auch in echten Projekten suchen, z. B. PowerBackupPro_CleanTools…"><svg class="i"><use href="/icons.svg#scan-search"/></svg>Auch in Projekten suchen</button>
<span class="sp"></span>
<button class="btn" type="button" id="nestCancel">Abbrechen</button>
<button class="btn primary" type="button" id="nestOk"><svg class="i"><use href="/icons.svg#check"/></svg>Übernehmen</button>
</div>
</dialog>
<div id="toast"></div>
<script src="app.js"></script>
</body>

View File

@@ -34,6 +34,7 @@ const itch = require('./lib/itch')
const create = require('./lib/create')
const archive = require('./lib/archive')
const itchpack = require('./lib/itchpack')
const nested = require('./lib/nested')
const scheduler = require('./lib/scheduler')
// The projects folder comes from the settings (lib/settings.js) and can be
@@ -206,18 +207,31 @@ function projectList() {
for (const root of ROOTS) {
let entries
try { entries = fs.readdirSync(root.path, { withFileTypes: true }) } catch { continue }
// projects in subfolders chosen in the scanner (lib/nested.js); a pure
// collection folder above them is hidden, a real project stays
const sub = (root.nested ?? []).filter((rel) => { try { return fs.statSync(path.join(root.path, rel)).isDirectory() } catch { return false } })
const hide = new Set()
for (const rel of sub) {
const top = rel.split(path.sep)[0]
if (!nested.isProject(path.join(root.path, top))) hide.add(top.toLowerCase())
}
for (const e of entries) {
if (e.isDirectory() && !e.name.startsWith('.') && !NOT_PROJECTS.has(e.name.toLowerCase())) raw.push({ folder: e.name, root })
if (e.isDirectory() && !e.name.startsWith('.') && !NOT_PROJECTS.has(e.name.toLowerCase()) && !hide.has(e.name.toLowerCase())) raw.push({ folder: e.name, root, parent: '' })
}
for (const rel of sub) raw.push({ folder: rel, root, parent: path.dirname(rel) })
}
// key: the folder's name; on a clash "(parent folder)" / "(projects folder)" is added
const base = (p) => path.basename(p.folder)
const count = new Map()
for (const p of raw) count.set(p.folder.toLowerCase(), (count.get(p.folder.toLowerCase()) ?? 0) + 1)
for (const p of raw) count.set(base(p).toLowerCase(), (count.get(base(p).toLowerCase()) ?? 0) + 1)
const used = new Set()
const list = raw.map((p) => {
let key = count.get(p.folder.toLowerCase()) > 1 ? `${p.folder} (${p.root.name})` : p.folder
const b = base(p)
let key = count.get(b.toLowerCase()) > 1 ? `${b} (${p.parent ? path.basename(p.parent) : p.root.name})` : b
if (used.has(key.toLowerCase())) key = `${b} (${p.root.name})`
while (used.has(key.toLowerCase())) key += ` [${p.root.id}]`
used.add(key.toLowerCase())
return { key, folder: p.folder, root: p.root }
return { key, folder: p.folder, root: p.root, parent: p.parent }
})
projMap = new Map(list.map((p) => [p.key, p]))
return list
@@ -243,7 +257,9 @@ function keyOf(rootPath, folder) {
function resolveProject(key) {
const p = projectRef(key)
if (!p) return null
if (!fs.existsSync(p.path) || !fs.statSync(p.path).isDirectory() || path.dirname(p.path) !== p.root.path) return null
// a direct child of a shown projects folder, or a chosen project in a subfolder (projMap)
const inside = p.path.toLowerCase().startsWith(p.root.path.toLowerCase() + path.sep)
if (!inside || !fs.existsSync(p.path) || !fs.statSync(p.path).isDirectory()) return null
return p.path
}
@@ -281,6 +297,7 @@ async function describeProject(p, target) {
return {
name: p.key,
folder: p.folder,
parent: p.parent ?? '',
root: p.root.id,
rootName: p.root.name,
mtime: stat.mtime.toISOString(),
@@ -294,7 +311,7 @@ async function describeProject(p, target) {
lastBackup: backup.lastFor(p.root.path, p.folder, target),
storage: storageSummary(p),
...meta,
published: itch.forProject(p.folder, meta.itch),
published: itch.forProject(path.basename(p.folder), meta.itch),
}
}
@@ -375,13 +392,15 @@ app.get('/api/projects', handle(async (req, res) => {
cleanupAvailable: storage.available(),
cleanAvailable: storage.cleanupAvailable(),
activityPending: activity.pending(),
// projects in subfolders found but not yet chosen/dismissed (lib/nested.js)
nestedHint: ROOTS.length ? nested.hint(s.roots.filter((r) => fs.existsSync(r.path))) : 0,
})
}))
// itch.io profile: games found + which project claims them (lib/itch.js)
async function itchStatus() {
const s = itch.state
const claimed = projectList().map((p) => itch.forProject(p.folder, readStatusFile(path.join(p.root.path, p.folder)).itch)?.url).filter(Boolean)
const claimed = projectList().map((p) => itch.forProject(path.basename(p.folder), readStatusFile(path.join(p.root.path, p.folder)).itch)?.url).filter(Boolean)
return { profile: s.profile, at: s.at, error: s.error, games: s.games, unmatched: itch.unmatched(claimed) }
}
app.get('/api/itch', handle(async (req, res) => { await itch.ensure(); res.json(await itchStatus()) }))
@@ -531,21 +550,34 @@ app.post('/api/projects/:name/move', handle(async (req, res) => {
if (!ref) return res.status(404).json({ error: 'unknown project' })
const root = settings.get().roots.find((r) => r.id === (req.body?.root || ref.root.id))
if (!root || !fs.existsSync(root.path)) return res.status(400).json({ error: 'Projektordner nicht gefunden.' })
// a project in a subfolder is renamed where it is (same projects folder);
// moved to another projects folder it lands at the top there
const stay = ref.parent && root.id === ref.root.id
let r
try {
r = await create.move({ from: ref.path, rootPath: root.path, name: req.body?.name })
r = await create.move({ from: ref.path, rootPath: stay ? path.join(root.path, ref.parent) : root.path, name: req.body?.name })
} catch (e) {
return res.status(400).json({ error: String(e.message ?? e) })
}
const newRoot = path.resolve(root.path)
storage.rename(ref.root.path, ref.folder, newRoot, r.name)
const newFolder = stay ? path.join(ref.parent, r.name) : r.name
if (ref.parent) {
const old = settings.get().roots.find((x) => x.id === ref.root.id)
if (old) {
const keep = (old.nested ?? []).filter((x) => x.toLowerCase() !== ref.folder.toLowerCase())
settings.setNested(old.id, stay ? [...keep, newFolder] : keep, old.nestedIgnored ?? [])
nested.forgetHint()
applySettings()
}
}
storage.rename(ref.root.path, ref.folder, newRoot, newFolder)
thumbCache.delete(key)
quickCache.delete(key)
icons.forget(ref.path)
projectList()
const shown = ROOTS.some((x) => x.id === root.id)
if (shown) activity.warm([r.path])
res.json({ ok: true, name: r.name, root: root.id, rootName: root.name, shown, key: shown ? keyOf(newRoot, r.name) : r.name })
res.json({ ok: true, name: r.name, root: root.id, rootName: root.name, shown, key: shown ? keyOf(newRoot, newFolder) : r.name })
}))
// Adds projects folders from the dropdown. body: { paths: [...], activate }
app.post('/api/roots/add', (req, res) => {
@@ -559,6 +591,46 @@ app.post('/api/roots/add', (req, res) => {
res.status(400).json({ error: String(e.message ?? e) })
}
})
// Projects in subfolders (lib/nested.js): scan every registered projects folder.
// ?deep=1 also lists sub-projects inside real projects.
app.get('/api/nested/scan', (req, res) => {
const deep = req.query.deep === '1'
const out = settings.get().roots.filter((r) => fs.existsSync(r.path)).map((r) => {
const chosen = new Set((r.nested ?? []).map((x) => x.toLowerCase()))
const ignored = new Set((r.nestedIgnored ?? []).map((x) => x.toLowerCase()))
const flag = (x) => ({ ...x, chosen: chosen.has(x.rel.toLowerCase()), ignored: ignored.has(x.rel.toLowerCase()) })
const sc = nested.scan(r.path, { deep })
// chosen entries the scan doesn't show any more (e.g. inside a real project, scanned without deep)
const seen = new Set([...sc.containers.flatMap((c) => c.projects), ...sc.inProjects].map((x) => x.rel.toLowerCase()))
const extra = (r.nested ?? []).filter((x) => !seen.has(x.toLowerCase()) && fs.existsSync(path.join(r.path, x)))
.map((rel) => ({ rel, markers: nested.markers(path.join(r.path, rel)), parent: rel.split(path.sep)[0] }))
return {
id: r.id, name: r.name, path: r.path,
containers: sc.containers.map((c) => ({ rel: c.rel, projects: c.projects.map(flag) })),
inProjects: [...sc.inProjects, ...extra].map(flag),
}
})
res.json({ roots: out, deep })
})
// Stores the choice. body: { roots: { <rootId>: { chosen: [rel], ignored: [rel] } } }
app.post('/api/nested', (req, res) => {
if (storage.busy() || backup.busy() || create.busy()) return res.status(409).json({ error: 'Erst warten, bis Scan/Backup fertig ist.' })
const input = req.body?.roots
if (!input || typeof input !== 'object') return res.status(400).json({ error: 'roots fehlt' })
let chosenCount = 0
for (const r of settings.get().roots) {
const v = input[r.id]
if (!v) continue
const ok = (list) => (Array.isArray(list) ? list : []).map((x) => nested.cleanRel(r.path, x))
.filter((x) => x && fs.existsSync(path.join(r.path, x)) && fs.statSync(path.join(r.path, x)).isDirectory())
const chosen = ok(v.chosen)
settings.setNested(r.id, chosen, ok(v.ignored).filter((x) => !chosen.includes(x)))
chosenCount += chosen.length
}
nested.forgetHint()
applySettings()
res.json({ ok: true, chosen: chosenCount, projects: projectList().length })
})
// Subfolders of a folder, for adding several projects folders at once
app.get('/api/subfolders', (req, res) => {
try { res.json(settings.subfolders(String(req.query.path ?? ''))) } catch (e) { res.status(400).json({ error: String(e.message ?? e) }) }