diff --git a/ThunderstoreCLI/API/ApiHelper.cs b/ThunderstoreCLI/API/ApiHelper.cs index afd05ef..2c1f1fa 100644 --- a/ThunderstoreCLI/API/ApiHelper.cs +++ b/ThunderstoreCLI/API/ApiHelper.cs @@ -108,7 +108,7 @@ public HttpRequestMessage GetPackagesV1(string community) private static string SerializeFileData(string filePath) { - return new FileData() + return new FileData { Filename = Path.GetFileName(filePath), Filesize = new FileInfo(filePath).Length diff --git a/ThunderstoreCLI/Commands/BuildCommand.cs b/ThunderstoreCLI/Commands/BuildCommand.cs index 3cdbeac..ba58a67 100644 --- a/ThunderstoreCLI/Commands/BuildCommand.cs +++ b/ThunderstoreCLI/Commands/BuildCommand.cs @@ -294,14 +294,19 @@ public static string FormatArchivePath(string path, bool validate = true) public static string SerializeManifest(Config config) { var dependencies = config.PackageConfig.Dependencies ?? new Dictionary(); - var manifest = new PackageManifestV1() + IEnumerable? installerDeclarations = config.InstallConfig.InstallerDeclarations; + installerDeclarations ??= Array.Empty(); + var manifest = new PackageManifestV1 { Namespace = config.PackageConfig.Namespace, Name = config.PackageConfig.Name, Description = config.PackageConfig.Description, VersionNumber = config.PackageConfig.VersionNumber, WebsiteUrl = config.PackageConfig.WebsiteUrl, - Dependencies = dependencies.Select(x => $"{x.Key}-{x.Value}").ToArray() + Dependencies = dependencies.Select(x => $"{x.Key}-{x.Value}").ToArray(), + Installers = installerDeclarations + .Select(x => new PackageManifestV1.InstallerDeclaration { Identifier = x.Identifier }) + .ToArray() }; return manifest.Serialize(BaseJson.IndentedSettings); diff --git a/ThunderstoreCLI/Commands/InitCommand.cs b/ThunderstoreCLI/Commands/InitCommand.cs index a63bb57..bdb5f21 100644 --- a/ThunderstoreCLI/Commands/InitCommand.cs +++ b/ThunderstoreCLI/Commands/InitCommand.cs @@ -38,7 +38,7 @@ public static int Run(Config config) { Write.Line($"Project configuration already exists, overwriting"); } - File.WriteAllText(path, new ThunderstoreProject(true).Serialize()); + File.WriteAllText(path, new ThunderstoreProject(Config.DefaultConfig).Serialize()); var iconPath = config.GetPackageIconPath(); if (File.Exists(iconPath)) diff --git a/ThunderstoreCLI/Commands/InstallCommand.cs b/ThunderstoreCLI/Commands/InstallCommand.cs index 1d7bb28..0b76ce4 100644 --- a/ThunderstoreCLI/Commands/InstallCommand.cs +++ b/ThunderstoreCLI/Commands/InstallCommand.cs @@ -1,6 +1,5 @@ using System.Diagnostics; using System.IO.Compression; -using System.Net.Http.Headers; using System.Runtime.InteropServices; using System.Text.RegularExpressions; using ThunderstoreCLI.Configuration; diff --git a/ThunderstoreCLI/Commands/PublishCommand.cs b/ThunderstoreCLI/Commands/PublishCommand.cs index de07e9b..2b5e437 100644 --- a/ThunderstoreCLI/Commands/PublishCommand.cs +++ b/ThunderstoreCLI/Commands/PublishCommand.cs @@ -253,7 +253,7 @@ private static void PublishPackageRequest(Config config, string uploadUuid) throw new PublishCommandException(); } - return new CompletedUpload.CompletedPartData() + return new CompletedUpload.CompletedPartData { ETag = response.Headers.ETag.Tag, PartNumber = part.PartNumber diff --git a/ThunderstoreCLI/Commands/RunCommand.cs b/ThunderstoreCLI/Commands/RunCommand.cs index d3b7de2..48899b2 100644 --- a/ThunderstoreCLI/Commands/RunCommand.cs +++ b/ThunderstoreCLI/Commands/RunCommand.cs @@ -1,6 +1,5 @@ using System.Diagnostics; using System.Runtime.InteropServices; -using System.Text; using ThunderstoreCLI.Configuration; using ThunderstoreCLI.Game; using ThunderstoreCLI.Utils; diff --git a/ThunderstoreCLI/Configuration/CLIParameterConfig.cs b/ThunderstoreCLI/Configuration/CLIParameterConfig.cs index 759873e..04d5750 100644 --- a/ThunderstoreCLI/Configuration/CLIParameterConfig.cs +++ b/ThunderstoreCLI/Configuration/CLIParameterConfig.cs @@ -11,7 +11,7 @@ public BaseConfig(T options) public override GeneralConfig GetGeneralConfig() { - return new GeneralConfig() + return new GeneralConfig { TcliConfig = options.TcliDirectory, Repository = options.Repository @@ -29,7 +29,7 @@ public CLIParameterConfig(T opts) : base(opts) { } { if (options == null) return null; - return new PackageConfig() + return new PackageConfig { ProjectConfigPath = options.ConfigPath, Namespace = options.Namespace, @@ -45,7 +45,7 @@ public CLIInitCommandConfig(InitOptions options) : base(options) { } public override InitConfig GetInitConfig() { - return new InitConfig() + return new InitConfig { Overwrite = options.Overwrite }; @@ -63,7 +63,7 @@ public CLIPublishCommandConfig(PublishOptions options) : base(options) { } public override PublishConfig GetPublishConfig() { - return new PublishConfig() + return new PublishConfig { File = options.File }; @@ -71,7 +71,7 @@ public override PublishConfig GetPublishConfig() public override AuthConfig GetAuthConfig() { - return new AuthConfig() + return new AuthConfig { AuthToken = options.Token }; @@ -82,9 +82,9 @@ public class ModManagementCommandConfig : BaseConfig { public ModManagementCommandConfig(ModManagementOptions options) : base(options) { } - public override ModManagementConfig? GetModManagementConfig() + public override ModManagementConfig GetModManagementConfig() { - return new ModManagementConfig() + return new ModManagementConfig { GameIdentifer = options.GameName, ProfileName = options.Profile, @@ -97,9 +97,9 @@ public class GameImportCommandConfig : BaseConfig { public GameImportCommandConfig(GameImportOptions options) : base(options) { } - public override GameImportConfig? GetGameImportConfig() + public override GameImportConfig GetGameImportConfig() { - return new GameImportConfig() + return new GameImportConfig { ExePath = options.ExePath, GameId = options.GameId, @@ -111,9 +111,9 @@ public class RunGameCommandConfig : BaseConfig { public RunGameCommandConfig(RunGameOptions options) : base(options) { } - public override RunGameConfig? GetRunGameConfig() + public override RunGameConfig GetRunGameConfig() { - return new RunGameConfig() + return new RunGameConfig { GameName = options.GameName, ProfileName = options.Profile, diff --git a/ThunderstoreCLI/Configuration/Config.cs b/ThunderstoreCLI/Configuration/Config.cs index ff35a83..d561891 100644 --- a/ThunderstoreCLI/Configuration/Config.cs +++ b/ThunderstoreCLI/Configuration/Config.cs @@ -13,6 +13,7 @@ public class Config public required InitConfig InitConfig { get; init; } public required BuildConfig BuildConfig { get; init; } public required PublishConfig PublishConfig { get; init; } + public required InstallConfig InstallConfig { get; init; } public required AuthConfig AuthConfig { get; init; } public required ModManagementConfig ModManagementConfig { get; init; } public required GameImportConfig GameImportConfig { get; init; } @@ -30,6 +31,23 @@ private Config() api = new Lazy(() => new ApiHelper(this)); cache = new Lazy(() => new DownloadCache(Path.Combine(GeneralConfig!.TcliConfig, "ModCache"))); } + + private static Config BlankConfig => new() + { + GeneralConfig = new GeneralConfig(), + PackageConfig = new PackageConfig(), + InitConfig = new InitConfig(), + BuildConfig = new BuildConfig(), + PublishConfig = new PublishConfig(), + InstallConfig = new InstallConfig(), + AuthConfig = new AuthConfig(), + ModManagementConfig = new ModManagementConfig(), + GameImportConfig = new GameImportConfig(), + RunGameConfig = new RunGameConfig(), + }; + + public static Config DefaultConfig => MergeConfigFromProvider(BlankConfig, new DefaultConfig(), true); + public static Config FromCLI(IConfigProvider cliConfig) { List providers = new(); @@ -99,7 +117,7 @@ public string GetBuildOutputFile() public PackageUploadMetadata GetUploadMetadata(string fileUuid) { - return new PackageUploadMetadata() + return new PackageUploadMetadata { AuthorName = PackageConfig.Namespace, Categories = PublishConfig.Categories!.GetOrDefault("") ?? Array.Empty(), @@ -114,34 +132,30 @@ public PackageUploadMetadata GetUploadMetadata(string fileUuid) public static Config Parse(IConfigProvider[] configProviders) { - Config result = new() - { - GeneralConfig = new GeneralConfig(), - PackageConfig = new PackageConfig(), - InitConfig = new InitConfig(), - BuildConfig = new BuildConfig(), - PublishConfig = new PublishConfig(), - AuthConfig = new AuthConfig(), - ModManagementConfig = new ModManagementConfig(), - GameImportConfig = new GameImportConfig(), - RunGameConfig = new RunGameConfig(), - }; + var result = BlankConfig; foreach (var provider in configProviders) { - provider.Parse(result); - Merge(result.GeneralConfig, provider.GetGeneralConfig(), false); - Merge(result.PackageConfig, provider.GetPackageMeta(), false); - Merge(result.InitConfig, provider.GetInitConfig(), false); - Merge(result.BuildConfig, provider.GetBuildConfig(), false); - Merge(result.PublishConfig, provider.GetPublishConfig(), false); - Merge(result.AuthConfig, provider.GetAuthConfig(), false); - Merge(result.ModManagementConfig, provider.GetModManagementConfig(), false); - Merge(result.GameImportConfig, provider.GetGameImportConfig(), false); - Merge(result.RunGameConfig, provider.GetRunGameConfig(), false); + MergeConfigFromProvider(result, provider, false); } return result; } + public static Config MergeConfigFromProvider(Config target, IConfigProvider provider, bool overwrite) + { + provider.Parse(target); + Merge(target.GeneralConfig, provider.GetGeneralConfig(), overwrite); + Merge(target.PackageConfig, provider.GetPackageMeta(), overwrite); + Merge(target.InitConfig, provider.GetInitConfig(), overwrite); + Merge(target.BuildConfig, provider.GetBuildConfig(), overwrite); + Merge(target.PublishConfig, provider.GetPublishConfig(), overwrite); + Merge(target.InstallConfig, provider.GetInstallConfig(), overwrite); + Merge(target.AuthConfig, provider.GetAuthConfig(), overwrite); + Merge(target.ModManagementConfig, provider.GetModManagementConfig(), overwrite); + Merge(target.GameImportConfig, provider.GetGameImportConfig(), overwrite); + Merge(target.RunGameConfig, provider.GetRunGameConfig(), overwrite); + return target; + } + public static void Merge<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] T>(T target, T source, bool overwrite) { if (source == null) @@ -218,6 +232,21 @@ public class PublishConfig public Dictionary? Categories { get; set; } } +public struct InstallerDeclaration +{ + public readonly string Identifier; + + public InstallerDeclaration(string identifier) + { + Identifier = identifier; + } +} + +public class InstallConfig +{ + public List? InstallerDeclarations { get; set; } +} + public class AuthConfig { public string? AuthToken { get; set; } diff --git a/ThunderstoreCLI/Configuration/DefaultConfig.cs b/ThunderstoreCLI/Configuration/DefaultConfig.cs index c78cef7..64cd744 100644 --- a/ThunderstoreCLI/Configuration/DefaultConfig.cs +++ b/ThunderstoreCLI/Configuration/DefaultConfig.cs @@ -2,9 +2,9 @@ namespace ThunderstoreCLI.Configuration; class DefaultConfig : EmptyConfig { - public override GeneralConfig? GetGeneralConfig() + public override GeneralConfig GetGeneralConfig() { - return new GeneralConfig() + return new GeneralConfig { Repository = Defaults.REPOSITORY_URL }; @@ -12,25 +12,25 @@ class DefaultConfig : EmptyConfig public override PackageConfig GetPackageMeta() { - return new PackageConfig() + return new PackageConfig { ProjectConfigPath = Defaults.PROJECT_CONFIG_PATH, Namespace = "AuthorName", Name = "PackageName", VersionNumber = "0.0.1", Description = "Example mod description", - WebsiteUrl = "", + WebsiteUrl = "https://thunderstore.io", ContainsNsfwContent = false, Dependencies = new() { - { "Example-Dependency", "1.0.0" } + { "AuthorName-PackageName", "0.0.1" } } }; } public override InitConfig GetInitConfig() { - return new InitConfig() + return new InitConfig { Overwrite = false }; @@ -38,23 +38,32 @@ public override InitConfig GetInitConfig() public override BuildConfig GetBuildConfig() { - return new BuildConfig() + return new BuildConfig { IconPath = "./icon.png", ReadmePath = "./README.md", OutDir = "./build", - CopyPaths = new() - { - { new("./dist", "") } - } + CopyPaths = [new("./dist", "")] }; } public override PublishConfig GetPublishConfig() { - return new PublishConfig() + return new PublishConfig + { + File = null, + Communities = ["riskofrain2"], + Categories = new Dictionary { + { "riskofrain2", ["items", "skills", ] }, + } + }; + } + + public override InstallConfig GetInstallConfig() + { + return new InstallConfig { - File = null + InstallerDeclarations = [new InstallerDeclaration("foo-installer")] }; } } diff --git a/ThunderstoreCLI/Configuration/EmptyConfig.cs b/ThunderstoreCLI/Configuration/EmptyConfig.cs index c3074b5..20839e9 100644 --- a/ThunderstoreCLI/Configuration/EmptyConfig.cs +++ b/ThunderstoreCLI/Configuration/EmptyConfig.cs @@ -4,48 +4,23 @@ namespace ThunderstoreCLI.Configuration; public abstract class EmptyConfig : IConfigProvider { public virtual void Parse(Config currentConfig) { } - public virtual GeneralConfig? GetGeneralConfig() - { - return null; - } - - public virtual PackageConfig? GetPackageMeta() - { - return null; - } - - public virtual InitConfig? GetInitConfig() - { - return null; - } - - public virtual BuildConfig? GetBuildConfig() - { - return null; - } - - public virtual PublishConfig? GetPublishConfig() - { - return null; - } - - public virtual AuthConfig? GetAuthConfig() - { - return null; - } - - public virtual ModManagementConfig? GetModManagementConfig() - { - return null; - } - - public virtual GameImportConfig? GetGameImportConfig() - { - return null; - } - - public virtual RunGameConfig? GetRunGameConfig() - { - return null; - } + public virtual GeneralConfig? GetGeneralConfig() => null; + + public virtual PackageConfig? GetPackageMeta() => null; + + public virtual InitConfig? GetInitConfig() => null; + + public virtual BuildConfig? GetBuildConfig() => null; + + public virtual PublishConfig? GetPublishConfig() => null; + + public virtual InstallConfig? GetInstallConfig() => null; + + public virtual AuthConfig? GetAuthConfig() => null; + + public virtual ModManagementConfig? GetModManagementConfig() => null; + + public virtual GameImportConfig? GetGameImportConfig() => null; + + public virtual RunGameConfig? GetRunGameConfig() => null; } diff --git a/ThunderstoreCLI/Configuration/EnvironmentConfig.cs b/ThunderstoreCLI/Configuration/EnvironmentConfig.cs index 3d64dbf..e1d571e 100644 --- a/ThunderstoreCLI/Configuration/EnvironmentConfig.cs +++ b/ThunderstoreCLI/Configuration/EnvironmentConfig.cs @@ -8,7 +8,7 @@ class EnvironmentConfig : EmptyConfig public override AuthConfig GetAuthConfig() { - return new AuthConfig() + return new AuthConfig { AuthToken = ReadEnv(AUTH_TOKEN) }; diff --git a/ThunderstoreCLI/Configuration/IConfigProvider.cs b/ThunderstoreCLI/Configuration/IConfigProvider.cs index 89b2e70..956275a 100644 --- a/ThunderstoreCLI/Configuration/IConfigProvider.cs +++ b/ThunderstoreCLI/Configuration/IConfigProvider.cs @@ -9,6 +9,7 @@ public interface IConfigProvider InitConfig? GetInitConfig(); BuildConfig? GetBuildConfig(); PublishConfig? GetPublishConfig(); + InstallConfig? GetInstallConfig(); AuthConfig? GetAuthConfig(); ModManagementConfig? GetModManagementConfig(); GameImportConfig? GetGameImportConfig(); diff --git a/ThunderstoreCLI/Configuration/ProjectFileConfig.cs b/ThunderstoreCLI/Configuration/ProjectFileConfig.cs index 33323a3..872e634 100644 --- a/ThunderstoreCLI/Configuration/ProjectFileConfig.cs +++ b/ThunderstoreCLI/Configuration/ProjectFileConfig.cs @@ -1,5 +1,4 @@ using ThunderstoreCLI.Models; -using ThunderstoreCLI.Utils; using static Crayon.Output; namespace ThunderstoreCLI.Configuration; @@ -24,17 +23,17 @@ public override void Parse(Config currentConfig) Project = ThunderstoreProject.Deserialize(File.ReadAllText(SourcePath))!; } - public override GeneralConfig? GetGeneralConfig() + public override GeneralConfig GetGeneralConfig() { - return new GeneralConfig() + return new GeneralConfig { Repository = Project.Publish?.Repository! }; } - public override PackageConfig? GetPackageMeta() + public override PackageConfig GetPackageMeta() { - return new PackageConfig() + return new PackageConfig { Namespace = Project.Package?.Namespace, Name = Project.Package?.Name, @@ -47,26 +46,38 @@ public override void Parse(Config currentConfig) }; } - public override BuildConfig? GetBuildConfig() + public override BuildConfig GetBuildConfig() { - return new BuildConfig() + return new BuildConfig { - CopyPaths = Project.Build?.CopyPaths.Select(static path => new CopyPathMap(path.Source, path.Target)).ToList(), + CopyPaths = Project.Build?.CopyPaths + .Select(static path => new CopyPathMap(path.Source, path.Target)) + .ToList(), IconPath = Project.Build?.Icon, OutDir = Project.Build?.OutDir, ReadmePath = Project.Build?.Readme }; } - public override PublishConfig? GetPublishConfig() + public override PublishConfig GetPublishConfig() { - return new PublishConfig() + return new PublishConfig { Categories = Project.Publish?.Categories.Categories, Communities = Project.Publish?.Communities }; } + public override InstallConfig GetInstallConfig() + { + return new InstallConfig + { + InstallerDeclarations = Project.Install?.InstallerDeclarations + .Select(static path => new InstallerDeclaration(path.Identifier)) + .ToList() + }; + } + public static void Write(Config config, string path) { File.WriteAllText(path, new ThunderstoreProject(config).Serialize()); diff --git a/ThunderstoreCLI/Game/ModProfile.cs b/ThunderstoreCLI/Game/ModProfile.cs index 5a43fb0..86d52f5 100644 --- a/ThunderstoreCLI/Game/ModProfile.cs +++ b/ThunderstoreCLI/Game/ModProfile.cs @@ -1,5 +1,3 @@ -using System.Diagnostics.CodeAnalysis; -using System.Text.Json.Serialization; using ThunderstoreCLI.Models; namespace ThunderstoreCLI.Game; diff --git a/ThunderstoreCLI/Models/BaseToml.cs b/ThunderstoreCLI/Models/BaseToml.cs index b69d16c..644e0ab 100644 --- a/ThunderstoreCLI/Models/BaseToml.cs +++ b/ThunderstoreCLI/Models/BaseToml.cs @@ -8,5 +8,5 @@ public abstract class BaseToml<[DynamicallyAccessedMembers(DynamicallyAccessedMe { public string Serialize() => TomletMain.TomlStringFrom(this); - public static T? Deserialize(string toml) => TomletMain.To(toml); + public static T Deserialize(string toml) => TomletMain.To(toml); } diff --git a/ThunderstoreCLI/Models/SchemaResponse.cs b/ThunderstoreCLI/Models/SchemaResponse.cs index ab607d8..8376a3b 100644 --- a/ThunderstoreCLI/Models/SchemaResponse.cs +++ b/ThunderstoreCLI/Models/SchemaResponse.cs @@ -1,6 +1,5 @@ using ThunderstoreCLI.Configuration; using ThunderstoreCLI.Game; -using ThunderstoreCLI.Utils; namespace ThunderstoreCLI.Models; diff --git a/ThunderstoreCLI/Models/ThunderstoreProject.cs b/ThunderstoreCLI/Models/ThunderstoreProject.cs index 6b09b7a..f26e4b5 100644 --- a/ThunderstoreCLI/Models/ThunderstoreProject.cs +++ b/ThunderstoreCLI/Models/ThunderstoreProject.cs @@ -45,20 +45,21 @@ public class ConfigData public class PackageData { [TomlProperty("namespace")] - public string Namespace { get; set; } = "AuthorName"; + public string? Namespace { get; set; } [TomlProperty("name")] - public string Name { get; set; } = "PackageName"; + public string? Name { get; set; } [TomlProperty("versionNumber")] - public string VersionNumber { get; set; } = "0.0.1"; + public string? VersionNumber { get; set; } [TomlProperty("description")] - public string Description { get; set; } = "Example mod description"; + public string? Description { get; set; } [TomlProperty("websiteUrl")] - public string WebsiteUrl { get; set; } = "https://thunderstore.io"; + public string? WebsiteUrl { get; set; } [TomlProperty("containsNsfwContent")] public bool ContainsNsfwContent { get; set; } = false; + [TomlProperty("dependencies")] [TomlDoNotInlineObject] - public Dictionary Dependencies { get; set; } = new() { { "AuthorName-PackageName", "0.0.1" } }; + public Dictionary Dependencies { get; set; } = new(); } [TomlProperty("package")] public PackageData? Package { get; set; } @@ -67,23 +68,23 @@ public class PackageData public class BuildData { [TomlProperty("icon")] - public string Icon { get; set; } = "./icon.png"; + public string? Icon { get; set; } [TomlProperty("readme")] - public string Readme { get; set; } = "./README.md"; + public string? Readme { get; set; } [TomlProperty("outdir")] - public string OutDir { get; set; } = "./build"; + public string? OutDir { get; set; } [TomlDoNotInlineObject] public class CopyPath { [TomlProperty("source")] - public string Source { get; set; } = "./dist"; + public string? Source { get; set; } [TomlProperty("target")] - public string Target { get; set; } = ""; + public string? Target { get; set; } } [TomlProperty("copy")] - public CopyPath[] CopyPaths { get; set; } = new CopyPath[] { new CopyPath() }; + public CopyPath[] CopyPaths { get; set; } = Array.Empty(); } [TomlProperty("build")] public BuildData? Build { get; set; } @@ -92,26 +93,37 @@ public class CopyPath public class PublishData { [TomlProperty("repository")] - public string Repository { get; set; } = "https://thunderstore.io"; + public string? Repository { get; set; } + [TomlProperty("communities")] - public string[] Communities { get; set; } = - { - "riskofrain2" - }; + public string[] Communities { get; set; } = Array.Empty(); [TomlProperty("categories")] [TomlDoNotInlineObject] public CategoryDictionary Categories { get; set; } = new() { - Categories = new Dictionary - { - { "riskofrain2", new[] { "items", "skills" } } - } + Categories = new Dictionary(), }; } [TomlProperty("publish")] public PublishData? Publish { get; set; } + [TomlDoNotInlineObject] + public class InstallData + { + [TomlDoNotInlineObject] + public class InstallerDeclaration + { + [TomlProperty("identifier")] + public string? Identifier { get; set; } + } + + [TomlProperty("installers")] + public InstallerDeclaration[] InstallerDeclarations { get; set; } = Array.Empty(); + } + [TomlProperty("install")] + public InstallData? Install { get; set; } + public ThunderstoreProject() { } public ThunderstoreProject(bool initialize) @@ -122,27 +134,41 @@ public ThunderstoreProject(bool initialize) Package = new PackageData(); Build = new BuildData(); Publish = new PublishData(); + Install = new InstallData(); } public ThunderstoreProject(Config config) { - Package = new PackageData() + Package = new PackageData { Namespace = config.PackageConfig.Namespace!, - Name = config.PackageConfig.Name! + Name = config.PackageConfig.Name!, + VersionNumber = config.PackageConfig.VersionNumber!, + Description = config.PackageConfig.Description!, + WebsiteUrl = config.PackageConfig.WebsiteUrl!, + ContainsNsfwContent = config.PackageConfig.ContainsNsfwContent.GetValueOrDefault(false), + Dependencies = config.PackageConfig.Dependencies! }; - Build = new BuildData() + Build = new BuildData { - Icon = config.GetPackageIconPath(), - OutDir = config.GetBuildOutputDir(), - Readme = config.GetPackageReadmePath(), - CopyPaths = config.BuildConfig.CopyPaths!.Select(x => new BuildData.CopyPath { Source = x.From, Target = x.To }).ToArray()! + Icon = config.BuildConfig.IconPath!, + OutDir = config.BuildConfig.OutDir!, + Readme = config.BuildConfig.ReadmePath!, + CopyPaths = config.BuildConfig.CopyPaths! + .Select(x => new BuildData.CopyPath { Source = x.From, Target = x.To }) + .ToArray() }; - Publish = new PublishData() + Publish = new PublishData { Categories = new CategoryDictionary { Categories = config.PublishConfig.Categories! }, Communities = config.PublishConfig.Communities!, Repository = config.GeneralConfig.Repository }; + Install = new InstallData + { + InstallerDeclarations = config.InstallConfig.InstallerDeclarations! + .Select(x => new InstallData.InstallerDeclaration { Identifier = x.Identifier }) + .ToArray() + }; } } diff --git a/ThunderstoreCLI/Options.cs b/ThunderstoreCLI/Options.cs index 9a3a14f..f476bbe 100644 --- a/ThunderstoreCLI/Options.cs +++ b/ThunderstoreCLI/Options.cs @@ -30,7 +30,7 @@ public virtual bool Validate() { if (!Directory.Exists(TcliDirectory)) { - Directory.CreateDirectory(TcliDirectory!); + Directory.CreateDirectory(TcliDirectory); } return true; diff --git a/ThunderstoreCLI/PackageManifestV1.cs b/ThunderstoreCLI/PackageManifestV1.cs index 3ea2b1b..858769a 100644 --- a/ThunderstoreCLI/PackageManifestV1.cs +++ b/ThunderstoreCLI/PackageManifestV1.cs @@ -23,9 +23,19 @@ public class PackageManifestV1 : BaseJson [JsonProperty("website_url")] public string? WebsiteUrl { get; set; } + [JsonProperty("installers")] + public InstallerDeclaration[]? Installers { get; set; } + private string? fullName; + [JsonIgnore] public string FullName => fullName ??= $"{Namespace}-{Name}"; + public class InstallerDeclaration + { + [JsonProperty("identifier")] + public string? Identifier { get; set; } + } + public PackageManifestV1() { } public PackageManifestV1(PackageVersionData version) diff --git a/ThunderstoreCLI/Program.cs b/ThunderstoreCLI/Program.cs index 3b5d9a4..d99679d 100644 --- a/ThunderstoreCLI/Program.cs +++ b/ThunderstoreCLI/Program.cs @@ -1,6 +1,5 @@ using System.Diagnostics; using CommandLine; -using ThunderstoreCLI.Models; using ThunderstoreCLI.Utils; namespace ThunderstoreCLI; diff --git a/ThunderstoreCLI/ThunderstoreCLI.csproj b/ThunderstoreCLI/ThunderstoreCLI.csproj index 7fdeeb0..ba326b1 100644 --- a/ThunderstoreCLI/ThunderstoreCLI.csproj +++ b/ThunderstoreCLI/ThunderstoreCLI.csproj @@ -3,7 +3,7 @@ Exe net7.0;net6.0 - 11 + 12 Major ThunderstoreCLI tcli diff --git a/ThunderstoreCLI/Utils/SteamUtils.cs b/ThunderstoreCLI/Utils/SteamUtils.cs index d7f703b..990b468 100644 --- a/ThunderstoreCLI/Utils/SteamUtils.cs +++ b/ThunderstoreCLI/Utils/SteamUtils.cs @@ -1,6 +1,5 @@ using System.Runtime.InteropServices; using System.Runtime.Versioning; -using System.Security.AccessControl; using System.Text.RegularExpressions; using Microsoft.Win32; @@ -154,7 +153,7 @@ public static bool IsProtonGame(string steamAppId) return Path.Combine(steamDir, "steamapps"); } - private static string? FindSteamDirectoryOsx() + private static string FindSteamDirectoryOsx() { return Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),