Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Deployable **GitHub language chart generator** — embeddable SVGs for READMEs a
- **Theming**: Supports `default`, `light`, and `dark` themes.
- **Custom Colours**: Set background (`bg`), text (`text`), and individual language colours (`c1`-`c16`) via query parameters.
- **Dynamic Layout:** The legend automatically shifts to a **two-column layout** when displaying 9 or more languages.
- Automatically fetches all public GitHub repositories. Organization sources with a token also include private repos visible to that token.
- Automatically fetches all public GitHub repositories. Users or organization sources with a token include private repos exposed to that token.
- Ignores forks and optionally specific repositories (`IGNORED_REPOS`).
- Uses **hourly caching** to reduce API calls and improve performance.

Expand Down
18 changes: 11 additions & 7 deletions src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,17 @@ async function fetchAndAggregate(now: number): Promise<LanguageBytes> {
let hadFetchFailure = false;
const repoGroups = await Promise.all([
...usernames.map(u =>
fetchAllRepos(`https://api.github.com/users/${encodeURIComponent(u.name)}/repos?per_page=100`, u.token)
.then(repos => ({ token: u.token, repos }))
.catch(() => {
hadFetchFailure = true;
console.error(`Skipping user "${u.name}": failed to fetch repositories.`);
return { token: u.token, repos: [] as Repo[] };
})
fetchAllRepos(
u.token ? `https://api.github.com/user/repos?per_page=100&visibility=all&affiliation=owner`
: `https://api.github.com/users/${encodeURIComponent(u.name)}/repos?per_page=100`,
u.token
)
.then(repos => ({ token: u.token, repos }))
.catch(() => {
hadFetchFailure = true;
console.error(`Skipping user "${u.name}": failed to fetch repositories.`);
return { token: u.token, repos: [] as Repo[] };
})
),
...orgs.map(o =>
fetchAllRepos(`https://api.github.com/orgs/${encodeURIComponent(o.name)}/repos?per_page=100`, o.token)
Expand Down
2 changes: 1 addition & 1 deletion tests/github.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ describe("fetchLanguageData", () => {
await fetchLanguageData();

expect(global.fetch).toHaveBeenCalledWith(
"https://api.github.com/users/testuser/repos?per_page=100",
"https://api.github.com/user/repos?per_page=100&visibility=all&affiliation=owner",
{ headers: { Authorization: "Bearer test-token" } }
);
expect(global.fetch).toHaveBeenCalledWith(
Expand Down
Loading