Change to using builtin SemVer type for AbstractModMetadata and ProgramStatistics.Generated (#536)
* Change to using SemVer builtin type * Remove SptVersion from config, remove redundant .ToString() * Update test mod, fix watermark string conversion
This commit is contained in:
@@ -431,7 +431,7 @@ public class GameController(
|
||||
{
|
||||
if (
|
||||
fullProfile.SptData.Mods.Any(m =>
|
||||
m.Author == mod.ModMetadata.Author && m.Version == mod.ModMetadata.Version && m.Name == mod.ModMetadata.Name
|
||||
m.Author == mod.ModMetadata.Author && m.Version == mod.ModMetadata.Version.ToString() && m.Name == mod.ModMetadata.Name
|
||||
)
|
||||
)
|
||||
{
|
||||
@@ -443,7 +443,7 @@ public class GameController(
|
||||
new ModDetails
|
||||
{
|
||||
Author = mod.ModMetadata.Author,
|
||||
Version = mod.ModMetadata.Version,
|
||||
Version = mod.ModMetadata.Version.ToString(),
|
||||
Name = mod.ModMetadata.Name,
|
||||
Url = mod.ModMetadata.Url,
|
||||
DateAdded = timeUtil.GetTimeStamp(),
|
||||
@@ -496,7 +496,7 @@ public class GameController(
|
||||
if (logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
logger.Debug($"Profile made with: {fullProfile.SptData?.Version}");
|
||||
logger.Debug($"Server version: {ProgramStatics.SPT_VERSION() ?? _coreConfig.SptVersion} {ProgramStatics.COMMIT()}");
|
||||
logger.Debug($"Server version: {ProgramStatics.SPT_VERSION()} {ProgramStatics.COMMIT()}");
|
||||
logger.Debug($"Debug enabled: {ProgramStatics.DEBUG()}");
|
||||
logger.Debug($"Mods enabled: {ProgramStatics.MODS()}");
|
||||
}
|
||||
|
||||
@@ -9,9 +9,6 @@ public record CoreConfig : BaseConfig
|
||||
[JsonPropertyName("kind")]
|
||||
public override string Kind { get; set; } = "spt-core";
|
||||
|
||||
[JsonPropertyName("sptVersion")]
|
||||
public required string SptVersion { get; set; }
|
||||
|
||||
[JsonPropertyName("projectName")]
|
||||
public required string ProjectName { get; set; }
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace SPTarkov.Server.Core.Models.Spt.Mod;
|
||||
using Version = SemanticVersioning.Version;
|
||||
|
||||
namespace SPTarkov.Server.Core.Models.Spt.Mod;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a collection of metadata used to determine things such as author, version,
|
||||
@@ -31,14 +33,22 @@ public abstract record AbstractModMetadata
|
||||
public abstract List<string>? Contributors { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Semantic version of this mod, this uses the semver standard
|
||||
/// Semantic version of this mod, this uses the semver standard: https://semver.org/
|
||||
/// <br/><br/>
|
||||
/// Version = new Version("1.0.0"); is valid
|
||||
/// <br/>
|
||||
/// Version = new Version("1.0.0.0"); is not
|
||||
/// </summary>
|
||||
public abstract string Version { get; init; }
|
||||
public abstract Version Version { get; }
|
||||
|
||||
/// <summary>
|
||||
/// SPT version this mod was built for
|
||||
/// SPT version this mod was built for, this uses the semver standard: https://semver.org/
|
||||
/// <br/><br/>
|
||||
/// Version = new Version("4.0.0"); is valid
|
||||
/// <br/>
|
||||
/// Version = new Version("4.0.0.0"); is not
|
||||
/// </summary>
|
||||
public abstract string SptVersion { get; init; }
|
||||
public abstract Version SptVersion { get; }
|
||||
|
||||
/// <summary>
|
||||
/// List of mods this mod should load before
|
||||
@@ -60,7 +70,7 @@ public abstract record AbstractModMetadata
|
||||
///
|
||||
/// Mod dependency is the key, version is the value
|
||||
/// </summary>
|
||||
public abstract Dictionary<string, string>? ModDependencies { get; set; }
|
||||
public abstract Dictionary<string, Version>? ModDependencies { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Link to this mod's mod page, or GitHub page
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
<Target Name="GenerateProgramStatics" BeforeTargets="CollectPackageReferences;CoreCompile">
|
||||
<WriteLinesToFile
|
||||
File="Utils/ProgramStatics.Generated.cs"
|
||||
Lines="// <auto-generated />
// This file is automatically generated. Do not modify manually.
// Any changes made to this file will be overwritten during the build process.

using SPTarkov.Server.Core.Models.Enums%3B

namespace SPTarkov.Server.Core.Utils%3B

public static partial class ProgramStatics
{
 private static string SptVersion { get%3B } = "$(SptVersion)"%3B
 private static string Commit { get%3B } = "$(SptCommit)"%3B
 private static double BuildTime { get%3B } = $(SptBuildTime)%3B
 private static EntryType BuildType { get%3B } = EntryType.$(SptBuildType)%3B
}
"
|
||||
Lines="// <auto-generated />
// This file is automatically generated. Do not modify manually.
// Any changes made to this file will be overwritten during the build process.

using SPTarkov.Server.Core.Models.Enums%3B

using Version = SemanticVersioning.Version%3B

namespace SPTarkov.Server.Core.Utils%3B

public static partial class ProgramStatics
{
 private static Version SptVersion { get%3B } = new("$(SptVersion)")%3B
 private static string Commit { get%3B } = "$(SptCommit)"%3B
 private static double BuildTime { get%3B } = $(SptBuildTime)%3B
 private static EntryType BuildType { get%3B } = EntryType.$(SptBuildType)%3B
}
"
|
||||
Overwrite="true"
|
||||
/>
|
||||
</Target>
|
||||
|
||||
@@ -39,7 +39,7 @@ public class App(
|
||||
_logger.Debug($"Ran as admin: {Environment.IsPrivilegedProcess}");
|
||||
_logger.Debug($"CPU cores: {Environment.ProcessorCount}");
|
||||
_logger.Debug($"PATH: {(Environment.ProcessPath ?? "null returned").Encode(EncodeType.BASE64)}");
|
||||
_logger.Debug($"Server: {ProgramStatics.SPT_VERSION() ?? _coreConfig.SptVersion}");
|
||||
_logger.Debug($"Server: {ProgramStatics.SPT_VERSION()}");
|
||||
|
||||
// _logger.Debug($"RAM: {(os.totalmem() / 1024 / 1024 / 1024).toFixed(2)}GB");
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using SPTarkov.Server.Core.Models.Enums;
|
||||
using SPTarkov.Server.Core.Models.Logging;
|
||||
using Version = SemanticVersioning.Version;
|
||||
|
||||
namespace SPTarkov.Server.Core.Utils;
|
||||
|
||||
@@ -68,7 +69,7 @@ public static partial class ProgramStatics
|
||||
return _mods;
|
||||
}
|
||||
|
||||
public static string SPT_VERSION()
|
||||
public static Version SPT_VERSION()
|
||||
{
|
||||
return SptVersion;
|
||||
}
|
||||
|
||||
@@ -12,32 +12,32 @@ namespace SPTarkov.Server.Core.Utils;
|
||||
public class WatermarkLocale(ServerLocalisationService serverLocalisationService)
|
||||
{
|
||||
public IReadOnlyList<string> Description { get; } =
|
||||
[
|
||||
serverLocalisationService.GetText("watermark-discord_url"),
|
||||
"",
|
||||
serverLocalisationService.GetText("watermark-free_of_charge"),
|
||||
serverLocalisationService.GetText("watermark-paid_scammed"),
|
||||
serverLocalisationService.GetText("watermark-commercial_use_prohibited"),
|
||||
];
|
||||
[
|
||||
serverLocalisationService.GetText("watermark-discord_url"),
|
||||
"",
|
||||
serverLocalisationService.GetText("watermark-free_of_charge"),
|
||||
serverLocalisationService.GetText("watermark-paid_scammed"),
|
||||
serverLocalisationService.GetText("watermark-commercial_use_prohibited"),
|
||||
];
|
||||
public IReadOnlyList<string> Modding { get; } =
|
||||
[
|
||||
"",
|
||||
serverLocalisationService.GetText("watermark-modding_disabled"),
|
||||
"",
|
||||
serverLocalisationService.GetText("watermark-not_an_issue"),
|
||||
serverLocalisationService.GetText("watermark-do_not_report"),
|
||||
];
|
||||
[
|
||||
"",
|
||||
serverLocalisationService.GetText("watermark-modding_disabled"),
|
||||
"",
|
||||
serverLocalisationService.GetText("watermark-not_an_issue"),
|
||||
serverLocalisationService.GetText("watermark-do_not_report"),
|
||||
];
|
||||
public IReadOnlyList<string> Warning { get; } =
|
||||
[
|
||||
"",
|
||||
serverLocalisationService.GetText("watermark-testing_build"),
|
||||
serverLocalisationService.GetText("watermark-no_support"),
|
||||
"",
|
||||
$"{serverLocalisationService.GetText("watermark-report_issues_to")}:",
|
||||
serverLocalisationService.GetText("watermark-issue_tracker_url"),
|
||||
"",
|
||||
serverLocalisationService.GetText("watermark-use_at_own_risk"),
|
||||
];
|
||||
[
|
||||
"",
|
||||
serverLocalisationService.GetText("watermark-testing_build"),
|
||||
serverLocalisationService.GetText("watermark-no_support"),
|
||||
"",
|
||||
$"{serverLocalisationService.GetText("watermark-report_issues_to")}:",
|
||||
serverLocalisationService.GetText("watermark-issue_tracker_url"),
|
||||
"",
|
||||
serverLocalisationService.GetText("watermark-use_at_own_risk"),
|
||||
];
|
||||
}
|
||||
|
||||
[Injectable(TypePriority = OnLoadOrder.Watermark)]
|
||||
@@ -93,7 +93,7 @@ public class Watermark(
|
||||
/// <returns></returns>
|
||||
public string GetVersionTag(bool withEftVersion = false)
|
||||
{
|
||||
var sptVersion = ProgramStatics.SPT_VERSION() ?? sptConfig.SptVersion;
|
||||
var sptVersion = ProgramStatics.SPT_VERSION().ToString();
|
||||
var versionTag = ProgramStatics.DEBUG() ? $"{sptVersion} - {serverLocalisationService.GetText("bleeding_edge_build")}" : sptVersion;
|
||||
|
||||
if (withEftVersion)
|
||||
|
||||
Reference in New Issue
Block a user