mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-05-18 23:03:06 +08:00
fix: skip disabled discussion queries in platform audit
This commit is contained in:
@@ -9,7 +9,10 @@ const path = require('path');
|
||||
const { execFileSync, spawnSync } = require('child_process');
|
||||
|
||||
const SCRIPT = path.join(__dirname, '..', '..', 'scripts', 'discussion-audit.js');
|
||||
const { DISCUSSION_QUERY } = require(path.join(__dirname, '..', '..', 'scripts', 'lib', 'github-discussions'));
|
||||
const {
|
||||
DISCUSSION_ENABLED_QUERY,
|
||||
DISCUSSION_QUERY
|
||||
} = require(path.join(__dirname, '..', '..', 'scripts', 'lib', 'github-discussions'));
|
||||
|
||||
function createTempDir(prefix) {
|
||||
return fs.mkdtempSync(path.join(os.tmpdir(), prefix));
|
||||
@@ -23,6 +26,10 @@ function discussionGhKey(owner, name, first = 100) {
|
||||
return `api graphql -f owner=${owner} -f name=${name} -F first=${first} -f query=${DISCUSSION_QUERY}`;
|
||||
}
|
||||
|
||||
function discussionEnabledGhKey(owner, name) {
|
||||
return `api graphql -f owner=${owner} -f name=${name} -f query=${DISCUSSION_ENABLED_QUERY}`;
|
||||
}
|
||||
|
||||
function writeGhShim(rootDir, responses) {
|
||||
const shimPath = path.join(rootDir, 'gh-shim.js');
|
||||
fs.writeFileSync(shimPath, `
|
||||
@@ -95,6 +102,9 @@ function runTests() {
|
||||
|
||||
try {
|
||||
const shimPath = writeGhShim(rootDir, {
|
||||
[discussionEnabledGhKey('affaan-m', 'everything-claude-code')]: {
|
||||
data: { repository: { hasDiscussionsEnabled: true } }
|
||||
},
|
||||
[discussionGhKey('affaan-m', 'everything-claude-code')]: {
|
||||
data: {
|
||||
repository: {
|
||||
@@ -155,6 +165,9 @@ function runTests() {
|
||||
|
||||
try {
|
||||
const shimPath = writeGhShim(rootDir, {
|
||||
[discussionEnabledGhKey('affaan-m', 'everything-claude-code')]: {
|
||||
data: { repository: { hasDiscussionsEnabled: true } }
|
||||
},
|
||||
[discussionGhKey('affaan-m', 'everything-claude-code')]: {
|
||||
data: {
|
||||
repository: {
|
||||
@@ -207,6 +220,9 @@ function runTests() {
|
||||
|
||||
try {
|
||||
const shimPath = writeGhShim(rootDir, {
|
||||
[discussionEnabledGhKey('affaan-m', 'everything-claude-code')]: {
|
||||
data: { repository: { hasDiscussionsEnabled: true } }
|
||||
},
|
||||
[discussionGhKey('affaan-m', 'everything-claude-code')]: {
|
||||
data: {
|
||||
repository: {
|
||||
@@ -237,6 +253,34 @@ function runTests() {
|
||||
}
|
||||
})) passed++; else failed++;
|
||||
|
||||
if (test('passes without heavy query when discussions are disabled', () => {
|
||||
const rootDir = createTempDir('discussion-audit-disabled-');
|
||||
|
||||
try {
|
||||
const shimPath = writeGhShim(rootDir, {
|
||||
[discussionEnabledGhKey('ECC-Tools', 'ECC-website')]: {
|
||||
data: { repository: { hasDiscussionsEnabled: false } }
|
||||
}
|
||||
});
|
||||
|
||||
const parsed = JSON.parse(run([
|
||||
'--json',
|
||||
'--repo',
|
||||
'ECC-Tools/ECC-website'
|
||||
], {
|
||||
cwd: rootDir,
|
||||
env: { ECC_GH_SHIM: shimPath }
|
||||
}));
|
||||
|
||||
assert.strictEqual(parsed.ready, true);
|
||||
assert.strictEqual(parsed.repos[0].discussions.enabled, false);
|
||||
assert.strictEqual(parsed.totals.totalDiscussions, 0);
|
||||
assert.strictEqual(parsed.totals.errors, 0);
|
||||
} finally {
|
||||
cleanup(rootDir);
|
||||
}
|
||||
})) passed++; else failed++;
|
||||
|
||||
if (test('cli help and invalid args exit cleanly', () => {
|
||||
const help = runProcess(['--help']);
|
||||
assert.strictEqual(help.status, 0);
|
||||
|
||||
Reference in New Issue
Block a user