mirror of
https://github.com/wagesj45/butterflow-ui.git
synced 2024-12-21 17:02:28 -06:00
Update Check
This commit is contained in:
parent
0c3921f6b0
commit
5751726f99
8 changed files with 195 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
|
||||
<Product Id="*" Name="butterflow-ui" Language="1033" Version="1.0.2" Manufacturer="butterflow-ui @ github" UpgradeCode="bba9d512-377a-467e-920a-cbcf36ffc072">
|
||||
<Product Id="*" Name="butterflow-ui" Language="1033" Version="1.0.3" Manufacturer="butterflow-ui @ github" UpgradeCode="bba9d512-377a-467e-920a-cbcf36ffc072">
|
||||
<Package Id="*" InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
|
||||
|
||||
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
|
||||
|
|
|
@ -57,6 +57,7 @@
|
|||
</StackPanel>
|
||||
</Grid>
|
||||
<Separator Margin="0,10" />
|
||||
<TextBlock Text="{x:Static butterflow_ui:OctokitWrapper.CurrentVersionStatusDescription}" TextAlignment="Center" Margin="0,10" />
|
||||
<Button Name="btnOK" MaxWidth="50" Content="{x:Static loc:Localization.OKLabel}" Click="btnOK_Click"/>
|
||||
</StackPanel>
|
||||
</DockPanel>
|
||||
|
|
36
butterflow-ui/Localization/Localization.Designer.cs
generated
36
butterflow-ui/Localization/Localization.Designer.cs
generated
|
@ -195,6 +195,15 @@ namespace butterflow_ui.Localization {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The current version is behind the github repository and should be updated..
|
||||
/// </summary>
|
||||
public static string BehindVersionStatusDescription {
|
||||
get {
|
||||
return ResourceManager.GetString("BehindVersionStatusDescription", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to ButterflowUI Configuration File.
|
||||
/// </summary>
|
||||
|
@ -249,6 +258,15 @@ namespace butterflow_ui.Localization {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The current version is up to date with the github repository..
|
||||
/// </summary>
|
||||
public static string CurrentVersionStatusDescription {
|
||||
get {
|
||||
return ResourceManager.GetString("CurrentVersionStatusDescription", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Custom Rate.
|
||||
/// </summary>
|
||||
|
@ -258,6 +276,15 @@ namespace butterflow_ui.Localization {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The current version is ahead of the github repository, or is a custom version of butterflow-ui that cannot be compared to the github repository..
|
||||
/// </summary>
|
||||
public static string CustomVersionStatusDescription {
|
||||
get {
|
||||
return ResourceManager.GetString("CustomVersionStatusDescription", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Developers and Contributors.
|
||||
/// </summary>
|
||||
|
@ -789,6 +816,15 @@ namespace butterflow_ui.Localization {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Github failed to respond with the current version. This could be because of rate limits or a network failure..
|
||||
/// </summary>
|
||||
public static string UnknownVersionStatusDescription {
|
||||
get {
|
||||
return ResourceManager.GetString("UnknownVersionStatusDescription", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Version.
|
||||
/// </summary>
|
||||
|
|
|
@ -372,4 +372,16 @@
|
|||
<data name="SupportedFileTypesLabel" xml:space="preserve">
|
||||
<value>Supported File Types</value>
|
||||
</data>
|
||||
<data name="BehindVersionStatusDescription" xml:space="preserve">
|
||||
<value>The current version is behind the github repository and should be updated.</value>
|
||||
</data>
|
||||
<data name="CurrentVersionStatusDescription" xml:space="preserve">
|
||||
<value>The current version is up to date with the github repository.</value>
|
||||
</data>
|
||||
<data name="CustomVersionStatusDescription" xml:space="preserve">
|
||||
<value>The current version is ahead of the github repository, or is a custom version of butterflow-ui that cannot be compared to the github repository.</value>
|
||||
</data>
|
||||
<data name="UnknownVersionStatusDescription" xml:space="preserve">
|
||||
<value>Github failed to respond with the current version. This could be because of rate limits or a network failure.</value>
|
||||
</data>
|
||||
</root>
|
139
butterflow-ui/OctokitWrapper.cs
Normal file
139
butterflow-ui/OctokitWrapper.cs
Normal file
|
@ -0,0 +1,139 @@
|
|||
using csmic;
|
||||
using Octokit;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace butterflow_ui
|
||||
{
|
||||
/// <summary>
|
||||
/// An wrapper for the Octokit.net class. This class is used to extract functionality for
|
||||
/// checking github for updates to butterflow-ui installation.
|
||||
/// </summary>
|
||||
public static class OctokitWrapper
|
||||
{
|
||||
#region Members
|
||||
|
||||
/// <summary> The RegEx string for matching . </summary>
|
||||
private const string REGEX_VERSION = @"(?<Major>\d+ ?)\.(?<Minor>\d+ ?)\.(?<Patch>\d+ ?)";
|
||||
|
||||
/// <summary> The version status of the current installation. </summary>
|
||||
private static VersionStatus versionStatus = VersionStatus.unknown;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary> Gets the current version status of this installation. </summary>
|
||||
/// <value> The current version status of this installation. </value>
|
||||
public static VersionStatus CurrentVersionStatus
|
||||
{
|
||||
get
|
||||
{
|
||||
return versionStatus;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Gets information describing the current version status. </summary>
|
||||
/// <value> Information describing the current version status. </value>
|
||||
public static string CurrentVersionStatusDescription
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (CurrentVersionStatus)
|
||||
{
|
||||
case VersionStatus.current:
|
||||
return Localization.Localization.CurrentVersionStatusDescription;
|
||||
case VersionStatus.behind:
|
||||
return Localization.Localization.BehindVersionStatusDescription;
|
||||
case VersionStatus.custom:
|
||||
return Localization.Localization.CustomVersionStatusDescription;
|
||||
case VersionStatus.unknown:
|
||||
default:
|
||||
return Localization.Localization.UnknownVersionStatusDescription;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
/// <summary> Static constructor. </summary>
|
||||
static OctokitWrapper()
|
||||
{
|
||||
versionStatus = GetVersionStatus();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary> Gets version status from github. </summary>
|
||||
/// <returns> The current version status. </returns>
|
||||
private static VersionStatus GetVersionStatus()
|
||||
{
|
||||
var interpreter = new InputInterpreter();
|
||||
var client = new GitHubClient(new ProductHeaderValue("butterflow-ui"));
|
||||
var releases = client.Repository.Release.GetAll("wagesj45", "butterflow-ui").Result;
|
||||
|
||||
if (releases.Any())
|
||||
{
|
||||
var latest = releases.First();
|
||||
decimal latestMajor = 0, latestMinor = 0, latestPatch = 0, currentMajor = 0, currentMinor = 0, currentPatch = 0;
|
||||
|
||||
var regex = new Regex(REGEX_VERSION);
|
||||
foreach (Match match in regex.Matches(latest.TagName))
|
||||
{
|
||||
latestMajor = interpreter.ComputeExpression(match.Groups["Major"].Value);
|
||||
latestMinor = interpreter.ComputeExpression(match.Groups["Minor"].Value);
|
||||
latestPatch = interpreter.ComputeExpression(match.Groups["Patch"].Value);
|
||||
}
|
||||
|
||||
foreach (Match match in regex.Matches(Assembly.GetExecutingAssembly().GetName().Version.ToString()))
|
||||
{
|
||||
currentMajor = interpreter.ComputeExpression(match.Groups["Major"].Value);
|
||||
currentMinor = interpreter.ComputeExpression(match.Groups["Minor"].Value);
|
||||
currentPatch = interpreter.ComputeExpression(match.Groups["Patch"].Value);
|
||||
}
|
||||
|
||||
if (latestMajor == currentMajor && latestMinor == currentMinor && latestPatch == currentPatch)
|
||||
{
|
||||
return VersionStatus.current;
|
||||
}
|
||||
|
||||
if (latestMajor >= currentMajor && latestMinor >= currentMinor && latestPatch >= currentPatch)
|
||||
{
|
||||
return VersionStatus.behind;
|
||||
}
|
||||
|
||||
return VersionStatus.custom;
|
||||
}
|
||||
|
||||
return VersionStatus.unknown;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Subclasses
|
||||
|
||||
/// <summary> Values that represent version status of the current installation of butterflow-ui. </summary>
|
||||
public enum VersionStatus
|
||||
{
|
||||
/// <summary> The current version is up to date with the github repository. </summary>
|
||||
current,
|
||||
/// <summary> The current version is behind the github repository and should be updated. </summary>
|
||||
behind,
|
||||
/// <summary> The current version is ahead of the github repository, or is a custom version of butterflow-ui that cannot be compared to the github repository. </summary>
|
||||
custom,
|
||||
/// <summary> Github failed to respond with the current version. This could be because of rate limits or a network failure. </summary>
|
||||
unknown
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -51,5 +51,5 @@ using System.Windows;
|
|||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.2.*")]
|
||||
[assembly: AssemblyVersion("1.0.3.*")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
|
|
|
@ -45,6 +45,9 @@
|
|||
<Reference Include="Gu.Wpf.Media, Version=0.5.0.2, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Gu.Wpf.Media.0.5.0.2\lib\net45\Gu.Wpf.Media.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Octokit, Version=0.31.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Octokit.0.31.0\lib\net45\Octokit.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
|
@ -72,6 +75,7 @@
|
|||
<Compile Include="FlowFilterType.cs" />
|
||||
<Compile Include="InverseBoolConverter.cs" />
|
||||
<Compile Include="InverseBoolVisibilityConverter.cs" />
|
||||
<Compile Include="OctokitWrapper.cs" />
|
||||
<Compile Include="OptionsConfigurationFile.cs" />
|
||||
<Compile Include="OptionsWindow.xaml.cs">
|
||||
<DependentUpon>OptionsWindow.xaml</DependentUpon>
|
||||
|
|
|
@ -2,4 +2,5 @@
|
|||
<packages>
|
||||
<package id="csmic" version="1.1.4" targetFramework="net471" />
|
||||
<package id="Gu.Wpf.Media" version="0.5.0.2" targetFramework="net471" />
|
||||
<package id="Octokit" version="0.31.0" targetFramework="net471" />
|
||||
</packages>
|
Loading…
Reference in a new issue