@rmdes/indiekit-endpoint-github 1.2.3 → 1.2.5
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/controllers/changelog.js +54 -8
- package/lib/starred-cache.js +11 -12
- package/package.json +1 -1
|
@@ -17,7 +17,7 @@ function categorizeRepo(name) {
|
|
|
17
17
|
return "other";
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
const
|
|
20
|
+
const REPO_CATEGORY_LABELS = {
|
|
21
21
|
core: "Core",
|
|
22
22
|
deployment: "Deployment",
|
|
23
23
|
theme: "Theme",
|
|
@@ -28,6 +28,37 @@ const CATEGORY_LABELS = {
|
|
|
28
28
|
other: "Other",
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Categorize a commit by its conventional commit prefix
|
|
33
|
+
* @param {string} title - First line of commit message
|
|
34
|
+
* @returns {string} - Category key
|
|
35
|
+
*/
|
|
36
|
+
function categorizeCommit(title) {
|
|
37
|
+
if (/^feat[:(]/i.test(title)) return "features";
|
|
38
|
+
if (/^fix[:(]/i.test(title)) return "fixes";
|
|
39
|
+
if (/^perf[:(]/i.test(title)) return "performance";
|
|
40
|
+
if (/^a11y[:(]/i.test(title)) return "accessibility";
|
|
41
|
+
if (/^docs[:(]/i.test(title)) return "documentation";
|
|
42
|
+
if (/^refactor[:(]/i.test(title)) return "refactor";
|
|
43
|
+
if (/^chore[:(]/i.test(title)) return "chores";
|
|
44
|
+
if (/^style[:(]/i.test(title)) return "style";
|
|
45
|
+
if (/^test[:(]/i.test(title)) return "tests";
|
|
46
|
+
return "other";
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const COMMIT_CATEGORY_LABELS = {
|
|
50
|
+
features: "Features",
|
|
51
|
+
fixes: "Fixes",
|
|
52
|
+
performance: "Performance",
|
|
53
|
+
accessibility: "Accessibility",
|
|
54
|
+
documentation: "Documentation",
|
|
55
|
+
refactor: "Refactor",
|
|
56
|
+
chores: "Chores",
|
|
57
|
+
style: "Style",
|
|
58
|
+
tests: "Tests",
|
|
59
|
+
other: "Other",
|
|
60
|
+
};
|
|
61
|
+
|
|
31
62
|
/**
|
|
32
63
|
* Split an array into chunks of a given size
|
|
33
64
|
* @param {Array} array
|
|
@@ -94,17 +125,23 @@ export const changelogController = {
|
|
|
94
125
|
repo.name.includes("indiekit"),
|
|
95
126
|
);
|
|
96
127
|
|
|
97
|
-
// Build categories map from discovered repos
|
|
98
|
-
const
|
|
128
|
+
// Build repo-based categories map from discovered repos
|
|
129
|
+
const repoCategories = {};
|
|
99
130
|
for (const repo of indiekitRepos) {
|
|
100
131
|
const cat = categorizeRepo(repo.name);
|
|
101
|
-
if (!
|
|
102
|
-
|
|
103
|
-
label:
|
|
132
|
+
if (!repoCategories[cat]) {
|
|
133
|
+
repoCategories[cat] = {
|
|
134
|
+
label: REPO_CATEGORY_LABELS[cat] || cat,
|
|
104
135
|
repos: [],
|
|
105
136
|
};
|
|
106
137
|
}
|
|
107
|
-
|
|
138
|
+
repoCategories[cat].repos.push(repo.name);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Build commit-type categories map (static, populated after commits are fetched)
|
|
142
|
+
const commitCategories = {};
|
|
143
|
+
for (const [key, label] of Object.entries(COMMIT_CATEGORY_LABELS)) {
|
|
144
|
+
commitCategories[key] = { label, count: 0 };
|
|
108
145
|
}
|
|
109
146
|
|
|
110
147
|
// Fetch commits in batches of 5 to avoid secondary rate limits
|
|
@@ -138,6 +175,7 @@ export const changelogController = {
|
|
|
138
175
|
repoName: repo.name,
|
|
139
176
|
repoUrl: repo.html_url,
|
|
140
177
|
category: categorizeRepo(repo.name),
|
|
178
|
+
commitCategory: categorizeCommit(c.commit.message.split("\n")[0]),
|
|
141
179
|
}));
|
|
142
180
|
} catch {
|
|
143
181
|
return [];
|
|
@@ -152,9 +190,17 @@ export const changelogController = {
|
|
|
152
190
|
(a, b) => new Date(b.date || 0) - new Date(a.date || 0),
|
|
153
191
|
);
|
|
154
192
|
|
|
193
|
+
// Populate commit category counts
|
|
194
|
+
for (const commit of allCommits) {
|
|
195
|
+
if (commitCategories[commit.commitCategory]) {
|
|
196
|
+
commitCategories[commit.commitCategory].count++;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
155
200
|
response.json({
|
|
156
201
|
commits: allCommits,
|
|
157
|
-
categories,
|
|
202
|
+
categories: repoCategories,
|
|
203
|
+
commitCategories,
|
|
158
204
|
totalCommits: allCommits.length,
|
|
159
205
|
days: daysValue,
|
|
160
206
|
generatedAt: new Date().toISOString(),
|
package/lib/starred-cache.js
CHANGED
|
@@ -86,21 +86,20 @@ export async function annotateWithLists(db, lists) {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
//
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
];
|
|
89
|
+
// Reset all repos' lists first, then annotate per-repo
|
|
90
|
+
await collection.updateMany({}, { $set: { lists: [] } });
|
|
91
|
+
|
|
92
|
+
const annotateOps = [...repoToLists.entries()].map(([fullName, slugs]) => ({
|
|
93
|
+
updateOne: {
|
|
94
|
+
filter: { fullName },
|
|
95
|
+
update: { $set: { lists: slugs } },
|
|
96
|
+
},
|
|
97
|
+
}));
|
|
99
98
|
|
|
100
99
|
// Process in batches of 1000 to avoid MongoDB limits
|
|
101
100
|
let reposAnnotated = 0;
|
|
102
|
-
for (let i = 0; i <
|
|
103
|
-
const batch =
|
|
101
|
+
for (let i = 0; i < annotateOps.length; i += 1000) {
|
|
102
|
+
const batch = annotateOps.slice(i, i + 1000);
|
|
104
103
|
const result = await collection.bulkWrite(batch, { ordered: true });
|
|
105
104
|
reposAnnotated += result.modifiedCount;
|
|
106
105
|
}
|
package/package.json
CHANGED