From 747d88421a2c6cee95c3736060aa04b877336bbc Mon Sep 17 00:00:00 2001 From: Stiwi Gabriel Courage Date: Wed, 6 May 2026 14:18:48 +0200 Subject: [PATCH] fix(#152): enhance Get-NovaProjectInfo to include installed NovaModuleTools version - Add -Installed parameter to return the installed NovaModuleTools name and version - Update documentation and examples for new version view --- CHANGELOG.md | 4 + README.md | 5 +- .../en-US/Get-NovaProjectInfo.md | 86 +++++++++++++++---- docs/NovaModuleTools/en-US/NovaModuleTools.md | 3 +- docs/commands.html | 24 ++++-- docs/versioning-and-updates.html | 13 +-- .../cli/SetNovaCliExecutablePermission.ps1 | 2 +- src/public/GetNovaProjectInfo.ps1 | 17 +++- tests/ArchitectureGuardrails.Tests.ps1 | 2 +- tests/NovaCommandModel.Tests.ps1 | 15 ++++ 10 files changed, 135 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 131d44ea..d511e809 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,10 @@ Keep stable `Update-NovaModuleVersion` / `% nova bump` releases on the SemVer ma ### Fixed +- Add a PowerShell installed-tool version view through `Get-NovaProjectInfo -Installed`. + - PowerShell now exposes the installed `NovaModuleTools` module name and version directly instead of requiring the + launcher-only `% nova --version` path. + - `Get-Help Get-NovaProjectInfo` now documents both the project-version and installed-tool-version views. - Stop build-driven workflows when a `src/public` file contains zero or multiple top-level functions. - This prevents helper functions from being exported accidentally just because they live in a public file. - `Invoke-NovaBuild`, `Test-NovaBuild -Build`, packaging, publishing, and release flows now surface the warning diff --git a/README.md b/README.md index 3de268d9..981925c2 100644 --- a/README.md +++ b/README.md @@ -118,9 +118,11 @@ the installed module manifest. When `Invoke-NovaBuild` detects a newer `NovaModuleTools` version after a build, the update warning also includes that same release notes link. -To compare the current project version with what is installed locally for that same module, use: +To inspect the current project version, the installed version of the current project module, or the installed +`NovaModuleTools` tool version, use: ```powershell +PS> Get-NovaProjectInfo -Installed % nova version % nova version --installed % nova version -i @@ -132,6 +134,7 @@ To compare the current project version with what is installed locally for that s - `% nova version --installed` / `% nova version -i` shows the locally installed version of the current project/module from the local module path +- `Get-NovaProjectInfo -Installed` shows the installed `NovaModuleTools` module name and version from PowerShell - `% nova --version` / `% nova -v` shows the installed `NovaModuleTools` version ### CLI help diff --git a/docs/NovaModuleTools/en-US/Get-NovaProjectInfo.md b/docs/NovaModuleTools/en-US/Get-NovaProjectInfo.md index c25c8edb..4c6cb2fc 100644 --- a/docs/NovaModuleTools/en-US/Get-NovaProjectInfo.md +++ b/docs/NovaModuleTools/en-US/Get-NovaProjectInfo.md @@ -4,7 +4,7 @@ external help file: NovaModuleTools-Help.xml HelpUri: '' Locale: en-US Module Name: NovaModuleTools -ms.date: 04/25/2026 +ms.date: 05/06/2026 PlatyPS schema version: 2024-05-01 title: Get-NovaProjectInfo --- @@ -13,16 +13,28 @@ title: Get-NovaProjectInfo ## SYNOPSIS -Reads `project.json` and returns resolved NovaModuleTools project metadata. +Reads `project.json` and returns resolved NovaModuleTools project metadata or a version-focused view. ## SYNTAX -### __AllParameterSets +### ProjectInfo + +```text +PS> Get-NovaProjectInfo [[-Path] ] [] +``` + +### ProjectVersion ```text PS> Get-NovaProjectInfo [[-Path] ] [-Version] [] ``` +### InstalledVersion + +```text +PS> Get-NovaProjectInfo [-Installed] [] +``` + ## DESCRIPTION `Get-NovaProjectInfo` reads the `project.json` file in a NovaModuleTools project and returns a project information @@ -37,6 +49,9 @@ Use this command from scripts, tests, or troubleshooting when you want one objec When you use `-Version`, the command returns only the project version string instead of the full project object. +When you use `-Installed`, the command returns the installed `NovaModuleTools` module name and version string instead of +project metadata. + ## EXAMPLES ### EXAMPLE 1 @@ -63,6 +78,14 @@ PS> Get-NovaProjectInfo -Version Returns only the version string from `project.json`. +### EXAMPLE 4 + +```text +PS> Get-NovaProjectInfo -Installed +``` + +Returns the installed `NovaModuleTools` module name and version string. + ## PARAMETERS ### -Path @@ -75,12 +98,18 @@ DefaultValue: (Get-Location).Path SupportsWildcards: false Aliases: [] ParameterSets: -- Name: (All) - Position: 0 - IsRequired: false - ValueFromPipeline: false - ValueFromPipelineByPropertyName: false - ValueFromRemainingArguments: false + - Name: ProjectInfo + Position: 0 + IsRequired: false + ValueFromPipeline: false + ValueFromPipelineByPropertyName: false + ValueFromRemainingArguments: false + - Name: ProjectVersion + Position: 0 + IsRequired: false + ValueFromPipeline: false + ValueFromPipelineByPropertyName: false + ValueFromRemainingArguments: false DontShow: false AcceptedValues: [] HelpMessage: '' @@ -96,12 +125,33 @@ DefaultValue: False SupportsWildcards: false Aliases: [] ParameterSets: -- Name: (All) - Position: Named - IsRequired: false - ValueFromPipeline: false - ValueFromPipelineByPropertyName: false - ValueFromRemainingArguments: false + - Name: ProjectVersion + Position: Named + IsRequired: false + ValueFromPipeline: false + ValueFromPipelineByPropertyName: false + ValueFromRemainingArguments: false +DontShow: false +AcceptedValues: [] +HelpMessage: '' +``` + +### -Installed + +Return the installed `NovaModuleTools` module name and version string instead of project metadata. + +```yaml +Type: System.Management.Automation.SwitchParameter +DefaultValue: False +SupportsWildcards: false +Aliases: [] +ParameterSets: + - Name: InstalledVersion + Position: Named + IsRequired: false + ValueFromPipeline: false + ValueFromPipelineByPropertyName: false + ValueFromRemainingArguments: false DontShow: false AcceptedValues: [] HelpMessage: '' @@ -125,6 +175,10 @@ You can't pipe objects to this cmdlet. Returned when you use `-Version`. +### System.String + +Returned when you use `-Installed`. + ### PSCustomObject Returned by default. The object includes project metadata, defaulted build settings, and resolved paths. @@ -133,6 +187,8 @@ Returned by default. The object includes project metadata, defaulted build setti This command throws a clear error when `project.json` is missing or empty. +`-Installed` does not require a project path or a `project.json` file. + ## RELATED LINKS - https://github.com/stiwicourage/NovaModuleTools/blob/main/docs/NovaModuleTools/en-US/Invoke-NovaBuild.md diff --git a/docs/NovaModuleTools/en-US/NovaModuleTools.md b/docs/NovaModuleTools/en-US/NovaModuleTools.md index 69806e26..76bd25a6 100644 --- a/docs/NovaModuleTools/en-US/NovaModuleTools.md +++ b/docs/NovaModuleTools/en-US/NovaModuleTools.md @@ -24,7 +24,8 @@ manifest generation, external help generation, resource copying, and Pester-base ### `PS> Get-NovaProjectInfo` -Reads `project.json` and returns resolved project metadata and paths. +Reads `project.json` and returns resolved project metadata and paths, or returns the project/install version views when +requested. ### `PS> Get-NovaUpdateNotificationPreference` diff --git a/docs/commands.html b/docs/commands.html index 33ac257b..8a75e72a 100644 --- a/docs/commands.html +++ b/docs/commands.html @@ -189,19 +189,23 @@

Get-NovaProjectInfo / % nova info

  • Best for: scripts, troubleshooting, and understanding resolved paths
  • -
  • Key parameters: -Path, -Version
  • +
  • Key parameters: -Path, -Version, -Installed +
  • Output: a project object, or just the version string when you use - -Version
  • + -Version, or the installed NovaModuleTools name and version + string when you use + -Installed
-

Inspect project metadata

+

Inspect project metadata or version views

Showing: PowerShell

PS> Get-NovaProjectInfo
-PS> Get-NovaProjectInfo -Version
+PS> Get-NovaProjectInfo -Version +PS> Get-NovaProjectInfo -Installed
-
PS> Get-NovaProjectInfo -Version
+
PS> Get-NovaProjectInfo -Version
+PS> Get-NovaProjectInfo -Installed
-

PowerShell note: the cmdlet surface covers the project version directly. - Installed-module and installed-tool version views stay on the launcher flow described in - the linked guide.

+

PowerShell note: Get-NovaProjectInfo -Version covers the + project version and + Get-NovaProjectInfo -Installed covers the installed + NovaModuleTools tool version. + The installed current-project module view stays on the launcher flow described in the + linked guide.

See version view differences

diff --git a/docs/versioning-and-updates.html b/docs/versioning-and-updates.html index beea8854..5de9ff71 100644 --- a/docs/versioning-and-updates.html +++ b/docs/versioning-and-updates.html @@ -120,7 +120,7 @@

Choose the right version command

- % nova --version + Get-NovaProjectInfo -Installed or % nova --version The installed NovaModuleTools version. Use this when you are troubleshooting Nova itself or checking whether the tool needs an update. @@ -136,7 +136,8 @@

Choose the right version command

-
PS> Get-NovaProjectInfo -Version
+
PS> Get-NovaProjectInfo -Version
+PS> Get-NovaProjectInfo -Installed
-

PowerShell note: project version lookup has a direct cmdlet form. The installed - module/tool version views remain launcher-oriented on this page, as shown in the comparison - table - above.

+

PowerShell note: project version lookup and installed-tool version lookup both + have direct + cmdlet forms. The installed current-project module view remains launcher-oriented on this page, + as shown in the comparison table above.

diff --git a/src/private/cli/SetNovaCliExecutablePermission.ps1 b/src/private/cli/SetNovaCliExecutablePermission.ps1 index fac890f5..5acee80b 100644 --- a/src/private/cli/SetNovaCliExecutablePermission.ps1 +++ b/src/private/cli/SetNovaCliExecutablePermission.ps1 @@ -12,7 +12,7 @@ function Set-NovaCliExecutablePermission { return } - & chmod '+x' $Path + & chmod '+x' $Path 2> $null if ($LASTEXITCODE -ne 0) { Stop-NovaOperation -Message "Failed to make nova launcher executable: $Path" -ErrorId 'Nova.Dependency.CliLauncherPermissionUpdateFailed' -Category InvalidOperation -TargetObject $Path } diff --git a/src/public/GetNovaProjectInfo.ps1 b/src/public/GetNovaProjectInfo.ps1 index d1d3df49..0bf68cd5 100644 --- a/src/public/GetNovaProjectInfo.ps1 +++ b/src/public/GetNovaProjectInfo.ps1 @@ -1,10 +1,21 @@ function Get-NovaProjectInfo { - [CmdletBinding()] + [CmdletBinding(DefaultParameterSetName = 'ProjectInfo')] param( - [Parameter(Position = 0)] + [Parameter(Position = 0, ParameterSetName = 'ProjectInfo')] + [Parameter(Position = 0, ParameterSetName = 'ProjectVersion')] [string]$Path = (Get-Location).Path, - [switch]$Version + [Parameter(ParameterSetName = 'ProjectVersion')] + [switch]$Version, + [Parameter(ParameterSetName = 'InstalledVersion')] + [switch]$Installed ) + + if ($Installed) { + $module = $ExecutionContext.SessionState.Module + $installedVersion = Get-NovaCliInstalledVersion -Module $module + return Format-NovaCliVersionString -Name $module.Name -Version $installedVersion + } + $workflowContext = Get-NovaProjectInfoContext -Path $Path return Get-NovaProjectInfoResult -WorkflowContext $workflowContext -Version:$Version } diff --git a/tests/ArchitectureGuardrails.Tests.ps1 b/tests/ArchitectureGuardrails.Tests.ps1 index acdfcaf1..2a6e47b2 100644 --- a/tests/ArchitectureGuardrails.Tests.ps1 +++ b/tests/ArchitectureGuardrails.Tests.ps1 @@ -83,7 +83,7 @@ Describe 'Architecture guardrails' { It 'public command files use only their approved Nova helper surface' { $testCases = @( [pscustomobject]@{Path = 'src/public/DeployNovaPackage.ps1'; ExpectedHelpers = @('Get-NovaPackageUploadWorkflowContext', 'Get-NovaProjectInfo', 'Invoke-NovaPackageUploadWorkflow', 'New-NovaPackageUploadDynamicParameterDictionary', 'New-NovaPackageUploadOption')} - [pscustomobject]@{Path = 'src/public/GetNovaProjectInfo.ps1'; ExpectedHelpers = @('Get-NovaProjectInfoContext', 'Get-NovaProjectInfoResult')} + [pscustomobject]@{Path = 'src/public/GetNovaProjectInfo.ps1'; ExpectedHelpers = @('Format-NovaCliVersionString', 'Get-NovaCliInstalledVersion', 'Get-NovaProjectInfoContext', 'Get-NovaProjectInfoResult')} [pscustomobject]@{Path = 'src/public/GetNovaUpdateNotificationPreference.ps1'; ExpectedHelpers = @('Get-NovaUpdateNotificationPreferenceStatus')} [pscustomobject]@{Path = 'src/public/InitializeNovaModule.ps1'; ExpectedHelpers = @('Get-NovaModuleInitializationWorkflowContext', 'Invoke-NovaModuleInitializationWorkflow')} [pscustomobject]@{Path = 'src/public/InstallNovaCli.ps1'; ExpectedHelpers = @('Get-NovaCliInstallWorkflowContext', 'Invoke-NovaCliInstallWorkflow', 'Write-NovaModuleReleaseNotesLink')} diff --git a/tests/NovaCommandModel.Tests.ps1 b/tests/NovaCommandModel.Tests.ps1 index 1b3d15b9..21cad394 100644 --- a/tests/NovaCommandModel.Tests.ps1 +++ b/tests/NovaCommandModel.Tests.ps1 @@ -113,6 +113,21 @@ Describe 'Nova command model - project, help, and build behavior' { } } + It 'Get-NovaProjectInfo -Installed returns the installed NovaModuleTools name and version without reading project.json' { + InModuleScope $script:moduleName -Parameters @{ExpectedModuleName = $script:moduleName} { + param($ExpectedModuleName) + + Mock Get-NovaCliInstalledVersion {'9.9.9-preview'} + Mock Get-NovaProjectInfoContext {throw 'should not resolve project context'} + Mock Get-NovaProjectInfoResult {throw 'should not shape project output'} + + Get-NovaProjectInfo -Installed | Should -Be "$ExpectedModuleName 9.9.9-preview" + Assert-MockCalled Get-NovaCliInstalledVersion -Times 1 -Scope It + Assert-MockCalled Get-NovaProjectInfoContext -Times 0 -Scope It + Assert-MockCalled Get-NovaProjectInfoResult -Times 0 -Scope It + } + } + It 'Get-NovaProjectInfo delegates context resolution and result shaping to private helpers' { InModuleScope $script:moduleName { Mock Get-NovaProjectInfoContext {