all-contributors-for-repository 0.2.3 → 0.3.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/lib/collect/adding/addAcceptedIssues.js +15 -6
- package/lib/collect/adding/addAcceptedIssues.js.map +1 -1
- package/lib/collect/parsing/parseMergedPullAuthors.js +2 -2
- package/lib/collect/parsing/parseMergedPullAuthors.js.map +1 -1
- package/lib/collect/parsing/parseMergedPullType.js +3 -2
- package/lib/collect/parsing/parseMergedPullType.js.map +1 -1
- package/package.json +10 -10
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { descriptionToCoAuthors } from "description-to-co-authors";
|
|
1
2
|
function addAcceptedIssues(acceptedIssues, contributors, options) {
|
|
2
3
|
for (const acceptedIssue of acceptedIssues) {
|
|
3
4
|
const labels = acceptedIssue.labels.map(
|
|
@@ -13,12 +14,20 @@ function addAcceptedIssues(acceptedIssues, contributors, options) {
|
|
|
13
14
|
// - 🔧 `tool`: authors of merged PRs that address issues labeled as tooling
|
|
14
15
|
[options.labelTypeTool, "tool"]
|
|
15
16
|
]) {
|
|
16
|
-
if (labels.some((label) => label === labelType)) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
);
|
|
17
|
+
if (!labels.some((label) => label === labelType)) {
|
|
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);
|
|
22
31
|
}
|
|
23
32
|
}
|
|
24
33
|
}
|
|
@@ -1 +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// 💡 `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\
|
|
1
|
+
{"version":3,"sources":["../../../src/collect/adding/addAcceptedIssues.ts"],"sourcesContent":["import { descriptionToCoAuthors } from \"description-to-co-authors\";\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":"AAAA,SAAS,8BAA8B;AAKhC,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,gBAAgB,OAAO;AAAA;AAAA,MAEhC,CAAC,QAAQ,eAAe,MAAM;AAAA,IAC/B,GAAY;AACX,UAAI,CAAC,OAAO,KAAK,CAAC,UAAU,UAAU,SAAS,GAAG;AACjD;AAAA,MACD;AAEA,YAAM,SAAS,CAAC;AAEhB,UAAI,cAAc,MAAM;AACvB,eAAO,KAAK,cAAc,KAAK,KAAK;AAAA,MACrC;AAEA,UAAI,cAAc,MAAM;AACvB,mBAAW,YAAY,uBAAuB,cAAc,IAAI,GAAG;AAClE,iBAAO,KAAK,SAAS,QAAQ;AAAA,QAC9B;AAAA,MACD;AAEA,iBAAW,SAAS,QAAQ;AAC3B,qBAAa,IAAI,OAAO,cAAc,QAAQ,YAAY;AAAA,MAC3D;AAAA,IACD;AAAA,EACD;AACD;","names":[]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { descriptionToCoAuthors } from "description-to-co-authors";
|
|
2
2
|
async function parseMergedPullAuthors(mergedPull, cachingCoAuthorToUsername) {
|
|
3
3
|
const authors = [];
|
|
4
4
|
authors.push(mergedPull.user?.login);
|
|
5
5
|
if (mergedPull.body) {
|
|
6
|
-
const coAuthors =
|
|
6
|
+
const coAuthors = descriptionToCoAuthors(mergedPull.body);
|
|
7
7
|
for (const coAuthor of coAuthors) {
|
|
8
8
|
authors.push(await cachingCoAuthorToUsername(coAuthor));
|
|
9
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collect/parsing/parseMergedPullAuthors.ts"],"sourcesContent":["import { CachingCoAuthorToUsername } from \"co-author-to-username\";\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/collect/parsing/parseMergedPullAuthors.ts"],"sourcesContent":["import { CachingCoAuthorToUsername } from \"co-author-to-username\";\nimport { descriptionToCoAuthors } from \"description-to-co-authors\";\n\ninterface MergedPullForAuthors {\n\tbody?: string;\n\tuser?: { login?: string } | null;\n}\n\nexport async function parseMergedPullAuthors(\n\tmergedPull: MergedPullForAuthors,\n\tcachingCoAuthorToUsername: CachingCoAuthorToUsername,\n) {\n\tconst authors: (string | undefined)[] = [];\n\n\tauthors.push(mergedPull.user?.login);\n\n\tif (mergedPull.body) {\n\t\tconst coAuthors = descriptionToCoAuthors(mergedPull.body);\n\n\t\tfor (const coAuthor of coAuthors) {\n\t\t\tauthors.push(await cachingCoAuthorToUsername(coAuthor));\n\t\t}\n\t}\n\n\treturn Array.from(\n\t\tnew Set(\n\t\t\tauthors.filter(\n\t\t\t\t(author: string | undefined): author is string => !!author,\n\t\t\t),\n\t\t),\n\t);\n}\n"],"mappings":"AACA,SAAS,8BAA8B;AAOvC,eAAsB,uBACrB,YACA,2BACC;AACD,QAAM,UAAkC,CAAC;AAEzC,UAAQ,KAAK,WAAW,MAAM,KAAK;AAEnC,MAAI,WAAW,MAAM;AACpB,UAAM,YAAY,uBAAuB,WAAW,IAAI;AAExD,eAAW,YAAY,WAAW;AACjC,cAAQ,KAAK,MAAM,0BAA0B,QAAQ,CAAC;AAAA,IACvD;AAAA,EACD;AAEA,SAAO,MAAM;AAAA,IACZ,IAAI;AAAA,MACH,QAAQ;AAAA,QACP,CAAC,WAAiD,CAAC,CAAC;AAAA,MACrD;AAAA,IACD;AAAA,EACD;AACD;","names":[]}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { CommitParser } from "conventional-commits-parser";
|
|
2
2
|
const allContributorsTypes = /* @__PURE__ */ new Map([
|
|
3
3
|
["build", "infra"],
|
|
4
4
|
["ci", "infra"],
|
|
5
5
|
["docs", "doc"],
|
|
6
6
|
["test", "test"]
|
|
7
7
|
]);
|
|
8
|
+
const parser = new CommitParser();
|
|
8
9
|
function parseMergedPullType(title) {
|
|
9
|
-
const { type } =
|
|
10
|
+
const { type } = parser.parse(title);
|
|
10
11
|
return (type && allContributorsTypes.get(type)) ?? "code";
|
|
11
12
|
}
|
|
12
13
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collect/parsing/parseMergedPullType.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../../../src/collect/parsing/parseMergedPullType.ts"],"sourcesContent":["import { CommitParser } from \"conventional-commits-parser\";\n\nconst allContributorsTypes = new Map([\n\t[\"build\", \"infra\"],\n\t[\"ci\", \"infra\"],\n\t[\"docs\", \"doc\"],\n\t[\"test\", \"test\"],\n]);\n\nconst parser = new CommitParser();\n\nexport function parseMergedPullType(title: string) {\n\tconst { type } = parser.parse(title);\n\n\treturn (type && allContributorsTypes.get(type)) ?? \"code\";\n}\n"],"mappings":"AAAA,SAAS,oBAAoB;AAE7B,MAAM,uBAAuB,oBAAI,IAAI;AAAA,EACpC,CAAC,SAAS,OAAO;AAAA,EACjB,CAAC,MAAM,OAAO;AAAA,EACd,CAAC,QAAQ,KAAK;AAAA,EACd,CAAC,QAAQ,MAAM;AAChB,CAAC;AAED,MAAM,SAAS,IAAI,aAAa;AAEzB,SAAS,oBAAoB,OAAe;AAClD,QAAM,EAAE,KAAK,IAAI,OAAO,MAAM,KAAK;AAEnC,UAAQ,QAAQ,qBAAqB,IAAI,IAAI,MAAM;AACpD;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "all-contributors-for-repository",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Generates an allcontributors list for an existing repository. 🤝",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -37,31 +37,31 @@
|
|
|
37
37
|
"*": "prettier --ignore-unknown --write"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"co-author-to-username": "^0.1.
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"octokit": "^
|
|
40
|
+
"co-author-to-username": "^0.1.1",
|
|
41
|
+
"conventional-commits-parser": "^6.0.0",
|
|
42
|
+
"description-to-co-authors": "^0.3.0",
|
|
43
|
+
"octokit": "^4.0.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@release-it/conventional-changelog": "^8.0.1",
|
|
47
47
|
"@types/conventional-commits-parser": "^5.0.0",
|
|
48
|
-
"@types/eslint": "^
|
|
49
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
48
|
+
"@types/eslint": "^9.0.0",
|
|
49
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
50
50
|
"@typescript-eslint/parser": "^7.0.0",
|
|
51
51
|
"@vitest/coverage-v8": "^1.1.3",
|
|
52
52
|
"console-fail-test": "^0.4.0",
|
|
53
53
|
"cspell": "^8.3.2",
|
|
54
|
-
"eslint": "^
|
|
54
|
+
"eslint": "^9.0.0",
|
|
55
55
|
"eslint-plugin-deprecation": "^2.0.0",
|
|
56
56
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
57
57
|
"eslint-plugin-jsdoc": "^48.0.2",
|
|
58
58
|
"eslint-plugin-jsonc": "^2.11.2",
|
|
59
|
-
"eslint-plugin-markdown": "^
|
|
59
|
+
"eslint-plugin-markdown": "^5.0.0",
|
|
60
60
|
"eslint-plugin-n": "^17.0.0",
|
|
61
61
|
"eslint-plugin-no-only-tests": "^3.1.0",
|
|
62
62
|
"eslint-plugin-perfectionist": "^2.5.0",
|
|
63
63
|
"eslint-plugin-regexp": "^2.2.0",
|
|
64
|
-
"eslint-plugin-vitest": "^0.
|
|
64
|
+
"eslint-plugin-vitest": "^0.5.0",
|
|
65
65
|
"eslint-plugin-yml": "^1.11.0",
|
|
66
66
|
"husky": "^9.0.0",
|
|
67
67
|
"jsonc-eslint-parser": "^2.4.0",
|