Add Update Checker

This commit is contained in:
Canon
2026-02-10 18:30:04 +08:00
parent fedc202aee
commit 806adafd90
6 changed files with 141 additions and 4 deletions
+6 -1
View File
@@ -28,12 +28,17 @@ public class ScanCommand : AsyncCommand<ModPathSettings>
var gitHubApiService = new GitHubApiService();
var modDiscoveryService = new ModDiscoveryService(gitService, gitHubApiService);
// Start update check in background (non-blocking)
var updateCheckService = new UpdateCheckService(gitHubApiService.HttpClient);
var updateCheckTask = updateCheckService.CheckForUpdateAsync(cancellationToken);
// Run interactive menu
var menu = new InteractiveMenu(
gitService,
gitHubApiService,
modDiscoveryService,
modsDirectory);
modsDirectory,
updateCheckTask);
await menu.RunAsync(cancellationToken);
+15
View File
@@ -31,6 +31,10 @@ public class UpdateCommand : AsyncCommand<ModPathSettings>
var gitHubApiService = new GitHubApiService();
var modDiscoveryService = new ModDiscoveryService(gitService, gitHubApiService);
// Start update check in background (non-blocking)
var updateCheckService = new UpdateCheckService(gitHubApiService.HttpClient);
var updateCheckTask = updateCheckService.CheckForUpdateAsync(cancellationToken);
// Discover mods
var mods = await ProgressReporter.WithStatusAsync(
"Scanning mods directory...",
@@ -76,6 +80,17 @@ public class UpdateCommand : AsyncCommand<ModPathSettings>
ModTableRenderer.RenderUpdateSummary(results);
// Show update notification if available
var updateResult = await updateCheckTask;
if (updateResult != null)
{
AnsiConsole.WriteLine();
var label = updateResult.IsPrerelease ? "Pre-release available" : "Update available";
AnsiConsole.MarkupLine(
$"[yellow bold]{label}: v{updateResult.LatestVersion}[/] [grey](current: {updateResult.CurrentVersion})[/]");
AnsiConsole.MarkupLine($"[grey]Download: {updateResult.ReleaseUrl}[/]");
}
var failCount = results.Count(r => !r.Success);
return failCount > 0 ? 1 : 0;
}