-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetNovaVersionUpdatePlan.ps1
More file actions
69 lines (57 loc) · 2.23 KB
/
Copy pathGetNovaVersionUpdatePlan.ps1
File metadata and controls
69 lines (57 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
function Get-NovaVersionUpdatePlan {
[CmdletBinding()]
param(
[ValidateSet('Major', 'Minor', 'Patch')]
[string]$Label = 'Patch',
[switch]$PreviewRelease,
[switch]$StableRelease,
[pscustomobject]$ProjectInfo
)
$projectInfo = Get-NovaVersionUpdateProjectInfo -ProjectInfo $ProjectInfo
$currentVersion = Get-NovaCurrentVersionForUpdatePlan -ProjectInfo $projectInfo
$versionPart = Get-NovaVersionPartForUpdatePlan -CurrentVersion $currentVersion -Label $Label -PreviewRelease:$PreviewRelease
$releaseType = Get-NovaVersionPreReleaseLabel -CurrentVersion $currentVersion -PreviewRelease:$PreviewRelease -StableRelease:$StableRelease
$newVersion = [semver]::new($versionPart.Major, $versionPart.Minor, $versionPart.Patch, $releaseType, $null)
return [pscustomobject]@{
ProjectFile = $projectInfo.ProjectJSON
CurrentVersion = $currentVersion
NewVersion = $newVersion
}
}
function Get-NovaVersionUpdateProjectInfo {
[CmdletBinding()]
param(
[pscustomobject]$ProjectInfo
)
if ($null -ne $ProjectInfo) {
return $ProjectInfo
}
return Get-NovaProjectInfo
}
function Get-NovaCurrentVersionForUpdatePlan {
[CmdletBinding()]
param(
[Parameter(Mandatory)][pscustomobject]$ProjectInfo
)
$hasVersion = $ProjectInfo.PSObject.Properties.Name -contains 'Version'
if ($hasVersion -and -not [string]::IsNullOrWhiteSpace($ProjectInfo.Version)) {
return [semver]$ProjectInfo.Version
}
$projectJsonData = Read-ProjectJsonData -ProjectJsonPath $ProjectInfo.ProjectJSON
return [semver]$projectJsonData.Version
}
function Get-NovaVersionPartForUpdatePlan {
[CmdletBinding()]
param(
[Parameter(Mandatory)][semver]$CurrentVersion,
[Parameter(Mandatory)][string]$Label,
[switch]$PreviewRelease
)
if ($PreviewRelease) {
if (-not [string]::IsNullOrWhiteSpace($CurrentVersion.PreReleaseLabel)) {
return Get-NovaVersionPartObject -CurrentVersion $CurrentVersion
}
return Get-NovaVersionPartForLabel -CurrentVersion $CurrentVersion -Label Patch
}
return Get-NovaVersionPartForLabel -CurrentVersion $CurrentVersion -Label $Label
}