all-contributors-for-repository 0.0.1
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/LICENSE.md +20 -0
- package/README.md +99 -0
- package/lib/ContributorsCollection.d.ts +9 -0
- package/lib/ContributorsCollection.d.ts.map +1 -0
- package/lib/ContributorsCollection.js +31 -0
- package/lib/ContributorsCollection.js.map +1 -0
- package/lib/ContributorsCollection.test.d.ts +2 -0
- package/lib/ContributorsCollection.test.d.ts.map +1 -0
- package/lib/ContributorsCollection.test.js +38 -0
- package/lib/ContributorsCollection.test.js.map +1 -0
- package/lib/collect/api.d.ts +5 -0
- package/lib/collect/api.d.ts.map +1 -0
- package/lib/collect/api.js +21 -0
- package/lib/collect/api.js.map +1 -0
- package/lib/collect/api.test.d.ts +2 -0
- package/lib/collect/api.test.d.ts.map +1 -0
- package/lib/collect/api.test.js +23 -0
- package/lib/collect/api.test.js.map +1 -0
- package/lib/collect/collectAcceptedIssues.d.ts +510 -0
- package/lib/collect/collectAcceptedIssues.d.ts.map +1 -0
- package/lib/collect/collectAcceptedIssues.js +19 -0
- package/lib/collect/collectAcceptedIssues.js.map +1 -0
- package/lib/collect/collectEvents.d.ts +643 -0
- package/lib/collect/collectEvents.d.ts.map +1 -0
- package/lib/collect/collectEvents.js +13 -0
- package/lib/collect/collectEvents.js.map +1 -0
- package/lib/collect/collectIssueEvents.d.ts +742 -0
- package/lib/collect/collectIssueEvents.d.ts.map +1 -0
- package/lib/collect/collectIssueEvents.js +25 -0
- package/lib/collect/collectIssueEvents.js.map +1 -0
- package/lib/collect/collectMergedPulls.d.ts +496 -0
- package/lib/collect/collectMergedPulls.d.ts.map +1 -0
- package/lib/collect/collectMergedPulls.js +16 -0
- package/lib/collect/collectMergedPulls.js.map +1 -0
- package/lib/collect/index.d.ts +5 -0
- package/lib/collect/index.d.ts.map +1 -0
- package/lib/collect/index.js +58 -0
- package/lib/collect/index.js.map +1 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +7 -0
- package/lib/index.js.map +1 -0
- package/lib/options.d.ts +22 -0
- package/lib/options.d.ts.map +1 -0
- package/lib/options.js +27 -0
- package/lib/options.js.map +1 -0
- package/package.json +81 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
'Software'), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
17
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
18
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
19
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
20
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
<h1 align="center">All Contributors For Repository</h1>
|
|
2
|
+
|
|
3
|
+
<p align="center">Generates an allcontributors list for an existing repository.</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="#contributors" target="_blank">
|
|
7
|
+
<!-- prettier-ignore-start -->
|
|
8
|
+
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
9
|
+
<img alt="All Contributors: 1" src="https://img.shields.io/badge/all_contributors-1-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?token=eVIFY4MhfQ"/>
|
|
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
|
+
</p>
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
```shell
|
|
32
|
+
npm i all-contributors-for-repository
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { createAllContributorsForRepository } from "all-contributors-for-repository";
|
|
37
|
+
|
|
38
|
+
const contributors = await createAllContributorsForRepository();
|
|
39
|
+
/*
|
|
40
|
+
{
|
|
41
|
+
john_reilly: [ 'bug', 'code' ],
|
|
42
|
+
joshuakgoldberg: [ 'maintenance', 'tool' ],
|
|
43
|
+
}
|
|
44
|
+
*/
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
> **Warning**
|
|
48
|
+
> This tool only sees contributions that can be detected from GitHub's API.
|
|
49
|
+
> Don't forget to manually add in other forms of contributions!
|
|
50
|
+
|
|
51
|
+
The types of contributions detected are:
|
|
52
|
+
|
|
53
|
+
- 🐛 `bug`: anybody who filed an issue labeled as accepting PRs and a bug _(see options)_
|
|
54
|
+
- 💻 `computer`: all PR authors and co-authors
|
|
55
|
+
- 📖 `doc`: authors of merged PRs that address issues labeled as accepting PRs and docs _(see options)_
|
|
56
|
+
- 🚧 `maintenance`: adding labels to issues and PRs, and merging PRs
|
|
57
|
+
- 👀 `review`: submitting a review for a PR
|
|
58
|
+
- 🔧 `tool`: authors of merged PRs that address issues labeled as accepting PRs and tooling _(see options)_
|
|
59
|
+
|
|
60
|
+
> 💡 Given that list of contributors, you might want to run `all-contributors add` on each contributor & contribution type.
|
|
61
|
+
>
|
|
62
|
+
> ```ts
|
|
63
|
+
> import { $ } from "execa";
|
|
64
|
+
>
|
|
65
|
+
> for (const [contributor, contributions] of Object.entries(contributors)) {
|
|
66
|
+
> for (const contribution of contributions) {
|
|
67
|
+
> await $`npx all-contributors add ${contributor} ${contribution}`;
|
|
68
|
+
> }
|
|
69
|
+
> }
|
|
70
|
+
> ```
|
|
71
|
+
|
|
72
|
+
## Development
|
|
73
|
+
|
|
74
|
+
See [`.github/CONTRIBUTING.md`](./.github/CONTRIBUTING.md), then [`.github/DEVELOPMENT.md`](./.github/DEVELOPMENT.md).
|
|
75
|
+
Thanks! 💖
|
|
76
|
+
|
|
77
|
+
## Contributors
|
|
78
|
+
|
|
79
|
+
<!-- spellchecker: disable -->
|
|
80
|
+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
81
|
+
<!-- prettier-ignore-start -->
|
|
82
|
+
<!-- markdownlint-disable -->
|
|
83
|
+
<table>
|
|
84
|
+
<tbody>
|
|
85
|
+
<tr>
|
|
86
|
+
<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>
|
|
87
|
+
</tr>
|
|
88
|
+
</tbody>
|
|
89
|
+
</table>
|
|
90
|
+
|
|
91
|
+
<!-- markdownlint-restore -->
|
|
92
|
+
<!-- prettier-ignore-end -->
|
|
93
|
+
|
|
94
|
+
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
95
|
+
<!-- spellchecker: enable -->
|
|
96
|
+
|
|
97
|
+
<!-- You can remove this notice if you don't want it 🙂 no worries! -->
|
|
98
|
+
|
|
99
|
+
> 💙 This package is based on [@JoshuaKGoldberg](https://github.com/JoshuaKGoldberg)'s [template-typescript-node-package](https://github.com/JoshuaKGoldberg/template-typescript-node-package).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContributorsCollection.d.ts","sourceRoot":"","sources":["../src/ContributorsCollection.ts"],"names":[],"mappings":"AAAA,qBAAa,sBAAsB;;gBAItB,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC;IAItC,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM;IAM3C,OAAO;;;CAUP"}
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
export class ContributorsCollection {
|
|
14
|
+
constructor(ignoredLogins) {
|
|
15
|
+
_ContributorsCollection_contributors.set(this, {});
|
|
16
|
+
_ContributorsCollection_ignoredLogins.set(this, void 0);
|
|
17
|
+
__classPrivateFieldSet(this, _ContributorsCollection_ignoredLogins, ignoredLogins, "f");
|
|
18
|
+
}
|
|
19
|
+
add(login, type) {
|
|
20
|
+
if (login && !__classPrivateFieldGet(this, _ContributorsCollection_ignoredLogins, "f").has(login)) {
|
|
21
|
+
(__classPrivateFieldGet(this, _ContributorsCollection_contributors, "f")[login.toLowerCase()] ??= new Set()).add(type);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
collect() {
|
|
25
|
+
return Object.fromEntries(Object.entries(__classPrivateFieldGet(this, _ContributorsCollection_contributors, "f"))
|
|
26
|
+
.map(([contributor, types]) => [contributor, Array.from(types).sort()])
|
|
27
|
+
.sort(([a], [b]) => a.localeCompare(b)));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
_ContributorsCollection_contributors = new WeakMap(), _ContributorsCollection_ignoredLogins = new WeakMap();
|
|
31
|
+
//# sourceMappingURL=ContributorsCollection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContributorsCollection.js","sourceRoot":"","sources":["../src/ContributorsCollection.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,MAAM,OAAO,sBAAsB;IAIlC,YAAY,aAA0B;QAHtC,+CAA6C,EAAE,EAAC;QAChD,wDAA4B;QAG3B,uBAAA,IAAI,yCAAkB,aAAa,MAAA,CAAC;IACrC,CAAC;IAED,GAAG,CAAC,KAAyB,EAAE,IAAY;QAC1C,IAAI,KAAK,IAAI,CAAC,uBAAA,IAAI,6CAAe,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;YAC7C,CAAC,uBAAA,IAAI,4CAAc,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,KAAK,IAAI,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;SAClE;IACF,CAAC;IAED,OAAO;QACN,OAAO,MAAM,CAAC,WAAW,CACxB,MAAM,CAAC,OAAO,CAAC,uBAAA,IAAI,4CAAc,CAAC;aAChC,GAAG,CACH,CAAC,CAAC,WAAW,EAAE,KAAK,CAAC,EAAE,EAAE,CACxB,CAAC,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAU,CACjD;aACA,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CACxC,CAAC;IACH,CAAC;CACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContributorsCollection.test.d.ts","sourceRoot":"","sources":["../src/ContributorsCollection.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { ContributorsCollection } from "./ContributorsCollection.js";
|
|
3
|
+
describe("ContributorsCollection", () => {
|
|
4
|
+
it("produces no entries when none were added", () => {
|
|
5
|
+
const contributors = new ContributorsCollection(new Set());
|
|
6
|
+
const actual = contributors.collect();
|
|
7
|
+
expect(actual).toEqual({});
|
|
8
|
+
});
|
|
9
|
+
it("adds a login when it is not ignored", () => {
|
|
10
|
+
const contributors = new ContributorsCollection(new Set());
|
|
11
|
+
contributors.add("abc", "bug");
|
|
12
|
+
const actual = contributors.collect();
|
|
13
|
+
expect(actual).toEqual({ abc: ["bug"] });
|
|
14
|
+
});
|
|
15
|
+
it("adds sorted contributions for logins when they are added in non-alphabetical order ", () => {
|
|
16
|
+
const contributors = new ContributorsCollection(new Set());
|
|
17
|
+
contributors.add("def", "tool");
|
|
18
|
+
contributors.add("abc", "tool");
|
|
19
|
+
contributors.add("abc", "bug");
|
|
20
|
+
contributors.add("abc", "code");
|
|
21
|
+
contributors.add("def", "code");
|
|
22
|
+
const actual = contributors.collect();
|
|
23
|
+
expect(actual).toEqual({
|
|
24
|
+
abc: ["bug", "code", "tool"],
|
|
25
|
+
def: ["code", "tool"],
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
it("does not add a login contribution when it is ignored ", () => {
|
|
29
|
+
const contributors = new ContributorsCollection(new Set(["ignored"]));
|
|
30
|
+
contributors.add("abc", "bug");
|
|
31
|
+
contributors.add("ignored", "code");
|
|
32
|
+
const actual = contributors.collect();
|
|
33
|
+
expect(actual).toEqual({
|
|
34
|
+
abc: ["bug"],
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=ContributorsCollection.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContributorsCollection.test.js","sourceRoot":"","sources":["../src/ContributorsCollection.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;IACvC,EAAE,CAAC,0CAA0C,EAAE,GAAG,EAAE;QACnD,MAAM,YAAY,GAAG,IAAI,sBAAsB,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;QAE3D,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,EAAE,CAAC;QAEtC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;QAC9C,MAAM,YAAY,GAAG,IAAI,sBAAsB,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;QAE3D,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAE/B,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,EAAE,CAAC;QAEtC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qFAAqF,EAAE,GAAG,EAAE;QAC9F,MAAM,YAAY,GAAG,IAAI,sBAAsB,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;QAE3D,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAChC,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAChC,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC/B,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAChC,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAEhC,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,EAAE,CAAC;QAEtC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACtB,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC;YAC5B,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;SACrB,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uDAAuD,EAAE,GAAG,EAAE;QAChE,MAAM,YAAY,GAAG,IAAI,sBAAsB,CAAC,IAAI,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAEtE,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC/B,YAAY,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAEpC,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,EAAE,CAAC;QAEtC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACtB,GAAG,EAAE,CAAC,KAAK,CAAC;SACZ,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Octokit } from "octokit";
|
|
2
|
+
import { AllContributorsForRepositoryOptions } from "../options.js";
|
|
3
|
+
export declare function createOctokit(options: AllContributorsForRepositoryOptions): Octokit;
|
|
4
|
+
export declare function paginate<T>(request: (page: number, perPage: number) => Promise<T[]>): Promise<T[]>;
|
|
5
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/collect/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,OAAO,EAAE,mCAAmC,EAAE,MAAM,eAAe,CAAC;AAIpE,wBAAgB,aAAa,CAC5B,OAAO,EAAE,mCAAmC,GAC1C,OAAO,CAMT;AAED,wBAAsB,QAAQ,CAAC,CAAC,EAC/B,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,EAAE,CAAC,gBAexD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Octokit } from "octokit";
|
|
2
|
+
const perPage = 100;
|
|
3
|
+
export function createOctokit(options) {
|
|
4
|
+
return new (Octokit.defaults({
|
|
5
|
+
owner: options.owner,
|
|
6
|
+
per_page: perPage,
|
|
7
|
+
repo: options.repo,
|
|
8
|
+
}))({ auth: options.auth });
|
|
9
|
+
}
|
|
10
|
+
export async function paginate(request) {
|
|
11
|
+
const items = [];
|
|
12
|
+
for (let i = 0;; i += 1) {
|
|
13
|
+
const response = await request(i, perPage);
|
|
14
|
+
items.push(...response);
|
|
15
|
+
if (response.length < 100) {
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return items;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/collect/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAIlC,MAAM,OAAO,GAAG,GAAG,CAAC;AAEpB,MAAM,UAAU,aAAa,CAC5B,OAA4C;IAE5C,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;QAC5B,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,QAAQ,EAAE,OAAO;QACjB,IAAI,EAAE,OAAO,CAAC,IAAI;KAClB,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;AAC7B,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC7B,OAAwD;IAExD,MAAM,KAAK,GAAQ,EAAE,CAAC;IAEtB,KAAK,IAAI,CAAC,GAAG,CAAC,GAAI,CAAC,IAAI,CAAC,EAAE;QACzB,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;QAE3C,KAAK,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC;QAExB,IAAI,QAAQ,CAAC,MAAM,GAAG,GAAG,EAAE;YAC1B,MAAM;SACN;KACD;IAED,OAAO,KAAK,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.test.d.ts","sourceRoot":"","sources":["../../src/collect/api.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { paginate } from "./api.js";
|
|
3
|
+
describe("paginate", () => {
|
|
4
|
+
it("returns an empty array when request returns an empty array", async () => {
|
|
5
|
+
const request = () => Promise.resolve([]);
|
|
6
|
+
const actual = await paginate(request);
|
|
7
|
+
expect(actual).toEqual([]);
|
|
8
|
+
});
|
|
9
|
+
it("returns the first request's items when request returns an array the first time", async () => {
|
|
10
|
+
const request = (page) => Promise.resolve(page ? [] : [{ page }]);
|
|
11
|
+
const actual = await paginate(request);
|
|
12
|
+
expect(actual).toEqual([{ page: 0 }]);
|
|
13
|
+
});
|
|
14
|
+
it("returns multiple request items when request returns multiple times time", async () => {
|
|
15
|
+
const request = (page) => Promise.resolve(page < 2 ? Array(100).fill({ page }) : []);
|
|
16
|
+
const actual = await paginate(request);
|
|
17
|
+
expect(actual).toEqual([
|
|
18
|
+
...Array(100).fill({ page: 0 }),
|
|
19
|
+
...Array(100).fill({ page: 1 }),
|
|
20
|
+
]);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=api.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.test.js","sourceRoot":"","sources":["../../src/collect/api.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;IACzB,EAAE,CAAC,4DAA4D,EAAE,KAAK,IAAI,EAAE;QAC3E,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAE1C,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,CAAC;QAEvC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gFAAgF,EAAE,KAAK,IAAI,EAAE;QAC/F,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAE1E,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,CAAC;QAEvC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yEAAyE,EAAE,KAAK,IAAI,EAAE;QACxF,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,EAAE,CAChC,OAAO,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAE5D,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,CAAC;QAEvC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACtB,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;YAC/B,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;SAC/B,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
|