Skip to content

Commit

Permalink
Comment out all the stuff and add mockups for missing interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCakeIsNaOH committed Jun 17, 2022
1 parent 8b2cd72 commit 9846e1d
Show file tree
Hide file tree
Showing 20 changed files with 339 additions and 90 deletions.
5 changes: 5 additions & 0 deletions src/chocolatey/chocolatey.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@
<Compile Include="infrastructure.app\commands\ChocolateyExportCommand.cs" />
<Compile Include="infrastructure.app\commands\ChocolateyInfoCommand.cs" />
<Compile Include="infrastructure.app\commands\ChocolateyHelpCommand.cs" />
<Compile Include="infrastructure\mockups\PackageOperationEventArgs.cs" />
<Compile Include="infrastructure\mockups\IPackageManager.cs" />
<Compile Include="infrastructure\mockups\IPackageRepository.cs" />
<Compile Include="infrastructure\mockups\PhysicalFileSystem.cs" />
<Compile Include="infrastructure\cryptography\DefaultEncryptionUtility.cs" />
<Compile Include="infrastructure\adapters\IEncryptionUtility.cs" />
<Compile Include="infrastructure.app\validations\GlobalConfigurationValidation.cs" />
Expand Down Expand Up @@ -205,6 +209,7 @@
<Compile Include="infrastructure\logging\LogMessage.cs" />
<Compile Include="infrastructure\logging\LogSinkLog.cs" />
<Compile Include="infrastructure\registration\AssemblyResolution.cs" />
<Compile Include="infrastructure\mockups\IPackage.cs" />
<Compile Include="infrastructure\synchronization\GlobalMutex.cs" />
<Compile Include="infrastructure\logging\TraceLog.cs" />
<Compile Include="infrastructure\registration\SecurityProtocol.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ namespace chocolatey.infrastructure.app.commands
using infrastructure.commands;
using infrastructure.configuration;
using logging;
using mockups;
using nuget;
using NuGet.Common;
using NuGet.Versioning;
Expand Down Expand Up @@ -147,7 +148,7 @@ public virtual void noop(ChocolateyConfiguration configuration)

