(query, variables)
| 119 | if (!TOKEN) console.error("Warning: no GITHUB_TOKEN/GH_TOKEN (or gh auth token). Resolution will be limited."); |
| 120 | |
| 121 | async function graphql(query, variables) { |
| 122 | const body = JSON.stringify(variables ? { query, variables } : { query }); |
| 123 | const options = { |
| 124 | hostname: "api.github.com", |
| 125 | path: "/graphql", |
| 126 | method: "POST", |
| 127 | headers: { |
| 128 | "User-Agent": "contributors-table-graphql", |
| 129 | "Authorization": `Bearer ${TOKEN}`, |
| 130 | "Content-Type": "application/json", |
| 131 | "Content-Length": Buffer.byteLength(body), |
| 132 | }, |
| 133 | }; |
| 134 | return await new Promise((resolve) => { |
| 135 | const req = https.request(options, (res) => { |
| 136 | let data = ""; |
| 137 | res.setEncoding("utf8"); |
| 138 | res.on("data", (c) => (data += c)); |
| 139 | res.on("end", () => { |
| 140 | try { |
| 141 | const json = JSON.parse(data || "{}"); |
| 142 | if (json.errors && DEBUG) console.error("GraphQL errors:", JSON.stringify(json.errors, null, 2)); |
| 143 | resolve(json); |
| 144 | } catch { resolve({}); } |
| 145 | }); |
| 146 | }); |
| 147 | req.on("error", () => resolve({})); |
| 148 | req.write(body); |
| 149 | req.end(); |
| 150 | }); |
| 151 | } |
| 152 | |
| 153 | // Batch fetch commit author + message for SHAs; count primary-author occurrences per login |
| 154 | async function fetchCommitsByOidBatch(oids) { |
no outgoing calls
no test coverage detected