Skip to content
This repository was archived by the owner on Jun 27, 2024. It is now read-only.

Commit 0090817

Browse files
committed
Add installation of OpenMod uconomy migrator
1 parent efcdc02 commit 0090817

4 files changed

Lines changed: 16 additions & 17 deletions

File tree

src/Commands/OpenModPermissionsStep.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public override void OnChoice(string choice)
3535
return;
3636
case "om":
3737
case "openmod":
38+
Jobs.Add(new UconomyMigratorInstallJob());
3839
Jobs.Add(new MigratePermissionsJob());
3940
return;
4041
}

src/Jobs/NuGetInstallJob.cs

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using OpenMod.Installer.RocketMod.Helpers;
22
using OpenMod.NuGet;
33
using Rocket.Core.Logging;
4-
using System;
54
using System.IO;
65
using System.Linq;
76
using System.Threading.Tasks;
@@ -20,24 +19,22 @@ protected NuGetInstallJob(string packageId)
2019

2120
public void ExecuteMigration(string[] args)
2221
{
23-
AsyncHelperEx.RunSync(() => DownloadPackage(args.Contains("--force") || args.Contains("-f")));
22+
AsyncHelperEx.RunSync(() => DownloadPackage(args.Contains("--force") || args.Contains("-f"), args.Contains("-p") || args.Contains("--pre")));
2423
}
2524

26-
private async Task DownloadPackage(bool force)
25+
private async Task DownloadPackage(bool force, bool usePre)
2726
{
2827
Logger.Log($"Installing package \"{m_PackageId}\"...");
2928
var nuGetPackageManager = NuGetHelper.GetNuGetPackageManager();
3029

31-
const bool c_AllowPreReleaseVersion = false;
32-
3330
var oldIdentity = await nuGetPackageManager.GetLatestPackageIdentityAsync(m_PackageId);
3431
if (!force && oldIdentity != null)
3532
{
3633
Logger.LogWarning($"Package \"{m_PackageId}\" is already installed, skipping. Use \"openmod install -f\" to install anyway.");
3734
return;
3835
}
3936

40-
var package = await nuGetPackageManager.QueryPackageExactAsync(m_PackageId, null, c_AllowPreReleaseVersion);
37+
var package = await nuGetPackageManager.QueryPackageExactAsync(m_PackageId, null, usePre);
4138
if (package?.Identity == null)
4239
{
4340
Logger.LogError($"Downloading has failed for {m_PackageId}: {NuGetInstallCode.PackageOrVersionNotFound}");
@@ -52,16 +49,8 @@ private async Task DownloadPackage(bool force)
5249

5350
var identity = package.Identity;
5451

55-
var installResult = await nuGetPackageManager.InstallAsync(identity, c_AllowPreReleaseVersion);
56-
bool isInstalled;
57-
if (Enum.GetValues(typeof(NuGetInstallCode)).Length == 3) // loaded 3.0 version openmod
58-
{
59-
isInstalled = (int) installResult.Code is 0 or 1; // Success / NoUpdatesFound
60-
}
61-
else
62-
{
63-
isInstalled = installResult.Code == NuGetInstallCode.Success;
64-
}
52+
var installResult = await nuGetPackageManager.InstallAsync(identity, usePre);
53+
var isInstalled = installResult.Code == NuGetInstallCode.Success || installResult.Code == NuGetInstallCode.NoUpdatesFound;
6554

6655
if (isInstalled)
6756
{
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace OpenMod.Installer.RocketMod.Jobs
2+
{
3+
public class UconomyMigratorInstallJob : NuGetInstallJob
4+
{
5+
public UconomyMigratorInstallJob() : base("OpenMod.Migrator.Uconomy")
6+
{
7+
}
8+
}
9+
}

src/OpenMod.Installer.RocketMod.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<ItemGroup>
1010
<PackageReference Include="Nito.AsyncEx.Context" Version="5.1.0" />
11-
<PackageReference Include="OpenMod.NuGet" Version="2.3.8" />
11+
<PackageReference Include="OpenMod.NuGet" Version="3.0.0-beta1" />
1212
<PackageReference Include="OpenMod.UnityEngine.Redist" Version="2019.4.10" />
1313
<PackageReference Include="OpenMod.Unturned.Redist" Version="3.20.14" />
1414
</ItemGroup>

0 commit comments

Comments
 (0)