Skip to content

Commit 16c63b0

Browse files
committed
Merge branch 'release/0.2.0'
2 parents 1ec4e72 + 4d4ed0d commit 16c63b0

File tree

24 files changed

+646
-61
lines changed

24 files changed

+646
-61
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Build status](https://ci.appveyor.com/api/projects/status/6xm2ci85fnpxf8g2?svg=true)](https://ci.appveyor.com/project/AdmiringWorm/wormies-au-helpers) [![license](https://img.shields.io/github/license/WormieCorp/Wormies-AU-Helpers.svg)](https://github.com/WormieCorp/Wormies-AU-Helpers/blob/master/LICENSE)
1+
[![Build status](https://img.shields.io/appveyor/ci/AdmiringWorm/Wormies-AU-Helpers.svg?style=plastic&logo=appveyor)](https://ci.appveyor.com/project/AdmiringWorm/wormies-au-helpers) [![Code Coverage](https://img.shields.io/codecov/c/github/WormieCorp/Wormies-AU-Helpers/develop.svg?style=plastic)](https://codecov.io/gh/WormieCorp/Wormies-AU-Helpers/branch/develop) [![license](https://img.shields.io/github/license/WormieCorp/Wormies-AU-Helpers.svg?style=plastic)](https://github.com/WormieCorp/Wormies-AU-Helpers/blob/master/LICENSE)
22

33
# Chocolatey Automatic Package Updater Helper Module
44

@@ -12,14 +12,14 @@ To Learn more about AU, please refer to their relevant [documentation](https://g
1212
- Ability to update either a single or multiple metadata elements
1313

1414
Please read our documentation for an overall view of the functions available:
15-
<https://wormiecorp.github.io/Wormies-AU-Helpers/docs/>
15+
https://wormiecorp.github.io/Wormies-AU-Helpers/docs/
1616

1717
## Installation
1818

1919
Wormies-AU-Helpers requires a minimally PowerShell version 3: `$host.Version -ge '3.0'`.
2020

2121
To install it, use one of the following methods:
22-
- PowerShell Gallery: [`Install-Module wormies-au-helpers`](https://www.powershellgallery.com/packages/Wormies-AU-Helpers)
23-
- Chocolatey: [`choco install wormies-au-helpers`](https://chocolatey.org/packages/wormies-au-helpers)
24-
- MyGet: [`choco install wormies-au-helpers --source https://www.myget.org/F/wormie-nugets --pre`](https://www.myget.org/feed/wormie-nugets/package/nuget/wormies-au-helpers)
25-
- [Download](https://com/WormieCorp/Wormies-AU-Helpers/releases/latest) latest 7z package, or latest build [artifact](https://ci.appveyor.com/project/admiringworm/wormies-au-helpers/build/artifacts)
22+
- [![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`]
23+
- [![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`]
24+
- [![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)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
function Expand-AliasesInText {
2+
[cmdletbinding(SupportsShouldProcess = $True)]
3+
param(
4+
[Parameter(Mandatory = $true)]
5+
[string]$text,
6+
[Parameter(Mandatory = $true)]
7+
[hashtable]$aliases,
8+
$ParserErrors = $null)
9+
10+
$tokens = [System.Management.Automation.PSParser]::Tokenize($text, [ref]$ParserErrors)
11+
$commands = $tokens | Where-Object Type -eq "Command" | Sort-Object Start -Descending
12+
13+
foreach ($cmd in $commands) {
14+
$key = $cmd.Content
15+
if ($aliases.Contains($key)) {
16+
$alias = $aliases.$key
17+
$old = $cmd.Content
18+
$new = $alias.ResolvedCommandName
19+
if ($PSCmdlet.ShouldProcess($old, "Expand alias to $new")) {
20+
$text = $text.Remove($cmd.Start, $cmd.Content.Length).Insert($cmd.Start, $new)
21+
}
22+
}
23+
}
24+
25+
return $text
26+
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<#
2+
.SYNOPSIS
3+
Expands the aliases in either the file or text passed to the function.
4+
5+
.DESCRIPTION
6+
Any scripts in 'corporate' or 'formal' use should have any aliases expanded.
7+
This this removes ambiguity and any potential clashes or errors.
8+
9+
.PARAMETER Text
10+
The script text that should parsed for aliases to expand.
11+
12+
.PARAMETER Directory
13+
The directory to use for parsing files.
14+
15+
.PARAMETER Filter
16+
The filter to use when traversing a directory for files to parse.
17+
18+
.PARAMETER Files
19+
The files to expand aliases in.
20+
21+
.EXAMPLE
22+
Expand-Aliases -Text "rm file.txt; gi file.exe"
23+
24+
Should be expanded to "Remove-Item file.txt; Get-Item file.exe"
25+
26+
.EXAMPLE
27+
Expand-Aliases -Directory .\tools -Filter "*.ps1"
28+
29+
Should traverse the tools directory relative to the current
30+
directory, and expand all aliases in files matching the specified filter.
31+
32+
.EXAMPLE
33+
Expand-Aliases -Files ".\file1.ps1","text-File.txt"
34+
35+
Should expand all aliases in the two specified files.
36+
37+
.LINK
38+
https://wormiecorp.github.io/Wormies-AU-Helpers/docs/functions/expand-aliases
39+
#>
40+
41+
function Expand-Aliases () {
42+
param(
43+
[Parameter(Mandatory = $true, ParameterSetName = 'text')]
44+
[string]$Text,
45+
[Parameter(Mandatory = $true, ParameterSetName = 'directory')]
46+
[string]$Directory,
47+
[Parameter(Mandatory = $false, ParameterSetName = 'directory')]
48+
[string]$Filter = "*.ps1",
49+
[Parameter(Mandatory = $true, ParameterSetName = 'files')]
50+
[string[]]$Files
51+
)
52+
53+
BEGIN {
54+
$moduleExists = Get-Module chocolateyInstaller -All -ErrorAction SilentlyContinue
55+
if (!$moduleExists) {
56+
Import-Module "$env:ChocolateyInstall\helpers\chocolateyInstaller.psm1" -ErrorAction SilentlyContinue -Force -WarningAction SilentlyContinue
57+
}
58+
$aliases = Get-Alias | Group-Object -AsHashTable -Property Name
59+
$ParserErrors = $null
60+
}
61+
62+
PROCESS {
63+
if ($directory -or $files) {
64+
$allFiles = if (!$files) {
65+
Get-ChildItem -LiteralPath $directory -Filter $filter -Recurse
66+
}
67+
else {
68+
$files | ForEach-Object { Get-Item $_ }
69+
}
70+
71+
foreach ($file in $allFiles) {
72+
$oldText = Get-Content -Path $file.FullName -Raw
73+
$text = Expand-AliasesInText -text $oldText -aliases $aliases -ParserErrors $ParserErrors
74+
if ($oldText -cne $text) {
75+
[System.IO.File]::WriteAllText($file.FullName, $text, [System.Text.Encoding]::UTF8)
76+
}
77+
}
78+
}
79+
else {
80+
$text = Expand-AliasesInText -text $text -aliases $aliases -ParserErrors $ParserErrors
81+
}
82+
}
83+
84+
END {
85+
if (!$moduleExists) {
86+
Remove-Module chocolateyInstaller -ErrorAction SilentlyContinue -Force
87+
}
88+
if (!$directory -and !$Files) {
89+
$Text
90+
}
91+
}
92+
}

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,12 @@
4848
4949
will output `5.0-beta-20171123` (the current date)
5050
51+
.NOTES
52+
While the parameter `NuspecFile` accepts globbing patterns,
53+
it is expected to only match a single file.
54+
5155
.LINK
52-
https://wormiecorp.github.io/docs/functions/get-fixversion
56+
https://wormiecorp.github.io/Wormies-AU-Helpers/docs/functions/get-fixversion
5357
#>
5458
function Get-FixVersion() {
5559
param(
@@ -60,6 +64,7 @@ function Get-FixVersion() {
6064
[string]$OnlyFixBelowVersion = $null,
6165
[Alias("AppendZeroes")]
6266
[int]$AppendRevisionLength = 1,
67+
[SupportsWildcards()]
6368
[string]$NuspecFile = "./*.nuspec"
6469
)
6570
function appendRevision {

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
1717
.OUTPUTS
1818
The redirected url when one is found, otherwise returns the same url that was passed.
19+
20+
.LINK
21+
https://wormiecorp.github.io/Wormies-AU-Helpers/docs/functions/get-redirectedurl
1922
#>
2023
function Get-RedirectedUrl {
2124
param(

Wormies-AU-Helpers/public/Update-Metadata.ps1

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ Update-Metadata -data @{ title = 'My Awesome Title' }
3030
@{ title = 'My Awesome Title' } | Update-Metadata
3131
3232
.NOTES
33-
Will throw an exception if the specified key doesn't exist in the nuspec file.
33+
Will throw an exception if the specified key doesn't exist in the nuspec file.
34+
35+
While the parameter `NuspecFile` accepts globbing patterns,
36+
it is expected to only match a single file.
37+
38+
.LINK
39+
https://wormiecorp.github.io/Wormies-AU-Helpers/docs/functions/update-metadata
3440
#>
3541
function Update-Metadata {
3642
param(
@@ -41,6 +47,7 @@ function Update-Metadata {
4147
[Parameter(Mandatory = $true, ParameterSetName = "Multiple", ValueFromPipeline = $true)]
4248
[hashtable]$data = @{$key = $value},
4349
[ValidateScript( { Test-Path $_ })]
50+
[SupportsWildcards()]
4451
[string]$NuspecFile = ".\*.nuspec"
4552
)
4653

@@ -49,7 +56,7 @@ function Update-Metadata {
4956
$nu = New-Object xml
5057
$nu.PSBase.PreserveWhitespace = $true
5158
$nu.Load($NuspecFile)
52-
$data.Keys | % {
59+
$data.Keys | ForEach-Object {
5360
if ($nu.package.metadata."$_") {
5461
$nu.package.metadata."$_" = $data[$_]
5562
}

chocolatey/Build-Package.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ if (!$res) { throw "Can't find markdown header 'Features' in the README.md" }
2323

2424
$features = $Matches[0]
2525
"Updating nuspec file"
26-
$repo = git remote get-url origin | % { $_ -replace '\.git$' }
26+
$repo = git remote get-url origin | ForEach-Object { $_ -replace '\.git$' }
2727
$nuspecBuildPath = $nuspecPath -replace "\.nuspec$", "_build.nuspec"
2828
[xml]$au = Get-Content $nuspecPath -Encoding UTF8
2929
$description = $au.package.metadata.summary + ".`n`n" + $features
@@ -46,13 +46,13 @@ else {
4646
$au.Save($nuspecBuildPath)
4747

4848
"Copying 7z archive"
49-
$archive = Get-ChildItem "$buildPath/$version/*${version}.7z" | % FullName
49+
$archive = Get-ChildItem "$buildPath/$version/*${version}.7z" | ForEach-Object FullName
5050
Copy-Item $archive $PSScriptRoot/tools/Wormies-AU-Helpers.7z
5151
Copy-Item $PSScriptRoot/../LICENSE $PSScriptRoot/legal/LICENSE.txt
5252

53-
$checksum = Get-FileHash $archive -Algorithm SHA256 | % Hash
53+
$checksum = Get-FileHash $archive -Algorithm SHA256 | ForEach-Object Hash
5454

55-
$content = Get-Content $PSScriptRoot/legal/VERIFICATION.txt -Encoding UTF8 | % {
55+
$content = Get-Content $PSScriptRoot/legal/VERIFICATION.txt -Encoding UTF8 | ForEach-Object {
5656
$_ -replace "\<.*\/tag\/[^\>]*\>", "<$repo/releases/tag/${version}>" `
5757
-replace "(checksum\:).*", "`${1} ${checksum}" `
5858
-replace "\<.*LICENSE\>", "<$($au.package.metadata.licenseUrl)>"

docs/build.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
##########################################################################
1+
##########################################################################
22
# This is the Cake bootstrapper script for PowerShell.
33
# This file was downloaded from https://github.com/cake-build/resources
44
# Feel free to change this file to fit your needs.
@@ -123,7 +123,7 @@ if (!(Test-Path $PACKAGES_CONFIG)) {
123123
if (!(Test-Path $NUGET_EXE)) {
124124
Write-Verbose -Message "Trying to find nuget.exe in PATH..."
125125
$existingPaths = $Env:Path -Split ';' | Where-Object { (![string]::IsNullOrEmpty($_)) -and (Test-Path $_ -PathType Container) }
126-
$NUGET_EXE_IN_PATH = Get-ChildItem -Path $existingPaths -Filter "nuget.exe" | Select -First 1
126+
$NUGET_EXE_IN_PATH = Get-ChildItem -Path $existingPaths -Filter "nuget.exe" | Select-Object -First 1
127127
if ($NUGET_EXE_IN_PATH -ne $null -and (Test-Path $NUGET_EXE_IN_PATH.FullName)) {
128128
Write-Verbose -Message "Found in PATH at $($NUGET_EXE_IN_PATH.FullName)."
129129
$NUGET_EXE = $NUGET_EXE_IN_PATH.FullName

docs/input/_Bottom.cshtml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<div class="github-button">
2+
<a href="https://github.com/WormieCorp/Wormies-AU-Helpers" target="_blank"><i class="fa fa-github"></i> GitHub</a>
3+
</div>
4+
5+
<script src="https://cdnjs.cloudflare.com/ajax/libs/anchor-js/4.1.0/anchor.min.js" integrity="sha256-lZaRhKri35AyJSypXXs4o6OPFTbTmUoltBbDCbdzegg=" crossorigin="anonymous"></script>
6+
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.7.1/clipboard.min.js" integrity="sha256-Daf8GuI2eLKHJlOWLRR/zRy9Clqcj4TUSumbxYH9kGI=" crossorigin="anonymous"></script>
7+
<script type="text/javascript" src="@Context.GetLink("/assets/js/setup.min.js")" data-assets-dir="@Context.GetLink("/assets")"></script>
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
/* Control the margin for bootstrap alert boxes */
2+
.alert > p {
3+
margin-top: 0px;
4+
}
5+
6+
.btn-copy {
7+
/* Control the look and feel of the copy box applied to code sections */
8+
&[disabled] .clippy {
9+
opacity: .3;
10+
}
11+
12+
pre & {
13+
-webkit-transition: opacity 0.3s ease-in-out;
14+
-o-transition: opacity 0.3s ease-in-out;
15+
-moz-transition: opacity 0.3s ease-in-out;
16+
transition: opacity 0.3s ease-in-out;
17+
opacity: 0;
18+
padding: 2px 6px;
19+
float: right;
20+
}
21+
22+
pre:hover & {
23+
opacity: 1;
24+
}
25+
}
26+
27+
.tooltipped {
28+
position: relative;
29+
30+
&:after, &:before {
31+
position: absolute;
32+
display: none;
33+
pointer-events: none;
34+
}
35+
36+
&:after {
37+
z-index: 1000000;
38+
padding: 5px 8px;
39+
font: normal normal 11px/1.5 Helvetica arial, nimbussans1, liberationsans, freesans, clean, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol";
40+
color: #fff;
41+
text-align: center;
42+
text-decoration: none;
43+
text-shadow: none;
44+
text-transform: none;
45+
letter-spacing: normal;
46+
word-wrap: break-word;
47+
white-space: pre;
48+
content: attr(aria-label);
49+
background: rgba(0, 0, 0, 0.8);
50+
border-radius: 3px;
51+
-webkit-font-smoothing: subpixel-antialiased;
52+
}
53+
54+
&:before {
55+
z-index: 1000001;
56+
width: 0;
57+
height: 0;
58+
color: rgba(0, 0, 0, 0.8);
59+
content: "";
60+
border: 5px solid transparent;
61+
}
62+
63+
&:hover, &:active, &:focus {
64+
&:before, &:after {
65+
display: inline-block;
66+
text-decoration: none;
67+
}
68+
}
69+
}
70+
71+
.tooltipped-s, .tooltipped-se, .tooltipped-sw {
72+
&:after {
73+
top: 100%;
74+
right: 50%;
75+
margin-top: 5px;
76+
}
77+
78+
&:before {
79+
top:auto;
80+
right: 50%;
81+
bottom: -5px;
82+
margin-right: -5px;
83+
border-bottom-color: rgba(0, 0, 0, 0.8);
84+
}
85+
}
86+
87+
@font-family-sans-serif: "Roboto", Helvetica, Arial, sans-serif;
88+
89+
/* For GitHub */
90+
.bottom-footer {
91+
margin-bottom: 40px !important; // Make room for the GitHub button
92+
}
93+
94+
.github-button {
95+
z-index: 100;
96+
position: fixed;
97+
bottom: 0px;
98+
right: 90px;
99+
padding: 1em 3em;
100+
background-color: #367fa9;
101+
border: 0;
102+
border-top-left-radius: 0.5em;
103+
border-top-right-radius: 0.5em;
104+
font-family: sans-serif;
105+
font-size: 9pt;
106+
text-transform: uppercase;
107+
text-align: center;
108+
text-decoration: none;
109+
cursor: pointer;
110+
cursor: hand;
111+
-webkit-transition: all .3s ease;
112+
-o-transition: all .3s ease;
113+
-moz-transition: all .3s ease;
114+
transition: all .3s ease;
115+
color: #fff;
116+
a, a:active, a:hover, a:focus {
117+
color: #fff;
118+
}
119+
120+
&:hover, &:focus {
121+
background-color: #4EABDD;
122+
color: #fff;
123+
}
124+
}

0 commit comments

Comments
 (0)