all-contributors-for-repository 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -13
- package/lib/Contributor.d.ts +3 -2
- package/lib/Contributor.js +8 -7
- package/lib/Contributor.js.map +1 -1
- package/lib/ContributorsCollection.d.ts +5 -4
- package/lib/ContributorsCollection.js +32 -33
- package/lib/ContributorsCollection.js.map +1 -1
- package/lib/collect/adding/addAcceptedIssues.d.ts +9 -0
- package/lib/collect/adding/addAcceptedIssues.js +27 -0
- package/lib/collect/adding/addAcceptedIssues.js.map +1 -0
- package/lib/collect/adding/addMergedPulls.d.ts +8 -0
- package/lib/collect/adding/addMergedPulls.js +22 -0
- package/lib/collect/adding/addMergedPulls.js.map +1 -0
- package/lib/collect/api.d.ts +8 -6
- package/lib/collect/api.js +20 -16
- package/lib/collect/api.js.map +1 -1
- package/lib/collect/collecting/collectAcceptedIssues.d.ts +511 -0
- package/lib/collect/collecting/collectAcceptedIssues.js +16 -0
- package/lib/collect/collecting/collectAcceptedIssues.js.map +1 -0
- package/lib/collect/{collectIssueEvents.d.ts → collecting/collectIssueEvents.d.ts} +7 -4
- package/lib/collect/collecting/collectIssueEvents.js +27 -0
- package/lib/collect/collecting/collectIssueEvents.js.map +1 -0
- package/lib/collect/{collectMergedPulls.d.ts → collecting/collectMergedPulls.d.ts} +7 -4
- package/lib/collect/collecting/collectMergedPulls.js +14 -0
- package/lib/collect/collecting/collectMergedPulls.js.map +1 -0
- package/lib/collect/{collectEvents.d.ts → collecting/collectRepoEvents.d.ts} +7 -5
- package/lib/collect/collecting/collectRepoEvents.js +17 -0
- package/lib/collect/collecting/collectRepoEvents.js.map +1 -0
- package/lib/collect/index.d.ts +6 -4
- package/lib/collect/index.js +23 -61
- package/lib/collect/index.js.map +1 -1
- package/lib/collect/parsing/parseMergedPullAuthors.d.ts +5 -4
- package/lib/collect/parsing/parseMergedPullAuthors.js +19 -15
- package/lib/collect/parsing/parseMergedPullAuthors.js.map +1 -1
- package/lib/collect/parsing/parseMergedPullType.d.ts +3 -2
- package/lib/collect/parsing/parseMergedPullType.js +11 -8
- package/lib/collect/parsing/parseMergedPullType.js.map +1 -1
- package/lib/collect/processing/processContributors.d.ts +10 -0
- package/lib/collect/processing/processContributors.js +26 -0
- package/lib/collect/processing/processContributors.js.map +1 -0
- package/lib/collect/processing/repoEventIsPullRequestReviewEvent.d.ts +12 -0
- package/lib/collect/processing/repoEventIsPullRequestReviewEvent.js +7 -0
- package/lib/collect/processing/repoEventIsPullRequestReviewEvent.js.map +1 -0
- package/lib/getAllContributorsForRepository.d.ts +6 -3
- package/lib/getAllContributorsForRepository.js +9 -4
- package/lib/getAllContributorsForRepository.js.map +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.js +4 -1
- package/lib/index.js.map +1 -1
- package/lib/options.d.ts +10 -4
- package/lib/options.js +30 -23
- package/lib/options.js.map +1 -1
- package/package.json +50 -40
- package/lib/CachingMap.d.ts +0 -8
- package/lib/CachingMap.d.ts.map +0 -1
- package/lib/CachingMap.js +0 -30
- package/lib/CachingMap.js.map +0 -1
- package/lib/CachingMap.test.d.ts +0 -2
- package/lib/CachingMap.test.d.ts.map +0 -1
- package/lib/CachingMap.test.js +0 -31
- package/lib/CachingMap.test.js.map +0 -1
- package/lib/Contributor.d.ts.map +0 -1
- package/lib/Contributor.test.d.ts +0 -2
- package/lib/Contributor.test.d.ts.map +0 -1
- package/lib/Contributor.test.js +0 -25
- package/lib/Contributor.test.js.map +0 -1
- package/lib/ContributorsCollection.d.ts.map +0 -1
- package/lib/ContributorsCollection.test.d.ts +0 -2
- package/lib/ContributorsCollection.test.d.ts.map +0 -1
- package/lib/ContributorsCollection.test.js +0 -38
- package/lib/ContributorsCollection.test.js.map +0 -1
- package/lib/collect/api.d.ts.map +0 -1
- package/lib/collect/api.test.d.ts +0 -2
- package/lib/collect/api.test.d.ts.map +0 -1
- package/lib/collect/api.test.js +0 -43
- package/lib/collect/api.test.js.map +0 -1
- package/lib/collect/collectAcceptedIssues.d.ts +0 -510
- package/lib/collect/collectAcceptedIssues.d.ts.map +0 -1
- package/lib/collect/collectAcceptedIssues.js +0 -13
- package/lib/collect/collectAcceptedIssues.js.map +0 -1
- package/lib/collect/collectEvents.d.ts.map +0 -1
- package/lib/collect/collectEvents.js +0 -12
- package/lib/collect/collectEvents.js.map +0 -1
- package/lib/collect/collectIssueEvents.d.ts.map +0 -1
- package/lib/collect/collectIssueEvents.js +0 -19
- package/lib/collect/collectIssueEvents.js.map +0 -1
- package/lib/collect/collectMergedPulls.d.ts.map +0 -1
- package/lib/collect/collectMergedPulls.js +0 -11
- package/lib/collect/collectMergedPulls.js.map +0 -1
- package/lib/collect/eventIsPullRequestReviewEvent.d.ts +0 -9
- package/lib/collect/eventIsPullRequestReviewEvent.d.ts.map +0 -1
- package/lib/collect/eventIsPullRequestReviewEvent.js +0 -5
- package/lib/collect/eventIsPullRequestReviewEvent.js.map +0 -1
- package/lib/collect/eventIsPullRequestReviewEvent.test.d.ts +0 -2
- package/lib/collect/eventIsPullRequestReviewEvent.test.d.ts.map +0 -1
- package/lib/collect/eventIsPullRequestReviewEvent.test.js +0 -15
- package/lib/collect/eventIsPullRequestReviewEvent.test.js.map +0 -1
- package/lib/collect/index.d.ts.map +0 -1
- package/lib/collect/parsing/CachingMap.d.ts +0 -7
- package/lib/collect/parsing/CachingMap.d.ts.map +0 -1
- package/lib/collect/parsing/CachingMap.js +0 -30
- package/lib/collect/parsing/CachingMap.js.map +0 -1
- package/lib/collect/parsing/collectUserByEmail.d.ts +0 -3
- package/lib/collect/parsing/collectUserByEmail.d.ts.map +0 -1
- package/lib/collect/parsing/collectUserByEmail.js +0 -5
- package/lib/collect/parsing/collectUserByEmail.js.map +0 -1
- package/lib/collect/parsing/parseMergedPullAuthors.d.ts.map +0 -1
- package/lib/collect/parsing/parseMergedPullAuthors.test.d.ts +0 -2
- package/lib/collect/parsing/parseMergedPullAuthors.test.d.ts.map +0 -1
- package/lib/collect/parsing/parseMergedPullAuthors.test.js +0 -49
- package/lib/collect/parsing/parseMergedPullAuthors.test.js.map +0 -1
- package/lib/collect/parsing/parseMergedPullType.d.ts.map +0 -1
- package/lib/collect/parsing/parseMergedPullType.test.d.ts +0 -2
- package/lib/collect/parsing/parseMergedPullType.test.d.ts.map +0 -1
- package/lib/collect/parsing/parseMergedPullType.test.js +0 -16
- package/lib/collect/parsing/parseMergedPullType.test.js.map +0 -1
- package/lib/createAllContributorsForRepository.d.ts +0 -3
- package/lib/createAllContributorsForRepository.d.ts.map +0 -1
- package/lib/createAllContributorsForRepository.js +0 -7
- package/lib/createAllContributorsForRepository.js.map +0 -1
- package/lib/getAllContributorsForRepository.d.ts.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/options.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<h1 align="center">All Contributors For Repository</h1>
|
|
2
2
|
|
|
3
|
-
<p align="center">Generates an allcontributors list for an existing repository
|
|
3
|
+
<p align="center">Generates an allcontributors list for an existing repository. 🤝</p>
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
6
6
|
<a href="#contributors" target="_blank">
|
|
@@ -9,21 +9,23 @@
|
|
|
9
9
|
<img alt="All Contributors: 1" src="https://img.shields.io/badge/all_contributors-1-21bb42.svg" />
|
|
10
10
|
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
11
11
|
<!-- prettier-ignore-end -->
|
|
12
|
-
|
|
12
|
+
</a>
|
|
13
13
|
<a href="https://codecov.io/gh/JoshuaKGoldberg/all-contributors-for-repository" target="_blank">
|
|
14
|
-
<img alt="Codecov Test Coverage" src="https://codecov.io/gh/JoshuaKGoldberg/all-contributors-for-repository/branch/main/graph/badge.svg
|
|
14
|
+
<img alt="Codecov Test Coverage" src="https://codecov.io/gh/JoshuaKGoldberg/all-contributors-for-repository/branch/main/graph/badge.svg"/>
|
|
15
15
|
</a>
|
|
16
16
|
<a href="https://github.com/JoshuaKGoldberg/all-contributors-for-repository/blob/main/.github/CODE_OF_CONDUCT.md" target="_blank">
|
|
17
17
|
<img alt="Contributor Covenant" src="https://img.shields.io/badge/code_of_conduct-enforced-21bb42" />
|
|
18
18
|
</a>
|
|
19
19
|
<a href="https://github.com/JoshuaKGoldberg/all-contributors-for-repository/blob/main/LICENSE.md" target="_blank">
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
<img alt="License: MIT" src="https://img.shields.io/github/license/JoshuaKGoldberg/all-contributors-for-repository?color=21bb42">
|
|
21
|
+
</a>
|
|
22
22
|
<a href="https://github.com/sponsors/JoshuaKGoldberg" target="_blank">
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
<img alt="Sponsor: On GitHub" src="https://img.shields.io/badge/sponsor-on_github-21bb42.svg" />
|
|
24
|
+
</a>
|
|
25
25
|
<img alt="Style: Prettier" src="https://img.shields.io/badge/style-prettier-21bb42.svg" />
|
|
26
|
-
|
|
26
|
+
<img alt="TypeScript: Strict" src="https://img.shields.io/badge/typescript-strict-21bb42.svg" />
|
|
27
|
+
<img alt="npm package version" src="https://img.shields.io/npm/v/all-contributors-for-repository?color=21bb42" />
|
|
28
|
+
<img alt="Sponsor: On GitHub" src="https://img.shields.io/badge/sponsor-on_github-21bb42.svg" />
|
|
27
29
|
</p>
|
|
28
30
|
|
|
29
31
|
<p align="center">
|
|
@@ -45,12 +47,14 @@ const contributors = await getAllContributorsForRepository({
|
|
|
45
47
|
owner: "JoshuaKGoldberg",
|
|
46
48
|
repo: "template-typescript-node-package",
|
|
47
49
|
});
|
|
50
|
+
|
|
48
51
|
/*
|
|
49
52
|
{
|
|
50
53
|
john_reilly: [ 'bug', 'code' ],
|
|
51
54
|
joshuakgoldberg: [ 'maintenance', 'tool' ],
|
|
52
55
|
}
|
|
53
56
|
*/
|
|
57
|
+
console.log(contributors);
|
|
54
58
|
```
|
|
55
59
|
|
|
56
60
|
> **Warning**
|
|
@@ -100,7 +104,7 @@ It additionally allows for the following optional options.
|
|
|
100
104
|
- `labelTypeDocs` _(`string`)_: Label to indicate an issue is for documentation.
|
|
101
105
|
- `labelTypeTool` _(`string`)_: Label to indicate an issue is for tooling.
|
|
102
106
|
|
|
103
|
-
```
|
|
107
|
+
```ts
|
|
104
108
|
import { getAllContributorsForRepository } from "all-contributors-for-repository";
|
|
105
109
|
|
|
106
110
|
getAllContributorsForRepository({
|
|
@@ -127,7 +131,7 @@ Thanks! 💖
|
|
|
127
131
|
<table>
|
|
128
132
|
<tbody>
|
|
129
133
|
<tr>
|
|
130
|
-
<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>
|
|
134
|
+
<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> <a href="#infra-JoshuaKGoldberg" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
|
|
131
135
|
</tr>
|
|
132
136
|
</tbody>
|
|
133
137
|
</table>
|
|
@@ -138,6 +142,4 @@ Thanks! 💖
|
|
|
138
142
|
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
139
143
|
<!-- spellchecker: enable -->
|
|
140
144
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
> 💙 This package is based on [@JoshuaKGoldberg](https://github.com/JoshuaKGoldberg)'s [template-typescript-node-package](https://github.com/JoshuaKGoldberg/template-typescript-node-package).
|
|
145
|
+
> 💙 This package is based on [@JoshuaKGoldberg](https://github.com/JoshuaKGoldberg)'s [create-typescript-app](https://github.com/JoshuaKGoldberg/create-typescript-app).
|
package/lib/Contributor.d.ts
CHANGED
package/lib/Contributor.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
(this.contributions[type] ??= new Set()).add(number);
|
|
7
|
-
}
|
|
1
|
+
class Contributor {
|
|
2
|
+
contributions = {};
|
|
3
|
+
add(number, type) {
|
|
4
|
+
(this.contributions[type] ??= /* @__PURE__ */ new Set()).add(number);
|
|
5
|
+
}
|
|
8
6
|
}
|
|
7
|
+
export {
|
|
8
|
+
Contributor
|
|
9
|
+
};
|
|
9
10
|
//# sourceMappingURL=Contributor.js.map
|
package/lib/Contributor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/Contributor.ts"],"sourcesContent":["export class Contributor {\n\treadonly contributions: Record<string, Set<number>> = {};\n\n\tadd(number: number, type: string) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n\t\t(this.contributions[type] ??= new Set()).add(number);\n\t}\n}\n"],"mappings":"AAAO,MAAM,YAAY;AAAA,EACf,gBAA6C,CAAC;AAAA,EAEvD,IAAI,QAAgB,MAAc;AAEjC,KAAC,KAAK,cAAc,IAAI,MAAM,oBAAI,IAAI,GAAG,IAAI,MAAM;AAAA,EACpD;AACD;","names":[]}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* For a set of logins, the contributions under those users.
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
type ContributorsContributions = Record<string, ContributorContributions>;
|
|
5
5
|
/**
|
|
6
6
|
* For each contribution under a login, the issue/PR numbers that count as that type.
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
type ContributorContributions = Record<string, number[]>;
|
|
9
|
+
declare class ContributorsCollection {
|
|
10
10
|
#private;
|
|
11
11
|
constructor(ignoredLogins: Set<string>);
|
|
12
12
|
add(login: string | undefined, number: number, type: string): void;
|
|
13
13
|
collect(): ContributorsContributions;
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
|
|
16
|
+
export { type ContributorContributions, ContributorsCollection, type ContributorsContributions };
|
|
@@ -1,38 +1,37 @@
|
|
|
1
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
-
};
|
|
7
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
-
};
|
|
12
|
-
var _ContributorsCollection_contributors, _ContributorsCollection_ignoredLogins;
|
|
13
1
|
import { Contributor } from "./Contributor.js";
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
2
|
+
class ContributorsCollection {
|
|
3
|
+
#contributors = {};
|
|
4
|
+
#ignoredLogins;
|
|
5
|
+
constructor(ignoredLogins) {
|
|
6
|
+
this.#ignoredLogins = ignoredLogins;
|
|
7
|
+
}
|
|
8
|
+
add(login, number, type) {
|
|
9
|
+
if (login && !this.#ignoredLogins.has(login)) {
|
|
10
|
+
(this.#contributors[login.toLowerCase()] ??= new Contributor()).add(
|
|
11
|
+
number,
|
|
12
|
+
type
|
|
13
|
+
);
|
|
24
14
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
15
|
+
}
|
|
16
|
+
collect() {
|
|
17
|
+
return Object.fromEntries(
|
|
18
|
+
Object.entries(this.#contributors).map(
|
|
19
|
+
([login, contributor]) => [
|
|
20
|
+
login,
|
|
21
|
+
Object.fromEntries(
|
|
22
|
+
Object.entries(contributor.contributions).map(
|
|
23
|
+
([type, numbers]) => [
|
|
30
24
|
type,
|
|
31
|
-
Array.from(numbers).sort((a, b) => a - b)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
Array.from(numbers).sort((a, b) => a - b)
|
|
26
|
+
]
|
|
27
|
+
)
|
|
28
|
+
)
|
|
29
|
+
]
|
|
30
|
+
).sort(([a], [b]) => a.localeCompare(b))
|
|
31
|
+
);
|
|
32
|
+
}
|
|
36
33
|
}
|
|
37
|
-
|
|
34
|
+
export {
|
|
35
|
+
ContributorsCollection
|
|
36
|
+
};
|
|
38
37
|
//# sourceMappingURL=ContributorsCollection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/ContributorsCollection.ts"],"sourcesContent":["import { Contributor } from \"./Contributor.js\";\n\n/**\n * For a set of logins, the contributions under those users.\n */\nexport type ContributorsContributions = Record<\n\tstring,\n\tContributorContributions\n>;\n\n/**\n * For each contribution under a login, the issue/PR numbers that count as that type.\n */\nexport type ContributorContributions = Record<string, number[]>;\n\nexport class ContributorsCollection {\n\t#contributors: Record<string, Contributor> = {};\n\t#ignoredLogins: Set<string>;\n\n\tconstructor(ignoredLogins: Set<string>) {\n\t\tthis.#ignoredLogins = ignoredLogins;\n\t}\n\n\tadd(login: string | undefined, number: number, type: string) {\n\t\tif (login && !this.#ignoredLogins.has(login)) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n\t\t\t(this.#contributors[login.toLowerCase()] ??= new Contributor()).add(\n\t\t\t\tnumber,\n\t\t\t\ttype,\n\t\t\t);\n\t\t}\n\t}\n\n\tcollect(): ContributorsContributions {\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries(this.#contributors)\n\t\t\t\t.map(\n\t\t\t\t\t([login, contributor]) =>\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\tlogin,\n\t\t\t\t\t\t\tObject.fromEntries(\n\t\t\t\t\t\t\t\tObject.entries(contributor.contributions).map(\n\t\t\t\t\t\t\t\t\t([type, numbers]) => [\n\t\t\t\t\t\t\t\t\t\ttype,\n\t\t\t\t\t\t\t\t\t\tArray.from(numbers).sort((a, b) => a - b),\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t] as const,\n\t\t\t\t)\n\t\t\t\t.sort(([a], [b]) => a.localeCompare(b)),\n\t\t);\n\t}\n}\n"],"mappings":"AAAA,SAAS,mBAAmB;AAerB,MAAM,uBAAuB;AAAA,EACnC,gBAA6C,CAAC;AAAA,EAC9C;AAAA,EAEA,YAAY,eAA4B;AACvC,SAAK,iBAAiB;AAAA,EACvB;AAAA,EAEA,IAAI,OAA2B,QAAgB,MAAc;AAC5D,QAAI,SAAS,CAAC,KAAK,eAAe,IAAI,KAAK,GAAG;AAE7C,OAAC,KAAK,cAAc,MAAM,YAAY,CAAC,MAAM,IAAI,YAAY,GAAG;AAAA,QAC/D;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAAA,EAEA,UAAqC;AACpC,WAAO,OAAO;AAAA,MACb,OAAO,QAAQ,KAAK,aAAa,EAC/B;AAAA,QACA,CAAC,CAAC,OAAO,WAAW,MACnB;AAAA,UACC;AAAA,UACA,OAAO;AAAA,YACN,OAAO,QAAQ,YAAY,aAAa,EAAE;AAAA,cACzC,CAAC,CAAC,MAAM,OAAO,MAAM;AAAA,gBACpB;AAAA,gBACA,MAAM,KAAK,OAAO,EAAE,KAAK,CAAC,GAAG,MAAM,IAAI,CAAC;AAAA,cACzC;AAAA,YACD;AAAA,UACD;AAAA,QACD;AAAA,MACF,EACC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AAAA,IACxC;AAAA,EACD;AACD;","names":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ContributorsCollection } from '../../ContributorsCollection.js';
|
|
2
|
+
import { AllContributorsForRepositoryOptions } from '../../options.js';
|
|
3
|
+
import { AcceptedIssue } from '../collecting/collectAcceptedIssues.js';
|
|
4
|
+
import 'octokit';
|
|
5
|
+
import '../api.js';
|
|
6
|
+
|
|
7
|
+
declare function addAcceptedIssues(acceptedIssues: AcceptedIssue[], contributors: Pick<ContributorsCollection, "add">, options: Pick<AllContributorsForRepositoryOptions, `labelType${string}` & keyof AllContributorsForRepositoryOptions>): void;
|
|
8
|
+
|
|
9
|
+
export { addAcceptedIssues };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
function addAcceptedIssues(acceptedIssues, contributors, options) {
|
|
2
|
+
for (const acceptedIssue of acceptedIssues) {
|
|
3
|
+
const labels = acceptedIssue.labels.map(
|
|
4
|
+
(label) => typeof label === "string" ? label : label.name
|
|
5
|
+
);
|
|
6
|
+
for (const [labelType, contribution] of [
|
|
7
|
+
// 🐛 `bug`: anybody who filed an issue labeled as accepting PRs and a bug
|
|
8
|
+
[options.labelTypeBug, "bug"],
|
|
9
|
+
// - 📖 `doc`: authors of merged PRs that address issues labeled as docs
|
|
10
|
+
[options.labelTypeDocs, "docs"],
|
|
11
|
+
// - 🔧 `tool`: authors of merged PRs that address issues labeled as tooling
|
|
12
|
+
[options.labelTypeTool, "tool"]
|
|
13
|
+
]) {
|
|
14
|
+
if (labels.some((label) => label === labelType)) {
|
|
15
|
+
contributors.add(
|
|
16
|
+
acceptedIssue.user?.login,
|
|
17
|
+
acceptedIssue.number,
|
|
18
|
+
contribution
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
addAcceptedIssues
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=addAcceptedIssues.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/collect/adding/addAcceptedIssues.ts"],"sourcesContent":["import { ContributorsCollection } from \"../../ContributorsCollection.js\";\nimport { AllContributorsForRepositoryOptions } from \"../../options.js\";\nimport { AcceptedIssue } from \"../collecting/collectAcceptedIssues.js\";\n\nexport function addAcceptedIssues(\n\tacceptedIssues: AcceptedIssue[],\n\tcontributors: Pick<ContributorsCollection, \"add\">,\n\toptions: Pick<\n\t\tAllContributorsForRepositoryOptions,\n\t\t`labelType${string}` & keyof AllContributorsForRepositoryOptions\n\t>,\n) {\n\tfor (const acceptedIssue of acceptedIssues) {\n\t\tconst labels = acceptedIssue.labels.map((label) =>\n\t\t\ttypeof label === \"string\" ? label : label.name,\n\t\t);\n\n\t\tfor (const [labelType, contribution] of [\n\t\t\t// 🐛 `bug`: anybody who filed an issue labeled as accepting PRs and a bug\n\t\t\t[options.labelTypeBug, \"bug\"],\n\t\t\t// - 📖 `doc`: authors of merged PRs that address issues labeled as docs\n\t\t\t[options.labelTypeDocs, \"docs\"],\n\t\t\t// - 🔧 `tool`: authors of merged PRs that address issues labeled as tooling\n\t\t\t[options.labelTypeTool, \"tool\"],\n\t\t] as const) {\n\t\t\tif (labels.some((label) => label === labelType)) {\n\t\t\t\tcontributors.add(\n\t\t\t\t\tacceptedIssue.user?.login,\n\t\t\t\t\tacceptedIssue.number,\n\t\t\t\t\tcontribution,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n}\n"],"mappings":"AAIO,SAAS,kBACf,gBACA,cACA,SAIC;AACD,aAAW,iBAAiB,gBAAgB;AAC3C,UAAM,SAAS,cAAc,OAAO;AAAA,MAAI,CAAC,UACxC,OAAO,UAAU,WAAW,QAAQ,MAAM;AAAA,IAC3C;AAEA,eAAW,CAAC,WAAW,YAAY,KAAK;AAAA;AAAA,MAEvC,CAAC,QAAQ,cAAc,KAAK;AAAA;AAAA,MAE5B,CAAC,QAAQ,eAAe,MAAM;AAAA;AAAA,MAE9B,CAAC,QAAQ,eAAe,MAAM;AAAA,IAC/B,GAAY;AACX,UAAI,OAAO,KAAK,CAAC,UAAU,UAAU,SAAS,GAAG;AAChD,qBAAa;AAAA,UACZ,cAAc,MAAM;AAAA,UACpB,cAAc;AAAA,UACd;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD;","names":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Octokit } from 'octokit';
|
|
2
|
+
import { ContributorsCollection } from '../../ContributorsCollection.js';
|
|
3
|
+
import { MergedPull } from '../collecting/collectMergedPulls.js';
|
|
4
|
+
import '../api.js';
|
|
5
|
+
|
|
6
|
+
declare function addMergedPulls(mergedPulls: MergedPull[], contributors: Pick<ContributorsCollection, "add">, octokit: Octokit): Promise<void>;
|
|
7
|
+
|
|
8
|
+
export { addMergedPulls };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createCachingCoAuthorToUsername } from "co-author-to-username";
|
|
2
|
+
import { parseMergedPullAuthors } from "../parsing/parseMergedPullAuthors.js";
|
|
3
|
+
import { parseMergedPullType } from "../parsing/parseMergedPullType.js";
|
|
4
|
+
async function addMergedPulls(mergedPulls, contributors, octokit) {
|
|
5
|
+
const cachingCoAuthorToUsername = createCachingCoAuthorToUsername({
|
|
6
|
+
fetcher: octokit
|
|
7
|
+
});
|
|
8
|
+
for (const mergedPull of mergedPulls) {
|
|
9
|
+
const authors = await parseMergedPullAuthors(
|
|
10
|
+
mergedPull,
|
|
11
|
+
cachingCoAuthorToUsername
|
|
12
|
+
);
|
|
13
|
+
const type = parseMergedPullType(mergedPull.title);
|
|
14
|
+
for (const author of authors) {
|
|
15
|
+
contributors.add(author, mergedPull.number, type);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
addMergedPulls
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=addMergedPulls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/collect/adding/addMergedPulls.ts"],"sourcesContent":["import { createCachingCoAuthorToUsername } from \"co-author-to-username\";\nimport { Octokit } from \"octokit\";\n\nimport { ContributorsCollection } from \"../../ContributorsCollection.js\";\nimport { MergedPull } from \"../collecting/collectMergedPulls.js\";\nimport { parseMergedPullAuthors } from \"../parsing/parseMergedPullAuthors.js\";\nimport { parseMergedPullType } from \"../parsing/parseMergedPullType.js\";\n\nexport async function addMergedPulls(\n\tmergedPulls: MergedPull[],\n\tcontributors: Pick<ContributorsCollection, \"add\">,\n\toctokit: Octokit,\n) {\n\tconst cachingCoAuthorToUsername = createCachingCoAuthorToUsername({\n\t\tfetcher: octokit,\n\t});\n\n\tfor (const mergedPull of mergedPulls) {\n\t\tconst authors = await parseMergedPullAuthors(\n\t\t\tmergedPull,\n\t\t\tcachingCoAuthorToUsername,\n\t\t);\n\t\tconst type = parseMergedPullType(mergedPull.title);\n\n\t\tfor (const author of authors) {\n\t\t\tcontributors.add(author, mergedPull.number, type);\n\t\t}\n\t}\n}\n"],"mappings":"AAAA,SAAS,uCAAuC;AAKhD,SAAS,8BAA8B;AACvC,SAAS,2BAA2B;AAEpC,eAAsB,eACrB,aACA,cACA,SACC;AACD,QAAM,4BAA4B,gCAAgC;AAAA,IACjE,SAAS;AAAA,EACV,CAAC;AAED,aAAW,cAAc,aAAa;AACrC,UAAM,UAAU,MAAM;AAAA,MACrB;AAAA,MACA;AAAA,IACD;AACA,UAAM,OAAO,oBAAoB,WAAW,KAAK;AAEjD,eAAW,UAAU,SAAS;AAC7B,mBAAa,IAAI,QAAQ,WAAW,QAAQ,IAAI;AAAA,IACjD;AAAA,EACD;AACD;","names":[]}
|
package/lib/collect/api.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { Octokit } from
|
|
2
|
-
|
|
1
|
+
import { Octokit } from 'octokit';
|
|
2
|
+
|
|
3
|
+
interface RequestDefaults {
|
|
3
4
|
owner: string;
|
|
4
5
|
repo: string;
|
|
5
6
|
}
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
declare function createOctokit(auth: string | undefined): Octokit;
|
|
8
|
+
interface RequestOptionsWithPage extends RequestDefaults {
|
|
8
9
|
page: number;
|
|
9
10
|
per_page: number;
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
declare function paginate<T>(defaults: RequestDefaults, request: (requestOptions: RequestOptionsWithPage) => Promise<T[]>): Promise<T[]>;
|
|
13
|
+
|
|
14
|
+
export { type RequestDefaults, type RequestOptionsWithPage, createOctokit, paginate };
|
package/lib/collect/api.js
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
import { Octokit } from "octokit";
|
|
2
2
|
const perPage = 100;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
function createOctokit(auth) {
|
|
4
|
+
return new (Octokit.defaults({
|
|
5
|
+
headers: {
|
|
6
|
+
"X-GitHub-Api-Version": "2022-11-28"
|
|
7
|
+
},
|
|
8
|
+
per_page: perPage
|
|
9
|
+
}))({ auth });
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
11
|
+
async function paginate(defaults, request) {
|
|
12
|
+
const items = [];
|
|
13
|
+
for (let i = 0; i < 10; i += 1) {
|
|
14
|
+
const response = await request({ page: i, per_page: perPage, ...defaults });
|
|
15
|
+
items.push(...response);
|
|
16
|
+
if (response.length < 100) {
|
|
17
|
+
break;
|
|
19
18
|
}
|
|
20
|
-
|
|
19
|
+
}
|
|
20
|
+
return items;
|
|
21
21
|
}
|
|
22
|
+
export {
|
|
23
|
+
createOctokit,
|
|
24
|
+
paginate
|
|
25
|
+
};
|
|
22
26
|
//# sourceMappingURL=api.js.map
|
package/lib/collect/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/collect/api.ts"],"sourcesContent":["import { Octokit } from \"octokit\";\n\nconst perPage = 100;\n\nexport interface RequestDefaults {\n\towner: string;\n\trepo: string;\n}\n\nexport function createOctokit(auth: string | undefined): Octokit {\n\treturn new (Octokit.defaults({\n\t\theaders: {\n\t\t\t\"X-GitHub-Api-Version\": \"2022-11-28\",\n\t\t},\n\t\tper_page: perPage,\n\t}))({ auth });\n}\n\nexport interface RequestOptionsWithPage extends RequestDefaults {\n\tpage: number;\n\tper_page: number;\n}\n\nexport async function paginate<T>(\n\tdefaults: RequestDefaults,\n\trequest: (requestOptions: RequestOptionsWithPage) => Promise<T[]>,\n) {\n\tconst items: T[] = [];\n\n\tfor (let i = 0; i < 10; i += 1) {\n\t\tconst response = await request({ page: i, per_page: perPage, ...defaults });\n\n\t\titems.push(...response);\n\n\t\tif (response.length < 100) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn items;\n}\n"],"mappings":"AAAA,SAAS,eAAe;AAExB,MAAM,UAAU;AAOT,SAAS,cAAc,MAAmC;AAChE,SAAO,KAAK,QAAQ,SAAS;AAAA,IAC5B,SAAS;AAAA,MACR,wBAAwB;AAAA,IACzB;AAAA,IACA,UAAU;AAAA,EACX,CAAC,GAAG,EAAE,KAAK,CAAC;AACb;AAOA,eAAsB,SACrB,UACA,SACC;AACD,QAAM,QAAa,CAAC;AAEpB,WAAS,IAAI,GAAG,IAAI,IAAI,KAAK,GAAG;AAC/B,UAAM,WAAW,MAAM,QAAQ,EAAE,MAAM,GAAG,UAAU,SAAS,GAAG,SAAS,CAAC;AAE1E,UAAM,KAAK,GAAG,QAAQ;AAEtB,QAAI,SAAS,SAAS,KAAK;AAC1B;AAAA,IACD;AAAA,EACD;AAEA,SAAO;AACR;","names":[]}
|