Skip to content

Commit 69efa77

Browse files
committed
feat: update the update-contributor script to use the config file
1 parent 209f2ce commit 69efa77

File tree

1 file changed

+10
-42
lines changed

1 file changed

+10
-42
lines changed

packages/frontendmu-data/scripts/update-contributors.js

Lines changed: 10 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@ import fs from "fs";
22
import { execSync } from "child_process";
33

44
const owner = "frontendmu";
5-
const repo = "frontend.mu";
65
const branch = "main"; // Replace with the default branch of your repository
76

87
const contributorsFile = "./data/contributors.json";
8+
const configSource = `https://raw.githubusercontent.com/${owner}/frontend.mu/${branch}/packages/frontendmu-data/scripts/update-contributors.config.json`
99

1010
async function updateContributors() {
1111
try {
12+
const config = await loadConfig();
13+
const includedRepositories = config.includedRepositories;
14+
const excludedContributors = config.excludedContributors;
15+
1216
const allPublicRepositoriesList = await fetch(
1317
`https://api.github.com/users/${owner}/repos`
1418
).then((response) => response.json());
@@ -17,55 +21,16 @@ async function updateContributors() {
1721
(repo) => repo.name
1822
);
1923

20-
// console.log("All public repositories:", allPublicRepositories);
21-
// [
22-
// '.github',
23-
// 'branding',
24-
// 'conference-2024',
25-
// 'events',
26-
// 'frontend.mu',
27-
// 'frontendmu-daisy',
28-
// 'frontendmu-nuxt',
29-
// 'frontendmu-ticket',
30-
// 'google-photos-sync',
31-
// 'hacktoberfestmu-2019',
32-
// 'meetupFEC',
33-
// 'nuxt-workshop-devcon2024',
34-
// 'nuxt-workshop-devcon2024-preparations',
35-
// 'playground',
36-
// 'vercel-og-next',
37-
// 'video'
38-
// ]
39-
40-
// const contributors = [];
4124
const contributorsMap = {};
4225

43-
const excludedContributors = ["actions-user", "github-actions[bot]"];
44-
const excludedRepositories = [".github", "google-photos-sync", "branding"];
45-
4626
for (const repo of allPublicRepositories) {
47-
if (excludedRepositories.includes(repo)) {
27+
if (!includedRepositories.includes(repo)) {
4828
continue;
4929
}
5030
const contributorsList = await fetch(
5131
`https://api.github.com/repos/${owner}/${repo}/contributors`
5232
).then((response) => response.json());
5333

54-
// const contributorsListFiltered = contributorsList
55-
// .map((contributor) => {
56-
// return {
57-
// username: contributor.login,
58-
// contributions: contributor.contributions,
59-
// };
60-
// })
61-
// .filter((contributor) => {
62-
// return !excludedContributors.includes(contributor.username);
63-
// });
64-
// contributors.push(...contributorsListFiltered);
65-
// console.log(`Contributors for ${repo}:`, contributorsListFiltered);
66-
// }
67-
// const updatedContributors = [...new Set(contributors)];
68-
6934
contributorsList.forEach((contributor) => {
7035
if (!excludedContributors.includes(contributor.login)) {
7136
if (contributorsMap[contributor.login]) {
@@ -92,7 +57,6 @@ async function updateContributors() {
9257
contributorsFile,
9358
contributorsData
9459
);
95-
// console.log("Contributors file updated.");
9660

9761
// Configure Git user and email for the commit
9862
execSync('git config user.name "GitHub Action"');
@@ -125,4 +89,8 @@ function getExistingContributors() {
12589
return [];
12690
}
12791

92+
async function loadConfig() {
93+
return await fetch(configSource).then((response) => response.json());
94+
}
95+
12896
updateContributors();

0 commit comments

Comments
 (0)