Repository navigation
fix(release): add changelogTitle config to prevent changelog header orphaning #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
950a595
3eda3da
72e0b84
1c33f6e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,12 @@ | ||
| # Changelog | ||
|
|
||
| All notable changes to this project will be documented in this file. | ||
|
|
||
| The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), | ||
| and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
|
||
| ## [Unreleased] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Add the release configuration change under The As per coding guidelines, “The PR adds or edits an entry beneath 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
|
|
||
| ## [3.1.2](https://github.com/WYRE-AI/node-superops/compare/v3.1.1...v3.1.2) (2026-10-08) | ||
|
|
||
|
|
||
|
|
@@ -144,15 +153,6 @@ Page<Asset> instead of a cursor Connection. | |
| * Add semantic-release for GitHub Packages publishing ([6221a7f](https://github.com/asachs01/node-superops/commit/6221a7f61c8b689b240b0fe33f242228b24605dc)) | ||
| * Initial release of node-superops TypeScript library ([443c430](https://github.com/asachs01/node-superops/commit/443c43094ca61eecf3e22489eed161a4d441f695)) | ||
|
|
||
| # Changelog | ||
|
|
||
| All notable changes to this project will be documented in this file. | ||
|
|
||
| The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), | ||
| and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
|
||
| ## [Unreleased] | ||
|
|
||
| ## [0.1.0] - 2026-02-04 | ||
|
|
||
| ### Added | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| import { describe, it, expect } from 'vitest'; | ||
| import { insertReleaseNotes } from '../../scripts/prepare-release.mjs'; | ||
|
|
||
| describe('insertReleaseNotes', () => { | ||
| it('returns bare notes when there is no existing changelog', () => { | ||
| expect(insertReleaseNotes('## [1.0.0] notes', '')).toBe('## [1.0.0] notes\n'); | ||
| expect(insertReleaseNotes('## [1.0.0] notes', undefined as unknown as string)).toBe( | ||
| '## [1.0.0] notes\n' | ||
| ); | ||
| }); | ||
|
|
||
| it('appends after a header-only scaffold with no release headings yet', () => { | ||
| const existing = '# Changelog\n\nAll notable changes to this project will be documented here.'; | ||
| const result = insertReleaseNotes('## [1.0.0](link) (2026-01-01)\n\n* first release', existing); | ||
| expect(result).toBe( | ||
| '# Changelog\n\nAll notable changes to this project will be documented here.\n\n' + | ||
| '## [1.0.0](link) (2026-01-01)\n\n* first release\n' | ||
| ); | ||
| }); | ||
|
|
||
| it('prepends notes when there is no header scaffold (heading at index 0)', () => { | ||
| const existing = '## [1.0.0](link) (2026-01-01)\n\n* first release'; | ||
| const notes = '## [1.1.0](link) (2026-02-01)\n\n* second release'; | ||
| const result = insertReleaseNotes(notes, existing); | ||
| expect(result).toBe(`${notes}\n\n${existing}\n`); | ||
| }); | ||
|
|
||
| it('inserts notes between the header scaffold and the first versioned entry (node-rootly shape: no Unreleased section)', () => { | ||
| const existing = | ||
| '# Changelog\n\n' + | ||
| 'All notable changes to this project will be documented in this file.\n' + | ||
| 'See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.\n\n' + | ||
| '## [1.0.3](https://github.com/WYRE-AI/node-rootly/compare/v1.0.2...v1.0.3) (2026-08-25)\n\n' + | ||
| '* export request() from public API'; | ||
| const notes = '## [1.0.4](https://github.com/WYRE-AI/node-rootly/compare/v1.0.3...v1.0.4) (2026-10-16)\n\n* a new fix'; | ||
| const result = insertReleaseNotes(notes, existing); | ||
|
|
||
| expect(result).toBe( | ||
| '# Changelog\n\n' + | ||
| 'All notable changes to this project will be documented in this file.\n' + | ||
| 'See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.\n\n' + | ||
| `${notes}\n\n` + | ||
| '## [1.0.3](https://github.com/WYRE-AI/node-rootly/compare/v1.0.2...v1.0.3) (2026-08-25)\n\n' + | ||
| '* export request() from public API\n' | ||
| ); | ||
| // New notes must land strictly after the header, never swallow/duplicate it. | ||
| expect(result.indexOf(notes)).toBeGreaterThan(result.indexOf('# Changelog')); | ||
| expect(result.match(/# Changelog/g)).toHaveLength(1); | ||
| }); | ||
|
|
||
| it('keeps "## [Unreleased]" above the inserted notes, not below it (the regression this PR fixes)', () => { | ||
| const existing = | ||
| '# Changelog\n\n' + | ||
| 'All notable changes to this project will be documented in this file.\n\n' + | ||
| '## [Unreleased]\n\n' + | ||
| '## [1.0.0](link) (2026-08-25)\n\n' + | ||
| '* first release'; | ||
| const notes = '## [1.1.0](link) (2026-10-16)\n\n* a new fix'; | ||
| const result = insertReleaseNotes(notes, existing); | ||
|
|
||
| const unreleasedIdx = result.indexOf('## [Unreleased]'); | ||
| const notesIdx = result.indexOf(notes); | ||
| const oldEntryIdx = result.indexOf('## [1.0.0]'); | ||
|
|
||
| expect(unreleasedIdx).toBeGreaterThan(-1); | ||
| // Unreleased must stay ABOVE the newly inserted notes (this is the exact | ||
| // bug an unqualified /^## \[/ regex would reintroduce: matching | ||
| // "## [Unreleased]" itself as "the first real entry" and inserting the | ||
| // new notes between the preamble and Unreleased instead of below it). | ||
| expect(unreleasedIdx).toBeLessThan(notesIdx); | ||
| expect(notesIdx).toBeLessThan(oldEntryIdx); | ||
| }); | ||
|
|
||
| it('recognizes the bare first-release heading shape ("# X.Y.Z (date)", no link) as a real entry', () => { | ||
| const existing = | ||
| '# Changelog\n\n' + | ||
| 'All notable changes to this project will be documented in this file.\n\n' + | ||
| '# 1.0.0 (2026-01-01)\n\n' + | ||
| '* initial release — no repository link configured'; | ||
| const notes = '## [1.1.0](link) (2026-02-01)\n\n* second release'; | ||
| const result = insertReleaseNotes(notes, existing); | ||
|
|
||
| expect(result.indexOf('# Changelog')).toBeLessThan(result.indexOf(notes)); | ||
| expect(result.indexOf(notes)).toBeLessThan(result.indexOf('# 1.0.0 (2026-01-01)')); | ||
| }); | ||
| }); |
Uh oh!
There was an error while loading. Please reload this page.