-
-
Notifications
You must be signed in to change notification settings - Fork 13
feat(delivery): ✨ add delivery metadata commands and manifest support #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
* Add `Public/New-ConfigurationDelivery.ps1` to emit Options.Delivery (Enable, InternalsPath, IncludeRootReadme, IncludeRootChangelog, Schema) for build config. * Add `Public/Install-ModuleDocumentation.ps1` to install bundled `Internals` content (and optional README/CHANGELOG) using `PrivateData.PSData.PSPublishModuleDelivery`. * Export `New-ConfigurationDelivery` and `Install-ModuleDocumentation` in `PSPublishModule.psd1`. * Update `Private/New-PersonalManifest.ps1` to validate and emit `PSPublishModuleDelivery` into `PrivateData.PSData` when `Options.Delivery` is present.
…f README/CHANGELOG * Add `New-ConfigurationDelivery` public cmdlet and help (`Public/New-ConfigurationDelivery.ps1`, `Docs/New-ConfigurationDelivery.md`). * Add `Install-ModuleDocumentation` public cmdlet and help (`Public/Install-ModuleDocumentation.ps1`, `Docs/Install-ModuleDocumentation.md`) to copy bundled `Internals` content and optional root `README*/CHANGELOG*`. * Emit `PSPublishModuleDelivery` into module manifest when `Options.Delivery` is enabled via `New-PersonalManifest`. * Stage and copy requested root `README*/CHANGELOG*` and non-merge `*.ps1` from `Internals` during build/merge in `Start-ModuleMerging`. * Export new functions and register `New-ConfigurationDelivery`/`Install-ModuleDocumentation` in `PSPublishModule.psd1`; add `Microsoft.PowerShell.PSResourceGet` to required modules and `Build-Module` config. * Bump `ModuleVersion` to `2.0.26`. * Misc: small formatting and path/variable cleanups in `Start-ArtefactsBuilding` and newline fix in `New-ConfigurationInformation`.
Pull Request Review: feat(delivery): ✨ add delivery metadata commands and manifest supportSummaryThis PR adds new functionality for embedding and installing bundled module documentation/internals. The implementation includes two new public functions and updates to the manifest generation logic. Overall, the code is well-structured and follows PowerShell best practices. ✅ Strengths
🔍 Code Quality ObservationsNew-ConfigurationDelivery.ps1Line 61: Uses the correct Line 47-57: Schema versioning ( Install-ModuleDocumentation.ps1Line 52: Good use of generic list for performance: $resolvedTargets = [System.Collections.Generic.List[string]]::new()Line 77: Uses Line 83-84: Smart fallback logic for boolean values: $includeReadme = if ($null -ne $delivery.IncludeRootReadme) { [bool]$delivery.IncludeRootReadme } else { $true }Private/New-PersonalManifest.ps1Line 102: Good validation - adds Line 127-129: Conditional logic correctly checks both existence and Enable flag before emitting metadata.
|
Code Review: PR #41 - Delivery Metadata Commands and Manifest SupportSummaryThis PR adds a delivery system for bundling and installing module documentation/examples with clear metadata support. Two new public functions are introduced with manifest generation logic extended. Strengths
Critical Issues1. Path Traversal Security Risk (Install-ModuleDocumentation.ps1:83,87) $resolvedBase = [System.IO.Path]::GetFullPath($Module.ModuleBase)
$resolvedInternals = [System.IO.Path]::GetFullPath($internalsPath)
if (-not $resolvedInternals.StartsWith($resolvedBase)) {
throw "InternalsPath attempts to access paths outside module base"
}2. Test-ModuleManifest Warnings (Install-ModuleDocumentation.ps1:80) High Priority3. Missing Structure Validation (New-PersonalManifest.ps1:128-130) 4. Inconsistent Error Handling (Install-ModuleDocumentation.ps1:102,110,117) 5. Parameter Validation (New-ConfigurationDelivery.ps1:45) Medium Priority6. Test Coverage 7. Documentation Performance & Security
ConclusionWell-crafted PR following PowerShell conventions with clean, documented code. Main concerns are input validation and path security that should be addressed before merge. Recommendation: Approve with changes requested for security validation |
Pull Request Review: feat(delivery) - Add delivery metadata commands and manifest supportSummaryThis PR introduces a new delivery system for bundling and installing internal documentation/examples alongside PowerShell modules. The implementation includes two new public cmdlets ( Code Quality & Best Practices✅ Strengths
|
… flow * Add `.editorconfig` to enforce consistent C# formatting. * Add `Private/Copy-PSPDirectoryTree.ps1` helper to copy directory trees with optional overwrite. * Enhance `Register-Certificate`: * Add full function documentation header. * Default include patterns to scripts only and add `-ExcludePath` support to skip folders (e.g. `Internals`) before signing. * Apply exclusion filtering for both OpenAuthenticode and Windows flows. * Update `Start-ModuleSigning.ps1` to build `Include`/`ExcludePath` lists from configuration: * Respect `IncludeBinaries`, `IncludeExe`, `IncludeInternals`, and `ExcludePaths` options. * Pass `ExcludePath` to `Register-Certificate`. * Extend `New-ConfigurationBuild.ps1` with signing-related parameters (`SignIncludeInternals`, `SignIncludeBinaries`, `SignIncludeExe`, `SignCustomInclude`, `SignExcludePaths`) and map bound params into an `Options.Signing` block for backward-compatible config emission. * Improve `Install-ModuleDocumentation.ps1`: * Add `Layout` and `OnExists` parameters and preserve legacy `CreateVersionSubfolder` behavior. * Use `Copy-PSPDirectoryTree` for merge/overwrite semantics and safer copying of root `README`/`CHANGELOG`. * Minor tidy-ups: * C# formatting cleanup in `Sources` files. * Remove trailing newline change in `PSPublishModule.psd1`.
Pull Request Review: Delivery Metadata Commands and Manifest SupportThank you for this comprehensive feature addition! This PR adds valuable functionality for bundling and deploying internal documentation. Strengths
Potential Bugs and Issues - High Priority
Medium Priority Issues
Security Concerns
Performance
Test Coverage - MISSING
Recommendations: Add Pester tests for all new public functions covering parameter combinations, pipeline input, error handling, and edge cases. Recommendations SummaryMust fix before merge:
Should fix: Overall AssessmentThis is a well-designed and valuable feature with sound architecture and good API design. Main concerns are error handling robustness and test coverage. Once addressed, this will be a solid addition. Recommendation: Request changes to address high-priority issues and add test coverage before merging. |
* Add new `Show-ModuleDocumentation` cmdlet (Public/Show-ModuleDocumentation.ps1) with full help and examples; add README entry and export in `PSPublishModule.psd1`. * Add private helpers `Resolve-DocFile.ps1` and `Write-Heading.ps1` to support doc resolution and output formatting. * Extend `Install-ModuleDocumentation` (public + help): * Add `-Layout`/`-OnExists` options and document layout behavior. * Add `-ListOnly` and `-Open` switches and implement listing + open-after-copy behavior. * Update examples and help text for clarity. * Flesh out `Register-Certificate` help and behavior: * Add `-ExcludePath`, clarify `-Include` defaults, include `-IncludeChain` options and default timestamp server. * Rework parameter docs and defaults for usability and CI scenarios. * Update `New-ConfigurationBuild` docs: * Document new signing-related switches (`-SignIncludeInternals`, `-SignIncludeBinaries`, `-SignIncludeExe`, `-SignCustomInclude`, `-SignExcludePaths`) and improve many parameter descriptions. * Adjust parameter position metadata in help to reflect new additions. * Minor README and help cleanups across doc files for consistency.
Pull Request Review: feat(delivery) - Add delivery metadata commands and manifest supportSummaryThis PR adds a comprehensive delivery/documentation system to PSPublishModule, enabling modules to bundle and install internal documentation (Internals folder) with metadata support. The implementation includes three new public cmdlets, signing enhancements, and build configuration improvements. Overall Assessment✅ Recommended for merge with minor suggestions for improvement. The PR demonstrates excellent code quality with well-structured functionality, comprehensive documentation, and thoughtful error handling. The feature is well-designed and follows PowerShell best practices. Code Quality & Best Practices ⭐Strengths
Suggestions for Improvement1. Register-Certificate.ps1:108-112 - Duplicate Internals exclusion logicThe exclusion logic appears to hardcode the Internals path exclusion even when it's already in the ExcludePath array: $items = $items | Where-Object {
$full = $_.FullName
($full -notlike '*\Internals\*' -and $full -notlike '*/Internals/*') -and (
($ExcludePath | ForEach-Object { $full -like ("*" + $_ + "*") }) -notcontains $true)
}Issue: The Internals check is hardcoded separately from the ExcludePath logic, which could cause confusion if someone passes "Internals" in ExcludePath. Suggestion: Simplify to rely on ExcludePath being populated correctly by Start-ModuleSigning: if ($ExcludePath) {
$items = $items | Where-Object {
$full = $_.FullName
-not ($ExcludePath | Where-Object { $full -like "*$_*" })
}
}This same pattern appears at lines 108-112 and 126-130 (Windows and Linux paths). Potential Bugs & Issues 🐛1. Install-ModuleDocumentation.ps1:181-182 - Redundant Start-Process callif ($IsWindows) { Start-Process -FilePath $readme.FullName | Out-Null }
else { Start-Process -FilePath $readme.FullName | Out-Null }Issue: Both branches are identical, making the if/else unnecessary. Fix: Simplify to: Start-Process -FilePath $readme.FullName | Out-Null2. Copy-PSPDirectoryTree.ps1:21 - Silent failure on copy error} catch {
if (-not (Test-Path -LiteralPath $target)) { throw }
# If not overwriting and file exists, skip silently
}Issue: The catch block silently suppresses ALL errors when the target exists, not just "file exists" errors. Other errors (permissions, disk full, etc.) would be hidden. Suggestion: Be more specific about which errors to suppress: } catch {
if (-not (Test-Path -LiteralPath $target)) {
throw # File doesn't exist, so this is a real error
}
# Target exists and we're not overwriting - skip silently
# Consider: Write-Verbose "Skipping existing file: $target"
}3. Show-ModuleDocumentation.ps1:159 - Missing error handling on Start-Processif ($Open) {
Start-Process -FilePath $target | Out-Null
return
}Issue: Start-Process can fail (file association missing, permission denied) but errors are not handled. Suggestion: Wrap in try/catch like Install-ModuleDocumentation does at line 177-189. 4. OnImportAndRemove.cs:79-83 - Incomplete .NET version detectionprivate bool IsNet5OrHigher() {
return System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription.StartsWith(".NET 5", StringComparison.OrdinalIgnoreCase) ||
// ... only checks .NET 5-8
}Issue: Hardcoded version checks will fail for .NET 9+. The method exists but isn't used anywhere in the code. Suggestion: Either remove unused methods (IsNetCore, IsNet5OrHigher) or implement a more robust version check: private bool IsNet5OrHigher() {
var description = System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription;
if (description.StartsWith(".NET ", StringComparison.OrdinalIgnoreCase)) {
var versionString = description.Substring(5).Split(' ')[0];
if (int.TryParse(versionString[0].ToString(), out int majorVersion)) {
return majorVersion >= 5;
}
}
return false;
}Performance Considerations ⚡1. Install-ModuleDocumentation.ps1:157-172 - Multiple file system iterations$rootFiles = @(Get-ChildItem -Path $Module.ModuleBase -File -ErrorAction SilentlyContinue)
if ($includeReadme -and $rootFiles.Count -gt 0) {
foreach ($file in $rootFiles) {
if ($file.Name -like 'README*') { ... }
}
}
if ($includeChlog -and $rootFiles.Count -gt 0) {
foreach ($file in $rootFiles) {
if ($file.Name -like 'CHANGELOG*') { ... }
}
}Impact: Minor - iterates through all root files twice when both README and CHANGELOG are requested. Optimization: Single pass with filter: $rootFiles = @(Get-ChildItem -Path $Module.ModuleBase -File -ErrorAction SilentlyContinue)
foreach ($file in $rootFiles) {
if ($includeReadme -and $file.Name -like 'README*') {
try { Copy-Item -LiteralPath $file.FullName -Destination $dest -Force:$Force.IsPresent -ErrorAction Stop } catch { }
}
if ($includeChlog -and $file.Name -like 'CHANGELOG*') {
try { Copy-Item -LiteralPath $file.FullName -Destination $dest -Force:$Force.IsPresent -ErrorAction Stop } catch { }
}
}2. Register-Certificate.ps1:106 & 124 - Recursive Get-ChildItem with IncludeUsing
Security Concerns 🔒1. Certificate Handling - Well implemented ✅
2. Path Traversal Protection - Good ✅
3. Code Signing Logic - Secure ✅
Minor Concern: Copy-PSPDirectoryTree.ps1 - No validationThe function doesn't validate that Source is not a parent of Destination, which could cause infinite recursion if misconfigured. Consider adding a check: if ($Destination.StartsWith($Source)) {
throw "Destination cannot be a subdirectory of Source"
}Test Coverage 🧪Missing: No test files are included in this PR. Recommendations:
Documentation 📚Strengths
Suggestions
Architecture & Design 🏗️Excellent Design Decisions
Minor Suggestions
Additional Notes.editorconfig AdditionThe new .editorconfig file is a great addition for C# consistency. The settings look reasonable and follow Microsoft conventions. Version BumpThe PR bumps ModuleVersion to 2.0.26, which is appropriate for a feature addition. ConclusionThis is a high-quality PR that adds valuable functionality to PSPublishModule. The code is well-structured, follows PowerShell best practices, and includes comprehensive documentation. The issues identified are minor and don't block merging, but addressing them would further improve code quality and maintainability. Recommendation: ✅ Approve and merge after considering the suggestions above (optional improvements). Great work! 🎉 |
…ort for module documentation * Add new delivery options: `IncludeRootLicense`, `LicenseDestination`, `ImportantLinks`, `IntroText`, `UpgradeText`, `IntroFile`, `UpgradeFile` (schema bumped to 1.2). * Expose `RequireLicenseAcceptance` in manifest generation so builders can require a root license file. * Enhance build/merging to copy/normalize `LICENSE*` into `Internals`/`Root`/`Both` and ensure a root `license.txt` when `RequireLicenseAcceptance` is set. * Extend `Resolve-DocFile` to resolve `LICENSE` and `UPGRADE` patterns robustly (multiple filename variants). * Update `Install-ModuleDocumentation`: * Add `-NoIntro` switch. * Copy `LICENSE`, `IntroFile` and `UpgradeFile` when configured. * Display Intro text and `ImportantLinks` after install unless suppressed. * Update `Show-ModuleDocumentation` to support `-License`, `-Intro` and `-Upgrade` flags and to list license files. * Update help/docs (`*.md`) to describe the new parameters and behavior.
…leDocumentation` descriptions, and add `-NoIntro` param * Add `-RequireLicenseAcceptance` to New-ConfigurationManifest docs with guidance about requiring a root `license.txt` and builder normalization of `LICENSE`/`LICENSE.md`. * Replace placeholder texts in Show-ModuleDocumentation for `-License`, `-Intro`, and `-Upgrade` with concrete behavior and fallback rules. * Add `.PARAMETER NoIntro` to Install-ModuleDocumentation to suppress installed intro/links, and remove a duplicate `$includeLicense` assignment (minor cleanup).
…tation`, `Install-ModuleDocumentation` and `Invoke-ModuleBuild` * Add `License`, `Intro`, and `Upgrade` parameter descriptions and related examples to `Show-ModuleDocumentation`. * Expand examples in `Install-ModuleDocumentation` (include `-Layout`, `-OnExists`, `-ListOnly`, `-NoIntro -Open`) and normalize path example; simplify `Start-Process` usage when opening README or folder (remove redundant platform branch). * Improve parameter documentation for `IncludeCustomCode`, `IncludeToArray`, `LibrariesCore`, `LibrariesDefault`, and `LibrariesStandard` in `Invoke-ModuleBuild`. * Ensure file ends with a newline.
* Add full comment-based help (SYNOPSIS, DESCRIPTION, PARAMETER, EXAMPLE, NOTES) to: - `Get-MissingFunctions` - `Initialize-PortableModule` - `Initialize-PortableScript` - `New-ConfigurationCommand` - `New-ConfigurationExecute` - `New-ConfigurationFormat` - `New-ConfigurationInformation` - `New-ConfigurationTest` * Improves discoverability via `Get-Help` and clarifies usage/examples for each public cmdlet. * No behavioral or functional changes; purely documentation enhancements.
Pull Request Review - PR #41SummaryThis PR adds delivery metadata commands and manifest support, introducing two new public functions ( Code Quality & Best Practices✅ Strengths
|
Public/New-ConfigurationDelivery.ps1to emit Options.Delivery (Enable, InternalsPath, IncludeRootReadme, IncludeRootChangelog, Schema) for build config.Public/Install-ModuleDocumentation.ps1to install bundledInternalscontent (and optional README/CHANGELOG) usingPrivateData.PSData.PSPublishModuleDelivery.New-ConfigurationDeliveryandInstall-ModuleDocumentationinPSPublishModule.psd1.Private/New-PersonalManifest.ps1to validate and emitPSPublishModuleDeliveryintoPrivateData.PSDatawhenOptions.Deliveryis present.