Commit 2b299ac
authored
fix(build): seed CHANGELOG.md with version entry for release-please frontmatter preservation (#170)
## Summary
Fixes #169
Seeds CHANGELOG.md with a placeholder version entry so release-please
preserves YAML frontmatter during changelog updates.
## Problem
PR #168 fails markdown linting because CHANGELOG.md had no version
entry. When release-please's `updateContent()` method runs without a
matching version header (`'\n###? v?[0-9[]'`), it takes the "no version
found" code path which:
1. Prepends `# Changelog\n` header
2. Adds the new changelog entry
3. Calls `adjustHeaders()` on **all** existing content (including
frontmatter)
4. Appends adjusted content at the **end** of the file
This mangles the YAML frontmatter, causing MD003, MD012, MD013, and
MD022 lint failures.
## Solution
Add `## 0.0.0 (Initial)` placeholder version entry. This triggers
release-please's "version found" path:
```typescript
const lastEntryIndex = content.search(versionHeaderRegex);
const before = content.slice(0, lastEntryIndex); // Frontmatter preserved
const after = content.slice(lastEntryIndex); // Only versions processed
return `${before}\n${this.changelogEntry}\n${adjustHeaders(after)}`;
```
The frontmatter stays in the protected `before` slice and is preserved
exactly as-is.
## Changes
- [CHANGELOG.md](CHANGELOG.md) - Added `## 0.0.0 (Initial)` placeholder
version entry
## Testing
- ✅ `npx markdownlint-cli2 CHANGELOG.md` passes with 0 errors
## Next Steps
After merging this PR:
1. Close PR #168
2. Release-please will regenerate with the corrected algorithm
## References
- [release-please
changelog.ts](https://github.com/googleapis/release-please/blob/main/src/updaters/changelog.ts)
- `updateContent()` algorithm1 parent 070e042 commit 2b299ac
1 file changed
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
0 commit comments