mirror of
https://github.com/FalloutCollaborationProject/FCP-Mod-Updater.git
synced 2026-07-27 17:04:05 -07:00
Refactor Update Rendering code to stay after updating mods
This commit is contained in:
@@ -38,6 +38,7 @@ public class UpdateCommand(
|
|||||||
if (updateableMods.Count == 0)
|
if (updateableMods.Count == 0)
|
||||||
{
|
{
|
||||||
AnsiConsole.MarkupLine("[green]All FCP mods are up to date![/]");
|
AnsiConsole.MarkupLine("[green]All FCP mods are up to date![/]");
|
||||||
|
await RenderAppUpdateNoticeAsync(updateCheckTask);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,15 +58,7 @@ public class UpdateCommand(
|
|||||||
|
|
||||||
ModTableRenderer.RenderUpdateSummary(results);
|
ModTableRenderer.RenderUpdateSummary(results);
|
||||||
|
|
||||||
UpdateCheckResult? updateResult = await updateCheckTask;
|
await RenderAppUpdateNoticeAsync(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);
|
var failCount = results.Count(r => !r.Success);
|
||||||
return failCount > 0 ? 1 : 0;
|
return failCount > 0 ? 1 : 0;
|
||||||
@@ -81,4 +74,14 @@ public class UpdateCommand(
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static async Task RenderAppUpdateNoticeAsync(Task<UpdateCheckResult?> updateCheckTask)
|
||||||
|
{
|
||||||
|
UpdateCheckResult? updateResult = await updateCheckTask;
|
||||||
|
if (updateResult is null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
AnsiConsole.WriteLine();
|
||||||
|
AppUpdateNoticeRenderer.Render(updateResult);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using FCPModUpdater.Services;
|
||||||
|
using Spectre.Console;
|
||||||
|
|
||||||
|
namespace FCPModUpdater.UI;
|
||||||
|
|
||||||
|
public static class AppUpdateNoticeRenderer
|
||||||
|
{
|
||||||
|
public static void Render(UpdateCheckResult updateResult)
|
||||||
|
{
|
||||||
|
var label = updateResult.IsPrerelease ? "Pre-release available" : "Update available";
|
||||||
|
|
||||||
|
AnsiConsole.MarkupLine(
|
||||||
|
$"[yellow bold]{label}: v{updateResult.LatestVersion}[/] [grey](current: {updateResult.CurrentVersion})[/]");
|
||||||
|
AnsiConsole.MarkupLine("[grey]Close this app before updating.[/]");
|
||||||
|
AnsiConsole.MarkupLine($"[grey]Run: {GetUpdateCommand()}[/]");
|
||||||
|
AnsiConsole.MarkupLine($"[grey]Manual download: {updateResult.ReleaseUrl}[/]");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetUpdateCommand()
|
||||||
|
{
|
||||||
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
|
return @"update-fcp-mod-manager.bat";
|
||||||
|
|
||||||
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||||
|
return "./update-fcp-mod-manager.sh";
|
||||||
|
|
||||||
|
return "download the latest release manually";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -47,10 +47,7 @@ public class InteractiveMenu
|
|||||||
var updateResult = await _updateCheckTask;
|
var updateResult = await _updateCheckTask;
|
||||||
if (updateResult != null)
|
if (updateResult != null)
|
||||||
{
|
{
|
||||||
var label = updateResult.IsPrerelease ? "Pre-release available" : "Update available";
|
AppUpdateNoticeRenderer.Render(updateResult);
|
||||||
AnsiConsole.MarkupLine(
|
|
||||||
$"[yellow bold]{label}: v{updateResult.LatestVersion}[/] [grey](current: {updateResult.CurrentVersion})[/]");
|
|
||||||
AnsiConsole.MarkupLine($"[grey]Download: {updateResult.ReleaseUrl}[/]");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user