mirror of
https://github.com/FalloutCollaborationProject/FCP-Mod-Updater.git
synced 2026-07-27 17:04:05 -07:00
Update to Spectre Console 0.55
This commit is contained in:
@@ -1,30 +1,30 @@
|
||||
using FCPModUpdater.Commands.Settings;
|
||||
using FCPModUpdater.Services;
|
||||
using FCPModUpdater.UI;
|
||||
using JetBrains.Annotations;
|
||||
using Spectre.Console;
|
||||
using Spectre.Console.Cli;
|
||||
|
||||
namespace FCPModUpdater.Commands;
|
||||
|
||||
[UsedImplicitly]
|
||||
public class ScanCommand(
|
||||
IGitService gitService,
|
||||
IGitHubApiService gitHubApiService,
|
||||
IModDiscoveryService modDiscoveryService,
|
||||
UpdateCheckService updateCheckService) : AsyncCommand<ModPathSettings>
|
||||
{
|
||||
public override async Task<int> ExecuteAsync(CommandContext context, ModPathSettings settings,
|
||||
protected override async Task<int> ExecuteAsync(CommandContext context, ModPathSettings settings,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
var modsDirectory = ModsDirectoryResolver.Resolve(settings.ModDirectory?.FullName, interactive: true);
|
||||
if (modsDirectory == null)
|
||||
return 1;
|
||||
|
||||
AnsiConsole.MarkupLine($"[grey]Using mods directory: {modsDirectory}[/]");
|
||||
AnsiConsole.WriteLine();
|
||||
|
||||
var updateCheckTask = updateCheckService.CheckForUpdateAsync(cancellationToken);
|
||||
Task<UpdateCheckResult?> updateCheckTask = updateCheckService.CheckForUpdateAsync(cancellationToken);
|
||||
|
||||
var menu = new InteractiveMenu(
|
||||
gitService,
|
||||
|
||||
@@ -17,23 +17,21 @@ public class UpdateCommand(
|
||||
public static IReadOnlyList<InstalledMod> GetUpdateableMods(IReadOnlyList<InstalledMod> mods)
|
||||
=> mods.Where(m => m.Source == ModSource.Git && m.Status == ModStatus.Behind).ToList();
|
||||
|
||||
public override async Task<int> ExecuteAsync(CommandContext context, ModPathSettings settings,
|
||||
CancellationToken cancellationToken)
|
||||
protected override async Task<int> ExecuteAsync(CommandContext context, ModPathSettings settings,
|
||||
CancellationToken ct)
|
||||
{
|
||||
try
|
||||
{
|
||||
var modsDirectory = ModsDirectoryResolver.Resolve(settings.ModDirectory?.FullName, interactive: false);
|
||||
if (modsDirectory == null)
|
||||
return 1;
|
||||
|
||||
AnsiConsole.MarkupLine($"[grey]Using mods directory: {modsDirectory}[/]");
|
||||
AnsiConsole.WriteLine();
|
||||
|
||||
var updateCheckTask = updateCheckService.CheckForUpdateAsync(cancellationToken);
|
||||
Task<UpdateCheckResult?> updateCheckTask = updateCheckService.CheckForUpdateAsync(ct);
|
||||
|
||||
var mods = await ProgressReporter.WithStatusAsync(
|
||||
"Scanning mods directory...",
|
||||
async () => await modDiscoveryService.DiscoverModsAsync(modsDirectory, ct: cancellationToken));
|
||||
async () => await modDiscoveryService.DiscoverModsAsync(modsDirectory, ct: ct));
|
||||
|
||||
var updateableMods = GetUpdateableMods(mods);
|
||||
|
||||
@@ -54,16 +52,16 @@ public class UpdateCommand(
|
||||
var results = await ProgressReporter.WithBatchProgressAsync(
|
||||
"Updating mods",
|
||||
updateableMods,
|
||||
m => m.Name,
|
||||
installedMod => installedMod.Name,
|
||||
async (mod, progress) =>
|
||||
{
|
||||
progress.Report(25);
|
||||
var fetchOk = await gitService.FetchAsync(mod.Path, ct: cancellationToken);
|
||||
var fetchOk = await gitService.FetchAsync(mod.Path, ct: ct);
|
||||
if (!fetchOk)
|
||||
return (false, "Fetch failed");
|
||||
|
||||
progress.Report(50);
|
||||
var pullOk = await gitService.PullAsync(mod.Path, ct: cancellationToken);
|
||||
var pullOk = await gitService.PullAsync(mod.Path, ct: ct);
|
||||
progress.Report(100);
|
||||
|
||||
return (pullOk, pullOk ? null : "Pull failed");
|
||||
@@ -71,7 +69,7 @@ public class UpdateCommand(
|
||||
|
||||
ModTableRenderer.RenderUpdateSummary(results);
|
||||
|
||||
var updateResult = await updateCheckTask;
|
||||
UpdateCheckResult? updateResult = await updateCheckTask;
|
||||
if (updateResult != null)
|
||||
{
|
||||
AnsiConsole.WriteLine();
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
<PackageReference Include="JetBrains.Annotations" Version="2025.2.4" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.5" />
|
||||
<PackageReference Include="Microsoft.Extensions.Http" Version="10.0.5" />
|
||||
<PackageReference Include="Spectre.Console" Version="0.54.0" />
|
||||
<PackageReference Include="Spectre.Console.Cli" Version="0.53.1" />
|
||||
<PackageReference Include="Spectre.Console" Version="0.55.0" />
|
||||
<PackageReference Include="Spectre.Console.Cli" Version="0.55.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||
|
||||
+15
-7
@@ -39,17 +39,20 @@
|
||||
},
|
||||
"Spectre.Console": {
|
||||
"type": "Direct",
|
||||
"requested": "[0.54.0, )",
|
||||
"resolved": "0.54.0",
|
||||
"contentHash": "StDXCFayfy0yB1xzUHT2tgEpV1/HFTiS4JgsAQS49EYTfMixSwwucaQs/bIOCwXjWwIQTMuxjUIxcB5XsJkFJA=="
|
||||
"requested": "[0.55.0, )",
|
||||
"resolved": "0.55.0",
|
||||
"contentHash": "2TVhUHFsDux0Z+y2Hv4bFsOMuON4SuotEEKkMparFkp5Rm259naaaEQrN4Sv6C1cbsiGKPjfkJDGgUp+hZPjTw==",
|
||||
"dependencies": {
|
||||
"Spectre.Console.Ansi": "0.55.0"
|
||||
}
|
||||
},
|
||||
"Spectre.Console.Cli": {
|
||||
"type": "Direct",
|
||||
"requested": "[0.53.1, )",
|
||||
"resolved": "0.53.1",
|
||||
"contentHash": "y//7ZZ0shhvgXzoJXJzMaLGA4dPem8qCbkyv9khfE8NQDlH4hPVsHOHYoz6uzAwiTX9Yd7OnX3wNOX/wRfPUOg==",
|
||||
"requested": "[0.55.0, )",
|
||||
"resolved": "0.55.0",
|
||||
"contentHash": "cFJTB1te4eaAICd4Zp+8T/kiRn1ikQxgGqmoNarb1qoQ/7LzHAvVQ62x5U9GW3E0QI7sZLcXIIoq4CpqgTx42Q==",
|
||||
"dependencies": {
|
||||
"Spectre.Console": "0.53.1"
|
||||
"Spectre.Console": "0.55.0"
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.Configuration": {
|
||||
@@ -145,6 +148,11 @@
|
||||
"type": "Transitive",
|
||||
"resolved": "10.0.5",
|
||||
"contentHash": "/HUHJ0tw/LQvD0DZrz50eQy/3z7PfX7WWEaXnjKTV9/TNdcgFlNTZGo49QhS7PTmhDqMyHRMqAXSBxLh0vso4g=="
|
||||
},
|
||||
"Spectre.Console.Ansi": {
|
||||
"type": "Transitive",
|
||||
"resolved": "0.55.0",
|
||||
"contentHash": "GIfgOvuF8MpU52bprhwtDEtx0gmVIGOepM8bw0lH/TSMD0rg1Xp+5Y53kPG8rFVdcpbNANlhDQ5mEVVPO3/2Tg=="
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user