Skip to content

Commit

Permalink
Do some decent version comparisons. (#351)
Browse files Browse the repository at this point in the history
* Fix 350, by doing some decent version comparisons.

* Only accept --verbose to change loglevel.

* Bump version to 1.3.4
  • Loading branch information
CartBlanche committed Sep 26, 2023
1 parent fe794a7 commit 71fe764
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 26 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Meadow.CLI
env:
CLI_RELEASE_VERSION: 1.3.0.0
IDE_TOOLS_RELEASE_VERSION: 1.3.0
MEADOW_OS_VERSION: 1.3.0.0
CLI_RELEASE_VERSION: 1.3.4.0
IDE_TOOLS_RELEASE_VERSION: 1.3.4
MEADOW_OS_VERSION: 1.3.4.0
VS_MAC_2019_VERSION: 8.10
VS_MAC_2022_VERSION: 17.5

Expand Down
2 changes: 1 addition & 1 deletion Meadow.CLI.Core/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Meadow.CLI.Core
{
public static class Constants
{
public const string CLI_VERSION = "1.3.0.0";
public const string CLI_VERSION = "1.3.4.0";
public const ushort HCOM_PROTOCOL_PREVIOUS_VERSION_NUMBER = 0x0006;
public const ushort HCOM_PROTOCOL_CURRENT_VERSION_NUMBER = 0x0007; // Used for transmission
public const string WILDERNESS_LABS_USB_VID = "2E6A";
Expand Down
15 changes: 7 additions & 8 deletions Meadow.CLI.Core/Internals/Dfu/DfuUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,10 @@ public static async Task<bool> FlashFile(string fileName, IUsbDevice? device = n

LastSerialNumber = GetDeviceSerial(device);

var dfuUtilVersion = GetDfuUtilVersion();
var dfuUtilVersion = new System.Version(GetDfuUtilVersion());
logger.LogDebug("Detected OS: {os}", RuntimeInformation.OSDescription);

if (string.IsNullOrEmpty(dfuUtilVersion))
if (dfuUtilVersion == null)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
Expand All @@ -236,24 +236,23 @@ public static async Task<bool> FlashFile(string fileName, IUsbDevice? device = n
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
logger.LogError("dfu-util not found - install using package manager, for example: `apt install dfu-util`");
logger.LogError("dfu-util not found - install using package manager, for example: `apt install dfu-util` or the equivalent for your Linux distribution");
}
return false;
}
else if (dfuUtilVersion != "0.10")
else if (dfuUtilVersion.CompareTo(new System.Version("0.11")) < 0)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
logger.LogError("dfu-util update required. To install, run in administrator mode: meadow install dfu-util");
logger.LogError("dfu-util update required. To update, run in administrator mode: `meadow install dfu-util`");
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
logger.LogError("dfu-util update required. To install, run: brew upgrade dfu-util");
logger.LogError("dfu-util update required. To update, run: `brew upgrade dfu-util`");
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
if (dfuUtilVersion != "0.9")
return false;
logger.LogError("dfu-util update required. To update , run: `apt upgrade dfu-util` or the equivalent for your Linux distribution");
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Meadow.CLI.Core/Managers/DownloadManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public async Task InstallDfuUtil(bool is64Bit = true,

Directory.CreateDirectory(WildernessLabsTemp);

const string downloadUrl = "https://s3-us-west-2.amazonaws.com/downloads.wildernesslabs.co/public/dfu-util-0.10-binaries.zip";
const string downloadUrl = "https://s3-us-west-2.amazonaws.com/downloads.wildernesslabs.co/public/dfu-util-0.11-binaries.zip";

var downloadFileName = downloadUrl.Substring(downloadUrl.LastIndexOf("/", StringComparison.Ordinal) + 1);
var response = await Client.GetAsync(downloadUrl, HttpCompletionOption.ResponseHeadersRead, cancellationToken);
Expand Down
2 changes: 1 addition & 1 deletion Meadow.CLI.Core/Meadow.CLI.Core.6.0.0.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Version>1.3.0.0</Version>
<Version>1.3.4.0</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion Meadow.CLI.Core/Meadow.CLI.Core.Classic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Version>1.3.0.0</Version>
<Version>1.3.4.0</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion Meadow.CLI.Core/Meadow.CLI.Core.VS2019.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Version>1.3.0.0</Version>
<Version>1.3.4.0</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion Meadow.CLI.Core/Meadow.CLI.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Version>1.3.0.0</Version>
<Version>1.3.4.0</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion Meadow.CLI/Meadow.CLI.Classic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Authors>Peter Moody, Adrian Stevens, Brian Kim, Pete Garafano, Dominique Louis</Authors>
<Company>Wilderness Labs, Inc</Company>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageVersion>1.3.0.0</PackageVersion>
<PackageVersion>1.3.4.0</PackageVersion>
<Platforms>AnyCPU</Platforms>
<PackageProjectUrl>http://developer.wildernesslabs.co/Meadow/Meadow.Foundation/</PackageProjectUrl>
<PackageIcon>icon.png</PackageIcon>
Expand Down
2 changes: 1 addition & 1 deletion Meadow.CLI/Meadow.CLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Authors>Peter Moody, Adrian Stevens, Brian Kim, Pete Garafano, Dominique Louis</Authors>
<Company>Wilderness Labs, Inc</Company>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageVersion>1.3.0.0</PackageVersion>
<PackageVersion>1.3.4.0</PackageVersion>
<Platforms>AnyCPU</Platforms>
<PackageProjectUrl>http://developer.wildernesslabs.co/Meadow/Meadow.Foundation/</PackageProjectUrl>
<PackageIcon>icon.png</PackageIcon>
Expand Down
9 changes: 2 additions & 7 deletions Meadow.CLI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,9 @@ public static async Task<int> Main(string[] args)
.Build();

var logLevel = LogEventLevel.Information;
var logModifier = args.FirstOrDefault(a => a.Equals("-m"))
?.Count(x => x == 'm') ?? 0;

logLevel -= logModifier;
if (logLevel < 0)
{
logLevel = 0;
}
if (args.Contains("--verbose"))
logLevel = LogEventLevel.Verbose;

var outputTemplate = logLevel == LogEventLevel.Verbose
? "[{Timestamp:HH:mm:ss.fff} {Level:u3}] {Message:lj}{NewLine}{Exception}"
Expand Down

0 comments on commit 71fe764

Please sign in to comment.