Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration history support #4552

Merged
merged 26 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9c274fd
Refactor a few unpackaged paths into shared code
JohnMcPMS May 21, 2024
48ec331
Start on database infra
JohnMcPMS May 22, 2024
aff0dd2
some work for dynamic storage base
JohnMcPMS May 22, 2024
8fa3a75
much of the database work done, needs unit info and value set tables …
JohnMcPMS May 23, 2024
4344626
needs work on value set table
JohnMcPMS May 23, 2024
477ad2a
value set work
JohnMcPMS May 24, 2024
82e2598
some more work on value table
JohnMcPMS May 25, 2024
3bc54e0
Remove value set table in favor of just putting YAML in the database
JohnMcPMS May 27, 2024
5f7c78a
finish using YAML for complex values
JohnMcPMS May 27, 2024
bcb17ad
stitching for compilation success
JohnMcPMS May 28, 2024
dfe98bb
work on last bit of product code in config core
JohnMcPMS May 28, 2024
5101747
Finish config component code; builds
JohnMcPMS May 31, 2024
f33d9b1
Add a test that round trips the set through history and fix the issue…
JohnMcPMS May 31, 2024
cb2fef3
More unit tests
JohnMcPMS May 31, 2024
df1353d
wip on winget.exe integrations
JohnMcPMS May 31, 2024
8de7edc
finish configure list functionality
JohnMcPMS May 31, 2024
82a89a7
Add support to existing commands
JohnMcPMS Jun 2, 2024
67c34fb
add history serialization and completion
JohnMcPMS Jun 10, 2024
af85897
e2e tests for winget
JohnMcPMS Jun 11, 2024
e5e6f04
wip: ps cmdlet updates for history
JohnMcPMS Jun 11, 2024
682e69e
finish ps cmdlets and tests
JohnMcPMS Jun 13, 2024
ebf36f3
remove cmdlet
JohnMcPMS Jun 13, 2024
4ee8adb
Move parameters for positional requirements
JohnMcPMS Jun 14, 2024
a6ee1ff
Fix copy-paste comment
JohnMcPMS Jun 20, 2024
c40c77f
Merge from master
JohnMcPMS Jun 20, 2024
21530e0
Fix my bad merge
JohnMcPMS Jun 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
bcp
BEFACEF
BFirst
bght

Check warning on line 43 in .github/actions/spelling/expect.txt

View workflow job for this annotation

GitHub Actions / Check Spelling

entry has inconsistent line ending (unexpected-line-ending)
bigcatalog
BITMAPINFOHEADER
bitspace
Expand Down Expand Up @@ -74,7 +74,8 @@
COINIT
COMGLB
commandline
compressapi
compressapi

Check warning on line 77 in .github/actions/spelling/expect.txt

View workflow job for this annotation

GitHub Actions / Check Spelling

entry has inconsistent line ending (unexpected-line-ending)
concurrencysal
contactsupport
contentfiles
contoso
Expand Down
4 changes: 3 additions & 1 deletion src/AppInstallerCLICore/AppInstallerCLICore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@
<ClInclude Include="Commands\COMCommand.h" />
<ClInclude Include="Commands\CompleteCommand.h" />
<ClInclude Include="Commands\ConfigureCommand.h" />
<ClInclude Include="Commands\ConfigureListCommand.h" />
<ClInclude Include="Commands\ConfigureShowCommand.h" />
<ClInclude Include="Commands\ConfigureTestCommand.h" />
<ClInclude Include="Commands\ConfigureValidateCommand.h" />
Expand Down Expand Up @@ -432,6 +433,7 @@
<ClCompile Include="CheckpointManager.cpp" />
<ClCompile Include="Commands\COMCommand.cpp" />
<ClCompile Include="Commands\ConfigureCommand.cpp" />
<ClCompile Include="Commands\ConfigureListCommand.cpp" />
<ClCompile Include="Commands\ConfigureShowCommand.cpp" />
<ClCompile Include="Commands\ConfigureTestCommand.cpp" />
<ClCompile Include="Commands\ConfigureValidateCommand.cpp" />
Expand Down Expand Up @@ -551,4 +553,4 @@
</Reference>
</ItemGroup>
</Target>
</Project>
</Project>
6 changes: 6 additions & 0 deletions src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@
<ClInclude Include="ConfigureExportCommand.h">
<Filter>Commands</Filter>
</ClInclude>
<ClInclude Include="Commands\ConfigureListCommand.h">
<Filter>Commands</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
Expand Down Expand Up @@ -478,6 +481,9 @@
<ClCompile Include="ConfigureExportCommand.cpp">
<Filter>Commands</Filter>
</ClCompile>
<ClCompile Include="Commands\ConfigureListCommand.cpp">
<Filter>Commands</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="PropertySheet.props" />
Expand Down
6 changes: 5 additions & 1 deletion src/AppInstallerCLICore/Argument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ namespace AppInstaller::CLI

