From a0838fd8c305e5de709b58ecc150609ea2e0289d Mon Sep 17 00:00:00 2001 From: Adrian Stevens Date: Mon, 5 Aug 2024 17:39:34 -0700 Subject: [PATCH 1/6] Delete legacy commands --- .../Commands/Legacy/DownloadOsCommand.cs | 16 ----------- .../Commands/Legacy/FlashOsCommand.cs | 20 ------------- .../Commands/Legacy/InstallDfuCommand.cs | 14 ---------- .../Commands/Legacy/ListPortsCommand.cs | 19 ------------- .../Commands/Legacy/MonoDisableCommand.cs | 14 ---------- .../Commands/Legacy/MonoEnableCommand.cs | 14 ---------- .../Commands/Legacy/MonoStateCommand.cs | 14 ---------- .../Commands/Legacy/UsePortCommand.cs | 28 ------------------- 8 files changed, 139 deletions(-) delete mode 100644 Source/v2/Meadow.Cli/Commands/Legacy/DownloadOsCommand.cs delete mode 100644 Source/v2/Meadow.Cli/Commands/Legacy/FlashOsCommand.cs delete mode 100644 Source/v2/Meadow.Cli/Commands/Legacy/InstallDfuCommand.cs delete mode 100644 Source/v2/Meadow.Cli/Commands/Legacy/ListPortsCommand.cs delete mode 100644 Source/v2/Meadow.Cli/Commands/Legacy/MonoDisableCommand.cs delete mode 100644 Source/v2/Meadow.Cli/Commands/Legacy/MonoEnableCommand.cs delete mode 100644 Source/v2/Meadow.Cli/Commands/Legacy/MonoStateCommand.cs delete mode 100644 Source/v2/Meadow.Cli/Commands/Legacy/UsePortCommand.cs diff --git a/Source/v2/Meadow.Cli/Commands/Legacy/DownloadOsCommand.cs b/Source/v2/Meadow.Cli/Commands/Legacy/DownloadOsCommand.cs deleted file mode 100644 index 5995118d..00000000 --- a/Source/v2/Meadow.Cli/Commands/Legacy/DownloadOsCommand.cs +++ /dev/null @@ -1,16 +0,0 @@ -using CliFx.Attributes; -using Meadow.Cloud.Client; -using Meadow.Software; -using Microsoft.Extensions.Logging; - -namespace Meadow.CLI.Commands.DeviceManagement; - -[Command("download os", Description = "** Deprecated ** Use `firmware download` instead")] -public class DownloadOsCommand : FirmwareDownloadCommand -{ - public DownloadOsCommand(FileManager fileManager, IMeadowCloudClient meadowCloudClient, ILoggerFactory loggerFactory) - : base(fileManager, meadowCloudClient, loggerFactory) - { - Logger.LogWarning($"Deprecated command - use `firmware download` instead"); - } -} \ No newline at end of file diff --git a/Source/v2/Meadow.Cli/Commands/Legacy/FlashOsCommand.cs b/Source/v2/Meadow.Cli/Commands/Legacy/FlashOsCommand.cs deleted file mode 100644 index 00fad646..00000000 --- a/Source/v2/Meadow.Cli/Commands/Legacy/FlashOsCommand.cs +++ /dev/null @@ -1,20 +0,0 @@ -using CliFx.Attributes; -using Microsoft.Extensions.Logging; - -namespace Meadow.CLI.Commands.DeviceManagement; - -[Command("flash os", Description = "** Deprecated ** Use `firmware write` instead")] -public class FlashOsCommand : BaseDeviceCommand -{ - public FlashOsCommand( - MeadowConnectionManager connectionManager, - ILoggerFactory loggerFactory) - : base(connectionManager, loggerFactory) - { - } - - protected override ValueTask ExecuteCommand() - { - throw new CommandException($"Deprecated command. Use `firmware write` instead"); - } -} \ No newline at end of file diff --git a/Source/v2/Meadow.Cli/Commands/Legacy/InstallDfuCommand.cs b/Source/v2/Meadow.Cli/Commands/Legacy/InstallDfuCommand.cs deleted file mode 100644 index a28bb0c3..00000000 --- a/Source/v2/Meadow.Cli/Commands/Legacy/InstallDfuCommand.cs +++ /dev/null @@ -1,14 +0,0 @@ -using CliFx.Attributes; -using Microsoft.Extensions.Logging; - -namespace Meadow.CLI.Commands.DeviceManagement; - -[Command("install dfu", Description = "** Deprecated ** Use `dfu install` instead")] -public class InstallDfuCommand : DfuInstallCommand -{ - public InstallDfuCommand(ISettingsManager settingsManager, ILoggerFactory loggerFactory) - : base(settingsManager, loggerFactory, "0.11") - { - Logger?.LogWarning($"Deprecated command - use `dfu install` instead"); - } -} \ No newline at end of file diff --git a/Source/v2/Meadow.Cli/Commands/Legacy/ListPortsCommand.cs b/Source/v2/Meadow.Cli/Commands/Legacy/ListPortsCommand.cs deleted file mode 100644 index d99402d2..00000000 --- a/Source/v2/Meadow.Cli/Commands/Legacy/ListPortsCommand.cs +++ /dev/null @@ -1,19 +0,0 @@ -using CliFx.Attributes; -using Microsoft.Extensions.Logging; - -namespace Meadow.CLI.Commands.DeviceManagement; - -[Command("list ports", Description = "** Deprecated ** Use `port list` instead")] -public class ListPortsCommand : PortListCommand -{ - public ListPortsCommand(ISettingsManager settingsManager, ILoggerFactory loggerFactory) - : base(loggerFactory) - { - Logger?.LogWarning($"Deprecated command - use `port list` instead"); - } - - protected override ValueTask ExecuteCommand() - { - return base.ExecuteCommand(); - } -} \ No newline at end of file diff --git a/Source/v2/Meadow.Cli/Commands/Legacy/MonoDisableCommand.cs b/Source/v2/Meadow.Cli/Commands/Legacy/MonoDisableCommand.cs deleted file mode 100644 index 8d9e63bf..00000000 --- a/Source/v2/Meadow.Cli/Commands/Legacy/MonoDisableCommand.cs +++ /dev/null @@ -1,14 +0,0 @@ -using CliFx.Attributes; -using Microsoft.Extensions.Logging; - -namespace Meadow.CLI.Commands.DeviceManagement; - -[Command("mono disable", Description = "** Deprecated ** Use `runtime disable` instead")] -public class MonoDisableCommand : RuntimeDisableCommand -{ - public MonoDisableCommand(MeadowConnectionManager connectionManager, ILoggerFactory loggerFactory) - : base(connectionManager, loggerFactory) - { - Logger?.LogWarning($"Deprecated command - use `runtime disable` instead"); - } -} \ No newline at end of file diff --git a/Source/v2/Meadow.Cli/Commands/Legacy/MonoEnableCommand.cs b/Source/v2/Meadow.Cli/Commands/Legacy/MonoEnableCommand.cs deleted file mode 100644 index d19bafe9..00000000 --- a/Source/v2/Meadow.Cli/Commands/Legacy/MonoEnableCommand.cs +++ /dev/null @@ -1,14 +0,0 @@ -using CliFx.Attributes; -using Microsoft.Extensions.Logging; - -namespace Meadow.CLI.Commands.DeviceManagement; - -[Command("mono enable", Description = "** Deprecated ** Use `runtime enable` instead")] -public class MonoEnableCommand : RuntimeEnableCommand -{ - public MonoEnableCommand(MeadowConnectionManager connectionManager, ILoggerFactory loggerFactory) - : base(connectionManager, loggerFactory) - { - Logger?.LogWarning($"Deprecated command - use `runtime enable` instead"); - } -} \ No newline at end of file diff --git a/Source/v2/Meadow.Cli/Commands/Legacy/MonoStateCommand.cs b/Source/v2/Meadow.Cli/Commands/Legacy/MonoStateCommand.cs deleted file mode 100644 index 4fd2a7d3..00000000 --- a/Source/v2/Meadow.Cli/Commands/Legacy/MonoStateCommand.cs +++ /dev/null @@ -1,14 +0,0 @@ -using CliFx.Attributes; -using Microsoft.Extensions.Logging; - -namespace Meadow.CLI.Commands.DeviceManagement; - -[Command("mono state", Description = "** Deprecated ** Use `runtime state` instead")] -public class MonoStateCommand : RuntimeStateCommand -{ - public MonoStateCommand(MeadowConnectionManager connectionManager, ILoggerFactory loggerFactory) - : base(connectionManager, loggerFactory) - { - Logger?.LogWarning($"Deprecated command - use `runtime state` instead"); - } -} \ No newline at end of file diff --git a/Source/v2/Meadow.Cli/Commands/Legacy/UsePortCommand.cs b/Source/v2/Meadow.Cli/Commands/Legacy/UsePortCommand.cs deleted file mode 100644 index c46db0fa..00000000 --- a/Source/v2/Meadow.Cli/Commands/Legacy/UsePortCommand.cs +++ /dev/null @@ -1,28 +0,0 @@ -using CliFx.Attributes; -using Microsoft.Extensions.Logging; - -namespace Meadow.CLI.Commands.DeviceManagement; - -[Command("use port", Description = "** Deprecated ** Use `port select` (if connecting via serial port) or `config route` (if connecting via IP) instead")] -public class UsePortCommand : BaseCommand -{ - private readonly ISettingsManager _settingsManager; - - [CommandParameter(0, Name = "Port", IsRequired = true)] - public string Port { get; set; } = default!; - - public UsePortCommand(ILoggerFactory loggerFactory, ISettingsManager settingsManager) - : base(loggerFactory) - { - Logger?.LogWarning($"Deprecated command -use `config route` instead"); - _settingsManager = settingsManager; - } - - protected override ValueTask ExecuteCommand() - { - _settingsManager.SaveSetting("route", Port); - Logger?.LogInformation($"Using {Port}"); - - return ValueTask.CompletedTask; - } -} \ No newline at end of file From 3bf0052c4085bc74aeeb36846b79dde4538f8bd3 Mon Sep 17 00:00:00 2001 From: Adrian Stevens Date: Mon, 5 Aug 2024 17:39:46 -0700 Subject: [PATCH 2/6] Bump version to v2.0.55 --- Source/v2/Meadow.Cli/Meadow.CLI.csproj | 2 +- Source/v2/Meadow.Cli/Properties/AssemblyInfo.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/v2/Meadow.Cli/Meadow.CLI.csproj b/Source/v2/Meadow.Cli/Meadow.CLI.csproj index 3624b1bf..ce3c5ca7 100644 --- a/Source/v2/Meadow.Cli/Meadow.CLI.csproj +++ b/Source/v2/Meadow.Cli/Meadow.CLI.csproj @@ -10,7 +10,7 @@ Wilderness Labs, Inc Wilderness Labs, Inc true - 2.0.54.0 + 2.0.55.0 AnyCPU http://developer.wildernesslabs.co/Meadow/Meadow.CLI/ https://github.com/WildernessLabs/Meadow.CLI diff --git a/Source/v2/Meadow.Cli/Properties/AssemblyInfo.cs b/Source/v2/Meadow.Cli/Properties/AssemblyInfo.cs index fe1b57c9..be708e11 100644 --- a/Source/v2/Meadow.Cli/Properties/AssemblyInfo.cs +++ b/Source/v2/Meadow.Cli/Properties/AssemblyInfo.cs @@ -6,5 +6,5 @@ namespace Meadow.CLI; public static class Constants { - public const string CLI_VERSION = "2.0.54.0"; + public const string CLI_VERSION = "2.0.55.0"; } \ No newline at end of file From 1683ff6f7629d52f6c37ba3ae8b78704d20773dc Mon Sep 17 00:00:00 2001 From: Adrian Stevens Date: Mon, 5 Aug 2024 17:40:18 -0700 Subject: [PATCH 3/6] Fix file deletes in sub folders when deploying --- Source/v2/Meadow.Tooling.Core/App/AppManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/v2/Meadow.Tooling.Core/App/AppManager.cs b/Source/v2/Meadow.Tooling.Core/App/AppManager.cs index a08b74b0..06b7ecd7 100644 --- a/Source/v2/Meadow.Tooling.Core/App/AppManager.cs +++ b/Source/v2/Meadow.Tooling.Core/App/AppManager.cs @@ -133,7 +133,7 @@ public static async Task DeployApplication( foreach (var file in removeFiles) { logger?.LogInformation($"Deleting '{file}'"); - var folder = string.IsNullOrEmpty(file.Path) ? $"/{MeadowRootFolder}/" : $"{file.Path}"; + var folder = string.IsNullOrEmpty(file.Path) ? $"/{MeadowRootFolder}/" : $"/{MeadowRootFolder}/{file.Path}/"; await connection.DeleteFile($"{folder}{file.Name}", cancellationToken); } From 08a6f9171cb44670e08014e58c6d541bcff3e7d6 Mon Sep 17 00:00:00 2001 From: Adrian Stevens Date: Mon, 5 Aug 2024 17:47:45 -0700 Subject: [PATCH 4/6] Rationalize filesystem constants --- Source/v2/Meadow.CLI/Commands/Current/App/AppTools.cs | 8 +++----- Source/v2/Meadow.Tooling.Core/App/AppManager.cs | 10 ++++++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Source/v2/Meadow.CLI/Commands/Current/App/AppTools.cs b/Source/v2/Meadow.CLI/Commands/Current/App/AppTools.cs index 59435a9a..8b50d7ba 100644 --- a/Source/v2/Meadow.CLI/Commands/Current/App/AppTools.cs +++ b/Source/v2/Meadow.CLI/Commands/Current/App/AppTools.cs @@ -7,8 +7,6 @@ namespace Meadow.CLI.Commands.DeviceManagement; internal static class AppTools { - internal const string MeadowRootFolder = "meadow0"; - internal static string ValidateAndSanitizeAppPath(string? path) { path ??= Directory.GetCurrentDirectory(); @@ -124,15 +122,15 @@ internal static string SanitizeMeadowFilename(string fileName) if (string.IsNullOrWhiteSpace(folder)) { - folder = Path.DirectorySeparatorChar + MeadowRootFolder; + folder = Path.DirectorySeparatorChar + AppManager.MeadowRootFolder; } else { if (!folder.StartsWith(Path.DirectorySeparatorChar)) { - if (!folder.StartsWith($"{MeadowRootFolder}")) + if (!folder.StartsWith($"{AppManager.MeadowRootFolder}")) { - folder = $"{Path.DirectorySeparatorChar}{MeadowRootFolder}{Path.DirectorySeparatorChar}{folder}"; + folder = $"{Path.DirectorySeparatorChar}{AppManager.MeadowRootFolder}{Path.DirectorySeparatorChar}{folder}"; } else { diff --git a/Source/v2/Meadow.Tooling.Core/App/AppManager.cs b/Source/v2/Meadow.Tooling.Core/App/AppManager.cs index 06b7ecd7..8a6722f3 100644 --- a/Source/v2/Meadow.Tooling.Core/App/AppManager.cs +++ b/Source/v2/Meadow.Tooling.Core/App/AppManager.cs @@ -14,13 +14,14 @@ namespace Meadow.CLI; public static class AppManager { - static readonly string MeadowRootFolder = "meadow0"; + public static readonly string MeadowRootFolder = "meadow0"; - static readonly string[] PersistantFolders = new string[] + public static readonly string[] PersistantFolders = new string[] { "Data", "Documents", "update-store", + "system", }; private static bool MatchingDllExists(string file) @@ -132,6 +133,11 @@ public static async Task DeployApplication( // delete those files foreach (var file in removeFiles) { + if (PersistantFolders.Contains(file.Path)) + { + continue; + } + logger?.LogInformation($"Deleting '{file}'"); var folder = string.IsNullOrEmpty(file.Path) ? $"/{MeadowRootFolder}/" : $"/{MeadowRootFolder}/{file.Path}/"; From c8d2292a0586186e0a231ed703e287a67a5f8a3a Mon Sep 17 00:00:00 2001 From: Adrian Stevens Date: Mon, 5 Aug 2024 17:48:05 -0700 Subject: [PATCH 5/6] Ignore persistent folders when calling delete all --- .../Commands/Current/File/FileDeleteCommand.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Source/v2/Meadow.Cli/Commands/Current/File/FileDeleteCommand.cs b/Source/v2/Meadow.Cli/Commands/Current/File/FileDeleteCommand.cs index fb789510..bf3da405 100644 --- a/Source/v2/Meadow.Cli/Commands/Current/File/FileDeleteCommand.cs +++ b/Source/v2/Meadow.Cli/Commands/Current/File/FileDeleteCommand.cs @@ -76,6 +76,15 @@ protected override async ValueTask ExecuteCommand() private async Task DeleteFileRecursive(IMeadowDevice device, string directoryname, MeadowFileInfo fileInfo, CancellationToken cancellationToken) { var meadowFile = AppTools.SanitizeMeadowFilename(Path.Combine(directoryname, fileInfo.Name)); + + foreach (var folder in AppManager.PersistantFolders) + { + if (meadowFile.StartsWith($"/{AppManager.MeadowRootFolder}/{folder}")) + { + return; + } + } + if (fileInfo.IsDirectory) { // Add a backslash as we're a directory and not a file From 6b08096fc9efaddb295714c7d69b006545e384f8 Mon Sep 17 00:00:00 2001 From: Adrian Stevens Date: Mon, 5 Aug 2024 17:48:17 -0700 Subject: [PATCH 6/6] Update constants --- .../v2/Meadow.Cli/Commands/Current/File/FileListCommand.cs | 2 +- .../Commands/Current/Firmware/FirmwareWriteCommand.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/v2/Meadow.Cli/Commands/Current/File/FileListCommand.cs b/Source/v2/Meadow.Cli/Commands/Current/File/FileListCommand.cs index 8061345b..8db5b576 100644 --- a/Source/v2/Meadow.Cli/Commands/Current/File/FileListCommand.cs +++ b/Source/v2/Meadow.Cli/Commands/Current/File/FileListCommand.cs @@ -35,7 +35,7 @@ protected override async ValueTask ExecuteCommand() Logger?.LogInformation($"Getting file list..."); } - var files = await device.GetFileList(Folder ?? $"/{AppTools.MeadowRootFolder}/", Verbose, CancellationToken); + var files = await device.GetFileList(Folder ?? $"/{AppManager.MeadowRootFolder}/", Verbose, CancellationToken); if (files == null || files.Length == 0) { diff --git a/Source/v2/Meadow.Cli/Commands/Current/Firmware/FirmwareWriteCommand.cs b/Source/v2/Meadow.Cli/Commands/Current/Firmware/FirmwareWriteCommand.cs index b1d436b9..b489e7e5 100644 --- a/Source/v2/Meadow.Cli/Commands/Current/Firmware/FirmwareWriteCommand.cs +++ b/Source/v2/Meadow.Cli/Commands/Current/Firmware/FirmwareWriteCommand.cs @@ -223,7 +223,7 @@ protected override async ValueTask ExecuteCommand() } else { - await connection!.Device!.WriteFile(osFileWithoutBootloader, $"/{AppTools.MeadowRootFolder}/update/os/{package.OsWithoutBootloader}"); + await connection!.Device!.WriteFile(osFileWithoutBootloader, $"/{AppManager.MeadowRootFolder}/update/os/{package.OsWithoutBootloader}"); } } @@ -361,7 +361,7 @@ private async Task FindMeadowConnection(IList portsTo } else { - await connection.Device!.WriteFile(runtimePath, $"/{AppTools.MeadowRootFolder}/update/os/{destinationFilename}"); + await connection.Device!.WriteFile(runtimePath, $"/{AppManager.MeadowRootFolder}/update/os/{destinationFilename}"); } return connection; @@ -403,7 +403,7 @@ private async Task WriteEspFiles(IMeadowConnection? connection, DeviceInfo? devi { foreach (var file in fileList) { - await connection!.Device!.WriteFile(file, $"/{AppTools.MeadowRootFolder}/update/os/{Path.GetFileName(file)}"); + await connection!.Device!.WriteFile(file, $"/{AppManager.MeadowRootFolder}/update/os/{Path.GetFileName(file)}"); await Task.Delay(500); } }