1+ import { execSync } from 'node:child_process'
12import { promises as fsp } from 'node:fs'
3+ import { $fetch } from 'ofetch'
24import { resolve } from 'pathe'
35import { globby } from 'globby'
46import { execaSync } from 'execa'
57import { determineSemverChange , getGitDiff , loadChangelogConfig , parseCommits } from 'changelogen'
68
79export interface Dep {
8- name : string ,
9- range : string ,
10+ name : string
11+ range : string
1012 type : string
1113}
1214
@@ -35,7 +37,7 @@ export async function loadPackage (dir: string) {
3537 dir,
3638 data,
3739 save,
38- updateDeps
40+ updateDeps,
3941 }
4042}
4143
@@ -93,7 +95,7 @@ export async function loadWorkspace (dir: string) {
9395 save,
9496 find,
9597 rename,
96- setVersion
98+ setVersion,
9799 }
98100}
99101
@@ -112,3 +114,25 @@ export async function getLatestCommits () {
112114
113115 return parseCommits ( await getGitDiff ( latestTag ) , config )
114116}
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