Skip to content

Commit

Permalink
Merge branch 'release/0.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
AdmiringWorm committed Jan 7, 2018
2 parents 1ec4e72 + 4d4ed0d commit 16c63b0
Show file tree
Hide file tree
Showing 24 changed files with 646 additions and 61 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![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)
[![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)

# Chocolatey Automatic Package Updater Helper Module

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

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

## Installation

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

To install it, use one of the following methods:
- PowerShell Gallery: [`Install-Module wormies-au-helpers`](https://www.powershellgallery.com/packages/Wormies-AU-Helpers)
- Chocolatey: [`choco install wormies-au-helpers`](https://chocolatey.org/packages/wormies-au-helpers)
- 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)
- [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)
- [![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`]
- [![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`]
- [![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`]
- 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)
26 changes: 26 additions & 0 deletions Wormies-AU-Helpers/private/Expand-AliasesInText.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
function Expand-AliasesInText {
[cmdletbinding(SupportsShouldProcess = $True)]
param(
[Parameter(Mandatory = $true)]
[string]$text,
[Parameter(Mandatory = $true)]
[hashtable]$aliases,
$ParserErrors = $null)

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

foreach ($cmd in $commands) {
$key = $cmd.Content
if ($aliases.Contains($key)) {
$alias = $aliases.$key
$old = $cmd.Content
$new = $alias.ResolvedCommandName
if ($PSCmdlet.ShouldProcess($old, "Expand alias to $new")) {
$text = $text.Remove($cmd.Start, $cmd.Content.Length).Insert($cmd.Start, $new)
}
}
}

return $text
}
92 changes: 92 additions & 0 deletions Wormies-AU-Helpers/public/Expand-Aliases.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<#
.SYNOPSIS
Expands the aliases in either the file or text passed to the function.
.DESCRIPTION
Any scripts in 'corporate' or 'formal' use should have any aliases expanded.
This this removes ambiguity and any potential clashes or errors.
.PARAMETER Text
The script text that should parsed for aliases to expand.
.PARAMETER Directory
The directory to use for parsing files.
.PARAMETER Filter
The filter to use when traversing a directory for files to parse.
.PARAMETER Files
The files to expand aliases in.
.EXAMPLE
Expand-Aliases -Text "rm file.txt; gi file.exe"
Should be expanded to "Remove-Item file.txt; Get-Item file.exe"
.EXAMPLE
Expand-Aliases -Directory .\tools -Filter "*.ps1"
Should traverse the tools directory relative to the current
directory, and expand all aliases in files matching the specified filter.
.EXAMPLE
Expand-Aliases -Files ".\file1.ps1","text-File.txt"
Should expand all aliases in the two specified files.
.LINK
https://wormiecorp.github.io/Wormies-AU-Helpers/docs/functions/expand-aliases
#>

function Expand-Aliases () {
param(
[Parameter(Mandatory = $true, ParameterSetName = 'text')]
[string]$Text,
[Parameter(Mandatory = $true, ParameterSetName = 'directory')]
[string]$Directory,
[Parameter(Mandatory = $false, ParameterSetName = 'directory')]
[string]$Filter = "*.ps1",
[Parameter(Mandatory = $true, ParameterSetName = 'files')]
[string[]]$Files
)

BEGIN {
$moduleExists = Get-Module chocolateyInstaller -All -ErrorAction SilentlyContinue
if (!$moduleExists) {
Import-Module "$env:ChocolateyInstall\helpers\chocolateyInstaller.psm1" -ErrorAction SilentlyContinue -Force -WarningAction SilentlyContinue
}
$aliases = Get-Alias | Group-Object -AsHashTable -Property Name
$ParserErrors = $null
}

PROCESS {
if ($directory -or $files) {
$allFiles = if (!$files) {
Get-ChildItem -LiteralPath $directory -Filter $filter -Recurse
}
else {
$files | ForEach-Object { Get-Item $_ }
}

foreach ($file in $allFiles) {
$oldText = Get-Content -Path $file.FullName -Raw
$text = Expand-AliasesInText -text $oldText -aliases $aliases -ParserErrors $ParserErrors
if ($oldText -cne $text) {
[System.IO.File]::WriteAllText($file.FullName, $text, [System.Text.Encoding]::UTF8)
}
}
}
else {
$text = Expand-AliasesInText -text $text -aliases $aliases -ParserErrors $ParserErrors
}
}

END {
if (!$moduleExists) {
Remove-Module chocolateyInstaller -ErrorAction SilentlyContinue -Force
}
if (!$directory -and !$Files) {
$Text
}
}
}
7 changes: 6 additions & 1 deletion Wormies-AU-Helpers/public/Get-FixVersion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@
will output `5.0-beta-20171123` (the current date)
.NOTES
While the parameter `NuspecFile` accepts globbing patterns,
it is expected to only match a single file.
.LINK
https://wormiecorp.github.io/docs/functions/get-fixversion
https://wormiecorp.github.io/Wormies-AU-Helpers/docs/functions/get-fixversion
#>
function Get-FixVersion() {
param(
Expand All @@ -60,6 +64,7 @@ function Get-FixVersion() {
[string]$OnlyFixBelowVersion = $null,
[Alias("AppendZeroes")]
[int]$AppendRevisionLength = 1,
[SupportsWildcards()]
[string]$NuspecFile = "./*.nuspec"
)
function appendRevision {
Expand Down
3 changes: 3 additions & 0 deletions Wormies-AU-Helpers/public/Get-RedirectedUrl.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
.OUTPUTS
The redirected url when one is found, otherwise returns the same url that was passed.
.LINK
https://wormiecorp.github.io/Wormies-AU-Helpers/docs/functions/get-redirectedurl
#>
function Get-RedirectedUrl {
param(
Expand Down
11 changes: 9 additions & 2 deletions Wormies-AU-Helpers/public/Update-Metadata.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ Update-Metadata -data @{ title = 'My Awesome Title' }
@{ title = 'My Awesome Title' } | Update-Metadata
.NOTES
Will throw an exception if the specified key doesn't exist in the nuspec file.
Will throw an exception if the specified key doesn't exist in the nuspec file.
While the parameter `NuspecFile` accepts globbing patterns,
it is expected to only match a single file.
.LINK
https://wormiecorp.github.io/Wormies-AU-Helpers/docs/functions/update-metadata
#>
function Update-Metadata {
param(
Expand All @@ -41,6 +47,7 @@ function Update-Metadata {
[Parameter(Mandatory = $true, ParameterSetName = "Multiple", ValueFromPipeline = $true)]
[hashtable]$data = @{$key = $value},
[ValidateScript( { Test-Path $_ })]
[SupportsWildcards()]
[string]$NuspecFile = ".\*.nuspec"
)

Expand All @@ -49,7 +56,7 @@ function Update-Metadata {
$nu = New-Object xml
$nu.PSBase.PreserveWhitespace = $true
$nu.Load($NuspecFile)
$data.Keys | % {
$data.Keys | ForEach-Object {
if ($nu.package.metadata."$_") {
$nu.package.metadata."$_" = $data[$_]
}
Expand Down
8 changes: 4 additions & 4 deletions chocolatey/Build-Package.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if (!$res) { throw "Can't find markdown header 'Features' in the README.md" }

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

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

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

$content = Get-Content $PSScriptRoot/legal/VERIFICATION.txt -Encoding UTF8 | % {
$content = Get-Content $PSScriptRoot/legal/VERIFICATION.txt -Encoding UTF8 | ForEach-Object {
$_ -replace "\<.*\/tag\/[^\>]*\>", "<$repo/releases/tag/${version}>" `
-replace "(checksum\:).*", "`${1} ${checksum}" `
-replace "\<.*LICENSE\>", "<$($au.package.metadata.licenseUrl)>"
Expand Down
4 changes: 2 additions & 2 deletions docs/build.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##########################################################################
##########################################################################
# This is the Cake bootstrapper script for PowerShell.
# This file was downloaded from https://github.com/cake-build/resources
# Feel free to change this file to fit your needs.
Expand Down Expand Up @@ -123,7 +123,7 @@ if (!(Test-Path $PACKAGES_CONFIG)) {
if (!(Test-Path $NUGET_EXE)) {
Write-Verbose -Message "Trying to find nuget.exe in PATH..."
$existingPaths = $Env:Path -Split ';' | Where-Object { (![string]::IsNullOrEmpty($_)) -and (Test-Path $_ -PathType Container) }
$NUGET_EXE_IN_PATH = Get-ChildItem -Path $existingPaths -Filter "nuget.exe" | Select -First 1
$NUGET_EXE_IN_PATH = Get-ChildItem -Path $existingPaths -Filter "nuget.exe" | Select-Object -First 1
if ($NUGET_EXE_IN_PATH -ne $null -and (Test-Path $NUGET_EXE_IN_PATH.FullName)) {
Write-Verbose -Message "Found in PATH at $($NUGET_EXE_IN_PATH.FullName)."
$NUGET_EXE = $NUGET_EXE_IN_PATH.FullName
Expand Down
7 changes: 7 additions & 0 deletions docs/input/_Bottom.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div class="github-button">
<a href="https://github.com/WormieCorp/Wormies-AU-Helpers" target="_blank"><i class="fa fa-github"></i> GitHub</a>
</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/anchor-js/4.1.0/anchor.min.js" integrity="sha256-lZaRhKri35AyJSypXXs4o6OPFTbTmUoltBbDCbdzegg=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.7.1/clipboard.min.js" integrity="sha256-Daf8GuI2eLKHJlOWLRR/zRy9Clqcj4TUSumbxYH9kGI=" crossorigin="anonymous"></script>
<script type="text/javascript" src="@Context.GetLink("/assets/js/setup.min.js")" data-assets-dir="@Context.GetLink("/assets")"></script>
124 changes: 124 additions & 0 deletions docs/input/assets/css/override.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/* Control the margin for bootstrap alert boxes */
.alert > p {
margin-top: 0px;
}

.btn-copy {
/* Control the look and feel of the copy box applied to code sections */
&[disabled] .clippy {
opacity: .3;
}

pre & {
-webkit-transition: opacity 0.3s ease-in-out;
-o-transition: opacity 0.3s ease-in-out;
-moz-transition: opacity 0.3s ease-in-out;
transition: opacity 0.3s ease-in-out;
opacity: 0;
padding: 2px 6px;
float: right;
}

pre:hover & {
opacity: 1;
}
}

.tooltipped {
position: relative;

&:after, &:before {
position: absolute;
display: none;
pointer-events: none;
}

&:after {
z-index: 1000000;
padding: 5px 8px;
font: normal normal 11px/1.5 Helvetica arial, nimbussans1, liberationsans, freesans, clean, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol";
color: #fff;
text-align: center;
text-decoration: none;
text-shadow: none;
text-transform: none;
letter-spacing: normal;
word-wrap: break-word;
white-space: pre;
content: attr(aria-label);
background: rgba(0, 0, 0, 0.8);
border-radius: 3px;
-webkit-font-smoothing: subpixel-antialiased;
}

&:before {
z-index: 1000001;
width: 0;
height: 0;
color: rgba(0, 0, 0, 0.8);
content: "";
border: 5px solid transparent;
}

&:hover, &:active, &:focus {
&:before, &:after {
display: inline-block;
text-decoration: none;
}
}
}

.tooltipped-s, .tooltipped-se, .tooltipped-sw {
&:after {
top: 100%;
right: 50%;
margin-top: 5px;
}

&:before {
top:auto;
right: 50%;
bottom: -5px;
margin-right: -5px;
border-bottom-color: rgba(0, 0, 0, 0.8);
}
}

@font-family-sans-serif: "Roboto", Helvetica, Arial, sans-serif;

/* For GitHub */
.bottom-footer {
margin-bottom: 40px !important; // Make room for the GitHub button
}

.github-button {
z-index: 100;
position: fixed;
bottom: 0px;
right: 90px;
padding: 1em 3em;
background-color: #367fa9;
border: 0;
border-top-left-radius: 0.5em;
border-top-right-radius: 0.5em;
font-family: sans-serif;
font-size: 9pt;
text-transform: uppercase;
text-align: center;
text-decoration: none;
cursor: pointer;
cursor: hand;
-webkit-transition: all .3s ease;
-o-transition: all .3s ease;
-moz-transition: all .3s ease;
transition: all .3s ease;
color: #fff;
a, a:active, a:hover, a:focus {
color: #fff;
}

&:hover, &:focus {
background-color: #4EABDD;
color: #fff;
}
}
3 changes: 3 additions & 0 deletions docs/input/assets/images/clippy.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 16c63b0

Please sign in to comment.