From 609ceedaba6cd42e7025f1a15ebfeb26c69bab80 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 11 Jan 2020 16:53:58 -0500 Subject: update for compatibility list change --- src/SMAPI.Toolkit/Framework/Clients/Wiki/WikiClient.cs | 12 ++---------- src/SMAPI.Toolkit/Framework/Clients/Wiki/WikiModEntry.cs | 4 ++-- 2 files changed, 4 insertions(+), 12 deletions(-) (limited to 'src/SMAPI.Toolkit/Framework/Clients') diff --git a/src/SMAPI.Toolkit/Framework/Clients/Wiki/WikiClient.cs b/src/SMAPI.Toolkit/Framework/Clients/Wiki/WikiClient.cs index 384f23fc..c829c0f4 100644 --- a/src/SMAPI.Toolkit/Framework/Clients/Wiki/WikiClient.cs +++ b/src/SMAPI.Toolkit/Framework/Clients/Wiki/WikiClient.cs @@ -102,6 +102,7 @@ namespace StardewModdingAPI.Toolkit.Framework.Clients.Wiki string anchor = this.GetAttribute(node, "id"); string contentPackFor = this.GetAttribute(node, "data-content-pack-for"); string devNote = this.GetAttribute(node, "data-dev-note"); + string pullRequestUrl = this.GetAttribute(node, "data-pr"); IDictionary mapLocalVersions = this.GetAttributeAsVersionMapping(node, "data-map-local-versions"); IDictionary mapRemoteVersions = this.GetAttributeAsVersionMapping(node, "data-map-remote-versions"); @@ -132,15 +133,6 @@ namespace StardewModdingAPI.Toolkit.Framework.Clients.Wiki } } - // parse links - List> metadataLinks = new List>(); - foreach (HtmlNode linkElement in node.Descendants("td").Last().Descendants("a").Skip(1)) // skip anchor link - { - string text = linkElement.InnerText.Trim(); - Uri url = new Uri(linkElement.GetAttributeValue("href", "")); - metadataLinks.Add(Tuple.Create(url, text)); - } - // yield model yield return new WikiModEntry { @@ -159,7 +151,7 @@ namespace StardewModdingAPI.Toolkit.Framework.Clients.Wiki Compatibility = compatibility, BetaCompatibility = betaCompatibility, Warnings = warnings, - MetadataLinks = metadataLinks.ToArray(), + PullRequestUrl = pullRequestUrl, DevNote = devNote, MapLocalVersions = mapLocalVersions, MapRemoteVersions = mapRemoteVersions, diff --git a/src/SMAPI.Toolkit/Framework/Clients/Wiki/WikiModEntry.cs b/src/SMAPI.Toolkit/Framework/Clients/Wiki/WikiModEntry.cs index 931dcd43..474dce3d 100644 --- a/src/SMAPI.Toolkit/Framework/Clients/Wiki/WikiModEntry.cs +++ b/src/SMAPI.Toolkit/Framework/Clients/Wiki/WikiModEntry.cs @@ -57,8 +57,8 @@ namespace StardewModdingAPI.Toolkit.Framework.Clients.Wiki /// The human-readable warnings for players about this mod. public string[] Warnings { get; set; } - /// Extra metadata links (usually for open pull requests). - public Tuple[] MetadataLinks { get; set; } + /// The URL of the pull request which submits changes for an unofficial update to the author, if any. + public string PullRequestUrl { get; set; } /// Special notes intended for developers who maintain unofficial updates or submit pull requests. public string DevNote { get; set; } -- cgit From 2b68be4ebbb16213167b9bd04e891c7e05c67400 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 11 Jan 2020 20:33:01 -0500 Subject: add version mappings from the wiki to API data --- docs/release-notes.md | 3 +++ .../Framework/Clients/WebApi/ModExtendedMetadataModel.cs | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'src/SMAPI.Toolkit/Framework/Clients') diff --git a/docs/release-notes.md b/docs/release-notes.md index 22e609dd..63cbbc2c 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -9,6 +9,9 @@ * Fixed 'collection was modified' error when returning to title in rare cases. * Fixed update-check error if a mod's Chucklefish page has no version. +* For SMAPI/tool developers: + * The `/mods` web API endpoint now includes version mappings from the wiki. + ## 3.1 Released 05 January 2019 for Stardew Valley 1.4 or later. diff --git a/src/SMAPI.Toolkit/Framework/Clients/WebApi/ModExtendedMetadataModel.cs b/src/SMAPI.Toolkit/Framework/Clients/WebApi/ModExtendedMetadataModel.cs index 4a697585..8c21e4e0 100644 --- a/src/SMAPI.Toolkit/Framework/Clients/WebApi/ModExtendedMetadataModel.cs +++ b/src/SMAPI.Toolkit/Framework/Clients/WebApi/ModExtendedMetadataModel.cs @@ -55,7 +55,7 @@ namespace StardewModdingAPI.Toolkit.Framework.Clients.WebApi /// The latest unofficial version, if newer than and . public ModEntryVersionModel Unofficial { get; set; } - /// The latest unofficial version for the current Stardew Valley or SMAPI beta, if any (see ). + /// The latest unofficial version for the current Stardew Valley or SMAPI beta, if any. public ModEntryVersionModel UnofficialForBeta { get; set; } /**** @@ -84,6 +84,15 @@ namespace StardewModdingAPI.Toolkit.Framework.Clients.WebApi /// The beta game or SMAPI version which broke this mod, if applicable. public string BetaBrokeIn { get; set; } + /**** + ** Version mappings + ****/ + /// Maps local versions to a semantic version for update checks. + public IDictionary MapLocalVersions { get; set; } + + /// Maps remote versions to a semantic version for update checks. + public IDictionary MapRemoteVersions { get; set; } + /********* ** Public methods @@ -127,13 +136,16 @@ namespace StardewModdingAPI.Toolkit.Framework.Clients.WebApi this.BetaCompatibilityStatus = wiki.BetaCompatibility?.Status; this.BetaCompatibilitySummary = wiki.BetaCompatibility?.Summary; this.BetaBrokeIn = wiki.BetaCompatibility?.BrokeIn; + + this.MapLocalVersions = wiki.MapLocalVersions; + this.MapRemoteVersions = wiki.MapRemoteVersions; } // internal DB data if (db != null) { this.ID = this.ID.Union(db.FormerIDs).ToArray(); - this.Name = this.Name ?? db.DisplayName; + this.Name ??= db.DisplayName; } } -- cgit From d68e4f97665898027f45782b8e66333912ae08ea Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 12 Jan 2020 19:41:14 -0500 Subject: drop pre-3.0 update-check support --- docs/release-notes.md | 1 + .../Framework/Clients/WebApi/ModEntryModel.cs | 22 ---------------------- src/SMAPI.Web/Controllers/ModsApiController.cs | 17 ++--------------- 3 files changed, 3 insertions(+), 37 deletions(-) (limited to 'src/SMAPI.Toolkit/Framework/Clients') diff --git a/docs/release-notes.md b/docs/release-notes.md index bc30bed7..e2c6d500 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -15,6 +15,7 @@ For modders: For SMAPI/tool developers: * The `/mods` web API endpoint now includes version mappings from the wiki. + * Dropped API support for the pre-3.0 update-check format. ## 3.1 Released 05 January 2019 for Stardew Valley 1.4 or later. diff --git a/src/SMAPI.Toolkit/Framework/Clients/WebApi/ModEntryModel.cs b/src/SMAPI.Toolkit/Framework/Clients/WebApi/ModEntryModel.cs index f1bcfccc..2f58a3f1 100644 --- a/src/SMAPI.Toolkit/Framework/Clients/WebApi/ModEntryModel.cs +++ b/src/SMAPI.Toolkit/Framework/Clients/WebApi/ModEntryModel.cs @@ -1,5 +1,3 @@ -using System; - namespace StardewModdingAPI.Toolkit.Framework.Clients.WebApi { /// Metadata about a mod. @@ -17,26 +15,6 @@ namespace StardewModdingAPI.Toolkit.Framework.Clients.WebApi /// Optional extended data which isn't needed for update checks. public ModExtendedMetadataModel Metadata { get; set; } - /// The main version. - [Obsolete] - public ModEntryVersionModel Main { get; set; } - - /// The latest optional version, if newer than . - [Obsolete] - public ModEntryVersionModel Optional { get; set; } - - /// The latest unofficial version, if newer than and . - [Obsolete] - public ModEntryVersionModel Unofficial { get; set; } - - /// The latest unofficial version for the current Stardew Valley or SMAPI beta, if any (see ). - [Obsolete] - public ModEntryVersionModel UnofficialForBeta { get; set; } - - /// Whether a Stardew Valley or SMAPI beta which affects mod compatibility is in progress. If this is true, should be used for beta versions of SMAPI instead of . - [Obsolete] - public bool? HasBetaInfo { get; set; } - /// The errors that occurred while fetching update data. public string[] Errors { get; set; } = new string[0]; } diff --git a/src/SMAPI.Web/Controllers/ModsApiController.cs b/src/SMAPI.Web/Controllers/ModsApiController.cs index 3e3b81c8..f194b4d0 100644 --- a/src/SMAPI.Web/Controllers/ModsApiController.cs +++ b/src/SMAPI.Web/Controllers/ModsApiController.cs @@ -94,8 +94,6 @@ namespace StardewModdingAPI.Web.Controllers if (model?.Mods == null) return new ModEntryModel[0]; - bool legacyMode = SemanticVersion.TryParse(version, out ISemanticVersion parsedVersion) && parsedVersion.IsOlderThan("3.0.0-beta.20191109"); - // fetch wiki data WikiModEntry[] wikiData = this.WikiCache.GetWikiMods().Select(p => p.GetModel()).ToArray(); IDictionary mods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); @@ -104,19 +102,8 @@ namespace StardewModdingAPI.Web.Controllers if (string.IsNullOrWhiteSpace(mod.ID)) continue; - ModEntryModel result = await this.GetModData(mod, wikiData, model.IncludeExtendedMetadata || legacyMode, model.ApiVersion); - if (legacyMode) - { - result.Main = result.Metadata.Main; - result.Optional = result.Metadata.Optional; - result.Unofficial = result.Metadata.Unofficial; - result.UnofficialForBeta = result.Metadata.UnofficialForBeta; - result.HasBetaInfo = result.Metadata.BetaCompatibilityStatus != null; - result.SuggestedUpdate = null; - if (!model.IncludeExtendedMetadata) - result.Metadata = null; - } - else if (!model.IncludeExtendedMetadata && (model.ApiVersion == null || mod.InstalledVersion == null)) + ModEntryModel result = await this.GetModData(mod, wikiData, model.IncludeExtendedMetadata, model.ApiVersion); + if (!model.IncludeExtendedMetadata && (model.ApiVersion == null || mod.InstalledVersion == null)) { var errors = new List(result.Errors); errors.Add($"This API can't suggest an update because {nameof(model.ApiVersion)} or {nameof(mod.InstalledVersion)} are null, and you didn't specify {nameof(model.IncludeExtendedMetadata)} to get other info. See the SMAPI technical docs for usage."); -- cgit