Skip to content

Commit

Permalink
fix name and add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ryfu-msft committed Nov 15, 2024
1 parent 4396784 commit 7923d82
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 12 deletions.
15 changes: 15 additions & 0 deletions doc/Settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,21 @@ The `purgePortablePackage` behavior affects the default behavior for uninstallin
},
```

## Configure Behavior

The `configureBehavior` settings affect the default behavior of applying a configuration.

### Default Module Root
The `defaultModuleRoot` behavior affects the default root directory where modules are installed to. Defaults to `%LOCALAPPDATA%/Microsoft/WinGet/Configuration/Modules` if value is not set or is invalid.

> Note: This setting value must be an absolute path.
```json
"configureBehavior": {
"defaultModuleRoot": "C:/Program Files/Modules/"
},
```

## Telemetry

The `telemetry` settings control whether winget writes ETW events that may be sent to Microsoft on a default installation of Windows.
Expand Down
6 changes: 3 additions & 3 deletions schemas/JSON/settings/settings.schema.0.2.json
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@
}
}
},
"ConfigurationBehavior": {
"description": "Configuration settings",
"ConfigureBehavior": {
"description": "Configure settings",
"type": "object",
"properties": {
"defaultModuleRoot": {
Expand All @@ -208,7 +208,7 @@
"maxLength": 32767
}
}
}
},
"DownloadBehavior": {
"description": "Download settings",
"type": "object",
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/ConfigurationCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace AppInstaller::CLI
}
}

std::filesystem::path defaultModuleRoot = Settings::User().Get<Settings::Setting::ConfigurationDefaultModuleRoot>();
std::filesystem::path defaultModuleRoot = Settings::User().Get<Settings::Setting::ConfigureDefaultModuleRoot>();

if (!defaultModuleRoot.empty())
{
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLIE2ETests/ConfigureCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void ConfigureFromTestRepo_SettingsDefaultModuleRoot()
TestCommon.EnsureModuleState(Constants.SimpleTestModuleName, present: false);

string moduleTestDir = TestCommon.GetRandomTestDir();
WinGetSettingsHelper.ConfigureConfigurationBehavior(Constants.DefaultModuleRoot, moduleTestDir);
WinGetSettingsHelper.ConfigureConfigureBehavior(Constants.DefaultModuleRoot, moduleTestDir);

string args = TestCommon.GetTestDataFile("Configuration\\Configure_TestRepo_Location.yml");
var result = TestCommon.RunAICLICommand(CommandAndAgreementsAndVerbose, args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public static void ConfigureInstallBehavior(string settingName, string value)
/// </summary>
/// <param name="settingName">Setting name.</param>
/// <param name="value">Setting value.</param>
public static void ConfigureConfigurationBehavior(string settingName, string value)
public static void ConfigureConfigureBehavior(string settingName, string value)
{
JObject settingsJson = GetJsonSettingsObject("configureBehavior");
var configureBehavior = settingsJson["configureBehavior"];
Expand Down
6 changes: 3 additions & 3 deletions src/AppInstallerCLITests/UserSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,17 +526,17 @@ TEST_CASE("SettingsDownloadDefaultDirectory", "[settings]")
}
}

TEST_CASE("SettingsConfigurationDefaultModuleRoot", "[settings]")
TEST_CASE("SettingsConfigureDefaultModuleRoot", "[settings]")
{
auto again = DeleteUserSettingsFiles();

SECTION("Valid path")
{
std::string_view json = R"({ "configurationBehavior": { "defaultModuleRoot": "C:/Foo/Bar" } })";
std::string_view json = R"({ "configureBehavior": { "defaultModuleRoot": "C:/Foo/Bar" } })";
SetSetting(Stream::PrimaryUserSettings, json);
UserSettingsTest userSettingTest;

REQUIRE(userSettingTest.Get<Setting::ConfigurationDefaultModuleRoot>() == "C:/Foo/Bar");
REQUIRE(userSettingTest.Get<Setting::ConfigureDefaultModuleRoot>() == "C:/Foo/Bar");
REQUIRE(userSettingTest.GetWarnings().size() == 0);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/AppInstallerCommonCore/Public/winget/UserSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ namespace AppInstaller::Settings
// Download behavior
DownloadDefaultDirectory,
// Configuration behavior
ConfigurationDefaultModuleRoot,
ConfigureDefaultModuleRoot,
// Interactivity
InteractivityDisable,
#ifndef AICLI_DISABLE_TEST_HOOKS
Expand Down Expand Up @@ -188,7 +188,7 @@ namespace AppInstaller::Settings
// Download behavior
SETTINGMAPPING_SPECIALIZATION(Setting::DownloadDefaultDirectory, std::string, std::filesystem::path, {}, ".downloadBehavior.defaultDownloadDirectory"sv);
// Configuration behavior
SETTINGMAPPING_SPECIALIZATION(Setting::ConfigurationDefaultModuleRoot, std::string, std::filesystem::path, {}, ".configurationBehavior.defaultModuleRoot"sv);
SETTINGMAPPING_SPECIALIZATION(Setting::ConfigureDefaultModuleRoot, std::string, std::filesystem::path, {}, ".configureBehavior.defaultModuleRoot"sv);

// Network
SETTINGMAPPING_SPECIALIZATION(Setting::NetworkDownloader, std::string, InstallerDownloader, InstallerDownloader::Default, ".network.downloader"sv);
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCommonCore/UserSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ namespace AppInstaller::Settings
return ValidatePathValue(value);
}

WINGET_VALIDATE_SIGNATURE(ConfigurationDefaultModuleRoot)
WINGET_VALIDATE_SIGNATURE(ConfigureDefaultModuleRoot)
{
return ValidatePathValue(value);
}
Expand Down

0 comments on commit 7923d82

Please sign in to comment.