From 31545552000f9a26963ca250e03a23fa4ace1a64 Mon Sep 17 00:00:00 2001 From: Rain Sallow Date: Wed, 15 Mar 2023 11:10:15 -0400 Subject: [PATCH] (#2980) Remove webpi source runner This has been non functional for quite some time and is deprecated. Removing it for 2.0. Updated end to end tests as well, and removed a reference to it in the GenerateDocs.ps1 file. --- GenerateDocs.ps1 | 2 +- .../chocolatey/chocolatey/chocolatey.nuspec | 1 - .../commands/ChocolateyListCommandSpecs.cs | 25 -- src/chocolatey/chocolatey.csproj | 1 - .../commands/ChocolateyInfoCommand.cs | 2 +- .../commands/ChocolateyInstallCommand.cs | 10 +- .../commands/ChocolateyListCommand.cs | 11 +- .../commands/ChocolateyOutdatedCommand.cs | 2 +- .../commands/ChocolateyUninstallCommand.cs | 2 +- .../commands/ChocolateyUpgradeCommand.cs | 2 +- .../infrastructure.app/domain/SourceType.cs | 2 - .../infrastructure.app/domain/SourceTypes.cs | 7 - .../ChocolateyRegistrationModule.cs | 1 - .../services/WebPiService.cs | 317 ------------------ .../commands/choco-list.Tests.ps1 | 12 - .../commands/choco-removed.Tests.ps1 | 15 + 16 files changed, 22 insertions(+), 390 deletions(-) delete mode 100644 src/chocolatey/infrastructure.app/services/WebPiService.cs diff --git a/GenerateDocs.ps1 b/GenerateDocs.ps1 index d092978b2..f4c12f97c 100644 --- a/GenerateDocs.ps1 +++ b/GenerateDocs.ps1 @@ -230,7 +230,7 @@ function Convert-CommandText { $commandText = $commandText -creplace '^(.+)(\s+Command\s*)$', "# `$1`$2 (choco $commandName)" $commandText = $commandText -creplace '^(DEPRECATION NOTICE|Usage|Troubleshooting|Examples|Exit Codes|Connecting to Chocolatey.org|See It In Action|Alternative Sources|Resources|Packages.config|Scripting \/ Integration - Best Practices \/ Style Guide)', '## $1' $commandText = $commandText -replace '^(Commands|How To Pass Options)', '## $1' - $commandText = $commandText -replace '^(WebPI|Windows Features|Ruby|Cygwin|Python)\s*$', '### $1' + $commandText = $commandText -replace '^(Windows Features|Ruby|Cygwin|Python)\s*$', '### $1' $commandText = $commandText -replace '(? :choco-info: **NOTE**' $commandText = $commandText -replace '\*> :choco-info: \*\*NOTE\*\*\*', '> :choco-info: **NOTE**' $commandText = $commandText -replace 'the command reference', '[how to pass arguments](xref:choco-commands#how-to-pass-options-switches)' diff --git a/nuspec/chocolatey/chocolatey/chocolatey.nuspec b/nuspec/chocolatey/chocolatey/chocolatey.nuspec index 2508a2a6b..4c14e90a8 100644 --- a/nuspec/chocolatey/chocolatey/chocolatey.nuspec +++ b/nuspec/chocolatey/chocolatey/chocolatey.nuspec @@ -68,7 +68,6 @@ There are quite a few commands you can call - you should check out the [command - Install ruby gem - choco install compass -source ruby - Install python egg - choco install sphynx -source python - Install windows feature - choco install IIS -source windowsfeatures -- Install webpi feature - choco install IIS7.5Express -source webpi #### More diff --git a/src/chocolatey.tests/infrastructure.app/commands/ChocolateyListCommandSpecs.cs b/src/chocolatey.tests/infrastructure.app/commands/ChocolateyListCommandSpecs.cs index 195c80e0d..4b1ee9705 100644 --- a/src/chocolatey.tests/infrastructure.app/commands/ChocolateyListCommandSpecs.cs +++ b/src/chocolatey.tests/infrastructure.app/commands/ChocolateyListCommandSpecs.cs @@ -525,12 +525,6 @@ public void should_output_removal_in_v2_0_0() MockLogger.Messages.Keys.ShouldContain("Warn"); MockLogger.Messages["Warn"].ShouldContain(@" Will be removed for the list command in v2.0.0."); - MockLogger.Messages["Warn"].ShouldContain(@" -The `webpi` source is deprecated and will be removed in Chocolatey v2.0.0. - The WebPI feed provided by Microsoft was retired on December 31st, 2022. For - more information, see the IIS team's blog post: - https://blogs.iis.net/iisteam/web-platform-installer-end-of-support-feed -"); } } @@ -547,25 +541,6 @@ public override void Because() { command.help_message(configuration); } - - [Fact, Obsolete("Will be removed in v2.0.0")] - public void should_output_deprecation_notice_header() - { - MockLogger.Messages.Keys.ShouldContain("Warn"); - MockLogger.Messages["Warn"].ShouldContain("DEPRECATION NOTICE"); - } - - [Fact] - public void should_ouput_webpi_removal_in_v2_0_0() - { - MockLogger.Messages.Keys.ShouldContain("Warn"); - MockLogger.Messages["Warn"].ShouldContain(@" -The `webpi` source is deprecated and will be removed in Chocolatey v2.0.0. - The WebPI feed provided by Microsoft was retired on December 31st, 2022. For - more information, see the IIS team's blog post: - https://blogs.iis.net/iisteam/web-platform-installer-end-of-support-feed -"); - } } } } diff --git a/src/chocolatey/chocolatey.csproj b/src/chocolatey/chocolatey.csproj index d93b60094..187318e9d 100644 --- a/src/chocolatey/chocolatey.csproj +++ b/src/chocolatey/chocolatey.csproj @@ -366,7 +366,6 @@ - diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyInfoCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyInfoCommand.cs index de65dc3c0..19e43215f 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyInfoCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyInfoCommand.cs @@ -36,7 +36,7 @@ public override void configure_argument_parser(OptionSet optionSet, ChocolateyCo optionSet .Add( "s=|source=", - "Source - Source location for install. Can use special 'webpi' or 'windowsfeatures' sources. Defaults to sources.", + "Source - Source location for install. Can use special 'windowsfeatures', 'ruby', 'cygwin', or 'python' sources. Defaults to configured sources.", option => configuration.Sources = option.remove_surrounding_quotes()) .Add( "l|lo|localonly|local-only", diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyInstallCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyInstallCommand.cs index 5adc01b4a..7897de876 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyInstallCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyInstallCommand.cs @@ -40,7 +40,7 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon { optionSet .Add("s=|source=", - "Source - The source to find the package(s) to install. Special sources include: ruby, webpi, cygwin, windowsfeatures, and python. To specify more than one source, pass it with a semi-colon separating the values (e.g. \"'source1;source2'\"). Defaults to default feeds.", + "Source - The source to find the package(s) to install. Special sources include: ruby, cygwin, windowsfeatures, and python. To specify more than one source, pass it with a semi-colon separating the values (e.g. \"'source1;source2'\"). Defaults to default feeds.", option => configuration.Sources = option.remove_surrounding_quotes()) .Add("version=", "Version - A specific version to install. Defaults to unspecified.", @@ -263,7 +263,6 @@ Side by side installations has been deprecated and will be removed in v2.0.0. Instead of using side by side installations, distinct packages should be created if similar functionality is needed going forward. "); - "chocolatey".Log().Warn(WebPiService.DeprecationMessage); "chocolatey".Log().Info(ChocolateyLoggers.Important, "Usage"); "chocolatey".Log().Info(@" @@ -398,13 +397,6 @@ This specifies the source is Ruby Gems and that we are installing a the command will install that first. e.g. `choco install compass -source ruby` -WebPI (DEPRECATED) -This specifies the source is Web PI (Web Platform Installer) and that - we are installing a WebPI product, such as IISExpress. If you do not - have the Web PI command line installed, it will install that first and - then the product requested. - e.g. `choco install IISExpress --source webpi` - Cygwin This specifies the source is Cygwin and that we are installing a cygwin package, such as bash. If you do not have Cygwin installed, it will diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyListCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyListCommand.cs index 404600061..8fb0bbc06 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyListCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyListCommand.cs @@ -50,7 +50,7 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon optionSet .Add("s=|source=", - "Source - Source location for install. Can use special 'webpi' or 'windowsfeatures' sources. Defaults to sources." + deprecationNotice, + "Source - Source location for install. Can use special 'windowsfeatures', 'ruby', 'cygwin', or 'python' sources. Defaults to sources." + deprecationNotice, option => configuration.Sources = option.remove_surrounding_quotes()) .Add("l|lo|local|localonly|local-only", localOnlyDescription, @@ -205,8 +205,6 @@ use the full command going forward (`choco list`). "); } - "chocolatey".Log().Warn(WebPiService.DeprecationMessage); - "chocolatey".Log().Info(ChocolateyLoggers.Important, "Examples"); "chocolatey".Log().Info(@" choco list --local-only (DEPRECATED: will be default for list in v2.0.0) @@ -261,13 +259,6 @@ file a ticket so we can document it at "chocolatey".Log().Info(@" Available in 0.9.10+. -WebPI (DEPRECATED) -This specifies the source is Web PI (Web Platform Installer) and that - we are searching for a WebPI product, such as IISExpress. If you do - not have the Web PI command line installed, it will install that first - and then perform the search requested. - e.g. `choco {0} --source webpi` - Windows Features This specifies that the source is a Windows Feature and we should install via the Deployment Image Servicing and Management tool (DISM) diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyOutdatedCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyOutdatedCommand.cs index 750fef418..6b125f7c7 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyOutdatedCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyOutdatedCommand.cs @@ -38,7 +38,7 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon { optionSet .Add("s=|source=", - "Source - The source to find the package(s) to install. Special sources include: ruby, webpi, cygwin, windowsfeatures, and python. To specify more than one source, pass it with a semi-colon separating the values (e.g. \"'source1;source2'\"). Defaults to default feeds.", + "Source - The source to find the package(s) to install. Special sources include: ruby, cygwin, windowsfeatures, and python. To specify more than one source, pass it with a semi-colon separating the values (e.g. \"'source1;source2'\"). Defaults to default feeds.", option => configuration.Sources = option.remove_surrounding_quotes()) .Add("u=|user=", "User - used with authenticated feeds. Defaults to empty.", diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyUninstallCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyUninstallCommand.cs index 130b2a3f5..50835e0a0 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyUninstallCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyUninstallCommand.cs @@ -40,7 +40,7 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon { optionSet .Add("s=|source=", - "Source - The source to find the package(s) to install. Special sources include: ruby, webpi, cygwin, windowsfeatures, and python. Defaults to default feeds.", + "Source - The source to find the package(s) to install. Special sources include: ruby, cygwin, windowsfeatures, and python. Defaults to default feeds.", option => configuration.Sources = option.remove_surrounding_quotes()) .Add("version=", "Version - A specific version to uninstall. Defaults to unspecified.", diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyUpgradeCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyUpgradeCommand.cs index 6accfe233..592f6cacc 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyUpgradeCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyUpgradeCommand.cs @@ -40,7 +40,7 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon { optionSet .Add("s=|source=", - "Source - The source to find the package(s) to install. Special sources include: ruby, webpi, cygwin, windowsfeatures, and python. To specify more than one source, pass it with a semi-colon separating the values (e.g. \"'source1;source2'\"). Defaults to default feeds.", + "Source - The source to find the package(s) to install. Special sources include: ruby, cygwin, windowsfeatures, and python. To specify more than one source, pass it with a semi-colon separating the values (e.g. \"'source1;source2'\"). Defaults to default feeds.", option => configuration.Sources = option.remove_surrounding_quotes()) .Add("version=", "Version - A specific version to install. Defaults to unspecified.", diff --git a/src/chocolatey/infrastructure.app/domain/SourceType.cs b/src/chocolatey/infrastructure.app/domain/SourceType.cs index b5b6bfa6c..66dc5af68 100644 --- a/src/chocolatey/infrastructure.app/domain/SourceType.cs +++ b/src/chocolatey/infrastructure.app/domain/SourceType.cs @@ -26,8 +26,6 @@ public enum SourceType { //this is what it should be when it's not set normal, - [Obsolete("The WebPI service has been retired, and this source type will be removed in v2.0.0 of Chocolatey.")] - webpi, ruby, python, windowsfeature, diff --git a/src/chocolatey/infrastructure.app/domain/SourceTypes.cs b/src/chocolatey/infrastructure.app/domain/SourceTypes.cs index fead1483a..fcbaf44b7 100644 --- a/src/chocolatey/infrastructure.app/domain/SourceTypes.cs +++ b/src/chocolatey/infrastructure.app/domain/SourceTypes.cs @@ -48,13 +48,6 @@ public static class SourceTypes /// public const string RUBY = "ruby"; - /// - /// The source is of type Web PI and need to be handled by an - /// alternative source runner. - /// - [Obsolete("The WebPI service has been retired, and this source type will be removed in v2.0.0 of Chocolatey.")] - public const string WEBPI = "webpi"; - /// /// The source is a windows feature and is only provided as an /// alias for diff --git a/src/chocolatey/infrastructure.app/registration/ChocolateyRegistrationModule.cs b/src/chocolatey/infrastructure.app/registration/ChocolateyRegistrationModule.cs index cb5bf168b..5d293ced5 100644 --- a/src/chocolatey/infrastructure.app/registration/ChocolateyRegistrationModule.cs +++ b/src/chocolatey/infrastructure.app/registration/ChocolateyRegistrationModule.cs @@ -67,7 +67,6 @@ public void register_dependencies(IContainerRegistrator registrator, ChocolateyC registrator.register_service( typeof(INugetService), - typeof(WebPiService), typeof(WindowsFeatureService), typeof(CygwinService), typeof(PythonService), diff --git a/src/chocolatey/infrastructure.app/services/WebPiService.cs b/src/chocolatey/infrastructure.app/services/WebPiService.cs deleted file mode 100644 index 582a0f328..000000000 --- a/src/chocolatey/infrastructure.app/services/WebPiService.cs +++ /dev/null @@ -1,317 +0,0 @@ -// Copyright © 2017 - 2022 Chocolatey Software, Inc -// Copyright © 2011 - 2017 RealDimensions Software, LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -namespace chocolatey.infrastructure.app.services -{ - using System; - using System.Collections.Concurrent; - using System.Collections.Generic; - using System.Linq; - using System.Text.RegularExpressions; - using configuration; - using domain; - using infrastructure.commands; - using logging; - using results; - using platforms; - - [Obsolete("The WebPI service has been retired, and this source type will be removed in v2.0.0 of Chocolatey.")] - public sealed class WebPiService : ISourceRunner - { - private readonly ICommandExecutor _commandExecutor; - private readonly INugetService _nugetService; - private const string PACKAGE_NAME_TOKEN = "{{packagename}}"; - private const string EXE_PATH = "webpicmd.exe"; - private const string APP_NAME = "Web Platform Installer"; - public const string WEB_PI_PACKAGE = "webpicmd"; - public const string PACKAGE_NAME_GROUP = "PkgName"; - public static readonly Regex InstallingRegex = new Regex(@"Started installing:", RegexOptions.Compiled); - public static readonly Regex InstalledRegex = new Regex(@"Install completed \(Success\):", RegexOptions.Compiled); - public static readonly Regex AlreadyInstalledRegex = new Regex(@"No products to be installed \(either not available or already installed\)", RegexOptions.Compiled); - - //public static readonly Regex NotInstalled = new Regex(@"not installed", RegexOptions.Compiled); - public static readonly Regex PackageNameRegex = new Regex(@"'(?<{0}>[^']*)'".format_with(PACKAGE_NAME_GROUP), RegexOptions.Compiled); - - private readonly IDictionary _listArguments = new Dictionary(StringComparer.InvariantCultureIgnoreCase); - private readonly IDictionary _installArguments = new Dictionary(StringComparer.InvariantCultureIgnoreCase); - - public WebPiService(ICommandExecutor commandExecutor, INugetService nugetService) - { - _commandExecutor = commandExecutor; - _nugetService = nugetService; - set_cmd_args_dictionaries(); - } - - /// - /// Set any command arguments dictionaries necessary for the service - /// - private void set_cmd_args_dictionaries() - { - set_list_dictionary(_listArguments); - set_install_dictionary(_installArguments); - } - - /// - /// Sets list dictionary - /// - private void set_list_dictionary(IDictionary args) - { - args.Add("_action_", new ExternalCommandArgument { ArgumentOption = "/List", Required = true }); - args.Add("_list_option_", new ExternalCommandArgument { ArgumentOption = "/ListOption:All", Required = true }); - } - - /// - /// Sets install dictionary - /// - private void set_install_dictionary(IDictionary args) - { - args.Add("_action_", new ExternalCommandArgument { ArgumentOption = "/Install", Required = true }); - args.Add("_accept_eula_", new ExternalCommandArgument { ArgumentOption = "/AcceptEula", Required = true }); - args.Add("_suppress_reboot_", new ExternalCommandArgument { ArgumentOption = "/SuppressReboot", Required = true }); - args.Add("_package_name_", new ExternalCommandArgument - { - ArgumentOption = "/Products:", - ArgumentValue = PACKAGE_NAME_TOKEN, - QuoteValue = false, - Required = true - }); - } - - public string SourceType - { - get { return SourceTypes.WEBPI; } - } - - public void ensure_source_app_installed(ChocolateyConfiguration config, Action ensureAction) - { - if (Platform.get_platform() != PlatformType.Windows) throw new NotImplementedException("This source is not supported on non-Windows systems"); - - var runnerConfig = new ChocolateyConfiguration - { - PackageNames = WEB_PI_PACKAGE, - Sources = ApplicationParameters.PackagesLocation, - Debug = config.Debug, - Force = config.Force, - Verbose = config.Verbose, - CommandExecutionTimeoutSeconds = config.CommandExecutionTimeoutSeconds, - CacheLocation = config.CacheLocation, - RegularOutput = config.RegularOutput, - PromptForConfirmation = false, - AcceptLicense = true, - QuietOutput = true, - }; - runnerConfig.ListCommand.LocalOnly = true; - - var localPackages = _nugetService.list_run(runnerConfig); - - if (!localPackages.Any(p => p.Name.is_equal_to(WEB_PI_PACKAGE))) - { - runnerConfig.Sources = ApplicationParameters.ChocolateyCommunityFeedSource; - - var prompt = config.PromptForConfirmation; - config.PromptForConfirmation = false; - _nugetService.install_run(runnerConfig, ensureAction.Invoke); - config.PromptForConfirmation = prompt; - } - } - - internal const string DeprecationMessage = @" -The `webpi` source is deprecated and will be removed in Chocolatey v2.0.0. - The WebPI feed provided by Microsoft was retired on December 31st, 2022. For - more information, see the IIS team's blog post: - https://blogs.iis.net/iisteam/web-platform-installer-end-of-support-feed -"; - - private void write_deprecation_warning() - { - this.Log().Warn(ChocolateyLoggers.Important, "DEPRECATION WARNING"); - this.Log().Warn(DeprecationMessage); - } - - public int count_run(ChocolateyConfiguration config) - { - throw new NotImplementedException("Count is not supported for this source runner."); - } - - public void list_noop(ChocolateyConfiguration config) - { - write_deprecation_warning(); - var args = ExternalCommandArgsBuilder.build_arguments(config, _listArguments); - this.Log().Info("Would have run '{0} {1}'".format_with(EXE_PATH.escape_curly_braces(), args.escape_curly_braces())); - } - - public IEnumerable list_run(ChocolateyConfiguration config) - { - write_deprecation_warning(); - var packageResults = new List(); - var args = ExternalCommandArgsBuilder.build_arguments(config, _listArguments); - - //var whereToStartRecording = "---"; - //var whereToStopRecording = "--"; - //var recordingValues = false; - - Environment.ExitCode = _commandExecutor.execute( - EXE_PATH, - args, - config.CommandExecutionTimeoutSeconds, - workingDirectory: ApplicationParameters.ShimsLocation, - stdOutAction: (s, e) => - { - var logMessage = e.Data; - if (string.IsNullOrWhiteSpace(logMessage)) return; - if (!config.QuietOutput) - { - this.Log().Info(logMessage.escape_curly_braces()); - } - else - { - this.Log().Debug(() => "[{0}] {1}".format_with(APP_NAME, logMessage.escape_curly_braces())); - } - - //if (recordingValues) - //{ - // var lineParts = logMessage.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); - // if (lineParts.Length > 1) - // { - // var pkgResult = new PackageResult(lineParts[0], null, null); - // packageResults.GetOrAdd(lineParts[0], pkgResult); - // } - //} - - //if (logMessage.Contains(whereToStartRecording)) recordingValues = true; - }, - stdErrAction: (s, e) => - { - if (string.IsNullOrWhiteSpace(e.Data)) return; - this.Log().Error(() => "{0}".format_with(e.Data.escape_curly_braces())); - }, - updateProcessPath: false, - allowUseWindow: true - ); - - return packageResults; - } - - public void install_noop(ChocolateyConfiguration config, Action continueAction) - { - write_deprecation_warning(); - var args = ExternalCommandArgsBuilder.build_arguments(config, _installArguments); - args = args.Replace(PACKAGE_NAME_TOKEN, config.PackageNames.Replace(';', ',')); - this.Log().Info("Would have run '{0} {1}'".format_with(EXE_PATH.escape_curly_braces(), args.escape_curly_braces())); - } - - public ConcurrentDictionary install_run(ChocolateyConfiguration config, Action continueAction) - { - write_deprecation_warning(); - var packageResults = new ConcurrentDictionary(StringComparer.InvariantCultureIgnoreCase); - var args = ExternalCommandArgsBuilder.build_arguments(config, _installArguments); - - foreach (var packageToInstall in config.PackageNames.Split(new[] { ApplicationParameters.PackageNamesSeparator }, StringSplitOptions.RemoveEmptyEntries)) - { - var argsForPackage = args.Replace(PACKAGE_NAME_TOKEN, packageToInstall); - var exitCode = _commandExecutor.execute( - EXE_PATH, - argsForPackage, - config.CommandExecutionTimeoutSeconds, - ApplicationParameters.ShimsLocation, - (s, e) => - { - var logMessage = e.Data; - if (string.IsNullOrWhiteSpace(logMessage)) return; - this.Log().Info(() => " [{0}] {1}".format_with(APP_NAME, logMessage.escape_curly_braces())); - - var packageName = get_value_from_output(logMessage, PackageNameRegex, PACKAGE_NAME_GROUP); - var results = packageResults.GetOrAdd(packageName, new PackageResult(packageName, null, null)); - if (AlreadyInstalledRegex.IsMatch(logMessage)) - { - results.Messages.Add(new ResultMessage(ResultType.Inconclusive, packageName)); - this.Log().Warn(ChocolateyLoggers.Important, " [{0}] {1} already installed or doesn't exist. --force has no effect.".format_with(APP_NAME, string.IsNullOrWhiteSpace(packageName) ? packageToInstall : packageName)); - return; - } - - if (InstallingRegex.IsMatch(logMessage)) - { - this.Log().Info(ChocolateyLoggers.Important, "{0}".format_with(packageName)); - return; - } - - if (InstalledRegex.IsMatch(logMessage)) - { - this.Log().Info(ChocolateyLoggers.Important, " {0} has been installed successfully.".format_with(string.IsNullOrWhiteSpace(packageName) ? packageToInstall : packageName)); - } - }, - (s, e) => - { - if (string.IsNullOrWhiteSpace(e.Data)) return; - this.Log().Error(() => "[{0}] {1}".format_with(APP_NAME, e.Data.escape_curly_braces())); - }, - updateProcessPath: false, - allowUseWindow: true - ); - - if (exitCode != 0) - { - Environment.ExitCode = exitCode; - } - } - - return packageResults; - } - - public ConcurrentDictionary upgrade_noop(ChocolateyConfiguration config, Action continueAction) - { - write_deprecation_warning(); - this.Log().Warn(ChocolateyLoggers.Important, "{0} does not implement upgrade".format_with(APP_NAME)); - return new ConcurrentDictionary(StringComparer.InvariantCultureIgnoreCase); - } - - public ConcurrentDictionary upgrade_run(ChocolateyConfiguration config, Action continueAction, Action beforeUpgradeAction = null) - { - write_deprecation_warning(); - throw new NotImplementedException("{0} does not implement upgrade".format_with(APP_NAME)); - } - - public void uninstall_noop(ChocolateyConfiguration config, Action continueAction) - { - write_deprecation_warning(); - this.Log().Warn(ChocolateyLoggers.Important, "{0} does not implement uninstall".format_with(APP_NAME)); - } - - public ConcurrentDictionary uninstall_run(ChocolateyConfiguration config, Action continueAction, Action beforeUninstallAction = null) - { - write_deprecation_warning(); - throw new NotImplementedException("{0} does not implement uninstall".format_with(APP_NAME)); - } - - /// - /// Grabs a value from the output based on the regex. - /// - /// The output. - /// The regex. - /// Name of the group. - /// - private static string get_value_from_output(string output, Regex regex, string groupName) - { - var matchGroup = regex.Match(output).Groups[groupName]; - if (matchGroup != null) - { - return matchGroup.Value; - } - - return string.Empty; - } - } -} diff --git a/tests/chocolatey-tests/commands/choco-list.Tests.ps1 b/tests/chocolatey-tests/commands/choco-list.Tests.ps1 index c53b5f048..7f967804d 100644 --- a/tests/chocolatey-tests/commands/choco-list.Tests.ps1 +++ b/tests/chocolatey-tests/commands/choco-list.Tests.ps1 @@ -394,18 +394,6 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, ListCommand, SearchComma } } - Context "WebPI source should show a deprecation message" { - BeforeAll { - Restore-ChocolateyInstallSnapshot - - $Output = Invoke-Choco $_ --source=webpi - } - - It "Should show the deprecation warning" { - $Output.Lines | Should -Contain 'The `webpi` source is deprecated and will be removed in Chocolatey v2.0.0.' -Because $Output.String - } - } - Context "Searching for older stable version" { BeforeAll { Restore-ChocolateyInstallSnapshot -Quick diff --git a/tests/chocolatey-tests/commands/choco-removed.Tests.ps1 b/tests/chocolatey-tests/commands/choco-removed.Tests.ps1 index adf902c8f..2c5741f9e 100644 --- a/tests/chocolatey-tests/commands/choco-removed.Tests.ps1 +++ b/tests/chocolatey-tests/commands/choco-removed.Tests.ps1 @@ -98,4 +98,19 @@ exit $command.Count ) { Get-ChildItem -Path $env:ChocolateyInstall -Name "$Name.exe" -Recurse -ErrorAction SilentlyContinue | Should -HaveCount 0 } + + Context 'Ensure WebPI source removal' -Skip:(-not (Test-ChocolateyVersionEqualOrHigherThan '1.999.999')) { + + BeforeAll { + $Output = Invoke-Choco list --source webpi + } + + It 'Exits with Failure (1)' { + $Output.ExitCode | Should -Be 1 + } + + It "Reports that the path for the source could not be resolved" { + $Output.String | Should -Match "The path '[^'].*webpi' for the selected source could not be resolved." + } + } }