Skip to content

Conversation

@PrzemyslawKlys
Copy link
Member

No description provided.

* 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`.
… 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`.
* 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.
…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.
…ation tooling

* Add module files and examples: `PowerGuardian.psd1`, `PowerGuardian.psm1`, `.gitignore`, `README.MD`, `Examples/ShowModule.ps1`.
* Add build script `Build/Build-Module.ps1` with formatting, packaging and build/artefact configuration.
* Add .NET project `Sources/PowerGuardian/PowerGuardian.csproj` and core implementation:
  * Cmdlets: `ShowPGModuleDocumentationCommand`, `InstallPGModuleDocumentationCommand`
  * Services: `DocumentationFinder`, `DocumentationInstaller`, `Renderer`
  * Models/Enums: `DeliveryOptions`, `DocumentKind`, `DocumentationLayout`, `OnExistsOption`
  * Utilities: `ModuleResolver`, `PathHelper`
* Implement documentation discovery, planning and installation flows (Readme/Changelog/License handling, Internals path, delivery/layout options, list/open/raw modes) and file rendering.
… code highlighter

* Add new PowerShell public commands `Show-ProjectDocumentation` and `Install-ProjectDocumentation` and deprecation wrappers `Show-ModuleDocumentation` / `Install-ModuleDocumentation` that forward to the new implementations.
* Introduce C# cmdlets `ShowModuleDocumentationCommand` and `InstallModuleDocumentationCommand` (renamed from PG variants) with `Show-Documentation` / `Install-Documentation` aliases for parity.
* Implement markdown rendering improvements via `Renderer` (OfficeIMO.Markdown + Spectre.Console) and add `CodeHighlighter` service to syntax-highlight code blocks (PowerShell + C#).
* Update `PowerGuardian.csproj` to include documentation generation, new package refs and a project reference; add PowerGuardian project to solution file.
* Update module manifest `PowerGuardian.psd1` to export the new aliases/cmdlets and adjust cmdlet export lists.
* Add PowerShell public script implementations for install/show project docs (copying README/CHANGELOG/LICENSE, handling Intro/Upgrade/links, layout/on-exists options).
* Update example `ShowModule.ps1` to display `-Readme -Changelog`.
* Preserve backward compatibility via aliases and wrappers while warning about deprecation.
…runing helpers

* Flesh out many cmdlet help Markdown files (examples, SYNOPSIS, DESCRIPTION and parameter metadata) including:
  * `Get-MissingFunctions`, `Initialize-PortableModule`, `Initialize-PortableScript`, `Install-ModuleDocumentation`
  * `Invoke-ModuleBuild`, `New-Configuration*` docs (`Command`, `Execute`, `Format`, `Information`, `Manifest`, `Test`)
  * `Show-ModuleDocumentation` improvements and new `Show-ProjectDocumentation` doc page
  * Add `Install-ProjectDocumentation.md` and update `Readme.md` to reference project docs
* Add efficient repository scanning helpers:
  * Add `Private/Get-PSPDirectoriesPruned.ps1` and `Private/Get-PSPFilesPruned.ps1`
  * Update `Private/Start-PreparingVariables.ps1` to use pruned directory/file scanning and improved exclude/prune handling (reduces recursion and ignores common build/output folders)
* Module/tooling updates:
  * PowerGuardian: set `RefreshPSD1Only = $true` in build config, fix example in `Examples/ShowModule.ps1`, add `RequireLicenseAcceptance` and tidy manifest (`PowerGuardian.psd1`, `PowerGuardian.psm1`)
  * PSPublishModule manifest: export `Install-ProjectDocumentation` and `Show-ProjectDocumentation`, add `RequireLicenseAcceptance` in PSData
* Build/runtime dependency change:
  * Bump `PowerShellStandard.Library` to `5.1.1` and mark `PrivateAssets="all"` in `Sources/PowerGuardian/PowerGuardian.csproj`

Motivation: complete and standardize help documentation for public commands, add project-level documentation installer/viewer, and improve build/scan reliability and performance by pruning common irrelevant folders during project scans.
…markdown rendering

* Add `HighlightJson` and `HighlightYaml` and wire `json|jsonc` and `yaml|yml` language handling in `CodeHighlighter.Highlight`.
* Improve `RenderInlineCell` to parse inline Markdown via `MarkdownReader.ParseInlineText` and reuse `RenderInlines` for consistent rendering (with fallback on parse errors).
* Make `RenderInlines` public so it can be reused from `RenderInlineCell`.
* Minor cleanup: remove redundant no-op line in C# comment handling.
…and doc switches

* Introduce syntax highlighters and pipeline: `IHighlighter`, `PowerShellHighlighter`, `JsonHighlighter`, `GenericHighlighter`, `HighlighterPipeline` — selects best highlighter and falls back gracefully.
* Add `JsonRendererPreference` enum and new cmdlet params `-JsonRenderer` / `-DefaultCodeLanguage` in the C# `ShowModuleDocumentation` cmdlet; parse prefs and pass to `Renderer`.
* Enhance `Renderer` to:
  * Render JSON code blocks using `Spectre.Console.Json.JsonText` (when not using `System` preference) with graceful fallback to tokenizer pipeline.
  * Use tokenizer pipeline for other code blocks and respect a default code language when none is specified.
* Add `-All` and `-Links` switches to `Show-ProjectDocumentation` (PowerShell) to display standard doc order (Intro, README, CHANGELOG, LICENSE) and print `ImportantLinks`; implement corresponding behavior in the C# cmdlet.
* Update project dependencies: add `Spectre.Console.Json` and conditionally add `System.Text.Json` for `net472`.
* Remove deprecated helper wrappers (`Install-ModuleDocumentation`, `Show-ModuleDocumentation`) and update module exports and example invocation to use `Show-ProjectDocumentation`.
* Minor robustness improvements and fallbacks to ensure graceful degradation on parse/tokenize failures.
… example

* Add `Sources/PowerGuardian/Services/HtmlExporter.cs` to export module documentation to HTML using HtmlForgeX and TablerTabs.
  * Renders markdown with configured `MarkdownOptions` (headings base level, table mode, sanitize, autolink, allow relative links).
  * Writes sanitized timestamped HTML file, creates directories as needed, and optionally opens the generated file in the default browser.
* Update `Module-PowerGuardian/Examples/ShowModule.ps1` to demonstrate `Mailozaurr` (Readme, `DefaultCodeLanguage` PowerShell, `-OpenHtml`, `-Changelog`, `-HeadingRules H1AndH2`) and call `EFAdminManager` with `-OpenHtml`.
…model

* Introduce `HeadingRuleMode` enum to represent heading validation modes: `None`, `H1`, `H1AndH2`.
* Add internal `DocumentItem` model with `Title`, `Kind` (e.g. FILE, INTRO, UPGRADE, LINKS) and `Content` for markdown storage.
…kenizer` to `ShowModuleDocumentationCommand`

* Add cmdlet parameters: `HeadingRules`, `ExportHtmlPath`, `OpenHtml`, and `DisableTokenizer`.
* Map `HeadingRules` to `HeadingRuleMode` and pass it to `Renderer`; respect `DisableTokenizer` when creating the renderer.
* Implement optional HTML export path/Open behavior: assemble `DocumentItem` list from files, `INTRO`/`UPGRADE` delivery texts and `Links`, then call `HtmlExporter.Export` and emit the exported path (with verbose output).
* Preserve existing file resolution, link handling and fallback messages when reading files.
…nd add `HtmlForgeX` ProjectReference

* Update PackageReference for `System.Text.Json` in the net472 ItemGroup to 9.0.9 to align with runtime expectations and avoid compatibility issues.
* Add ProjectReference to `HtmlForgeX` so HTML/exporter-related code is included in the build/publish outputs.
…dering and add block spacing

* Update example `ShowModule.ps1` to remove `-OpenHtml` and explicit `-HeadingRules` usage.
* Stop passing `HeadingRules`/`DisableTokenizer` into `Renderer` from `ShowModuleDocumentationCommand`; renderer now focuses on JSON renderer + default language.
* `Renderer`:
  * Render JSON using `JsonText` directly and fall back to highlighter markup (no panel) on parse failure.
  * Render code blocks and other markdown blocks with trailing blank lines for improved console spacing.
  * Use content variable consistently and avoid panel headers for code blocks.
  * `RenderInlines` now concatenates inline parts without inserting extra spaces.
* `PowerShellHighlighter`:
  * Prefer `Extent` (`StartOffset`/`EndOffset`) for multi-line token offsets and robustly fall back to `Start`/`Length`.
  * Minor reorder to improve reliability when tokenizing.
* `HighlighterPipeline` comment clarified ordering intent.

These changes fix multi-line token offset handling, simplify JSON/code output, and improve console readability.
* Remove `Content` from token tuple and stop reflecting the `Content` property.
* Build segments from `code.Substring(start, length)` so token text always aligns with `Extent`/`Start` offsets and preserves original spacing (including multi-line).
* Simplifies token handling and avoids issues when tokens lack or expose mismatched `Content`.
…nd related models/services

* Add `RepositoryPaths` and `RepositoryBranch` to `New-ConfigurationDelivery` and bump delivery schema to `1.3`.
* Extend `Show-ModuleDocumentation` with remote options (`-FromRepository`, `-PreferRepository`, `-RepositoryBranch`, `-RepositoryToken`, `-RepositoryPaths`) and render/export switches; implement remote fetch/list/render flow and env-var token fallbacks.
* Introduce `RepoInfo` model and `RepoUrlParser` utility plus `GitHubRepository` and `AzureDevOpsRepository` services to resolve default branch, fetch file content and list folder files.
* Render remote markdown/text via new `Renderer.ShowContent` (supports raw output and Markdown rendering).
* Add XML documentation to enums and models, add `OutputType` and parameter docs to `Install-ModuleDocumentation` cmdlet, and tidy parameter usage/comments.
* Add `System.Net.Http` reference for `net472` in `PowerGuardian.csproj`.
* Failures during remote operations are handled safely (non-throwing fallbacks).
…checks

* Enable `#nullable enable` and annotate nullable reference types across cmdlets, services and models (`ShowPGModuleDocumentationCommand`, `InstallPGModuleDocumentationCommand`, `DocumentationFinder`, `DocumentationInstaller`, `RepoInfo`, etc.) to improve null-safety.
* Update rendering/highlighter contracts and implementations: make `IHighlighter.Highlight` nullable and propagate `string?` returns; adjust `GenericHighlighter`, `JsonHighlighter`, `PowerShellHighlighter` to return `null` on fallback and handle reflection/token offsets robustly.
* Harden remote repo clients: add defensive `TryGetProperty` checks and null guards in `GitHubRepository` and `AzureDevOpsRepository`; fix filename extraction to avoid substring/IndexOf errors.
* Improve renderer resiliency: guard `Markup.Escape` and `Rule` usage with null-coalescing, ensure link/image inline rendering handles nulls.
* Add XML documentation comments to several types (`RepoInfo`, `DocumentItem`, `Renderer`, `PathHelper`, repo clients, installers) and remove minor dead/unused code (`HtmlExporter` unused `idx`).
* Project config: treat missing XML doc comments as errors by enabling `<WarningsAsErrors>CS1591</WarningsAsErrors>` in the `PowerGuardian.csproj`.

These changes aim to reduce NREs, improve code clarity and maintainability, and make highlighting/rendering pipelines more robust.
…ion, tests and examples

* Introduce `DocumentationPlanner` to centralize document selection, local vs remote resolution and export planning.
* Add `IRepoClient` and `RepoClientFactory` plus implementations for GitHub/AzureDevOps to enable fetching repository files; integrate into planner.
* Refactor cmdlets into partials and move parameter definitions to `*.Parameters.cs` for `ShowModuleDocumentationCommand` and `InstallModuleDocumentationCommand`.
* Add `DocumentItem.Path` and `AssemblyInfo` with `InternalsVisibleTo("PowerGuardian.Tests")` to support internal access from tests.
* Add `PowerGuardian.Tests` project and `DocumentationPlannerTests` to validate planner behavior.
* Add example scripts under `Module-PowerGuardian/Examples` (Show/Install usage).
* Update solution to include the `PowerGuardian.Tests` project.
* Misc: null-safety / defensive fixes, minor renderer and highlighter argument/escape improvements, and small parsing/trim/fallback fixes in repo clients.

*Motivation*: centralize and test document planning and remote repository support, improve code organization (partial classes) and enable unit tests and examples for easier development and validation.
…election` and HTML/export + repo backfill

* Implement full console `Get-ModuleDocumentation` cmdlet (parameters, rendering, repo options) and add its parameter partial class.
* Introduce `DocumentationSelection` enum to provide high-level `-Type` selections and map them into fine-grained flags for both `Get-` and `Show-` cmdlets.
* Extend `Show-ModuleDocumentation` parameters: rename/alias export path to `OutputPath`/`Path`, add `DoNotShow` switch and `Type` handling; always export HTML by default (respecting `DoNotShow`).
* Add remote repository backfill in `DocumentationPlanner` to fetch missing standard docs (README/CHANGELOG/LICENSE) using repo client, and add discovery for `Scripts` and `Docs` tabs under `Internals`.
* Add `FileName` to `DocumentItem` and include it when planning/exporting items.
* Update `HtmlExporter` to group `SCRIPT` and `DOC` items into nested tabs, filter standard docs, and use file names for tab titles.
* Add example script `ModuleDocs-Demo.ps1` and simplify `ShowModule.ps1` usage; update module manifest to export `Get-ModuleDocumentation`.
* General robustness: parameter validation, defensive file/dir checks, and tolerant remote errors (fail-safe).
…ags and rich HTML exporter

* Introduce `ModuleInfoModel` and `ModuleDependency` to capture manifest metadata and dependency graph.
* Add new cmdlet parameters: `-SkipRemote`, `-SkipDependencies`, `-SkipCommands`, `-Fast`, `-MaxCommands`, `-HelpTimeoutSeconds`; `-Fast` maps to the three skip flags.
* Extract manifest data (name, version, PSData fields, required/external dependencies) and enrich dependency info from installed modules (one level deep).
* Pass metadata into `DocumentationPlanner` and conditionally disable remote backfill when `-SkipRemote` is set.
* Overhaul `HtmlExporter` API to accept `ModuleInfoModel` and `Action<string>?` logger; render:
  * Module information card
  * Structured tabs for docs, scripts and docs groupings
  * Dependencies tables + VisNetwork graph
  * Commands tab with per-command `Get-Help` rendering and timeout handling
* Ensure document contents are read when missing content is provided by plan; expose verbose logging during planning/export.
* Minor PowerShell fixes/examples:
  * Example `ShowModule.ps1` now calls `Show-ModuleDocumentation -Verbose`.
  * `Show-ProjectDocumentation.ps1` heading punctuation and link formatting fixes.

Notes:
* `HtmlExporter` signature changed and new model types were added — update callers if consumed externally.
…rter command/help rendering

* Add `HelpAsCode` SwitchParameter to `ShowModuleDocumentationCommand` and `ModuleInfoModel`; wire through `ProcessRecord` to module metadata.
* Increase default `HelpTimeoutSeconds` from 3 to 60 to reduce premature Get-Help timeouts.
* HtmlExporter improvements:
  * Set `Document { LibraryMode = LibraryMode.Online }`.
  * Group and de-duplicate dependencies for the DataTable display.
  * Prevent duplicate nodes in the VisNetwork graph by tracking added node ids.
  * Precompute help entries via `BuildHelpMap` (with line counts/logging) to avoid repeated Get-Help calls.
  * Render command help inside fenced PowerShell code blocks when `HelpAsCode` is enabled.
…TML exporter rendering

* Add `GetHelpParser` service to parse `Get-Help -Full` into a structured `CommandHelpModel`, with timeout and robust extraction of synopsis, syntax, parameters, examples, inputs/outputs, notes and related links.
* Integrate structured help into `HtmlExporter`: `BuildHelpMap` now returns both parsed `CommandHelpModel` and raw help fallback; render structured help via `RenderHelpPanel` / `RenderHelpMarkdown` when available; fall back to raw markdown and respect `HelpAsCode` option.
* Revamp Dependencies UI in HTML exporter:
  * Introduce a "Declared" tab showing root / direct / nested rows (sorted by level/parent/name) with exportable data table.
  * Add a hierarchical VisNetwork "Diagram" tab (larger canvas, hierarchical layout, physics disabled) for clearer dependency graphs.
* Normalize dependency names by trimming whitespace when parsing manifests and dependency entries to avoid spurious empty / whitespace-only names.
* Enable example `Show-ModuleDocumentation -Name 'EFAdminManager' -Verbose` in `Examples/ShowModule.ps1`.
…ling improvements

* Add `Set-ModuleDocumentation` cmdlet and `TokenStore` to persist repository tokens (DPAPI on Windows, Base64 fallback for cross-platform).
* DocumentationPlanner: backfill repository `Docs` roots, respect `DocumentationOrder`, use persisted tokens when available and add remote docs as `DocumentItem` (Source="Remote").
* HtmlExporter: allow raw HTML in Markdown, split Docs into Local/Repository subtabs when both present, improve markdown/rendering options and tab layout.
* Add `Source` property to `DocumentItem` to distinguish local vs remote docs.
* Public DSL/API updates:
  * `New-ConfigurationDelivery` — add `RepositoryPaths`, `RepositoryBranch`, `DocumentationOrder` and examples.
  * `Install-ProjectDocumentation` / `Show-ProjectDocumentation` — add examples, parameter formatting, and behavior notes about root README/CHANGELOG/LICENSE inclusion.
* Improvements to build tooling and reliability:
  * Capture and show `dotnet publish/build/pack` output in `Start-LibraryBuilding` and `Invoke-DotNetReleaseBuild` for better error diagnostics.
  * Preserve `Docs` when `IncludeAll 'Internals\'` is used in `Start-PreparingVariables` so `Internals\Docs` is bundled.
* Robust AST parsing: `Get-AstTokens` filters reserved/control tokens, handles edge cases and avoids false positives.
* Manifest/packaging tweaks: export `Set-ModuleDocumentation`, add `ProjectUri` in manifest and tidy csproj references.
* Docs/README cleanup and removal of obsolete help markdown files.

This change enables fetching and merging documentation straight from module repositories (GitHub/Azure DevOps), improves UX and error visibility during .NET builds, and provides a secure way to persist access tokens.
…exporter rendering

* Show command examples: switch active example and tidy Example comments in sources.
* `ShowPGModuleDocumentationCommand`:
  * Track which manifest path was used and use it for repeated manifest lookups.
  * Pull `RepositoryBranch` and `RepositoryPaths` from delivery metadata (and manifest/hashtable fallbacks) when parameters are not specified.
  * Add verbose diagnostics for repository parsing and token source (parameter/env/stored), and report repository/path intent without leaking secrets.
  * Map exporter warning messages into `WriteWarning` and expose branch/paths fallback into planner.
* `DocumentationPlanner`:
  * Mark planned items with `Source = "Remote"` or `Source = "Local"` and normalize remote item titles (remove legacy "(remote)" suffix).
* `HtmlExporter`:
  * Annotate local copies of `README`/`CHANGELOG`/`LICENSE` with " (local)" when remote versions exist to clarify origin.
  * Rename "Docs" tab to "Documentation" and preserve `(local)` suffixes in tab titles while ignoring legacy `(remote)` suffixes.
  * Improve help rendering by using markdown rendering APIs and richer verbose logs for structured help metadata.
  * Emit exporter labelling warnings via provided logger.
* `Start-PreparingVariables`:
  * Ensure `Docs` is not globally pruned when `IncludeAll` requests `Internals\` and include files without extension from `IncludeAll` directories.
* Misc:
  * Remove stray trailing blank line in `Get-PSPDirectoriesPruned.ps1`.
  * Minor example/example-comment cleanup in sample `ShowModule.ps1`.

These changes improve repository backfill heuristics, make origin of documentation explicit, and produce clearer HTML exports and verbose diagnostics.
… and HTML exporter rendering

* Set `FileName` and `Title` for remote `README`/`CHANGELOG`/`LICENSE` items so tabs and filenames are correct.
* Treat files returned from `RepositoryPaths` as `DocumentItem` with `Kind = "DOC"` (preserve `Path`/`FileName`) instead of adding generic `FILE`.
* Preserve local `FILE` items when `PreferRepository` so remote docs can be compared with local copies.
* Update `HtmlExporter` to prefer `FileName` when deriving base labels and avoid mutating local titles.
* Add source badges (`local` / `remote`) and include source in tab log messages.
* Switch markdown table rendering to DataTables and enable responsive/export/state-save options (plus a toggle view button) for better table UX.
…e help/example parsing & HTML rendering

* Add `ExamplesMode` and `ExamplesLayout` enums and expose them as parameters on `Show-ModuleDocumentation` (`ExamplesMode`, `ExamplesLayout`).
* Wire new options through `ModuleInfoModel` and cmdlet metadata so the `HtmlExporter` honors chosen sourcing (`Auto/Raw/Maml`) and layout (`MamlDefault/ProseFirst/AllAsCode`).
* Enhance `GetHelpParser`:
  * Make parser partial and accept `ExamplesMode`.
  * Implement raw `EXAMPLES` extraction from `Get-Help` output to preserve original formatting.
  * Improve structured MAML handling: normalize CRLF, compute line counts, set per-example `Mode` diagnostics.
  * Add AST/token-based splitting and robust heuristics to separate code vs remarks; expose helpers for reclassification and trailing-narrative splitting.
* Add `ExampleClassifier` service for simple prompt-first classification (prompt lines => code, rest => remarks) used by raw Markdown formatting.
* Update `HtmlExporter`:
  * Integrate `ExamplesMode` and `ExamplesLayout` when building help map and rendering commands.
  * Support three example rendering layouts: `MamlDefault` (code then remarks), `ProseFirst` (remarks then code), and `AllAsCode` (combined fenced block).
  * Improve dependency graph node IDs to avoid collisions per level and add smoother dashed edges for child links.
  * Add per-example verbose diagnostics when rendering structured help.
  * Various robustness fixes (null-safe trimming, fallback Markdown formatting).
* Minor improvements:
  * Tweak `Show-ProjectDocumentation` link printing for clearer output formatting.
  * Update example usage file `ShowModule.ps1` (reorder/uncomment example invocations to demonstrate new `ExamplesLayout` options).

This enables more accurate preservation and presentation of command examples and gives users control over how examples are sourced and laid out in rendered docs.
…-ProjectDocumentation`

* Replace legacy `Install-ModuleDocumentation` occurrences with `Install-ProjectDocumentation` in:
  * Docs/Install-ProjectDocumentation.md
  * Public/Install-ProjectDocumentation.ps1
* Documentation-only change — no functional behavior modified. Ensures examples match the actual cmdlet name.
…psd1` and add install-documentation samples

* Add `Examples/Install-Documentation01.ps1` and `Install-Documentation02.ps1` demonstrating `Install-ModuleDocumentation`.
* Update `ModuleDocs-Demo.ps1`, `Show-All.ps1` and `Show-PreferRepository.ps1` to import via `"$PSScriptRoot\..\PowerGuardian.psd1"` and tidy comments/formatting.
* Update `Build/Build-Module.ps1` manifest `ModuleVersion` to `0.5.0`.
…e `#nullable enable`, and guard null in repo URL check

* Removed `#nullable enable` directives from multiple cmdlet sources to unify nullable context.
* Added missing `[Parameter]` attributes to `RequiredVersion`, `Layout` and `OnExists` in `InstallModuleDocumentationCommand.Parameters.cs`.
* Replaced `projectUri.Contains(...)` with a null-safe check `(projectUri ?? string.Empty).IndexOf(..., StringComparison.OrdinalIgnoreCase) >= 0` to prevent possible NRE.
* Minor tidy: removed stray trailing blank lines and adjusted duplicated example blocks in `ShowModuleDocumentationCommand`.
…d guard doc install/copy logic

* Enable nullable via project file and remove duplicate / file-level `#nullable enable` (project-level nullability now controls compilation).
* DocumentationInstaller: prevent accidental overwrites — copy license only when missing or when `force` is specified; preserve merge semantics by skipping existing files unless overwrite/force is set; ensure CopyTree respects overwrite behavior.
* GetHelpParser: add null-coalescing guard when concatenating `codeOut` to avoid potential null reference issues.
* Add repository `NuGet.config` to direct NuGet `globalPackagesFolder` to `.nuget/packages`.
* Keep restored packages within the repo layout for consistent restores and to avoid using the user profile cache.
* Configuration-only change; no code behavior modified.
* Correct `PowerGuardian.psd1` manifest to set `ModuleVersion` from `1.0.0` to `0.5.0`.
* Ensures manifest version aligns with intended package/release version.
…et-ModuleDocumentation` and `Show-ModuleDocumentation`

* Add example scripts to Module-PowerGuardian/Examples:
  * `Get-Documentation01.ps1` — console view, `-Type All`, HTML export and save to path (`-DoNotShow`).
  * `Show-Documentation01.ps1` — show all local docs (README/CHANGELOG/LICENSE/UPGRADE/Intro).
  * `Show-Documentation02.ps1` — prefer repository docs and open combined HTML (`-PreferRepository -OpenHtml`).
  * `Show-Documentation03.ps1` — assorted examples for `EFAdminManager` (Verbose, `-PreferRepository`, `-ExamplesLayout` variants).
* Each example imports the local `PowerGuardian.psd1` to standardize module loading.
…es` and revamp remote-doc handling

* Add `DocumentationMode` enum and `Mode` selection (`PreferLocal`/`PreferRemote`/`All`) for remote vs local tab policy.
* Introduce `-Online` switch on `Show-ModuleDocumentation` (legacy `PreferRepository`/`FromRepository`/`RepositoryPaths` are mapped as legacy inputs).
* Add `ShowDuplicates` toggle and make remote access explicit via `Online`/`Mode` instead of legacy boolean flags.
* Remove high-level `-Type` and granular `-Readme`/`-Changelog`/`-License` public parameters (mapped internally when needed).
* Planner now only fetches remote docs when `Online` is requested and exposes remote candidates; selection policy applied in exporter.
* HtmlExporter: implement robust grouping/de-duplication and selection logic for README/CHANGELOG/LICENSE (honors `Mode` and `ShowDuplicates`), normalize content comparisons, add info logging for collapse/selection decisions.
* Change default `ExamplesLayout` to `ProseFirst` and wire through model/meta; update ExamplesMode handling.
* Tweak `Fast` handling to no longer imply skipping remote fetch; adjust request/metadata mapping accordingly.
* Update `ModuleInfoModel` to include `Mode`, `Online`, `ShowDuplicates`, and new `ExamplesLayout` default.
* Improve XML/header comments across services (`DocumentationFinder`, `ExampleClassifier`, `GetHelpParser`, `HtmlExporter`, `DocumentationInstaller`) and adjust DataTables defaults/export/toggle settings.
* Examples: update Show-Documentation03.ps1 to use `-Online` and `-ShowDuplicates`.

This refactors remote-document workflow to be explicit and more predictable, simplifies cmdlet surface area, and improves HTML export behavior for local vs remote content.
* Update Module-PSMaintenance Build script: set `NETProjectPath` to "$PSScriptRoot\..\..\PSMaintenance".
* Update Module-PSPublishModule Build script: fix `Remove-Item` to target module's Lib folder and set `NETProjectPath` to "$PSScriptRoot\..\..\PSPublishModule".
* Add/update `.gitignore` files: expand Visual Studio gitignore for Module-PSMaintenance and add new `.gitignore` for Module-PSPublishModule.
* Replace updated compiled binaries for PSPublishModule (Lib/Core and Lib/Default).
* Minor code hygiene: add nullable annotations to `OnImportAndRemove.MyResolveEventHandler` signature and ensure newline at EOF.
* Implement `Install-ModuleScript` cmdlet (C#) to copy PowerShell scripts from a module's `Internals\Scripts` (or fallbacks) into a flattened destination.
  * Parameters: `-Name`/`-Module`, `-Path`, `-ScriptsRelativePath`, `-Include`/`-Exclude`, `-OnExists`, `-Force`, `-ListOnly`.
  * Defaults: include `*.ps1`, `ScriptsRelativePath` = `Internals\Scripts`, `OnExists` = `Merge`.
  * Behavior: resolves module location, searches recursively, supports `ShouldProcess`, and handles conflicts (`Skip`, `Stop`, `Merge`, `Overwrite`).
* Export the new cmdlet in `PSMaintenance.psd1`.
* Add example `Examples/Install-Scripts01.ps1` demonstrating basic usage.
* Add comprehensive `README.md` covering installation, usage, configuration examples and build/publish guidance.
* Add `CHANGELOG.md` with full project history up to v2.0.19 to track changes and releases.
* Initial import of documentation files to improve project discoverability and release tracking.
@claude
Copy link

claude bot commented Nov 5, 2025

Pull Request Review - PR #44

Executive Summary

This PR implements a significant repository restructuring to separate the PowerShell module code from the C# .NET project. The changes move all module-related files into a Module/ subdirectory while keeping the .NET project (PSPublishModule.csproj) at the root level.

Overall Assessment: ⚠️ Requires Changes - The restructuring is well-intentioned and mostly well-executed, but there is a critical CI/CD issue that will cause build failures.


Critical Issues 🚨

1. GitHub Actions Workflow Not Updated

Severity: CRITICAL - This will break CI/CD

The .github/workflows/BuildModule.yml file references the old paths:

  • Line 29: .\Build\Build-Module.ps1
  • Line 33: .\PSPublishModule.Tests.ps1
  • Line 45: .\Build\Build-Module.ps1 (Linux)
  • Line 49: .\PSPublishModule.Tests.ps1 (Linux)
  • Line 61: .\Build\Build-Module.ps1 (MacOS)
  • Line 65: .\PSPublishModule.Tests.ps1 (MacOS)

Required Fix:

# Should be updated to:
.\Module\Build\Build-Module.ps1
.\Module\PSPublishModule.Tests.ps1

Without this change, all CI builds will fail immediately after merge.


Code Quality & Best Practices ✅

Positives:

  1. Consistent File Organization - All module files properly relocated under Module/ directory
  2. .editorconfig Added - Excellent addition for C# code consistency (244 lines of comprehensive formatting rules)
  3. Path Updates - Build script correctly updated:
    • NETProjectPath changed from Sources\PSPublishModule to ..\PSPublishModule (Build-Module.ps1:122)
    • Lib path updated from PSPublishModule\Lib to PSPublishModule\Module\Lib (Build-Module.ps1:8)
  4. Documentation Improvements - Expanded help documentation for multiple cmdlets
  5. No Breaking Changes - Module structure maintained; only directory layout changed

Minor Issues:

  1. Hardcoded Local Path (Line 8 of Build-Module.ps1)

    Remove-Item -Path "C:\Support\GitHub\PSPublishModule\Module\Lib" ...

    While this is for local development only (as noted in comments), consider using a relative path for better portability:

    Remove-Item -Path "$PSScriptRoot\..\..\Module\Lib" -Recurse -Force -ErrorAction SilentlyContinue
  2. Typo in Comment (Build-Module.ps1:6)

    # "rmeove" should be "remove"

Performance Considerations ⚡

No negative performance impact identified.

The restructuring is purely organizational and doesn't affect:

  • Module loading performance
  • Build times
  • Runtime execution

Security Assessment 🔒

No security concerns identified.

  • No secrets or credentials exposed
  • Certificate references use environment-based checks ($Env:COMPUTERNAME)
  • PFX handling uses base64 encoding via secure parameters
  • .gitignore properly updated to exclude sensitive files

Test Coverage 📊

Test coverage maintained:

  • All test files moved consistently to Module/Tests/
  • Main test file PSPublishModule.Tests.ps1 relocated to Module/
  • No tests removed or modified
  • Test structure preserved

Concern: Once the CI/CD workflow is fixed, all tests should pass, but currently they cannot run due to incorrect paths in the workflow.


Architectural Review 🏗️

Rationale for Changes:

The restructuring appears to support a cleaner separation of concerns:

  • Root level: .NET project, solution files, NuGet config
  • Module/ subdirectory: PowerShell module with all its components

This is a reasonable pattern for projects that combine .NET and PowerShell code.

File Count:

  • Changed files: 266
  • Additions: 4,045 lines
  • Deletions: 573 lines

Most changes are file relocations (renames). Actual code changes are minimal.


Recommendations 📝

Must Fix Before Merge:

  1. ✅ Update .github/workflows/BuildModule.yml to use correct paths (all 3 platform builds)

Should Fix:

  1. Fix typo: "rmeove" → "remove" in Build-Module.ps1:6
  2. Consider making the Remove-Item path relative instead of hardcoded

Nice to Have:

  1. Update README.MD to document the new directory structure
  2. Consider adding a migration guide for contributors using local clones

Testing Recommendations 🧪

Before merging, verify:

  1. ✅ CI/CD builds pass on all platforms (Windows, Linux, MacOS)
  2. ✅ Module builds successfully from new location
  3. ✅ All Pester tests pass
  4. ✅ Published artifacts include correct paths
  5. ✅ Artefacts are created in expected locations

Summary

This is a well-structured refactoring with a clear architectural vision. The code changes are minimal and focused. However, the critical oversight of not updating the CI/CD workflow paths will cause immediate build failures.

Action Required: Update the GitHub Actions workflow file, then this PR will be ready to merge.

Estimated Time to Fix: ~5 minutes


Review conducted by Claude Code. For questions about this review, please reference the specific line numbers and file paths mentioned above.

…ata.PSData.Delivery`/`Repository`

* Replace legacy `PSPublishModuleDelivery` references in docs and cmdlets with `PrivateData.PSData.Delivery`.
* Update `New-PersonalManifest.ps1` to emit a structured `Delivery` node and an optional `Repository` node (branch/paths), and include `Delivery`/`Repository` in validated PrivateData entries.
* Update public cmdlets (`Install-ProjectDocumentation`, `Show-ProjectDocumentation`) and documentation to read from the new nodes.
* Fix minor typo in `Build-Module.ps1` ("rmeove" → "remove").
@PrzemyslawKlys PrzemyslawKlys merged commit 0abadda into master Nov 5, 2025
1 of 4 checks passed
@PrzemyslawKlys PrzemyslawKlys deleted the PowerGuardian branch November 5, 2025 08:26
@claude
Copy link

claude bot commented Nov 5, 2025

PR Review: Power Guardian (#44)

Overview

This PR represents a significant architectural improvement to PSPublishModule with 4,068 additions and 574 deletions across 266 files. The changes focus on repository restructuring, standardization, and enhanced functionality.

✅ Strengths

1. Excellent Repository Restructuring

  • Moving all module content into a dedicated Module/ subdirectory greatly improves project organization
  • Clear separation between PowerShell module code and C# project
  • Consistent directory structure (Public, Private, Tests, Docs, Examples) follows PowerShell best practices

2. Code Standardization

  • Addition of .editorconfig with comprehensive C# coding standards ensures consistency
  • Formatting configuration in Build-Module.ps1 maintains PowerShell code quality
  • Well-documented functions with updated help files

3. Enhanced Functionality

  • Addition of Microsoft.PowerShell.PSResourceGet as a required module modernizes package management
  • New test failure analysis capabilities (Get-ModuleTestFailures)
  • Comprehensive test coverage with 7 test suites covering encoding, versioning, building, and analysis

4. Clean C# Implementation

The OnImportAndRemove.cs implementation is well-structured:

  • Proper interface implementation (IModuleAssemblyInitializer, IModuleAssemblyCleanup)
  • Appropriate runtime detection for .NET Framework vs Core
  • Good error handling in assembly resolution

5. Documentation

  • 43 markdown documentation files provide comprehensive coverage
  • Updated examples organized by functionality category
  • Integration and refactoring summaries for maintainability

⚠️ Issues & Concerns

1. Critical: Hardcoded Absolute Paths

Severity: HIGH

The build script contains hardcoded developer-specific paths that will break on other systems:

Module/Build/Build-Module.ps1:8

Remove-Item -Path "C:\Support\GitHub\PSPublishModule\Module\Lib" -Recurse -Force -ErrorAction SilentlyContinue

Recommendation:

$ModuleRoot = Split-Path -Parent $PSScriptRoot
Remove-Item -Path "$ModuleRoot\Lib" -Recurse -Force -ErrorAction SilentlyContinue

This pattern appears in 21 files across the repository. While many are in examples/documentation, the build script should use relative paths.

2. Security: Certificate Hardcoding

Severity: MEDIUM

Module/Build/Build-Module.ps1:115

CertificateThumbprint = '483292C9E317AA13B07BB7A96AE9D1A5ED9E7703'

While protected by hostname check (EVOMONSTER), this exposes certificate metadata. Consider:

  • Moving to environment variables or secure configuration
  • Adding documentation about certificate requirements
  • Commented-out credentials on lines 116-117 are good practice

3. Potential Bug: IsNet5OrHigher() Incomplete

Severity: LOW

PSPublishModule/OnImportAndRemove.cs:79-84

The version detection only checks for .NET 5-8 explicitly. This will fail with .NET 9+:

private bool IsNet5OrHigher() {
    return System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription.StartsWith(".NET 5", ...) ||
           System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription.StartsWith(".NET 6", ...) ||
           // ... only up to .NET 8
}

Recommendation:

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, out int version)) {
            return version >= 5;
        }
    }
    return false;
}

Note: The method IsNet5OrHigher() is defined but never used in the codebase, so impact is minimal.

4. Performance: Assembly Resolution Inefficiency

Severity: LOW

PSPublishModule/OnImportAndRemove.cs:35-54

The MyResolveEventHandler enumerates all directory files on every assembly resolution attempt. Consider:

  • Caching the file list or assembly mappings
  • Early exit if directory is null
  • Using AssemblyName.Name for more precise matching instead of StartsWith

Current implementation:

var filesInDirectory = Directory.GetFiles(directoryPath); // Called repeatedly

Recommendation: Cache results in a static dictionary on first call.

5. Maintenance: .gitignore Redundancy

Severity: LOW

Module/.gitignore:388-389

CLAUDE.md
.claude/*

These entries should be in the root .gitignore rather than Module-specific file, as they apply repository-wide.

6. Documentation: Missing Version History

The IsNetCore() and IsNet5OrHigher() methods exist but are unused. Consider either:

  • Removing dead code
  • Adding TODO comments if planned for future use
  • Using them to replace the single IsNetFramework() check with more granular logic

📊 Test Coverage Assessment

Excellent test coverage with:

  • 7 comprehensive test suites (26,000+ lines of test code)
  • Tests for new Get-ModuleTestFailures functionality
  • Build process validation
  • Encoding/line ending conversion tests
  • Version management tests
  • Pester v5.7.1 framework

The main test runner (PSPublishModule.Tests.ps1) properly orchestrates all tests. Good practice disabling InModuleScope tests in build script (line 153) to avoid conflicts.

🔒 Security Assessment

Overall: Good

✅ Proper error handling with -ErrorAction SilentlyContinue
✅ No credentials in code (commented out properly)
✅ Certificate operations protected by hostname check
⚠️ Certificate thumbprint exposure (low risk)
✅ Assembly loading from trusted module directory only
✅ No user input directly executed

🎯 Recommendations

High Priority

  1. Replace hardcoded paths in Build-Module.ps1 with relative paths
  2. Add CI/CD validation to catch environment-specific paths

Medium Priority

  1. Move certificate configuration to environment variables or config file
  2. Fix .NET version detection for future-proofing
  3. Add caching to assembly resolver for better performance

Low Priority

  1. Clean up unused methods (IsNetCore, IsNet5OrHigher if not needed)
  2. Consolidate .gitignore entries to root level where appropriate
  3. Add CHANGELOG entry documenting this restructuring (if not already done)

📝 Summary

This is a well-executed refactoring that significantly improves the repository structure and maintainability. The main concerns are:

  • Hardcoded paths that limit portability
  • Minor future-proofing issues in version detection
  • Small performance optimization opportunities

The restructuring follows PowerShell module best practices, test coverage is excellent, and the C# integration is clean. With the hardcoded path fix, this would be production-ready.

Overall Assessment: ✅ Approved with Minor Changes Recommended

Great work on this architectural improvement! 🎉


Note: This PR is already merged. These recommendations should be considered for follow-up PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants