This repository was 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
feat: add script to get a list of all repos #145
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that I slightly changed the output here to make this script a little more universally applicable. It now just outputs a list of repos (strings), not wrapped in a
{ target: "<repo>" }object.