Skip to content

Commit b60d666

Browse files
authored
Merge pull request #3721 from marticliment/improvements-to-install-options
2 parents e8f31cb + ac50bba commit b60d666

48 files changed

Lines changed: 464 additions & 560 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The main goal of this project is to create an intuitive GUI for the most common
88
With this app, you can easily download, install, update, and uninstall any software published on the supported package managers — and much more!
99

1010
![image](https://github.com/user-attachments/assets/7cb447ca-ee8b-4bce-8561-b9332fb0139a)
11-
11+
View more screenshots [here](#screenthots)
1212

1313
Check out the [Supported Package Managers Table](#supported-package-managers) for more details!
1414

src/UniGetUI.Core.LanguageEngine/LanguageData.cs

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using UniGetUI.Core.Data;
66
using UniGetUI.Core.Logging;
77
using UniGetUI.PackageEngine.Enums;
8+
using Architecture = UniGetUI.PackageEngine.Enums.Architecture;
89

910
namespace UniGetUI.Core.Language
1011
{
@@ -151,45 +152,17 @@ private static Person[] LoadLanguageTranslatorList()
151152

152153
public static class CommonTranslations
153154
{
154-
public static readonly Dictionary<Architecture, string> ArchNames = new()
155-
{
156-
{ Architecture.X64, "x64" },
157-
{ Architecture.X86, "x86" },
158-
{ Architecture.Arm64, "arm64" },
159-
{ Architecture.Arm, "arm32" },
160-
};
161-
162-
public static readonly Dictionary<string, Architecture> InvertedArchNames = new()
163-
{
164-
{ "x64", Architecture.X64 },
165-
{ "x86", Architecture.X86 },
166-
{ "arm64", Architecture.Arm64 },
167-
{ "arm32", Architecture.Arm },
168-
};
169-
170-
public static readonly Dictionary<PackageScope, string> ScopeNames = new()
155+
public static readonly Dictionary<string, string> ScopeNames = new()
171156
{
172157
{ PackageScope.Global, "Machine | Global" },
173158
{ PackageScope.Local, "User | Local" },
174159
};
175160

176-
public static readonly Dictionary<string, PackageScope> InvertedScopeNames = new()
161+
public static readonly Dictionary<string, string> InvertedScopeNames = new()
177162
{
178163
{ "Machine | Global", PackageScope.Global },
179164
{ "User | Local", PackageScope.Local },
180165
};
181-
182-
public static readonly Dictionary<PackageScope, string> ScopeNames_NonLang = new()
183-
{
184-
{ PackageScope.Global, "machine" },
185-
{ PackageScope.Local, "user" },
186-
};
187-
188-
public static readonly Dictionary<string, PackageScope> InvertedScopeNames_NonLang = new()
189-
{
190-
{ "machine", PackageScope.Global },
191-
{ "user", PackageScope.Local },
192-
};
193166
}
194167
}
195168

src/UniGetUI.Core.Tools/Tools.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,5 +694,9 @@ public static string GetCurrentLocale()
694694
{
695695
return LanguageEngine?.Locale ?? "Unset/Unknown";
696696
}
697+
698+
private static readonly HashSet<char> illegalPathChars = Path.GetInvalidFileNameChars().ToHashSet();
699+
public static string MakeValidFileName(string name)
700+
=> string.Concat(name.Where(x => !illegalPathChars.Contains(x)));
697701
}
698702
}

src/UniGetUI.PAckageEngine.Interfaces/IInstallationOptions.cs

Lines changed: 0 additions & 42 deletions
This file was deleted.

src/UniGetUI.PAckageEngine.Interfaces/IPackage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public interface IPackage : INotifyPropertyChanged, IEquatable<IPackage>
149149
/// <returns>False if the update is a major update or the update doesn't exist, true if it's a minor update</returns>
150150
public bool IsUpdateMinor();
151151

152-
public SerializablePackage AsSerializable();
152+
public Task<SerializablePackage> AsSerializableAsync();
153153

154154
public SerializableIncompatiblePackage AsSerializable_Incompatible();
155155
}

