Add debug logging, alternate paths, and FTB detection to cron

- CurseForge: tries manifest.json + minecraftinstance.json
- Modrinth: modrinth.index.json (unchanged)
- FTB: version.json with parent ID detection
- All catch blocks now log exception messages for debugging
- Wings connection failures logged explicitly

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude (Chronicler #83 - The Compiler)
2026-04-12 22:39:44 -05:00
parent 962dc3bd4f
commit 7ef83fd0a0
2 changed files with 91 additions and 12 deletions

View File

@@ -104,6 +104,7 @@ class CheckModpackUpdates extends Command
try {
$this->fileRepository->setServer($server);
} catch (\Exception $e) {
$this->line(" [debug] Cannot connect to Wings: " . $e->getMessage());
return null;
}
@@ -115,28 +116,49 @@ class CheckModpackUpdates extends Command
$mr = $this->detectModrinth($server);
if ($mr) return $mr;
// FTB: version.json
$ftb = $this->detectFtb($server);
if ($ftb) return $ftb;
return null;
}
private function detectCurseForge(Server $server): ?array
{
try {
$content = $this->fileRepository->getContent('manifest.json');
$manifest = json_decode($content, true);
$paths = ['manifest.json', 'minecraftinstance.json'];
if (is_array($manifest) && ($manifest['manifestType'] ?? '') === 'minecraftModpack') {
$projectId = $manifest['projectID'] ?? null;
if ($projectId) {
$this->info(" Detected CurseForge pack (projectID: {$projectId})");
foreach ($paths as $path) {
try {
$content = $this->fileRepository->getContent($path);
$data = json_decode($content, true);
if (!is_array($data)) continue;
// Standard manifest.json (CurseForge export)
if ($path === 'manifest.json' && ($data['manifestType'] ?? '') === 'minecraftModpack') {
$projectId = $data['projectID'] ?? null;
if ($projectId) {
$this->info(" Detected CurseForge via {$path} (projectID: {$projectId})");
return [
'platform' => 'curseforge',
'modpack_id' => (string) $projectId,
'name' => $data['name'] ?? null,
];
}
}
// minecraftinstance.json (CurseForge launcher install)
if ($path === 'minecraftinstance.json' && isset($data['projectID'])) {
$this->info(" Detected CurseForge via {$path} (projectID: {$data['projectID']})");
return [
'platform' => 'curseforge',
'modpack_id' => (string) $projectId,
'name' => $manifest['name'] ?? null,
'modpack_id' => (string) $data['projectID'],
'name' => $data['name'] ?? null,
];
}
} catch (\Exception $e) {
$this->line(" [debug] {$path}: " . $e->getMessage());
}
} catch (\Exception $e) {
// File doesn't exist or node offline
}
return null;
}
@@ -161,7 +183,27 @@ class CheckModpackUpdates extends Command
}
}
} catch (\Exception $e) {
// File doesn't exist or node offline
$this->line(" [debug] modrinth.index.json: " . $e->getMessage());
}
return null;
}
private function detectFtb(Server $server): ?array
{
try {
$content = $this->fileRepository->getContent('version.json');
$data = json_decode($content, true);
if (is_array($data) && isset($data['id']) && isset($data['parent'])) {
$this->info(" Detected FTB pack (id: {$data['parent']})");
return [
'platform' => 'ftb',
'modpack_id' => (string) $data['parent'],
'name' => $data['name'] ?? null,
];
}
} catch (\Exception $e) {
$this->line(" [debug] version.json (FTB): " . $e->getMessage());
}
return null;
}