Skip to content

Commit 4c1b863

Browse files
committed
#215 feat: enhance version update workflow with progress reporting and detailed summaries
refactor(Update-NovaModuleVersion): align with terminal-ux-design principles Fixes #229
1 parent b5066da commit 4c1b863

9 files changed

Lines changed: 338 additions & 51 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
3131
- `Set-NovaUpdateNotificationPreference` now ends with a clear success or preview summary, prints the settings file path, suggests `Get-NovaUpdateNotificationPreference` as the next verification step, and gives a more actionable validation error when no enable/disable switch is supplied.
3232
- `Test-NovaBuild` now shows progress across the main test phases, ends with the result file path plus a coverage summary and next-step hint when tests pass, uses a test-plan summary in `-WhatIf` mode, and fails with more actionable guidance when Pester or coverage checks fail.
3333
- `Update-NovaModuleTool` now ends with a visible up-to-date, preview, cancelled, or updated summary, skips prerelease confirmation during `-WhatIf`, shows progress for the actual self-update step, and suggests `Get-NovaProjectInfo -Installed` after a successful update.
34+
- `Update-NovaModuleVersion` now ends with a visible preview, cancelled, or updated summary, prints the resolved version file plus the detected/applied release label, shows progress while writing `project.json`, and suggests the next command to run after the bump.
3435

3536
### Deprecated
3637

RELEASE_NOTE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ This file summarizes the release notes for NovaModuleTools. **UNRELEASED** chang
2727
- `Set-NovaUpdateNotificationPreference` now ends with a clear success or preview summary, prints the settings file path, suggests `Get-NovaUpdateNotificationPreference` as the next verification step, and gives a more actionable validation error when no enable/disable switch is supplied.
2828
- `Test-NovaBuild` now shows progress across the main test phases, ends with the result file path plus a coverage summary and next-step hint when tests pass, uses a test-plan summary in `-WhatIf` mode, and fails with more actionable guidance when Pester or coverage checks fail.
2929
- `Update-NovaModuleTool` now ends with a visible up-to-date, preview, cancelled, or updated summary, skips prerelease confirmation during `-WhatIf`, shows progress for the actual self-update step, and suggests `Get-NovaProjectInfo -Installed` after a successful update.
30+
- `Update-NovaModuleVersion` now ends with a visible preview, cancelled, or updated summary, prints the resolved version file plus the detected/applied release label, shows progress while writing `project.json`, and suggests the next command to run after the bump.
3031

3132
### Deprecated
3233

docs/NovaModuleTools/en-US/Update-NovaModuleVersion.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ When Git tags exist, only commits since the latest tag are considered. If Git-ba
4343
If the repository exists but has no commits yet, the command stops with: `Cannot bump version because the repository
4444
has no commits yet. Create an initial commit first.`
4545

46-
This command supports `-WhatIf` and `-Confirm` through PowerShell `SupportsShouldProcess`. Use `-WhatIf` to preview the calculated release label and the exact next version without changing the stored version.
46+
This command supports `-WhatIf` and `-Confirm` through PowerShell `SupportsShouldProcess`. Use `-WhatIf` to preview the calculated release label and the exact next version without changing the stored version. The command now ends with a clear plan, cancellation, or success summary, prints the resolved version file plus the detected/applied release label, and suggests the next step to run.
4747

4848
Use `-ContinuousIntegration` when the same session should first re-activate the built `dist/` module before the version bump workflow starts. This is useful in CI/self-hosting flows where an earlier command changed the active module state.
4949

@@ -58,7 +58,7 @@ When the current version is already a prerelease for the selected release line,
5858
PS> Update-NovaModuleVersion
5959
```
6060

61-
Updates the version in the current project using the release label inferred from recent commit messages.
61+
Updates the version in the current project using the release label inferred from recent commit messages, then prints the version file plus the next suggested validation step.
6262

6363
### EXAMPLE 2
6464

@@ -81,7 +81,7 @@ Label: Minor
8181
CommitCount: 12
8282
```
8383

