Refactor input validation in New-AsBuiltConfig, New-AsBuiltReport, and New-AsBuiltReportConfig scripts#73
Refactor input validation in New-AsBuiltConfig, New-AsBuiltReport, and New-AsBuiltReportConfig scripts#73rebelinux wants to merge 2 commits intoAsBuiltReport:devfrom
Conversation
…d New-AsBuiltReportConfig scripts - Updated string comparisons from `""` to `''` for consistency and clarity. - Enhanced validation logic for user inputs in various prompts to ensure default values are set correctly. - Excluded 'AsBuiltReport.Chart' and 'AsBuiltReport.Diagram' from the list of installed report modules in multiple locations to streamline report generation.
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
Refactors interactive input validation and report-module discovery in the New-AsBuiltConfig, New-AsBuiltReport, and New-AsBuiltReportConfig PowerShell entrypoints, while also updating workflow tooling and standardizing quoting.
Changes:
- Excludes
AsBuiltReport.ChartandAsBuiltReport.Diagramfrom discovered report modules (validation + argument completers). - Normalizes string literals to single quotes in multiple scripts and style assets.
- Bumps the Bluesky release-post GitHub Action version in the release workflow.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| AsBuiltReport.Core/Src/Public/New-AsBuiltReportConfig.ps1 | Filters module discovery to omit Chart/Diagram and updates quoting in validation/completer logic. |
| AsBuiltReport.Core/Src/Public/New-AsBuiltReport.ps1 | Filters available report modules, normalizes quoting, and adjusts message output code paths. |
| AsBuiltReport.Core/Src/Public/New-AsBuiltConfig.ps1 | Normalizes empty-string checks and defaulting behavior in interactive prompts. |
| AsBuiltReport.Core/AsBuiltReport.Core.Style.ps1 | Switches embedded Base64 image string to single-quoted literal. |
| .github/workflows/Release.yml | Updates zentered/bluesky-post-action from v0.3.0 to v0.4.0. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| # If StyleFilePath was specified, ensure the file provided in the path exists, otherwise exit with error | ||
| # If StyleFilePath was specified, ensure the file provided in the path exists, otherwise exit with error'AsBuiltReport.Core' |
There was a problem hiding this comment.
The inline comment has an unexpected trailing string ("'AsBuiltReport.Core'") which looks like an accidental paste and makes the guidance confusing. Please remove the stray text so the comment reads cleanly.
| # If StyleFilePath was specified, ensure the file provided in the path exists, otherwise exit with error'AsBuiltReport.Core' | |
| # If StyleFilePath was specified, ensure the file provided in the path exists, otherwise exit with error |
| #region Generate PScribo document | ||
| # if Verbose has been passed | ||
| if ($PSCmdlet.MyInvocation.BoundParameters["Verbose"].IsPresent) { | ||
| if ($PSCmdlet.MyInvocation.BoundParameters['Verbose'].IsPresent) { |
There was a problem hiding this comment.
$PSCmdlet.MyInvocation.BoundParameters['Verbose'] is $null when -Verbose isn’t supplied, so accessing .IsPresent can throw "You cannot call a method on a null-valued expression" and prevent the non-verbose branch from running. Use a null-safe check like $PSBoundParameters.ContainsKey('Verbose') (or equivalent) before deciding which path to take.
| if ($PSCmdlet.MyInvocation.BoundParameters['Verbose'].IsPresent) { | |
| if ($PSBoundParameters.ContainsKey('Verbose')) { |
| # Find the root folder where the module is located for the report that has been specified | ||
| try { | ||
| $Module = Get-Module -Name "AsBuiltReport.$Report" -ListAvailable | Where-Object { $_.name -ne 'AsBuiltReport.Core' } | Sort-Object -Property Version -Descending | Select-Object -Unique | ||
| $Module = Get-Module -Name "AsBuiltReport.$Report" -ListAvailable | Where-Object { $_.name -ne 'AsBuiltReport.Core' -and $_.name -ne 'AsBuiltReport.Chart' -and $_.name -ne 'AsBuiltReport.Diagram' } | Sort-Object -Property Version -Descending | Select-Object -Unique |
There was a problem hiding this comment.
This Get-Module ... | Sort-Object Version -Descending | Select-Object -Unique can still return multiple module versions (because different versions are distinct objects), which makes $Module an array. That can lead to incorrect path building / truthy array behavior in if (Test-Path ...) and confusing output. Prefer selecting a single module (e.g., take the first after sorting) to ensure $Module.ModuleBase and $Module.Name are scalars.
| $Module = Get-Module -Name "AsBuiltReport.$Report" -ListAvailable | Where-Object { $_.name -ne 'AsBuiltReport.Core' -and $_.name -ne 'AsBuiltReport.Chart' -and $_.name -ne 'AsBuiltReport.Diagram' } | Sort-Object -Property Version -Descending | Select-Object -Unique | |
| $Module = Get-Module -Name "AsBuiltReport.$Report" -ListAvailable | Where-Object { $_.name -ne 'AsBuiltReport.Core' -and $_.name -ne 'AsBuiltReport.Chart' -and $_.name -ne 'AsBuiltReport.Diagram' } | Sort-Object -Property Version -Descending | Select-Object -First 1 |
Refactor input validation in New-AsBuiltConfig, New-AsBuiltReport, and New-AsBuiltReportConfig scripts
""to''for consistency and clarity.