npm.io
1.0.0 • Published 3 weeks ago

all-contributors-for-repository

Licence
MIT
Version
1.0.0
Deps
5
Size
114 kB
Vulns
0
Weekly
0
Stars
4

All Contributors For Repository

Generates an allcontributors list for an existing repository.

 All Contributors: 7  Code of Conduct: Kept  Coverage  License: MIT  npm version  TypeScript: Strict

Usage

npm i all-contributors-for-repository
import { getAllContributorsForRepository } from "all-contributors-for-repository";

const contributors = await getAllContributorsForRepository({
	owner: "JoshuaKGoldberg",
	repo: "create-typescript-app",
});

/*
{
  john_reilly: [ 'bug', 'code' ],
  joshuakgoldberg: [ 'maintenance', 'tool' ],
}
*/
console.log(contributors);

Warning This tool only sees contributions that can be detected from the last 500 events in GitHub's API. Don't forget to manually add in other forms of contributions!

The types of contributions detected from the GitHub API are:

  • bug: anybody who filed an issue labeled as accepting PRs and a bug (see Options)
  • doc: authors of merged PRs that address issues labeled as accepting PRs and docs (see Options)
  • maintenance: adding labels to issues and PRs, and merging PRs
  • review: submitting a review for a PR
  • tool: authors of merged PRs that address issues labeled as accepting PRs and tooling (see Options)

Additionally, based on PR conventional commit titles in the Angular convention, for all PR authors and co-authors:

  • build and ci: will be treated as an :infra: contribution
  • docs: will be treated as an :doc: contribution
  • test: will be treated as an :test: contribution
  • All other PRs -including those without a conventional title- will be treated as :code: contributions

Given that list of contributors, you might want to run all-contributors add on each contributor & contribution type.

import { $ } from "execa";

for (const [contributor, contributions] of Object.entries(contributors)) {
	const contributionTypes = Object.keys(contributions).join(",");
	await $`npx all-contributors add ${contributor} ${contributionTypes}`;
}

See populate-all-contributors-for-repository for a project that does just that.

Options

The exported getAllContributorsForRepository function takes in an object with two required properties:

  • owner (string): The owner of the repository to query, such as "JoshuaKGoldberg".
  • repository (string): The name of the repository to query, such as "all-contributors-for-repository".

It additionally allows for the following optional options.

  • auth (string): GitHub auth token to query the API with, if necessary for private repositories and/or to avoid rate limiting.
  • ignoredLogins (RegExp[]): Regular expressions for usernames to ignore commits from, such as bot users.
    • Default: [/\[bot\]$/i, /^allcontributors$/i, /^copilot$/i, /^dependabot$/i, /^renovate$/i]
  • labelAcceptingPrs (string): Label to indicate an issue is accepting pull requests.
  • labelTypeBug (string): Label to indicate an issue is for a bug.
  • labelTypeDocs (string): Label to indicate an issue is for documentation.
  • labelTypeIdeas (string): Label to indicate an issue is for a feature.
  • labelTypeTool (string): Label to indicate an issue is for tooling.
  • since (Date): Only include contributions made at or after this time.
    • Default: no limit; all available contributions are included.
    • Useful for repeated runs, to avoid re-requesting contributions that were already seen.
import { getAllContributorsForRepository } from "all-contributors-for-repository";

getAllContributorsForRepository({
	auth: "abc123",
	ignoredLogins: [/-it$/i],
	labelAcceptingPrs: "help wanted",
	labelTypeBug: "bug",
	labelTypeDocs: "docs",
	labelTypeIdeas: "feature",
	labelTypeTool: "tool",
	since: new Date("2026-01-01"),
});

Development

See .github/CONTRIBUTING.md, then .github/DEVELOPMENT.md. Thanks!

Contributors

Adrian D'Alessandro
Adrian D'Alessandro

Eli
Eli

Fabian De La Peña Montero
Fabian De La Peña Montero

Josh Goldberg
Josh Goldberg

Navin Moorthy
Navin Moorthy

Phi Nguyen
Phi Nguyen

michael faith
michael faith

This package was templated with create-typescript-app using the Bingo framework.