Skip to content

Fixed conditional attribute evaluation for test#445

Merged
psjamesp merged 1 commit intoPowerShellOrg:v2from
tstager:v2
Apr 12, 2026
Merged

Fixed conditional attribute evaluation for test#445
psjamesp merged 1 commit intoPowerShellOrg:v2from
tstager:v2

Conversation

@tstager
Copy link
Copy Markdown
Contributor

@tstager tstager commented Apr 1, 2026

The JSON conditional evaluation on the PLASTER_Options variable always evaluates to false in the PowerShell gallery v2.0 version of Plaster. I provided a fix for the issue. You by no means have to merge this. I just wanted to show you where the problem with JSON templates was happening. It is working great now and I am extremely excited to see that this has been updated, and JSON manifest and templating are great.

Copilot AI review requested due to automatic review settings April 1, 2026 01:14
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a bug where condition expressions in JSON Plaster manifests that reference parameters (e.g., ${Feature}) were not being resolved to the internal PLASTER_PARAM_* variables, causing conditions to evaluate incorrectly (typically false).

Changes:

  • Update condition evaluation to translate JSON-style ${ParamName} references into ${PLASTER_PARAM_ParamName} before evaluation.
  • Add Pester tests covering JSON manifest condition evaluation for content directives, parameter conditions, and multichoice parameters.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
Plaster/Private/Test-ConditionAttribute.ps1 Rewrites JSON-style parameter references in condition expressions so they evaluate against PLASTER_PARAM_* variables.
tests/ConditionEval.Tests.ps1 Adds test coverage to verify JSON manifest condition behavior for parameter-referencing expressions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Plaster/Private/Test-ConditionAttribute.ps1
Comment thread tests/ConditionEval.Tests.ps1
@psjamesp psjamesp merged commit 3d78fca into PowerShellOrg:v2 Apr 12, 2026
3 of 4 checks passed
psjamesp added a commit that referenced this pull request Apr 13, 2026
…zed build/test (#449)

## Overview

This PR lands the long-running `v2` branch into `master`, shipping
Plaster **2.0.0-alpha1**. It's a large drop (~50 commits, ~115 files,
+11.5k / -3.2k) and touches nearly every part of the project, so the
sections below break it down by theme rather than by commit.

Target version: `Plaster.psd1` → `ModuleVersion = '2.0.0'`, `Prerelease
= 'alpha1'`.

## Highlights

- **JSON manifest support** — Plaster templates can now be authored as
JSON in addition to XML, with a full `plaster-manifest-v2.json` schema,
bidirectional conversion, and validation.
- **Modular source layout** — the monolithic `Invoke-Plaster.ps1` /
`NewPlasterManifest.ps1` / `GetModuleExtension.ps1` files have been
decomposed into per-function `Public/` and `Private/` files.
- **PowerShell 7.x + cross-platform** — Windows, Linux, macOS all
supported; minimum PS version is now 5.1.
- **Pester 5.x test suite** — large coverage expansion with per-function
tests.
- **Modernized build** — psake + PowerShellBuild + PSDepend, with a
`-Bootstrap` switch for clean CI installs.
- **Publish workflow** rewired end-to-end and validated against
GitHub-hosted runners.

## What changed

### Module architecture
- Split `Plaster/InvokePlaster.ps1` (1500+ lines),
`Plaster/NewPlasterManifest.ps1`, and `Plaster/GetModuleExtension.ps1`
into discrete `Public/` and `Private/` function files.
- New `Plaster/Private/` helpers for things that were previously inline:
`ConvertFrom-JsonManifest`, `ConvertTo-JsonManifest`,
`ConvertFrom-JsonContentAction`, `ConvertTo-JsonContentAction`,
`Copy-FileWithConflictDetection`, `Expand-FileSourceSpec`,
`Get-ManifestsUnderPath`, `Get-PlasterManifestType`,
`Initialize-PredefinedVariables`, `Invoke-ExpressionImpl`,
`Invoke-PlasterOperation`, `New-ConstrainedRunspace`,
`Resolve-ModuleVersionString`, `Resolve-ProcessParameter`,
`Start-Process*`, `Write-PlasterLog`, and friends.
- `Plaster.psm1` / `Plaster.psd1` updated to match the new layout.

