Skip to content

Add Plaster demos (XML + JSON) and fix three source-run path bugs#469

Merged
psjamesp merged 4 commits into
mainfrom
Update-Readme
Jun 18, 2026
Merged

Add Plaster demos (XML + JSON) and fix three source-run path bugs#469
psjamesp merged 4 commits into
mainfrom
Update-Readme

Conversation

@psjamesp

Copy link
Copy Markdown
Contributor

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 in demos/output/ (gitignored).

  1. XML greeter — classic format, ${PLASTER_PARAM_X} syntax, choice, templateFile, message
  2. JSON greeter — same template, modern ${X} syntax, &-labels without XML escaping
  3. JSON modulemultichoice (native [0,1] default), pattern validation, user-fullname (git), conditional content, newModuleManifest, modify
  4. Discovery + authoringGet-PlasterTemplate, New-PlasterManifest -AddContent, Test-PlasterManifest, then scaffolds from the just-authored template

See 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 $PSScriptRoot points one level below the module root. (The compiled build in Output/ flattens to the root, so it was unaffected.)

File Fix
Plaster/Public/Test-PlasterManifest.ps1 XSD schema path falls back one level up when not found under Public/
Plaster/Public/Get-PlasterTemplate.ps1 bundled Templates/ path falls back one level up
Plaster/Private/ConvertFrom-JsonContentAction.ps1 suppress AppendChild pipeline leakage in modify actions (was returning Object[] instead of a single XmlElement, breaking JSON modify)

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

psjamesp and others added 3 commits April 7, 2026 17:02
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>
@psjamesp psjamesp closed this Jun 18, 2026
# Conflicts:
#	CHANGELOG.md
#	Plaster/Private/ConvertFrom-JsonContentAction.ps1
#	Plaster/Private/Test-JsonManifestContent.ps1
#	Plaster/Public/Invoke-Plaster.ps1
#	tests/JsonTest.Tests.ps1
@psjamesp psjamesp reopened this Jun 18, 2026
@psjamesp psjamesp merged commit c5da01d into main Jun 18, 2026
2 of 5 checks passed
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>
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.

1 participant