@@ -42,6 +42,20 @@ if (!GH_TOKEN) {
42
42
process . exit ( 1 ) ;
43
43
}
44
44
45
+ if ( ! packageJSON . repository || typeof packageJSON . repository . url !== 'string' ) {
46
+ console . error ( 'package.json is missing repository.url string!' ) ;
47
+ process . exit ( 1 ) ;
48
+ }
49
+
50
+ const match = / h t t p s : \/ \/ g i t h u b .c o m \/ ( [ ^ / ] + ) \/ ( [ ^ / ] + ) .g i t / . exec (
51
+ packageJSON . repository . url ,
52
+ ) ;
53
+ if ( match == null ) {
54
+ console . error ( 'Can not extract organisation and repo name from repo URL!' ) ;
55
+ process . exit ( 1 ) ;
56
+ }
57
+ const [ , githubOrg , githubRepo ] = match ;
58
+
45
59
getChangeLog ( )
46
60
. then ( changelog => process . stdout . write ( changelog ) )
47
61
. catch ( error => console . error ( error ) ) ;
@@ -120,7 +134,7 @@ function graphqlRequestImpl(query, variables, cb) {
120
134
headers : {
121
135
Authorization : 'bearer ' + GH_TOKEN ,
122
136
'Content-Type' : 'application/json' ,
123
- 'User-Agent' : 'graphql-js -changelog' ,
137
+ 'User-Agent' : 'gen -changelog' ,
124
138
} ,
125
139
} ) ;
126
140
@@ -200,7 +214,7 @@ async function batchCommitInfo(commits) {
200
214
201
215
const response = await graphqlRequest ( `
202
216
{
203
- repository(owner: "graphql ", name: "graphql-js ") {
217
+ repository(owner: "${ githubOrg } ", name: "${ githubRepo } ") {
204
218
${ commitsSubQuery }
205
219
}
206
220
}
@@ -217,7 +231,7 @@ function commitsInfoToPRs(commits) {
217
231
const prs = { } ;
218
232
for ( const commit of commits ) {
219
233
const associatedPRs = commit . associatedPullRequests . nodes . filter (
220
- pr => pr . repository . nameWithOwner === 'graphql/graphql-js' ,
234
+ pr => pr . repository . nameWithOwner === ` ${ githubOrg } / ${ githubRepo } ` ,
221
235
) ;
222
236
if ( associatedPRs . length === 0 ) {
223
237
throw new Error (
0 commit comments