// Configuration commands
case Execution::Args::Type::ConfigurationFile:
return { type, "file"_liv, 'f' };
return { type, "file"_liv, 'f', ArgTypeCategory::ConfigurationSetChoice, ArgTypeExclusiveSet::ConfigurationSetChoice };
case Execution::Args::Type::ConfigurationAcceptWarning:
return { type, "accept-configuration-agreements"_liv };
case Execution::Args::Type::ConfigurationEnable:
Expand All @@ -215,6 +215,10 @@ namespace AppInstaller::CLI
return { type, "module"_liv };
case Execution::Args::Type::ConfigurationExportResource:
return { type, "resource"_liv };
case Execution::Args::Type::ConfigurationHistoryItem:
return { type, "history"_liv, 'h', ArgTypeCategory::ConfigurationSetChoice, ArgTypeExclusiveSet::ConfigurationSetChoice };
case Execution::Args::Type::ConfigurationHistoryRemove:
return { type, "remove"_liv };

// Download command
case Execution::Args::Type::DownloadDirectory:
Expand Down
3 changes: 3 additions & 0 deletions src/AppInstallerCLICore/Argument.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ namespace AppInstaller::CLI
// E.g.: --dependency-source
// E.g.: --accept-source-agreements
ExtendedSource = 0x400,
// Arguments for selecting a configuration set (file or history).
ConfigurationSetChoice = 0x800,
};

DEFINE_ENUM_FLAG_OPERATORS(ArgTypeCategory);
Expand All @@ -87,6 +89,7 @@ namespace AppInstaller::CLI
StubType = 0x10,
Proxy = 0x20,
AllAndTargetVersion = 0x40,
ConfigurationSetChoice = 0x80,

