Skip to content

Commit 0a119a0

Browse files
committed
fix: invalid Slack blocks with no PRs
1 parent 761bc34 commit 0a119a0

File tree

6 files changed

+186
-73
lines changed

6 files changed

+186
-73
lines changed

dist/index.js

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -81503,7 +81503,7 @@ function getEmojiBlocks(name, type = 'rich_text_section') {
8150381503
* @param [text] The sub-header text.
8150481504
*/
8150581505
function getFirstBlocks(orgs, header, text) {
81506-
return [
81506+
const headerBlock = [
8150781507
{
8150881508
text: {
8150981509
emoji: true,
@@ -81512,31 +81512,37 @@ function getFirstBlocks(orgs, header, text) {
8151281512
},
8151381513
type: 'header',
8151481514
},
81515-
...(text ? getContextMarkdownBlock(text) : []),
81516-
{
81517-
elements: orgs.flatMap((org) => [
81518-
{
81519-
text: {
81520-
emoji: true,
81521-
text: `${(0,_krauters_utils__WEBPACK_IMPORTED_MODULE_0__.capitalize)(org)} Org`,
81522-
type: 'plain_text',
81523-
},
81524-
type: 'button',
81525-
url: `${_constants_js__WEBPACK_IMPORTED_MODULE_1__/* .scmUrl */ .Hm}/${org}`,
81515+
];
81516+
const contextBlock = text ? getContextMarkdownBlock(text) : [];
81517+
const actionsBlock = [];
81518+
if (orgs.length > 0) {
81519+
const actionElements = [];
81520+
for (const org of orgs) {
81521+
actionElements.push({
81522+
text: {
81523+
emoji: true,
81524+
text: `${(0,_krauters_utils__WEBPACK_IMPORTED_MODULE_0__.capitalize)(org)} Org`,
81525+
type: 'plain_text',
8152681526
},
81527-
{
81528-
text: {
81529-
emoji: true,
81530-
text: `${(0,_krauters_utils__WEBPACK_IMPORTED_MODULE_0__.capitalize)(org)} PRs`,
81531-
type: 'plain_text',
81532-
},
81533-
type: 'button',
81534-
url: `${_constants_js__WEBPACK_IMPORTED_MODULE_1__/* .prBaseUrl */ .Fh}${org}`,
81527+
type: 'button',
81528+
url: `${_constants_js__WEBPACK_IMPORTED_MODULE_1__/* .scmUrl */ .Hm}/${org}`,
81529+
});
81530+
actionElements.push({
81531+
text: {
81532+
emoji: true,
81533+
text: `${(0,_krauters_utils__WEBPACK_IMPORTED_MODULE_0__.capitalize)(org)} PRs`,
81534+
type: 'plain_text',
8153581535
},
81536-
]),
81536+
type: 'button',
81537+
url: `${_constants_js__WEBPACK_IMPORTED_MODULE_1__/* .prBaseUrl */ .Fh}${org}`,
81538+
});
81539+
}
81540+
actionsBlock.push({
81541+
elements: actionElements,
8153781542
type: 'actions',
81538-
},
81539-
];
81543+
});
81544+
}
81545+
return [...headerBlock, ...contextBlock, ...actionsBlock];
8154081546
}
8154181547
/**
8154281548
* Get the last Slack block which includes footer markdown.
@@ -90359,7 +90365,7 @@ module.exports = {"version":"3.17.0"};
9035990365
/***/ 8330:
9036090366
/***/ ((module) => {
9036190367

90362-
module.exports = /*#__PURE__*/JSON.parse('{"UU":"@krauters/github-notifier","rE":"1.0.0","TB":"https://buymeacoffee.com/coltenkrauter"}');
90368+
module.exports = /*#__PURE__*/JSON.parse('{"UU":"@krauters/github-notifier","rE":"1.0.1","TB":"https://buymeacoffee.com/coltenkrauter"}');
9036390369

9036490370
/***/ })
9036590371

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 96 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@krauters/github-notifier",
33
"description": "GitHub Notifier by Krauters – Post Open Pull Requests to Slack",
4-
"version": "1.0.0",
4+
"version": "1.0.1",
55
"author": "Colten Krauter <coltenkrauter>",
66
"type": "module",
77
"homepage": "https://buymeacoffee.com/coltenkrauter",
@@ -41,17 +41,17 @@
4141
"@actions/core": "1.11.1",
4242
"@actions/github": "6.0.0",
4343
"@krauters/utils": "^1.4.0",
44-
"@octokit/types": "13.10.0",
44+
"@octokit/types": "14.0.0",
4545
"@slack/web-api": "7.9.1"
4646
},
4747
"devDependencies": {
4848
"@krauters/eslint-config": "^1.8.0",
4949
"@types/jest": "^29.5.14",
50-
"@types/node": "^22.13.14",
50+
"@types/node": "^22.14.1",
5151
"@vercel/ncc": "^0.38.3",
5252
"husky": "9.1.7",
5353
"jest": "^29.7.0",
54-
"ts-jest": "^29.3.0"
54+
"ts-jest": "^29.3.2"
5555
},
5656
"bugs": {
5757
"url": "https://github.com/krauters/github-notifier/issues/new?title=%5BBUG%5D+Brief+Description&template=bug_report.md"

0 commit comments

Comments
 (0)