Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
### Changed

- `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`.

### Deprecated

Expand Down
3 changes: 2 additions & 1 deletion RELEASE_NOTE.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ This file summarizes the release notes for NovaModuleTools. **UNRELEASED** chang
### Changed

- `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.

### Deprecated

### Removed

### Fixed

- PowerShell command help `RELATED LINKS` now use valid help-topic links instead of GitHub blob pages.
- PowerShell command help `RELATED LINKS` now use valid help-topic.

### Security

Expand Down
6 changes: 6 additions & 0 deletions docs/NovaModuleTools/en-US/Get-NovaProjectInfo.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ When you use `-Version`, the command returns only the project version string ins

When you use `-Installed`, the command returns the installed `NovaModuleTools` module name and version string instead of project metadata.

When `-Path` does not resolve to an existing project root folder, or the folder does not contain `project.json`,
the command fails with an actionable error that tells you how to recover.

## EXAMPLES

### EXAMPLE 1
Expand Down Expand Up @@ -185,6 +188,9 @@ Returned by default. The object includes project metadata, defaulted build setti

This command throws a clear error when `project.json` is missing or empty.

If `-Path` points to a file or a folder that does not exist, `Get-NovaProjectInfo` tells you to rerun it from a
Nova project root or pass `-Path` to the folder that contains `project.json`.

`-Installed` does not require a project path or a `project.json` file.

## RELATED LINKS
Expand Down
37 changes: 33 additions & 4 deletions src/private/shared/GetNovaProjectInfoContext.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,44 @@ function Get-NovaProjectInfoContext {
[Parameter(Mandatory)][string]$Path
)

$projectRoot = (Resolve-Path -LiteralPath $Path).Path
$projectRoot = Resolve-NovaProjectInfoRootPath -Path $Path
$projectJson = [System.IO.Path]::Join($projectRoot, 'project.json')
if (-not (Test-Path -LiteralPath $projectJson)) {
Stop-NovaOperation -Message "Not a project folder. project.json not found: $projectJson" -ErrorId 'Nova.Environment.ProjectJsonNotFound' -Category ObjectNotFound -TargetObject $projectJson
}
Assert-NovaProjectJsonPresence -ProjectRoot $projectRoot -ProjectJson $projectJson

return [pscustomobject]@{
ProjectRoot = $projectRoot
ProjectJson = $projectJson
JsonData = Read-ProjectJsonData -ProjectJsonPath $projectJson
}
}

function Resolve-NovaProjectInfoRootPath {
[CmdletBinding()]
param(
[Parameter(Mandatory)][string]$Path
)

try {
$resolvedPath = (Resolve-Path -LiteralPath $Path -ErrorAction Stop).Path
} catch {
Stop-NovaOperation -Message "Project path not found: $Path. Run Get-NovaProjectInfo from a Nova project root or pass -Path to an existing project folder." -ErrorId 'Nova.Environment.ProjectPathNotFound' -Category ObjectNotFound -TargetObject $Path
}

if (-not (Test-Path -LiteralPath $resolvedPath -PathType Container)) {
Stop-NovaOperation -Message "Project path must be a folder: $resolvedPath. Pass -Path to the project root that contains project.json." -ErrorId 'Nova.Environment.ProjectPathNotDirectory' -Category InvalidArgument -TargetObject $resolvedPath
}

return $resolvedPath
}

function Assert-NovaProjectJsonPresence {
[CmdletBinding()]
param(
[Parameter(Mandatory)][string]$ProjectRoot,
[Parameter(Mandatory)][string]$ProjectJson
)

if (-not (Test-Path -LiteralPath $ProjectJson -PathType Leaf)) {
Stop-NovaOperation -Message "project.json not found in project root: $ProjectRoot. Run Get-NovaProjectInfo from a folder that contains project.json or pass -Path to that folder." -ErrorId 'Nova.Environment.ProjectJsonNotFound' -Category ObjectNotFound -TargetObject $ProjectJson
}
}
13 changes: 12 additions & 1 deletion tests/private/shared/GetNovaProjectInfoContext.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,19 @@ Describe 'Get-NovaProjectInfoContext' {
Remove-Item -LiteralPath $script:root -Recurse -Force -ErrorAction SilentlyContinue
}

It 'throws a clear error when the project path does not exist' {
{Get-NovaProjectInfoContext -Path (Join-Path $script:root 'missing')} | Should -Throw '*Project path not found:*Run Get-NovaProjectInfo from a Nova project root or pass -Path to an existing project folder.*'
}

It 'throws a clear error when the project path points to a file instead of a folder' {
$filePath = Join-Path $script:root 'project.txt'
Set-Content -LiteralPath $filePath -Value 'content'

{Get-NovaProjectInfoContext -Path $filePath} | Should -Throw '*Project path must be a folder:*Pass -Path to the project root that contains project.json.*'
}

It 'throws when project.json is missing in the given folder' {
{Get-NovaProjectInfoContext -Path $script:root} | Should -Throw
{Get-NovaProjectInfoContext -Path $script:root} | Should -Throw '*project.json not found in project root:*Run Get-NovaProjectInfo from a folder that contains project.json or pass -Path to that folder.*'
}

It 'returns the resolved root, project.json path, and parsed JSON data' {
Expand Down
Loading