// This must always be at the end
Max
Expand Down
16 changes: 11 additions & 5 deletions src/AppInstallerCLICore/Commands/ConfigureCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.
#include "pch.h"
#include "ConfigureCommand.h"
#include "ConfigureListCommand.h"
#include "ConfigureShowCommand.h"
#include "ConfigureTestCommand.h"
#include "ConfigureValidateCommand.h"
Expand All @@ -24,6 +25,7 @@ namespace AppInstaller::CLI
{
return InitializeFromMoveOnly<std::vector<std::unique_ptr<Command>>>({
std::make_unique<ConfigureShowCommand>(FullName()),
std::make_unique<ConfigureListCommand>(FullName()),
std::make_unique<ConfigureTestCommand>(FullName()),
std::make_unique<ConfigureValidateCommand>(FullName()),
std::make_unique<ConfigureExportCommand>(FullName()),
Expand All @@ -35,6 +37,7 @@ namespace AppInstaller::CLI
return {
Argument{ Execution::Args::Type::ConfigurationFile, Resource::String::ConfigurationFileArgumentDescription, ArgumentType::Positional },
Argument{ Execution::Args::Type::ConfigurationModulePath, Resource::String::ConfigurationModulePath, ArgumentType::Positional },
Argument{ Execution::Args::Type::ConfigurationHistoryItem, Resource::String::ConfigurationHistoryItemArgumentDescription, ArgumentType::Standard, Argument::Visibility::Help },
Argument{ Execution::Args::Type::ConfigurationAcceptWarning, Resource::String::ConfigurationAcceptWarningArgumentDescription, ArgumentType::Flag },
Argument{ Execution::Args::Type::ConfigurationEnable, Resource::String::ConfigurationEnableMessage, ArgumentType::Flag, Argument::Visibility::Help },
Argument{ Execution::Args::Type::ConfigurationDisable, Resource::String::ConfigurationDisableMessage, ArgumentType::Flag, Argument::Visibility::Help },
Expand Down Expand Up @@ -94,12 +97,15 @@ namespace AppInstaller::CLI
}
else
{
if (!execArgs.Contains(Execution::Args::Type::ConfigurationFile))
{
throw CommandException(Resource::String::RequiredArgError("file"_liv));
}
Configuration::ValidateCommonArguments(execArgs, true);
}
}

Configuration::ValidateCommonArguments(execArgs);
void ConfigureCommand::Complete(Execution::Context& context, Execution::Args::Type argType) const
{
if (argType == Execution::Args::Type::ConfigurationHistoryItem)
{
context << CompleteConfigurationHistoryItem;
}
}
}
1 change: 1 addition & 0 deletions src/AppInstallerCLICore/Commands/ConfigureCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ namespace AppInstaller::CLI
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;
};
}
84 changes: 84 additions & 0 deletions src/AppInstallerCLICore/Commands/ConfigureListCommand.cpp
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;
}
}
}
24 changes: 24 additions & 0 deletions src/AppInstallerCLICore/Commands/ConfigureListCommand.h
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;
};
}
13 changes: 11 additions & 2 deletions src/AppInstallerCLICore/Commands/ConfigureShowCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ namespace AppInstaller::CLI
{
return {
// Required for now, make exclusive when history implemented
Argument{ Execution::Args::Type::ConfigurationFile, Resource::String::ConfigurationFileArgumentDescription, ArgumentType::Positional, true },
Argument{ Execution::Args::Type::ConfigurationFile, Resource::String::ConfigurationFileArgumentDescription, ArgumentType::Positional },
Argument{ Execution::Args::Type::ConfigurationModulePath, Resource::String::ConfigurationModulePath, ArgumentType::Positional },
Argument{ Execution::Args::Type::ConfigurationHistoryItem, Resource::String::ConfigurationHistoryItemArgumentDescription, ArgumentType::Standard, Argument::Visibility::Help },
};
}

Expand Down Expand Up @@ -45,6 +46,14 @@ namespace AppInstaller::CLI

void ConfigureShowCommand::ValidateArgumentsInternal(Execution::Args& execArgs) const
{
Configuration::ValidateCommonArguments(execArgs);
Configuration::ValidateCommonArguments(execArgs, true);
}

void ConfigureShowCommand::Complete(Execution::Context& context, Execution::Args::Type argType) const
{
if (argType == Execution::Args::Type::ConfigurationHistoryItem)
{
context << CompleteConfigurationHistoryItem;
}
}
}
1 change: 1 addition & 0 deletions src/AppInstallerCLICore/Commands/ConfigureShowCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ namespace AppInstaller::CLI
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;
};
}
13 changes: 11 additions & 2 deletions src/AppInstallerCLICore/Commands/ConfigureTestCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ namespace AppInstaller::CLI
std::vector<Argument> ConfigureTestCommand::GetArguments() const
{
return {
Argument{ Execution::Args::Type::ConfigurationFile, Resource::String::ConfigurationFileArgumentDescription, ArgumentType::Positional, true },
Argument{ Execution::Args::Type::ConfigurationFile, Resource::String::ConfigurationFileArgumentDescription, ArgumentType::Positional },
Argument{ Execution::Args::Type::ConfigurationModulePath, Resource::String::ConfigurationModulePath, ArgumentType::Positional },
Argument{ Execution::Args::Type::ConfigurationHistoryItem, Resource::String::ConfigurationHistoryItemArgumentDescription, ArgumentType::Standard, Argument::Visibility::Help },
Argument{ Execution::Args::Type::ConfigurationAcceptWarning, Resource::String::ConfigurationAcceptWarningArgumentDescription, ArgumentType::Flag },
};
}
Expand Down Expand Up @@ -48,6 +49,14 @@ namespace AppInstaller::CLI

