Skip to content

Commit a0e1579

Browse files
tablackburnclaude
andcommitted
feat(changelog): add template-level CHANGELOG.md (CalVer)
Track changes to the PowerShell module template itself with its own changelog, separate from the downstream-module starter changelog. CHANGELOG.md (new) — template's own history. Uses Calendar Versioning (YYYY.MM.DD) since the template has no API contract for SemVer to describe; date-based answers the question downstream consumers actually ask ("how stale is my init?"). First entry [2026.04.29] captures the five chunks landed in the chore/template-sync branch. Initialize-Template.ps1: - Add CHANGELOG.md to the substitution-loop exclusion list. Without this, init would rewrite literal {{ModuleName}} mentions in the template's history to the user's chosen module name. - After the README.template.md → README.md swap, add a parallel CHANGELOG.template.md → CHANGELOG.md swap so downstream modules receive the placeholder-laden starter changelog (the existing CHANGELOG.template.md, formerly CHANGELOG.md), not the template's own history. tests/Manifest.tests.ps1: - Skip the "Changelog and manifest versions are the same" assertion when running on the un-initialized template, where CHANGELOG.md holds the template's CalVer version which intentionally diverges from the {{ModuleName}}.psd1 ModuleVersion. Marker: presence of CHANGELOG.template.md (exists only pre-init; survives init's substitution loop because nothing in the path matches a placeholder token). The "valid version in changelog" assertion stays — PowerShell parses [Version]'2026.4.29' fine. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 65fd9e4 commit a0e1579

3 files changed

Lines changed: 53 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Changelog
2+
3+
All notable changes to this template will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project uses [Calendar Versioning](https://calver.org/) (`YYYY.MM.DD`).
7+
8+
For the changelog of a *module initialized from this template*, see the module's
9+
own `CHANGELOG.md` (generated from `CHANGELOG.template.md` during init).
10+
11+
## [Unreleased]
12+
13+
## [2026.04.29] - 2026-04-29
14+
15+
### Added
16+
17+
- SemVer-aware dependency version checks: new `tests/ManifestHelpers.psm1` exporting `Test-VersionConstraint`. `tests/Manifest.tests.ps1` now differentiates `RequiredVersion` / `ModuleVersion` / `MaximumVersion`, accepts both string and hashtable shapes in `requirements.psd1`, and detects duplicate `RequiredModules` entries.
18+
- README split: template-facing `README.md` (what GitHub visitors see) and module-facing `README.template.md` (substituted into `README.md` during init).
19+
- `docs/en-US/about_{{ModuleName}}.help.md` stub for `Get-Help about_<Module>`. `Initialize-Template.ps1` now also renames `{{ModuleName}}` files in `docs/en-US/`.
20+
- `.gitattributes` marking `docs/en-US/*` as `linguist-generated`.
21+
- `.markdownlint-cli2.jsonc` config (relax MD013 in tables/code, allow MD024 siblings, ignore generated docs and `instructions/`).
22+
23+
### Changed
24+
25+
- `PSScriptAnalyzerSettings.psd1`: replaced one-line `@{ IncludeRules = @('*') }` with the structured form (Include/Exclude/Rules + commented compat scaffold).
26+
- Bumped `PSScriptAnalyzer` 1.24.0 → 1.25.0.
27+
28+
### Fixed
29+
30+
- `tests/Help.tests.ps1`: replaced undefined `$parameterNames` with `$commandParameterNames` in the help-vs-code parameter check (was silently asserting against `$null`).
31+
- `{{ModuleName}}/{{ModuleName}}.psm1`: dot-source catch block now preserves the original `ErrorRecord` via bare `throw` (was `throw $_`, which wrapped the error).
32+
33+
[Unreleased]: https://github.com/tablackburn/PowerShellModuleTemplate/compare/v2026.04.29...HEAD
34+
[2026.04.29]: https://github.com/tablackburn/PowerShellModuleTemplate/releases/tag/v2026.04.29

Initialize-Template.ps1

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ $filesToProcess = Get-ChildItem -Path $PSScriptRoot -Recurse -File | Where-Objec
180180
$_.FullName -notmatch '[\\/]Output[\\/]' -and
181181
$_.FullName -notmatch '[\\/]out[\\/]' -and
182182
$_.Name -ne 'Initialize-Template.ps1' -and
183+
$_.Name -ne 'CHANGELOG.md' -and
183184
$_.Extension -in @('.ps1', '.psm1', '.psd1', '.md', '.json', '.yml', '.yaml', '.xml', '.txt', '')
184185
}
185186

@@ -287,6 +288,15 @@ if (Test-Path -Path $readmeTemplate) {
287288
Write-Host ' Generated module README.md from template' -ForegroundColor Green
288289
}
289290

291+
# Replace template-facing CHANGELOG.md with the module-facing CHANGELOG.template.md
292+
# (placeholders inside CHANGELOG.template.md were already substituted by the file-processing loop above)
293+
$changelogTemplate = Join-Path -Path $PSScriptRoot -ChildPath 'CHANGELOG.template.md'
294+
$changelogPath = Join-Path -Path $PSScriptRoot -ChildPath 'CHANGELOG.md'
295+
if (Test-Path -Path $changelogTemplate) {
296+
Move-Item -Path $changelogTemplate -Destination $changelogPath -Force
297+
Write-Host ' Generated module CHANGELOG.md from template' -ForegroundColor Green
298+
}
299+
290300
# Initialize Git repository if requested
291301
if (-not $NoGitInit) {
292302
$gitFolder = Join-Path -Path $PSScriptRoot -ChildPath '.git'

tests/Manifest.tests.ps1

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@ BeforeDiscovery {
8686
}
8787
$manifestData = Test-ModuleManifest @testModuleManifestParameters
8888
$dependencies = $manifestData.RequiredModules
89+
90+
# When running on the un-initialized template, CHANGELOG.md tracks the template's
91+
# CalVer version (YYYY.MM.DD), which deliberately decouples from the manifest's
92+
# ModuleVersion. Skip the equality assertion in that case; downstream modules (post-init)
93+
# keep the assertion. Marker: CHANGELOG.template.md exists only pre-init —
94+
# Initialize-Template.ps1 moves it onto CHANGELOG.md during init. The marker survives
95+
# the init substitution loop because no token in the path matches a {{Placeholder}}.
96+
$isTemplate = Test-Path -LiteralPath (Join-Path -Path $Env:BHProjectPath -ChildPath 'CHANGELOG.template.md')
8997
}
9098
BeforeAll {
9199
# Check if the BHBuildOutput environment variable exists to determine if this test is running in a psake
@@ -180,7 +188,7 @@ Describe 'Module manifest' {
180188
$changelogVersion -as [Version] | Should -Not -BeNullOrEmpty
181189
}
182190

183-
It 'Changelog and manifest versions are the same' {
191+
It 'Changelog and manifest versions are the same' -Skip:$isTemplate {
184192
$changelogVersion -as [Version] | Should -Be ( $manifestData.Version -as [Version] )
185193
}
186194

0 commit comments

Comments
 (0)