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