1
+ import { execSync } from 'node:child_process'
1
2
import { promises as fsp } from 'node:fs'
3
+ import { $fetch } from 'ofetch'
2
4
import { resolve } from 'pathe'
3
5
import { globby } from 'globby'
4
6
import { execaSync } from 'execa'
5
7
import { determineSemverChange , getGitDiff , loadChangelogConfig , parseCommits } from 'changelogen'
6
8
7
9
export interface Dep {
8
- name : string ,
9
- range : string ,
10
+ name : string
11
+ range : string
10
12
type : string
11
13
}
12
14
@@ -35,7 +37,7 @@ export async function loadPackage (dir: string) {
35
37
dir,
36
38
data,
37
39
save,
38
- updateDeps
40
+ updateDeps,
39
41
}
40
42
}
41
43
@@ -93,7 +95,7 @@ export async function loadWorkspace (dir: string) {
93
95
save,
94
96
find,
95
97
rename,
96
- setVersion
98
+ setVersion,
97
99
}
98
100
}
99
101
@@ -112,3 +114,25 @@ export async function getLatestCommits () {
112
114
113
115
return parseCommits ( await getGitDiff ( latestTag ) , config )
114
116
}
117
+
118
+ export async function getContributors ( ) {
119
+ const contributors = [ ] as Array < { name : string , username : string } >
120
+ const emails = new Set < string > ( )
121
+ const latestTag = execSync ( 'git describe --tags --abbrev=0' ) . toString ( ) . trim ( )
122
+ const rawCommits = await getGitDiff ( latestTag )
123
+ for ( const commit of rawCommits ) {
124
+ if ( emails . has ( commit . author . email ) || commit . author . name === 'renovate[bot]' ) { continue }
125
+ const { author } = await $fetch < { author : { login : string , email : string } } > ( `https://api.github.com/repos/CodeDredd/pinia-orm/commits/${ commit . shortHash } ` , {
126
+ headers : {
127
+ 'User-Agent' : 'CodeDredd/pinia-orm' ,
128
+ 'Accept' : 'application/vnd.github.v3+json' ,
129
+ 'Authorization' : `token ${ process . env . GITHUB_TOKEN } ` ,
130
+ } ,
131
+ } )
132
+ if ( ! contributors . some ( c => c . username === author . login ) ) {
133
+ contributors . push ( { name : commit . author . name , username : author . login } )
134
+ }
135
+ emails . add ( author . email )
136
+ }
137
+ return contributors
138
+ }
0 commit comments