From 78d14e509da808a85d6119f40eccaa833f9d1fea Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Sat, 24 May 2025 14:07:35 -0700 Subject: [PATCH 1/3] =?UTF-8?q?fix(requirements):=20=F0=9F=94=A7=20update?= =?UTF-8?q?=20'PSScriptAnalyzer'=20version=20to=201.24.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Updated the version of 'PSScriptAnalyzer' from `1.19.1` to `1.24.0` to ensure compatibility and access to the latest features and fixes. --- requirements.psd1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.psd1 b/requirements.psd1 index 5ffd065..a67b089 100644 --- a/requirements.psd1 +++ b/requirements.psd1 @@ -21,7 +21,7 @@ Version = '0.6.1' } 'PSScriptAnalyzer' = @{ - Version = '1.19.1' + Version = '1.24.0' } 'PwshSpectreConsole' = @{ Version = '2.3.0' From 2d5cb361ceeca85fc52ea5915d154bf44c68abdc Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Sat, 24 May 2025 14:11:50 -0700 Subject: [PATCH 2/3] =?UTF-8?q?chore(workflow):=20=E2=9C=A8=20update=20per?= =?UTF-8?q?missions=20in=20CI=20workflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Added `contents: read` and `issues: write` permissions to enhance workflow capabilities. --- .github/workflows/CI.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index d4d20d8..195794f 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -5,6 +5,8 @@ on: permissions: checks: write pull-requests: write + contents: read + issues: write jobs: ci: uses: HeyItsGilbert/.github/.github/workflows/ModuleCI.yml@main From 93425202807e9077556284445d830fda7bd9eeda Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Sat, 24 May 2025 14:15:38 -0700 Subject: [PATCH 3/3] =?UTF-8?q?docs:=20=E2=9C=8F=EF=B8=8F=20update=20docum?= =?UTF-8?q?entation=20and=20examples=20for=20`Show-PesterResult`=20and=20`?= =?UTF-8?q?Show-PesterResultTree`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Added example usage for `Show-PesterResult` to demonstrate TUI exploration of Pester results. * Enhanced `Show-PesterResultTree` documentation with a new example and adjusted parameter position. * Updated `cspell.json` to include "psake" in ignored words list. --- PesterExplorer/Public/Show-PesterResult.ps1 | 3 +- .../Public/Show-PesterResultTree.ps1 | 18 +++++++ cspell.json | 3 +- docs/en-US/Show-PesterResultTree.md | 2 +- tests/Help.tests.ps1 | 51 +++++++++---------- 5 files changed, 46 insertions(+), 31 deletions(-) diff --git a/PesterExplorer/Public/Show-PesterResult.ps1 b/PesterExplorer/Public/Show-PesterResult.ps1 index 29fb820..29b0bae 100644 --- a/PesterExplorer/Public/Show-PesterResult.ps1 +++ b/PesterExplorer/Public/Show-PesterResult.ps1 @@ -17,8 +17,7 @@ function Show-PesterResult { $pesterResult = Invoke-Pester -Path "path\to\tests.ps1" -PassThru Show-PesterResult -PesterResult $pesterResult - .NOTES - This function is part of the PesterExplorer module and requires Spectre.Console to be installed. + This example runs Pester tests and opens a TUI to explore the results. #> [CmdletBinding()] [OutputType([void])] diff --git a/PesterExplorer/Public/Show-PesterResultTree.ps1 b/PesterExplorer/Public/Show-PesterResultTree.ps1 index be04320..7b31efc 100644 --- a/PesterExplorer/Public/Show-PesterResultTree.ps1 +++ b/PesterExplorer/Public/Show-PesterResultTree.ps1 @@ -1,4 +1,22 @@ function Show-PesterResultTree { + <# + .SYNOPSIS + Show a Pester result in a tree format using Spectre.Console. + + .DESCRIPTION + This function takes a Pester result object and formats it into a tree structure + using Spectre.Console. It is useful for visualizing the structure of Pester results + such as runs, containers, blocks, and tests. + + .PARAMETER PesterResult + The Pester result object to display. This should be a Pester Run object. + + .EXAMPLE + $pesterResult = Invoke-Pester -Path "path\to\tests.ps1" -PassThru + Show-PesterResultTree -PesterResult $pesterResult + + This example runs Pester tests and displays the results in a tree format. + #> [CmdletBinding()] [OutputType([void])] param ( diff --git a/cspell.json b/cspell.json index 56a44ed..a833095 100644 --- a/cspell.json +++ b/cspell.json @@ -7,7 +7,8 @@ ], "words": [], "ignoreWords": [ - "pwsh" + "pwsh", + "psake" ], "import": [] } diff --git a/docs/en-US/Show-PesterResultTree.md b/docs/en-US/Show-PesterResultTree.md index 3f1580f..6726a3b 100644 --- a/docs/en-US/Show-PesterResultTree.md +++ b/docs/en-US/Show-PesterResultTree.md @@ -39,7 +39,7 @@ Parameter Sets: (All) Aliases: Required: False -Position: 0 +Position: 1 Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/tests/Help.tests.ps1 b/tests/Help.tests.ps1 index 8a6e175..4fe12b3 100644 --- a/tests/Help.tests.ps1 +++ b/tests/Help.tests.ps1 @@ -4,18 +4,15 @@ BeforeDiscovery { function global:FilterOutCommonParams { param ($Params) - $commonParams = @( - 'Debug', 'ErrorAction', 'ErrorVariable', 'InformationAction', 'InformationVariable', - 'OutBuffer', 'OutVariable', 'PipelineVariable', 'Verbose', 'WarningAction', - 'WarningVariable', 'Confirm', 'Whatif' - ) - $params | Where-Object { $_.Name -notin $commonParams } | Sort-Object -Property Name -Unique + $commonParameters = [System.Management.Automation.PSCmdlet]::CommonParameters + + [System.Management.Automation.PSCmdlet]::OptionalCommonParameters + $params | Where-Object { $_.Name -notin $commonParameters } | Sort-Object -Property Name -Unique } - $manifest = Import-PowerShellDataFile -Path $env:BHPSModuleManifest - $outputDir = Join-Path -Path $env:BHProjectPath -ChildPath 'Output' - $outputModDir = Join-Path -Path $outputDir -ChildPath $env:BHProjectName - $outputModVerDir = Join-Path -Path $outputModDir -ChildPath $manifest.ModuleVersion + $manifest = Import-PowerShellDataFile -Path $env:BHPSModuleManifest + $outputDir = Join-Path -Path $env:BHProjectPath -ChildPath 'Output' + $outputModDir = Join-Path -Path $outputDir -ChildPath $env:BHProjectName + $outputModVerDir = Join-Path -Path $outputModDir -ChildPath $manifest.ModuleVersion $outputModVerManifest = Join-Path -Path $outputModVerDir -ChildPath "$($env:BHProjectName).psd1" # Get module commands @@ -23,7 +20,7 @@ BeforeDiscovery { Get-Module $env:BHProjectName | Remove-Module -Force -ErrorAction Ignore Import-Module -Name $outputModVerManifest -Verbose:$false -ErrorAction Stop $params = @{ - Module = (Get-Module $env:BHProjectName) + Module = (Get-Module $env:BHProjectName) CommandType = [System.Management.Automation.CommandTypes[]]'Cmdlet, Function' # Not alias } if ($PSVersionTable.PSVersion.Major -lt 6) { @@ -39,22 +36,22 @@ Describe "Test help for <_.Name>" -ForEach $commands { BeforeDiscovery { # Get command help, parameters, and links - $command = $_ - $commandHelp = Get-Help $command.Name -ErrorAction SilentlyContinue - $commandParameters = global:FilterOutCommonParams -Params $command.ParameterSets.Parameters + $command = $_ + $commandHelp = Get-Help $command.Name -ErrorAction SilentlyContinue + $commandParameters = global:FilterOutCommonParams -Params $command.ParameterSets.Parameters $commandParameterNames = $commandParameters.Name - $helpLinks = $commandHelp.relatedLinks.navigationLink.uri + $helpLinks = $commandHelp.relatedLinks.navigationLink.uri } BeforeAll { # These vars are needed in both discovery and test phases so we need to duplicate them here - $command = $_ - $commandName = $_.Name - $commandHelp = Get-Help $command.Name -ErrorAction SilentlyContinue - $commandParameters = global:FilterOutCommonParams -Params $command.ParameterSets.Parameters - $commandParameterNames = $commandParameters.Name - $helpParameters = global:FilterOutCommonParams -Params $commandHelp.Parameters.Parameter - $helpParameterNames = $helpParameters.Name + $command = $_ + $commandName = $_.Name + $commandHelp = Get-Help $command.Name -ErrorAction SilentlyContinue + $commandParameters = global:FilterOutCommonParams -Params $command.ParameterSets.Parameters + $commandParameterNames = $commandParameters.Name + $helpParameters = global:FilterOutCommonParams -Params $commandHelp.Parameters.Parameter + $helpParameterNames = $helpParameters.Name } # If help is not found, synopsis in auto-generated help is the syntax diagram @@ -81,12 +78,12 @@ Describe "Test help for <_.Name>" -ForEach $commands { (Invoke-WebRequest -Uri $_ -UseBasicParsing).StatusCode | Should -Be '200' } - Context "Parameter <_.Name>" -Foreach $commandParameters { + Context "Parameter <_.Name>" -ForEach $commandParameters { BeforeAll { - $parameter = $_ - $parameterName = $parameter.Name - $parameterHelp = $commandHelp.parameters.parameter | Where-Object Name -eq $parameterName + $parameter = $_ + $parameterName = $parameter.Name + $parameterHelp = $commandHelp.parameters.parameter | Where-Object Name -EQ $parameterName $parameterHelpType = if ($parameterHelp.ParameterValue) { $parameterHelp.ParameterValue.Trim() } } @@ -107,7 +104,7 @@ Describe "Test help for <_.Name>" -ForEach $commands { } } - Context "Test <_> help parameter help for " -Foreach $helpParameterNames { + Context "Test <_> help parameter help for " -ForEach $helpParameterNames { # Shouldn't find extra parameters in help. It "finds help parameter in code: <_>" {