@@ -51,7 +51,6 @@ const getReleaseChannel = version => {
51
51
const slackFormatter = {
52
52
generateChangelog : ( { packageData, releasePrUrl, pusher } ) => {
53
53
const markdown = text => ( { type : 'section' , text : { type : 'mrkdwn' , text } } ) ;
54
- const divider = ( ) => ( { type : 'divider' } ) ;
55
54
const header = text => ( { type : 'header' , text : { type : 'plain_text' , text } } ) ;
56
55
const context = ( imgUrl , text ) => ( {
57
56
type : 'context' ,
@@ -64,22 +63,47 @@ const slackFormatter = {
64
63
65
64
const releaseChannel = getReleaseChannel ( packageData ?. [ 0 ] ?. version ) ;
66
65
blocks . push ( header ( `Javascript SDKs - ${ releaseChannel } Release - ${ new Date ( ) . toLocaleDateString ( 'en-US' ) } ` ) ) ;
66
+ blocks . push ( markdown ( `All release PRs for this day can be found <${ releasePrUrl } |here>.\nReleased packages:\n` ) ) ;
67
67
68
- let body = '' ;
69
- for ( const { name, version, changelogUrl } of packageData ) {
70
- body += `• <${ changelogUrl } |Changelog> - \`${ name } @${ version } \`\n` ;
71
- }
68
+ createPackagesBody ( packageData ) . forEach ( body => {
69
+ blocks . push ( markdown ( body ) ) ;
70
+ } ) ;
72
71
73
- blocks . push ( markdown ( `All release PRs for this day can be found <${ releasePrUrl } |here>.\nReleased packages:\n` ) ) ;
74
- blocks . push ( markdown ( body ) ) ;
75
- // blocks.push(divider());
76
72
blocks . push ( markdown ( '\n' ) ) ;
77
73
blocks . push ( context ( pusher . avatarUrl , `<${ pusher . profileUrl } |*${ pusher . username } *> triggered this release.` ) ) ;
78
74
79
75
return JSON . stringify ( { blocks } ) ;
80
76
} ,
81
77
} ;
82
78
79
+ /**
80
+ * @property {PackageData[] } packageData
81
+ */
82
+ const createPackagesBody = packageData => {
83
+ // The Slack API has a limitation of ~3000 characters per block and
84
+ // also there is a limit on the number of blocks that can be sent in a single message.
85
+ // So, we split the body into fragments of 10 packages each.
86
+ const fragments = [ ] ;
87
+ let body = '' ;
88
+ let count = 0 ;
89
+ for ( const { name, version, changelogUrl } of packageData ) {
90
+ body += `• <${ changelogUrl } |Changelog> - \`${ name } @${ version } \`\n` ;
91
+ count ++ ;
92
+
93
+ if ( count === 10 ) {
94
+ fragments . push ( body ) ;
95
+ body = '' ;
96
+ count = 0 ;
97
+ }
98
+ }
99
+ // This is the remaining
100
+ if ( body ) {
101
+ fragments . push ( body ) ;
102
+ }
103
+
104
+ return fragments ;
105
+ } ;
106
+
83
107
/**
84
108
* @type {Record<string, Formatter> }
85
109
*/
0 commit comments