diff --git a/CHANGELOG.md b/CHANGELOG.md index 3800850..2322c59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), - `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. - `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`. +- `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. ### Deprecated diff --git a/RELEASE_NOTE.md b/RELEASE_NOTE.md index 049257a..56c2850 100644 --- a/RELEASE_NOTE.md +++ b/RELEASE_NOTE.md @@ -15,6 +15,7 @@ This file summarizes the release notes for NovaModuleTools. **UNRELEASED** chang - `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. - `Get-NovaProjectInfo` now explains how to recover when `-Path` is invalid or the target folder is not a Nova project root. +- `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. ### Deprecated diff --git a/docs/NovaModuleTools/en-US/Get-NovaUpdateNotificationPreference.md b/docs/NovaModuleTools/en-US/Get-NovaUpdateNotificationPreference.md index f1c5941..65b0d66 100644 --- a/docs/NovaModuleTools/en-US/Get-NovaUpdateNotificationPreference.md +++ b/docs/NovaModuleTools/en-US/Get-NovaUpdateNotificationPreference.md @@ -32,6 +32,11 @@ The same stored preference is also used by `Update-NovaModuleTool` (alias: `Upda Stable self-updates remain available and do not require prerelease eligibility. +If no settings file exists yet, the command reports the default behavior: prerelease self-updates are enabled and +stable self-updates remain available. + +Use `% nova notification` when you want the CLI-oriented view of the same preference. + ## EXAMPLES ### EXAMPLE 1 @@ -44,6 +49,15 @@ Shows whether prerelease self-updates are currently enabled, whether stable self ### EXAMPLE 2 +```text +PS> Get-NovaUpdateNotificationPreference -Verbose +``` + +Shows the current status and writes a short explanation that tells you whether Nova is using a stored settings file +or the built-in default. + +### EXAMPLE 3 + ```text PS> Set-NovaUpdateNotificationPreference -DisablePrereleaseNotifications PS> Get-NovaUpdateNotificationPreference @@ -77,10 +91,14 @@ Use `Set-NovaUpdateNotificationPreference -DisablePrereleaseNotifications` to st Use `Set-NovaUpdateNotificationPreference -EnablePrereleaseNotifications` to allow prerelease self-updates again. +Use `-Verbose` when you want a short explanation of whether Nova is reading a stored preference or falling back to +the default. + 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. ## RELATED LINKS - [Invoke-NovaBuild](./Invoke-NovaBuild.md) - [Set-NovaUpdateNotificationPreference](./Set-NovaUpdateNotificationPreference.md) +- [Install-NovaCli](./Install-NovaCli.md) - [Update-NovaModuleTool](./Update-NovaModuleTools.md) diff --git a/src/private/update/GetNovaUpdateNotificationPreferenceStatus.ps1 b/src/private/update/GetNovaUpdateNotificationPreferenceStatus.ps1 index 7eae290..f0115e7 100644 --- a/src/private/update/GetNovaUpdateNotificationPreferenceStatus.ps1 +++ b/src/private/update/GetNovaUpdateNotificationPreferenceStatus.ps1 @@ -3,10 +3,44 @@ function Get-NovaUpdateNotificationPreferenceStatus { param() $preference = Read-NovaUpdateNotificationPreference + $settingsPath = Get-NovaUpdateSettingsFilePath + $settingsFileExists = Test-Path -LiteralPath $settingsPath -PathType Leaf - return [pscustomobject]@{ + $status = [pscustomobject]@{ PrereleaseNotificationsEnabled = $preference.PrereleaseNotificationsEnabled StableReleaseNotificationsEnabled = $true - SettingsPath = Get-NovaUpdateSettingsFilePath + SettingsPath = $settingsPath } + + Write-NovaUpdateNotificationPreferenceStatusVerbose -Status $status -SettingsFileExists:$settingsFileExists + return $status +} + +function Write-NovaUpdateNotificationPreferenceStatusVerbose { + [CmdletBinding()] + param( + [Parameter(Mandatory)][pscustomobject]$Status, + [Parameter(Mandatory)][bool]$SettingsFileExists + ) + + $prereleaseState = Get-NovaUpdateNotificationPreferenceStateText -Enabled:$Status.PrereleaseNotificationsEnabled + if ($SettingsFileExists) { + Write-Verbose "Prerelease self-updates are $prereleaseState. Stable self-updates remain available. Settings file: $( $Status.SettingsPath )" + return + } + + 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." +} + +function Get-NovaUpdateNotificationPreferenceStateText { + [CmdletBinding()] + param( + [Parameter(Mandatory)][bool]$Enabled + ) + + if ($Enabled) { + return 'enabled' + } + + return 'disabled' } diff --git a/tests/private/update/GetNovaUpdateNotificationPreferenceStatus.Tests.ps1 b/tests/private/update/GetNovaUpdateNotificationPreferenceStatus.Tests.ps1 index db55344..0e87b6c 100644 --- a/tests/private/update/GetNovaUpdateNotificationPreferenceStatus.Tests.ps1 +++ b/tests/private/update/GetNovaUpdateNotificationPreferenceStatus.Tests.ps1 @@ -10,11 +10,31 @@ Describe 'Get-NovaUpdateNotificationPreferenceStatus' { It 'returns the stored preference along with the settings file path' { Mock Read-NovaUpdateNotificationPreference {return [pscustomobject]@{PrereleaseNotificationsEnabled = $false}} Mock Get-NovaUpdateSettingsFilePath {return '/some/path/settings.json'} + Mock Test-Path {return $true} + Mock Write-Verbose {} $status = Get-NovaUpdateNotificationPreferenceStatus $status.PrereleaseNotificationsEnabled | Should -BeFalse $status.StableReleaseNotificationsEnabled | Should -BeTrue $status.SettingsPath | Should -Be '/some/path/settings.json' + Assert-MockCalled Write-Verbose -Times 1 -ParameterFilter { + $Message -eq 'Prerelease self-updates are disabled. Stable self-updates remain available. Settings file: /some/path/settings.json' + } + } + + It 'explains when the default preference is being used because the settings file is missing' { + Mock Read-NovaUpdateNotificationPreference {return [pscustomobject]@{PrereleaseNotificationsEnabled = $true}} + Mock Get-NovaUpdateSettingsFilePath {return '/some/path/settings.json'} + Mock Test-Path {return $false} + Mock Write-Verbose {} + + $status = Get-NovaUpdateNotificationPreferenceStatus + + $status.PrereleaseNotificationsEnabled | Should -BeTrue + $status.SettingsPath | Should -Be '/some/path/settings.json' + Assert-MockCalled Write-Verbose -Times 1 -ParameterFilter { + $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.' + } } }