84-
Shows the calculated version update without modifying `project.json`.
84+
Shows the calculated version update without modifying `project.json`, then ends with a version-update plan summary and a reminder to rerun without `-WhatIf` when you are ready to write the new version.
8585

8686
### EXAMPLE 4
8787

@@ -111,7 +111,7 @@ Label: Minor
111111
CommitCount: 12
112112
```
113113

114-
Shows how `-Preview` keeps the detected semantic label for reporting but deterministically enters the next patch preview track when the current version is stable.
114+
Shows how `-Preview` keeps the detected semantic label for reporting but deterministically enters the next patch preview track when the current version is stable, while the plan summary still points to the exact next version that would be written.
115115

116116
### EXAMPLE 6
117117

@@ -165,7 +165,7 @@ Label: Major
165165
CommitCount: 34
166166
```
167167

168-
Shows how stable `0.y.z` bumps still warn that `1.0.0` must be set manually when the API becomes stable, while breaking-change commits on that line continue to plan the next minor version instead of jumping straight to `1.0.0`.
168+
Shows how stable `0.y.z` bumps still warn that `1.0.0` must be set manually when the API becomes stable, while breaking-change commits on that line continue to plan the next minor version instead of jumping straight to `1.0.0`. The plan output also keeps both the detected and applied release labels visible.
169169

170170
### EXAMPLE 10
171171

src/private/release/InvokeNovaVersionUpdateWorkflow.ps1

Lines changed: 91 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,46 @@ function Invoke-NovaVersionUpdateWorkflow {
77
)
88

