Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small fixes and Export CLI method #2154

Merged
merged 3 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<PackageVersion Include="Nerdbank.FullDuplexStream" Version="1.1.12" />
<PackageVersion Include="Nerdbank.Streams" Version="2.11.74" />
<PackageVersion Include="NexusMods.Paths" Version="0.10.0" />
<PackageVersion Include="NexusMods.MnemonicDB.Abstractions" Version="0.9.86" />
<PackageVersion Include="NexusMods.MnemonicDB" Version="0.9.86" />
<PackageVersion Include="NexusMods.MnemonicDB.Abstractions" Version="0.9.89" />
<PackageVersion Include="NexusMods.MnemonicDB" Version="0.9.89" />
<PackageVersion Include="NexusMods.Hashing.xxHash64" Version="2.0.2" />
<PackageVersion Include="NexusMods.Paths.Extensions.Nx" Version="0.10.0" />
<PackageVersion Include="NexusMods.Paths.TestingHelpers" Version="0.10.0" />
Expand Down Expand Up @@ -127,7 +127,7 @@
<PackageVersion Include="Humanizer" Version="2.14.1" />
<PackageVersion Include="ini-parser-netstandard" Version="2.5.2" />
<PackageVersion Include="Mutagen.Bethesda.Skyrim" Version="0.44.0" />
<PackageVersion Include="NexusMods.MnemonicDB.SourceGenerator" Version="0.9.86" />
<PackageVersion Include="NexusMods.MnemonicDB.SourceGenerator" Version="0.9.89" />
<PackageVersion Include="NLog.Extensions.Logging" Version="5.3.11" />
<PackageVersion Include="OneOf" Version="3.0.271" />
<PackageVersion Include="ReactiveUI.Fody" Version="19.5.41" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using NexusMods.MnemonicDB.Storage;
using NexusMods.Paths;
using ModFileTreeNode = NexusMods.Paths.Trees.KeyedBox<NexusMods.Paths.RelativePath, NexusMods.Abstractions.FileStore.Trees.ModFileTree>;
using ULongAttribute = NexusMods.Abstractions.MnemonicDB.Attributes.ULongAttribute;
halgari marked this conversation as resolved.
Show resolved Hide resolved

namespace NexusMods.Abstractions.FileStore.Downloads;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using NexusMods.Abstractions.MnemonicDB.Attributes;
using NexusMods.MnemonicDB.Abstractions.Attributes;
using NexusMods.MnemonicDB.Abstractions.Models;
using ULongAttribute = NexusMods.Abstractions.MnemonicDB.Attributes.ULongAttribute;

namespace NexusMods.Abstractions.Loadouts.Files;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using NexusMods.MnemonicDB.Abstractions.Models;
using NexusMods.MnemonicDB.Abstractions.TxFunctions;
using File = NexusMods.Abstractions.Loadouts.Files.File;
using ULongAttribute = NexusMods.Abstractions.MnemonicDB.Attributes.ULongAttribute;

namespace NexusMods.Abstractions.Loadouts;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using NexusMods.MnemonicDB.Abstractions.TxFunctions;
using NexusMods.MnemonicDB.Storage;
using File = NexusMods.Abstractions.Loadouts.Files.File;
using ULongAttribute = NexusMods.Abstractions.MnemonicDB.Attributes.ULongAttribute;

namespace NexusMods.Abstractions.Loadouts.Mods;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using NexusMods.Abstractions.MnemonicDB.Attributes;
using NexusMods.MnemonicDB.Abstractions.Attributes;
using NexusMods.MnemonicDB.Abstractions.Models;
using ULongAttribute = NexusMods.Abstractions.MnemonicDB.Attributes.ULongAttribute;

namespace NexusMods.Abstractions.NexusModsLibrary;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using NexusMods.Abstractions.Resources.DB;
using NexusMods.MnemonicDB.Abstractions.Attributes;
using NexusMods.MnemonicDB.Abstractions.Models;
using ULongAttribute = NexusMods.Abstractions.MnemonicDB.Attributes.ULongAttribute;

