option('repair')) { return $this->repairEmulator($updateService, $alertService); } if (! $updateService->isConfigured()) { $this->error('Geen GitHub URL geconfigureerd voor emulator updates.'); $this->info('Configureer dit in Filament > Settings > Emulator'); return Command::FAILURE; } $this->info('Emulator update service gestart...'); $checkResult = $updateService->checkForUpdates(); if (isset($checkResult['error'])) { $this->error($checkResult['error']); return Command::FAILURE; } $this->table( ['Property', 'Value'], [ ['Huidige Versie', $checkResult['current_version']], ['Nieuwste Versie', $checkResult['latest_version']], ['Update Beschikbaar', $checkResult['update_available'] ? 'JA' : 'NEE'], ['Type', $checkResult['update_type'] ?? 'N/A'], ], ); if ($this->option('check')) { return Command::SUCCESS; } $force = $this->option('force'); $rebuild = $this->option('rebuild'); if (! $checkResult['update_available'] && ! $force && ! $rebuild) { $this->info('Emulator is al up-to-date!'); return Command::SUCCESS; } if (! $checkResult['update_available'] && ($force || $rebuild)) { $this->warn('Geen nieuwe versie beschikbaar, maar force/rebuild aangevraagd.'); } if (! $force && ! $rebuild && ! $this->confirm('Wil je de emulator updaten naar v' . $checkResult['latest_version'] . '?')) { $this->info('Update geannuleerd.'); return Command::SUCCESS; } $this->info('Emulator wordt geüpdatet...'); try { if ($rebuild || $checkResult['type'] === 'source_build') { $this->info('Build vanaf source...'); $result = $updateService->buildFromSource($force); } else { $result = $updateService->updateEmulator(); } if ($result['success']) { $this->info($result['message'] ?? 'Emulator succesvol geüpdatet!'); $alertService->send( AlertType::EMULATOR_ONLINE, 'Emulator succesvol geüpdatet naar v' . ($result['version'] ?? 'onbekend'), [ 'version' => $result['version'] ?? 'onbekend', 'jar' => $result['jar'] ?? 'N/A', ], AlertChannel::DISCORD, ); Log::info('[EmulatorUpdateCommand] Update successful', $result); return Command::SUCCESS; } $this->error('Update mislukt: ' . ($result['error'] ?? 'Onbekende fout')); $alertService->send( AlertType::EMULATOR_ERROR, 'Emulator update mislukt: ' . ($result['error'] ?? 'Onbekende fout'), [], AlertChannel::DISCORD, ); Log::error('[EmulatorUpdateCommand] Update failed', $result); return Command::FAILURE; } catch (\Exception $e) { $this->error('Update exception: ' . $e->getMessage()); $alertService->send( AlertType::CRITICAL_ERROR, 'Emulator update exception: ' . $e->getMessage(), [], AlertChannel::DISCORD, ); Log::error('[EmulatorUpdateCommand] Exception', ['error' => $e->getMessage()]); return Command::FAILURE; } } private function repairEmulator(EmulatorUpdateService $updateService, AlertService $alertService): int { $this->warn('🔧 Emulator repair modus gestart...'); $this->info('Dit zal de emulator status controleren en proberen te repareren.'); try { $repairResult = $updateService->repairEmulator(); if ($repairResult['success']) { $this->info('✅ Repair succesvol!'); foreach ($repairResult['actions'] ?? [] as $action) { $this->line(' - ' . $action); } $alertService->send( AlertType::EMULATOR_ONLINE, 'Emulator gerepareerd', ['actions' => $repairResult['actions'] ?? []], AlertChannel::DISCORD, ); return Command::SUCCESS; } $this->error('❌ Repair mislukt: ' . ($repairResult['error'] ?? 'Onbekende fout')); $alertService->send( AlertType::EMULATOR_ERROR, 'Emulator repair mislukt: ' . ($repairResult['error'] ?? 'Onbekende fout'), [], AlertChannel::DISCORD, ); return Command::FAILURE; } catch (\Exception $e) { $this->error('❌ Repair exception: ' . $e->getMessage()); return Command::FAILURE; } } }