using System;
using System.Text.RegularExpressions;
namespace AppScaffolding;
/// Result of a version check: definitive up-to-date, update available, or unable to determine.
public enum VersionCheckOutcome
{
UpToDate,
UpdateAvailable,
UnableToDetermine,
}
/// Result of checking for a new version. Use to show the right message; is set only when is .
public record VersionCheckResult(VersionCheckOutcome Outcome, UpgradeProperties? UpgradeProperties = null);
public partial record UpgradeProperties
{
public string ZipUrl { get; }
public string HtmlUrl { get; }
public string ZipName { get; }
public Version LatestRelease { get; }
public string Notes { get; }
public UpgradeProperties(string zipUrl, string htmlUrl, string zipName, Version latestRelease, string notes)
{
ZipName = zipName;
HtmlUrl = htmlUrl;
ZipUrl = zipUrl;
LatestRelease = latestRelease;
var text = NoAppBlockRegex().Replace(notes, "");
text = LinkStripRegex().Replace(text, "$1");
Notes = text.Trim();
}
[GeneratedRegex(@"\[(.*)\]\(.*\)")]
private static partial Regex LinkStripRegex();
[GeneratedRegex(@".*?", RegexOptions.Singleline)]
private static partial Regex NoAppBlockRegex();
}