@@ -2,13 +2,17 @@ import fs from "fs";
2
2
import { execSync } from "child_process" ;
3
3
4
4
const owner = "frontendmu" ;
5
- const repo = "frontend.mu" ;
6
5
const branch = "main" ; // Replace with the default branch of your repository
7
6
8
7
const contributorsFile = "./data/contributors.json" ;
8
+ const configSource = `https://raw.githubusercontent.com/${ owner } /frontend.mu/${ branch } /packages/frontendmu-data/scripts/update-contributors.config.json`
9
9
10
10
async function updateContributors ( ) {
11
11
try {
12
+ const config = await loadConfig ( ) ;
13
+ const includedRepositories = config . includedRepositories ;
14
+ const excludedContributors = config . excludedContributors ;
15
+
12
16
const allPublicRepositoriesList = await fetch (
13
17
`https://api.github.com/users/${ owner } /repos`
14
18
) . then ( ( response ) => response . json ( ) ) ;
@@ -17,55 +21,16 @@ async function updateContributors() {
17
21
( repo ) => repo . name
18
22
) ;
19
23
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 = [];
41
24
const contributorsMap = { } ;
42
25
43
- const excludedContributors = [ "actions-user" , "github-actions[bot]" ] ;
44
- const excludedRepositories = [ ".github" , "google-photos-sync" , "branding" ] ;
45
-
46
26
for ( const repo of allPublicRepositories ) {
47
- if ( excludedRepositories . includes ( repo ) ) {
27
+ if ( ! includedRepositories . includes ( repo ) ) {
48
28
continue ;
49
29
}
50
30
const contributorsList = await fetch (
51
31
`https://api.github.com/repos/${ owner } /${ repo } /contributors`
52
32
) . then ( ( response ) => response . json ( ) ) ;
53
33
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
-
69
34
contributorsList . forEach ( ( contributor ) => {
70
35
if ( ! excludedContributors . includes ( contributor . login ) ) {
71
36
if ( contributorsMap [ contributor . login ] ) {
@@ -92,7 +57,6 @@ async function updateContributors() {
92
57
contributorsFile ,
93
58
contributorsData
94
59
) ;
95
- // console.log("Contributors file updated.");
96
60
97
61
// Configure Git user and email for the commit
98
62
execSync ( 'git config user.name "GitHub Action"' ) ;
@@ -125,4 +89,8 @@ function getExistingContributors() {
125
89
return [ ] ;
126
90
}
127
91
92
+ async function loadConfig ( ) {
93
+ return await fetch ( configSource ) . then ( ( response ) => response . json ( ) ) ;
94
+ }
95
+
128
96
updateContributors ( ) ;
0 commit comments