-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configuration history support (#4552)
## Change This change adds basic configuration history support. This is stored in an SQLite database that is shared by all of the configuration code (so both `winget.exe` and PowerShell modules will use the same database). The database currently holds a representation of every configuration set that has been applied (or at least attempted to be applied). Basic fields are stored directly, while more complex data is stored by serializing to YAML. While the database currently has only basic data, it will eventually contain status information for configuration units and other information used during synchronization of multiple configuration users. >[!Note] >The dev build (based on `AICLI_DISABLE_TEST_HOOKS`) uses a different location for history to prevent local tests runs from adversely affecting the configuration usage experience for us. ### winget.exe interface changes A new command is added under the `configure` top level command, `list`. This shows details about items in the history. ```PowerShell > wingetdev configure list Identifier Name First Applied Origin ---------------------------------------------------------------------------------- {9C8386B3-6C06-46D8-A0B1-83F3C73D86CE} Test Name 2024-06-13 11:43:20.000 Test Path {F9DB9D25-92F3-4FBC-AD34-BEEEE53F08A0} Test Name 2024-06-13 11:43:21.000 Test Path {49B3FDDA-9ABA-475C-A9FE-296CE3D7ED48} Test Name 2024-06-13 11:43:21.000 Test Path {436B929A-E717-4F3B-B16E-BD268D5916D6} Test Name 2024-06-13 11:43:21.000 Test Path > wingetdev configure list -h "{9C8386B3-6C06-46D8-A0B1-83F3C73D86CE}" Field Value ---------------------------------------------------- Identifier {9C8386B3-6C06-46D8-A0B1-83F3C73D86CE} Name Test Name First Applied 2024-06-13 11:43:20.000 Origin Test Origin Path Test Path ``` In addition to listing everything, one can provide the listed name of the configuration or any unique starting sequence of the identifier to select a single item to view. The selection options apply to all other commands that take in the history item parameter, and completion has been added for the parameter so that substrings of either identifier or name can be expanded. The `configure`, `configure show`, and `configure test` commands have all had the history parameter added so that one can operate directly against a historical set. In addition to displaying information about history, the `configure list` command also allows for removing items from history with `--remove` and creating a YAML file for the set with `--output`. ### PowerShell interface changes The existing cmdlet `Get-WinGetConfiguration` was updated to include parameter set options `-All` to get all set from history and `-InstanceIdentifier` to get a single one (these are exclusive with `-File` and each other). `Remove-WinGetConfigurationHistory` was added to allow removing sets from history, and `ConvertTo-WinGetConfigurationYaml` was added to enable serializing a set to a string.
- Loading branch information
Showing
102 changed files
with
3,198 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
#include "pch.h" | ||
#include "ConfigureListCommand.h" | ||
#include "Workflows/ConfigurationFlow.h" | ||
#include "ConfigurationCommon.h" | ||
|
||
using namespace AppInstaller::CLI::Workflow; | ||
|
||
namespace AppInstaller::CLI | ||
{ | ||
std::vector<Argument> ConfigureListCommand::GetArguments() const | ||
{ | ||
return { | ||
Argument{ Execution::Args::Type::ConfigurationHistoryItem, Resource::String::ConfigurationHistoryItemArgumentDescription, ArgumentType::Standard }, | ||
Argument{ Execution::Args::Type::OutputFile, Resource::String::OutputFileArgumentDescription, ArgumentType::Standard, Argument::Visibility::Help }, | ||
Argument{ Execution::Args::Type::ConfigurationHistoryRemove, Resource::String::ConfigurationHistoryRemoveArgumentDescription, ArgumentType::Flag, Argument::Visibility::Help }, | ||
}; | ||
} | ||
|
||
Resource::LocString ConfigureListCommand::ShortDescription() const | ||
{ | ||
return { Resource::String::ConfigureListCommandShortDescription }; | ||
} | ||
|
||
Resource::LocString ConfigureListCommand::LongDescription() const | ||
{ | ||
return { Resource::String::ConfigureListCommandLongDescription }; | ||
} | ||
|
||
Utility::LocIndView ConfigureListCommand::HelpLink() const | ||
{ | ||
return "https://aka.ms/winget-command-configure#list"_liv; | ||
} | ||
|
||
void ConfigureListCommand::ExecuteInternal(Execution::Context& context) const | ||
{ | ||
context << | ||
VerifyIsFullPackage << | ||
CreateConfigurationProcessorWithoutFactory << | ||
GetConfigurationSetHistory; | ||
|
||
if (context.Args.Contains(Execution::Args::Type::ConfigurationHistoryItem)) | ||
{ | ||
context << SelectSetFromHistory; | ||
|
||
if (context.Args.Contains(Execution::Args::Type::OutputFile)) | ||
{ | ||
context << SerializeConfigurationSetHistory; | ||
} | ||
|
||
if (context.Args.Contains(Execution::Args::Type::ConfigurationHistoryRemove)) | ||
{ | ||
context << RemoveConfigurationSetHistory; | ||
} | ||
else | ||
{ | ||
context << ShowSingleConfigurationSetHistory; | ||
} | ||
} | ||
else | ||
{ | ||
context << ShowConfigurationSetHistory; | ||
} | ||
} | ||
|
||
void ConfigureListCommand::ValidateArgumentsInternal(Execution::Args& execArgs) const | ||
{ | ||
if ((execArgs.Contains(Execution::Args::Type::ConfigurationHistoryRemove) || | ||
execArgs.Contains(Execution::Args::Type::OutputFile)) && | ||
!execArgs.Contains(Execution::Args::Type::ConfigurationHistoryItem)) | ||
{ | ||
throw CommandException(Resource::String::RequiredArgError(ArgumentCommon::ForType(Execution::Args::Type::ConfigurationHistoryItem).Name)); | ||
} | ||
} | ||
|
||
void ConfigureListCommand::Complete(Execution::Context& context, Execution::Args::Type argType) const | ||
{ | ||
if (argType == Execution::Args::Type::ConfigurationHistoryItem) | ||
{ | ||
context << CompleteConfigurationHistoryItem; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
#pragma once | ||
#include "Command.h" | ||
|
||
namespace AppInstaller::CLI | ||
{ | ||
struct ConfigureListCommand final : public Command | ||
{ | ||
ConfigureListCommand(std::string_view parent) : Command("list", { "ls" }, parent) {} | ||
|
||
std::vector<Argument> GetArguments() const override; | ||
|
||
Resource::LocString ShortDescription() const override; | ||
Resource::LocString LongDescription() const override; | ||
|
||
Utility::LocIndView HelpLink() const override; | ||
|
||
protected: | ||
void ExecuteInternal(Execution::Context& context) const override; | ||
void ValidateArgumentsInternal(Execution::Args& execArgs) const override; | ||
void Complete(Execution::Context& context, Execution::Args::Type argType) const override; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.