@rmdes/indiekit-endpoint-github 1.2.3 → 1.2.4

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.
@@ -17,7 +17,7 @@ function categorizeRepo(name) {
17
17
  return "other";
18
18
  }
19
19
 
20
- const CATEGORY_LABELS = {
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 categories = {};
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 (!categories[cat]) {
102
- categories[cat] = {
103
- label: CATEGORY_LABELS[cat] || cat,
132
+ if (!repoCategories[cat]) {
133
+ repoCategories[cat] = {
134
+ label: REPO_CATEGORY_LABELS[cat] || cat,
104
135
  repos: [],
105
136
  };
106
137
  }
107
- categories[cat].repos.push(repo.name);
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rmdes/indiekit-endpoint-github",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "description": "GitHub activity endpoint for Indiekit. Display commits, stars, contributions, and featured repositories.",
5
5
  "keywords": [
6
6
  "indiekit",