Skip to content
This repository was archived by the owner on Aug 29, 2023. It is now read-only.

Commit 449cf5e

Browse files
Stebalienmarten-seemann
authored andcommitted
feat: add script to get a list of all repos
1 parent 1631da2 commit 449cf5e

6 files changed

Lines changed: 414 additions & 0 deletions

File tree

scripts/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Repo Maintenence Scripts
2+
3+
This directory contains a set of scripts useful for repo maintenence.

scripts/get-repos/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

scripts/get-repos/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Repo List
2+
3+
List all PL repos. Currently, this script lists all Go & JavaScript repos in the following orgs:
4+
5+
- ipfs
6+
- ipfs-shipyard
7+
- ipld
8+
- libp2p
9+
- multiformats
10+
11+
It outputs them as a JSON array.
12+
13+
## Install
14+
15+
Before usage, you'll need to install the dependencies.
16+
17+
```go
18+
$ npm install
19+
```
20+
21+
## Usage
22+
23+
```bash
24+
$ node index.js
25+
```
26+
27+
If you run into GitHub's rate limits, try setting the GITHUB_TOKEN environment variable:
28+
```bash
29+
$ GITHUB_TOKEN=<your token> node index.js
30+
```

scripts/get-repos/index.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import {Octokit} from '@octokit/rest'
2+
3+
const LANGUAGES = ["JavaScript", "Go"]
4+
const ORGS = ["ipfs", "ipfs-shipyard", "ipld", "libp2p", "multiformats"]
5+
6+
const options = {}
7+
if (process.env.GITHUB_TOKEN) {
8+
options.auth = process.env.GITHUB_TOKEN
9+
}
10+
11+
const octokit = new Octokit(options)
12+
13+
async function list_repos(orgs, langs) {
14+
let results = []
15+
for (const org of orgs) {
16+
for await (const resp of octokit.paginate.iterator(octokit.rest.repos.listForOrg, {org})) {
17+
for (const repo of resp.data) {
18+
if (repo.private || repo.archived) {
19+
continue
20+
}
21+
if (!langs.includes(repo.language)) {
22+
continue
23+
}
24+
results.push(repo.full_name)
25+
}
26+
}
27+
}
28+
return results.sort((a, b) => a.full_name < b.full_name)
29+
}
30+
31+
(async () => {
32+
let repos = await list_repos(ORGS, LANGUAGES)
33+
console.log(JSON.stringify(repos))
34+
})()

0 commit comments

Comments
 (0)