Skip to content

Commit 14d15bd

Browse files
committed
#215 fix(#217): clarify update notification perference status
1 parent 46c91b4 commit 14d15bd

5 files changed

Lines changed: 76 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
1919

2020
- `Deploy-NovaPackage` now shows a concise resolved-upload summary before execution, reports progress while multiple artifacts are uploading, and prints a short completion summary with a suggested verification step after successful raw uploads.
2121
- `Get-NovaProjectInfo` now fails with clearer recovery guidance when `-Path` does not exist, points to a file, or the target folder is missing `project.json`.
22+
- `Get-NovaUpdateNotificationPreference -Verbose` now explains whether Nova is reading a stored preference or the built-in default, and the command help now points read-only PowerShell users to the matching `% nova notification` workflow.
2223

2324
### Deprecated
2425

RELEASE_NOTE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ This file summarizes the release notes for NovaModuleTools. **UNRELEASED** chang
1515

1616
- `Deploy-NovaPackage` now shows clearer terminal feedback during raw package uploads, including a concise pre-flight summary, progress across multiple artifacts, and a short verification hint after success.
1717
- `Get-NovaProjectInfo` now explains how to recover when `-Path` is invalid or the target folder is not a Nova project root.
18+
- `Get-NovaUpdateNotificationPreference -Verbose` now tells you whether Nova is using a stored update-notification preference or the built-in default, and the help now points to the matching `% nova notification` workflow.
1819

1920
### Deprecated
2021