src/UniGetUI.PAckageEngine.Interfaces/ManagerHelpers/IPackageOperationHelper.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using UniGetUI.PackageEngine.Enums;
2+
using UniGetUI.PackageEngine.Serializable;
23

34
namespace UniGetUI.PackageEngine.Interfaces.ManagerProviders
45
{
@@ -12,11 +13,9 @@ public interface IPackageOperationHelper
1213
/// that the requested operation is performed over the given package, with its corresponding
1314
/// installation options.
1415
/// </summary>
15-
public IReadOnlyList<string> GetParameters(
16-
IPackage package,
17-
IInstallationOptions options,
18-
OperationType operation
19-
);
16+
public IReadOnlyList<string> GetParameters(IPackage package,
17+
InstallOptions options,
18+
OperationType operation);
2019

2120
/// <summary>
2221
/// Returns the veredict of the given package operation, given the package, the operation type,

src/UniGetUI.PackageEngine.Enums/Enums.cs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,22 @@ namespace UniGetUI.PackageEngine.Enums
33
/// <summary>
44
/// Represents the installation scope of a package
55
/// </summary>
6-
public enum PackageScope
6+
public static class PackageScope
77
{
8-
Global = 1,
9-
Machine = 1,
10-
Local = 0,
11-
User = 0,
8+
public static HashSet<string> ValidValues = [Machine, User];
9+
public const string Machine = "machine";
10+
public const string Global = Machine;
11+
public const string User = "user";
12+
public const string Local = User;
13+
}
14+
15+
public static class Architecture
16+
{
17+
public static HashSet<string> ValidValues = [x86, x64, arm32, arm64];
18+
public const string x86 = "x86";
19+
public const string x64 = "x64";
20+
public const string arm32 = "arm32";
21+
public const string arm64 = "arm64";
1222
}
1323

1424
public enum DeserializedPackageStatus

src/UniGetUI.PackageEngine.Enums/ManagerCapabilities.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public struct ManagerCapabilities
2828
public bool CanDownloadInstaller = false;
2929
public bool SupportsCustomVersions = false;
3030
public bool SupportsCustomArchitectures = false;
31-
public Architecture[] SupportedCustomArchitectures = [];
31+
public string[] SupportedCustomArchitectures = [];
3232
public bool SupportsCustomScopes = false;
3333
public bool SupportsPreRelease = false;
3434
public bool SupportsCustomLocations = false;

src/UniGetUI.PackageEngine.Enums/OverridenInstallationOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
namespace UniGetUI.PackageEngine.Structs;
44
public struct OverridenInstallationOptions
55
{
6-
public PackageScope? Scope;
6+
public string? Scope;
77
public bool? RunAsAdministrator;
88
public bool PowerShell_DoNotSetScopeParameter = false;
99
public bool? WinGet_SpecifyVersion = null;
1010

11-
public OverridenInstallationOptions(PackageScope? scope = null, bool? runAsAdministrator = null)
11+
public OverridenInstallationOptions(string? scope = null, bool? runAsAdministrator = null)
1212
{
1313
Scope = scope;
1414
RunAsAdministrator = runAsAdministrator;

src/UniGetUI.PackageEngine.Managers.Cargo/Helpers/CargoPkgOperationHelper.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
using UniGetUI.PackageEngine.Classes.Manager.BaseProviders;
22
using UniGetUI.PackageEngine.Enums;
33
using UniGetUI.PackageEngine.Interfaces;
4+
using UniGetUI.PackageEngine.Serializable;
45

56
namespace UniGetUI.PackageEngine.Managers.CargoManager;
67

78
internal sealed class CargoPkgOperationHelper(Cargo cargo) : BasePkgOperationHelper(cargo)
89
{
9-
protected override IReadOnlyList<string> _getOperationParameters(IPackage package, IInstallationOptions options, OperationType operation)
10+
protected override IReadOnlyList<string> _getOperationParameters(IPackage package,
11+
InstallOptions options, OperationType operation)
1012
{
1113
var version = options.Version == string.Empty ? package.VersionString : options.Version;
1214
List<string> parameters = operation switch

0 commit comments

Comments
 (0)