2026-04-24 17:16:20 +00:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright 2026 Google LLC
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { execSync } from 'node:child_process';
|
2026-04-30 00:04:44 +00:00
|
|
|
import { GITHUB_OWNER, GITHUB_REPO } from '../types.js';
|
2026-04-24 17:16:20 +00:00
|
|
|
|
|
|
|
|
try {
|
2026-04-30 21:07:41 +00:00
|
|
|
const query = 'query($owner: String!, $repo: String!) { repository(owner: $owner, name: $repo) { issues(states: OPEN) { totalCount } } }';
|
2026-04-30 00:04:44 +00:00
|
|
|
const output = execSync(
|
2026-04-30 21:07:41 +00:00
|
|
|
`gh api graphql -F owner=${GITHUB_OWNER} -F repo=${GITHUB_REPO} -f query='${query}'`,
|
2026-04-24 17:16:20 +00:00
|
|
|
{
|
|
|
|
|
encoding: 'utf-8',
|
2026-04-30 21:07:41 +00:00
|
|
|
stdio: ['ignore', 'pipe', 'ignore'],
|
2026-04-24 17:16:20 +00:00
|
|
|
},
|
|
|
|
|
).trim();
|
2026-04-30 00:04:44 +00:00
|
|
|
const parsed = JSON.parse(output);
|
|
|
|
|
const totalCount = parsed?.data?.repository?.issues?.totalCount ?? 0;
|
2026-04-30 21:07:41 +00:00
|
|
|
process.stdout.write(`open_issues,${totalCount}\n`);
|
2026-04-24 17:16:20 +00:00
|
|
|
} catch {
|
|
|
|
|
// Fallback if gh fails or no issues found
|
2026-04-30 21:07:41 +00:00
|
|
|
process.stdout.write('open_issues,0\n');
|
2026-04-24 17:16:20 +00:00
|
|
|
}
|