parent
da54fbc7f3
commit
f4e03fab82
|
|
@ -14,46 +14,42 @@ class CheckUpdates extends Command
|
||||||
$currentNorm = $this->readInstalledVersionNorm();
|
$currentNorm = $this->readInstalledVersionNorm();
|
||||||
$currentRaw = $this->readInstalledVersionRaw() ?? ($currentNorm ? 'v'.$currentNorm : null);
|
$currentRaw = $this->readInstalledVersionRaw() ?? ($currentNorm ? 'v'.$currentNorm : null);
|
||||||
|
|
||||||
// Neuesten Tag vom Remote holen (semver-freundlich sortiert)
|
|
||||||
$appPath = base_path();
|
$appPath = base_path();
|
||||||
$cmd = <<<BASH
|
$cmd = <<<BASH
|
||||||
set -e
|
set -e
|
||||||
cd {$appPath}
|
cd {$appPath}
|
||||||
git fetch --tags --force --quiet origin +refs/tags/*:refs/tags/*
|
git fetch --tags --force --quiet origin +refs/tags/*:refs/tags/*
|
||||||
# Beste Wahl zuerst: v*-Tags semver-sortiert, sonst alle Tags
|
|
||||||
(git tag -l 'v*' --sort=-v:refname | head -n1) || true
|
(git tag -l 'v*' --sort=-v:refname | head -n1) || true
|
||||||
BASH;
|
BASH;
|
||||||
|
|
||||||
$latestTagRaw = trim((string) shell_exec($cmd));
|
$latestTagRaw = trim((string) shell_exec($cmd));
|
||||||
if ($latestTagRaw === '') {
|
if ($latestTagRaw === '') {
|
||||||
// Fallback auf alle Tags (ohne Filter), falls keine v*-Tags existieren
|
|
||||||
$latestTagRaw = trim((string) shell_exec("cd {$appPath} && git tag -l --sort=-v:refname | head -n1"));
|
$latestTagRaw = trim((string) shell_exec("cd {$appPath} && git tag -l --sort=-v:refname | head -n1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normieren (v weg, Suffixe wie -3-gabcd/-dirty entfernen)
|
|
||||||
$latestNorm = $this->normalizeVersion($latestTagRaw);
|
$latestNorm = $this->normalizeVersion($latestTagRaw);
|
||||||
|
|
||||||
// Nichts gefunden -> Caches leeren
|
// Nichts gefunden -> alles leeren
|
||||||
if (!$latestNorm) {
|
if (!$latestNorm) {
|
||||||
cache()->forget('updates:latest');
|
cache()->forget('updates:latest');
|
||||||
cache()->forget('updates:latest_raw');
|
cache()->forget('updates:latest_raw');
|
||||||
cache()->forget('mailwolt.update_available'); // Legacy
|
cache()->forget('mailwolt.update_available'); // legacy
|
||||||
$this->warn('Keine Release-Tags gefunden.');
|
$this->warn('Keine Release-Tags gefunden.');
|
||||||
return self::SUCCESS;
|
return self::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cache schreiben
|
// Nur wenn wirklich neuer als installiert -> Keys setzen
|
||||||
cache()->put('updates:latest', $latestNorm, now()->addMinutes(10));
|
|
||||||
cache()->put('updates:latest_raw', $latestTagRaw, now()->addMinutes(10));
|
|
||||||
cache()->forever('mailwolt.update_available', $latestNorm); // Legacy-Kompat
|
|
||||||
|
|
||||||
// Vergleich & Ausgabe
|
|
||||||
if ($currentNorm && version_compare($latestNorm, $currentNorm, '>')) {
|
if ($currentNorm && version_compare($latestNorm, $currentNorm, '>')) {
|
||||||
|
cache()->forever('updates:latest', $latestNorm);
|
||||||
|
cache()->forever('updates:latest_raw', $latestTagRaw ?: ('v'.$latestNorm));
|
||||||
|
cache()->forever('mailwolt.update_available', $latestNorm); // legacy-kompat
|
||||||
$this->info("Update verfügbar: {$latestTagRaw} (installiert: ".($currentRaw ?? $currentNorm).")");
|
$this->info("Update verfügbar: {$latestTagRaw} (installiert: ".($currentRaw ?? $currentNorm).")");
|
||||||
} else {
|
} else {
|
||||||
|
// Kein Update -> Keys löschen
|
||||||
|
cache()->forget('updates:latest');
|
||||||
|
cache()->forget('updates:latest_raw');
|
||||||
|
cache()->forget('mailwolt.update_available'); // legacy
|
||||||
$this->info("Aktuell (installiert: ".($currentRaw ?? $currentNorm ?? 'unbekannt').").");
|
$this->info("Aktuell (installiert: ".($currentRaw ?? $currentNorm ?? 'unbekannt').").");
|
||||||
// Kein Update – Legacy-Key aufräumen (UI liest die neuen Keys)
|
|
||||||
cache()->forget('mailwolt.update_available');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cache()->put('updates:last_checked_at', now(), now()->addMinutes(10));
|
cache()->put('updates:last_checked_at', now(), now()->addMinutes(10));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue