@@ -34,10 +34,10 @@ const REPOS = ['angular', 'components', 'angular-cli'];
34
34
/**
35
35
* Handle flags for the script.
36
36
*/
37
- const args = yargs . option ( 'use-created' , { type : 'boolean' } )
38
- . option ( 'since ' , { type : 'string' , demandOption : true } )
39
- . strictOptions ( )
40
- . argv ;
37
+ const args = yargs
38
+ . option ( 'use-created ' , { type : 'boolean' } )
39
+ . option ( 'since' , { type : 'string' , demandOption : true } )
40
+ . strictOptions ( ) . argv ;
41
41
42
42
/**
43
43
* Authenticated instance of Github GraphQl API service, relies on a
@@ -48,7 +48,7 @@ const graphql = unauthenticatedGraphql.defaults({
48
48
// TODO(josephperrott): Remove reference to TOKEN environment variable as part of larger
49
49
// effort to migrate to expecting tokens via GITHUB_ACCESS_TOKEN environment variables.
50
50
authorization : `token ${ process . env [ 'TOKEN' ] || process . env [ 'GITHUB_ACCESS_TOKEN' ] } ` ,
51
- }
51
+ } ,
52
52
} ) ;
53
53
54
54
/**
@@ -57,27 +57,32 @@ const graphql = unauthenticatedGraphql.defaults({
57
57
async function getAllOrgMembers ( ) {
58
58
// The GraphQL query object to get a page of members of an organization.
59
59
const MEMBERS_QUERY = params (
60
- {
61
- $first : 'Int' , // How many entries to get with each request
62
- $after : 'String' , // The cursor to start the page at
63
- $owner : 'String!' , // The organization to query for
64
- } ,
65
- {
66
- organization : params ( { login : '$owner' } , {
60
+ {
61
+ $first : 'Int' , // How many entries to get with each request
62
+ $after : 'String' , // The cursor to start the page at
63
+ $owner : 'String!' , // The organization to query for
64
+ } ,
65
+ {
66
+ organization : params (
67
+ { login : '$owner' } ,
68
+ {
67
69
membersWithRole : params (
68
- {
69
- first : '$first' ,
70
- after : '$after' ,
70
+ {
71
+ first : '$first' ,
72
+ after : '$after' ,
73
+ } ,
74
+ {
75
+ nodes : [ { login : types . string } ] ,
76
+ pageInfo : {
77
+ hasNextPage : types . boolean ,
78
+ endCursor : types . string ,
71
79
} ,
72
- {
73
- nodes : [ { login : types . string } ] ,
74
- pageInfo : {
75
- hasNextPage : types . boolean ,
76
- endCursor : types . string ,
77
- } ,
78
- } ) ,
79
- } )
80
- } ) ;
80
+ } ,
81
+ ) ,
82
+ } ,
83
+ ) ,
84
+ } ,
85
+ ) ;
81
86
const query = graphqlQuery ( 'members' , MEMBERS_QUERY ) ;
82
87
83
88
/**
@@ -103,10 +108,11 @@ async function getAllOrgMembers() {
103
108
104
109
while ( hasNextPage ) {
105
110
const { query, params} = queryBuilder ( 100 , cursor ) ;
106
- const results = await graphql ( query . toString ( ) , params ) as typeof MEMBERS_QUERY ;
111
+ const results = ( await graphql ( query . toString ( ) , params ) ) as typeof MEMBERS_QUERY ;
107
112
108
- results . organization . membersWithRole . nodes . forEach (
109
- ( node : { login : string } ) => members . push ( node . login ) ) ;
113
+ results . organization . membersWithRole . nodes . forEach ( ( node : { login : string } ) =>
114
+ members . push ( node . login ) ,
115
+ ) ;
110
116
hasNextPage = results . organization . membersWithRole . pageInfo . hasNextPage ;
111
117
cursor = results . organization . membersWithRole . pageInfo . endCursor ;
112
118
}
@@ -121,7 +127,7 @@ async function getAllOrgMembers() {
121
127
function buildQueryAndParams ( username : string , date : string ) {
122
128
// Whether the updated or created timestamp should be used.
123
129
const updatedOrCreated = args [ 'use-created' ] ? 'created' : 'updated' ;
124
- let dataQueries : { [ key : string ] : { query : string , label : string } } = { } ;
130
+ let dataQueries : { [ key : string ] : { query : string ; label : string } } = { } ;
125
131
// Add queries and params for all values queried for each repo.
126
132
for ( let repo of REPOS ) {
127
133
dataQueries = {
@@ -131,8 +137,7 @@ function buildQueryAndParams(username: string, date: string) {
131
137
label : `${ ORG } /${ repo } Issue Authored` ,
132
138
} ,
133
139
[ `${ repo . replace ( / [ \/ \- ] / g, '_' ) } _issues_involved` ] : {
134
- query : `repo:${ ORG } /${ repo } is:issue -author:${ username } involves:${ username } ${
135
- updatedOrCreated } :>${ date } `,
140
+ query : `repo:${ ORG } /${ repo } is:issue -author:${ username } involves:${ username } ${ updatedOrCreated } :>${ date } ` ,
136
141
label : `${ ORG } /${ repo } Issue Involved` ,
137
142
} ,
138
143
[ `${ repo . replace ( / [ \/ \- ] / g, '_' ) } _pr_author` ] : {
@@ -144,13 +149,11 @@ function buildQueryAndParams(username: string, date: string) {
144
149
label : `${ ORG } /${ repo } PR Involved` ,
145
150
} ,
146
151
[ `${ repo . replace ( / [ \/ \- ] / g, '_' ) } _pr_reviewed` ] : {
147
- query : `repo:${ ORG } /${ repo } is:pr -author:${ username } reviewed-by:${ username } ${
148
- updatedOrCreated } :>${ date } `,
152
+ query : `repo:${ ORG } /${ repo } is:pr -author:${ username } reviewed-by:${ username } ${ updatedOrCreated } :>${ date } ` ,
149
153
label : `${ ORG } /${ repo } PR Reviewed` ,
150
154
} ,
151
155
[ `${ repo . replace ( / [ \/ \- ] / g, '_' ) } _pr_commented` ] : {
152
- query : `repo:${ ORG } /${ repo } is:pr -author:${ username } commenter:${ username } ${
153
- updatedOrCreated } :>${ date } `,
156
+ query : `repo:${ ORG } /${ repo } is:pr -author:${ username } commenter:${ username } ${ updatedOrCreated } :>${ date } ` ,
154
157
label : `${ ORG } /${ repo } PR Commented` ,
155
158
} ,
156
159
} ;
@@ -163,8 +166,7 @@ function buildQueryAndParams(username: string, date: string) {
163
166
label : `${ ORG } org Issue Authored` ,
164
167
} ,
165
168
[ `${ ORG } _org_issues_involved` ] : {
166
- query : `org:${ ORG } is:issue -author:${ username } involves:${ username } ${ updatedOrCreated } :>${
167
- date } `,
169
+ query : `org:${ ORG } is:issue -author:${ username } involves:${ username } ${ updatedOrCreated } :>${ date } ` ,
168
170
label : `${ ORG } org Issue Involved` ,
169
171
} ,
170
172
[ `${ ORG } _org_pr_author` ] : {
@@ -176,13 +178,11 @@ function buildQueryAndParams(username: string, date: string) {
176
178
label : `${ ORG } org PR Involved` ,
177
179
} ,
178
180
[ `${ ORG } _org_pr_reviewed` ] : {
179
- query : `org:${ ORG } is:pr -author:${ username } reviewed-by:${ username } ${ updatedOrCreated } :>${
180
- date } `,
181
+ query : `org:${ ORG } is:pr -author:${ username } reviewed-by:${ username } ${ updatedOrCreated } :>${ date } ` ,
181
182
label : `${ ORG } org PR Reviewed` ,
182
183
} ,
183
184
[ `${ ORG } _org_pr_commented` ] : {
184
- query :
185
- `org:${ ORG } is:pr -author:${ username } commenter:${ username } ${ updatedOrCreated } :>${ date } ` ,
185
+ query : `org:${ ORG } is:pr -author:${ username } commenter:${ username } ${ updatedOrCreated } :>${ date } ` ,
186
186
label : `${ ORG } org PR Commented` ,
187
187
} ,
188
188
} ;
@@ -191,7 +191,7 @@ function buildQueryAndParams(username: string, date: string) {
191
191
* Gets the labels for each requested value to be used as headers.
192
192
*/
193
193
function getLabels ( pairs : typeof dataQueries ) {
194
- return Object . values ( pairs ) . map ( val => val . label ) ;
194
+ return Object . values ( pairs ) . map ( ( val ) => val . label ) ;
195
195
}
196
196
197
197
/**
@@ -201,13 +201,14 @@ function buildQueryAndParams(username: string, date: string) {
201
201
const output : { [ key : string ] : { } } = { } ;
202
202
Object . entries ( pairs ) . map ( ( [ key , val ] ) => {
203
203
output [ alias ( key , 'search' ) ] = params (
204
- {
205
- query : `"${ val . query } "` ,
206
- type : 'ISSUE' ,
207
- } ,
208
- {
209
- issueCount : types . number ,
210
- } ) ;
204
+ {
205
+ query : `"${ val . query } "` ,
206
+ type : 'ISSUE' ,
207
+ } ,
208
+ {
209
+ issueCount : types . number ,
210
+ } ,
211
+ ) ;
211
212
} ) ;
212
213
return output ;
213
214
}
@@ -229,7 +230,7 @@ async function run(date: string) {
229
230
230
231
for ( const username of allOrgMembers ) {
231
232
const results = await graphql ( buildQueryAndParams ( username , date ) . query . toString ( ) ) ;
232
- const values = Object . values ( results ) . map ( result => `${ result . issueCount } ` ) ;
233
+ const values = Object . values ( results ) . map ( ( result ) => `${ result . issueCount } ` ) ;
233
234
console . info ( [ username , ...values ] . join ( ',' ) ) ;
234
235
}
235
236
} catch ( error ) {
0 commit comments