Skip to content

Commit 0b07266

Browse files
committed
Merge branch 'release/0.3.0'
* release/0.3.0: (build) Updated to only collect files in build directory (build) Added codecov config (docs) Fixed incorrect github release link (docs) Fixed copy-paste error (GH-15) Allow users to disable escaping of redirected url (GH-18) Added ability to add alias whitelist (choco) Fixed incorrect urls used in nuspec file (docs) Updated release notes
2 parents f4ff65d + cd20cd5 commit 0b07266

File tree

11 files changed

+66
-13
lines changed

11 files changed

+66
-13
lines changed

.appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ test_script:
2121
Import-Module $env:USERPROFILE\CodeCovIo.psm1
2222
.\test -CodeCoverage
2323
artifacts:
24-
- path: '**\*.nupkg'
25-
- path: '**\*.7z'
24+
- path: '.build\**\*.nupkg'
25+
- path: '.build\**\*.7z'
2626
notifications:
2727
- provider: GitHubPullRequest
2828
on_build_success: false

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ To install it, use one of the following methods:
2222
- [![PowerShell Gallery](https://img.shields.io/powershellgallery/v/Wormies-AU-Helpers.svg?style=plastic)](https://www.powershellgallery.com/packages/Wormies-AU-Helpers): [`Install-Module wormies-au-helpers`]
2323
- [![Chocolatey](https://img.shields.io/chocolatey/v/wormies-au-helpers.svg?style=plastic)](https://chocolatey.org/packages/wormies-au-helpers): [`choco install wormies-au-helpers`]
2424
- [![MyGet](https://img.shields.io/myget/wormie-nugets/vpre/wormies-au-helpers.svg?style=plastic&label=MyGet)](https://www.myget.org/feed/wormie-nugets/package/nuget/wormies-au-helpers): [`choco install wormies-au-helpers --source https://www.myget.org/F/wormie-nugets --pre`]
25-
- Download the 7z archive from the latest [![GitHub Release](https://img.shields.io/github/release/qubyte/rubidium.svg?style=plastic&label=GitHub%20Release)](https://com/WormieCorp/Wormies-AU-Helpers/releases/latest), or latest appveyor build [artifact](https://ci.appveyor.com/project/admiringworm/wormies-au-helpers/build/artifacts)
25+
- Download the 7z archive from the latest [![GitHub Release](https://img.shields.io/github/release/WormieCorp/Wormies-AU-Helpers.svg?style=plastic&label=GitHub%20Release)](https://github.com/WormieCorp/Wormies-AU-Helpers/releases/latest), or latest appveyor build [artifact](https://ci.appveyor.com/project/admiringworm/wormies-au-helpers/build/artifacts)

Wormies-AU-Helpers/private/Expand-AliasesInText.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
[string]$text,
66
[Parameter(Mandatory = $true)]
77
[hashtable]$aliases,
8-
$ParserErrors = $null)
8+
$ParserErrors = $null,
9+
[string[]]$whitelist = @())
910

1011
$tokens = [System.Management.Automation.PSParser]::Tokenize($text, [ref]$ParserErrors)
1112
$commands = $tokens | Where-Object Type -eq "Command" | Sort-Object Start -Descending
1213

1314
foreach ($cmd in $commands) {
1415
$key = $cmd.Content
15-
if ($aliases.Contains($key)) {
16+
if ($aliases.Contains($key) -and !$whitelist.Contains($key)) {
1617
$alias = $aliases.$key
1718
$old = $cmd.Content
1819
$new = $alias.ResolvedCommandName

Wormies-AU-Helpers/public/Expand-Aliases.ps1

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
.PARAMETER Files
1919
The files to expand aliases in.
2020
21+
.PARAMETER AliasWhitelist
22+
Allows to add a array of whitelisted aliases that shouldn't be expanded.
23+
(defaults to @('Get-UninstallRegistryKey'))
24+
2125
.EXAMPLE
2226
Expand-Aliases -Text "rm file.txt; gi file.exe"
2327
@@ -47,7 +51,10 @@ function Expand-Aliases () {
4751
[Parameter(Mandatory = $false, ParameterSetName = 'directory')]
4852
[string]$Filter = "*.ps1",
4953
[Parameter(Mandatory = $true, ParameterSetName = 'files')]
50-
[string[]]$Files
54+
[string[]]$Files,
55+
[Parameter(Mandatory = $false)]
56+
[Alias('Whitelist')]
57+
[string[]]$AliasWhitelist = @('Get-PackageParameters'; 'Get-UninstallRegistryKey') # We add some default due to later chocolatey version setting it as an alias
5158
)
5259

5360
BEGIN {
@@ -70,14 +77,14 @@ function Expand-Aliases () {
7077

7178
foreach ($file in $allFiles) {
7279
$oldText = Get-Content -Path $file.FullName -Raw
73-
$text = Expand-AliasesInText -text $oldText -aliases $aliases -ParserErrors $ParserErrors
80+
$text = Expand-AliasesInText -text $oldText -aliases $aliases -ParserErrors $ParserErrors -whitelist $AliasWhitelist
7481
if ($oldText -cne $text) {
7582
[System.IO.File]::WriteAllText($file.FullName, $text, [System.Text.Encoding]::UTF8)
7683
}
7784
}
7885
}
7986
else {
80-
$text = Expand-AliasesInText -text $text -aliases $aliases -ParserErrors $ParserErrors
87+
$text = Expand-AliasesInText -text $text -aliases $aliases -ParserErrors $ParserErrors -whitelist $AliasWhitelist
8188
}
8289
}
8390

Wormies-AU-Helpers/public/Get-RedirectedUrl.ps1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ function Get-RedirectedUrl {
2424
param(
2525
[Parameter(Mandatory = $true)]
2626
[uri]$url,
27-
[uri]$referer
27+
[uri]$referer,
28+
[Alias('DisableEscape','RawUrl')]
29+
[switch]$NoEscape
2830
)
2931

3032
$req = [System.Net.WebRequest]::CreateDefault($url)
@@ -36,7 +38,7 @@ function Get-RedirectedUrl {
3638

3739
if ($resp -and $resp.ResponseUri.OriginalString -ne $url) {
3840
Write-Verbose "Found redirected url '$($resp.ResponseUri)"
39-
if ( $($resp.ResponseUri.OriginalString) -match '\%\d+' ) {
41+
if ($NoEscape -or $($resp.ResponseUri.OriginalString) -match '\%\d+' ) {
4042
$result = $resp.ResponseUri.OriginalString
4143
}
4244
else {

chocolatey/Build-Package.ps1

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,8 @@ $description = $au.package.metadata.summary + ".`n`n" + $features
3030
$au.package.metadata.version = $version
3131
$au.package.metadata.description = $description
3232
$au.package.metadata.licenseUrl = "${repo}/blob/develop/LICENSE"
33-
$au.package.metadata.projectUrl = $repo
3433
$au.package.metadata.projectSourceUrl = $repo
3534
$au.package.metadata.bugTrackerUrl = "${repo}/issues"
36-
$au.package.metadata.docsUrl = "${repo}/wiki"
3735
$au.package.metadata.packageSourceUrl = "${repo}/tree/develop/chocolatey"
3836

3937
if (Test-Path "$PSScriptRoot/CHANGELOG.md") {

codecov.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
coverage:
2+
notify:
3+
gitter:
4+
default:
5+
url: secret:2OfQF7Mj7kKPY5mD3LKeyV9Ap4OB8Cvz1dTFwgzygQLzxtbuUHuWHOC6fKhzaa0RwEcjAKkClyF2GVasF6+Vj6p0jULn7au1GqbQpcmqBpZ8QVMWu97rHSeR9N0iDkyi
6+
threshold: 1%
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
Title: Bug Release 0.2.2
3+
Published: 2018-05-05
4+
Category: Release
5+
Author: AdmiringWorm
6+
---
7+
8+
# 0.2.2 Bug Release
9+
10+
As part of this release we had [15 commits](https://github.com/WormieCorp/Wormies-AU-Helpers/compare/0.2.1...0.2.2) which resulted in [1 issue](https://github.com/WormieCorp/Wormies-AU-Helpers/issues?milestone=7&state=closed) being closed.
11+
12+
13+
__Bug__
14+
15+
- [__#17__](https://github.com/WormieCorp/Wormies-AU-Helpers/issues/17) Some uri escape to %2520 instead of %20
16+
17+
### Where to get it
18+
You can download this release from [chocolatey](https://chocolatey.org/packages/wormies-au-helpers/0.2.2), or from the [PowerShell Gallery](https://www.powershellgallery.com/packages/Wormies-AU-Helpers/0.2.2)

scripts/Create-GithubRelease.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ $repoUser = $splits | Select-Object -Last 1 -Skip 2
1818
$repoName = $splits | Select-Object -Last 1 -Skip 1
1919
$args += " -o '$repoUser' -r '$repoName'"
2020

21-
$assets = Get-ChildItem $PSScriptRoot/.. -Include "*.7z", "*.nupkg" -Recurse | ForEach-Object FullName
21+
$assets = Get-ChildItem $PSScriptRoot/../.build -Include "*.7z", "*.nupkg" -Recurse | ForEach-Object FullName
2222

2323
"Uploading the followings assets to $repoName for version $version"
2424
$assets | ForEach-Object { " - " + (Split-Path -Leaf $_) }

tests/public/Expand-Aliases.Tests.ps1

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,21 @@ Describe "Expand-Aliases" {
6969

7070
Get-Module chocolateyInstaller -All | Should -Not -Be $null
7171
}
72+
73+
It "Should not expand aliases specified in whitelist array" {
74+
$testText = 'gc "something"'
75+
$expectedText = 'gc "something"'
76+
77+
Expand-Aliases -Text $testText -AliasWhitelist @('gc') | Should Be $expectedText
78+
79+
$testText = 'Get-UninstallRegistryKey "somekey"'
80+
$expectedText = 'Get-UninstallRegistryKey "somekey"'
81+
82+
Expand-Aliases -Text $testText | Should Be $expectedText
83+
84+
$testText = $testText + '; gc "testing"'
85+
$expectedText = $expectedText + '; Get-Content "testing"'
86+
87+
Expand-Aliases -Text $testText | Should Be $expectedText
88+
}
7289
}

0 commit comments

Comments
 (0)