Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(versions): Refactor 'versions.ps1' #3721

Merged
merged 23 commits into from
Nov 13, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions lib/versions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,24 @@ function Get-LatestVersion {
Get latest version of app
.DESCRIPTION
Get latest version of app from manifest
.PARAMETER App
App's name
.PARAMETER Bucket
Bucket which the app is belong to
niheaven marked this conversation as resolved.
Show resolved Hide resolved
.PARAMETER URL
Remote app manifest's URI
#>
[OutputType([String])]
[CmdletBinding()]
param (
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)]
[String]
# App's name
$App,
[Parameter(Position = 1)]
[String]
# Bucket which the app is belong to
$Bucket,
[Parameter(Position = 2)]
[String]
# Remote app manifest's URI
$URL
)
return (manifest $App $Bucket $URL).version
Expand All @@ -31,17 +34,19 @@ function Select-CurrentVersion {
Select current version of app
.DESCRIPTION
Select current version of installed app, from 'current\manifest.json' or modified time of version directory
.PARAMETER App
App's name
.PARAMETER Global
If global installed
niheaven marked this conversation as resolved.
Show resolved Hide resolved
#>
[OutputType([String])]
[CmdletBinding()]
param (
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)]
[String]
# App's name
$App,
[Parameter(Position = 1)]
[Switch]
# If global installed
$Global
)

Expand All @@ -65,17 +70,19 @@ function Get-InstalledVersion {
Get installed version of app
.DESCRIPTION
Get all installed version of app, by checking version directories' 'install.json'
niheaven marked this conversation as resolved.
Show resolved Hide resolved
.PARAMETER App
App's name
.PARAMETER Global
If global installed
niheaven marked this conversation as resolved.
Show resolved Hide resolved
#>
[OutputType([Object[]])]
[CmdletBinding()]
param (
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)]
[String]
# App's name
$App,
[Parameter(Position = 1)]
[Switch]
# If global installed
$Global
)

Expand All @@ -96,6 +103,12 @@ function Compare-Version {
Compare versions
.DESCRIPTION
niheaven marked this conversation as resolved.
Show resolved Hide resolved
Compare versions, mainly according to SemVer's rules
niheaven marked this conversation as resolved.
Show resolved Hide resolved
.PARAMETER ReferenceVersion
Specifies a version used as a reference for comparison
.PARAMETER DifferenceVersion
Specifies the version that are compared to the reference version
.PARAMETER Delimiter
Specifies the delimiter of versions
.OUTPUTS
System.Int32
'0' if DifferenceVersion is equal to ReferenceVersion,
Expand All @@ -107,14 +120,11 @@ function Compare-Version {
param (
[Parameter(Position = 0)]
[String]
# Specifies a version used as a reference for comparison.
$ReferenceVersion,
[Parameter(Position = 1, ValueFromPipeline = $true)]
[String]
# Specifies the version that are compared to the reference version.
$DifferenceVersion,
[String]
# Specifies the delimiter of versions
$Delimiter = '-'
)

Expand Down