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.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 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); } } 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 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 diff --git a/Source/v2/Meadow.Tooling.Core/App/AppManager.cs b/Source/v2/Meadow.Tooling.Core/App/AppManager.cs index a08b74b0..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,8 +133,13 @@ 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}/" : $"{file.Path}"; + var folder = string.IsNullOrEmpty(file.Path) ? $"/{MeadowRootFolder}/" : $"/{MeadowRootFolder}/{file.Path}/"; await connection.DeleteFile($"{folder}{file.Name}", cancellationToken); }