Skip to content

Commit 06f29d2

Browse files
feat: add watcher warning to module report
1 parent 5eb8d3d commit 06f29d2

5 files changed

Lines changed: 60 additions & 3 deletions

File tree

scripts/check-modules/__tests__/result-markdown.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ describe("result-markdown", () => {
2020
name: "MMM-Boolean",
2121
maintainer: "Carol",
2222
issues: true
23+
},
24+
{
25+
name: "MMM-Quiet",
26+
maintainer: "Dana",
27+
url: "https://github.com/example/MMM-Quiet",
28+
watchersCount: 0
2329
}
2430
]);
2531

@@ -29,6 +35,12 @@ describe("result-markdown", () => {
2935
maintainer: "Alice",
3036
url: "https://github.com/example/MMM-Example",
3137
issues: ["Issue one", "Issue two"]
38+
},
39+
{
40+
name: "MMM-Quiet",
41+
maintainer: "Dana",
42+
url: "https://github.com/example/MMM-Quiet",
43+
issues: ["GitHub reports 0 watchers; maintainer notifications may be missed."]
3244
}
3345
]);
3446
});

scripts/check-modules/result-markdown.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ interface ProcessedModuleLike {
1818
issues?: boolean | string[] | string | null;
1919
maintainer?: string;
2020
name?: string;
21+
watchersCount?: number;
2122
url?: string;
2223
}
2324

@@ -41,13 +42,18 @@ export function collectIssueSummaries(modules: unknown[]): IssueSummary[] {
4142

4243
const stageModule = module as ProcessedModuleLike;
4344
const issues = normalizeIssuesInput(stageModule.issues);
45+
const watcherIssue = stageModule.watchersCount === 0
46+
? "GitHub reports 0 watchers; maintainer notifications may be missed."
47+
: null;
4448

45-
if (issues.length === 0 || typeof stageModule.name !== "string" || typeof stageModule.maintainer !== "string") {
49+
const combinedIssues = watcherIssue ? [...issues, watcherIssue] : issues;
50+
51+
if (combinedIssues.length === 0 || typeof stageModule.name !== "string" || typeof stageModule.maintainer !== "string") {
4652
return [];
4753
}
4854

4955
return [{
50-
issues,
56+
issues: combinedIssues,
5157
maintainer: stageModule.maintainer,
5258
name: stageModule.name,
5359
url: typeof stageModule.url === "string" ? stageModule.url : undefined
@@ -67,6 +73,7 @@ export function buildResultMarkdown(stats: ResultMarkdownStats, summaries: Issue
6773
"* Some issues are opinionated recommendations. Please feel free to ignore them.",
6874
""
6975
);
76+
7077
lines.push("## Statistics", "");
7178
lines.push("| | number |");
7279
lines.push("|:---------------------|:--------:|");

scripts/shared/module-catalogue-output.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export interface ProcessedModule extends ModuleRecord {
1717
maintainer?: string;
1818
name?: string;
1919
outdated?: boolean;
20+
watchersCount?: number;
2021
stars?: number;
2122
tags?: string[];
2223
url?: string;
@@ -107,6 +108,7 @@ const PROCESSED_MODULE_ALLOWED_KEYS: string[] = [
107108
"outdated",
108109
"issues",
109110
"stars",
111+
"watchersCount",
110112
"license",
111113
"hasGithubIssues",
112114
"isArchived",
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { describe, it } from "node:test";
2+
import assert from "node:assert";
3+
4+
import { normalizeRepositoryData } from "../api.ts";
5+
6+
describe("updateRepositoryApiData/api", () => {
7+
it("exposes GitHub subscriber count as watchersCount", () => {
8+
const normalized = normalizeRepositoryData({
9+
stargazers_count: 12,
10+
subscribers_count: 0,
11+
has_issues: true,
12+
archived: false,
13+
defaultBranchRef: { target: { committedDate: "2026-01-01T00:00:00.000Z" } }
14+
}, null, "github");
15+
16+
assert.strictEqual(normalized.watchersCount, 0);
17+
assert.strictEqual(normalized.stars, 12);
18+
});
19+
20+
it("keeps a non-zero GitHub subscriber count intact", () => {
21+
const normalized = normalizeRepositoryData({
22+
stargazers_count: 12,
23+
subscribers_count: 7,
24+
has_issues: true,
25+
archived: false,
26+
defaultBranchRef: { target: { committedDate: "2026-01-01T00:00:00.000Z" } }
27+
}, null, "github");
28+
29+
assert.strictEqual(normalized.watchersCount, 7);
30+
});
31+
});

scripts/updateRepositoryApiData/api.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ interface RepositoryApiData {
4141
stargazerCount?: number;
4242
stargazers_count?: number;
4343
stars_count?: number;
44+
subscribers_count?: number;
4445
watchers_count?: number;
4546
[key: string]: unknown;
4647
}
@@ -68,6 +69,7 @@ export interface NormalizedRepositoryMetadata {
6869
isArchived: boolean;
6970
lastCommit: string | null;
7071
license: string | null;
72+
watchersCount?: number;
7173
stars: number;
7274
}
7375

@@ -171,13 +173,15 @@ export function normalizeRepositoryData(data: RepositoryApiData, branchData: Rep
171173
let license: string | null = null;
172174
let hasGithubIssues = false;
173175
let lastCommit: string | null = null;
176+
let watchersCount: number | undefined;
174177

175178
switch (repoType) {
176179
case "github":
177180
stars = data.stargazers_count ?? data.stargazerCount ?? 0;
178181
license = data.license?.spdx_id ?? data.licenseInfo?.spdxId ?? null;
179182
hasGithubIssues = data.has_issues ?? data.hasIssuesEnabled ?? false;
180183
lastCommit = branchData?.commit?.author?.date ?? data.defaultBranchRef?.target?.committedDate ?? data.pushedAt ?? null;
184+
watchersCount = data.subscribers_count ?? 0;
181185
break;
182186
case "gitlab":
183187
stars = data.star_count ?? 0;
@@ -205,6 +209,7 @@ export function normalizeRepositoryData(data: RepositoryApiData, branchData: Rep
205209
license,
206210
hasGithubIssues,
207211
isArchived,
208-
lastCommit
212+
lastCommit,
213+
watchersCount
209214
};
210215
}

0 commit comments

Comments
 (0)