11import { tryRunArgs } from '../utils/shell.ts' ;
22import type { ChangelogContext , ChangelogFormatter } from './changelog.ts' ;
3+ import { getBumpTypeForPackage , sortBumpFilesByType } from './changelog.ts' ;
34
45/** Authors filtered from "Thanks" attribution by default (e.g. bots) */
56/** Authors filtered from "Thanks" attribution by default (e.g. AI/automation bots) */
@@ -51,48 +52,53 @@ export function createGithubFormatter(options: GithubChangelogOptions = {}): Cha
5152
5253 const lines : string [ ] = [ ] ;
5354 lines . push ( `## ${ release . newVersion } ` ) ;
54- lines . push ( '' ) ;
55- lines . push ( `_${ date } _` ) ;
55+ lines . push ( `<sub>${ date } </sub>` ) ;
5656 lines . push ( '' ) ;
5757
5858 const relevantBumpFiles = bumpFiles . filter ( ( bf ) => release . bumpFiles . includes ( bf . id ) ) ;
59-
60- if ( relevantBumpFiles . length > 0 ) {
61- for ( const bf of relevantBumpFiles ) {
62- if ( ! bf . summary ) continue ;
63-
64- // Extract metadata overrides from summary (pr, commit, author lines)
65- const { cleanSummary, overrides } = extractSummaryMeta ( bf . summary ) ;
66-
67- // Look up git/PR info, with overrides taking precedence
68- const gitInfo = resolveBumpFileInfo ( bf . id , repoSlug , serverUrl , overrides ) ;
69-
70- const summaryLines = cleanSummary . split ( '\n' ) ;
71- const firstLine = linkifyIssueRefs ( summaryLines [ 0 ] ! , serverUrl , repoSlug ) ;
72-
73- // Build the prefix: PR link, commit link, thanks
74- const prefix = formatPrefix (
75- gitInfo ,
76- serverUrl ,
77- repoSlug ,
78- includeCommitLink ,
79- thankContributors ,
80- internalAuthorsSet ,
81- ) ;
82-
83- lines . push ( `-${ prefix ? ` ${ prefix } -` : '' } ${ firstLine } ` ) ;
84-
85- // Include continuation lines
86- for ( let i = 1 ; i < summaryLines . length ; i ++ ) {
87- if ( summaryLines [ i ] ! . trim ( ) ) {
88- lines . push ( ` ${ linkifyIssueRefs ( summaryLines [ i ] ! , serverUrl , repoSlug ) } ` ) ;
89- }
59+ const sorted = sortBumpFilesByType ( relevantBumpFiles , release . name ) ;
60+
61+ for ( const bf of sorted ) {
62+ if ( ! bf . summary ) continue ;
63+
64+ const type = getBumpTypeForPackage ( bf , release . name ) ;
65+ const tag = type !== release . type ? ` *(${ type } )*` : '' ;
66+
67+ // Extract metadata overrides from summary (pr, commit, author lines)
68+ const { cleanSummary, overrides } = extractSummaryMeta ( bf . summary ) ;
69+
70+ // Look up git/PR info, with overrides taking precedence
71+ const gitInfo = resolveBumpFileInfo ( bf . id , repoSlug , serverUrl , overrides ) ;
72+
73+ const summaryLines = cleanSummary . split ( '\n' ) ;
74+ const firstLine = linkifyIssueRefs ( summaryLines [ 0 ] ! , serverUrl , repoSlug ) ;
75+
76+ // Build the prefix: PR link, commit link, thanks
77+ const { links, thanks } = formatPrefix (
78+ gitInfo ,
79+ serverUrl ,
80+ repoSlug ,
81+ includeCommitLink ,
82+ thankContributors ,
83+ internalAuthorsSet ,
84+ ) ;
85+
86+ // Assemble: links, tag, thanks, then summary
87+ const parts = [ links , tag , thanks ] . filter ( Boolean ) ;
88+ const hasMeta = parts . length > 0 ;
89+ lines . push ( `- ${ parts . join ( ' ' ) } ${ hasMeta ? ' - ' : '' } ${ firstLine } ` ) ;
90+
91+ // Include continuation lines
92+ for ( let i = 1 ; i < summaryLines . length ; i ++ ) {
93+ if ( summaryLines [ i ] ! . trim ( ) ) {
94+ lines . push ( ` ${ linkifyIssueRefs ( summaryLines [ i ] ! , serverUrl , repoSlug ) } ` ) ;
9095 }
9196 }
9297 }
9398
94- if ( release . isDependencyBump && relevantBumpFiles . length === 0 ) {
95- lines . push ( '- Updated dependencies' ) ;
99+ if ( release . isDependencyBump ) {
100+ const depTag = release . type !== 'patch' ? ` *(patch)* -` : '' ;
101+ lines . push ( `-${ depTag } Updated dependencies` ) ;
96102 }
97103
98104 if ( release . isCascadeBump && ! release . isDependencyBump && relevantBumpFiles . length === 0 ) {
@@ -263,8 +269,8 @@ function findBumpFileCommitInfo(bumpFileId: string, repo?: string): BumpFileGitI
263269// ---- Formatting helpers ----
264270
265271/**
266- * Build the prefix portion of a changelog line: PR link, commit link, thanks.
267- * Matches the format used by @changesets/changelog-github .
272+ * Build the prefix portions of a changelog line, split into links and thanks
273+ * so the bump type tag can be inserted between them .
268274 */
269275function formatPrefix (
270276 info : BumpFileGitInfo ,
@@ -273,23 +279,24 @@ function formatPrefix(
273279 includeCommitLink : boolean ,
274280 thankContributors : boolean ,
275281 internalAuthors : Set < string > ,
276- ) : string {
277- const parts : string [ ] = [ ] ;
282+ ) : { links : string ; thanks : string } {
283+ const linkParts : string [ ] = [ ] ;
278284
279285 if ( info . prNumber && info . prUrl ) {
280- parts . push ( `[#${ info . prNumber } ](${ info . prUrl } )` ) ;
286+ linkParts . push ( `[#${ info . prNumber } ](${ info . prUrl } )` ) ;
281287 }
282288
283289 if ( includeCommitLink && info . commitHash && repo ) {
284290 const short = info . commitHash . slice ( 0 , 7 ) ;
285- parts . push ( `[\`${ short } \`](${ serverUrl } /${ repo } /commit/${ info . commitHash } )` ) ;
291+ linkParts . push ( `[\`${ short } \`](${ serverUrl } /${ repo } /commit/${ info . commitHash } )` ) ;
286292 }
287293
294+ let thanks = '' ;
288295 if ( thankContributors && info . author && ! internalAuthors . has ( info . author . toLowerCase ( ) ) ) {
289- parts . push ( `Thanks [@${ info . author } ](${ serverUrl } /${ info . author } )!` ) ;
296+ thanks = `Thanks [@${ info . author } ](${ serverUrl } /${ info . author } )!` ;
290297 }
291298
292- return parts . join ( ' ' ) ;
299+ return { links : linkParts . join ( ' ' ) , thanks } ;
293300}
294301
295302/**
0 commit comments