### JSON manifest support (new)
- `Plaster/Schema/plaster-manifest-v2.json` — full JSON Schema for v2
manifests.
- JSON ↔ internal-model converters: `ConvertFrom-JsonManifest`,
`ConvertTo-JsonManifest`, plus content-action variants.
- `Get-PlasterManifestType` detects XML vs JSON manifests;
`Test-PlasterManifest` validates both.
- Example JSON manifests under `examples/` (`plasterManifest.json`,
`plasterManifest-validatePattern.json`, `plasterManifest_fr-FR.json`).
- Fixed error handling around file and template actions in JSON flow.

### Cross-platform / PS7
- Minimum PowerShell version raised to 5.1; null-coalescing operators
removed from hot paths for PS5.1 compatibility (#443).
- Default encoding changed from `Default` to `UTF-8-NoBOM`.
- Path separator handling normalized; constrained-runspace compatibility
fixes for PS7.
- Parameter default value storage fixed on non-Windows.

### Tests
- Migrated to **Pester 5.x** (breaking change for test authors).
- New per-function test files: `Get-ModuleExtension.Tests.ps1`,
`Get-PlasterManifestPathForCulture.Tests.ps1`,
`Initialize-PredefinedVariables.Tests.ps1`,
`Resolve-ModuleVersionString.Tests.ps1`,
`New-PlasterManifest.Tests.ps1`, etc.
- Added `Help.tests.ps1`, `Manifest.tests.ps1`, `Meta.tests.ps1`,
`MetaFixers.psm1` (imported from Stucco).
- Large fixture added for module resolution tests
(`tests/Fixtures/ModuleList.xml`).
- Conditional-attribute evaluation tests fixed (#445).

### Build & tooling
- `build.ps1` refactored for cleaner parameter handling, with `-Task`,
`-Bootstrap`, and `-Help` parameter sets.
- `-Bootstrap` provisions PSDepend (pinned to PowerShellGet v2), then
runs a try-import-first-then-install pattern against
`requirements.psd1`.
- `requirements.psd1` pins PSDepend 0.3.8, Pester 5.7.1, psake 4.9.1,
BuildHelpers 2.0.16, PowerShellBuild 0.7.2, PSScriptAnalyzer 1.24.0.
- `psakeFile.ps1` delegates to PowerShellBuild; `CopyDirectories`
configured for `en-US`, `Schema`, `Templates`.
- `debugHarness.ps1` refactored for the new module layout.
- `.vscode/` tasks + settings refreshed; `.markdownlint.json` +
`cspell.json` added.

### CI / publish workflow
- `.github/workflows/publish.yaml` now runs on `windows-latest`, uses
`ModuleFast-action` to pre-stage deps, and invokes `./build.ps1 -Task
Publish -Bootstrap`.
- `.github/workflows/PesterReports.yml` updated permissions and action
versions.
- Dead placeholder \`internal-nuget-repo\` registration removed from the
bootstrap path (was failing \`Register-PSRepository\` URI validation on
GitHub runners).

### Docs
- README rewritten for v2.
- CHANGELOG reformatted to Keep a Changelog.
- Logo updated to make the 2.0 branding clearer.
- Examples directory expanded.

## Breaking changes

- **Minimum PowerShell version** is now 5.1 (was 3.0).
- **Test framework** is Pester 5.x — any downstream tests authored
against Pester 3/4 will need updating.
- **Default encoding** changed to `UTF-8-NoBOM`.
- Internal module layout changed significantly; anything dot-sourcing
Plaster internals by path will break (public API is unchanged).

## Test plan

- [ ] CI green on `v2` (publish workflow dry-run + Pester reports)
- [ ] \`./build.ps1 -Bootstrap -Task Test\` passes locally on Windows PS
5.1
- [ ] \`./build.ps1 -Bootstrap -Task Test\` passes on Windows PS 7
- [ ] Smoke test on Linux / macOS (PS 7)
- [ ] \`Invoke-Plaster\` against an XML manifest still works
(regression)
- [ ] \`Invoke-Plaster\` against a JSON manifest works end-to-end
- [ ] \`Test-PlasterManifest\` validates both XML and JSON manifests
- [ ] Publish workflow successfully pushes \`2.0.0-alpha1\` to PSGallery
when manually dispatched

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.

3 participants