diff --git a/docs/ZUSAMMENARBEIT.md b/docs/ZUSAMMENARBEIT.md index 1dcb9da..ea670f0 100644 --- a/docs/ZUSAMMENARBEIT.md +++ b/docs/ZUSAMMENARBEIT.md @@ -50,6 +50,20 @@ ## 4. Konflikte vermeiden | `public/build` | Wird nicht committet (Build-Ergebnis); nie von Hand ändern | | Datenbank-Migrationen | Nur Session A | +## 4a. Automatische Synchronisation (optional, je Rechner) + +`scripts/git-autosync.ps1` zieht alle 5 Minuten neue Commits von Gitea – nur per Vorspulen (`--ff-only`), nie bei lokalen, nicht committeten Änderungen an versionierten Dateien und nie, wenn beide Seiten neue Commits haben (dann Hinweis im Protokoll, bitte von Hand `git pull`). Protokoll: `storage/logs/git-autosync.log`, inklusive Hinweis, wenn danach `npm ci && npm run build`, `composer install` oder `php artisan migrate` nötig ist. + +```powershell +scripts\git-autosync.ps1 -Register # einrichten (Windows-Aufgabenplanung, aktueller Benutzer) +scripts\git-autosync.ps1 -Unregister # entfernen +scripts\git-autosync.ps1 # einmal von Hand +``` + +Eingerichtet auf: Firmen-Laptop (23.10.2026). + +**Lock-Datei:** Nach jeder Paketänderung `npm install` ausführen und `package-lock.json` mit committen; vor dem Push prüfen, dass `npm ci` fehlerfrei durchläuft – das Deploy-Skript und die CI bauen mit `npm ci` und brechen sonst ab (am 23.10. passiert: Lock-Datei passte nicht zu package.json). + ## 5. Wünsche der Design-Session an die Anwendung *(Session B trägt hier ein, was sie braucht; Session A erledigt es und vermerkt „erledigt in “.)* diff --git a/package-lock.json b/package-lock.json index 31083f4..7feb0c8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "fewo-stommer.de", + "name": "fewo-stommer", "lockfileVersion": 3, "requires": true, "packages": { @@ -656,6 +656,72 @@ "node": ">=14.0.0" } }, + "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@emnapi/core": { + "version": "1.11.1", + "dev": true, + "inBundle": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/wasi-threads": "1.2.2", + "tslib": "^2.4.0" + } + }, + "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@emnapi/runtime": { + "version": "1.11.1", + "dev": true, + "inBundle": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@emnapi/wasi-threads": { + "version": "1.2.2", + "dev": true, + "inBundle": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@napi-rs/wasm-runtime": { + "version": "1.1.4", + "dev": true, + "inBundle": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@tybys/wasm-util": "^0.10.1" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Brooooooklyn" + }, + "peerDependencies": { + "@emnapi/core": "^1.7.1", + "@emnapi/runtime": "^1.7.1" + } + }, + "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@tybys/wasm-util": { + "version": "0.10.2", + "dev": true, + "inBundle": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/tslib": { + "version": "2.8.1", + "dev": true, + "inBundle": true, + "license": "0BSD", + "optional": true + }, "node_modules/@tailwindcss/oxide-win32-arm64-msvc": { "version": "4.3.3", "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-arm64-msvc/-/oxide-win32-arm64-msvc-4.3.3.tgz", @@ -1565,7 +1631,6 @@ "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, @@ -1602,6 +1667,16 @@ "node": "^10 || ^12 || >=14" } }, + "node_modules/react": { + "version": "19.3.1", + "resolved": "https://registry.npmjs.org/react/-/react-19.3.1.tgz", + "integrity": "sha512-QNhWdt7nrgVWWQG58QuGsAR3jv3Hbe4mb4vz7w2csnHavciZJgda1CPNaldF6eVxv90ud3jUXpKlHL69gO38yw==", + "license": "MIT", + "optional": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/react-reconciler": { "version": "0.33.0", "resolved": "https://registry.npmjs.org/react-reconciler/-/react-reconciler-0.33.0.tgz", @@ -1908,7 +1983,6 @@ "integrity": "sha512-z1YpjieJ9g0ebTmQpLBv/oq9E3F9EIlOe+7LahW8SrE3LTiG3udBRUXQOlYXP9b+IC2q2phHeVxj9xGlw34OEQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "lightningcss": "^1.33.0", "picomatch": "^4.0.7", diff --git a/scripts/git-autosync.ps1 b/scripts/git-autosync.ps1 new file mode 100644 index 0000000..281f765 --- /dev/null +++ b/scripts/git-autosync.ps1 @@ -0,0 +1,78 @@ +<# + Keeps a local clone in sync with Gitea (e.g. every 5 minutes via Windows Task Scheduler). + Safe by design: it only fast-forwards. Nothing happens if there are local uncommitted changes, if the + branch has no upstream, or if local and remote both have new commits (that needs a human). + Log: storage/logs/git-autosync.log (not committed). + + Register (once per machine, PowerShell): + scripts\git-autosync.ps1 -Register # every 5 minutes, as the current user + scripts\git-autosync.ps1 -Unregister + Run once by hand: + scripts\git-autosync.ps1 +#> +param( + [switch] $Register, + [switch] $Unregister, + [int] $Minutes = 5 +) + +$ErrorActionPreference = 'Stop' +$repo = Split-Path -Parent $PSScriptRoot +$taskName = 'FeWo Stommer Git-Sync' +$log = Join-Path $repo 'storage\logs\git-autosync.log' + +if ($Register) { + $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "-NoProfile -NonInteractive -WindowStyle Hidden -ExecutionPolicy Bypass -File `"$PSCommandPath`"" + $trigger = New-ScheduledTaskTrigger -Once -At (Get-Date).AddMinutes(1) -RepetitionInterval (New-TimeSpan -Minutes $Minutes) + $settings = New-ScheduledTaskSettingsSet -StartWhenAvailable -DontStopIfGoingOnBatteries -AllowStartIfOnBatteries -ExecutionTimeLimit (New-TimeSpan -Minutes 5) -MultipleInstances IgnoreNew + Register-ScheduledTask -TaskName $taskName -Action $action -Trigger $trigger -Settings $settings -Description "git pull --ff-only für $repo (scripts/git-autosync.ps1)" -Force | Out-Null + Write-Output "Aufgabe '$taskName' eingerichtet: alle $Minutes Minuten. Protokoll: $log" + exit 0 +} + +if ($Unregister) { + Unregister-ScheduledTask -TaskName $taskName -Confirm:$false + Write-Output "Aufgabe '$taskName' entfernt." + exit 0 +} + +function Write-Log([string] $message) { + New-Item -ItemType Directory -Force -Path (Split-Path $log) | Out-Null + Add-Content -Path $log -Value ("{0:yyyy-MM-dd HH:mm:ss} {1}" -f (Get-Date), $message) -Encoding utf8 +} + +function Invoke-Git([string[]] $arguments) { + $output = & git.exe -C $repo @arguments 2>&1 + if ($LASTEXITCODE -ne 0) { throw "git $($arguments -join ' '): $output" } + return $output +} + +try { + Invoke-Git @('fetch', '--quiet', '--prune') | Out-Null + + $branch = (Invoke-Git @('rev-parse', '--abbrev-ref', 'HEAD')).Trim() + $upstream = & git.exe -C $repo rev-parse --abbrev-ref --symbolic-full-name '@{u}' 2>$null + if ($LASTEXITCODE -ne 0 -or -not $upstream) { Write-Log "übersprungen: Branch $branch hat keinen Upstream"; exit 0 } + + $counts = (Invoke-Git @('rev-list', '--left-right', '--count', "HEAD...$upstream")).Trim() -split '\s+' + $ahead = [int] $counts[0]; $behind = [int] $counts[1] + if ($behind -eq 0) { exit 0 } # nothing new – no log entry + + if ((Invoke-Git @('status', '--porcelain', '--untracked-files=no')) ) { Write-Log "übersprungen: lokale Änderungen in $branch ($behind neue Commits auf $upstream warten)"; exit 0 } + if ($ahead -gt 0) { Write-Log "nicht synchronisiert: $branch hat $ahead eigene und $behind neue Commits – bitte von Hand zusammenführen (git pull)"; exit 0 } + + $before = (Invoke-Git @('rev-parse', 'HEAD')).Trim() + Invoke-Git @('merge', '--ff-only', '--quiet', $upstream) | Out-Null + $changed = Invoke-Git @('diff', '--name-only', $before, 'HEAD') + $hints = @() + if ($changed -match '^(package\.json|package-lock\.json)$') { $hints += 'npm ci && npm run build' } + if ($changed -match '^composer\.(json|lock)$') { $hints += 'composer install' } + if ($changed -match '^database/migrations/') { $hints += 'php artisan migrate' } + if ($changed -match '^resources/(themes|css|js)/') { $hints += 'npm run build (Theme/Assets geändert)' } + $summary = (Invoke-Git @('log', '--oneline', "$before..HEAD")) -join ' | ' + Write-Log ("aktualisiert $branch um $behind Commit(s): $summary" + ($(if ($hints) { " → bitte ausführen: " + (($hints | Select-Object -Unique) -join '; ') } else { '' }))) +} +catch { + Write-Log "Fehler: $($_.Exception.Message)" + exit 1 +}