Skip to content

Commit

Permalink
Merge branch 'hotfix/0.4.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
AdmiringWorm committed Feb 23, 2021
2 parents 1c03f3d + ada5497 commit dac9ba0
Show file tree
Hide file tree
Showing 6 changed files with 298 additions and 238 deletions.
13 changes: 8 additions & 5 deletions Wormies-AU-Helpers/public/Get-FixVersion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@
version number isn't a 4-part version.
.EXAMPLE
Get-FixVersion -Version '24.0.0.195'
PS> Get-FixVersion -Version '24.0.0.195'
will output `24.0.0.19501` if the
nuspec version is equal to `24.0.0.195` or `24.0.0.19500` and
`$global:au_Force` is set to `$true`
.EXAMPLE
Get-FixVersion -Version '5.0-beta'
PS> Get-FixVersion -Version '5.0-beta'
will output `5.0-beta-20171123` (the current date)
Expand Down Expand Up @@ -133,16 +133,19 @@ function Get-FixVersion() {
if ($mainVersion -ge $belowVersion -and ($preRelease -ge $belowPreRelease)) {
if (!$preRelease -and ([string]$existingVersion).StartsWith($mainVersion)) {
return $existingVersion
}elseif (([string]$existingVersion).StartsWith("${mainVersion}${preRelease}")) {
}
elseif (([string]$existingVersion).StartsWith("${mainVersion}${preRelease}")) {
if ($global:au_Force -ne $true) { return $existingVersion }
}else {
}
else {
return $Version
}
}
elseif ($mainVersion -eq $belowVersion -and !$preRelease -and $belowVersion) {
if (([string]$existingVersion).StartsWith($mainVersion)) {
return $existingVersion
} else {
}
else {
return $Version
}
}
Expand Down
105 changes: 59 additions & 46 deletions Wormies-AU-Helpers/public/Update-Metadata.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,58 @@ $ErrorActionPreference = 'Stop'

<#
.SYNOPSIS
Updates the metadata nuspec file with the specified information.
Updates the metadata nuspec file with the specified information.
.DESCRIPTION
When a key and value is specified, update the metadata element with the specified key
and the corresponding value in the specified NuspecFile.
Singlular metadata elements are the only ones changed at this time.
When a key and value is specified, update the metadata element with the specified key
and the corresponding value in the specified NuspecFile.
Singlular metadata elements are the only ones changed at this time.
.PARAMETER key
The element that should be updated in the metadata section.
The element that should be updated in the metadata section.
.PARAMETER value
The value to update with.
The value to update with.
.PARAMETER NuspecFile
The metadata/nuspec file to update
The metadata/nuspec file to update
.EXAMPLE
Update-Metadata -key releaseNotes -value "https://github.com/majkinetor/AU/releases/latest"
PS> Update-Metadata -key releaseNotes -value "https://github.com/majkinetor/AU/releases/latest"
.EXAMPLE
Update-Metadata -key releaseNotes -value "https://github.com/majkinetor/AU/releases/latest" -NuspecFile ".\package.nuspec"
PS> Update-Metadata -key releaseNotes -value "https://github.com/majkinetor/AU/releases/latest" -NuspecFile ".\package.nuspec"
.EXAMPLE
This is an example of changing the Title of the nuspec file
Update-Metadata -data @{ title = 'My Awesome Title' }
- or -
@{ title = 'My Awesome Title' } | Update-Metadata
PS> @{ title = 'My Awesome Title' } | Update-Metadata
This is an example of changing the Title of the nuspec file
Update-Metadata -data @{ title = 'My Awesome Title' }
.EXAMPLE
This is an example of changing the id and version attributes for the dependency key
Update-Metadata -data @{ dependency = 'kb2919355|1.0.20160915' }
- or -
@{ dependency = 'kb2919355|1.0.20160915' } | Update-Metadata
PS> Update-Metadata -data @{ dependency = 'kb2919355|1.0.20160915' }
This is an example of changing the id and version attributes for the dependency key
.EXAMPLE
This is an example of changing the src and target attributes
Update-Metadata -data @{ file = 'tools\**,tools' }
- or -
@{ file = 'tools\**|tools' } | Update-Metadata
PS> @{ dependency = 'kb2919355|1.0.20160915' } | Update-Metadata
.EXAMPLE
PS> Update-Metadata -data @{ file = 'tools\**,tools' }
This is an example of changing the src and target attributes
.EXAMPLE
This is an example of changing the file src and target attributes for the first file element in the nuspec file.
If only one file element is found the change value is omitted.
@{ file = 'tools\**|tools,1' } | Update-Metadata
PS> @{ file = 'tools\**|tools' } | Update-Metadata
.EXAMPLE
PS> @{ file = 'tools\**|tools,1' } | Update-Metadata
This is an example of changing the file src and target attributes for the first file element in the nuspec file.
If only one file element is found the change value is omitted.
.INPUTS
A hashtable of key+value pairs can be used instead of specifically use an argument.
.NOTES
Will now show a warning if the specified key doesn't exist in the nuspec file.
Expand All @@ -56,6 +64,8 @@ If only one file element is found the change value is omitted.
While the parameter `NuspecFile` accepts globbing patterns,
it is expected to only match a single file.
The ability to update the file and dependency metadata was included in version 0.4.0.
.LINK
https://wormiecorp.github.io/Wormies-AU-Helpers/docs/functions/update-metadata
#>
Expand All @@ -66,7 +76,7 @@ function Update-Metadata {
[Parameter(Mandatory = $true, ParameterSetName = "Single")]
[string]$value,
[Parameter(Mandatory = $true, ParameterSetName = "Multiple", ValueFromPipeline = $true)]
[hashtable]$data = @{$key = $value},
[hashtable]$data = @{ $key = $value },
[ValidateScript( { Test-Path $_ })]
[SupportsWildcards()]
[string]$NuspecFile = ".\*.nuspec"
Expand All @@ -84,44 +94,46 @@ function Update-Metadata {
'^(file)$' {
$metaData = "files"
$NodeGroup = $nu.package.$metaData
$NodeData,[int]$change = $data[$_] -split (",")
$NodeData, [int]$change = $data[$_] -split (",")
$NodeCount = $nu.package.$metaData.ChildNodes.Count
$src,$target,$exclude = $NodeData -split ("\|")
$src, $target, $exclude = $NodeData -split ("\|")
$NodeAttributes = [ordered] @{
"src" = $src
"target" = $target
"exclude" = $exclude
}
$change = @{$true="0";$false=($change - 1)}[ ([string]::IsNullOrEmpty($change)) ]
"src" = $src
"target" = $target
"exclude" = $exclude
}
$change = @{$true = "0"; $false = ($change - 1) }[ ([string]::IsNullOrEmpty($change)) ]
if ($NodeCount -eq 3) {
$NodeGroup = $NodeGroup."$_"
} else {
}
else {
$NodeGroup = $NodeGroup.$_[$change]
}
}
'^(dependency)$' {
$MetaNode = $_ -replace("y","ies")
$MetaNode = $_ -replace ("y", "ies")
$metaData = "metadata"
$NodeData,[int]$change = $data[$_] -split (",")
$NodeData, [int]$change = $data[$_] -split (",")
$NodeGroup = $nu.package.$metaData.$MetaNode
$NodeCount = $nu.package.$metaData.$MetaNode.ChildNodes.Count
$id,$version,$include,$exclude = $NodeData -split ("\|")
$id, $version, $include, $exclude = $NodeData -split ("\|")
$NodeAttributes = [ordered] @{
"id" = $id
"version" = $version
"include" = $include
"exclude" = $exclude
}
$change = @{$true="0";$false=($change - 1)}[ ([string]::IsNullOrEmpty($change)) ]
"id" = $id
"version" = $version
"include" = $include
"exclude" = $exclude
}
$change = @{$true = "0"; $false = ($change - 1) }[ ([string]::IsNullOrEmpty($change)) ]
if ($NodeCount -eq 3) {
$NodeGroup = $NodeGroup."$_"
} else {
}
else {
$NodeGroup = $NodeGroup.$_[$change]
}
}
default {
if ( $nu.package.metadata."$_" ) {
$nu.package.metadata."$_" = $data[$_]
$nu.package.metadata."$_" = [string]$data[$_]
}
else {
Write-Warning "$_ does not exist on the metadata element in the nuspec file"
Expand All @@ -139,12 +151,13 @@ function Update-Metadata {
if (!([string]::IsNullOrEmpty($NodeAttributes[$attrib])) ) {
if (![string]::IsNullOrEmpty( $NodeGroup.Attributes ) ) {
$NodeGroup.SetAttribute($attrib, $NodeAttributes[$attrib] )
} else {
}
else {
Write-Warning "Attribute $attrib not defined for $_ in the nuspec file"
}
}
}
}
}
}

$utf8NoBom = New-Object System.Text.UTF8Encoding($false)
Expand Down
10 changes: 7 additions & 3 deletions docs/input/_Bottom.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
<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>
<script src="https://cdnjs.cloudflare.com/ajax/libs/anchor-js/4.3.0/anchor.min.js"
integrity="sha512-G2OGlm41XXw+fcgDcRPjVYEn7qCY6qiKWNqDGT37SnKh0qtRXTuKZ5/UQR0kDN0PZRNWcGExd3lAeqEH0I36bQ=="
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>
Loading

0 comments on commit dac9ba0

Please sign in to comment.