@@ -20,15 +20,30 @@ const firstLine = raw.replace(/\r/g, "").split("\n")[0].trim();
2020if ( / ^ M e r g e / . test ( firstLine ) || / ^ R e v e r t / . test ( firstLine ) ) process . exit ( 0 ) ;
2121
2222// Clean Commit convention pattern
23- // Format: <emoji> <type>[(<scope>)]: <description>
23+ // Format: <emoji> <type>[!][ (<scope>)]: <description>
2424const pattern =
25- / ^ ( 📦 | 🔧 | 🗑 \uFE0F ? | 🔒 | ⚙ \uFE0F ? | ☕ | 🧪 | 📖 | 🚀 ) ( n e w | u p d a t e | r e m o v e | s e c u r i t y | s e t u p | c h o r e | t e s t | d o c s | r e l e a s e ) ( \( [ a - z 0 - 9 ] [ a - z 0 - 9 - ] * \) ) ? : .{ 1 , 72 } $ / u;
25+ / ^ ( 📦 | 🔧 | 🗑 \uFE0F ? | 🔒 | ⚙ \uFE0F ? | ☕ | 🧪 | 📖 | 🚀 ) ( n e w | u p d a t e | r e m o v e | s e c u r i t y | s e t u p | c h o r e | t e s t | d o c s | r e l e a s e ) ( ! ? ) ( \( [ a - z 0 - 9 ] [ a - z 0 - 9 - ] * \) ) ? : .{ 1 , 72 } $ / u;
26+
27+ // Only new, update, remove, security may use the breaking change marker
28+ const breakingMatch = firstLine . match ( pattern ) ;
29+ if ( breakingMatch ) {
30+ const type = breakingMatch [ 2 ] ;
31+ const bang = breakingMatch [ 3 ] ;
32+ if ( bang === '!' && ! [ 'new' , 'update' , 'remove' , 'security' ] . includes ( type ) ) {
33+ console . error ( '' ) ;
34+ console . error ( '✖ Breaking change marker (!) is only allowed for: new, update, remove, security' ) ;
35+ console . error ( '' ) ;
36+ process . exit ( 1 ) ;
37+ }
38+ }
2639
2740if ( ! pattern . test ( firstLine ) ) {
2841 console . error ( "" ) ;
2942 console . error ( "✖ Invalid commit message format." ) ;
3043 console . error ( "" ) ;
31- console . error ( " Expected: <emoji> <type>[(<scope>)]: <description>" ) ;
44+ console . error ( " Expected: <emoji> <type>[!][(<scope>)]: <description>" ) ;
45+ console . error ( "" ) ;
46+ console . error ( " Use ! after type for breaking changes (new, update, remove, security only)" ) ;
3247 console . error ( "" ) ;
3348 console . error ( " Types and emojis:" ) ;
3449 console . error ( " 📦 new – new features, files, or capabilities" ) ;
@@ -45,6 +60,8 @@ if (!pattern.test(firstLine)) {
4560 console . error ( " 📦 new: user authentication system" ) ;
4661 console . error ( " 🔧 update (api): improve error handling" ) ;
4762 console . error ( " ⚙️ setup (ci): configure github actions workflow" ) ;
63+ console . error ( " 📦 new!: completely redesign authentication system" ) ;
64+ console . error ( " 🔧 update! (api): change response format for all endpoints" ) ;
4865 console . error ( "" ) ;
4966 console . error ( " Reference: https://github.com/wgtechlabs/clean-commit" ) ;
5067 console . error ( "" ) ;
0 commit comments