Phase 6 of the dashboard roadmap - the largest and riskiest item, since it overwrites live production code. Pulls the current main branch from the public Gitea repo over plain HTTPS (archive zip download + REST API for commit info) and applies it to the live hifi/ tree - no SSH, git binary, exec(), or shell_exec() anywhere, so it works on plain shared PHP hosting with no CI/deploy pipeline (exactly the hosting this site actually runs on, per DEPLOY.md's manual-FTP fallback). Six independent endpoints (status/check/download/extract/backup/apply) instead of one big request, mirroring the existing multi-step SetupController pattern - this app has no job-queue infrastructure, and a single ~127MB download+extract+backup+copy is the most likely way to hit an unknown host's max_execution_time or reverse-proxy timeout. GitUpdateService.php does the actual work; UpdateController.php is a thin adapter that marks each step in-progress/failed in a new gitignored update-state.php (same convention as db.php) so a crashed step shows as failed rather than stuck, and a retry starts clean. Security-critical bits: - The backup zip necessarily contains db.php (must be fully restorable), so it lives under hifi/_update/ behind a "Require all denied" .htaccess written the instant the directory is created, and hifi/_update/ was added to .gitignore in this same commit, before any code that could write into it - both needed since a physically-existing file bypasses this app's SPA-fallback/API rewrite rules entirely. - Only hifi/'s own subtree is extracted from the archive (hifi-src/ and everything else ignored) via a wrapper-folder-prefix detected at runtime, not hardcoded. - Copy-then-prune (not copy-only) across the whole hifi/ tree, since Vite renames JS/CSS chunks on every build and a copy-only updater would let stale chunks accumulate forever - guarded by a denylist (db.php, setup.php, ga-service-account.json, update-state.php, api/uploads/, plus local Claude-tooling dirs) that must never be touched in either direction. - index.html is swapped in last via copy+rename (near-atomic), after the new hashed assets it references are already fully in place. - Reuses SchemaController's existing migration logic as the last apply step (extracted into a new runMigration() so it's callable without Http::send()/exit ending the response early) and app_settings' existing maintenance-mode column to show visitors a maintenance page during the brief apply window, restoring whatever maintenance state existed before the update ran (not just forcing it off). Gated behind a new, narrower system.update permission (not the broader settings.manage), with its own settings tab hidden from anyone lacking it - unlike this app's usual "everyone with settings.manage sees every tab" pattern, since this one can overwrite the whole site. Verified in isolation (synthetic zip + fixture directories in a scratch folder, not the real hifi/ tree): wrapper-folder detection and selective hifi/-subtree extraction, and copy+prune with denylist enforcement. Not yet verified: behavior on an actual shared-hosting target (max_execution_time, ZipArchive availability, outbound HTTPS egress, disk quota vs disk_free_space()) - per the plan, validate against the Plesk test server from DEPLOY.md before ever running this against a real client site. Also enabled the php_zip extension in the local XAMPP php.ini, since it was disabled and this feature needs it. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
54 lines
2.2 KiB
Text
54 lines
2.2 KiB
Text
# Dieses Repo lebt im XAMPP htdocs-Ordner zusammen mit anderen, projektfremden
|
|
# Verzeichnissen (Standard-XAMPP-Dateien, andere lokale Seiten). Nur die beiden
|
|
# HifiPlanet-Ordner (hifi/ und hifi-src/) sollen versioniert werden.
|
|
/*
|
|
!/hifi/
|
|
!/hifi-src/
|
|
!/.gitignore
|
|
!/.github/
|
|
!/DEPLOY.md
|
|
|
|
# Von NPM regenerierbare Abhängigkeiten. Der Composer-vendor von hifi/api wird
|
|
# dagegen BEWUSST versioniert: das Kunden-Hosting (All-Inkl) hat keine
|
|
# CI-Anbindung, deshalb muss main das komplett deploybare hifi/ enthalten.
|
|
/hifi-src/node_modules/
|
|
|
|
# Der Vite-Build-Output (hifi/index.html + hifi/assets/) wird ebenfalls BEWUSST
|
|
# versioniert - gleicher Grund: main ist der einzige Branch und zugleich das
|
|
# Deploy-Artefakt (siehe DEPLOY.md). Vor jedem Commit lokal "npm run build"
|
|
# ausführen; das prebuild-Script in hifi-src/package.json räumt assets/ vorher
|
|
# leer, damit sich keine veralteten Hash-Chunks ansammeln.
|
|
|
|
# Umgebungsspezifische DB-Zugangsdaten (wird vom Admin-Panel automatisch neu geschrieben,
|
|
# unterscheidet sich zwischen Dev-/Live-Umgebung und gehört daher nicht ins Repo)
|
|
/hifi/api/config/db.php
|
|
|
|
# Einmalpasswort für den Ersteinrichtungs-Assistenten (siehe setup.php.example) -
|
|
# pro Umgebung unterschiedlich und darf nicht öffentlich einsehbar sein
|
|
/hifi/api/config/setup.php
|
|
|
|
# Google-Service-Account-Schlüssel für die Analytics-Data-API-Anbindung im Dashboard
|
|
# (wird vom Admin-Panel automatisch neu geschrieben, enthält einen privaten Schlüssel)
|
|
/hifi/api/config/ga-service-account.json
|
|
|
|
# Merkt sich den aktuell installierten Git-Commit fürs Auto-Update-Feature
|
|
# (GitUpdateService) - pro Umgebung unterschiedlich, wird automatisch geschrieben.
|
|
/hifi/api/config/update-state.php
|
|
|
|
# Arbeits-/Backup-Verzeichnis des Auto-Update-Features. Die Backup-ZIPs darin enthalten
|
|
# zwangsläufig db.php (siehe oben) - darf NIE ins Repo gelangen, sonst landen
|
|
# Datenbank-Zugangsdaten im (öffentlichen!) Git-Repo.
|
|
/hifi/_update/
|
|
|
|
# Claude-Code-Tooling (Skills/lokale Einstellungen) - gehört nicht zum Website-Projekt
|
|
/hifi/.claude/
|
|
/hifi/.agents/
|
|
/hifi/skills-lock.json
|
|
/hifi-src/.claude/
|
|
/hifi-src/.agents/
|
|
/hifi-src/skills-lock.json
|
|
|
|
# Von XAMPP/Editoren erzeugte Laufzeit-/Cache-Dateien
|
|
*.log
|
|
Thumbs.db
|
|
.DS_Store
|