winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit fc20f3237ad6eec0e2cfb15ee0258ddc2c6e84d6
parent c51083d0ad1400cbfa85eb59b5718f14183b53bc
Author: JohnMcPMS <johnmcp@microsoft.com>
Date:   Mon, 17 May 2021 18:20:31 -0700

Make a lot of experimental things release (#969)

Make `list`, `upgrade`, `uninstall`, and `export` commands no longer experimental.  Also make the REST source implementation not experimental, as well as making Delivery Optimization the default downloader.
Diffstat:
Msrc/AppInstallerCLICore/Commands/ExportCommand.h | 2+-
Msrc/AppInstallerCLICore/Commands/ListCommand.h | 2+-
Msrc/AppInstallerCLICore/Commands/UninstallCommand.h | 2+-
Msrc/AppInstallerCLICore/Commands/UpgradeCommand.h | 2+-
Msrc/AppInstallerCLIE2ETests/FeaturesCommand.cs | 2--
Msrc/AppInstallerCLIE2ETests/ImportCommand.cs | 9---------
Msrc/AppInstallerCLIE2ETests/ListCommand.cs | 13-------------
Msrc/AppInstallerCLIE2ETests/UninstallCommand.cs | 13-------------
Msrc/AppInstallerCLITests/Downloader.cpp | 2+-
Msrc/AppInstallerCommonCore/Downloader.cpp | 23+++++++++++++----------
Msrc/AppInstallerCommonCore/ExperimentalFeature.cpp | 34++++++++--------------------------
Msrc/AppInstallerCommonCore/Public/winget/ExperimentalFeature.h | 13++++---------
Msrc/AppInstallerCommonCore/Public/winget/UserSettings.h | 10----------
Msrc/AppInstallerCommonCore/UserSettings.cpp | 5-----
Msrc/AppInstallerRepositoryCore/RepositorySource.cpp | 18+-----------------
15 files changed, 31 insertions(+), 119 deletions(-)

diff --git a/src/AppInstallerCLICore/Commands/ExportCommand.h b/src/AppInstallerCLICore/Commands/ExportCommand.h @@ -8,7 +8,7 @@ namespace AppInstaller::CLI // Command to get the set of installed packages on the system. struct ExportCommand final : public Command { - ExportCommand(std::string_view parent) : Command("export", parent, Settings::ExperimentalFeature::Feature::ExperimentalExport) {} + ExportCommand(std::string_view parent) : Command("export", parent) {} std::vector<Argument> GetArguments() const override; diff --git a/src/AppInstallerCLICore/Commands/ListCommand.h b/src/AppInstallerCLICore/Commands/ListCommand.h @@ -8,7 +8,7 @@ namespace AppInstaller::CLI // Command to get the set of installed packages on the system. struct ListCommand final : public Command { - ListCommand(std::string_view parent) : Command("list", parent, Settings::ExperimentalFeature::Feature::ExperimentalList) {} + ListCommand(std::string_view parent) : Command("list", parent) {} std::vector<Argument> GetArguments() const override; diff --git a/src/AppInstallerCLICore/Commands/UninstallCommand.h b/src/AppInstallerCLICore/Commands/UninstallCommand.h @@ -7,7 +7,7 @@ namespace AppInstaller::CLI { struct UninstallCommand final : public Command { - UninstallCommand(std::string_view parent) : Command("uninstall", parent, Settings::ExperimentalFeature::Feature::ExperimentalUninstall) {} + UninstallCommand(std::string_view parent) : Command("uninstall", parent) {} std::vector<Argument> GetArguments() const override; diff --git a/src/AppInstallerCLICore/Commands/UpgradeCommand.h b/src/AppInstallerCLICore/Commands/UpgradeCommand.h @@ -7,7 +7,7 @@ namespace AppInstaller::CLI { struct UpgradeCommand final : public Command { - UpgradeCommand(std::string_view parent) : Command("upgrade", parent, Settings::ExperimentalFeature::Feature::ExperimentalUpgrade) {} + UpgradeCommand(std::string_view parent) : Command("upgrade", parent) {} std::vector<Argument> GetArguments() const override; diff --git a/src/AppInstallerCLIE2ETests/FeaturesCommand.cs b/src/AppInstallerCLIE2ETests/FeaturesCommand.cs @@ -28,8 +28,6 @@ namespace AppInstallerCLIE2ETests { var result = TestCommon.RunAICLICommand("features", ""); Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("Command Sample")); - Assert.True(result.StdOut.Contains("Argument Sample")); Assert.True(result.StdOut.Contains("Microsoft Store Support")); Assert.False(result.StdOut.Contains("Enabled")); } diff --git a/src/AppInstallerCLIE2ETests/ImportCommand.cs b/src/AppInstallerCLIE2ETests/ImportCommand.cs @@ -11,17 +11,9 @@ namespace AppInstallerCLIE2ETests [SetUp] public void Setup() { - InitializeAllFeatures(false); - ConfigureFeature("export", true); CleanupTestExe(); } - [TearDown] - public void TearDown() - { - InitializeAllFeatures(false); - } - [Test] public void ImportSuccessful_1_0() { @@ -128,7 +120,6 @@ namespace AppInstallerCLIE2ETests private void UninstallTestExe() { - ConfigureFeature("uninstall", true); TestCommon.RunAICLICommand("uninstall", Constants.ExeInstallerPackageId); } diff --git a/src/AppInstallerCLIE2ETests/ListCommand.cs b/src/AppInstallerCLIE2ETests/ListCommand.cs @@ -7,19 +7,6 @@ namespace AppInstallerCLIE2ETests public class ListCommand : BaseCommand { - [SetUp] - public void Setup() - { - InitializeAllFeatures(false); - ConfigureFeature("list", true); - } - - [TearDown] - public void TearDown() - { - InitializeAllFeatures(false); - } - [Test] public void ListSelf() { diff --git a/src/AppInstallerCLIE2ETests/UninstallCommand.cs b/src/AppInstallerCLIE2ETests/UninstallCommand.cs @@ -20,19 +20,6 @@ namespace AppInstallerCLIE2ETests // Package name of the test MSIX package private const string UninstallTestMsixName = "6c6338fe-41b7-46ca-8ba6-b5ad5312bb0e"; - [OneTimeSetUp] - public void OneTimeSetUp() - { - InitializeAllFeatures(false); - ConfigureFeature("uninstall", true); - } - - [OneTimeTearDown] - public void OneTimeTearDown() - { - InitializeAllFeatures(false); - } - [Test] public void UninstallTestExe() { diff --git a/src/AppInstallerCLITests/Downloader.cpp b/src/AppInstallerCLITests/Downloader.cpp @@ -66,5 +66,5 @@ TEST_CASE("DownloadInvalidUrl", "[Downloader]") ProgressCallback callback; - REQUIRE_THROWS_HR(Download("blargle-flargle-fluff", tempFile.GetPath(), DownloadType::Installer, callback, true), WININET_E_UNRECOGNIZED_SCHEME); + REQUIRE_THROWS(Download("blargle-flargle-fluff", tempFile.GetPath(), DownloadType::Installer, callback, true)); } diff --git a/src/AppInstallerCommonCore/Downloader.cpp b/src/AppInstallerCommonCore/Downloader.cpp @@ -164,18 +164,21 @@ namespace AppInstaller::Utility // Determine whether to try DO first or not, as this is the only choice currently supported. InstallerDownloader setting = User().Get<Setting::NetworkDownloader>(); - // Currently, the default remains WinINet until the DO path is proven. - if (setting == InstallerDownloader::Default) + if (setting == InstallerDownloader::Default || + setting == InstallerDownloader::DeliveryOptimization) { - setting = InstallerDownloader::WinInet; - } - - if (setting == InstallerDownloader::DeliveryOptimization) - { - return DODownload(url, dest, progress, computeHash, info); + auto result = DODownload(url, dest, progress, computeHash, info); + // Since we cannot pre-apply to the file with DO, post-apply the MotW to the file. + // Only do so if the file exists, because cancellation will not throw here. + if (std::filesystem::exists(dest)) + { + ApplyMotwIfApplicable(dest, URLZONE_INTERNET); + } + return result; - // While DO still requires an explicit opt-in, we will let failures through. - // When DO becomes the default, we may choose to catch exceptions and fall back to WinINet below. + // If DO becomes an issue, we may choose to catch exceptions and fall back to WinINet below. + // We would need to be careful not to bypass metered networks or other reasons that might + // intentionally cause the download to be blocked. } } diff --git a/src/AppInstallerCommonCore/ExperimentalFeature.cpp b/src/AppInstallerCommonCore/ExperimentalFeature.cpp @@ -18,6 +18,14 @@ namespace AppInstaller::Settings return true; } + // Even if all experimental features are disabled, if the store policy is enabled then override it. + if (feature == ExperimentalFeature::Feature::ExperimentalMSStore && + GroupPolicies().GetState(TogglePolicy::Policy::MSStoreSource) == PolicyState::Enabled) + { + // Force enable the feature + return true; + } + if (!GroupPolicies().IsEnabled(TogglePolicy::Policy::ExperimentalFeatures)) { AICLI_LOG(Core, Info, << @@ -35,23 +43,7 @@ namespace AppInstaller::Settings case ExperimentalFeature::Feature::ExperimentalArg: return userSettings.Get<Setting::EFExperimentalArg>(); case ExperimentalFeature::Feature::ExperimentalMSStore: - if (GroupPolicies().GetState(TogglePolicy::Policy::MSStoreSource) == PolicyState::Enabled) - { - // Force enable the feature - return true; - } - return userSettings.Get<Setting::EFExperimentalMSStore>(); - case ExperimentalFeature::Feature::ExperimentalList: - return userSettings.Get<Setting::EFList>(); - case ExperimentalFeature::Feature::ExperimentalUpgrade: - return userSettings.Get<Setting::EFExperimentalUpgrade>(); - case ExperimentalFeature::Feature::ExperimentalUninstall: - return userSettings.Get<Setting::EFUninstall>(); - case ExperimentalFeature::Feature::ExperimentalExport: - return userSettings.Get<Setting::EFExport>(); - case ExperimentalFeature::Feature::ExperimentalRestSource: - return userSettings.Get<Setting::EFRestSource>(); default: THROW_HR(E_UNEXPECTED); } @@ -80,16 +72,6 @@ namespace AppInstaller::Settings return ExperimentalFeature{ "Argument Sample", "experimentalArg", "https://aka.ms/winget-settings", Feature::ExperimentalArg }; case Feature::ExperimentalMSStore: return ExperimentalFeature{ "Microsoft Store Support", "experimentalMSStore", "https://aka.ms/winget-settings", Feature::ExperimentalMSStore }; - case Feature::ExperimentalList: - return ExperimentalFeature{ "List Command", "list", "https://aka.ms/winget-settings", Feature::ExperimentalList }; - case Feature::ExperimentalUpgrade: - return ExperimentalFeature{ "Upgrade Command", "upgrade", "https://aka.ms/winget-settings", Feature::ExperimentalUpgrade }; - case Feature::ExperimentalUninstall: - return ExperimentalFeature{ "Uninstall Command", "uninstall", "https://aka.ms/winget-settings", Feature::ExperimentalUninstall }; - case Feature::ExperimentalExport: - return ExperimentalFeature{ "Export Command", "export", "https://aka.ms/winget-settings", Feature::ExperimentalExport }; - case Feature::ExperimentalRestSource: - return ExperimentalFeature{ "Rest Source Support", "restSource", "https://aka.ms/winget-settings", Feature::ExperimentalRestSource }; default: THROW_HR(E_UNEXPECTED); } diff --git a/src/AppInstallerCommonCore/Public/winget/ExperimentalFeature.h b/src/AppInstallerCommonCore/Public/winget/ExperimentalFeature.h @@ -20,18 +20,13 @@ namespace AppInstaller::Settings enum class Feature : unsigned { None = 0x0, - ExperimentalCmd = 0x1, - ExperimentalArg = 0x2, - ExperimentalMSStore = 0x4, - ExperimentalList = 0x8, - ExperimentalUpgrade = 0x10, - ExperimentalUninstall = 0x20, - ExperimentalRestSource = 0x40, + ExperimentalMSStore = 0x1, Max, // This MUST always be after all experimental features // Features listed after Max will not be shown with the features command - // This can be used to hide highly experimental features - ExperimentalExport = 0x100 + // This can be used to hide highly experimental features (or these example ones) + ExperimentalCmd = 0x10000, + ExperimentalArg = 0x20000, }; using Feature_t = std::underlying_type_t<ExperimentalFeature::Feature>; diff --git a/src/AppInstallerCommonCore/Public/winget/UserSettings.h b/src/AppInstallerCommonCore/Public/winget/UserSettings.h @@ -68,12 +68,7 @@ namespace AppInstaller::Settings EFExperimentalCmd, EFExperimentalArg, EFExperimentalMSStore, - EFList, - EFExperimentalUpgrade, - EFUninstall, - EFExport, TelemetryDisable, - EFRestSource, InstallScopePreference, InstallScopeRequirement, NetworkDownloader, @@ -118,12 +113,7 @@ namespace AppInstaller::Settings SETTINGMAPPING_SPECIALIZATION(Setting::EFExperimentalCmd, bool, bool, false, ".experimentalFeatures.experimentalCmd"sv); SETTINGMAPPING_SPECIALIZATION(Setting::EFExperimentalArg, bool, bool, false, ".experimentalFeatures.experimentalArg"sv); SETTINGMAPPING_SPECIALIZATION(Setting::EFExperimentalMSStore, bool, bool, false, ".experimentalFeatures.experimentalMSStore"sv); - SETTINGMAPPING_SPECIALIZATION(Setting::EFList, bool, bool, false, ".experimentalFeatures.list"sv); - SETTINGMAPPING_SPECIALIZATION(Setting::EFExperimentalUpgrade, bool, bool, false, ".experimentalFeatures.upgrade"sv); - SETTINGMAPPING_SPECIALIZATION(Setting::EFUninstall, bool, bool, false, ".experimentalFeatures.uninstall"sv); - SETTINGMAPPING_SPECIALIZATION(Setting::EFExport, bool, bool, false, ".experimentalFeatures.export"sv); SETTINGMAPPING_SPECIALIZATION(Setting::TelemetryDisable, bool, bool, false, ".telemetry.disable"sv); - SETTINGMAPPING_SPECIALIZATION(Setting::EFRestSource, bool, bool, false, ".experimentalFeatures.restSource"sv); SETTINGMAPPING_SPECIALIZATION(Setting::InstallScopePreference, std::string, ScopePreference, ScopePreference::User, ".installBehavior.preferences.scope"sv); SETTINGMAPPING_SPECIALIZATION(Setting::InstallScopeRequirement, std::string, ScopePreference, ScopePreference::None, ".installBehavior.requirements.scope"sv); SETTINGMAPPING_SPECIALIZATION(Setting::NetworkDownloader, std::string, InstallerDownloader, InstallerDownloader::Default, ".network.downloader"sv); diff --git a/src/AppInstallerCommonCore/UserSettings.cpp b/src/AppInstallerCommonCore/UserSettings.cpp @@ -225,12 +225,7 @@ namespace AppInstaller::Settings WINGET_VALIDATE_PASS_THROUGH(EFExperimentalCmd) WINGET_VALIDATE_PASS_THROUGH(EFExperimentalArg) WINGET_VALIDATE_PASS_THROUGH(EFExperimentalMSStore) - WINGET_VALIDATE_PASS_THROUGH(EFList) - WINGET_VALIDATE_PASS_THROUGH(EFExperimentalUpgrade) - WINGET_VALIDATE_PASS_THROUGH(EFUninstall) - WINGET_VALIDATE_PASS_THROUGH(EFExport) WINGET_VALIDATE_PASS_THROUGH(TelemetryDisable) - WINGET_VALIDATE_PASS_THROUGH(EFRestSource) WINGET_VALIDATE_SIGNATURE(InstallScopePreference) { diff --git a/src/AppInstallerRepositoryCore/RepositorySource.cpp b/src/AppInstallerRepositoryCore/RepositorySource.cpp @@ -438,12 +438,6 @@ namespace AppInstaller::Repository for (auto& source : userSources) { - if (Utility::CaseInsensitiveEquals(Rest::RestSourceFactory::Type(), source.Type) - && !Settings::ExperimentalFeature::IsEnabled(Settings::ExperimentalFeature::Feature::ExperimentalRestSource)) - { - continue; - } - // Check source against list of allowed sources and drop tombstones for required sources if (!IsUserSourceAllowedByPolicy(source.Name, source.Type, source.Arg, source.IsTombstone)) { @@ -582,8 +576,7 @@ namespace AppInstaller::Repository { return Microsoft::PredefinedInstalledSourceFactory::Create(); } - else if (Utility::CaseInsensitiveEquals(Rest::RestSourceFactory::Type(), type) - && Settings::ExperimentalFeature::IsEnabled(Settings::ExperimentalFeature::Feature::ExperimentalRestSource)) + else if (Utility::CaseInsensitiveEquals(Rest::RestSourceFactory::Type(), type)) { return Rest::RestSourceFactory::Create(); } @@ -880,15 +873,6 @@ namespace AppInstaller::Repository details.LastUpdateTime = Utility::ConvertUnixEpochToSystemClock(0); details.Origin = SourceOrigin::User; - // Check feature flag enablement for rest source. - if (Utility::CaseInsensitiveEquals(Rest::RestSourceFactory::Type(), type) - && !Settings::ExperimentalFeature::IsEnabled(Settings::ExperimentalFeature::Feature::ExperimentalRestSource)) - { - AICLI_LOG(Repo, Error, << Settings::ExperimentalFeature::GetFeature(Settings::ExperimentalFeature::Feature::ExperimentalRestSource).Name() - << " feature is disabled. Execution cancelled."); - THROW_HR(APPINSTALLER_CLI_ERROR_EXPERIMENTAL_FEATURE_DISABLED); - } - AddSourceFromDetails(details, progress); AICLI_LOG(Repo, Info, << "Source created with extra data: " << details.Data);