'(default)']; if (is_dir($manifestDir)) { foreach (glob($manifestDir . '/versions-*.json') as $file) { $name = basename($file); if (preg_match('/^versions-([a-z0-9_-]{1,64})\.json$/', $name, $m)) { $channels[$m[1]] = $m[1]; } } } return $channels; } function loadManifest(string $path): array { if (!is_file($path)) return ['schemaVersion' => 1, 'product' => 'PROSERVE_UE', 'latest' => null, 'versions' => []]; return json_decode(file_get_contents($path), true) ?? []; } function saveManifest(string $path, array $manifest): void { // Re-tri par SemVer descendant usort($manifest['versions'], fn($a, $b) => version_compare($b['version'], $a['version'])); file_put_contents( $path, json_encode($manifest, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n" ); } if ($_SERVER['REQUEST_METHOD'] === 'POST') { Auth::checkCsrf(); $action = $_POST['action'] ?? ''; $manifest = loadManifest($manifestPath); try { if ($action === 'add') { $version = trim($_POST['version'] ?? ''); $minLicDate = trim($_POST['min_license_date'] ?? ''); $releasedAt = trim($_POST['released_at'] ?? ''); $notes = $_POST['notes'] ?? ''; $available = isset($_POST['available']); $isBeta = isset($_POST['is_beta']); $betaNotes = trim($_POST['beta_notes'] ?? '') ?: null; if (!preg_match('/^\d+\.\d+\.\d+$/', $version)) { throw new Exception('Numéro de version invalide (format X.Y.Z attendu).'); } if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $minLicDate)) { throw new Exception('Date min_license_date invalide.'); } foreach ($manifest['versions'] as $v) { if ($v['version'] === $version) throw new Exception("v{$version} existe déjà dans le manifest."); } $releasedAtIso = $releasedAt !== '' ? (new DateTime($releasedAt, new DateTimeZone('UTC')))->format('Y-m-d\TH:i:s\Z') : (new DateTimeImmutable('now', new DateTimeZone('UTC')))->format('Y-m-d\TH:i:s\Z'); $base = $config['base_url'] ?? 'https://asterionvr.com/PS_Launcher'; // Pour un channel non-default, le ZIP vit dans builds/{channel}/. // L'admin peut surcharger l'URL après-coup si la convention diffère. $zipPathPrefix = $channel === '' ? 'builds' : "builds/{$channel}"; $entry = [ 'version' => $version, 'releasedAt' => $releasedAtIso, 'executable' => 'PROSERVE_UE_5_5.exe', 'installFolderTemplate' => 'PROSERVE v{version}', 'download' => [ 'url' => "{$base}/{$zipPathPrefix}/proserve-{$version}.zip", 'sizeBytes' => 0, 'sha256' => 'REPLACE_AFTER_BUILD', ], 'releaseNotesUrl' => "{$base}/api/releasenotes/{$version}", 'minLicenseDate' => $minLicDate, 'availableForDownload' => $available, ]; if ($isBeta) { $entry['isBeta'] = true; if ($betaNotes !== null) $entry['betaNotes'] = $betaNotes; } $manifest['versions'][] = $entry; saveManifest($manifestPath, $manifest); if ($notes !== '') { if (!is_dir($notesDir)) mkdir($notesDir, 0755, true); file_put_contents("$notesDir/{$version}.md", $notes); } $message = "v{$version} ajoutée. Upload le ZIP en SFTP dans builds/, puis clique « Sync (sign-manifest) »."; } elseif ($action === 'edit_notes') { $version = $_POST['version'] ?? ''; $notes = $_POST['notes'] ?? ''; if (!preg_match('/^\d+\.\d+\.\d+$/', $version)) throw new Exception('Version invalide.'); if (!is_dir($notesDir)) mkdir($notesDir, 0755, true); file_put_contents("$notesDir/{$version}.md", $notes); $message = "Release notes de v{$version} mises à jour."; } elseif ($action === 'edit_meta') { $version = $_POST['version'] ?? ''; $minLicDate = trim($_POST['min_license_date'] ?? ''); $releasedAt = trim($_POST['released_at'] ?? ''); if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $minLicDate)) { throw new Exception('min_license_date invalide.'); } foreach ($manifest['versions'] as &$v) { if ($v['version'] === $version) { $v['minLicenseDate'] = $minLicDate; if ($releasedAt !== '') { $v['releasedAt'] = (new DateTime($releasedAt, new DateTimeZone('UTC')))->format('Y-m-d\TH:i:s\Z'); } break; } } unset($v); saveManifest($manifestPath, $manifest); $message = "Méta de v{$version} mises à jour."; } elseif ($action === 'set_beta') { $version = $_POST['version'] ?? ''; $isBeta = !empty($_POST['is_beta']); $betaNotes = trim($_POST['beta_notes'] ?? '') ?: null; foreach ($manifest['versions'] as &$v) { if ($v['version'] === $version) { if ($isBeta) { $v['isBeta'] = true; if ($betaNotes !== null) { $v['betaNotes'] = $betaNotes; } else { unset($v['betaNotes']); } } else { unset($v['isBeta']); unset($v['betaNotes']); } break; } } unset($v); saveManifest($manifestPath, $manifest); $message = "Statut BÊTA de v{$version} mis à jour. N'oublie pas de re-signer le manifest (« 🔁 Sync »)."; } elseif ($action === 'toggle_available') { $version = $_POST['version'] ?? ''; foreach ($manifest['versions'] as &$v) { if ($v['version'] === $version) { $v['availableForDownload'] = !($v['availableForDownload'] ?? true); break; } } unset($v); saveManifest($manifestPath, $manifest); $message = "Disponibilité de v{$version} mise à jour."; } elseif ($action === 'delete') { $version = $_POST['version'] ?? ''; $manifest['versions'] = array_values(array_filter( $manifest['versions'], fn($v) => $v['version'] !== $version )); saveManifest($manifestPath, $manifest); $message = "v{$version} retirée du manifest. Le ZIP reste dans builds/ (à supprimer en SFTP si voulu)."; } elseif ($action === 'sync' || $action === 'sync_versions') { require_once "$root/tools/SignManifest.php"; $signer = new \PSLauncher\Tools\SignManifest($root, $channel ?: null); $scope = $action === 'sync_versions' ? 'versions' : 'all'; $force = !empty($_POST['force']); $result = $signer->run($scope, $force); $label = $scope === 'versions' ? 'versions Proserve' : 'manifest complet'; $forceLabel = $force ? ' [FORCE: cache ignoré]' : ' [cache utilisé pour les ZIPs inchangés]'; $message = "Sortie du script (scope: {$label}{$forceLabel}) :\n" . implode("\n", $result['log']); if (!$result['ok']) $messageType = 'error'; } elseif ($action === 'sync_one') { $version = $_POST['version'] ?? ''; if ($version === '') throw new Exception("Version manquante"); require_once "$root/tools/SignManifest.php"; $signer = new \PSLauncher\Tools\SignManifest($root, $channel ?: null); $force = !empty($_POST['force']); $result = $signer->run('versions', $force, $version); $forceLabel = $force ? ' [FORCE]' : ''; $message = "Hash de v{$version}{$forceLabel} :\n" . implode("\n", $result['log']); if (!$result['ok']) $messageType = 'error'; } elseif ($action === 'set_skip_hash') { $version = $_POST['version'] ?? ''; $skipHash = !empty($_POST['skip']); foreach ($manifest['versions'] as &$v) { if ($v['version'] === $version) { if ($skipHash) { $v['download']['hashAlgorithm'] = 'none'; $v['download']['sha256'] = ''; } else { unset($v['download']['hashAlgorithm']); if (empty($v['download']['sha256'])) { $v['download']['sha256'] = 'REPLACE_AFTER_BUILD'; } } break; } } unset($v); saveManifest($manifestPath, $manifest); // Re-signature auto pour garder le manifest valide après le changement. // En mode skip, on n'a rien à hasher : on appelle run() qui se contentera // de détecter hashAlgorithm=none et re-signera. Pas de calcul lourd. require_once "$root/tools/SignManifest.php"; $signer = new \PSLauncher\Tools\SignManifest($root, $channel ?: null); $resign = $signer->run('versions', false); $message = ($skipHash ? "Vérif SHA-256 désactivée pour v{$version} et manifest re-signé." : "Vérif SHA-256 réactivée pour v{$version}. Clique « 🔁 Hash » sur cette ligne pour calculer le SHA-256.") . "\n" . implode("\n", $resign['log']); if (!$resign['ok']) $messageType = 'error'; } } catch (Exception $e) { $message = $e->getMessage(); $messageType = 'error'; } } $manifest = loadManifest($manifestPath); $zips = is_dir($buildsDir) ? array_map('basename', glob("$buildsDir/*.zip") ?: []) : []; $zipSizes = []; foreach ($zips as $z) $zipSizes[$z] = filesize("$buildsDir/$z"); // Pour l'édition : pré-charge les release notes existantes $existingNotes = []; foreach ($manifest['versions'] ?? [] as $v) { $f = "$notesDir/{$v['version']}.md"; $existingNotes[$v['version']] = is_file($f) ? file_get_contents($f) : ''; } $existingChannels = listExistingChannels($manifestDir); $channelLabel = $channel === '' ? 'default' : $channel; Layout::header('Versions', 'versions'); ?>
= htmlspecialchars($channelLabel) ?>www/PS_Launcher/builds/ en respectant le nom proserve-{version}.zip.sizeBytes, bumper latest, et signer le manifest avec Ed25519.| Version | Release | min_license | ZIP | Hash | Visible | Actions |
|---|---|---|---|---|---|---|
| v= htmlspecialchars($v['version']) ?> BÊTA | = htmlspecialchars(substr($v['releasedAt'] ?? '', 0, 10)) ?> | = htmlspecialchars($v['minLicenseDate'] ?? '—') ?> |
présent
= Layout::formatBytes($zipSizes[$zipBase] ?? 0) ?>
absent
attendu :
= htmlspecialchars($zipBase) ?> |
SKIP
= substr($v['download']['sha256'], 0, 12) ?>…
à calculer
|
⚙ Hash
La vérif SHA-256 est désactivée pour cette release.
Le manifest sert MétaNotes= !empty($v['isBeta']) ? '🟡 BÊTA' : 'Bêta' ?> |
|
| Aucune version dans le manifest. | ||||||
Aucun ZIP. Upload tes fichiers via SFTP dans www/PS_Launcher/builds/, puis clique « Sync » ci-dessus.
| Fichier | Taille | Référencé ? |
|---|---|---|
= htmlspecialchars($z) ?> |
= Layout::formatBytes($zipSizes[$z]) ?> | = $referenced ? "oui" : "orphelin" ?> |