docs/NovaModuleTools/en-US/Get-NovaUpdateNotificationPreference.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ The same stored preference is also used by `Update-NovaModuleTool` (alias: `Upda
3232

3333
Stable self-updates remain available and do not require prerelease eligibility.
3434

35+
If no settings file exists yet, the command reports the default behavior: prerelease self-updates are enabled and
36+
stable self-updates remain available.
37+
38+
Use `% nova notification` when you want the CLI-oriented view of the same preference.
39+
3540
## EXAMPLES
3641

3742
### EXAMPLE 1
@@ -44,6 +49,15 @@ Shows whether prerelease self-updates are currently enabled, whether stable self
4449

4550
### EXAMPLE 2
4651

52+
```text
53+
PS> Get-NovaUpdateNotificationPreference -Verbose
54+
```
55+
56+
Shows the current status and writes a short explanation that tells you whether Nova is using a stored settings file
57+
or the built-in default.
58+
59+
### EXAMPLE 3
60+
4761
```text
4862
PS> Set-NovaUpdateNotificationPreference -DisablePrereleaseNotifications
4963
PS> Get-NovaUpdateNotificationPreference
@@ -77,10 +91,14 @@ Use `Set-NovaUpdateNotificationPreference -DisablePrereleaseNotifications` to st
7791

7892
Use `Set-NovaUpdateNotificationPreference -EnablePrereleaseNotifications` to allow prerelease self-updates again.
7993

94+
Use `-Verbose` when you want a short explanation of whether Nova is reading a stored preference or falling back to
95+
the default.
96+
8097
When prerelease notifications are enabled again, `Update-NovaModuleTool` / `Update-NovaModuleTools` may again select a prerelease target. Prerelease self-updates still require explicit confirmation before the update proceeds, and that confirmation defaults to `No` so pressing Enter cancels the update.
8198

8299
## RELATED LINKS
83100

84101
- [Invoke-NovaBuild](./Invoke-NovaBuild.md)
85102
- [Set-NovaUpdateNotificationPreference](./Set-NovaUpdateNotificationPreference.md)
103+
- [Install-NovaCli](./Install-NovaCli.md)
86104
- [Update-NovaModuleTool](./Update-NovaModuleTools.md)

src/private/update/GetNovaUpdateNotificationPreferenceStatus.ps1

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,44 @@ function Get-NovaUpdateNotificationPreferenceStatus {
33
param()
44

55
$preference = Read-NovaUpdateNotificationPreference
6+
$settingsPath = Get-NovaUpdateSettingsFilePath
7+
$settingsFileExists = Test-Path -LiteralPath $settingsPath -PathType Leaf
68

7-
return [pscustomobject]@{
9+
$status = [pscustomobject]@{
810
PrereleaseNotificationsEnabled = $preference.PrereleaseNotificationsEnabled
911
StableReleaseNotificationsEnabled = $true
10-
SettingsPath = Get-NovaUpdateSettingsFilePath
12+
SettingsPath = $settingsPath
1113
}
14+
15+
Write-NovaUpdateNotificationPreferenceStatusVerbose -Status $status -SettingsFileExists:$settingsFileExists
16+
return $status
17+
}
18+
19+
function Write-NovaUpdateNotificationPreferenceStatusVerbose {
20+
[CmdletBinding()]
21+
param(
22+
[Parameter(Mandatory)][pscustomobject]$Status,
23+
[Parameter(Mandatory)][bool]$SettingsFileExists
24+
)
25+
26+
$prereleaseState = Get-NovaUpdateNotificationPreferenceStateText -Enabled:$Status.PrereleaseNotificationsEnabled
27+
if ($SettingsFileExists) {
28+
Write-Verbose "Prerelease self-updates are $prereleaseState. Stable self-updates remain available. Settings file: $( $Status.SettingsPath )"
29+
return
30+
}
31+
32+
Write-Verbose "No settings file was found at $( $Status.SettingsPath ). Using the default setting: prerelease self-updates are $prereleaseState. Stable self-updates remain available. Use Set-NovaUpdateNotificationPreference to store a different preference."
33+
}
34+
35+
function Get-NovaUpdateNotificationPreferenceStateText {
36+
[CmdletBinding()]
37+
param(
38+
[Parameter(Mandatory)][bool]$Enabled
39+
)
40+
41+
if ($Enabled) {
42+
return 'enabled'
43+
}
44+
45+
return 'disabled'
1246
}

tests/private/update/GetNovaUpdateNotificationPreferenceStatus.Tests.ps1

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,31 @@ Describe 'Get-NovaUpdateNotificationPreferenceStatus' {
1010
It 'returns the stored preference along with the settings file path' {
1111
Mock Read-NovaUpdateNotificationPreference {return [pscustomobject]@{PrereleaseNotificationsEnabled = $false}}
1212
Mock Get-NovaUpdateSettingsFilePath {return '/some/path/settings.json'}
13+
Mock Test-Path {return $true}
14+
Mock Write-Verbose {}
1315

1416
$status = Get-NovaUpdateNotificationPreferenceStatus
1517

1618
$status.PrereleaseNotificationsEnabled | Should -BeFalse
1719
$status.StableReleaseNotificationsEnabled | Should -BeTrue
1820
$status.SettingsPath | Should -Be '/some/path/settings.json'
21+
Assert-MockCalled Write-Verbose -Times 1 -ParameterFilter {
22+
$Message -eq 'Prerelease self-updates are disabled. Stable self-updates remain available. Settings file: /some/path/settings.json'
23+
}
24+
}
25+
26+
It 'explains when the default preference is being used because the settings file is missing' {
27+
Mock Read-NovaUpdateNotificationPreference {return [pscustomobject]@{PrereleaseNotificationsEnabled = $true}}
28+
Mock Get-NovaUpdateSettingsFilePath {return '/some/path/settings.json'}
29+
Mock Test-Path {return $false}
30+
Mock Write-Verbose {}
31+
32+
$status = Get-NovaUpdateNotificationPreferenceStatus
33+
34+
$status.PrereleaseNotificationsEnabled | Should -BeTrue
35+
$status.SettingsPath | Should -Be '/some/path/settings.json'
36+
Assert-MockCalled Write-Verbose -Times 1 -ParameterFilter {
37+
$Message -eq 'No settings file was found at /some/path/settings.json. Using the default setting: prerelease self-updates are enabled. Stable self-updates remain available. Use Set-NovaUpdateNotificationPreference to store a different preference.'
38+
}
1939
}
2040
}

0 commit comments

Comments
 (0)