Skip to content

Commit 23090c4

Browse files
committed
github fetch owner details
1 parent 63c1a79 commit 23090c4

6 files changed

+78946
-1
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

editRegistry.js

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
const fs = require("fs");
2+
const { Octokit } = require("@octokit/rest");
3+
const octokit = new Octokit({
4+
auth: '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'
5+
})
6+
7+
async function x() {
8+
let registry = JSON.parse(fs.readFileSync("registry.json", "utf-8"));
9+
let ownerDetails = JSON.parse(fs.readFileSync("ownerDetails.json", "utf-8"));
10+
console.log("number of registry extensions = ", Object.keys(registry).length);
11+
let ownerCount = 0, updateCount = 0,orgCount = 0, verifiedOrgs = 0;
12+
for (let registryKey of Object.keys(registry)) {
13+
let owner = registry[registryKey].owner;
14+
if (!ownerDetails[owner]) {
15+
let ownerSplit = registry[registryKey].owner.split(":");
16+
try{
17+
console.log("fetching ", owner);
18+
let ownerInfo = await octokit.request(`GET /orgs/${ownerSplit[1]}`, {
19+
org: 'ORG'
20+
})
21+
console.log(ownerInfo.data);
22+
ownerDetails[owner] = ownerInfo.data;
23+
orgCount ++;
24+
if(ownerInfo.data.is_verified){
25+
verifiedOrgs++;
26+
}
27+
} catch(e){
28+
if(e.status !== 404){
29+
console.error("Error fetching with critical error", e);
30+
break;
31+
}
32+
ownerDetails[owner] = {}
33+
}
34+
updateCount++;
35+
}
36+
ownerCount++;
37+
if (updateCount === 500) {
38+
// trial run
39+
break;
40+
}
41+
}
42+
console.log("total processed: ", ownerCount);
43+
console.log("total updated: ", updateCount);
44+
console.log("total orgs updated: ", orgCount);
45+
console.log("verified orgs updated: ", verifiedOrgs);
46+
47+
fs.writeFileSync("ownerDetails.json", JSON.stringify(ownerDetails, null, 4), "utf-8");
48+
}
49+
50+
x();

0 commit comments

Comments
 (0)