This repository has been archived by the owner on Aug 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #145 from protocol/get-repo-script
feat: add script to get a list of all repos
- Loading branch information
Showing
6 changed files
with
414 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
})() |
Oops, something went wrong.