(() => new DateTime());
private IDateTime DateTime
@@ -68,13 +69,12 @@ private IDateTime DateTime
/// Package information service
/// The files service
/// The downloader used to download packages
- public NugetService(IFileSystem fileSystem, ILogger nugetLogger, IChocolateyPackageInformationService packageInfoService, IFilesService filesService, IPackageDownloader packageDownloader)
+ public NugetService(IFileSystem fileSystem, ILogger nugetLogger, IChocolateyPackageInformationService packageInfoService, IFilesService filesService)
{
_fileSystem = fileSystem;
_nugetLogger = nugetLogger;
_packageInfoService = packageInfoService;
_filesService = filesService;
- _packageDownloader = packageDownloader;
}
public SourceType SourceType
@@ -89,6 +89,7 @@ public void ensure_source_app_installed(ChocolateyConfiguration config, Action list_run(ChocolateyConfiguration config)
{
+ return new PackageResult[0];
int count = 0;
var sources = config.Sources;
@@ -129,7 +131,7 @@ public virtual IEnumerable list_run(ChocolateyConfiguration confi
config.Prerelease = true;
config.ListCommand.IncludeVersionOverrides = true;
}
-
+ /*
if (config.RegularOutput) this.Log().Debug(() => "Running list with the following filter = '{0}'".format_with(config.Input));
if (config.RegularOutput) this.Log().Debug(ChocolateyLoggers.Verbose, () => "--- Start of List ---");
foreach (var pkg in NugetList.GetPackages(config, _nugetLogger))
@@ -222,7 +224,7 @@ Package url
yield return new PackageResult(package, null, config.Sources);
}
-
+ */
if (config.RegularOutput) this.Log().Debug(ChocolateyLoggers.Verbose, () => "--- End of List ---");
if (config.RegularOutput && !config.QuietOutput)
{
@@ -288,7 +290,7 @@ public virtual void pack_run(ChocolateyConfiguration config)
properties["version"] = config.Version;
}
-
+
// Initialize the property provider based on what was passed in using the properties flag
var propertyProvider = new DictionaryPropertyProvider(properties);
@@ -324,13 +326,13 @@ public virtual void pack_run(ChocolateyConfiguration config)
//{
// AnalyzePackage(package);
//}
-
- this.Log().Info(config.QuietOutput ? ChocolateyLoggers.LogFileOnly : ChocolateyLoggers.Important, () => "Successfully created package '{0}'".format_with(outputPath));
+
+ this.Log().Info(config.QuietOutput ? ChocolateyLoggers.LogFileOnly : ChocolateyLoggers.Important, () => "Successfully created package '{0}'".format_with(outputPath));
}
public void push_noop(ChocolateyConfiguration config)
{
- string nupkgFilePath = validate_and_return_package_file(config, Constants.PackageExtension);
+ string nupkgFilePath = validate_and_return_package_file(config, NuGetConstants.PackageExtension);
this.Log().Info(() => "Would have attempted to push '{0}' to source '{1}'.".format_with(_fileSystem.get_file_name(nupkgFilePath), config.Sources));
}
@@ -397,21 +399,21 @@ public virtual ConcurrentDictionary install_run(Chocolate
//todo: #23 handle all
- SemanticVersion version = !string.IsNullOrWhiteSpace(config.Version) ? new SemanticVersion(config.Version) : null;
+ SemanticVersion version = !string.IsNullOrWhiteSpace(config.Version) ? new SemanticVersion(SemanticVersion.Parse(config.Version)) : null;
if (config.Force) config.AllowDowngrade = true;
IList packageNames = config.PackageNames.Split(new[] { ApplicationParameters.PackageNamesSeparator }, StringSplitOptions.RemoveEmptyEntries).or_empty_list_if_null().ToList();
if (packageNames.Count == 1)
{
var packageName = packageNames.DefaultIfEmpty(string.Empty).FirstOrDefault();
- if (packageName.EndsWith(Constants.PackageExtension) || packageName.EndsWith(Constants.ManifestExtension))
+ if (packageName.EndsWith(NuGetConstants.PackageExtension) || packageName.EndsWith(PackagingConstants.ManifestExtension))
{
this.Log().Debug("Updating source and package name to handle *.nupkg or *.nuspec file.");
packageNames.Clear();
config.Sources = _fileSystem.get_directory_name(_fileSystem.get_full_path(packageName));
- if (packageName.EndsWith(Constants.ManifestExtension))
+ if (packageName.EndsWith(PackagingConstants.ManifestExtension))
{
packageNames.Add(_fileSystem.get_file_name_without_extension(packageName));
@@ -422,20 +424,21 @@ public virtual ConcurrentDictionary install_run(Chocolate
}
else
{
+ /*
var packageFile = new OptimizedZipPackage(_fileSystem.get_full_path(packageName));
version = packageFile.Version;
- packageNames.Add(packageFile.Id);
+ packageNames.Add(packageFile.Id); */
}
}
}
// this is when someone points the source directly at a nupkg
// e.g. -source c:\somelocation\somewhere\packagename.nupkg
- if (config.Sources.to_string().EndsWith(Constants.PackageExtension))
+ if (config.Sources.to_string().EndsWith(NuGetConstants.PackageExtension))
{
config.Sources = _fileSystem.get_directory_name(_fileSystem.get_full_path(config.Sources));
}
-
+ /*
var packageManager = NugetCommon.GetPackageManager(
config, _nugetLogger, _packageDownloader,
installSuccessAction: (e) =>
@@ -449,7 +452,7 @@ public virtual ConcurrentDictionary install_run(Chocolate
},
uninstallSuccessAction: null,
addUninstallHandler: true);
-
+
var originalConfig = config.deep_copy();
foreach (string packageName in packageNames.or_empty_list_if_null())
@@ -491,7 +494,7 @@ public virtual ConcurrentDictionary install_run(Chocolate
this.Log().Error(ChocolateyLoggers.Important, logMessage);
continue;
}
-
+ /*
IPackage availablePackage = NugetList.find_package(packageName, version, config, packageManager.SourceRepository);
if (availablePackage == null)
@@ -568,7 +571,7 @@ Version was specified as '{0}'. It is possible that version
if (continueAction != null) continueAction.Invoke(errorResult);
}
}
-
+ */
return packageInstalls;
}
@@ -609,10 +612,11 @@ public ConcurrentDictionary upgrade_run(ChocolateyConfigu
public virtual ConcurrentDictionary upgrade_run(ChocolateyConfiguration config, Action continueAction, bool performAction, Action beforeUpgradeAction = null)
{
+
_fileSystem.create_directory_if_not_exists(ApplicationParameters.PackagesLocation);
var packageInstalls = new ConcurrentDictionary(StringComparer.InvariantCultureIgnoreCase);
-
- SemanticVersion version = !string.IsNullOrWhiteSpace(config.Version) ? new SemanticVersion(config.Version) : null;
+ /*
+ SemanticVersion version = !string.IsNullOrWhiteSpace(config.Version) ? new SemanticVersion(SemanticVersion.Parse(config.Version)) : null;
if (config.Force) config.AllowDowngrade = true;
var packageManager = NugetCommon.GetPackageManager(
@@ -713,7 +717,7 @@ public virtual ConcurrentDictionary upgrade_run(Chocolate
// this is a prerelease - opt in for newer prereleases.
config.Prerelease = true;
}
-
+ /*
IPackage availablePackage = NugetList.find_package(packageName, version, config, packageManager.SourceRepository);
config.Prerelease = originalPrerelease;
@@ -747,7 +751,7 @@ public virtual ConcurrentDictionary upgrade_run(Chocolate
continue;
}
-
+
if (pkgInfo != null && pkgInfo.IsSideBySide)
{
//todo: #103 get smarter about realizing multiple versions have been installed before and allowing that
@@ -774,7 +778,7 @@ public virtual ConcurrentDictionary upgrade_run(Chocolate
continue;
}
-
+
if (installedPackage.Version == availablePackage.Version)
{
string logMessage = "{0} v{1} is the latest version available based on your source(s).".format_with(installedPackage.Id, installedPackage.Version);
@@ -891,12 +895,13 @@ public virtual ConcurrentDictionary upgrade_run(Chocolate
}
}
}
-
+*/
return packageInstalls;
}
public virtual ConcurrentDictionary get_outdated(ChocolateyConfiguration config)
{
+ /*
var packageManager = NugetCommon.GetPackageManager(
config,
_nugetLogger,
@@ -906,13 +911,15 @@ public virtual ConcurrentDictionary get_outdated(Chocolat
addUninstallHandler: false);
var repository = packageManager.SourceRepository;
- var outdatedPackages = new ConcurrentDictionary();
+ */
+ var outdatedPackages = new ConcurrentDictionary();
+ /*
set_package_names_if_all_is_specified(config, () => { config.IgnoreDependencies = true; });
var packageNames = config.PackageNames.Split(new[] { ApplicationParameters.PackageNamesSeparator }, StringSplitOptions.RemoveEmptyEntries).or_empty_list_if_null().ToList();
var originalConfig = config.deep_copy();
-
+ /*
foreach (var packageName in packageNames)
{
// reset config each time through
@@ -939,7 +946,7 @@ public virtual ConcurrentDictionary get_outdated(Chocolat
// this is a prerelease - opt in for newer prereleases.
config.Prerelease = true;
}
-
+
SemanticVersion version = null;
var latestPackage = NugetList.find_package(packageName, null, config, packageManager.SourceRepository);
@@ -963,9 +970,9 @@ public virtual ConcurrentDictionary get_outdated(Chocolat
string logMessage = "You have {0} v{1} installed. Version {2} is available based on your source(s).{3} Source(s): \"{4}\"".format_with(installedPackage.Id, installedPackage.Version, latestPackage.Version, Environment.NewLine, config.Sources);
packageResult.Messages.Add(new ResultMessage(ResultType.Note, logMessage));
- this.Log().Info("{0}|{1}|{2}|{3}".format_with(installedPackage.Id, installedPackage.Version, latestPackage.Version, isPinned.to_string().to_lower()));
+ this.Log().Info("{0}|{1}|{2}|{3}".format_with(installedPackage.Id, installedPackage.Version, latestPackage.Version, isPinned.to_string().to_lower()));
}
-
+ */
return outdatedPackages;
}
@@ -1023,6 +1030,7 @@ protected virtual ChocolateyConfiguration set_package_config_for_upgrade(Chocola
private string get_install_directory(ChocolateyConfiguration config, IPackage installedPackage)
{
+ /*
var pathResolver = NugetCommon.GetPathResolver(config, NugetCommon.GetNuGetFileSystem(config, _nugetLogger));
var installDirectory = pathResolver.GetInstallPath(installedPackage);
if (!_fileSystem.directory_exists(installDirectory))
@@ -1037,7 +1045,8 @@ private string get_install_directory(ChocolateyConfiguration config, IPackage in
if (!_fileSystem.directory_exists(installDirectory)) return null;
}
- return installDirectory;
+ return installDirectory; */
+ return "asdf";
}
public virtual void ensure_package_files_have_compatible_attributes(ChocolateyConfiguration config, IPackage installedPackage, ChocolateyPackageInformation pkgInfo)
@@ -1051,7 +1060,7 @@ public virtual void ensure_package_files_have_compatible_attributes(ChocolateyCo
public virtual void rename_legacy_package_version(ChocolateyConfiguration config, IPackage installedPackage, ChocolateyPackageInformation pkgInfo)
{
if (pkgInfo != null && pkgInfo.IsSideBySide) return;
-
+ /*
var installDirectory = _fileSystem.combine_paths(ApplicationParameters.PackagesLocation, installedPackage.Id);
if (!_fileSystem.directory_exists(installDirectory))
{
@@ -1065,6 +1074,7 @@ public virtual void rename_legacy_package_version(ChocolateyConfiguration config
"Error during old package rename");
}
}
+ */
}
public virtual void backup_existing_version(ChocolateyConfiguration config, IPackage installedPackage, ChocolateyPackageInformation packageInfo)
@@ -1264,8 +1274,8 @@ public ConcurrentDictionary uninstall_run(ChocolateyConfi
public virtual ConcurrentDictionary uninstall_run(ChocolateyConfiguration config, Action continueAction, bool performAction, Action beforeUninstallAction = null)
{
var packageUninstalls = new ConcurrentDictionary(StringComparer.InvariantCultureIgnoreCase);
-
- SemanticVersion version = config.Version != null ? new SemanticVersion(config.Version) : null;
+ /*
+ SemanticVersion version = config.Version != null ? new SemanticVersion(SemanticVersion.Parse(config.Version)) : null;
var packageManager = NugetCommon.GetPackageManager(config, _nugetLogger, _packageDownloader,
installSuccessAction: null,
uninstallSuccessAction: (e) =>
@@ -1392,7 +1402,7 @@ public virtual ConcurrentDictionary uninstall_run(Chocola
}
else
{
- var semanticVersion = new SemanticVersion(config.Version);
+ var semanticVersion = new SemanticVersion(SemanticVersion.Parse(config.Version));
installedPackageVersions = packageManager.LocalRepository.FindPackagesById(packageName).Where((p) => p.Version.Equals(semanticVersion)).ToList();
}
@@ -1510,7 +1520,7 @@ public virtual ConcurrentDictionary uninstall_run(Chocola
}
}
}
-
+ */
return packageUninstalls;
}
diff --git a/src/chocolatey/infrastructure.app/services/PowershellService.cs b/src/chocolatey/infrastructure.app/services/PowershellService.cs
index 25511564e9..d35efd3448 100644
--- a/src/chocolatey/infrastructure.app/services/PowershellService.cs
+++ b/src/chocolatey/infrastructure.app/services/PowershellService.cs
@@ -34,6 +34,7 @@ namespace chocolatey.infrastructure.app.services
using infrastructure.commands;
using infrastructure.registration;
using logging;
+ using mockups;
using NuGet;
using powershell;
using results;
@@ -196,7 +197,7 @@ public bool run_action(ChocolateyConfiguration configuration, PackageResult pack
{
var failure = false;
var package = packageResult.Package;
- prepare_powershell_environment(package, configuration, packageDirectory);
+ //prepare_powershell_environment(package, configuration, packageDirectory);
this.Log().Debug(ChocolateyLoggers.Important, "Contents of '{0}':".format_with(chocoPowerShellScript));
string chocoPowerShellScriptContents = _fileSystem.read_file(chocoPowerShellScript);
@@ -379,8 +380,8 @@ public void prepare_powershell_environment(IPackage package, ChocolateyConfigura
Environment.SetEnvironmentVariable("packageTitle", package.Title);
Environment.SetEnvironmentVariable("chocolateyPackageVersion", package.Version.to_string());
Environment.SetEnvironmentVariable("packageVersion", package.Version.to_string());
- Environment.SetEnvironmentVariable("chocolateyPackageVersionPrerelease", package.Version.SpecialVersion.to_string());
- Environment.SetEnvironmentVariable("chocolateyPackageVersionPackageRelease", package.Version.PackageReleaseVersion.to_string());
+ //Environment.SetEnvironmentVariable("chocolateyPackageVersionPrerelease", package.Version.SpecialVersion.to_string());
+ //Environment.SetEnvironmentVariable("chocolateyPackageVersionPackageRelease", package.Version.PackageReleaseVersion.to_string());
Environment.SetEnvironmentVariable("chocolateyPackageFolder", packageDirectory);
Environment.SetEnvironmentVariable("packageFolder", packageDirectory);
@@ -464,7 +465,7 @@ public void prepare_powershell_environment(IPackage package, ChocolateyConfigura
if (package.IsDownloadCacheAvailable)
{
Environment.SetEnvironmentVariable("DownloadCacheAvailable", "true");
-
+ /*
foreach (var downloadCache in package.DownloadCache.or_empty_list_if_null())
{
var urlKey = CryptoHashProvider.hash_value(downloadCache.OriginalUrl, CryptoHashProviderType.Sha256).Replace("=", string.Empty);
@@ -472,6 +473,7 @@ public void prepare_powershell_environment(IPackage package, ChocolateyConfigura
Environment.SetEnvironmentVariable("CacheChecksum_{0}".format_with(urlKey), downloadCache.Checksum);
Environment.SetEnvironmentVariable("CacheChecksumType_{0}".format_with(urlKey), "sha512");
}
+ */
}
SecurityProtocol.set_protocol(configuration, provideWarning:false);
diff --git a/src/chocolatey/infrastructure.app/services/TemplateService.cs b/src/chocolatey/infrastructure.app/services/TemplateService.cs
index 5961c88664..93834938e9 100644
--- a/src/chocolatey/infrastructure.app/services/TemplateService.cs
+++ b/src/chocolatey/infrastructure.app/services/TemplateService.cs
@@ -212,11 +212,13 @@ public void list_noop(ChocolateyConfiguration configuration)
public void list(ChocolateyConfiguration configuration)
{
+
+ /*
var packageManager = NugetCommon.GetPackageManager(configuration, _nugetLogger,
new PackageDownloader(),
installSuccessAction: null,
uninstallSuccessAction: null,
- addUninstallHandler: false);
+ addUninstallHandler: false); */
var templateDirList = _fileSystem.get_directories(ApplicationParameters.TemplatesLocation).ToList();
var isBuiltInTemplateOverriden = templateDirList.Contains(_fileSystem.combine_paths(ApplicationParameters.TemplatesLocation, _builtInTemplateOverrideName));
@@ -229,7 +231,7 @@ public void list(ChocolateyConfiguration configuration)
foreach (var templateDir in templateDirList)
{
configuration.TemplateCommand.Name = _fileSystem.get_file_name(templateDir);
- list_custom_template_info(configuration, packageManager);
+ //list_custom_template_info(configuration, packageManager);
}
this.Log().Info(configuration.RegularOutput ? "{0} Custom templates found at {1}{2}".format_with(templateDirList.Count(), ApplicationParameters.TemplatesLocation, Environment.NewLine) : string.Empty);
@@ -245,7 +247,7 @@ public void list(ChocolateyConfiguration configuration)
{
if (templateDirList.Contains(_fileSystem.combine_paths(ApplicationParameters.TemplatesLocation, configuration.TemplateCommand.Name)))
{
- list_custom_template_info(configuration, packageManager);
+ //list_custom_template_info(configuration, packageManager);
if (configuration.TemplateCommand.Name == _builtInTemplateName || configuration.TemplateCommand.Name == _builtInTemplateOverrideName)
{
list_built_in_template_info(configuration, isBuiltInTemplateOverriden, isBuiltInOrDefaultTemplateDefault);
@@ -265,7 +267,7 @@ public void list(ChocolateyConfiguration configuration)
}
}
}
-
+ /*
protected void list_custom_template_info(ChocolateyConfiguration configuration, IPackageManager packageManager)
{
var pkg = packageManager.LocalRepository.FindPackage("{0}.template".format_with(configuration.TemplateCommand.Name));
@@ -311,7 +313,7 @@ protected void list_custom_template_info(ChocolateyConfiguration configuration,
{
this.Log().Info("{0}|{1}".format_with(configuration.TemplateCommand.Name, pkgVersion));
}
- }
+ } */
protected void list_built_in_template_info(ChocolateyConfiguration configuration, bool isOverridden, bool isDefault)
{
diff --git a/src/chocolatey/infrastructure/cryptography/DefaultEncryptionUtility.cs b/src/chocolatey/infrastructure/cryptography/DefaultEncryptionUtility.cs
index e37c9934ae..71c8286c3e 100644
--- a/src/chocolatey/infrastructure/cryptography/DefaultEncryptionUtility.cs
+++ b/src/chocolatey/infrastructure/cryptography/DefaultEncryptionUtility.cs
@@ -87,7 +87,7 @@ public string generate_unique_token(string caseInsensitiveKey)
{
// SHA256 is case sensitive; given that our key is case insensitive, we upper case it
var pathBytes = Encoding.UTF8.GetBytes(caseInsensitiveKey.ToUpperInvariant());
- var hashProvider = new NuGet.CryptoHashProvider("SHA256");
+ var hashProvider = new NuGet.Common.CryptoHashProvider("SHA256");
return Convert.ToBase64String(hashProvider.CalculateHash(pathBytes)).ToUpperInvariant();
}
diff --git a/src/chocolatey/infrastructure/mockups/IPackage.cs b/src/chocolatey/infrastructure/mockups/IPackage.cs
new file mode 100644
index 0000000000..8aeba03998
--- /dev/null
+++ b/src/chocolatey/infrastructure/mockups/IPackage.cs
@@ -0,0 +1,84 @@
+// Copyright © 2017 - 2021 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.mockups
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Diagnostics.CodeAnalysis;
+ using System.IO;
+ using System.Runtime.Versioning;
+ using filesystem;
+ using NuGet.Packaging;
+ using NuGet.Versioning;
+
+ public interface IPackage : IPackageMetadata
+ {
+ bool IsAbsoluteLatestVersion { get; }
+
+ bool IsLatestVersion { get; }
+
+ bool Listed { get; }
+
+ DateTimeOffset? Published { get; }
+
+ [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "This might be expensive")]
+ IEnumerable GetFiles();
+
+ [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "This might be expensive")]
+ IEnumerable GetSupportedFrameworks();
+
+ [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "This might be expensive")]
+ Stream GetStream();
+
+ void ExtractContents(IFileSystem fileSystem, string extractPath);
+
+ void OverrideOriginalVersion(SemanticVersion version);
+
+ Uri ProjectSourceUrl { get; }
+ Uri PackageSourceUrl { get; }
+ Uri DocsUrl { get; }
+ Uri WikiUrl { get; }
+ Uri MailingListUrl { get; }
+ Uri BugTrackerUrl { get; }
+ IEnumerable Replaces { get; }
+ IEnumerable Provides { get; }
+ IEnumerable Conflicts { get; }
+
+ string SoftwareDisplayName { get; }
+ string SoftwareDisplayVersion { get; }
+
+ string PackageHash { get; }
+ string PackageHashAlgorithm { get; }
+ long PackageSize { get; }
+ int VersionDownloadCount { get; }
+
+ bool IsApproved { get; }
+ string PackageStatus { get; }
+ string PackageSubmittedStatus { get; }
+ string PackageTestResultStatus { get; }
+ DateTime? PackageTestResultStatusDate { get; }
+ string PackageValidationResultStatus { get; }
+ DateTime? PackageValidationResultDate { get; }
+ DateTime? PackageCleanupResultDate { get; }
+ DateTime? PackageReviewedDate { get; }
+ DateTime? PackageApprovedDate { get; }
+ string PackageReviewer { get; }
+
+ bool IsDownloadCacheAvailable { get; }
+ DateTime? DownloadCacheDate { get; }
+ }
+}
\ No newline at end of file
diff --git a/src/chocolatey/infrastructure/mockups/IPackageManager.cs b/src/chocolatey/infrastructure/mockups/IPackageManager.cs
new file mode 100644
index 0000000000..1f5e78b19c
--- /dev/null
+++ b/src/chocolatey/infrastructure/mockups/IPackageManager.cs
@@ -0,0 +1,72 @@
+// Copyright © 2017 - 2021 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.mockups
+{
+ using filesystem;
+ using NuGet.Common;
+ using NuGet.Versioning;
+
+ public interface IPackageManager
+ {
+ IFileSystem FileSystem { get; set; }
+
+ IPackageRepository LocalRepository { get; }
+
+ ILogger Logger { get; set; }
+
+ bool WhatIf { get; set; }
+
+ IPackageRepository SourceRepository { get; }
+
+
+ void InstallPackage(IPackage package, bool ignoreDependencies, bool allowPrereleaseVersions);
+
+ void InstallPackage(
+ IPackage package,
+ bool ignoreDependencies,
+ bool allowPrereleaseVersions,
+ bool ignoreWalkInfo);
+
+ void InstallPackage(
+ string packageId,
+ SemanticVersion version,
+ bool ignoreDependencies,
+ bool allowPrereleaseVersions);
+
+ void UpdatePackage(IPackage newPackage, bool updateDependencies, bool allowPrereleaseVersions);
+
+ void UpdatePackage(
+ string packageId,
+ SemanticVersion version,
+ bool updateDependencies,
+ bool allowPrereleaseVersions);
+
+ void UpdatePackage(
+ string packageId,
+ string versionSpec,
+ bool updateDependencies,
+ bool allowPrereleaseVersions);
+
+ void UninstallPackage(IPackage package, bool forceRemove, bool removeDependencies);
+
+ void UninstallPackage(
+ string packageId,
+ SemanticVersion version,
+ bool forceRemove,
+ bool removeDependencies);
+ }
+}
\ No newline at end of file
diff --git a/src/chocolatey/infrastructure/mockups/IPackageRepository.cs b/src/chocolatey/infrastructure/mockups/IPackageRepository.cs
new file mode 100644
index 0000000000..cc223ed7e7
--- /dev/null
+++ b/src/chocolatey/infrastructure/mockups/IPackageRepository.cs
@@ -0,0 +1,35 @@
+// Copyright © 2017 - 2021 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.mockups
+{
+ using System.Diagnostics.CodeAnalysis;
+ using System.Linq;
+
+ public interface IPackageRepository
+ {
+ string Source { get; }
+
+ bool SupportsPrereleasePackages { get; }
+
+ [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "This call might be expensive")]
+ IQueryable GetPackages();
+
+ void AddPackage(IPackage package);
+
+ void RemovePackage(IPackage package);
+ }
+}
\ No newline at end of file
diff --git a/src/chocolatey/infrastructure/mockups/PackageOperationEventArgs.cs b/src/chocolatey/infrastructure/mockups/PackageOperationEventArgs.cs
new file mode 100644
index 0000000000..125d0bbf34
--- /dev/null
+++ b/src/chocolatey/infrastructure/mockups/PackageOperationEventArgs.cs
@@ -0,0 +1,37 @@
+// Copyright © 2017 - 2021 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.mockups
+{
+ using System.ComponentModel;
+ using filesystem;
+
+ public class PackageOperationEventArgs : CancelEventArgs
+ {
+ public PackageOperationEventArgs(IPackage package, IFileSystem fileSystem, string installPath)
+ {
+ this.Package = package;
+ this.InstallPath = installPath;
+ this.FileSystem = fileSystem;
+ }
+
+ public string InstallPath { get; private set; }
+
+ public IPackage Package { get; private set; }
+
+ public IFileSystem FileSystem { get; private set; }
+ }
+}
\ No newline at end of file
diff --git a/src/chocolatey/infrastructure.app/nuget/ChocolateyPhysicalFileSystem.cs b/src/chocolatey/infrastructure/mockups/PhysicalFileSystem.cs
similarity index 60%
rename from src/chocolatey/infrastructure.app/nuget/ChocolateyPhysicalFileSystem.cs
rename to src/chocolatey/infrastructure/mockups/PhysicalFileSystem.cs
index 908011508c..b9db4515fb 100644
--- a/src/chocolatey/infrastructure.app/nuget/ChocolateyPhysicalFileSystem.cs
+++ b/src/chocolatey/infrastructure/mockups/PhysicalFileSystem.cs
@@ -14,25 +14,26 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-namespace chocolatey.infrastructure.app.nuget
+namespace chocolatey.infrastructure.mockups
{
+ using System;
using System.Collections.Generic;
- using NuGet;
+ using NuGet.Packaging;
- // ReSharper disable InconsistentNaming
-
- public class ChocolateyPhysicalFileSystem : PhysicalFileSystem
+ public class PhysicalFileSystem
{
- public ChocolateyPhysicalFileSystem(string root)
- : base(root)
+ private readonly string _root;
+
+ public PhysicalFileSystem(string root)
{
+ if (String.IsNullOrEmpty(root))
+ {
+ throw new ArgumentException("thing");
+ }
+ _root = root;
}
-
- public override void AddFiles(IEnumerable files, string rootDir)
+ public virtual void AddFiles(IEnumerable files, string rootDir)
{
- this.AddFiles(files, rootDir, preserveFilePath: true);
}
}
-
- // ReSharper restore InconsistentNaming
-}
+}
\ No newline at end of file
diff --git a/src/chocolatey/infrastructure/results/PackageResult.cs b/src/chocolatey/infrastructure/results/PackageResult.cs
index 5c5a35c2a3..6ece4a2b61 100644
--- a/src/chocolatey/infrastructure/results/PackageResult.cs
+++ b/src/chocolatey/infrastructure/results/PackageResult.cs
@@ -19,6 +19,7 @@ namespace chocolatey.infrastructure.results
using System;
using System.Collections.Generic;
using System.Linq;
+ using mockups;
using NuGet.Packaging;
///
@@ -63,7 +64,8 @@ public PackageResult(IPackage package, string installLocation, string source = n
}
}
-
+ Source = sources.FirstOrDefault(uri => uri.IsFile || uri.IsUnc).to_string();
+ /* TODO, fix this
var rp = Package as DataServicePackage;
if (rp != null && rp.DownloadUrl != null)
{
@@ -78,6 +80,7 @@ public PackageResult(IPackage package, string installLocation, string source = n
{
Source = sources.FirstOrDefault(uri => uri.IsFile || uri.IsUnc).to_string();
}
+ */
}
public PackageResult(string name, string version, string installLocation, string source = null)