mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Can install and compile SMEFT
This commit is contained in:
parent
550d744b07
commit
c84057ec22
@ -7,6 +7,9 @@ using System.Text.Json;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using NLog.Extensions.Logging;
|
||||||
|
using NLog.Targets;
|
||||||
using Octokit;
|
using Octokit;
|
||||||
using Wabbajack.CLI.TypeConverters;
|
using Wabbajack.CLI.TypeConverters;
|
||||||
using Wabbajack.CLI.Verbs;
|
using Wabbajack.CLI.Verbs;
|
||||||
@ -34,6 +37,7 @@ internal class Program
|
|||||||
new TypeConverterAttribute(typeof(ModListCategoryConverter)));
|
new TypeConverterAttribute(typeof(ModListCategoryConverter)));
|
||||||
|
|
||||||
var host = Host.CreateDefaultBuilder(Array.Empty<string>())
|
var host = Host.CreateDefaultBuilder(Array.Empty<string>())
|
||||||
|
.ConfigureLogging(AddLogging)
|
||||||
.ConfigureServices((host, services) =>
|
.ConfigureServices((host, services) =>
|
||||||
{
|
{
|
||||||
services.AddSingleton(new JsonSerializerOptions());
|
services.AddSingleton(new JsonSerializerOptions());
|
||||||
@ -81,4 +85,32 @@ internal class Program
|
|||||||
var service = host.Services.GetService<CommandLineBuilder>();
|
var service = host.Services.GetService<CommandLineBuilder>();
|
||||||
return await service!.Run(args);
|
return await service!.Run(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void AddLogging(ILoggingBuilder loggingBuilder)
|
||||||
|
{
|
||||||
|
var config = new NLog.Config.LoggingConfiguration();
|
||||||
|
|
||||||
|
var fileTarget = new FileTarget("file")
|
||||||
|
{
|
||||||
|
FileName = "logs/wabbajack-cli.current.log",
|
||||||
|
ArchiveFileName = "logs/wabbajack-cli.{##}.log",
|
||||||
|
ArchiveOldFileOnStartup = true,
|
||||||
|
MaxArchiveFiles = 10,
|
||||||
|
Layout = "${processtime} [${level:uppercase=true}] (${logger}) ${message:withexception=true}",
|
||||||
|
Header = "############ Wabbajack log file - ${longdate} ############"
|
||||||
|
};
|
||||||
|
|
||||||
|
var consoleTarget = new ConsoleTarget("console")
|
||||||
|
{
|
||||||
|
Layout = "${processtime} [${level:uppercase=true}] ${message:withexception=true}",
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
config.AddRuleForAllLevels(fileTarget);
|
||||||
|
config.AddRuleForAllLevels(consoleTarget);
|
||||||
|
|
||||||
|
loggingBuilder.ClearProviders();
|
||||||
|
loggingBuilder.SetMinimumLevel(LogLevel.Trace);
|
||||||
|
loggingBuilder.AddNLog(config);
|
||||||
|
}
|
||||||
}
|
}
|
@ -18,6 +18,8 @@
|
|||||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.2-mauipre.1.22054.8" />
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.2-mauipre.1.22054.8" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.2-mauipre.1.22054.8" />
|
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.2-mauipre.1.22054.8" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.2-mauipre.1.22054.8" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.2-mauipre.1.22054.8" />
|
||||||
|
<PackageReference Include="NLog" Version="5.0.0" />
|
||||||
|
<PackageReference Include="NLog.Extensions.Logging" Version="5.0.0" />
|
||||||
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.1" />
|
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.1" />
|
||||||
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.21561.1" />
|
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.21561.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -29,6 +29,20 @@ public static class AsyncParallelExtensions
|
|||||||
var tasks = coll.Select(mapFn).ToList();
|
var tasks = coll.Select(mapFn).ToList();
|
||||||
foreach (var itm in tasks) yield return await itm;
|
foreach (var itm in tasks) yield return await itm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Like PMapAll but don't keep defaults
|
||||||
|
public static async IAsyncEnumerable<TOut> PKeepAll<TIn, TOut>(this IEnumerable<TIn> coll,
|
||||||
|
Func<TIn, Task<TOut>> mapFn)
|
||||||
|
where TOut : class
|
||||||
|
{
|
||||||
|
var tasks = coll.Select(mapFn).ToList();
|
||||||
|
foreach (var itm in tasks)
|
||||||
|
{
|
||||||
|
var val = await itm;
|
||||||
|
if (itm != default)
|
||||||
|
yield return await itm;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static async IAsyncEnumerable<TOut> PMapAll<TIn, TJob, TOut>(this IEnumerable<TIn> coll,
|
public static async IAsyncEnumerable<TOut> PMapAll<TIn, TJob, TOut>(this IEnumerable<TIn> coll,
|
||||||
IResource<TJob> limiter, Func<TIn, Task<TOut>> mapFn)
|
IResource<TJob> limiter, Func<TIn, Task<TOut>> mapFn)
|
||||||
@ -40,6 +54,22 @@ public static class AsyncParallelExtensions
|
|||||||
yield return await itm;
|
yield return await itm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async IAsyncEnumerable<TOut> PKeepAll<TIn, TJob, TOut>(this IEnumerable<TIn> coll,
|
||||||
|
IResource<TJob> limiter, Func<TIn, Task<TOut>> mapFn)
|
||||||
|
where TOut : class
|
||||||
|
{
|
||||||
|
var tasks = coll.Select(mapFn).ToList();
|
||||||
|
foreach (var itm in tasks)
|
||||||
|
{
|
||||||
|
using var job = await limiter.Begin("", 0, CancellationToken.None);
|
||||||
|
var itmA = await itm;
|
||||||
|
if (itmA != default)
|
||||||
|
{
|
||||||
|
yield return await itm;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static async Task<List<T>> ToList<T>(this IAsyncEnumerable<T> coll)
|
public static async Task<List<T>> ToList<T>(this IAsyncEnumerable<T> coll)
|
||||||
{
|
{
|
||||||
|
@ -267,22 +267,22 @@ public abstract class ACompiler
|
|||||||
protected async Task CleanInvalidArchivesAndFillState()
|
protected async Task CleanInvalidArchivesAndFillState()
|
||||||
{
|
{
|
||||||
NextStep("Compiling", "Cleaning Invalid Archives");
|
NextStep("Compiling", "Cleaning Invalid Archives");
|
||||||
var remove = await IndexedArchives.PMapAll(CompilerLimiter, async a =>
|
var remove = await IndexedArchives.PKeepAll(CompilerLimiter, async a =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var resolved = await ResolveArchive(a);
|
var resolved = await ResolveArchive(a);
|
||||||
if (resolved == null) return null;
|
if (resolved == null) return a;
|
||||||
|
|
||||||
a.State = resolved.State;
|
a.State = resolved.State;
|
||||||
return a;
|
return default;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogWarning(ex, "While resolving archive {Archive}", a.Name);
|
_logger.LogWarning(ex, "While resolving archive {Archive}", a.Name);
|
||||||
return null;
|
return a;
|
||||||
}
|
}
|
||||||
}).ToHashSet(f => f == null);
|
}).ToHashSet();
|
||||||
|
|
||||||
if (remove.Count == 0) return;
|
if (remove.Count == 0) return;
|
||||||
|
|
||||||
|
@ -90,6 +90,8 @@ public class CompilerSettingsInferencer
|
|||||||
{
|
{
|
||||||
cs.OtherProfiles = await otherProfilesFile.ReadAllLinesAsync().ToArray();
|
cs.OtherProfiles = await otherProfilesFile.ReadAllLinesAsync().ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cs.OutputFile = cs.Source.Parent.Combine(cs.Profile).WithExtension(Ext.Wabbajack);
|
||||||
}
|
}
|
||||||
|
|
||||||
return cs;
|
return cs;
|
||||||
|
@ -45,16 +45,17 @@ public class OctoDiff
|
|||||||
|
|
||||||
private class JobProgressReporter : IProgressReporter
|
private class JobProgressReporter : IProgressReporter
|
||||||
{
|
{
|
||||||
private readonly IJob _job;
|
private readonly IJob? _job;
|
||||||
private readonly int _offset;
|
private readonly int _offset;
|
||||||
|
|
||||||
public JobProgressReporter(IJob job, int offset)
|
public JobProgressReporter(IJob? job, int offset)
|
||||||
{
|
{
|
||||||
_offset = offset;
|
_offset = offset;
|
||||||
_job = job;
|
_job = job;
|
||||||
}
|
}
|
||||||
public void ReportProgress(string operation, long currentPosition, long total)
|
public void ReportProgress(string operation, long currentPosition, long total)
|
||||||
{
|
{
|
||||||
|
if (_job == default) return;
|
||||||
var percent = Percent.FactoryPutInRange(currentPosition, total);
|
var percent = Percent.FactoryPutInRange(currentPosition, total);
|
||||||
var toReport = (long) (percent.Value * 100) - (_job.Current - _offset);
|
var toReport = (long) (percent.Value * 100) - (_job.Current - _offset);
|
||||||
_job.ReportNoWait((int) toReport);
|
_job.ReportNoWait((int) toReport);
|
||||||
|
Loading…
Reference in New Issue
Block a user