Skip to content

Commit

Permalink
Comment out all the things
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCakeIsNaOH committed Jun 24, 2022
1 parent cb47a85 commit 5db4d45
Show file tree
Hide file tree
Showing 27 changed files with 443 additions and 132 deletions.
6 changes: 5 additions & 1 deletion src/chocolatey/chocolatey.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,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 @@ -209,6 +213,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 Expand Up @@ -285,7 +290,6 @@
<Compile Include="infrastructure.app\nuget\ChocolateyNugetLogger.cs" />
<Compile Include="infrastructure.app\events\PreRunMessage.cs" />
<Compile Include="infrastructure.app\nuget\ChocolateyPackagePathResolver.cs" />
<Compile Include="infrastructure.app\nuget\ChocolateyPhysicalFileSystem.cs" />
<Compile Include="infrastructure.app\nuget\DictionaryPropertyProvider.cs" />
<Compile Include="infrastructure.app\nuget\NugetCommon.cs" />
<Compile Include="infrastructure.app\nuget\NuGetFileSystemExtensions.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
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
namespace chocolatey.infrastructure.app.nuget
{
using configuration;
using NuGet;
using System;
using System.Linq;
using System.Net;
using System.Security.Cryptography.X509Certificates;

using NuGet.Configuration;
using System.Collections.Generic;

class ChocolateyClientCertificateProvider : IClientCertificateProvider
{
ChocolateyConfiguration _configuration;
Expand All @@ -32,8 +33,13 @@ public ChocolateyClientCertificateProvider(ChocolateyConfiguration configuration
if (configuration == null)
throw new ArgumentNullException("configuration");
_configuration = configuration;
}

}

public void AddOrUpdate(ClientCertItem item)
{
throw new NotImplementedException();
}

public X509Certificate GetCertificate(Uri uri)
{
if (uri.OriginalString.StartsWith(_configuration.Sources.TrimEnd('/').ToLower(),StringComparison.InvariantCultureIgnoreCase))
Expand Down Expand Up @@ -67,6 +73,16 @@ public X509Certificate GetCertificate(Uri uri)
}
})
.FirstOrDefault();
}
}

public IReadOnlyList<ClientCertItem> GetClientCertificates()
{
throw new NotImplementedException();
}

