all-contributors-for-repository 0.4.0 → 0.5.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 +24 -38
- package/lib/Contributor.d.ts +5 -3
- package/lib/Contributor.d.ts.map +1 -0
- package/lib/Contributor.js +9 -8
- package/lib/Contributor.js.map +1 -1
- package/lib/ContributorsCollection.d.ts +8 -6
- package/lib/ContributorsCollection.d.ts.map +1 -0
- package/lib/ContributorsCollection.js +20 -34
- package/lib/ContributorsCollection.js.map +1 -1
- package/lib/collect/adding/addAcceptedIssues.d.ts +6 -6
- package/lib/collect/adding/addAcceptedIssues.d.ts.map +1 -0
- package/lib/collect/adding/addAcceptedIssues.js +20 -34
- package/lib/collect/adding/addAcceptedIssues.js.map +1 -1
- package/lib/collect/adding/addMergedPulls.d.ts +6 -5
- package/lib/collect/adding/addMergedPulls.d.ts.map +1 -0
- package/lib/collect/adding/addMergedPulls.js +12 -17
- package/lib/collect/adding/addMergedPulls.js.map +1 -1
- package/lib/collect/api.d.ts +10 -8
- package/lib/collect/api.d.ts.map +1 -0
- package/lib/collect/api.js +21 -20
- package/lib/collect/api.js.map +1 -1
- package/lib/collect/collecting/collectAcceptedIssues.d.ts +408 -354
- package/lib/collect/collecting/collectAcceptedIssues.d.ts.map +1 -0
- package/lib/collect/collecting/collectAcceptedIssues.js +12 -12
- package/lib/collect/collecting/collectAcceptedIssues.js.map +1 -1
- package/lib/collect/collecting/collectIssueEvents.d.ts +596 -522
- package/lib/collect/collecting/collectIssueEvents.d.ts.map +1 -0
- package/lib/collect/collecting/collectIssueEvents.js +17 -22
- package/lib/collect/collecting/collectIssueEvents.js.map +1 -1
- package/lib/collect/collecting/collectMergedPulls.d.ts +393 -341
- package/lib/collect/collecting/collectMergedPulls.d.ts.map +1 -0
- package/lib/collect/collecting/collectMergedPulls.js +12 -10
- package/lib/collect/collecting/collectMergedPulls.js.map +1 -1
- package/lib/collect/collecting/collectRepoEvents.d.ts +551 -487
- package/lib/collect/collecting/collectRepoEvents.d.ts.map +1 -0
- package/lib/collect/collecting/collectRepoEvents.js +11 -13
- package/lib/collect/collecting/collectRepoEvents.js.map +1 -1
- package/lib/collect/index.d.ts +5 -3
- package/lib/collect/index.d.ts.map +1 -0
- package/lib/collect/index.js +20 -15
- package/lib/collect/index.js.map +1 -1
- package/lib/collect/parsing/parseMergedPullAuthors.d.ts +8 -6
- package/lib/collect/parsing/parseMergedPullAuthors.d.ts.map +1 -0
- package/lib/collect/parsing/parseMergedPullAuthors.js +12 -18
- package/lib/collect/parsing/parseMergedPullAuthors.js.map +1 -1
- package/lib/collect/parsing/parseMergedPullType.d.ts +3 -1
- package/lib/collect/parsing/parseMergedPullType.d.ts.map +1 -0
- package/lib/collect/parsing/parseMergedPullType.js +12 -10
- package/lib/collect/parsing/parseMergedPullType.js.map +1 -1
- package/lib/collect/processing/processContributors.d.ts +8 -8
- package/lib/collect/processing/processContributors.d.ts.map +1 -0
- package/lib/collect/processing/processContributors.js +13 -21
- package/lib/collect/processing/processContributors.js.map +1 -1
- package/lib/collect/processing/repoEventIsPullRequestReviewEvent.d.ts +10 -10
- package/lib/collect/processing/repoEventIsPullRequestReviewEvent.d.ts.map +1 -0
- package/lib/collect/processing/repoEventIsPullRequestReviewEvent.js +5 -4
- package/lib/collect/processing/repoEventIsPullRequestReviewEvent.js.map +1 -1
- package/lib/getAllContributorsForRepository.d.ts +5 -3
- package/lib/getAllContributorsForRepository.d.ts.map +1 -0
- package/lib/getAllContributorsForRepository.js +7 -8
- package/lib/getAllContributorsForRepository.js.map +1 -1
- package/lib/index.d.ts +4 -3
- package/lib/index.js +2 -4
- package/lib/options.d.ts +51 -49
- package/lib/options.d.ts.map +1 -0
- package/lib/options.js +28 -31
- package/lib/options.js.map +1 -1
- package/package.json +47 -56
- package/lib/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,37 +1,21 @@
|
|
|
1
1
|
<h1 align="center">All Contributors For Repository</h1>
|
|
2
2
|
|
|
3
|
-
<p align="center">Generates an <a href="https://allcontributors.org">allcontributors</a> list for an existing repository. 🤝</p>
|
|
4
|
-
|
|
5
3
|
<p align="center">
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
9
|
-
<img alt="All Contributors: 2" src="https://img.shields.io/badge/all_contributors-2-21bb42.svg" />
|
|
10
|
-
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
11
|
-
<!-- prettier-ignore-end -->
|
|
12
|
-
</a>
|
|
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"/>
|
|
15
|
-
</a>
|
|
16
|
-
<a href="https://github.com/JoshuaKGoldberg/all-contributors-for-repository/blob/main/.github/CODE_OF_CONDUCT.md" target="_blank">
|
|
17
|
-
<img alt="Contributor Covenant" src="https://img.shields.io/badge/code_of_conduct-enforced-21bb42" />
|
|
18
|
-
</a>
|
|
19
|
-
<a href="https://github.com/JoshuaKGoldberg/all-contributors-for-repository/blob/main/LICENSE.md" target="_blank">
|
|
20
|
-
<img alt="License: MIT" src="https://img.shields.io/github/license/JoshuaKGoldberg/all-contributors-for-repository?color=21bb42">
|
|
21
|
-
</a>
|
|
22
|
-
<a href="https://github.com/sponsors/JoshuaKGoldberg" target="_blank">
|
|
23
|
-
<img alt="Sponsor: On GitHub" src="https://img.shields.io/badge/sponsor-on_github-21bb42.svg" />
|
|
24
|
-
</a>
|
|
25
|
-
<img alt="Style: Prettier" src="https://img.shields.io/badge/style-prettier-21bb42.svg" />
|
|
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" />
|
|
4
|
+
Generates an allcontributors list for an existing repository.
|
|
5
|
+
🤝
|
|
29
6
|
</p>
|
|
30
7
|
|
|
31
8
|
<p align="center">
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
9
|
+
<!-- prettier-ignore-start -->
|
|
10
|
+
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
11
|
+
<a href="#contributors" target="_blank"><img alt="👪 All Contributors: 3" src="https://img.shields.io/badge/%F0%9F%91%AA_all_contributors-3-21bb42.svg" /></a>
|
|
12
|
+
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
13
|
+
<!-- prettier-ignore-end -->
|
|
14
|
+
<a href="https://github.com/JoshuaKGoldberg/all-contributors-for-repository/blob/main/.github/CODE_OF_CONDUCT.md" target="_blank"><img alt="🤝 Code of Conduct: Kept" src="https://img.shields.io/badge/%F0%9F%A4%9D_code_of_conduct-kept-21bb42" /></a>
|
|
15
|
+
<a href="https://codecov.io/gh/JoshuaKGoldberg/all-contributors-for-repository" target="_blank"><img alt="🧪 Coverage" src="https://img.shields.io/codecov/c/github/JoshuaKGoldberg/all-contributors-for-repository?label=%F0%9F%A7%AA%20coverage" /></a>
|
|
16
|
+
<a href="https://github.com/JoshuaKGoldberg/all-contributors-for-repository/blob/main/LICENSE.md" target="_blank"><img alt="📝 License: MIT" src="https://img.shields.io/badge/%F0%9F%93%9D_license-MIT-21bb42.svg" /></a>
|
|
17
|
+
<a href="http://npmjs.com/package/all-contributors-for-repository" target="_blank"><img alt="📦 npm version" src="https://img.shields.io/npm/v/all-contributors-for-repository?color=21bb42&label=%F0%9F%93%A6%20npm" /></a>
|
|
18
|
+
<img alt="💪 TypeScript: Strict" src="https://img.shields.io/badge/%F0%9F%92%AA_typescript-strict-21bb42.svg" />
|
|
35
19
|
</p>
|
|
36
20
|
|
|
37
21
|
## Usage
|
|
@@ -87,7 +71,8 @@ Additionally, based on PR [conventional commit titles](https://www.conventionalc
|
|
|
87
71
|
> }
|
|
88
72
|
> ```
|
|
89
73
|
>
|
|
90
|
-
> See [populate-all-contributors-for-repository](https://github.com/JoshuaKGoldberg/populate-all-contributors-for-repository) for a project that does just that.
|
|
74
|
+
> See [populate-all-contributors-for-repository](https://github.com/JoshuaKGoldberg/populate-all-contributors-for-repository) for a project that does just that.
|
|
75
|
+
> 📋
|
|
91
76
|
|
|
92
77
|
### Options
|
|
93
78
|
|
|
@@ -99,11 +84,12 @@ The exported `getAllContributorsForRepository` function takes in an object with
|
|
|
99
84
|
It additionally allows for the following optional options.
|
|
100
85
|
|
|
101
86
|
- `auth` _(`string`)_: GitHub auth token to query the API with, if necessary for private repositories and/or to avoid rate limiting.
|
|
102
|
-
- `ignoredLogins` _(`
|
|
103
|
-
- Default: `
|
|
87
|
+
- `ignoredLogins` _(`RegExp[]`)_: Regular expressions for usernames to ignore commits from, such as bot users.
|
|
88
|
+
- Default: `[/\[bot\]$/i, /^allcontributors$/i, /^copilot$/i, /^dependabot$/i, /^renovate$/i]`
|
|
104
89
|
- `labelAcceptingPrs` _(`string`)_: Label to indicate an issue is accepting pull requests.
|
|
105
90
|
- `labelTypeBug` _(`string`)_: Label to indicate an issue is for a bug.
|
|
106
91
|
- `labelTypeDocs` _(`string`)_: Label to indicate an issue is for documentation.
|
|
92
|
+
- `labelTypeIdeas` _(`string`)_: Label to indicate an issue is for a feature.
|
|
107
93
|
- `labelTypeTool` _(`string`)_: Label to indicate an issue is for tooling.
|
|
108
94
|
|
|
109
95
|
```ts
|
|
@@ -111,10 +97,11 @@ import { getAllContributorsForRepository } from "all-contributors-for-repository
|
|
|
111
97
|
|
|
112
98
|
getAllContributorsForRepository({
|
|
113
99
|
auth: "abc123",
|
|
114
|
-
ignoredLogins: [
|
|
100
|
+
ignoredLogins: [/-it$/i],
|
|
115
101
|
labelAcceptingPrs: "help wanted",
|
|
116
102
|
labelTypeBug: "bug",
|
|
117
103
|
labelTypeDocs: "docs",
|
|
104
|
+
labelTypeIdeas: "feature",
|
|
118
105
|
labelTypeTool: "tool",
|
|
119
106
|
});
|
|
120
107
|
```
|
|
@@ -122,27 +109,26 @@ getAllContributorsForRepository({
|
|
|
122
109
|
## Development
|
|
123
110
|
|
|
124
111
|
See [`.github/CONTRIBUTING.md`](./.github/CONTRIBUTING.md), then [`.github/DEVELOPMENT.md`](./.github/DEVELOPMENT.md).
|
|
125
|
-
Thanks!
|
|
112
|
+
Thanks! 🤝
|
|
126
113
|
|
|
127
114
|
## Contributors
|
|
128
115
|
|
|
129
116
|
<!-- spellchecker: disable -->
|
|
130
117
|
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
131
118
|
<!-- prettier-ignore-start -->
|
|
132
|
-
<!-- markdownlint-disable -->
|
|
133
119
|
<table>
|
|
134
120
|
<tbody>
|
|
135
121
|
<tr>
|
|
136
|
-
<td align="center"
|
|
137
|
-
<td align="center"
|
|
122
|
+
<td align="center"><a href="https://www.fdlpm.com"><img src="https://avatars.githubusercontent.com/u/9667945?v=4?s=100" width="100px;" alt="Fabian De La Peña Montero"/><br /><sub><b>Fabian De La Peña Montero</b></sub></a><br /><a href="https://github.com/JoshuaKGoldberg/all-contributors-for-repository/commits?author=fdlpm" title="Documentation">📖</a></td>
|
|
123
|
+
<td align="center"><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="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="#content-JoshuaKGoldberg" title="Content">🖋</a> <a href="https://github.com/JoshuaKGoldberg/all-contributors-for-repository/commits?author=JoshuaKGoldberg" title="Documentation">📖</a> <a href="#ideas-JoshuaKGoldberg" title="Ideas, Planning, & Feedback">🤔</a> <a href="#infra-JoshuaKGoldberg" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#maintenance-JoshuaKGoldberg" title="Maintenance">🚧</a> <a href="#projectManagement-JoshuaKGoldberg" title="Project Management">📆</a> <a href="https://github.com/JoshuaKGoldberg/all-contributors-for-repository/commits?author=JoshuaKGoldberg" title="Tests">⚠️</a> <a href="#tool-JoshuaKGoldberg" title="Tools">🔧</a></td>
|
|
124
|
+
<td align="center"><a href="https://navinmoorthy.me/"><img src="https://avatars.githubusercontent.com/u/39694575?v=4?s=100" width="100px;" alt="Navin Moorthy"/><br /><sub><b>Navin Moorthy</b></sub></a><br /><a href="https://github.com/JoshuaKGoldberg/all-contributors-for-repository/issues?q=author%3Anavin-moorthy" title="Bug reports">🐛</a></td>
|
|
138
125
|
</tr>
|
|
139
126
|
</tbody>
|
|
140
127
|
</table>
|
|
141
128
|
|
|
142
|
-
<!-- markdownlint-restore -->
|
|
143
129
|
<!-- prettier-ignore-end -->
|
|
144
130
|
|
|
145
131
|
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
146
132
|
<!-- spellchecker: enable -->
|
|
147
133
|
|
|
148
|
-
>
|
|
134
|
+
> 💝 This package was templated with [`create-typescript-app`](https://github.com/JoshuaKGoldberg/create-typescript-app) using the [Bingo framework](https://create.bingo).
|
package/lib/Contributor.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
//#region src/Contributor.d.ts
|
|
1
2
|
declare class Contributor {
|
|
2
|
-
|
|
3
|
-
|
|
3
|
+
readonly contributions: Record<string, Set<number>>;
|
|
4
|
+
add(number: number, type: string): void;
|
|
4
5
|
}
|
|
5
|
-
|
|
6
|
+
//#endregion
|
|
6
7
|
export { Contributor };
|
|
8
|
+
//# sourceMappingURL=Contributor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Contributor.d.ts","names":[],"sources":["../src/Contributor.ts"],"sourcesContent":[],"mappings":";cAAa,WAAA;EAAA,SAAA,aAAW,EACC,MAAe,CAAf,MAAA,EAAe,GAAT,CAAA,MAAA,CAAA,CAAA"}
|
package/lib/Contributor.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
export {
|
|
8
|
-
Contributor
|
|
1
|
+
//#region src/Contributor.ts
|
|
2
|
+
var Contributor = class {
|
|
3
|
+
contributions = {};
|
|
4
|
+
add(number, type) {
|
|
5
|
+
(this.contributions[type] ??= /* @__PURE__ */ new Set()).add(number);
|
|
6
|
+
}
|
|
9
7
|
};
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { Contributor };
|
|
10
11
|
//# sourceMappingURL=Contributor.js.map
|
package/lib/Contributor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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(this.contributions[type] ??= new Set()).add(number);\n\t}\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Contributor.js","names":[],"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(this.contributions[type] ??= new Set()).add(number);\n\t}\n}\n"],"mappings":";AAAA,IAAa,cAAb,MAAyB;CACxB,AAAS,gBAA6C,EAAE;CAExD,IAAI,QAAgB,MAAc;AACjC,GAAC,KAAK,cAAc,0BAAU,IAAI,KAAK,EAAE,IAAI,OAAO"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/ContributorsCollection.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* For a set of logins, the contributions under those users.
|
|
3
4
|
*/
|
|
@@ -7,10 +8,11 @@ type ContributorsContributions = Record<string, ContributorContributions>;
|
|
|
7
8
|
*/
|
|
8
9
|
type ContributorContributions = Record<string, number[]>;
|
|
9
10
|
declare class ContributorsCollection {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
#private;
|
|
12
|
+
constructor(ignoredLogins?: RegExp[]);
|
|
13
|
+
add(login: string | undefined, number: number, type: string): void;
|
|
14
|
+
collect(): ContributorsContributions;
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
-
export {
|
|
16
|
+
//#endregion
|
|
17
|
+
export { ContributorContributions, ContributorsCollection, ContributorsContributions };
|
|
18
|
+
//# sourceMappingURL=ContributorsCollection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContributorsCollection.d.ts","names":[],"sources":["../src/ContributorsCollection.ts"],"sourcesContent":[],"mappings":";;AAKA;AAQA;AAEa,KAVD,yBAAA,GAA4B,MAcX,CAAA,MAoBjB,EAhCX,wBAgCoC,CAAA;;;;KA1BzB,wBAAA,GAA2B;cAE1B,sBAAA;;8BAIgB;;aAoBjB"}
|
|
@@ -1,37 +1,23 @@
|
|
|
1
1
|
import { Contributor } from "./Contributor.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
([login, contributor]) => [
|
|
20
|
-
login,
|
|
21
|
-
Object.fromEntries(
|
|
22
|
-
Object.entries(contributor.contributions).map(
|
|
23
|
-
([type, numbers]) => [
|
|
24
|
-
type,
|
|
25
|
-
Array.from(numbers).sort((a, b) => a - b)
|
|
26
|
-
]
|
|
27
|
-
)
|
|
28
|
-
)
|
|
29
|
-
]
|
|
30
|
-
).sort(([a], [b]) => a.localeCompare(b))
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
export {
|
|
35
|
-
ContributorsCollection
|
|
2
|
+
|
|
3
|
+
//#region src/ContributorsCollection.ts
|
|
4
|
+
var ContributorsCollection = class {
|
|
5
|
+
#contributors = {};
|
|
6
|
+
#ignoredLogins;
|
|
7
|
+
constructor(ignoredLogins) {
|
|
8
|
+
this.#ignoredLogins = ignoredLogins ?? [];
|
|
9
|
+
}
|
|
10
|
+
add(login, number, type) {
|
|
11
|
+
if (!login) return;
|
|
12
|
+
const loginNormalized = login.toLowerCase();
|
|
13
|
+
if (this.#ignoredLogins.some((pattern) => pattern.test(login))) return;
|
|
14
|
+
(this.#contributors[loginNormalized] ??= new Contributor()).add(number, type);
|
|
15
|
+
}
|
|
16
|
+
collect() {
|
|
17
|
+
return Object.fromEntries(Object.entries(this.#contributors).map(([login, contributor]) => [login, Object.fromEntries(Object.entries(contributor.contributions).map(([type, numbers]) => [type, Array.from(numbers).sort((a, b) => a - b)]))]).sort(([a], [b]) => a.localeCompare(b)));
|
|
18
|
+
}
|
|
36
19
|
};
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { ContributorsCollection };
|
|
37
23
|
//# sourceMappingURL=ContributorsCollection.js.map
|
|
@@ -1 +1 @@
|
|
|
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:
|
|
1
|
+
{"version":3,"file":"ContributorsCollection.js","names":["#ignoredLogins","#contributors"],"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: RegExp[];\n\n\tconstructor(ignoredLogins?: RegExp[]) {\n\t\tthis.#ignoredLogins = ignoredLogins ?? [];\n\t}\n\n\tadd(login: string | undefined, number: number, type: string) {\n\t\tif (!login) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst loginNormalized = login.toLowerCase();\n\t\tif (this.#ignoredLogins.some((pattern) => pattern.test(login))) {\n\t\t\treturn;\n\t\t}\n\n\t\t(this.#contributors[loginNormalized] ??= new Contributor()).add(\n\t\t\tnumber,\n\t\t\ttype,\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":";;;AAeA,IAAa,yBAAb,MAAoC;CACnC,gBAA6C,EAAE;CAC/C;CAEA,YAAY,eAA0B;AACrC,QAAKA,gBAAiB,iBAAiB,EAAE;;CAG1C,IAAI,OAA2B,QAAgB,MAAc;AAC5D,MAAI,CAAC,MACJ;EAGD,MAAM,kBAAkB,MAAM,aAAa;AAC3C,MAAI,MAAKA,cAAe,MAAM,YAAY,QAAQ,KAAK,MAAM,CAAC,CAC7D;AAGD,GAAC,MAAKC,aAAc,qBAAqB,IAAI,aAAa,EAAE,IAC3D,QACA,KACA;;CAGF,UAAqC;AACpC,SAAO,OAAO,YACb,OAAO,QAAQ,MAAKA,aAAc,CAChC,KACC,CAAC,OAAO,iBACR,CACC,OACA,OAAO,YACN,OAAO,QAAQ,YAAY,cAAc,CAAC,KACxC,CAAC,MAAM,aAAa,CACpB,MACA,MAAM,KAAK,QAAQ,CAAC,MAAM,GAAG,MAAM,IAAI,EAAE,CACzC,CACD,CACD,CACD,CACF,CACA,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,CAAC,CACxC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ContributorsCollection } from
|
|
2
|
-
import { AllContributorsForRepositoryOptions } from
|
|
3
|
-
import { AcceptedIssue } from
|
|
4
|
-
import 'octokit';
|
|
5
|
-
import '../api.js';
|
|
1
|
+
import { ContributorsCollection } from "../../ContributorsCollection.js";
|
|
2
|
+
import { AllContributorsForRepositoryOptions } from "../../options.js";
|
|
3
|
+
import { AcceptedIssue } from "../collecting/collectAcceptedIssues.js";
|
|
6
4
|
|
|
5
|
+
//#region src/collect/adding/addAcceptedIssues.d.ts
|
|
7
6
|
declare function addAcceptedIssues(acceptedIssues: AcceptedIssue[], contributors: Pick<ContributorsCollection, "add">, options: Pick<AllContributorsForRepositoryOptions, `labelType${string}` & keyof AllContributorsForRepositoryOptions>): void;
|
|
8
|
-
|
|
7
|
+
//#endregion
|
|
9
8
|
export { addAcceptedIssues };
|
|
9
|
+
//# sourceMappingURL=addAcceptedIssues.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addAcceptedIssues.d.ts","names":[],"sources":["../../../src/collect/adding/addAcceptedIssues.ts"],"sourcesContent":[],"mappings":";;;;;iBAMgB,iBAAA,iBACC,+BACF,KAAK,yCACV,KACR,kEAC6B"}
|
|
@@ -1,38 +1,24 @@
|
|
|
1
1
|
import { descriptionToCoAuthors } from "description-to-co-authors";
|
|
2
|
+
|
|
3
|
+
//#region src/collect/adding/addAcceptedIssues.ts
|
|
2
4
|
function addAcceptedIssues(acceptedIssues, contributors, options) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
continue;
|
|
19
|
-
}
|
|
20
|
-
const logins = [];
|
|
21
|
-
if (acceptedIssue.user) {
|
|
22
|
-
logins.push(acceptedIssue.user.login);
|
|
23
|
-
}
|
|
24
|
-
if (acceptedIssue.body) {
|
|
25
|
-
for (const coAuthor of descriptionToCoAuthors(acceptedIssue.body)) {
|
|
26
|
-
logins.push(coAuthor.username);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
for (const login of logins) {
|
|
30
|
-
contributors.add(login, acceptedIssue.number, contribution);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
5
|
+
for (const acceptedIssue of acceptedIssues) {
|
|
6
|
+
const labels = acceptedIssue.labels.map((label) => typeof label === "string" ? label : label.name);
|
|
7
|
+
for (const [labelType, contribution] of [
|
|
8
|
+
[options.labelTypeBug, "bug"],
|
|
9
|
+
[options.labelTypeDocs, "docs"],
|
|
10
|
+
[options.labelTypeIdeas, "ideas"],
|
|
11
|
+
[options.labelTypeTool, "tool"]
|
|
12
|
+
]) {
|
|
13
|
+
if (!labels.some((label) => label === labelType)) continue;
|
|
14
|
+
const logins = [];
|
|
15
|
+
if (acceptedIssue.user) logins.push(acceptedIssue.user.login);
|
|
16
|
+
if (acceptedIssue.body) for (const coAuthor of descriptionToCoAuthors(acceptedIssue.body)) logins.push(coAuthor.username);
|
|
17
|
+
for (const login of logins) contributors.add(login, acceptedIssue.number, contribution);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
34
20
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
};
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { addAcceptedIssues };
|
|
38
24
|
//# sourceMappingURL=addAcceptedIssues.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collect/adding/addAcceptedIssues.ts"],"sourcesContent":["import { descriptionToCoAuthors } from \"description-to-co-authors\";\n\nimport { 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// 💡 `ideas`: anybody who filed an issue labeled as accepting PRs and a feature\n\t\t\t[options.labelTypeIdeas, \"ideas\"],\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\tcontinue;\n\t\t\t}\n\n\t\t\tconst logins = [];\n\n\t\t\tif (acceptedIssue.user) {\n\t\t\t\tlogins.push(acceptedIssue.user.login);\n\t\t\t}\n\n\t\t\tif (acceptedIssue.body) {\n\t\t\t\tfor (const coAuthor of descriptionToCoAuthors(acceptedIssue.body)) {\n\t\t\t\t\tlogins.push(coAuthor.username);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (const login of logins) {\n\t\t\t\tcontributors.add(login, acceptedIssue.number, contribution);\n\t\t\t}\n\t\t}\n\t}\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"addAcceptedIssues.js","names":[],"sources":["../../../src/collect/adding/addAcceptedIssues.ts"],"sourcesContent":["import { descriptionToCoAuthors } from \"description-to-co-authors\";\n\nimport { 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// 💡 `ideas`: anybody who filed an issue labeled as accepting PRs and a feature\n\t\t\t[options.labelTypeIdeas, \"ideas\"],\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\tcontinue;\n\t\t\t}\n\n\t\t\tconst logins = [];\n\n\t\t\tif (acceptedIssue.user) {\n\t\t\t\tlogins.push(acceptedIssue.user.login);\n\t\t\t}\n\n\t\t\tif (acceptedIssue.body) {\n\t\t\t\tfor (const coAuthor of descriptionToCoAuthors(acceptedIssue.body)) {\n\t\t\t\t\tlogins.push(coAuthor.username);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (const login of logins) {\n\t\t\t\tcontributors.add(login, acceptedIssue.number, contribution);\n\t\t\t}\n\t\t}\n\t}\n}\n"],"mappings":";;;AAMA,SAAgB,kBACf,gBACA,cACA,SAIC;AACD,MAAK,MAAM,iBAAiB,gBAAgB;EAC3C,MAAM,SAAS,cAAc,OAAO,KAAK,UACxC,OAAO,UAAU,WAAW,QAAQ,MAAM,KAC1C;AAED,OAAK,MAAM,CAAC,WAAW,iBAAiB;GAEvC,CAAC,QAAQ,cAAc,MAAM;GAE7B,CAAC,QAAQ,eAAe,OAAO;GAE/B,CAAC,QAAQ,gBAAgB,QAAQ;GAEjC,CAAC,QAAQ,eAAe,OAAO;GAC/B,EAAW;AACX,OAAI,CAAC,OAAO,MAAM,UAAU,UAAU,UAAU,CAC/C;GAGD,MAAM,SAAS,EAAE;AAEjB,OAAI,cAAc,KACjB,QAAO,KAAK,cAAc,KAAK,MAAM;AAGtC,OAAI,cAAc,KACjB,MAAK,MAAM,YAAY,uBAAuB,cAAc,KAAK,CAChE,QAAO,KAAK,SAAS,SAAS;AAIhC,QAAK,MAAM,SAAS,OACnB,cAAa,IAAI,OAAO,cAAc,QAAQ,aAAa"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import '../api.js';
|
|
1
|
+
import { ContributorsCollection } from "../../ContributorsCollection.js";
|
|
2
|
+
import { MergedPull } from "../collecting/collectMergedPulls.js";
|
|
3
|
+
import { Octokit } from "octokit";
|
|
5
4
|
|
|
5
|
+
//#region src/collect/adding/addMergedPulls.d.ts
|
|
6
6
|
declare function addMergedPulls(mergedPulls: MergedPull[], contributors: Pick<ContributorsCollection, "add">, octokit: Octokit): Promise<void>;
|
|
7
|
-
|
|
7
|
+
//#endregion
|
|
8
8
|
export { addMergedPulls };
|
|
9
|
+
//# sourceMappingURL=addMergedPulls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addMergedPulls.d.ts","names":[],"sources":["../../../src/collect/adding/addMergedPulls.ts"],"sourcesContent":[],"mappings":";;;;;iBAQsB,cAAA,cACR,4BACC,KAAK,yCACV,UAAO"}
|
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
import { createCachingCoAuthorToUsername } from "co-author-to-username";
|
|
2
1
|
import { parseMergedPullAuthors } from "../parsing/parseMergedPullAuthors.js";
|
|
3
2
|
import { parseMergedPullType } from "../parsing/parseMergedPullType.js";
|
|
3
|
+
import { createCachingCoAuthorToUsername } from "co-author-to-username";
|
|
4
|
+
|
|
5
|
+
//#region src/collect/adding/addMergedPulls.ts
|
|
4
6
|
async function addMergedPulls(mergedPulls, contributors, octokit) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
cachingCoAuthorToUsername
|
|
12
|
-
);
|
|
13
|
-
const type = parseMergedPullType(mergedPull.title);
|
|
14
|
-
for (const author of authors) {
|
|
15
|
-
contributors.add(author, mergedPull.number, type);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
7
|
+
const cachingCoAuthorToUsername = createCachingCoAuthorToUsername({ fetcher: octokit });
|
|
8
|
+
for (const mergedPull of mergedPulls) {
|
|
9
|
+
const authors = await parseMergedPullAuthors(mergedPull, cachingCoAuthorToUsername);
|
|
10
|
+
const type = parseMergedPullType(mergedPull.title);
|
|
11
|
+
for (const author of authors) contributors.add(author, mergedPull.number, type);
|
|
12
|
+
}
|
|
18
13
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { addMergedPulls };
|
|
22
17
|
//# sourceMappingURL=addMergedPulls.js.map
|
|
@@ -1 +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":"
|
|
1
|
+
{"version":3,"file":"addMergedPulls.js","names":[],"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":";;;;;AAQA,eAAsB,eACrB,aACA,cACA,SACC;CACD,MAAM,4BAA4B,gCAAgC,EACjE,SAAS,SACT,CAAC;AAEF,MAAK,MAAM,cAAc,aAAa;EACrC,MAAM,UAAU,MAAM,uBACrB,YACA,0BACA;EACD,MAAM,OAAO,oBAAoB,WAAW,MAAM;AAElD,OAAK,MAAM,UAAU,QACpB,cAAa,IAAI,QAAQ,WAAW,QAAQ,KAAK"}
|
package/lib/collect/api.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { Octokit } from
|
|
1
|
+
import { Octokit } from "octokit";
|
|
2
2
|
|
|
3
|
+
//#region src/collect/api.d.ts
|
|
3
4
|
interface RequestDefaults {
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
owner: string;
|
|
6
|
+
repo: string;
|
|
6
7
|
}
|
|
7
|
-
declare function createOctokit(auth: string | undefined): Promise<Octokit>;
|
|
8
8
|
interface RequestOptionsWithPage extends RequestDefaults {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
page: number;
|
|
10
|
+
per_page: number;
|
|
11
11
|
}
|
|
12
|
+
declare function createOctokit(auth: string | undefined): Promise<Octokit>;
|
|
12
13
|
declare function paginate<T>(defaults: RequestDefaults, request: (requestOptions: RequestOptionsWithPage) => Promise<T[]>): Promise<T[]>;
|
|
13
|
-
|
|
14
|
-
export {
|
|
14
|
+
//#endregion
|
|
15
|
+
export { RequestDefaults, RequestOptionsWithPage, createOctokit, paginate };
|
|
16
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","names":[],"sources":["../../src/collect/api.ts"],"sourcesContent":[],"mappings":";;;UAKiB,eAAA;;EAAA,IAAA,EAAA,MAAA;AAKjB;AAKsB,UALL,sBAAA,SAA+B,eAOtC,CAAA;EAUY,IAAA,EAAA,MAAQ;EACnB,QAAA,EAAA,MAAA;;AACmD,iBAdxC,aAAA,CAcwC,IAAA,EAAA,MAAA,GAAA,SAAA,CAAA,EAZ3D,OAY2D,CAZnD,OAYmD,CAAA;AAAR,iBAFhC,QAEgC,CAAA,CAAA,CAAA,CAAA,QAAA,EAD3C,eAC2C,EAAA,OAAA,EAAA,CAAA,cAAA,EAA3B,sBAA2B,EAAA,GAAA,OAAA,CAAQ,CAAR,EAAA,CAAA,CAAA,EAAY,OAAZ,CAAY,CAAZ,EAAA,CAAA"}
|
package/lib/collect/api.js
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
import { octokitFromAuthSafe } from "octokit-from-auth";
|
|
2
|
+
|
|
3
|
+
//#region src/collect/api.ts
|
|
2
4
|
const perPage = 100;
|
|
3
5
|
async function createOctokit(auth) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
per_page: perPage
|
|
10
|
-
});
|
|
6
|
+
return await octokitFromAuthSafe({
|
|
7
|
+
auth,
|
|
8
|
+
headers: { "X-GitHub-Api-Version": "2022-11-28" },
|
|
9
|
+
per_page: perPage
|
|
10
|
+
});
|
|
11
11
|
}
|
|
12
12
|
async function paginate(defaults, request) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
const items = [];
|
|
14
|
+
for (let i = 0; i < 10; i += 1) {
|
|
15
|
+
const response = await request({
|
|
16
|
+
page: i,
|
|
17
|
+
per_page: perPage,
|
|
18
|
+
...defaults
|
|
19
|
+
});
|
|
20
|
+
items.push(...response);
|
|
21
|
+
if (response.length < 100) break;
|
|
22
|
+
}
|
|
23
|
+
return items;
|
|
22
24
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
export { createOctokit, paginate };
|
|
27
28
|
//# sourceMappingURL=api.js.map
|
package/lib/collect/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/collect/api.ts"],"sourcesContent":["import { Octokit } from \"octokit\";\nimport { octokitFromAuthSafe } from \"octokit-from-auth\";\n\nconst perPage = 100;\n\nexport interface RequestDefaults {\n\towner: string;\n\trepo: string;\n}\n\nexport async function createOctokit(\n\tauth: string | undefined,\n): Promise<Octokit> {\n\treturn await octokitFromAuthSafe({\n\t\tauth,\n\t\theaders: {\n\t\t\t\"X-GitHub-Api-Version\": \"2022-11-28\",\n\t\t},\n\t\tper_page: perPage,\n\t});\n}\n\nexport
|
|
1
|
+
{"version":3,"file":"api.js","names":["items: T[]"],"sources":["../../src/collect/api.ts"],"sourcesContent":["import { Octokit } from \"octokit\";\nimport { octokitFromAuthSafe } from \"octokit-from-auth\";\n\nconst perPage = 100;\n\nexport interface RequestDefaults {\n\towner: string;\n\trepo: string;\n}\n\nexport interface RequestOptionsWithPage extends RequestDefaults {\n\tpage: number;\n\tper_page: number;\n}\n\nexport async function createOctokit(\n\tauth: string | undefined,\n): Promise<Octokit> {\n\treturn await octokitFromAuthSafe({\n\t\tauth,\n\t\theaders: {\n\t\t\t\"X-GitHub-Api-Version\": \"2022-11-28\",\n\t\t},\n\t\tper_page: perPage,\n\t});\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":";;;AAGA,MAAM,UAAU;AAYhB,eAAsB,cACrB,MACmB;AACnB,QAAO,MAAM,oBAAoB;EAChC;EACA,SAAS,EACR,wBAAwB,cACxB;EACD,UAAU;EACV,CAAC;;AAGH,eAAsB,SACrB,UACA,SACC;CACD,MAAMA,QAAa,EAAE;AAErB,MAAK,IAAI,IAAI,GAAG,IAAI,IAAI,KAAK,GAAG;EAC/B,MAAM,WAAW,MAAM,QAAQ;GAAE,MAAM;GAAG,UAAU;GAAS,GAAG;GAAU,CAAC;AAE3E,QAAM,KAAK,GAAG,SAAS;AAEvB,MAAI,SAAS,SAAS,IACrB;;AAIF,QAAO"}
|