Skip to content

Build your personal knowledge base with Trilium Notes

chore: update contributors list

Elian Doran2c744122cab1
diff --git a/contributors.json b/contributors.json
index 86f480074c..5134dff233 100644
--- a/contributors.json
+++ b/contributors.json
@@ -1,5 +1,5 @@
{
- "ℹ️": "Use `npm run list-contributors`. as a reference to update this list.",
+ "ℹ️": "Auto-generated file. Run `pnpm run list-contributors` to regenerate.",
"contributors": [
{
"name": "eliandoran",
@@ -15,14 +15,17 @@
},
{
"name": "adoriandoran",
+ "fullName": "Adorian Doran",
"url": "https://github.com/adoriandoran"
},
{
"name": "perfectra1n",
+ "fullName": "Jon Fuller",
"url": "https://github.com/perfectra1n"
},
{
"name": "pano9000",
+ "fullName": "Panagiotis Papadopoulos",
"url": "https://github.com/pano9000"
},
{
@@ -33,81 +36,9 @@
"name": "JYC333",
"url": "https://github.com/JYC333"
},
- {
- "name": "francistw",
- "url": "https://github.com/francistw"
- },
{
"name": "Nriver",
"url": "https://github.com/Nriver"
- },
- {
- "name": "thfrei",
- "url": "https://github.com/thfrei"
- },
- {
- "name": "nathancahill",
- "url": "https://github.com/nathancahill"
- },
- {
- "name": "contributor",
- "url": "https://github.com/contributor"
- },
- {
- "name": "FliegendeWurst",
- "url": "https://github.com/FliegendeWurst"
- },
- {
- "name": "hasecilu",
- "url": "https://github.com/hasecilu"
- },
- {
- "name": "Meinzzzz",
- "url": "https://github.com/Meinzzzz"
- },
- {
- "name": "Sarah-Hussein",
- "url": "https://github.com/Sarah-Hussein"
- },
- {
- "name": "zerebos",
- "url": "https://github.com/zerebos"
- },
- {
- "name": "meichthys",
- "url": "https://github.com/meichthys"
- },
- {
- "name": "questamor",
- "url": "https://github.com/questamor"
- },
- {
- "name": "SukantGujar",
- "url": "https://github.com/SukantGujar"
- },
- {
- "name": "soulsands",
- "url": "https://github.com/soulsands"
- },
- {
- "name": "noobhjy",
- "url": "https://github.com/noobhjy"
- },
- {
- "name": "laurent22",
- "url": "https://github.com/laurent22"
- },
- {
- "name": "mlewand",
- "url": "https://github.com/mlewand"
- },
- {
- "name": "lzinga",
- "url": "https://github.com/lzinga"
- },
- {
- "name": "ytrkptl",
- "url": "https://github.com/ytrkptl"
}
]
-}
\ No newline at end of file
+}
diff --git a/scripts/list-contributors.ts b/scripts/list-contributors.ts
index 719898d679..c58766d5f6 100644
--- a/scripts/list-contributors.ts
+++ b/scripts/list-contributors.ts
@@ -1,60 +1,33 @@
-import { execSync} from "node:child_process";
+import { execSync } from "node:child_process";
+import { readFileSync, writeFileSync } from "node:fs";
+import { join } from "node:path";
+
+interface ContributorEntry {
+ name: string;
+ fullName?: string;
+ url: string;
+ role?: string;
+}
+
+interface ContributorFile {
+ contributors: ContributorEntry[];
+}
interface ContributorInfo {
name: string;
- fullName?: string
+ fullName?: string;
email?: string;
commitCount: number;
- translationCommitCount?: number;
- role?: string;
url?: string;
}
-interface showTableParams {
+interface ShowTableParams {
title: string;
comment?: string;
contributors: ContributorInfo[];
columns: (keyof ContributorInfo)[];
}
-async function main() {
- listLocalGitContributors();
- await listGitHubContributors();
-}
-
-async function listGitHubContributors() {
- let list: any[] | null = null;
-
- const response = await fetch("https://api.github.com/repos/TriliumNext/Trilium/contributors");
- if (response.ok) {
- list = await response.json();
- } else {
- console.error(`Unable to request the contributor list from GitHub. Reason: ${response.statusText}`);
- }
-
- if (!list) {
- return;
- }
-
- const MIN_CONTRIBUTIONS = 125;
- const contributors: ContributorInfo[] = list
- .filter((c) => c.contributions >= MIN_CONTRIBUTIONS)
- .map((c) => {
- return {
- name: c.login,
- url: c.html_url,
- commitCount: c.contributions
- } as ContributorInfo;
- });
-
- showTable({
- title: "GitHub Contributor List",
- comment: "Note: the GitHub list also include contributors that did not directly contribute to Trilium, but to submodules used in the Trilium's repo.",
- contributors: contributors,
- columns: ["name", "url", "commitCount"]
- });
-}
-
const TRANSLATION_PATHS = [
"apps/client/src/translations/",
"apps/server/src/assets/translations/"
@@ -67,6 +40,50 @@ const EXCLUDED_AUTHORS = new Set([
"renovate[bot]"
]);
+const NOREPLY_PATTERN = /^(?:\d+\+)?(.+)@users\.noreply\.github\.com$/;
+
+/**
+ * Manual mapping for contributors whose git email doesn't reveal their
+ * GitHub username (i.e. no noreply email in .mailmap).
+ */
+const EMAIL_TO_GITHUB: Record<string, string> = {
+ "[email protected]": "eliandoran",
+ "[email protected]": "zadam",
+ "[email protected]": "adoriandoran",
+ "[email protected]": "perfectra1n",
+};
+
+const CONTRIBUTORS_PATH = join(__dirname, "..", "contributors.json");
+
+/**
+ * Resolves a GitHub username from an email address.
+ *
+ * 1. Checks the manual mapping.
+ * 2. Extracts from GitHub noreply emails (e.g. "12345+user@…").
+ * 3. Scans .mailmap for alternate emails that match the noreply pattern.
+ */
+function resolveGitHub(email: string, name: string): string | undefined {
+ if (EMAIL_TO_GITHUB[email]) return EMAIL_TO_GITHUB[email];
+
+ const noreply = email.match(NOREPLY_PATTERN);
+ if (noreply) return noreply[1];
+
+ // Grep .mailmap for alternate emails that match the noreply pattern
+ try {
+ const escapedName = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
+ const mailmapContent = execSync(`grep -i "${escapedName}" .mailmap 2>/dev/null`).toString();
+ for (const line of mailmapContent.split("\n")) {
+ // Extract all emails from the line (inside angle brackets)
+ for (const [, email] of line.matchAll(/<([^>]+)>/g)) {
+ const match = email.match(NOREPLY_PATTERN);
+ if (match) return match[1];
+ }
+ }
+ } catch { /* no matches */ }
+
+ return undefined;
+}
+
function parseShortlog(rawOutput: string): Map<string, { email: string; commitCount: number }> {
const result = new Map<string, { email: string; commitCount: number }>();
for (const line of rawOutput.split("\n")) {
@@ -78,6 +95,12 @@ function parseShortlog(rawOutput: string): Map<string, { email: string; commitCo
return result;
}
+async function main() {
+ const { developers } = listLocalGitContributors();
+ await listGitHubContributors();
+ updateContributorsJson(developers);
+}
+
function listLocalGitContributors() {
const allOutput = execSync("git shortlog -sne --no-merges HEAD -- src/ apps/").toString();
const translationOutput = execSync(`git shortlog -sne --no-merges HEAD -- ${TRANSLATION_PATHS.join(" ")}`).toString();
@@ -87,39 +110,109 @@ function listLocalGitContributors() {
const developers: ContributorInfo[] = [];
const translators: ContributorInfo[] = [];
- let rank = 0;
+ const MIN_COMMITS = 100;
for (const [name, { email, commitCount }] of allContribs) {
if (EXCLUDED_AUTHORS.has(name)) continue;
- if (++rank > 20) break;
const translationCommitCount = translationContribs.get(name)?.commitCount ?? 0;
const isTranslator = translationCommitCount > commitCount * 0.5;
- const entry: ContributorInfo = { name, email, commitCount };
+ const githubUsername = resolveGitHub(email, name);
+ const url = githubUsername ? `https://github.com/${githubUsername}` : undefined;
+ const entry: ContributorInfo = { name, email, commitCount, url };
if (isTranslator) {
- translators.push(entry);
- } else {
+ if (commitCount >= 20) translators.push(entry);
+ } else if (commitCount >= MIN_COMMITS) {
developers.push(entry);
}
}
- showTable({
- title: "Local Git Contributors (Developers)",
- comment: "",
- columns: ["name", "email", "commitCount"],
- contributors: developers
- });
-
- showTable({
- title: "Local Git Contributors (Translators)",
- comment: "Contributors where >50% of commits are to translation files.",
- columns: ["name", "email", "commitCount"],
- contributors: translators
- });
+ // showTable({
+ // title: "Local Git Contributors (Developers)",
+ // columns: ["name", "url", "commitCount"],
+ // contributors: developers
+ // });
+
+ // showTable({
+ // title: "Local Git Contributors (Translators)",
+ // comment: "Contributors where >50% of commits are to translation files.",
+ // columns: ["name", "url", "commitCount"],
+ // contributors: translators
+ // });
+
+ return { developers, translators };
+}
+
+async function listGitHubContributors() {
+ let list: any[] | null = null;
+
+ const response = await fetch("https://api.github.com/repos/TriliumNext/Trilium/contributors");
+ if (response.ok) {
+ list = await response.json();
+ } else {
+ console.error(`Unable to request the contributor list from GitHub. Reason: ${response.statusText}`);
+ }
+
+ if (!list) {
+ return;
+ }
+
+ const MIN_CONTRIBUTIONS = 125;
+ const contributors: ContributorInfo[] = list
+ .filter((c) => c.contributions >= MIN_CONTRIBUTIONS)
+ .map((c) => {
+ return {
+ name: c.login,
+ url: c.html_url,
+ commitCount: c.contributions
+ } as ContributorInfo;
+ });
+
+ // showTable({
+ // title: "GitHub Contributor List",
+ // comment: "Note: the GitHub list also include contributors that did not directly contribute to Trilium, but to submodules used in the Trilium's repo.",
+ // contributors: contributors,
+ // columns: ["name", "url", "commitCount"]
+ // });
+}
+
+/**
+ * Updates contributors.json, preserving pinned entries (those with special
+ * roles like lead-dev, original-dev) and regenerating the rest from git data.
+ */
+function updateContributorsJson(developers: ContributorInfo[]) {
+ // Read existing file to preserve pinned entries
+ const existing: ContributorFile = JSON.parse(readFileSync(CONTRIBUTORS_PATH, "utf-8"));
+ const pinnedRoles = new Set<string>(["lead-dev", "original-dev"]);
+ const pinned = existing.contributors.filter((c) => c.role && pinnedRoles.has(c.role));
+
+ // Build a set of pinned GitHub usernames to avoid duplicates
+ const pinnedNames = new Set(pinned.map((c) => c.name));
+
+ const contributors: ContributorEntry[] = [...pinned];
+
+ // Add developers (skip those already pinned)
+ for (const dev of developers) {
+ const githubName = dev.url?.replace("https://github.com/", "");
+ if (!githubName || pinnedNames.has(githubName)) continue;
+
+ contributors.push({
+ name: githubName,
+ fullName: dev.name !== githubName ? dev.name : undefined,
+ url: dev.url!
+ });
+ }
+
+ const output = {
+ "ℹ️": "Auto-generated file. Run `pnpm run list-contributors` to regenerate.",
+ contributors
+ };
+ writeFileSync(CONTRIBUTORS_PATH, JSON.stringify(output, null, 4) + "\n");
+ console.log(`\n✅ Updated ${CONTRIBUTORS_PATH} with ${contributors.length} contributors.`);
}
-function showTable(params: showTableParams) {
+function showTable(params: ShowTableParams) {
console.log(`\n──── ${params.title} ────`);
if (params.comment) {
console.log(`\n${params.comment}\n`);
@@ -127,4 +220,4 @@ function showTable(params: showTableParams) {
console.table(params.contributors, params.columns);
}
-main();
\ No newline at end of file
+main();