diff options
author | Jamie Taylor <Jamie.Taylor@pobox.com> | 2022-10-01 21:09:39 -0400 |
---|---|---|
committer | Jamie Taylor <Jamie.Taylor@pobox.com> | 2022-10-01 21:30:14 -0400 |
commit | 83aec980b3ee739fb4bc251217556b3ae44f741b (patch) | |
tree | afa8c91eb20cf56ed2cb35563ba3bd2d1e4c8a46 /src/SMAPI.Web/Controllers | |
parent | 6d4eed56b1d80d02db773b0cd2f372baec6b2d1b (diff) | |
download | SMAPI-83aec980b3ee739fb4bc251217556b3ae44f741b.tar.gz SMAPI-83aec980b3ee739fb4bc251217556b3ae44f741b.tar.bz2 SMAPI-83aec980b3ee739fb4bc251217556b3ae44f741b.zip |
Add UpdateManifest site type.
Adds the UpdateManifest site key and associated client. This required
some additional features in the existing update machinery.
Each "version" can now (optionally) have its own download URL.
Mod Page objects can now specify that subkey matching (for that page)
should be "strict". A strict subkey match does not fall back to matching
with no subkey if a subkey was provided but produced no versions. It also
strips the leading '@' from the subkey.
IModDownload objects are now responsible for deciding whether a subkey
matches or not. The default behavior is unchanged, but this allows
different mod sites to have different rules for subkey matching (which
the UpdateManifest mod site uses to force exact matches).
Diffstat (limited to 'src/SMAPI.Web/Controllers')
-rw-r--r-- | src/SMAPI.Web/Controllers/ModsApiController.cs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/SMAPI.Web/Controllers/ModsApiController.cs b/src/SMAPI.Web/Controllers/ModsApiController.cs index 71fb42c2..1c34f2af 100644 --- a/src/SMAPI.Web/Controllers/ModsApiController.cs +++ b/src/SMAPI.Web/Controllers/ModsApiController.cs @@ -22,6 +22,7 @@ using StardewModdingAPI.Web.Framework.Clients.CurseForge; using StardewModdingAPI.Web.Framework.Clients.GitHub; using StardewModdingAPI.Web.Framework.Clients.ModDrop; using StardewModdingAPI.Web.Framework.Clients.Nexus; +using StardewModdingAPI.Web.Framework.Clients.UpdateManifest; using StardewModdingAPI.Web.Framework.ConfigModels; namespace StardewModdingAPI.Web.Controllers @@ -63,14 +64,15 @@ namespace StardewModdingAPI.Web.Controllers /// <param name="github">The GitHub API client.</param> /// <param name="modDrop">The ModDrop API client.</param> /// <param name="nexus">The Nexus API client.</param> - public ModsApiController(IWebHostEnvironment environment, IWikiCacheRepository wikiCache, IModCacheRepository modCache, IOptions<ModUpdateCheckConfig> config, IChucklefishClient chucklefish, ICurseForgeClient curseForge, IGitHubClient github, IModDropClient modDrop, INexusClient nexus) + /// <param name="updateManifest">The UpdateManifest client.</param> + public ModsApiController(IWebHostEnvironment environment, IWikiCacheRepository wikiCache, IModCacheRepository modCache, IOptions<ModUpdateCheckConfig> config, IChucklefishClient chucklefish, ICurseForgeClient curseForge, IGitHubClient github, IModDropClient modDrop, INexusClient nexus, IUpdateManifestClient updateManifest) { this.ModDatabase = new ModToolkit().GetModDatabase(Path.Combine(environment.WebRootPath, "SMAPI.metadata.json")); this.WikiCache = wikiCache; this.ModCache = modCache; this.Config = config; - this.ModSites = new ModSiteManager(new IModSiteClient[] { chucklefish, curseForge, github, modDrop, nexus }); + this.ModSites = new ModSiteManager(new IModSiteClient[] { chucklefish, curseForge, github, modDrop, nexus, updateManifest }); } /// <summary>Fetch version metadata for the given mods.</summary> @@ -161,18 +163,22 @@ namespace StardewModdingAPI.Web.Controllers // if there's only a prerelease version (e.g. from GitHub), don't override the main version ISemanticVersion? curMain = data.Version; + string? curMainUrl = data.MainVersionUrl; ISemanticVersion? curPreview = data.PreviewVersion; + string? curPreviewUrl = data.PreviewVersionUrl; if (curPreview == null && curMain?.IsPrerelease() == true) { curPreview = curMain; + curPreviewUrl = curMainUrl; curMain = null; + curMainUrl = null; } // handle versions if (this.IsNewer(curMain, main?.Version)) - main = new ModEntryVersionModel(curMain, data.Url!); + main = new ModEntryVersionModel(curMain, curMainUrl ?? data.Url!); if (this.IsNewer(curPreview, optional?.Version)) - optional = new ModEntryVersionModel(curPreview, data.Url!); + optional = new ModEntryVersionModel(curPreview, curPreviewUrl ?? data.Url!); } // get unofficial version |