-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
646 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.