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 #
This commit is contained in:
Craigory Coppola 2025-04-09 20:53:49 -04:00 committed by GitHub
parent 3ad8082a39
commit 7c22d2d969
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 23 deletions

View File

@ -50,7 +50,7 @@ jobs:
- name: Collect Issue Data
id: collect
run: npx ts-node ./scripts/issues-scraper/index.ts
run: npx tsx ./scripts/issues-scraper/index.ts
env:
GITHUB_TOKEN: ${{ github.token }}

View File

@ -3,7 +3,6 @@ import { table } from 'markdown-factory';
export function getSlackMessageJson(body: string) {
return {
text: 'Some Text',
blocks: [
{
type: 'section',
@ -19,8 +18,7 @@ export function getSlackMessageJson(body: string) {
export function formatGhReport(
currentData: ReportData,
trendData: TrendData,
prevData: ReportData,
unlabeledIssuesUrl: string
prevData: ReportData
): string {
const issueDelta = trendData.totalIssueCount;
const formattedIssueDelta = formatDelta(issueDelta);
@ -28,7 +26,7 @@ export function formatGhReport(
const bugDelta = trendData.totalBugCount;
const formattedBugDelta = formatDelta(bugDelta);
const header = `Issue Report for ${currentData.collectedDate} <${unlabeledIssuesUrl}|[view unlabeled]>
const header = `Issue Report for ${currentData.collectedDate}
\`\`\`
Totals, Issues: ${currentData.totalIssueCount} ${formattedIssueDelta} Bugs: ${currentData.totalBugCount} ${formattedBugDelta}\n\n`;

View File

@ -1,11 +1,10 @@
import { ensureDirSync, readJsonSync, writeJsonSync } from 'fs-extra';
import { dirname, join } from 'path';
import { ReportData, ScopeData, TrendData } from './model';
import { getScopeLabels, scrapeIssues } from './scrape-issues';
import { scrapeIssues } from './scrape-issues';
import { formatGhReport, getSlackMessageJson } from './format-slack-message';
import { setOutput } from '@actions/core';
import isCI from 'is-ci';
import { readdirSync } from 'fs';
const CACHE_FILE = join(__dirname, 'cached', 'data.json');
@ -15,12 +14,7 @@ async function main() {
oldData.collectedDate ? new Date(oldData.collectedDate) : undefined
);
const trendData = getTrendData(currentData, oldData);
const formatted = formatGhReport(
currentData,
trendData,
oldData,
getUnlabeledIssuesUrl(await getScopeLabels())
);
const formatted = formatGhReport(currentData, trendData, oldData);
setOutput('SLACK_MESSAGE', getSlackMessageJson(formatted));
console.log(formatted.replace(/\<(.*)\|(.*)\>/g, '[$1]($0)'));
saveCacheData(currentData);
@ -47,7 +41,7 @@ function getTrendData(newData: ReportData, oldData: ReportData): TrendData {
scopes: scopeTrends as Record<string, ScopeData>,
totalBugCount: newData.totalBugCount - oldData.totalBugCount,
totalIssueCount: newData.totalIssueCount - oldData.totalIssueCount,
totalClosed: newData.totalClosed - oldData.totalClosed ?? 0,
totalClosed: newData.totalClosed - oldData.totalClosed,
untriagedIssueCount:
newData.untriagedIssueCount - oldData.untriagedIssueCount,
};
@ -62,10 +56,8 @@ function saveCacheData(report: ReportData) {
function getOldData(): ReportData {
try {
console.log('DIR CONTENTS:', readdirSync(dirname(CACHE_FILE)));
return readJsonSync(CACHE_FILE);
} catch (e) {
console.log(e);
return {
scopes: {},
totalBugCount: 0,
@ -75,10 +67,3 @@ function getOldData(): ReportData {
};
}
}
function getUnlabeledIssuesUrl(scopeLabels: string[]) {
const labelFilters = scopeLabels.map((s) => `-label:"${s}"`);
return `https://github.com/nrwl/nx/issues/?q=is%3Aopen+is%3Aissue+sort%3Aupdated-desc+${encodeURIComponent(
labelFilters.join(' ')
)}`;
}