namespace NexusMods.Abstractions.NexusModsLibrary.Models;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using NexusMods.Abstractions.NexusModsLibrary.Attributes;
using NexusMods.MnemonicDB.Abstractions.Attributes;
using NexusMods.MnemonicDB.Abstractions.Models;
using ULongAttribute = NexusMods.Abstractions.MnemonicDB.Attributes.ULongAttribute;

namespace NexusMods.Abstractions.NexusModsLibrary.Models;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using NexusMods.Abstractions.MnemonicDB.Attributes;
using NexusMods.MnemonicDB.Abstractions.Attributes;
using NexusMods.MnemonicDB.Abstractions.Models;
using ULongAttribute = NexusMods.Abstractions.MnemonicDB.Attributes.ULongAttribute;

namespace NexusMods.Abstractions.NexusModsLibrary.Models;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using NexusMods.Abstractions.NexusModsLibrary.Attributes;
using NexusMods.MnemonicDB.Abstractions.Attributes;
using NexusMods.MnemonicDB.Abstractions.Models;
using ULongAttribute = NexusMods.Abstractions.MnemonicDB.Attributes.ULongAttribute;

namespace NexusMods.Abstractions.NexusModsLibrary.Models;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,7 @@ public async Task LoginAsync(CancellationToken token = default)
public async Task Logout()
{
_cachedUserInfo.Evict();
using var tx = _conn.BeginTransaction();
foreach (var token in JWTToken.All(_conn.Db))
{
tx.Delete(token.Id, true);
}
await tx.Commit();
await _conn.Excise(JWTToken.All(_conn.Db).Select(e => e.Id).ToArray());
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ private async Task<byte[]> DownloadImage(string? uri, CancellationToken token)

var filesResponse = await _apiClient.ModFilesAsync(gameDomain.ToString(), modPage.Uid.ModId, cancellationToken);
var files = filesResponse.Data.Files;

if (!files.TryGetFirst(x => x.FileId == fileId, out var fileInfo))
throw new NotImplementedException();

Expand Down
2 changes: 1 addition & 1 deletion src/NexusMods.Collections/InstallCollectionJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ private async Task<ModInstructions> EnsureNexusModDownloaded(Mod mod)

if (file.HasValue)
{
if (!file.Value.LibraryFiles.First().AsLibraryItem().TryGetAsLibraryFile(out var firstLibraryFile))
if (file.Value.LibraryFiles.First().AsLibraryItem().TryGetAsLibraryFile(out var firstLibraryFile))
return (mod, firstLibraryFile);
}

Expand Down
37 changes: 37 additions & 0 deletions src/NexusMods.DataModel/CommandLine/Verbs/ImportExport.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System.IO.Compression;
using Microsoft.Extensions.DependencyInjection;
using NexusMods.Abstractions.Cli;
using NexusMods.MnemonicDB.Abstractions;
using NexusMods.Paths;
using NexusMods.ProxyConsole.Abstractions;
using NexusMods.ProxyConsole.Abstractions.VerbDefinitions;

namespace NexusMods.DataModel.CommandLine.Verbs;

/// <summary>
/// Routines for importing and exporting the data model
/// </summary>
public static class ImportExport
{
/// <summary>
/// Register the import/export verbs
/// </summary>
/// <param name="services"></param>
/// <returns></returns>
public static IServiceCollection AddImportExportVerbs(this IServiceCollection services) =>
services.AddVerb(() => Export);

[Verb("export-datamodel", "Export the data model to a file")]
private static async Task<int> Export([Injected] IRenderer renderer,
[Injected] IConnection connection,
[Option("o", "output", "Output file, the contents will be compressed with deflate")] AbsolutePath output)
{
await using var stream = output.Create();
await renderer.RenderAsync(Renderable.Text("Exporting data model to file"));
await using var deflateStream = new DeflateStream(stream, CompressionLevel.Optimal);
await connection.DatomStore.ExportAsync(deflateStream);
await renderer.RenderAsync(Renderable.Text("Exported data model to file"));
return 0;
}

}
1 change: 1 addition & 0 deletions src/NexusMods.DataModel/Services.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public static IServiceCollection AddDataModel(this IServiceCollection coll)

// Verbs
coll.AddLoadoutManagementVerbs()
.AddImportExportVerbs()
.AddToolVerbs();

return coll;
Expand Down
Loading