Skip to content

Commit

Permalink
Merge branch 'stable' into master
Browse files Browse the repository at this point in the history
* stable:
  (#1861) Improves terminology in help documentation
  (#1998) Add authorization header to Get-WebFile
  (maint) Repalce RawGit with raw.githack.com CDN
  (#1899) Remove unused variables
  (GH-1060) Add BeforeInstall parameter to Install-ChocolateyPackage.ps1
  (maint) Improve log message
  (GH-2092) Take all registry keys into account
  (GH-1364) Template create .nuspec encoded without BOM
  (#1866) Limit pending package removal to top level
  (GH-2203) Get-ChocolateyUnzip add unzipLocation alias
  (GH-1889) Fix: Removal of ApiKey broken
  (#2114) Remove unused variable
  (GH-2048) update deprecation note to outdated
  (maint) Spelling and grammar fixes
  (maint) Replace tabs with spaces
  (#2078) Skip importing Chocolatey GUI Extension
  (#2227) Use latest Mono and Ubuntu on Travis
  • Loading branch information
gep13 committed Apr 19, 2021
2 parents 1638afe + 2e31696 commit 5868c66
Show file tree
Hide file tree
Showing 22 changed files with 100 additions and 75 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: csharp
dist: bionic
mono:
- 5.20.1
- 6.12.0
install:
- sudo apt-get install mono-devel
- nuget restore src/chocolatey.sln
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ You can also disable the feature `allowEmptyChecksumsSecure` to enforce checksum

## [0.9.10](https://github.com/chocolatey/choco/issues?q=milestone%3A0.9.10+is%3Aclosed) (June 17, 2016)

![Chocolatey Logo](https://cdn.rawgit.com/chocolatey/choco/14a627932c78c8baaba6bef5f749ebfa1957d28d/docs/logo/chocolateyicon.gif "Chocolatey")
![Chocolatey Logo](https://rawcdn.githack.com/chocolatey/choco/14a627932c78c8baaba6bef5f749ebfa1957d28d/docs/logo/chocolateyicon.gif "Chocolatey")

The "I got 99 problems, but a package manager ain't one" release. With the release of 0.9.10 (or if you prefer 0.9.10.0), we're about to make everything 100% better in your Windows package management world. We've addressed over 100 features and bugs in this release. We looked at how we could improve PowerShell and we've come out with a [competely internal host](https://github.com/chocolatey/choco/issues/8) that can Prompt and Read-Host in a way that times out and selects default values after a period of time. Speaking of PowerShell, how about some tab completion `choco <tab>` to `choco install node<tab>`? How about never having to [close and reopen your shell again](https://github.com/chocolatey/choco/issues/664)?

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Chocolatey - like yum or apt-get, but for Windows
You can just call me choco.

![Chocolatey Logo](https://cdn.rawgit.com/chocolatey/choco/14a627932c78c8baaba6bef5f749ebfa1957d28d/docs/logo/chocolateyicon.gif "Chocolatey")
![Chocolatey Logo](https://rawcdn.githack.com/chocolatey/choco/14a627932c78c8baaba6bef5f749ebfa1957d28d/docs/logo/chocolateyicon.gif "Chocolatey")

[![](https://img.shields.io/chocolatey/dt/chocolatey.svg)](https://community.chocolatey.org/packages/chocolatey) [![](https://img.shields.io/chocolatey/v/chocolatey.svg)](https://community.chocolatey.org/packages/chocolatey) [![Project Stats](https://www.openhub.net/p/chocolatey/widgets/project_thin_badge.gif)](https://www.openhub.net/p/chocolatey)

Expand Down
24 changes: 14 additions & 10 deletions src/chocolatey.resources/helpers/chocolateyInstaller.psm1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright © 2017 Chocolatey Software, Inc.
# Copyright © 2017 Chocolatey Software, Inc.
# Copyright © 2015 - 2017 RealDimensions Software, LLC
# Copyright © 2011 - 2015 RealDimensions Software, LLC & original authors/contributors from https://github.com/chocolatey/chocolatey
#
Expand Down Expand Up @@ -40,11 +40,11 @@ Write-Debug "Host version is $($host.Version), PowerShell Version is '$($PSVersi
Get-Item $helpersPath\functions\*.ps1 |
? { -not ($_.Name.Contains(".Tests.")) } |
% {
. $_.FullName;
#Export-ModuleMember -Function $_.BaseName
. $_.FullName;
#Export-ModuleMember -Function $_.BaseName
}

# Export built-in functions prior to loading extensions so that
# Export built-in functions prior to loading extensions so that
# extension-specific loading behavior can be used based on built-in
# functions. This allows those overrides to be much more deterministic
# This behavior was broken from v0.9.9.5 - v0.10.3.
Expand All @@ -66,14 +66,18 @@ if (Test-Path($extensionsPath)) {
Write-Debug "Loading '$fileNameWithoutExtension' extension.";
$loaded = $false
$currentAssemblies | % {
$name = $_.GetName().Name
if ($name -eq $fileNameWithoutExtension) {
Import-Module $_
$loaded = $true
$name = $_.GetName().Name
if ($name -eq $fileNameWithoutExtension) {
Import-Module $_
$loaded = $true
}
}
}

if (!$loaded) { Import-Module $path; }
if (!$loaded) {
if ($fileNameWithoutExtension -ne "chocolateygui.licensed") {
Import-Module $path;
}
}
} catch {
if ($env:ChocolateyPowerShellHost -eq 'true') {
Write-Warning "Import failed for '$path'. Error: '$_'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Install-ChocolateyZipPackage
#>
param(
[alias("file")][parameter(Mandatory=$false, Position=0)][string] $fileFullPath,
[parameter(Mandatory=$true, Position=1)][string] $destination,
[alias("unzipLocation")][parameter(Mandatory=$true, Position=1)][string] $destination,
[parameter(Mandatory=$false, Position=2)][string] $specificFolder,
[parameter(Mandatory=$false, Position=3)][string] $packageName,
[alias("file64")][parameter(Mandatory=$false)][string] $fileFullPath64,
Expand Down
24 changes: 12 additions & 12 deletions src/chocolatey.resources/helpers/functions/Get-WebFile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,15 @@ param(

if ($options.Headers.Count -gt 0) {
Write-Debug "Setting custom headers"
foreach ($item in $options.Headers.GetEnumerator()) {
$uri = (new-object system.uri $url)
Write-Debug($item.Key + ':' + $item.Value)
switch ($item.Key) {
'Accept' {$req.Accept = $item.Value}
'Cookie' {$req.CookieContainer.SetCookies($uri, $item.Value)}
'Referer' {$req.Referer = $item.Value}
'User-Agent' {$req.UserAgent = $item.Value}
Default {$req.Headers.Add($item.Key, $item.Value)}
foreach ($key in $options.headers.keys) {
$uri = (New-Object -Typename system.uri $url)
switch ($key) {
'Accept' {$req.Accept = $options.headers.$key}
'Cookie' {$req.CookieContainer.SetCookies($uri, $options.headers.$key)}
'Referer' {$req.Referer = $options.headers.$key}
'User-Agent' {$req.UserAgent = $options.headers.$key}
'Authorization' {$re.Authorization = $options.headers.$key}
Default {$req.Headers.Add($key, $options.headers.$key)}
}
}
}
Expand All @@ -209,7 +209,7 @@ param(

if ($headers.ContainsKey("Content-Type")) {
$contentType = $headers['Content-Type']
if ($contentType -ne $null) {
if ($null -ne $contentType) {
if ($contentType.ToLower().Contains("text/html") -or $contentType.ToLower().Contains("text/plain")) {
Write-Warning "$fileName is of content type $contentType"
Set-Content -Path $binaryIsTextCheckFile -Value "$fileName has content type $contentType" -Encoding UTF8 -Force
Expand Down Expand Up @@ -315,7 +315,7 @@ param(
}
}
} catch {
if ($req -ne $null) {
if ($null -ne $req) {
$req.ServicePoint.MaxIdleTime = 0
$req.Abort();
# ruthlessly remove $req to ensure it isn't reused
Expand All @@ -331,7 +331,7 @@ param(
throw "The remote file either doesn't exist, is unauthorized, or is forbidden for url '$url'. $($_.Exception.Message)"
}
} finally {
if ($res -ne $null) {
if ($null -ne $res) {
$res.Close()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,13 @@ functionality (see links).
.PARAMETER IgnoredArguments
Allows splatting with arguments that do not apply. Do not use directly.
.PARAMETER BeforeInstall Script
Specifies the commands to run after download has completed but before install steps have begun.
Available in 0.10.16+.
Use this for starting an auxilary process such as AutoHotkey, so that any timeouts are not
affected by the time to download.
.EXAMPLE
>
$packageName= 'bob'
Expand Down Expand Up @@ -271,8 +278,6 @@ Install-ChocolateyPackage @packageArgs
>
$packageName= 'bob'
$toolsDir = "$(Split-Path -Parent $MyInvocation.MyCommand.Definition)"
$url = 'https://somewhere.com/file.msi'
$url64 = 'https://somewhere.com/file-x64.msi'
$urlTransform = 'https://somewhere.com/file.mst'
$mstFileLocation = Join-Path $toolsDir 'transform.mst'
Expand Down Expand Up @@ -359,6 +364,7 @@ param(
[parameter(Mandatory=$false)]
[alias("useOnlyPackageSilentArgs")][switch] $useOnlyPackageSilentArguments = $false,
[parameter(Mandatory=$false)][switch]$useOriginalLocation,
[parameter(Mandatory=$false)][scriptblock] $beforeInstall,
[parameter(ValueFromRemainingArguments = $true)][Object[]] $ignoredArguments
)
[string]$silentArgs = $silentArgs -join ' '
Expand Down Expand Up @@ -405,6 +411,10 @@ param(
-GetOriginalFileName
}

if ($beforeInstall) {
& $beforeInstall
}

Install-ChocolateyInstallPackage -PackageName $packageName `
-FileType $fileType `
-SilentArgs $silentArgs `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ public class when_generate_is_called : TemplateServiceSpecsBase
private readonly ChocolateyConfiguration config = new ChocolateyConfiguration();
private readonly List<string> files = new List<string>();
private readonly HashSet<string> directoryCreated = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
private readonly UTF8Encoding utf8WithoutBOM = new UTF8Encoding(false);

public override void Context()
{
Expand All @@ -250,6 +251,8 @@ public override void Context()
fileSystem.Setup(x => x.directory_exists(It.IsAny<string>())).Returns<string>(dirPath => dirPath.EndsWith("templates\\default"));
fileSystem.Setup(x => x.write_file(It.IsAny<string>(), It.IsAny<string>(), Encoding.UTF8))
.Callback((string filePath, string fileContent, Encoding encoding) => files.Add(filePath));
fileSystem.Setup(x => x.write_file(It.IsAny<string>(), It.IsAny<string>(), utf8WithoutBOM))
.Callback((string filePath, string fileContent, Encoding encoding) => files.Add(filePath));
fileSystem.Setup(x => x.delete_directory_if_exists(It.IsAny<string>(), true));
fileSystem.Setup(x => x.create_directory_if_not_exists(It.IsAny<string>())).Callback(
(string directory) =>
Expand Down Expand Up @@ -322,6 +325,7 @@ public class when_generate_is_called_with_nested_folders : TemplateServiceSpecsB
private readonly ChocolateyConfiguration config = new ChocolateyConfiguration();
private readonly List<string> files = new List<string>();
private readonly HashSet<string> directoryCreated = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
private readonly UTF8Encoding utf8WithoutBOM = new UTF8Encoding(false);

public override void Context()
{
Expand All @@ -341,6 +345,8 @@ public override void Context()
fileSystem.Setup(x => x.directory_exists(It.IsAny<string>())).Returns<string>(dirPath => dirPath.EndsWith("templates\\test"));
fileSystem.Setup(x => x.write_file(It.IsAny<string>(), It.IsAny<string>(), Encoding.UTF8))
.Callback((string filePath, string fileContent, Encoding encoding) => files.Add(filePath));
fileSystem.Setup(x => x.write_file(It.IsAny<string>(), It.IsAny<string>(), utf8WithoutBOM))
.Callback((string filePath, string fileContent, Encoding encoding) => files.Add(filePath));
fileSystem.Setup(x => x.delete_directory_if_exists(It.IsAny<string>(), true));
fileSystem.Setup(x => x.get_files(It.IsAny<string>(), "*.*", SearchOption.AllDirectories))
.Returns(new[] { "templates\\test\\template.nuspec", "templates\\test\\random.txt", "templates\\test\\tools\\chocolateyInstall.ps1", "templates\\test\\tools\\lower\\another.ps1" });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace chocolatey.infrastructure.app.commands
using logging;
using services;

[CommandFor("install", "installs packages from various sources")]
[CommandFor("install", "installs packages using configured sources")]
public class ChocolateyInstallCommand : ICommand
{
private readonly IChocolateyPackageService _packageService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace chocolatey.infrastructure.app.commands
using services;
using templates;

[CommandFor("new", "generates files necessary for a chocolatey package from a template")]
[CommandFor("new", "creates template files for creating a new Chocolatey package")]
public class ChocolateyNewCommand : ICommand
{
private readonly ITemplateService _templateService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace chocolatey.infrastructure.app.commands
using logging;
using services;

[CommandFor("outdated", "retrieves packages that are outdated. Similar to upgrade all --noop")]
[CommandFor("outdated", "retrieves information about packages that are outdated. Similar to upgrade all --noop")]
public class ChocolateyOutdatedCommand : ICommand
{
private readonly IChocolateyPackageService _packageService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace chocolatey.infrastructure.app.commands
using logging;
using services;

[CommandFor("pack", "packages up a nuspec to a compiled nupkg")]
[CommandFor("pack", "packages nuspec, scripts, and other Chocolatey package resources into a nupkg file")]
public class ChocolateyPackCommand : ICommand
{
private readonly IChocolateyPackageService _packageService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace chocolatey.infrastructure.app.commands
using logging;
using services;

[CommandFor("push", "pushes a compiled nupkg")]
[CommandFor("push", "pushes a compiled nupkg to a source")]
public class ChocolateyPushCommand : ICommand
{
private readonly IChocolateyPackageService _packageService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace chocolatey.infrastructure.app.commands
using resources;
#endif

[CommandFor("unpackself", "have chocolatey set itself up")]
[CommandFor("unpackself", "re-installs Chocolatey base files")]
public class ChocolateyUnpackSelfCommand : ICommand
{
private readonly IFileSystem _fileSystem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ DEPRECATION NOTICE - `choco version -lo` is deprecated. version command
{
this.Log().Warn(ChocolateyLoggers.Important, @"
DEPRECATION NOTICE - choco version command is deprecated and will be
removed in version 1.0.0. Please use `choco upgrade pkgname --noop`
removed in version 1.0.0. Please use `choco outdated`
instead.");

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public override bool Equals(object obj)
var item = (ConfigFileApiKeySetting) obj;

return (Source == item.Source)
&& (Key == item.Source);
&& (Key == item.Key);
}

public override int GetHashCode()
Expand Down
Loading

0 comments on commit 5868c66

Please sign in to comment.