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

Commit

Permalink
Merge pull request #145 from protocol/get-repo-script
Browse files Browse the repository at this point in the history
feat: add script to get a list of all repos
  • Loading branch information
marten-seemann authored Jul 26, 2021
2 parents 1d33177 + a2c06ff commit 639ae74
Show file tree
Hide file tree
Showing 6 changed files with 414 additions and 0 deletions.
3 changes: 3 additions & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Repo Maintenence Scripts

This directory contains a set of scripts useful for repo maintenence.
1 change: 1 addition & 0 deletions scripts/get-repos/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
30 changes: 30 additions & 0 deletions scripts/get-repos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Repo List

List all PL repos. Currently, this script lists all Go & JavaScript repos in the following orgs:

- ipfs
- ipfs-shipyard
- ipld
- libp2p
- multiformats

It outputs them as a JSON array.

## Install

Before usage, you'll need to install the dependencies.

```bash
$ npm install
```

## Usage

```bash
$ node index.js
```

If you run into GitHub's rate limits, try setting the GITHUB_TOKEN environment variable:
```bash
$ GITHUB_TOKEN=your_token node index.js
```
34 changes: 34 additions & 0 deletions scripts/get-repos/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import {Octokit} from '@octokit/rest'

const LANGUAGES = ["JavaScript", "Go"]
const ORGS = ["ipfs", "ipfs-shipyard", "ipld", "libp2p", "multiformats"]

const options = {}
if (process.env.GITHUB_TOKEN) {
options.auth = process.env.GITHUB_TOKEN
}

const octokit = new Octokit(options)

async function list_repos(orgs, langs) {
let results = []
for (const org of orgs) {
for await (const resp of octokit.paginate.iterator(octokit.rest.repos.listForOrg, {org})) {
for (const repo of resp.data) {
if (repo.private || repo.archived) {
continue
}
if (!langs.includes(repo.language)) {
continue
}
results.push(repo.full_name)
}
}
}
return results.sort((a, b) => a.full_name < b.full_name)
}

(async () => {
let repos = await list_repos(ORGS, LANGUAGES)
console.log(JSON.stringify(repos))
})()
Loading

0 comments on commit 639ae74

Please sign in to comment.