public virtual void run(ChocolateyConfiguration configuration)
{
var packageManager = NugetCommon.GetPackageManager(configuration, _nugetLogger,
/*var packageManager = NugetCommon.GetPackageManager(configuration, _nugetLogger,
new PackageDownloader(),
installSuccessAction: null,
uninstallSuccessAction: null,
Expand All @@ -161,9 +162,9 @@ public virtual void run(ChocolateyConfiguration configuration)
case PinCommandType.remove:
set_pin(packageManager, configuration);
break;
}
}*/
}

/*
public virtual void list_pins(IPackageManager packageManager, ChocolateyConfiguration config)
{
var input = config.Input;
Expand All @@ -189,7 +190,7 @@ public virtual void set_pin(IPackageManager packageManager, ChocolateyConfigurat
var addingAPin = config.PinCommand.Command == PinCommandType.add;
this.Log().Info("Trying to {0} a pin for {1}".format_with(config.PinCommand.Command.to_string(), config.PinCommand.Name));
var versionUnspecified = string.IsNullOrWhiteSpace(config.Version);
SemanticVersion semanticVersion = versionUnspecified ? null : new SemanticVersion(config.Version);
SemanticVersion semanticVersion = versionUnspecified ? null : new SemanticVersion(SemanticVersion.Parse(config.Version));
IPackage installedPackage = packageManager.LocalRepository.FindPackage(config.PinCommand.Name, semanticVersion);
if (installedPackage == null)
{
Expand Down Expand Up @@ -222,7 +223,7 @@ public virtual void set_pin(IPackageManager packageManager, ChocolateyConfigurat
this.Log().Warn(NO_CHANGE_MESSAGE);
}
}

*/
public virtual bool may_require_admin_access()
{
var config = Config.get_configuration_settings();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@

namespace chocolatey.infrastructure.app.domain
{
using mockups;
using NuGet;
using NuGet.Versioning;
using results;

public sealed class ChocolateyPackageInformation
{
Expand Down
31 changes: 9 additions & 22 deletions src/chocolatey/infrastructure.app/nuget/NugetCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace chocolatey.infrastructure.app.nuget
using configuration;
using filesystem;
using logging;
using mockups;
using NuGet.Common;
using NuGet.Configuration;
using NuGet.Packaging;
Expand All @@ -52,23 +53,9 @@ private static IConsole Console
get { return _console.Value; }
}

public static IFileSystem GetNuGetFileSystem(ChocolateyConfiguration configuration, ILogger nugetLogger)
{
return new ChocolateyPhysicalFileSystem(ApplicationParameters.PackagesLocation) { Logger = nugetLogger };
}

public static IPackagePathResolver GetPathResolver(ChocolateyConfiguration configuration, IFileSystem nugetPackagesFileSystem)
{
return new ChocolateyPackagePathResolver(nugetPackagesFileSystem, configuration.AllowMultipleVersions);
}

public static IPackageRepository GetLocalRepository(IPackagePathResolver pathResolver, IFileSystem nugetPackagesFileSystem, ILogger nugetLogger)
{
return new ChocolateyLocalPackageRepository(pathResolver, nugetPackagesFileSystem) { Logger = nugetLogger, PackageSaveMode = PackageSaveModes.Nupkg | PackageSaveModes.Nuspec };
}

public static IPackageRepository GetRemoteRepository(ChocolateyConfiguration configuration, ILogger nugetLogger, IPackageDownloader packageDownloader)
public static void GetRemoteRepository(ChocolateyConfiguration configuration, ILogger nugetLogger, IPackageDownloader packageDownloader)
{
/*
if (configuration.Features.ShowDownloadProgress)
{
packageDownloader.ProgressAvailable += (sender, e) =>
Expand Down Expand Up @@ -172,18 +159,18 @@ public static IPackageRepository GetRemoteRepository(ChocolateyConfiguration con
ResolveDependenciesVertically = true
};
return repository;
return repository; */
}

// keep this here for the licensed edition for now
public static IPackageManager GetPackageManager(ChocolateyConfiguration configuration, ILogger nugetLogger, Action<PackageOperationEventArgs> installSuccessAction, Action<PackageOperationEventArgs> uninstallSuccessAction, bool addUninstallHandler)
public static void GetPackageManager(ChocolateyConfiguration configuration, ILogger nugetLogger, Action<PackageOperationEventArgs> installSuccessAction, Action<PackageOperationEventArgs> uninstallSuccessAction, bool addUninstallHandler)
{
return GetPackageManager(configuration, nugetLogger, new PackageDownloader(), installSuccessAction, uninstallSuccessAction, addUninstallHandler);
// return GetPackageManager(configuration, nugetLogger, new PackageDownloader(), installSuccessAction, uninstallSuccessAction, addUninstallHandler);
}

public static IPackageManager GetPackageManager(ChocolateyConfiguration configuration, ILogger nugetLogger, IPackageDownloader packageDownloader, Action<PackageOperationEventArgs> installSuccessAction, Action<PackageOperationEventArgs> uninstallSuccessAction, bool addUninstallHandler)
public static void GetPackageManager(ChocolateyConfiguration configuration, ILogger nugetLogger, IPackageDownloader packageDownloader, Action<PackageOperationEventArgs> installSuccessAction, Action<PackageOperationEventArgs> uninstallSuccessAction, bool addUninstallHandler)
{
IFileSystem nugetPackagesFileSystem = GetNuGetFileSystem(configuration, nugetLogger);
/* IFileSystem nugetPackagesFileSystem = GetNuGetFileSystem(configuration, nugetLogger);
IPackagePathResolver pathResolver = GetPathResolver(configuration, nugetPackagesFileSystem);
var packageManager = new PackageManager(GetRemoteRepository(configuration, nugetLogger, packageDownloader), pathResolver, nugetPackagesFileSystem, GetLocalRepository(pathResolver, nugetPackagesFileSystem, nugetLogger))
{
Expand Down Expand Up @@ -245,7 +232,7 @@ public static IPackageManager GetPackageManager(ChocolateyConfiguration configur
};
}
return packageManager;
return packageManager; */
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void RegisterComponents(Container container)
//nuget
container.Register<ILogger, ChocolateyNugetLogger>(Lifestyle.Singleton);
container.Register<INugetService, NugetService>(Lifestyle.Singleton);
container.Register<IPackageDownloader, PackageDownloader>(Lifestyle.Singleton);
//container.Register<PackageDownloader, PackageDownloader>(Lifestyle.Singleton);
container.Register<IPowershellService, PowershellService>(Lifestyle.Singleton);
container.Register<IChocolateyPackageInformationService, ChocolateyPackageInformationService>(Lifestyle.Singleton);
container.Register<IShimGenerationService, ShimGenerationService>(Lifestyle.Singleton);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public void run(PackageResult packageResult, ChocolateyConfiguration config)
}
}

/*
var pkgInfo = _packageInfoService.get_package_information(packageResult.Package);
if (pkgInfo.RegistrySnapshot == null)
{
Expand Down Expand Up @@ -104,6 +105,7 @@ public void run(PackageResult packageResult, ChocolateyConfiguration config)
var packageCacheLocation = _fileSystem.combine_paths(_fileSystem.get_full_path(config.CacheLocation), package.Id, package.Version.to_string());
remove(key, config, packageResult, packageCacheLocation);
}
*/
}

public void remove(RegistryApplicationKey key, ChocolateyConfiguration config, PackageResult packageResult, string packageCacheLocation)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ namespace chocolatey.infrastructure.app.services
using NuGet;
using domain;
using infrastructure.configuration;
using mockups;
using NuGet.Versioning;
using results;
using tolerance;
using IFileSystem = filesystem.IFileSystem;

Expand Down Expand Up @@ -149,7 +151,7 @@ has errored attempting to read it. This file will be renamed to
FaultTolerance.try_catch_with_logging_exception(
() =>
{
packageInformation.VersionOverride = new SemanticVersion(_fileSystem.read_file(versionOverrideFile).trim_safe());
packageInformation.VersionOverride = new SemanticVersion(SemanticVersion.Parse(_fileSystem.read_file(versionOverrideFile).trim_safe()));
},
"Unable to read version override file",
throwError: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ namespace chocolatey.infrastructure.app.services
using infrastructure.events;
using infrastructure.services;
using logging;
using mockups;
using NuGet;
using nuget;
using platforms;
Expand Down Expand Up @@ -1046,7 +1047,7 @@ public virtual void handle_package_uninstall(PackageResult packageResult, Chocol

private void uninstall_cleanup(ChocolateyConfiguration config, PackageResult packageResult)
{
if (config.Features.RemovePackageInformationOnUninstall) _packageInfoService.remove_package_information(packageResult.Package);
//if (config.Features.RemovePackageInformationOnUninstall) _packageInfoService.remove_package_information(packageResult.Package);

ensure_bad_package_path_is_clean(config, packageResult);
remove_rollback_if_exists(packageResult);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
namespace chocolatey.infrastructure.app.services
{
using domain;
using mockups;
using NuGet;

public interface IChocolateyPackageInformationService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace chocolatey.infrastructure.app.services
using System;
using System.Management.Automation.Runspaces;
using configuration;
using mockups;
using NuGet;
using results;

Expand Down
Loading

0 comments on commit 9846e1d

Please sign in to comment.