@@ -25,7 +25,7 @@ function log(...args) {
2525
2626// Commit parsing rules
2727const commitParsers = [
28- // Skip some " noise" commits
28+ // Skip noise
2929 { message : / ^ c h o r e \( r e l e a s e \) : p r e p a r e f o r / i, skip : true } ,
3030 { message : / ^ c h o r e \( d e p s .* \) / i, skip : true } ,
3131 { message : / ^ c h o r e \( c h a n g e .* \) / i, skip : true } ,
@@ -34,52 +34,58 @@ const commitParsers = [
3434 { message : / ^ f i x e s / i, skip : true } ,
3535 { message : / ^ b u i l d / i, skip : true } ,
3636
37- // Enhancements (new features, improvements, UX, performance)
37+ // Enhancements
3838 { message : / ^ f e a t | ^ p e r f | ^ s t y l e | ^ u i | ^ u x / i, group : "### :sparkles: Enhancements:" } ,
3939
40- // Bug fixes & hotfixes
40+ // Bug fixes
4141 { message : / ^ f i x | ^ b u g | ^ h o t f i x | ^ e m e r g e n c y / i, group : "### :bug: Bug Fixes:" } ,
4242
43- // Code quality (refactors, cleanup without changing behavior)
43+ // Code quality
4444 { message : / ^ r e f a c t o r / i, group : "### :wrench: Code Quality:" } ,
4545
4646 // Documentation
4747 { message : / ^ d o c / i, group : "### :books: Documentation:" } ,
4848
49- // Localization & internationalization
49+ // Localization
5050 { message : / ^ ( l a n g | i 1 8 n ) / i, group : "### :globe_with_meridians: Localization:" } ,
5151
5252 // Security
5353 { message : / ^ s e c u r i t y / i, group : "### :lock: Security:" } ,
5454
55- // Feature removal / drops
55+ // Feature removal
5656 { message : / ^ d r o p | ^ r e m o v e | ^ d e p r e c a t e d / i, group : "### :x: Feature Removals:" } ,
5757
5858 // Reverts
5959 { message : / ^ r e v e r t / i, group : "### :rewind: Reverts:" } ,
6060
61- // Build-related
61+ // Build
6262 { message : / ^ b u i l d / i, group : "### :building_construction: Build:" } ,
6363
64- // Dependencies-related
64+ // Dependencies
6565 { message : / ^ d e p e n d e n c y | ^ d e p s / i, group : "### :package: Dependencies:" } ,
6666
67- // Meta: configuration, CI/CD, versioning, releases
68- { message : / ^ c o n f i g | ^ c o n f i g u r a t i o n | ^ c i | ^ p i p e l i n e | ^ r e l e a s e | ^ v e r s i o n | ^ v e r s i o n i n g / i, group : "### :gear: Meta:" } ,
67+ // Meta
68+ {
69+ message : / ^ c o n f i g | ^ c o n f i g u r a t i o n | ^ c i | ^ p i p e l i n e | ^ r e l e a s e | ^ v e r s i o n | ^ v e r s i o n i n g / i,
70+ group : "### :gear: Meta:" ,
71+ } ,
6972
7073 // Tests
7174 { message : / ^ t e s t / i, group : "### :test_tube: Tests:" } ,
7275
73- // Infrastructure & Ops
76+ // Infrastructure
7477 { message : / ^ i n f r a | ^ i n f r a s t r u c t u r e | ^ o p s / i, group : "### :office: Infrastructure & Ops:" } ,
7578
76- // Chore & cleanup
77- { message : / ^ c h o r e | ^ h o u s e k e e p i n g | ^ c l e a n u p | ^ c l e a n \( u p \) / i, group : "### :broom: Maintenance & Cleanup:" } ,
79+ // Maintenance
80+ {
81+ message : / ^ c h o r e | ^ h o u s e k e e p i n g | ^ c l e a n u p | ^ c l e a n \( u p \) / i,
82+ group : "### :broom: Maintenance & Cleanup:" ,
83+ } ,
7884] ;
7985
8086const GROUP_ORDER = commitParsers . filter ( ( p ) => ! p . skip ) . map ( ( p ) => p . group ) ;
8187
82- // Helper functions
88+ // Helpers
8389function run ( cmd ) {
8490 log ( "Running:" , cmd ) ;
8591 return execSync ( cmd , { encoding : "utf8" } ) . trim ( ) ;
@@ -108,17 +114,20 @@ function cleanMessage(message) {
108114}
109115
110116function linkPR ( message ) {
111- return message . replace ( / \( # ( \d + ) \) / g, ( _ , num ) => `([#${ num } ](${ REPO_URL } /pull/${ num } ))` ) ;
117+ return message . replace ( / \( # ( \d + ) \) / g, ( _ , num ) => {
118+ return `([#${ num } ](${ REPO_URL } /pull/${ num } ))` ;
119+ } ) ;
112120}
113121
114- // Get GitHub release title for a tag
122+ // GitHub release title
115123function getReleaseTitle ( tag ) {
116124 const options = {
117125 hostname : "api.github.com" ,
118126 path : `/repos/CodeWorksCreativeHub/mLauncher/releases/tags/${ tag } ` ,
119127 method : "GET" ,
120128 headers : { "User-Agent" : "Node.js" } ,
121129 } ;
130+
122131 return new Promise ( ( resolve ) => {
123132 const req = https . request ( options , ( res ) => {
124133 let data = "" ;
@@ -132,22 +141,28 @@ function getReleaseTitle(tag) {
132141 }
133142 } ) ;
134143 } ) ;
144+
135145 req . on ( "error" , ( ) => resolve ( tag ) ) ;
136146 req . end ( ) ;
137147 } ) ;
138148}
139149
140- // Main async function
150+ // Main
141151async function generateChangelog ( ) {
142- const allTags = run ( "git tag --sort=-creatordate" ) . split ( "\n" ) ;
152+ // 🔥 Ignore nightly tags here
153+ const allTags = run ( "git tag --sort=-creatordate" )
154+ . split ( "\n" )
155+ . filter ( ( tag ) => ! / n i g h t l y / i. test ( tag ) ) ;
156+
143157 const tags = allTags . slice ( 0 , TAGS_TO_INCLUDE ) ;
144158 log ( "Tags to include:" , tags ) ;
145159
146160 let changelog = HEADER ;
147161
148- // Coming Soon / Unreleased
162+ // Unreleased
149163 const latestTag = tags [ 0 ] || "unreleased" ;
150164 const rawUnreleased = run ( `git log ${ latestTag } ..HEAD --pretty=format:"%h|%s"` ) . split ( "\n" ) ;
165+
151166 const unreleasedCommits = rawUnreleased
152167 . map ( ( line ) => {
153168 const [ hash , ...msgParts ] = line . split ( "|" ) ;
@@ -159,38 +174,37 @@ async function generateChangelog() {
159174 . filter ( Boolean ) ;
160175
161176 if ( unreleasedCommits . length > 0 ) {
162- log ( "Unreleased commits found:" , unreleasedCommits . length ) ;
163- changelog += `## [ ${ latestTag } → Unreleased](https://github.com/CodeWorksCreativeHub/mLauncher/tree/main) - In Development\n\n` ;
177+ changelog += `## [ ${ latestTag } → Unreleased]( ${ REPO_URL } /tree/main) - In Development\n\n` ;
178+
164179 const groups = { } ;
165180 for ( const c of unreleasedCommits ) {
166181 groups [ c . group ] = groups [ c . group ] || [ ] ;
167182 groups [ c . group ] . push ( `* ${ linkPR ( cleanMessage ( c . message ) ) } ([${ c . hash } ](${ REPO_URL } /commit/${ c . hash } ))` ) ;
168183 }
184+
169185 for ( const group of GROUP_ORDER ) {
170186 if ( groups [ group ] ) {
171- log ( `Unreleased group: ${ group } , commits: ${ groups [ group ] . length } ` ) ;
172187 changelog += `${ group } \n\n${ groups [ group ] . join ( "\n" ) } \n\n` ;
173188 }
174189 }
175190 }
176191
177- // Generate changelog for each tag
192+ // Tagged releases
178193 for ( let i = 0 ; i < tags . length ; i ++ ) {
179194 const currentTag = tags [ i ] ;
180- const releaseTitle = await getReleaseTitle ( currentTag ) ; // GitHub release title
181- log ( `Processing tag: ${ currentTag } (${ releaseTitle } )` ) ;
195+ const releaseTitle = await getReleaseTitle ( currentTag ) ;
182196
183197 let range ;
184198 if ( i === tags . length - 1 ) {
185199 const oldestTagIndex = allTags . indexOf ( currentTag ) ;
186200 const parentTag = allTags [ oldestTagIndex - 1 ] ;
187201 range = parentTag ? `${ parentTag } ..${ currentTag } ` : currentTag ;
188202 } else {
189- const previousTagInSlice = tags [ i + 1 ] ;
190- range = `${ previousTagInSlice } ..${ currentTag } ` ;
203+ range = `${ tags [ i + 1 ] } ..${ currentTag } ` ;
191204 }
192205
193206 const rawCommits = run ( `git log ${ range } --pretty=format:"%h|%s"` ) . split ( "\n" ) ;
207+
194208 const commits = rawCommits
195209 . map ( ( line ) => {
196210 const [ hash , ...msgParts ] = line . split ( "|" ) ;
@@ -226,5 +240,4 @@ async function generateChangelog() {
226240 console . log ( `✅ Generated ${ OUTPUT_FILE } ` ) ;
227241}
228242
229- // Run
230243generateChangelog ( ) ;
0 commit comments