Add Plaster demos (XML + JSON) and fix three source-run path bugs#469
Merged
Conversation
Adds a demos/ folder with four runnable presentation demos covering both
manifest formats with dummy data:
1. XML greeter script (classic ${PLASTER_PARAM_X} syntax)
2. JSON greeter (same template, modern ${X} syntax)
3. JSON module: multichoice, pattern validation, user-fullname,
conditional content, newModuleManifest, modify
4. Discovery + authoring: Get-PlasterTemplate / New-PlasterManifest /
Test-PlasterManifest, then scaffold from the authored template
Fixes three latent bugs surfaced by running templates from source, all from
$PSScriptRoot resolving to Public/ when functions are dot-sourced:
- Test-PlasterManifest: XSD schema path now falls back one level up
- Get-PlasterTemplate: bundled Templates/ path now falls back one level up
- ConvertFrom-JsonContentAction: suppress AppendChild pipeline leakage in
'modify' actions (was returning Object[] instead of a single element)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
# Conflicts: # CHANGELOG.md # Plaster/Private/ConvertFrom-JsonContentAction.ps1 # Plaster/Private/Test-JsonManifestContent.ps1 # Plaster/Public/Invoke-Plaster.ps1 # tests/JsonTest.Tests.ps1
HeyItsGilbert
added a commit
that referenced
this pull request
Jun 19, 2026
## Summary The `Run Tests (PowerShell 5.1)` CI job has been failing on every PR (e.g. #468, #469, #470) during `build.ps1 -Bootstrap` with: ``` PSDepend\0.3.8\Private\SemanticVersion.ps1: Cannot add type. The type name 'System.Management.Automation.SemanticVersion' already exists. ``` ### Root cause PSDepend `0.3.8` ships an **unguarded** `Add-Type` for its Windows PowerShell 5.1 `SemanticVersion` polyfill: ```powershell if ($PSVersionTable.PSVersion.Major -lt 6) { Add-Type -TypeDefinition $code } ``` On PS 5.1, `System.Management.Automation.SemanticVersion` is not a built-in type, so this runs. When PSDepend is imported a **second time** in the same session — which the bootstrap triggers because PSDepend is pinned as a dependency of itself in `requirements.psd1` — the `Add-Type` throws, since the type already exists in the AppDomain. PowerShell 6+ is unaffected: the type is built in, so the guard short-circuits. PSDepend `0.4.1` (newly released) adds the missing existence guard, making the polyfill idempotent: ```powershell if ($PSVersionTable.PSVersion.Major -lt 6 -and -not ('System.Management.Automation.SemanticVersion' -as [type])) { Add-Type -TypeDefinition $code } ``` ### Fix Bump the PSDepend pin in `requirements.psd1` from `0.3.8` → `0.4.1`. ## Reproduction / verification Reproduced on local Windows PowerShell 5.1 (`5.1.26100`) by pre-defining the type then dot-sourcing each version's `SemanticVersion.ps1`: | PSDepend | Result | | --- | --- | | `0.3.8` | ❌ `Cannot add type. The type name 'System.Management.Automation.SemanticVersion' already exists.` | | `0.4.1` | ✅ no-op (guard skips `Add-Type`) | CI will confirm the PS 5.1 job goes green on this PR. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
demos/folder with four runnable presentation demos exercising both manifest formats with dummy data, and fixes three latent source-run path bugs uncovered while building them.Demos (
demos/)Run all with
.\demos\Run-Demos.ps1(non-interactive, deterministic — safe for a live demo). Output lands indemos/output/(gitignored).${PLASTER_PARAM_X}syntax,choice,templateFile,message${X}syntax,&-labels without XML escapingmultichoice(native[0,1]default),patternvalidation,user-fullname(git), conditional content,newModuleManifest,modifyGet-PlasterTemplate,New-PlasterManifest -AddContent,Test-PlasterManifest, then scaffolds from the just-authored templateSee demos/README.md for presenter talking points.
Bug fixes
All three share one root cause: when Plaster runs from source, its functions are dot-sourced from
Public//Private/, so$PSScriptRootpoints one level below the module root. (The compiled build inOutput/flattens to the root, so it was unaffected.)Plaster/Public/Test-PlasterManifest.ps1Public/Plaster/Public/Get-PlasterTemplate.ps1Templates/path falls back one level upPlaster/Private/ConvertFrom-JsonContentAction.ps1AppendChildpipeline leakage inmodifyactions (was returningObject[]instead of a singleXmlElement, breaking JSONmodify)Testing
All four demos verified end-to-end from both the source module and a freshly rebuilt compiled
Output/module on PowerShell 7.6.2.🤖 Generated with Claude Code