public void Remove(IReadOnlyList<ClientCertItem> items)
{
throw new NotImplementedException();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@ namespace chocolatey.infrastructure.app.nuget
using System.Linq;
using System.Runtime.Versioning;
using System.Threading;
using filesystem;
using mockups;
using NuGet;
using NuGet.Common;
using NuGet.Packaging;
using NuGet.ProjectManagement;
using NuGet.Versioning;

// ReSharper disable InconsistentNaming

/*
public class ChocolateyLocalPackageRepository : LocalPackageRepository
{
public ChocolateyLocalPackageRepository(string physicalPath)
Expand Down Expand Up @@ -81,4 +87,5 @@ private string GetManifestFilePath(string packageId, SemanticVersion version)
}
// ReSharper restore InconsistentNaming
*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ namespace chocolatey.infrastructure.app.nuget
using NuGet;
using configuration;
using logging;
using NuGet.Credentials;
using System.Threading.Tasks;
using NuGet.Configuration;
using System.Threading;

// ReSharper disable InconsistentNaming

Expand All @@ -33,11 +37,13 @@ public sealed class ChocolateyNugetCredentialProvider : ICredentialProvider

private const string INVALID_URL = "http://somewhere123zzaafasd.invalid";

public string Id => throw new NotImplementedException();

public ChocolateyNugetCredentialProvider(ChocolateyConfiguration config)
{
_config = config;
}

/*
public ICredentials GetCredentials(Uri uri, IWebProxy proxy, CredentialType credentialType, bool retrying)
{
if (uri == null)
Expand Down Expand Up @@ -143,7 +149,9 @@ public ICredentials GetCredentials(Uri uri, IWebProxy proxy, CredentialType cred
return new NetworkCredential(source.Username, NugetEncryptionUtility.DecryptString(source.EncryptedPassword));
}
*/

/*
public ICredentials get_credentials_from_user(Uri uri, IWebProxy proxy, CredentialType credentialType)
{
if (!_config.Information.IsInteractive)
Expand Down Expand Up @@ -178,7 +186,12 @@ public ICredentials get_credentials_from_user(Uri uri, IWebProxy proxy, Credenti
return credentials;
}
*/
public Task<CredentialResponse> GetAsync(Uri uri, IWebProxy proxy, CredentialRequestType type, string message, bool isRetry, bool nonInteractive, CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
}

// ReSharper restore InconsistentNaming
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@
namespace chocolatey.infrastructure.app.nuget
{
using System.IO;
using filesystem;
using mockups;
using NuGet;
using NuGet.Configuration;
using NuGet.Packaging;
using NuGet.ProjectManagement;
using NuGet.Versioning;

// ReSharper disable InconsistentNaming

/*
public sealed class ChocolateyPackagePathResolver : DefaultPackagePathResolver
{
private readonly IFileSystem _nugetFileSystem;
Expand Down Expand Up @@ -65,9 +71,9 @@ public override string GetPackageFileName(string packageId, SemanticVersion vers
{
fileNameBase += "." + version.to_string();
}
return fileNameBase + Constants.PackageExtension;
return fileNameBase + NuGetConstants.PackageExtension;
}
}

*/
// ReSharper restore InconsistentNaming
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ namespace chocolatey.infrastructure.app.nuget
using System;
using System.Collections.Generic;
using System.IO;
using NuGet;
using NuGet.Packaging;

// ReSharper disable InconsistentNaming

/*
public static class NuGetFileSystemExtensions
{
public static void AddFiles(this IFileSystem fileSystem, IEnumerable<IPackageFile> files, string rootDir, bool preserveFilePath)
Expand All @@ -38,15 +38,15 @@ internal static void AddFileWithCheck(this IFileSystem fileSystem, string path,
{
using (Stream stream = streamFactory())
{
fileSystem.AddFile(path, stream);
//fileSystem.AddFile(path, stream);
}
}
internal static void AddFileWithCheck(this IFileSystem fileSystem, string path, Action<Stream> write)
{
fileSystem.AddFile(path, write);
//fileSystem.AddFile(path, write);
}
}

*/
// ReSharper restore InconsistentNaming
}
61 changes: 30 additions & 31 deletions src/chocolatey/infrastructure.app/nuget/NugetCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,20 @@ namespace chocolatey.infrastructure.app.nuget
using System.ComponentModel;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using adapters;
using infrastructure.configuration;
using NuGet;
using configuration;
using filesystem;
using logging;
using mockups;
using NuGet.Common;
using NuGet.Configuration;
using NuGet.PackageManagement;
using NuGet.Packaging;
using NuGet.Protocol.Core.Types;
using Console = adapters.Console;
using Environment = adapters.Environment;
using WebProxy = System.Net.WebProxy;
Expand All @@ -52,26 +56,16 @@ 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)
//public static SourceRepository GetRemoteRepository(ChocolateyConfiguration configuration, ILogger nugetLogger)
{

//TODO, fix
/*
if (configuration.Features.ShowDownloadProgress)
{
packageDownloader.ProgressAvailable += (sender, e) =>
PackageDownloader.
PackageDownloader.ProgressAvailable += (sender, e) =>
{
// http://stackoverflow.com/a/888569/18475
Console.Write("\rProgress: {0} {1}%".format_with(e.Operation, e.PercentComplete.to_string()).PadRight(Console.WindowWidth));
Expand All @@ -81,11 +75,12 @@ public static IPackageRepository GetRemoteRepository(ChocolateyConfiguration con
}
};
}

*/

IEnumerable<string> sources = configuration.Sources.to_string().Split(new[] { ";", "," }, StringSplitOptions.RemoveEmptyEntries);

IList<IPackageRepository> repositories = new List<IPackageRepository>();

/*
// ensure credentials can be grabbed from configuration
HttpClient.DefaultCredentialProvider = new ChocolateyNugetCredentialProvider(configuration);
HttpClient.DefaultCertificateProvider = new ChocolateyClientCertificateProvider(configuration);
Expand Down Expand Up @@ -172,29 +167,32 @@ 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);
}

public static IPackageManager GetPackageManager(ChocolateyConfiguration configuration, ILogger nugetLogger, IPackageDownloader packageDownloader, Action<PackageOperationEventArgs> installSuccessAction, Action<PackageOperationEventArgs> uninstallSuccessAction, bool addUninstallHandler)
{
IFileSystem nugetPackagesFileSystem = GetNuGetFileSystem(configuration, nugetLogger);
IPackagePathResolver pathResolver = GetPathResolver(configuration, nugetPackagesFileSystem);
var packageManager = new PackageManager(GetRemoteRepository(configuration, nugetLogger, packageDownloader), pathResolver, nugetPackagesFileSystem, GetLocalRepository(pathResolver, nugetPackagesFileSystem, nugetLogger))

//IFileSystem nugetPackagesFileSystem = GetNuGetFileSystem(configuration, nugetLogger);
//IPackagePathResolver pathResolver = GetPathResolver(configuration, nugetPackagesFileSystem);

/*
var packageManager = new NuGetPackageManager(GetRemoteRepository(configuration, nugetLogger, packageDownloader), pathResolver, nugetPackagesFileSystem, GetLocalRepository(pathResolver, nugetPackagesFileSystem, nugetLogger))
{
DependencyVersion = DependencyVersion.Highest,
Logger = nugetLogger,
};
*/

/*
var
var packageManager = new NuGetPackageManager()
// GH-1548
//note: is this a good time to capture a backup (for dependencies) / maybe grab remembered arguments here instead / and somehow get out of the endless loop!
//NOTE DO NOT EVER use this method - packageManager.PackageInstalling += (s, e) => { };
packageManager.PackageInstalled += (s, e) =>
{
var pkg = e.Package;
Expand Down Expand Up @@ -245,7 +243,8 @@ public static IPackageManager GetPackageManager(ChocolateyConfiguration configur
};
}
return packageManager;
return packageManager;
*/
}
}

Expand Down
Loading

0 comments on commit 5db4d45

Please sign in to comment.