void ConfigureTestCommand::ValidateArgumentsInternal(Execution::Args& execArgs) const
{
Configuration::ValidateCommonArguments(execArgs);
Configuration::ValidateCommonArguments(execArgs, true);
}

void ConfigureTestCommand::Complete(Execution::Context& context, Execution::Args::Type argType) const
{
if (argType == Execution::Args::Type::ConfigurationHistoryItem)
{
context << CompleteConfigurationHistoryItem;
}
}
}
1 change: 1 addition & 0 deletions src/AppInstallerCLICore/Commands/ConfigureTestCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ namespace AppInstaller::CLI
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;
};
}
8 changes: 7 additions & 1 deletion src/AppInstallerCLICore/ConfigurationCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace AppInstaller::CLI

namespace Configuration
{
void ValidateCommonArguments(Execution::Args& execArgs)
void ValidateCommonArguments(Execution::Args& execArgs, bool requireConfigurationSetChoice)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need requireConfigurationSetChoice? All the callers pass true.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since I made it an optional parameter defaulting to false, I didn't need to update both ConfigureValidateCommand and ConfigureExportCommand, which still call it.

{
auto modulePath = GetModulePathInfo(execArgs);

Expand All @@ -71,6 +71,12 @@ namespace AppInstaller::CLI
throw CommandException(Resource::String::ConfigurationModulePathArgError);
}
}

if (requireConfigurationSetChoice &&
!WI_IsFlagSet(Argument::GetCategoriesPresent(execArgs), ArgTypeCategory::ConfigurationSetChoice))
{
throw CommandException(Resource::String::RequiredArgError("file"_liv));
}
}

void SetModulePath(Execution::Context& context, IConfigurationSetProcessorFactory const& factory)
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/ConfigurationCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace AppInstaller::CLI
namespace Configuration
{
// Validates common arguments between configuration commands.
void ValidateCommonArguments(Execution::Args& execArgs);
void ValidateCommonArguments(Execution::Args& execArgs, bool requireConfigurationSetChoice = false);

// Sets the module path to install modules in the set processor.
void SetModulePath(Execution::Context& context, winrt::Microsoft::Management::Configuration::IConfigurationSetProcessorFactory const& factory);
Expand Down
18 changes: 18 additions & 0 deletions src/AppInstallerCLICore/ConfigurationContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace AppInstaller::CLI::Execution
{
ConfigurationProcessor Processor = nullptr;
ConfigurationSet Set = nullptr;
std::vector<ConfigurationSet> History;
};
}

Expand Down Expand Up @@ -65,4 +66,21 @@ namespace AppInstaller::CLI::Execution
{
m_data->Set = std::move(value);
}

std::vector<ConfigurationSet>& ConfigurationContext::History()
{
return m_data->History;
}

const std::vector<ConfigurationSet>& ConfigurationContext::History() const
{
return m_data->History;
}

void ConfigurationContext::History(const winrt::Windows::Foundation::Collections::IVector<ConfigurationSet>& value)
{
std::vector<ConfigurationSet> history{ value.Size() };
value.GetMany(0, history);
m_data->History = std::move(history);
}
}
Loading
Loading