Skip to content

Commit 7c22d2d

Browse files
authored
chore(repo): fix ts compilation of issues-scraper (#30656)
## Current Behavior Issues reporter is not running ## Expected Behavior Issues reporter is running ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #
1 parent 3ad8082 commit 7c22d2d

File tree

3 files changed

+6
-23
lines changed

3 files changed

+6
-23
lines changed

.github/workflows/issue-notifier.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050

5151
- name: Collect Issue Data
5252
id: collect
53-
run: npx ts-node ./scripts/issues-scraper/index.ts
53+
run: npx tsx ./scripts/issues-scraper/index.ts
5454
env:
5555
GITHUB_TOKEN: ${{ github.token }}
5656

scripts/issues-scraper/format-slack-message.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { table } from 'markdown-factory';
33

44
export function getSlackMessageJson(body: string) {
55
return {
6-
text: 'Some Text',
76
blocks: [
87
{
98
type: 'section',
@@ -19,16 +18,15 @@ export function getSlackMessageJson(body: string) {
1918
export function formatGhReport(
2019
currentData: ReportData,
2120
trendData: TrendData,
22-
prevData: ReportData,
23-
unlabeledIssuesUrl: string
21+
prevData: ReportData
2422
): string {
2523
const issueDelta = trendData.totalIssueCount;
2624
const formattedIssueDelta = formatDelta(issueDelta);
2725

2826
const bugDelta = trendData.totalBugCount;
2927
const formattedBugDelta = formatDelta(bugDelta);
3028

31-
const header = `Issue Report for ${currentData.collectedDate} <${unlabeledIssuesUrl}|[view unlabeled]>
29+
const header = `Issue Report for ${currentData.collectedDate}
3230
\`\`\`
3331
Totals, Issues: ${currentData.totalIssueCount} ${formattedIssueDelta} Bugs: ${currentData.totalBugCount} ${formattedBugDelta}\n\n`;
3432

scripts/issues-scraper/index.ts

+3-18
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { ensureDirSync, readJsonSync, writeJsonSync } from 'fs-extra';
22
import { dirname, join } from 'path';
33
import { ReportData, ScopeData, TrendData } from './model';
4-
import { getScopeLabels, scrapeIssues } from './scrape-issues';
4+
import { scrapeIssues } from './scrape-issues';
55
import { formatGhReport, getSlackMessageJson } from './format-slack-message';
66
import { setOutput } from '@actions/core';
77
import isCI from 'is-ci';
8-
import { readdirSync } from 'fs';
98

109
const CACHE_FILE = join(__dirname, 'cached', 'data.json');
1110

@@ -15,12 +14,7 @@ async function main() {
1514
oldData.collectedDate ? new Date(oldData.collectedDate) : undefined
1615
);
1716
const trendData = getTrendData(currentData, oldData);
18-
const formatted = formatGhReport(
19-
currentData,
20-
trendData,
21-
oldData,
22-
getUnlabeledIssuesUrl(await getScopeLabels())
23-
);
17+
const formatted = formatGhReport(currentData, trendData, oldData);
2418
setOutput('SLACK_MESSAGE', getSlackMessageJson(formatted));
2519
console.log(formatted.replace(/\<(.*)\|(.*)\>/g, '[$1]($0)'));
2620
saveCacheData(currentData);
@@ -47,7 +41,7 @@ function getTrendData(newData: ReportData, oldData: ReportData): TrendData {
4741
scopes: scopeTrends as Record<string, ScopeData>,
4842
totalBugCount: newData.totalBugCount - oldData.totalBugCount,
4943
totalIssueCount: newData.totalIssueCount - oldData.totalIssueCount,
50-
totalClosed: newData.totalClosed - oldData.totalClosed ?? 0,
44+
totalClosed: newData.totalClosed - oldData.totalClosed,
5145
untriagedIssueCount:
5246
newData.untriagedIssueCount - oldData.untriagedIssueCount,
5347
};
@@ -62,10 +56,8 @@ function saveCacheData(report: ReportData) {
6256

6357
function getOldData(): ReportData {
6458
try {
65-
console.log('DIR CONTENTS:', readdirSync(dirname(CACHE_FILE)));
6659
return readJsonSync(CACHE_FILE);
6760
} catch (e) {
68-
console.log(e);
6961
return {
7062
scopes: {},
7163
totalBugCount: 0,
@@ -75,10 +67,3 @@ function getOldData(): ReportData {
7567
};
7668
}
7769
}
78-
79-
function getUnlabeledIssuesUrl(scopeLabels: string[]) {
80-
const labelFilters = scopeLabels.map((s) => `-label:"${s}"`);
81-
return `https://github.com/nrwl/nx/issues/?q=is%3Aopen+is%3Aissue+sort%3Aupdated-desc+${encodeURIComponent(
82-
labelFilters.join(' ')
83-
)}`;
84-
}

0 commit comments

Comments
 (0)