Skip to content

Commit

Permalink
(majkinetorGH-234) Expand all aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCakeIsNaOH committed Jan 29, 2021
1 parent 3793d0a commit 9080a00
Show file tree
Hide file tree
Showing 39 changed files with 287 additions and 287 deletions.
18 changes: 9 additions & 9 deletions AU/Plugins/Git.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ param(
if ($packages.Length -eq 0) { Write-Host "No package updated, skipping"; return }

$root = Split-Path $packages[0].Path
pushd $root
Push-Location $root
$origin = git config --get remote.origin.url
$origin -match '(?<=:/+)[^/]+' | Out-Null
$machine = $Matches[0]

if ($User -and $Password) {
Write-Host "Setting credentials for: $machine"

if ( "machine $server" -notmatch (gc ~/_netrc)) {
if ( "machine $server" -notmatch (Get-Content ~/_netrc)) {
Write-Host "Credentials already found for machine: $machine"
}
"machine $machine", "login $User", "password $Password" | Out-File -Append ~/_netrc -Encoding ascii
Expand All @@ -54,15 +54,15 @@ git pull -q origin $Branch


if ($commitStrategy -like 'atomic*') {
$packages | % {
$packages | ForEach-Object {
Write-Host "Adding update package to git repository: $($_.Name)"
git add -u $_.Path
git status

Write-Host "Commiting $($_.Name)"
$message = "AU: $($_.Name) upgraded from $($_.NuspecVersion) to $($_.RemoteVersion)"
$gist_url = $Info.plugin_results.Gist -split '\n' | select -Last 1
$snippet_url = $Info.plugin_results.Snippet -split '\n' | select -Last 1
$gist_url = $Info.plugin_results.Gist -split '\n' | Select-Object -Last 1
$snippet_url = $Info.plugin_results.Snippet -split '\n' | Select-Object -Last 1
git commit -m "$message`n[skip ci] $gist_url $snippet_url" --allow-empty

if ($commitStrategy -eq 'atomictag') {
Expand All @@ -73,13 +73,13 @@ if ($commitStrategy -like 'atomic*') {
}
else {
Write-Host "Adding updated packages to git repository: $( $packages | % Name)"
$packages | % { git add -u $_.Path }
$packages | ForEach-Object { git add -u $_.Path }
git status

Write-Host "Commiting"
$message = "AU: $($packages.Length) updated - $($packages | % Name)"
$gist_url = $Info.plugin_results.Gist -split '\n' | select -Last 1
$snippet_url = $Info.plugin_results.Snippet -split '\n' | select -Last 1
$gist_url = $Info.plugin_results.Gist -split '\n' | Select-Object -Last 1
$snippet_url = $Info.plugin_results.Snippet -split '\n' | Select-Object -Last 1
git commit -m "$message`n[skip ci] $gist_url $snippet_url" --allow-empty

}
Expand All @@ -89,4 +89,4 @@ if ($commitStrategy -eq 'atomictag') {
write-host 'Atomic Tag Push'
git push -q --tags
}
popd
Pop-Location
16 changes: 8 additions & 8 deletions AU/Plugins/GitLab.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ if ($packages.Length -eq 0) { Write-Host "No package updated, skipping"; return

$root = Split-Path $packages[0].Path

pushd $root
Push-Location $root
$origin = git config --get remote.origin.url
$origin -match '(?<=:/+)[^/]+' | Out-Null
$machine = $Matches[0]
Expand Down Expand Up @@ -66,15 +66,15 @@ git pull -q origin $Branch

### Commit
if ($commitStrategy -like 'atomic*') {
$packages | % {
$packages | ForEach-Object {
Write-Host "Adding update package to git repository: $($_.Name)"
git add -u $_.Path
git status

Write-Host "Commiting $($_.Name)"
$message = "AU: $($_.Name) upgraded from $($_.NuspecVersion) to $($_.RemoteVersion)"
$gist_url = $Info.plugin_results.Gist -split '\n' | select -Last 1
$snippet_url = $Info.plugin_results.Snippet -split '\n' | select -Last 1
$gist_url = $Info.plugin_results.Gist -split '\n' | Select-Object -Last 1
$snippet_url = $Info.plugin_results.Snippet -split '\n' | Select-Object -Last 1
git commit -m "$message`n[skip ci] $gist_url $snippet_url" --allow-empty

if ($commitStrategy -eq 'atomictag') {
Expand All @@ -85,13 +85,13 @@ if ($commitStrategy -like 'atomic*') {
}
else {
Write-Host "Adding updated packages to git repository: $( $packages | % Name)"
$packages | % { git add -u $_.Path }
$packages | ForEach-Object { git add -u $_.Path }
git status

Write-Host "Commiting"
$message = "AU: $($packages.Length) updated - $($packages | % Name)"
$gist_url = $Info.plugin_results.Gist -split '\n' | select -Last 1
$snippet_url = $Info.plugin_results.Snippet -split '\n' | select -Last 1
$gist_url = $Info.plugin_results.Gist -split '\n' | Select-Object -Last 1
$snippet_url = $Info.plugin_results.Snippet -split '\n' | Select-Object -Last 1
git commit -m "$message`n[skip ci] $gist_url $snippet_url" --allow-empty

}
Expand All @@ -103,6 +103,6 @@ if ($commitStrategy -eq 'atomictag') {
write-host 'Atomic Tag Push'
git push -q --tags
}
popd
Pop-Location

git remote set-url origin $origin
10 changes: 5 additions & 5 deletions AU/Plugins/GitReleases.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function GetOrCreateRelease() {

try {
Write-Verbose "Checking for a release using the tag: $tagName..."
$response = Invoke-RestMethod -UseBasicParsing -Uri "https://api.github.com/repos/$repository/releases/tags/$tagName" -Headers $headers | ? tag_name -eq $tagName
$response = Invoke-RestMethod -UseBasicParsing -Uri "https://api.github.com/repos/$repository/releases/tags/$tagName" -Headers $headers | Where-Object tag_name -eq $tagName
if ($response) {
return $response
}
Expand All @@ -68,9 +68,9 @@ if ($packages.Length -eq 0) { Write-Host "No package updated, skipping"; return

$packagesToRelease = New-Object 'System.Collections.Generic.List[hashtable]'

$packages | % {
$packages | ForEach-Object {
if ($_.Streams) {
$_.Streams.Values | ? { $_.Updated } | % {
$_.Streams.Values | Where-Object { $_.Updated } | ForEach-Object {
$packagesToRelease.Add(@{
Name = $_.Name
NuspecVersion = $_.NuspecVersion
Expand Down Expand Up @@ -134,7 +134,7 @@ if ($releaseType -eq 'date') {
$uploadHeaders = $headers.Clone()
$uploadHeaders['Content-Type'] = 'application/zip'

$packagesToRelease | % {
$packagesToRelease | ForEach-Object {
# Because we grab all streams previously, we need to ignore
# cases when a stream haven't been updated (no nupkg file created)
if (!$_.NuFile) { return }
Expand All @@ -153,7 +153,7 @@ $packagesToRelease | % {

$fileName = [System.IO.Path]::GetFileName($_.NuFile)

$existing = $release.assets | ? name -eq $fileName
$existing = $release.assets | Where-Object name -eq $fileName
if ($existing) {
Write-Verbose "Removing existing $fileName asset..."
Invoke-RestMethod -UseBasicParsing -Uri $existing.url -method Delete -Headers $headers | Out-Null
Expand Down
2 changes: 1 addition & 1 deletion AU/Plugins/Gitter.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if (!$WebHookUrl) { return } # If we don't have a webhookurl we can't push statu
$updatedPackages = @($Info.result.updated).Count
$publishedPackages = @($Info.result.pushed).Count
$failedPackages = $Info.error_count.total
$gistUrl = $Info.plugin_results.Gist -split '\n' | select -Last 1
$gistUrl = $Info.plugin_results.Gist -split '\n' | Select-Object -Last 1
$packageCount = $Info.result.all.Length

$gitterMessage = ($MessageFormat -f $packageCount, $updatedPackages, $publishedPackages, $failedPackages, $gistUrl)
Expand Down
6 changes: 3 additions & 3 deletions AU/Plugins/History.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Write-Host "Saving history to $Path"

$res=[System.Collections.Specialized.OrderedDictionary]@{}
$log = git --no-pager log -q --grep '^AU: ' --date iso | Out-String
$all_commits = $log | sls 'commit(.|\n)+?(?=\ncommit )' -AllMatches
$all_commits = $log | Select-String 'commit(.|\n)+?(?=\ncommit )' -AllMatches
foreach ($commit in $all_commits.Matches.Value) {
$commit = $commit -split '\n'

Expand All @@ -37,7 +37,7 @@ foreach ($commit in $all_commits.Matches.Value) {
$report = $commit[5].Replace('[skip ci]','').Trim()
[array] $packages = ($commit[4] -replace '^\s+AU:.+?(-|:) |\[skip ci\]').Trim().ToLower()

$packages_md = $packages -split ' ' | % {
$packages_md = $packages -split ' ' | ForEach-Object {
$first = $_.Substring(0,1).ToUpper(); $rest = $_.Substring(1)
if ($report) {
"[$first]($report)[$rest](https://github.com/$Github_UserRepo/commit/$id)"
Expand All @@ -50,7 +50,7 @@ foreach ($commit in $all_commits.Matches.Value) {
$res.$date += $packages_md
}

$res = $res.Keys | select -First $Lines | % { $r=[System.Collections.Specialized.OrderedDictionary]@{} } { $r[$_] = $res[$_] } {$r}
$res = $res.Keys | Select-Object -First $Lines | ForEach-Object { $r=[System.Collections.Specialized.OrderedDictionary]@{} } { $r[$_] = $res[$_] } {$r}

$history = @"
# Update History
Expand Down
2 changes: 1 addition & 1 deletion AU/Plugins/Mail.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ $($info.error_info | Out-String)
"@
}

$Attachment | % { if ($_) { $msg.Attachments.Add($_)} }
$Attachment | ForEach-Object { if ($_) { $msg.Attachments.Add($_)} }

# Send mail message
$smtp = new-object Net.Mail.SmtpClient($Server)
Expand Down
8 changes: 4 additions & 4 deletions AU/Plugins/Report/markdown.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ $Title = if ($Params.Title) { $Params.Title } else { 'Update-AUPackag
#=======================================================================================

$now = $Info.startTime.ToUniversalTime().ToString('yyyy-MM-dd HH:mm')
$au_version = gmo au -ListAvailable | % Version | select -First 1 | % { "$_" }
$au_version = Get-Module au -ListAvailable | ForEach-Object Version | Select-Object -First 1 | ForEach-Object { "$_" }
$package_no = $Info.result.all.Length

$update_all_url = if ($Github_UserRepo) {"https://github.com/$Github_UserRepo/blob/master/update_all.ps1" } else { "https://github.com/majkinetor/au-packages-template/blob/master/update_all.ps1" }
Expand Down Expand Up @@ -55,8 +55,8 @@ if ($Info.pushed) {

if ($Info.error_count.total) {
md_title Errors
md_table $Info.result.errors -Columns ($columns + 'Error' | ? { ('Updated', 'Pushed') -notcontains $_ } )
$Info.result.errors | % {
md_table $Info.result.errors -Columns ($columns + 'Error' | Where-Object { ('Updated', 'Pushed') -notcontains $_ } )
$Info.result.errors | ForEach-Object {
md_title $_.Name -Level 3
md_code "$($_.Error)"
}
Expand All @@ -70,7 +70,7 @@ if ($Info.result.ignored) {
if ($Info.result.ok) {
md_title OK
md_table $Info.result.ok -Columns $columns
$Info.result.ok | % {
$Info.result.ok | ForEach-Object {
md_title $_.Name -Level 3
md_code $_.Result
}
Expand Down
10 changes: 5 additions & 5 deletions AU/Plugins/Report/markdown_funcs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ function md_code($Text) {
function md_table($result, $Columns, $MaxErrorLength=150) {
if (!$Columns) { $Columns = 'Name', 'Updated', 'Pushed', 'RemoteVersion', 'NuspecVersion', 'Error' }
$res = '|' + ($Columns -join '|') + "|`r`n"
$res += ((1..$Columns.Length | % { '|---' }) -join '') + "|`r`n"
$res += ((1..$Columns.Length | ForEach-Object { '|---' }) -join '') + "|`r`n"

$result | % {
$o = $_ | select `
$result | ForEach-Object {
$o = $_ | Select-Object `
@{ N='Icon'
E={'<img src="{0}" width="{1}" height="{1}"/>' -f $_.NuspecXml.package.metadata.iconUrl, $IconSize }
},
Expand All @@ -32,7 +32,7 @@ function md_table($result, $Columns, $MaxErrorLength=150) {
$r = "[{0}](#{1})" -f $_.Updated, $_.Name.Replace('.','').ToLower()
$r += if ($_.Updated) { ' &#x1F538;' }
$r += if ($_.Streams) { ' &#x1F544;' }
$r += if (ls $_.Path -Recurse -Include VERIFICATION.txt) { ' &#x1F4E5;' }
$r += if (Get-ChildItem $_.Path -Recurse -Include VERIFICATION.txt) { ' &#x1F4E5;' }
$r
}
},
Expand All @@ -55,7 +55,7 @@ function md_table($result, $Columns, $MaxErrorLength=150) {
'Ignored',
'IgnoreMessage'

$res += ((1..$Columns.Length | % { $col = $Columns[$_-1]; '|' + $o.$col }) -join '') + "|`r`n"
$res += ((1..$Columns.Length | ForEach-Object { $col = $Columns[$_-1]; '|' + $o.$col }) -join '') + "|`r`n"
}

$res
Expand Down
20 changes: 10 additions & 10 deletions AU/Plugins/Report/text.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ $Title = if ($Params.Title) { $Params.Title } else { 'Update-AUPackages'
#==============================================================================

function title($txt) { "`r`n{0}`r`n{1}`r`n" -f $txt,('-'*$txt.Length) }
function indent($txt, $level=4) { $txt -split "`n" | % { ' '*$level + $_ } }
function indent($txt, $level=4) { $txt -split "`n" | ForEach-Object { ' '*$level + $_ } }

$now = $Info.startTime.ToUniversalTime().ToString('yyyy-MM-dd HH:mm')
$au_version = gmo au -ListAvailable | % Version | select -First 1 | % { "$_" }
$au_version = Get-Module au -ListAvailable | ForEach-Object Version | Select-Object -First 1 | ForEach-Object { "$_" }
$package_no = $Info.result.all.Length

"{0,-15}{1}" -f 'Title:', $Title
Expand All @@ -28,33 +28,33 @@ else {

if ($Info.pushed) {
title Pushed
$Info.result.pushed | select 'Name', 'Updated', 'Pushed', 'RemoteVersion', 'NuspecVersion' | ft | Out-String | set r
$Info.result.pushed | Select-Object 'Name', 'Updated', 'Pushed', 'RemoteVersion', 'NuspecVersion' | Format-Table | Out-String | Set-Variable r
indent $r 2

$Info.result.pushed | % { $_.Name; indent $_.Result; "" }
$Info.result.pushed | ForEach-Object { $_.Name; indent $_.Result; "" }
}

if ($Info.error_count.total) {
title Errors
$Info.result.errors | select 'Name', 'NuspecVersion', 'Error' | ft | Out-String | set r
$Info.result.errors | Select-Object 'Name', 'NuspecVersion', 'Error' | Format-Table | Out-String | Set-Variable r
indent $r 2

$Info.result.errors | % { $_.Name; indent $_.Error; "" }
$Info.result.errors | ForEach-Object { $_.Name; indent $_.Error; "" }
}


if ($Info.result.ignored) {
title Ignored
$Info.result.ignored | ft | select 'Name', 'NuspecVersion', 'IgnoreMessage' | ft | Out-String | set r
$Info.result.ignored | Format-Table | Select-Object 'Name', 'NuspecVersion', 'IgnoreMessage' | Format-Table | Out-String | Set-Variable r
indent $r 2
}

$ok = $Info.result.ok | ? { !$_.Pushed }
$ok = $Info.result.ok | Where-Object { !$_.Pushed }
if ($ok) {
title OK
$ok | select 'Name', 'Updated', 'RemoteVersion', 'NuspecVersion' | ft | Out-String | set r
$ok | Select-Object 'Name', 'Updated', 'RemoteVersion', 'NuspecVersion' | Format-Table | Out-String | Set-Variable r
indent $r 2

$ok | % { $_.Name; indent $_.Result; "" }
$ok | ForEach-Object { $_.Name; indent $_.Result; "" }
}

4 changes: 2 additions & 2 deletions AU/Plugins/Snippet.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ param(
)

# Create snippet
ls $Path | % {
Get-ChildItem $Path | ForEach-Object {
$file_name = Split-Path $_ -Leaf
$content = gc $_ -Raw
$content = Get-Content $_ -Raw
$snippet = '{"content": "' + $content + '"}'
}

Expand Down
22 changes: 11 additions & 11 deletions AU/Private/AUPackage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AUPackage {
$this.Name = Split-Path -Leaf $Path

$this.NuspecPath = '{0}\{1}.nuspec' -f $this.Path, $this.Name
if (!(gi $this.NuspecPath -ea ignore)) { throw 'No nuspec file found in the package directory' }
if (!(Get-Item $this.NuspecPath -ea ignore)) { throw 'No nuspec file found in the package directory' }

$this.NuspecXml = [AUPackage]::LoadNuspecFile( $this.NuspecPath )
$this.NuspecVersion = $this.NuspecXml.package.metadata.version
Expand Down Expand Up @@ -55,7 +55,7 @@ class AUPackage {
if (!(Test-Path $streamsPath)) { return $null }
$res = [System.Collections.Specialized.OrderedDictionary] @{}
$versions = Get-Content $streamsPath | ConvertFrom-Json
$versions.psobject.Properties | % {
$versions.psobject.Properties | ForEach-Object {
$stream = $_.Name
$res.Add($stream, @{ NuspecVersion = $versions.$stream })
}
Expand All @@ -69,7 +69,7 @@ class AUPackage {
if (!$this.Streams.Contains($s)) { $this.Streams.$s = @{} }
if ($this.Streams.$s -ne 'ignore') { $this.Streams.$s.NuspecVersion = $v }
$versions = [System.Collections.Specialized.OrderedDictionary] @{}
$this.Streams.Keys | % {
$this.Streams.Keys | ForEach-Object {
$versions.Add($_, $this.Streams.$_.NuspecVersion)
}
$versions | ConvertTo-Json | Set-Content $this.StreamsPath -Encoding UTF8
Expand All @@ -78,36 +78,36 @@ class AUPackage {
Backup() {
$d = "$Env:TEMP\au\" + $this.Name

rm $d\* -Recurse -ea 0
cp . $d\_backup -Recurse
Remove-Item $d\* -Recurse -ea 0
Copy-Item . $d\_backup -Recurse
}

[string] SaveAndRestore() {
$d = "$Env:TEMP\au\" + $this.Name

cp . $d\_output -Recurse
rm .\* -Recurse
cp $d\_backup\* . -Recurse
Copy-Item . $d\_output -Recurse
Remove-Item .\* -Recurse
Copy-Item $d\_backup\* . -Recurse

return "$d\_output"
}

AUPackage( [hashtable] $obj ) {
if (!$obj) { throw 'Obj can not be empty' }
$obj.Keys | ? { $_ -ne 'Streams' } | % {
$obj.Keys | Where-Object { $_ -ne 'Streams' } | ForEach-Object {
$this.$_ = $obj.$_
}
if ($obj.Streams) {
$this.Streams = [System.Collections.Specialized.OrderedDictionary] @{}
$obj.Streams.psobject.Properties | % {
$obj.Streams.psobject.Properties | ForEach-Object {
$this.Streams.Add($_.Name, $_.Value)
}
}
}

[hashtable] Serialize() {
$res = @{}
$this | Get-Member -Type Properties | ? { $_.Name -ne 'Streams' } | % {
$this | Get-Member -Type Properties | Where-Object { $_.Name -ne 'Streams' } | ForEach-Object {
$property = $_.Name
$res.Add($property, $this.$property)
}
Expand Down
Loading

0 comments on commit 9080a00

Please sign in to comment.