99
$versionWriteResult = $null
10-
if ($ShouldRun) {
11-
$versionWriteResult = Set-NovaModuleVersion -ProjectInfo $WorkflowContext.ProjectInfo -Label (Get-NovaVersionUpdateEffectiveLabel -WorkflowContext $WorkflowContext) -PreviewRelease:$WorkflowContext.PreviewRelease -Confirm:$false
10+
$progressActivity = 'Updating Nova module version'
11+
try {
12+
if ($ShouldRun) {
13+
$versionWriteResult = Invoke-NovaVersionUpdateWorkflowStep -Activity $progressActivity -Status (Get-NovaVersionUpdateApplyStatus -WorkflowContext $WorkflowContext) -PercentComplete 80 -Action {
14+
Set-NovaModuleVersion -ProjectInfo $WorkflowContext.ProjectInfo -Label (Get-NovaVersionUpdateEffectiveLabel -WorkflowContext $WorkflowContext) -PreviewRelease:$WorkflowContext.PreviewRelease -Confirm:$false
15+
}
16+
}
1217
}
13-
14-
if (-not (Test-NovaVersionUpdateResultRequired -ShouldRun:$ShouldRun -WhatIfEnabled:$WhatIfEnabled)) {
15-
return
18+
finally {
19+
if ($ShouldRun) {
20+
Write-Progress -Activity $progressActivity -Completed
21+
}
1622
}
1723

18-
return Get-NovaVersionUpdateResult -WorkflowContext $WorkflowContext -Applied:($null -ne $versionWriteResult -and $versionWriteResult.Applied)
24+
$wasApplied = $null -ne $versionWriteResult -and $versionWriteResult.Applied
25+
$wasCancelled = (-not $ShouldRun) -and (-not $WhatIfEnabled)
26+
return Get-NovaVersionUpdateResult -WorkflowContext $WorkflowContext -Applied:$wasApplied -Previewed:$WhatIfEnabled -Cancelled:$wasCancelled
1927
}
2028

21-
function Test-NovaVersionUpdateResultRequired {
29+
function Invoke-NovaVersionUpdateWorkflowStep {
2230
[CmdletBinding()]
2331
param(
24-
[switch]$ShouldRun,
25-
[switch]$WhatIfEnabled
32+
[Parameter(Mandatory)][string]$Activity,
33+
[Parameter(Mandatory)][string]$Status,
34+
[Parameter(Mandatory)][int]$PercentComplete,
35+
[Parameter(Mandatory)][scriptblock]$Action
36+
)
37+
38+
Write-Progress -Activity $Activity -Status $Status -PercentComplete $PercentComplete
39+
return & $Action
40+
}
41+
42+
function Get-NovaVersionUpdateApplyStatus {
43+
[CmdletBinding()]
44+
param(
45+
[Parameter(Mandatory)][pscustomobject]$WorkflowContext
2646
)
2747

28-
return $ShouldRun -or $WhatIfEnabled
48+
$target = Get-NovaVersionUpdateTarget -WorkflowContext $WorkflowContext
49+
return "Writing version $( $WorkflowContext.NewVersion ) to $target"
2950
}
3051

3152
function Get-NovaVersionUpdateEffectiveLabel {
@@ -34,28 +55,35 @@ function Get-NovaVersionUpdateEffectiveLabel {
3455
[Parameter(Mandatory)][pscustomobject]$WorkflowContext
3556
)
3657

37-
if ($WorkflowContext.PSObject.Properties.Name -contains 'EffectiveLabel' -and -not [string]::IsNullOrWhiteSpace($WorkflowContext.EffectiveLabel)) {
38-
return $WorkflowContext.EffectiveLabel
58+
$effectiveLabel = Get-NovaVersionUpdateWorkflowPropertyValue -WorkflowContext $WorkflowContext -Name 'EffectiveLabel'
59+
if (-not [string]::IsNullOrWhiteSpace($effectiveLabel)) {
60+
return $effectiveLabel
3961
}
4062

41-
return $WorkflowContext.Label
63+
return Get-NovaVersionUpdateWorkflowPropertyValue -WorkflowContext $WorkflowContext -Name 'Label'
4264
}
4365

4466
function Get-NovaVersionUpdateResult {
4567
[CmdletBinding()]
4668
param(
4769
[Parameter(Mandatory)][pscustomobject]$WorkflowContext,
48-
[switch]$Applied
70+
[switch]$Applied,
71+
[switch]$Previewed,
72+
[switch]$Cancelled
4973
)
5074

5175
return [pscustomobject]@{
52-
PreviousVersion = $WorkflowContext.PreviousVersion
53-
NewVersion = $WorkflowContext.NewVersion
54-
Label = $WorkflowContext.Label
76+
PreviousVersion = Get-NovaVersionUpdateWorkflowPropertyValue -WorkflowContext $WorkflowContext -Name 'PreviousVersion'
77+
NewVersion = Get-NovaVersionUpdateWorkflowPropertyValue -WorkflowContext $WorkflowContext -Name 'NewVersion'
78+
Label = Get-NovaVersionUpdateWorkflowPropertyValue -WorkflowContext $WorkflowContext -Name 'Label'
5579
EffectiveLabel = Get-NovaVersionUpdateEffectiveLabel -WorkflowContext $WorkflowContext
5680
AdvisoryMessage = Get-NovaVersionUpdateAdvisoryMessage -WorkflowContext $WorkflowContext
57-
CommitCount = $WorkflowContext.CommitCount
81+
CommitCount = Get-NovaVersionUpdateWorkflowPropertyValue -WorkflowContext $WorkflowContext -Name 'CommitCount'
82+
ProjectFile = Get-NovaVersionUpdateProjectFile -WorkflowContext $WorkflowContext
83+
Target = Get-NovaVersionUpdateTarget -WorkflowContext $WorkflowContext
5884
Applied = [bool]$Applied
85+
Previewed = [bool]$Previewed
86+
Cancelled = [bool]$Cancelled
5987
}
6088
}
6189

@@ -65,10 +93,53 @@ function Get-NovaVersionUpdateAdvisoryMessage {
6593
[Parameter(Mandatory)][pscustomobject]$WorkflowContext
6694
)
6795

68-
if ($WorkflowContext.PSObject.Properties.Name -notcontains 'AdvisoryMessage') {
96+
return Get-NovaVersionUpdateWorkflowPropertyValue -WorkflowContext $WorkflowContext -Name 'AdvisoryMessage'
97+
}
98+
99+
function Get-NovaVersionUpdateProjectFile {
100+
[CmdletBinding()]
101+
param(
102+
[Parameter(Mandatory)][pscustomobject]$WorkflowContext
103+
)
104+
105+
$projectInfo = Get-NovaVersionUpdateWorkflowPropertyValue -WorkflowContext $WorkflowContext -Name 'ProjectInfo'
106+
if ($null -eq $projectInfo) {
107+
return $null
108+
}
109+
110+
$projectFileProperty = $projectInfo.PSObject.Properties['ProjectJSON']
111+
if ($null -eq $projectFileProperty) {
69112
return $null
70113
}
71114

72-
return $WorkflowContext.AdvisoryMessage
115+
return $projectFileProperty.Value
116+
}
117+
118+
function Get-NovaVersionUpdateTarget {
119+
[CmdletBinding()]
120+
param(
121+
[Parameter(Mandatory)][pscustomobject]$WorkflowContext
122+
)
123+
124+
$projectFile = Get-NovaVersionUpdateProjectFile -WorkflowContext $WorkflowContext
125+
if (-not [string]::IsNullOrWhiteSpace($projectFile)) {
126+
return [System.IO.Path]::GetFileName($projectFile)
127+
}
128+
129+
return Get-NovaVersionUpdateWorkflowPropertyValue -WorkflowContext $WorkflowContext -Name 'Target'
73130
}
74131

132+
function Get-NovaVersionUpdateWorkflowPropertyValue {
133+
[CmdletBinding()]
134+
param(
135+
[Parameter(Mandatory)][pscustomobject]$WorkflowContext,
136+
[Parameter(Mandatory)][string]$Name
137+
)
138+
139+
$property = $WorkflowContext.PSObject.Properties[$Name]
140+
if ($null -eq $property) {
141+
return $null
142+
}
143+
144+
return $property.Value
145+
}

src/private/release/WriteNovaVersionUpdateResultMessages.ps1

Lines changed: 137 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,14 @@ function Write-NovaVersionUpdateResultOutput {
3333
Write-Warning $advisoryMessage
3434
}
3535

36-
if ($Result.Applied) {
37-
Write-Host "Version bumped to : $( $Result.NewVersion )"
36+
Write-Message (Get-NovaVersionUpdateResultStatusMessage -Result $Result) -color (Get-NovaVersionUpdateResultStatusColor -Result $Result)
37+
38+
foreach ($line in (Get-NovaVersionUpdateResultDetailText -Result $Result)) {
39+
Write-Message $line
40+
}
41+
42+
foreach ($line in (Get-NovaVersionUpdateResultNextStepText -Result $Result)) {
43+
Write-Message $line
3844
}
3945
}
4046

@@ -44,11 +50,137 @@ function Get-NovaVersionUpdateResultAdvisoryMessage {
4450
[Parameter(Mandatory)][object]$Result
4551
)
4652

47-
if ($Result.PSObject.Properties.Name -notcontains 'AdvisoryMessage') {
48-
return $null
53+
return Get-NovaVersionUpdateResultPropertyValue -Result $Result -Name 'AdvisoryMessage'
54+
}
55+
56+
function Get-NovaVersionUpdateResultStatusMessage {
57+
[CmdletBinding()]
58+
param(
59+
[Parameter(Mandatory)][object]$Result
60+
)
61+
62+
if ([bool](Get-NovaVersionUpdateResultPropertyValue -Result $Result -Name 'Cancelled')) {
63+
return 'Version update cancelled before changing project.json.'
64+
}
65+
66+
if ([bool](Get-NovaVersionUpdateResultPropertyValue -Result $Result -Name 'Previewed')) {
67+
return "Version update plan ready -> $( Get-NovaVersionUpdateResultPropertyValue -Result $Result -Name 'NewVersion' )"
68+
}
69+
70+
return "Updated project version to $( Get-NovaVersionUpdateResultPropertyValue -Result $Result -Name 'NewVersion' )"
71+
}
72+
73+
function Get-NovaVersionUpdateResultStatusColor {
74+
[CmdletBinding()]
75+
param(
76+
[Parameter(Mandatory)][object]$Result
77+
)
78+
79+
if ([bool](Get-NovaVersionUpdateResultPropertyValue -Result $Result -Name 'Cancelled')) {
80+
return 'Blue'
81+
}
82+
83+
return 'Green'
84+
}
85+
86+
function Get-NovaVersionUpdateResultDetailText {
87+
[CmdletBinding()]
88+
param(
89+
[Parameter(Mandatory)][object]$Result
90+
)
91+
92+
$lines = @()
93+
$targetLine = Get-NovaVersionUpdateResultTargetLine -Result $Result
94+
if (-not [string]::IsNullOrWhiteSpace($targetLine)) {
95+
$lines += $targetLine
96+
}
97+
98+
$lines += "Previous version: $( Get-NovaVersionUpdateResultPropertyValue -Result $Result -Name 'PreviousVersion' )"
99+
$lines += "New version: $( Get-NovaVersionUpdateResultPropertyValue -Result $Result -Name 'NewVersion' )"
100+
$lines += Get-NovaVersionUpdateResultLabelText -Result $Result
101+
102+
$commitCount = Get-NovaVersionUpdateResultPropertyValue -Result $Result -Name 'CommitCount'
103+
if ($null -ne $commitCount) {
104+
$lines += "Commits considered: $commitCount"
105+
}
106+
107+
return $lines
108+
}
109+
110+
function Get-NovaVersionUpdateResultTargetLine {
111+
[CmdletBinding()]
112+
param(
113+
[Parameter(Mandatory)][object]$Result
114+
)
115+
116+
$projectFile = Get-NovaVersionUpdateResultPropertyValue -Result $Result -Name 'ProjectFile'
117+
if (-not [string]::IsNullOrWhiteSpace($projectFile)) {
118+
return "Version file: $projectFile"
119+
}
120+
121+
$target = Get-NovaVersionUpdateResultPropertyValue -Result $Result -Name 'Target'
122+
if (-not [string]::IsNullOrWhiteSpace($target)) {
123+
return "Version file: $target"
49124
}
50125

51-
return $Result.AdvisoryMessage
126+
return $null
52127
}
53128

129+
function Get-NovaVersionUpdateResultLabelText {
130+
[CmdletBinding()]
131+
param(
132+
[Parameter(Mandatory)][object]$Result
133+
)
54134

135+
$effectiveLabel = [string](Get-NovaVersionUpdateResultPropertyValue -Result $Result -Name 'EffectiveLabel')
136+
$detectedLabel = [string](Get-NovaVersionUpdateResultPropertyValue -Result $Result -Name 'Label')
137+
if ($effectiveLabel -eq $detectedLabel) {
138+
return @("Release label: $effectiveLabel")
139+
}
140+
141+
return @(
142+
"Detected release label: $detectedLabel"
143+
"Applied release label: $effectiveLabel"
144+
)
145+
}
146+
147+
function Get-NovaVersionUpdateResultNextStepText {
148+
[CmdletBinding()]
149+
param(
150+
[Parameter(Mandatory)][object]$Result
151+
)
152+
153+
if ([bool](Get-NovaVersionUpdateResultPropertyValue -Result $Result -Name 'Cancelled')) {
154+
return @(
155+
'Next step:'
156+
'Run Update-NovaModuleVersion again when you are ready to write the new version to project.json.'
157+
)
158+
}
159+
160+
if ([bool](Get-NovaVersionUpdateResultPropertyValue -Result $Result -Name 'Previewed')) {
161+
return @(
162+
'Next step:'
163+
'Run Update-NovaModuleVersion without -WhatIf when you are ready to apply the version change.'
164+
)
165+
}
166+
167+
return @(
168+
'Next step:'
169+
'Invoke-NovaBuild'
170+
)
171+
}
172+
173+
function Get-NovaVersionUpdateResultPropertyValue {
174+
[CmdletBinding()]
175+
param(
176+
[Parameter(Mandatory)][object]$Result,
177+
[Parameter(Mandatory)][string]$Name
178+
)
179+
180+
$property = $Result.PSObject.Properties[$Name]
181+
if ($null -eq $property) {
182+
return $null
183+
}
184+
185+
return $property.Value
186+
}

0 commit comments

Comments
 (0)