-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from pwsh-cs-tools/feat-v0.5.0
Features: 0.5.0 - Add caching of -Path packages and add support for SemVer2 packages
- Loading branch information
Showing
8 changed files
with
463 additions
and
82 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
publish.ps1 | ||
*.dll | ||
*.dll | ||
Import-Package/Packages | ||
Import-Package/Temp |
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,84 @@ | ||
# Custom function to convert SemVer string to a comparable object | ||
# Using this over Automation.SemanticVersion, since Automation.SemanticVersion only works in pwsh 7.2+ | ||
function ConvertTo-SemVerObject( [string]$semVerString ) { | ||
|
||
$semVerParts = $semVerString -split '[-\+]' | ||
If( $semVerParts.Count -gt 2 ){ | ||
$semVerParts = @( | ||
$semVerParts[0], | ||
(($semVerParts | Select-Object -Skip 1) -join "-") | ||
) | ||
} | ||
$versionParts = $semVerParts[0] -split '\.' | ||
|
||
$versionParts = $versionParts | ForEach-Object { | ||
[int]$_ | ||
} | ||
|
||
# Convert main version parts to integers | ||
$major = $versionParts[0] | ||
$minor = $versionParts[1] | ||
$patch = $versionParts[2] | ||
$legacyPrerelease = If( $versionParts.Count -gt 3 ){ | ||
$versionParts[3..($versionParts.Length-1)] | ||
} | ||
|
||
$preRelease = $null | ||
if ($semVerParts.Length -gt 1) { | ||
$preRelease = $semVerParts[1] | ||
} | ||
|
||
# Create a custom object | ||
New-Object PSObject -Property @{ | ||
Major = $major | ||
Minor = $minor | ||
Patch = $patch | ||
LegacyPrerelease = $legacyPrerelease | ||
PreRelease = $preRelease | ||
Original = $semVerString | ||
} | ||
|
||
} | ||
|
||
# Custom comparison function for SemVer | ||
function Compare-SemVerObject($x, $y) { | ||
if ($x.Major -ne $y.Major) { | ||
return $x.Major - $y.Major | ||
} | ||
if ($x.Minor -ne $y.Minor) { | ||
return $x.Minor - $y.Minor | ||
} | ||
if ($x.Patch -ne $y.Patch) { | ||
return $x.Patch - $y.Patch | ||
} | ||
if ($x.LegacyPrerelease -and $y.LegacyPrerelease){ | ||
$max_length = [Math]::Max( | ||
$x.LegacyPrerelease.Count, | ||
$y.LegacyPrerelease.Count | ||
) | ||
for ($i = 0; $i -lt $max_length; $i++) { | ||
$xlp = $x.LegacyPrerelease[ $i ] | ||
$ylp = $y.LegacyPrerelease[ $i ] | ||
If( $null -eq $xlp ){ | ||
return 1 | ||
} | ||
If( $null -eq $ylp ){ | ||
return -1 | ||
} | ||
If( $xlp -ne $ylp ){ | ||
return $xlp - $ylp | ||
} | ||
} | ||
} | ||
# Handle pre-release comparison | ||
if ($x.PreRelease -and $y.PreRelease) { | ||
return [string]::Compare($x.PreRelease, $y.PreRelease) | ||
} | ||
if ($x.PreRelease) { | ||
return -1 | ||
} | ||
if ($y.PreRelease) { | ||
return 1 | ||
} | ||
return 0 | ||
} |
Oops, something went wrong.