Skip to content

Commit

Permalink
feat: create createAllContributorsForRepository
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaKGoldberg committed May 1, 2023
1 parent c943b06 commit 6777f80
Show file tree
Hide file tree
Showing 22 changed files with 724 additions and 116 deletions.
13 changes: 11 additions & 2 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,24 @@
"contributors": [
{
"avatar_url": "https://avatars.githubusercontent.com/u/3335181?v=4",
"contributions": ["tool"],
"contributions": [
"tool",
"bug",
"code",
"maintenance",
"review",
"doc"
],
"login": "JoshuaKGoldberg",
"name": "Josh Goldberg",
"profile": "http://www.joshuakgoldberg.com"
}
],
"contributorsPerLine": 7,
"contributorsSortAlphabetically": true,
"files": ["README.md"],
"files": [
"README.md"
],
"imageSize": 100,
"projectName": "all-contributors-for-repository",
"projectOwner": "JoshuaKGoldberg",
Expand Down
7 changes: 7 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ module.exports = {
},
extends: ["plugin:jsonc/recommended-with-json"],
},
{
files: ["**/*.md/*.ts"],
rules: {
// These rules don't make sense in .md codeblocks
"@typescript-eslint/no-unused-vars": "off",
},
},
{
files: "**/*.test.ts",
rules: {
Expand Down
37 changes: 34 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,42 @@ npm i all-contributors-for-repository
```

```ts
import { greet } from "all-contributors-for-repository";
import { createAllContributorsForRepository } from "all-contributors-for-repository";

greet("Hello, world!");
const contributors = await createAllContributorsForRepository();
/*
{
john_reilly: [ 'bug', 'code' ],
joshuakgoldberg: [ 'maintenance', 'tool' ],
}
*/
```

> **Warning**
> This tool only sees contributions that can be detected from GitHub's API.
> Don't forget to manually add in other forms of contributions!
The types of contributions detected are:

- 🐛 `bug`: anybody who filed an issue labeled as accepting PRs and a bug _(see options)_
- 💻 `computer`: all PR authors and co-authors
- 📖 `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)_

> 💡 Given that list of contributors, you might want to run `all-contributors add` on each contributor & contribution type.
>
> ```ts
> import { $ } from "execa";
>
> for (const [contributor, contributions] of Object.entries(contributors)) {
> for (const contribution of contributions) {
> await $`npx all-contributors add ${contributor} ${contribution}`;
> }
> }
> ```
## Development
See [`.github/CONTRIBUTING.md`](./.github/CONTRIBUTING.md), then [`.github/DEVELOPMENT.md`](./.github/DEVELOPMENT.md).
Expand All @@ -52,7 +83,7 @@ Thanks! 💖
<table>
<tbody>
<tr>
<td align="center" valign="top" width="14.28%"><a href="http://www.joshuakgoldberg.com"><img src="https://avatars.githubusercontent.com/u/3335181?v=4?s=100" width="100px;" alt="Josh Goldberg"/><br /><sub><b>Josh Goldberg</b></sub></a><br /><a href="#tool-JoshuaKGoldberg" title="Tools">🔧</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://www.joshuakgoldberg.com"><img src="https://avatars.githubusercontent.com/u/3335181?v=4?s=100" width="100px;" alt="Josh Goldberg"/><br /><sub><b>Josh Goldberg</b></sub></a><br /><a href="#tool-JoshuaKGoldberg" title="Tools">🔧</a> <a href="https://github.com/JoshuaKGoldberg/all-contributors-for-repository/issues?q=author%3AJoshuaKGoldberg" title="Bug reports">🐛</a> <a href="https://github.com/JoshuaKGoldberg/all-contributors-for-repository/commits?author=JoshuaKGoldberg" title="Code">💻</a> <a href="#maintenance-JoshuaKGoldberg" title="Maintenance">🚧</a> <a href="https://github.com/JoshuaKGoldberg/all-contributors-for-repository/pulls?q=is%3Apr+reviewed-by%3AJoshuaKGoldberg" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/JoshuaKGoldberg/all-contributors-for-repository/commits?author=JoshuaKGoldberg" title="Documentation">📖</a></td>
</tr>
</tbody>
</table>
Expand Down
8 changes: 5 additions & 3 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@
"script/*.json"
],
"words": [
"allcontributors",
"Codecov",
"codespace",
"commitlint",
"contributorsrc",
"conventionalcommits",
"execa",
"infile",
"joshuakgoldberg",
"knip",
"lcov",
"outro",
"packagejson",
"quickstart",
"wontfix",
"outro",
"execa"
"wontfix"
]
}
1 change: 0 additions & 1 deletion knip.jsonc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"$schema": "https://unpkg.com/knip@next/schema.json",
"entry": "src/index.ts!",
"ignoreBinaries": ["gh", "grep"],
"project": "src/**/*.ts!"
}
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
"lint-staged": {
"*": "prettier --ignore-unknown --write"
},
"dependencies": {
"octokit": "^2.0.14"
},
"devDependencies": {
"@types/eslint": "^8.21.1",
"@typescript-eslint/eslint-plugin": "^5.48.2",
Expand Down
Loading

0 comments on commit 6777f80

Please sign in to comment.