From 6c39a31f72c5d6e1e202fe3fbed5f775976e448b Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Mon, 1 Oct 2018 19:32:49 -0400 Subject: special-case '-unofficial' when comparing versions --- src/StardewModdingAPI.Toolkit/SemanticVersion.cs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/StardewModdingAPI.Toolkit/SemanticVersion.cs') diff --git a/src/StardewModdingAPI.Toolkit/SemanticVersion.cs b/src/StardewModdingAPI.Toolkit/SemanticVersion.cs index 156d58ce..2a78d2f0 100644 --- a/src/StardewModdingAPI.Toolkit/SemanticVersion.cs +++ b/src/StardewModdingAPI.Toolkit/SemanticVersion.cs @@ -4,7 +4,13 @@ using System.Text.RegularExpressions; namespace StardewModdingAPI.Toolkit { /// A semantic version with an optional release tag. - /// The implementation is defined by Semantic Version 2.0 (http://semver.org/). + /// + /// The implementation is defined by Semantic Version 2.0 (http://semver.org/), with a few deviations: + /// - short-form "x.y" versions are supported (equivalent to "x.y.0"); + /// - hyphens are synonymous with dots in prerelease tags (like "-unofficial.3-pathoschild"); + /// - +build suffixes are not supported; + /// - and "-unofficial" in prerelease tags is always lower-precedence (e.g. "1.0-beta" is newer than "1.0-unofficial"). + /// public class SemanticVersion : ISemanticVersion { /********* @@ -17,13 +23,7 @@ namespace StardewModdingAPI.Toolkit internal const string UnboundedVersionPattern = @"(?>(?0|[1-9]\d*))\.(?>(?0|[1-9]\d*))(?>(?:\.(?0|[1-9]\d*))?)(?:-(?" + SemanticVersion.TagPattern + "))?"; /// A regular expression matching a semantic version string. - /// - /// This pattern is derived from the BNF documentation in the semver repo, - /// with three important deviations intended to support Stardew Valley mod conventions: - /// - allows short-form "x.y" versions; - /// - allows hyphens in prerelease tags as synonyms for dots (like "-unofficial-update.3"); - /// - doesn't allow '+build' suffixes. - /// + /// This pattern is derived from the BNF documentation in the semver repo, with deviations to support the Stardew Valley mod conventions (see remarks on ). internal static readonly Regex Regex = new Regex($@"^{SemanticVersion.UnboundedVersionPattern}$", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.ExplicitCapture); @@ -255,6 +255,12 @@ namespace StardewModdingAPI.Toolkit // compare if different if (curParts[i] != otherParts[i]) { + // unofficial is always lower-precedence + if (otherParts[i].Equals("unofficial", StringComparison.InvariantCultureIgnoreCase)) + return curNewer; + if (curParts[i].Equals("unofficial", StringComparison.InvariantCultureIgnoreCase)) + return curOlder; + // compare numerically if possible { if (int.TryParse(curParts[i], out int curNum) && int.TryParse(otherParts[i], out int otherNum)) -- cgit From 49e944d06fa7040889b569b62cb0025c057834df Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 4 Nov 2018 23:52:59 -0500 Subject: update HTTP URLs to HTTPS --- .editorconfig | 2 +- docs/README.md | 2 +- docs/release-notes.md | 6 +++--- docs/technical-docs.md | 4 ++-- src/SMAPI.Installer/unix-install.sh | 2 +- src/SMAPI.Tests/Core/ModResolverTests.cs | 2 +- src/SMAPI/Framework/SCore.cs | 2 +- src/SMAPI/SemanticVersion.cs | 2 +- src/StardewModdingAPI.Toolkit/SemanticVersion.cs | 2 +- 9 files changed, 12 insertions(+), 12 deletions(-) (limited to 'src/StardewModdingAPI.Toolkit/SemanticVersion.cs') diff --git a/.editorconfig b/.editorconfig index 126fdbd4..5bfc44bd 100644 --- a/.editorconfig +++ b/.editorconfig @@ -3,7 +3,7 @@ root: true ########## ## General formatting -## documentation: http://editorconfig.org +## documentation: https://editorconfig.org ########## [*] indent_style = space diff --git a/docs/README.md b/docs/README.md index e7d6d682..b8e3b50b 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,4 +1,4 @@ -**SMAPI** is an open-source modding API for [Stardew Valley](http://stardewvalley.net/) that lets +**SMAPI** is an open-source modding API for [Stardew Valley](https://stardewvalley.net/) that lets you play the game with mods. It's safely installed alongside the game's executable, and doesn't change any of your game files. It serves eight main purposes: diff --git a/docs/release-notes.md b/docs/release-notes.md index 8a15a4d2..6c2879df 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -666,7 +666,7 @@ For mod developers: * The SMAPI log now always uses `\r\n` line endings to simplify crossplatform viewing. * Fixed `SaveEvents.AfterLoad` being raised during the new-game intro before the player is initialised. * Fixed SMAPI not recognising `Mod` instances that don't subclass `Mod` directly. -* Several obsolete APIs have been removed (see [deprecation guide](http://canimod.com/guides/updating-a-smapi-mod)), +* Several obsolete APIs have been removed (see [migration guides](https://stardewvalleywiki.com/Modding:Index#Migration_guides)), and all _notice_-level deprecations have been increased to _info_. * Removed the experimental `IConfigFile`. @@ -749,7 +749,7 @@ For players: For developers: * Deprecated `Version` in favour of `SemanticVersion`. - _This new implementation is [semver 2.0](http://semver.org/)-compliant, introduces `NewerThan(version)` and `OlderThan(version)` convenience methods, adds support for parsing a version string into a `SemanticVersion`, and fixes various bugs with the former implementation. This also replaces `Manifest` with `IManifest`._ + _This new implementation is [semver 2.0](https://semver.org/)-compliant, introduces `NewerThan(version)` and `OlderThan(version)` convenience methods, adds support for parsing a version string into a `SemanticVersion`, and fixes various bugs with the former implementation. This also replaces `Manifest` with `IManifest`._ * Increased deprecation levels for `SObject`, `Extensions`, `LogWriter` (not `Log`), `SPlayer`, and `Mod.Entry(ModHelper)` (not `Mod.Entry(IModHelper)`). ## 1.4 @@ -828,7 +828,7 @@ For mod developers: * Added OS version to log. * Added zoom-adjusted mouse position to mouse-changed event arguments. * Added SMAPI code documentation. - * Switched to [semantic versioning](http://semver.org). + * Switched to [semantic versioning](https://semver.org). * Fixed mod versions not shown correctly in the log. * Fixed misspelled field in `manifest.json` schema. * Fixed some events getting wrong data. diff --git a/docs/technical-docs.md b/docs/technical-docs.md index be809c3f..08590cba 100644 --- a/docs/technical-docs.md +++ b/docs/technical-docs.md @@ -29,7 +29,7 @@ Using an official SMAPI release is recommended for most users. SMAPI uses some C# 7 code, so you'll need at least [Visual Studio 2017](https://www.visualstudio.com/vs/community/) on Windows, -[MonoDevelop 7.0](http://www.monodevelop.com/) on Linux, +[MonoDevelop 7.0](https://www.monodevelop.com/) on Linux, [Visual Studio 2017 for Mac](https://www.visualstudio.com/vs/visual-studio-mac/), or an equivalent IDE to compile it. It uses build configuration derived from the [crossplatform mod config](https://github.com/Pathoschild/Stardew.ModBuildConfig#readme) to detect @@ -48,7 +48,7 @@ To prepare a crossplatform SMAPI release, you'll need to compile it on two platf on the wiki for the first-time setup. 1. Update the version number in `GlobalAssemblyInfo.cs` and `Constants::Version`. Make sure you use a - [semantic version](http://semver.org). Recommended format: + [semantic version](https://semver.org). Recommended format: build type | format | example :--------- | :----------------------- | :------ diff --git a/src/SMAPI.Installer/unix-install.sh b/src/SMAPI.Installer/unix-install.sh index df02bb37..8379ed87 100644 --- a/src/SMAPI.Installer/unix-install.sh +++ b/src/SMAPI.Installer/unix-install.sh @@ -16,6 +16,6 @@ fi if $COMMAND mono >/dev/null 2>&1; then mono internal/Mono/install.exe else - echo "Oops! Looks like Mono isn't installed. Please install Mono from http://mono-project.com, reboot, and run this installer again." + echo "Oops! Looks like Mono isn't installed. Please install Mono from https://mono-project.com, reboot, and run this installer again." read fi diff --git a/src/SMAPI.Tests/Core/ModResolverTests.cs b/src/SMAPI.Tests/Core/ModResolverTests.cs index 51b839df..4a1f04c6 100644 --- a/src/SMAPI.Tests/Core/ModResolverTests.cs +++ b/src/SMAPI.Tests/Core/ModResolverTests.cs @@ -145,7 +145,7 @@ namespace StardewModdingAPI.Tests.Core this.SetupMetadataForValidation(mock, new ModDataRecordVersionedFields { Status = ModStatus.AssumeBroken, - AlternativeUrl = "http://example.org" + AlternativeUrl = "https://example.org" }); // act diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs index 5f2e90aa..e76e7a1d 100644 --- a/src/SMAPI/Framework/SCore.cs +++ b/src/SMAPI/Framework/SCore.cs @@ -266,7 +266,7 @@ namespace StardewModdingAPI.Framework // show details if game crashed during last session if (File.Exists(Constants.FatalCrashMarker)) { - this.Monitor.Log("The game crashed last time you played. That can be due to bugs in the game, but if it happens repeatedly you can ask for help here: http://community.playstarbound.com/threads/108375/.", LogLevel.Error); + this.Monitor.Log("The game crashed last time you played. That can be due to bugs in the game, but if it happens repeatedly you can ask for help here: https://community.playstarbound.com/threads/108375/.", LogLevel.Error); this.Monitor.Log("If you ask for help, make sure to share your SMAPI log: https://log.smapi.io.", LogLevel.Error); this.Monitor.Log("Press any key to delete the crash data and continue playing.", LogLevel.Info); Console.ReadKey(); diff --git a/src/SMAPI/SemanticVersion.cs b/src/SMAPI/SemanticVersion.cs index 587ff286..a65afeb8 100644 --- a/src/SMAPI/SemanticVersion.cs +++ b/src/SMAPI/SemanticVersion.cs @@ -70,7 +70,7 @@ namespace StardewModdingAPI /// Get an integer indicating whether this version precedes (less than 0), supercedes (more than 0), or is equivalent to (0) the specified version. /// The version to compare with this instance. /// The value is null. - /// The implementation is defined by Semantic Version 2.0 (http://semver.org/). + /// The implementation is defined by Semantic Version 2.0 (https://semver.org/). public int CompareTo(ISemanticVersion other) { return this.Version.CompareTo(other); diff --git a/src/StardewModdingAPI.Toolkit/SemanticVersion.cs b/src/StardewModdingAPI.Toolkit/SemanticVersion.cs index 2a78d2f0..32fea3d7 100644 --- a/src/StardewModdingAPI.Toolkit/SemanticVersion.cs +++ b/src/StardewModdingAPI.Toolkit/SemanticVersion.cs @@ -5,7 +5,7 @@ namespace StardewModdingAPI.Toolkit { /// A semantic version with an optional release tag. /// - /// The implementation is defined by Semantic Version 2.0 (http://semver.org/), with a few deviations: + /// The implementation is defined by Semantic Version 2.0 (https://semver.org/), with a few deviations: /// - short-form "x.y" versions are supported (equivalent to "x.y.0"); /// - hyphens are synonymous with dots in prerelease tags (like "-unofficial.3-pathoschild"); /// - +build suffixes are not supported; -- cgit From 0b03b4f16a446e4b139efd33f6378598ae66efee Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 7 Nov 2018 12:04:20 -0500 Subject: deprecate old manifest version format --- docs/release-notes.md | 1 + src/SMAPI/Framework/SCore.cs | 6 ++++++ src/StardewModdingAPI.Toolkit/SemanticVersion.cs | 7 ++++++- .../Serialisation/Converters/SemanticVersionConverter.cs | 2 +- 4 files changed, 14 insertions(+), 2 deletions(-) (limited to 'src/StardewModdingAPI.Toolkit/SemanticVersion.cs') diff --git a/docs/release-notes.md b/docs/release-notes.md index 57fb33a4..4e2d7cab 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -48,6 +48,7 @@ * Fixed `Context.IsPlayerFree` being true before the player finishes transitioning to a new location in multiplayer. * Suppressed the game's 'added crickets' debug output. * Updated dependencies (Harmony 1.0.9.1 → 1.2.0.1, Mono.Cecil 0.10 → 0.10.1). + * **Deprecation:** non-string manifest versions are now deprecated and will no longer work in SMAPI 3.0. * **Breaking change:** `helper.ModRegistry` now returns `IModInfo` instead of `IManifest` directly. This lets SMAPI return more metadata about mods. * **Breaking change:** most SMAPI files have been moved into a `smapi-internal` subfolder. This won't affect compiled mod releases, but you'll need to update the build config NuGet package. diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs index 3e8766c2..6cb564ce 100644 --- a/src/SMAPI/Framework/SCore.cs +++ b/src/SMAPI/Framework/SCore.cs @@ -895,6 +895,12 @@ namespace StardewModdingAPI.Framework return false; } + // add deprecation warning for old version format + { + if (mod.Manifest?.Version is Toolkit.SemanticVersion version && version.IsLegacyFormat) + this.DeprecationManager.Warn(mod.DisplayName, "non-string manifest version", "2.8", DeprecationLevel.Notice); + } + // validate dependencies // Although dependences are validated before mods are loaded, a dependency may have failed to load. if (mod.Manifest.Dependencies?.Any() == true) diff --git a/src/StardewModdingAPI.Toolkit/SemanticVersion.cs b/src/StardewModdingAPI.Toolkit/SemanticVersion.cs index 32fea3d7..de33df2f 100644 --- a/src/StardewModdingAPI.Toolkit/SemanticVersion.cs +++ b/src/StardewModdingAPI.Toolkit/SemanticVersion.cs @@ -42,6 +42,9 @@ namespace StardewModdingAPI.Toolkit /// An optional prerelease tag. public string Build { get; } + /// Whether the version was parsed from the legacy object format. + public bool IsLegacyFormat { get; } + /********* ** Public methods @@ -51,12 +54,14 @@ namespace StardewModdingAPI.Toolkit /// The minor version incremented for backwards-compatible changes. /// The patch version for backwards-compatible fixes. /// An optional prerelease tag. - public SemanticVersion(int major, int minor, int patch, string tag = null) + /// Whether the version was parsed from the legacy object format. + public SemanticVersion(int major, int minor, int patch, string tag = null, bool isLegacyFormat = false) { this.MajorVersion = major; this.MinorVersion = minor; this.PatchVersion = patch; this.Build = this.GetNormalisedTag(tag); + this.IsLegacyFormat = isLegacyFormat; this.AssertValid(); } diff --git a/src/StardewModdingAPI.Toolkit/Serialisation/Converters/SemanticVersionConverter.cs b/src/StardewModdingAPI.Toolkit/Serialisation/Converters/SemanticVersionConverter.cs index 070f2c97..e0e185c9 100644 --- a/src/StardewModdingAPI.Toolkit/Serialisation/Converters/SemanticVersionConverter.cs +++ b/src/StardewModdingAPI.Toolkit/Serialisation/Converters/SemanticVersionConverter.cs @@ -70,7 +70,7 @@ namespace StardewModdingAPI.Toolkit.Serialisation.Converters if (build == "0") build = null; // '0' from incorrect examples in old SMAPI documentation - return new SemanticVersion(major, minor, patch, build); + return new SemanticVersion(major, minor, patch, build, isLegacyFormat: true); } /// Read a JSON string. -- cgit From c0738296273304e71183ddc537aaf9ffc6d3da46 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 7 Nov 2018 12:17:53 -0500 Subject: deprecate version build field --- docs/release-notes.md | 9 ++++++--- src/SMAPI/Framework/SCore.cs | 9 +++++---- src/SMAPI/SemanticVersion.cs | 17 ++++++++++++++++- .../ISemanticVersion.cs | 4 ++++ src/StardewModdingAPI.Toolkit/SemanticVersion.cs | 10 +++++++--- 5 files changed, 38 insertions(+), 11 deletions(-) (limited to 'src/StardewModdingAPI.Toolkit/SemanticVersion.cs') diff --git a/docs/release-notes.md b/docs/release-notes.md index 4e2d7cab..2783ebc2 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -48,9 +48,12 @@ * Fixed `Context.IsPlayerFree` being true before the player finishes transitioning to a new location in multiplayer. * Suppressed the game's 'added crickets' debug output. * Updated dependencies (Harmony 1.0.9.1 → 1.2.0.1, Mono.Cecil 0.10 → 0.10.1). - * **Deprecation:** non-string manifest versions are now deprecated and will no longer work in SMAPI 3.0. - * **Breaking change:** `helper.ModRegistry` now returns `IModInfo` instead of `IManifest` directly. This lets SMAPI return more metadata about mods. - * **Breaking change:** most SMAPI files have been moved into a `smapi-internal` subfolder. This won't affect compiled mod releases, but you'll need to update the build config NuGet package. + * **Deprecations:** + * Non-string manifest versions are now deprecated and will no longer work in SMAPI 3.0. Affected mods should be updated to use a string version, like `"Version": "1.0.0"`. + * `ISemanticVersion.Build` is now deprecated and will be removed in SMAPI 3.0. Affected mods should use `ISemanticVersion.PrereleaseTag` instead. + * **Breaking changes:** + * `helper.ModRegistry` now returns `IModInfo` instead of `IManifest` directly. This lets SMAPI return more metadata about mods. + * Most SMAPI files have been moved into a `smapi-internal` subfolder. This won't affect compiled mod releases, but you'll need to update the build config NuGet package. * For SMAPI developers: * Added support for parallel stable/beta unofficial updates in update checks. diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs index 6cb564ce..7567c6db 100644 --- a/src/SMAPI/Framework/SCore.cs +++ b/src/SMAPI/Framework/SCore.cs @@ -77,7 +77,7 @@ namespace StardewModdingAPI.Framework /// Manages deprecation warnings. /// This is initialised after the game starts. - private DeprecationManager DeprecationManager; + private readonly DeprecationManager DeprecationManager; /// Manages SMAPI events for mods. private readonly EventManager EventManager; @@ -134,6 +134,10 @@ namespace StardewModdingAPI.Framework }; this.MonitorForGame = this.GetSecondaryMonitor("game"); this.EventManager = new EventManager(this.Monitor, this.ModRegistry); + this.DeprecationManager = new DeprecationManager(this.Monitor, this.ModRegistry); + + // inject deprecation managers + SemanticVersion.DeprecationManager = this.DeprecationManager; // init logging this.Monitor.Log($"SMAPI {Constants.ApiVersion} with Stardew Valley {Constants.GameVersion} on {EnvironmentUtility.GetFriendlyPlatformName(Constants.Platform)}", LogLevel.Info); @@ -340,9 +344,6 @@ namespace StardewModdingAPI.Framework /// Initialise SMAPI and mods after the game starts. private void InitialiseAfterGameStart() { - // load core components - this.DeprecationManager = new DeprecationManager(this.Monitor, this.ModRegistry); - // redirect direct console output if (this.MonitorForGame.WriteToConsole) this.ConsoleManager.OnMessageIntercepted += message => this.HandleConsoleMessage(this.MonitorForGame, message); diff --git a/src/SMAPI/SemanticVersion.cs b/src/SMAPI/SemanticVersion.cs index a65afeb8..401f62c2 100644 --- a/src/SMAPI/SemanticVersion.cs +++ b/src/SMAPI/SemanticVersion.cs @@ -1,5 +1,6 @@ using System; using Newtonsoft.Json; +using StardewModdingAPI.Framework; namespace StardewModdingAPI { @@ -12,6 +13,9 @@ namespace StardewModdingAPI /// The underlying semantic version implementation. private readonly ISemanticVersion Version; + /// Manages deprecation warnings. + internal static DeprecationManager DeprecationManager { get; set; } + /********* ** Accessors @@ -26,7 +30,18 @@ namespace StardewModdingAPI public int PatchVersion => this.Version.PatchVersion; /// An optional build tag. - public string Build => this.Version.Build; + [Obsolete("Use " + nameof(ISemanticVersion.PrereleaseTag) + " instead")] + public string Build + { + get + { + SemanticVersion.DeprecationManager?.Warn($"{nameof(ISemanticVersion)}.{nameof(ISemanticVersion.Build)}", "2.8", DeprecationLevel.Notice); + return this.Version.PrereleaseTag; + } + } + + /// An optional prerelease tag. + public string PrereleaseTag => this.Version.PrereleaseTag; /********* diff --git a/src/StardewModdingAPI.Toolkit.CoreInterfaces/ISemanticVersion.cs b/src/StardewModdingAPI.Toolkit.CoreInterfaces/ISemanticVersion.cs index 961ef777..6631b01d 100644 --- a/src/StardewModdingAPI.Toolkit.CoreInterfaces/ISemanticVersion.cs +++ b/src/StardewModdingAPI.Toolkit.CoreInterfaces/ISemanticVersion.cs @@ -18,8 +18,12 @@ namespace StardewModdingAPI int PatchVersion { get; } /// An optional build tag. + [Obsolete("Use " + nameof(ISemanticVersion.PrereleaseTag) + " instead")] string Build { get; } + /// An optional prerelease tag. + string PrereleaseTag { get; } + /********* ** Accessors diff --git a/src/StardewModdingAPI.Toolkit/SemanticVersion.cs b/src/StardewModdingAPI.Toolkit/SemanticVersion.cs index de33df2f..a7990d13 100644 --- a/src/StardewModdingAPI.Toolkit/SemanticVersion.cs +++ b/src/StardewModdingAPI.Toolkit/SemanticVersion.cs @@ -40,7 +40,11 @@ namespace StardewModdingAPI.Toolkit public int PatchVersion { get; } /// An optional prerelease tag. - public string Build { get; } + [Obsolete("Use " + nameof(ISemanticVersion.PrereleaseTag) + " instead")] + public string Build => this.PrereleaseTag; + + /// An optional prerelease tag. + public string PrereleaseTag { get; } /// Whether the version was parsed from the legacy object format. public bool IsLegacyFormat { get; } @@ -60,7 +64,7 @@ namespace StardewModdingAPI.Toolkit this.MajorVersion = major; this.MinorVersion = minor; this.PatchVersion = patch; - this.Build = this.GetNormalisedTag(tag); + this.PrereleaseTag = this.GetNormalisedTag(tag); this.IsLegacyFormat = isLegacyFormat; this.AssertValid(); @@ -98,7 +102,7 @@ namespace StardewModdingAPI.Toolkit this.MajorVersion = int.Parse(match.Groups["major"].Value); this.MinorVersion = match.Groups["minor"].Success ? int.Parse(match.Groups["minor"].Value) : 0; this.PatchVersion = match.Groups["patch"].Success ? int.Parse(match.Groups["patch"].Value) : 0; - this.Build = match.Groups["prerelease"].Success ? this.GetNormalisedTag(match.Groups["prerelease"].Value) : null; + this.PrereleaseTag = match.Groups["prerelease"].Success ? this.GetNormalisedTag(match.Groups["prerelease"].Value) : null; this.AssertValid(); } -- cgit