@@ -6,6 +6,7 @@ const yargs = require('yargs')
66const  chalk  =  require ( 'chalk' ) 
77const  inquirer  =  require ( 'inquirer' ) 
88const  didYouMean  =  require ( 'didyoumean' ) 
9+ const  { info,  warn,  use}  =  require ( 'nclr' ) 
910
1011const  init  =  require ( './init' ) 
1112const  generate  =  require ( './generate' ) 
@@ -191,7 +192,8 @@ async function fetchContributors(argv) {
191192  const  { 
192193    reviewers, 
193194    commitAuthors, 
194-     issueCreators /* , prCreators */ , 
195+     issueCreators, 
196+     prCreators, 
195197  }  =  await  getContributors ( argv . projectOwner ,  argv . projectName ,  true ) 
196198  const  args  =  { ...argv ,  _ : [ ] } 
197199  const  contributorsToAdd  =  [ ] 
@@ -201,18 +203,21 @@ async function fetchContributors(argv) {
201203    contributorsToAdd . push ( { login : usr . login ,  contributions : [ 'review' ] } ) 
202204
203205    console . log ( 
204-       `Adding  ${ chalk . underline ( 'Reviewer' ) } ${ chalk . blue ( usr . login ) }  , 
206+       `Including  ${ chalk . underline ( 'Reviewer' ) } ${ use ( 'info' ,   usr . login ) }  , 
205207    ) 
206208  } ) 
207209
208210  const  guessCategories  =  ( item ,  itemType ,  contributor )  =>  { 
209211    const  guessedCategory  =  learner 
210212      . classify ( item ) 
211-       . find ( ctr  =>  ctr  &&  ctr  !==  'null' ) 
213+       . find ( ctr  =>  ctr  &&  ctr  !==  'null'   &&   ctr   !==   'undefined' ) 
212214
213215    if  ( ! guessedCategory )  { 
214-       console . warn ( 
215-         `Oops, I couldn't find any category for the "${ item } ${ itemType }  , 
216+       warn ( 
217+         `Oops, I couldn't find any category for the "${ use (  
218+           'inp' ,  
219+           item ,  
220+         ) }  " ${ itemType } , 
216221      ) 
217222
218223      return 
@@ -222,22 +227,21 @@ async function fetchContributors(argv) {
222227      contributor . contributions . push ( guessedCategory ) 
223228
224229      console . log ( 
225-         `Adding  ${ chalk . blue ( contributor . login ) } ${ chalk . underline (  
230+         `Including  ${ use ( 'info' ,   contributor . login ) } ${ chalk . underline (  
226231          guessedCategory ,  
227-         ) }  `, 
232+         ) }  , based on " ${ use ( 'inp' ,   item ) } " `, 
228233      ) 
229234    } 
230235  } 
231236
237+   info ( 'Looking at issue creators' ) 
232238  issueCreators . forEach ( usr  =>  { 
233239    const  contributor  =  { 
234240      login : usr . login , 
235241      contributions : [ ] , 
236242    } 
237-     //TODO: Look at the titles field and categories based on that. 
238243
239244    usr . labels . forEach ( label  =>  guessCategories ( label ,  'label' ,  contributor ) ) 
240- 
241245    usr . titles . forEach ( title  =>  guessCategories ( title ,  'title' ,  contributor ) ) 
242246
243247    const  existingContributor  =  contributorsToAdd . find ( 
@@ -251,14 +255,35 @@ async function fetchContributors(argv) {
251255    } 
252256  } ) 
253257
254-   //TODO Look at prCreators (including its titles field) and add contributions from there 
258+   info ( 'Looking at PR creators' ) 
259+   prCreators . forEach ( usr  =>  { 
260+     const  contributor  =  { 
261+       login : usr . login , 
262+       contributions : [ ] , 
263+     } 
264+ 
265+     usr . labels . forEach ( label  =>  guessCategories ( label ,  'PR label' ,  contributor ) ) 
266+     usr . titles . forEach ( title  =>  guessCategories ( title ,  'PR title' ,  contributor ) ) 
267+ 
268+     const  existingContributor  =  contributorsToAdd . find ( 
269+       ctr  =>  ctr . login  ===  usr . login , 
270+     ) 
271+ 
272+     if  ( existingContributor )  { 
273+       existingContributor . contributions . push ( ...contributor . contributions ) 
274+     }  else  { 
275+       contributorsToAdd . push ( contributor ) 
276+     } 
277+   } ) 
278+ 
279+   info ( 'Looking at commit authors' ) 
255280  commitAuthors . forEach ( usr  =>  { 
256281    const  existingContributor  =  contributorsToAdd . find ( 
257282      ctr  =>  ctr . login  ===  usr . login , 
258283    ) 
259284
260285    if  ( existingContributor )  { 
261-       // There's no label or  commit message info so use only code for now  
286+       // TODO: See how the  commit message could be added (this may require the full output) to not just assume it's a code contribution  
262287      if  ( ! existingContributor . contributions . includes ( 'code' ) )  { 
263288        existingContributor . contributions . push ( 'code' ) 
264289      } 
@@ -269,8 +294,12 @@ async function fetchContributors(argv) {
269294
270295  // TODO: Roll onto other contribution categories following https://www.draw.io/#G1uL9saIuZl3rj8sOo9xsLOPByAe28qhwa 
271296
297+   info ( 'Finalising' ) 
272298  for  ( const  contributor  of  contributorsToAdd )  { 
273-     if  ( ! contributor . contributions . length )  { 
299+     const  isDependabotDuplicates  =  / d e p e n d a b o t ( \[ b o t \] | - \w + ) / . test ( 
300+       contributor . login , 
301+     ) 
302+     if  ( ! contributor . contributions . length  ||  isDependabotDuplicates )  { 
274303      console . log ( 'Skipping' ,  contributor . login ) 
275304
276305      continue 
@@ -280,7 +309,7 @@ async function fetchContributors(argv) {
280309    const  contributions  =  contributor . contributions . join ( '/' ) 
281310
282311    console . log ( 
283-       `Adding ${ chalk . blue ( contributor . login ) } ${ chalk . underline (  
312+       `Adding ${ use ( 'info' ,   contributor . login ) } ${ chalk . underline (  
284313        contributions ,  
285314      ) }  `, 
286315    ) 
@@ -292,7 +321,7 @@ async function fetchContributors(argv) {
292321      await  addContribution ( args ) 
293322    }  catch  ( error )  { 
294323      console . error ( 
295-         `Adding ${ chalk . blue ( contributor . login ) } ${ chalk . underline (  
324+         `Adding ${ use ( 'info' ,   contributor . login ) } ${ chalk . underline (  
296325          contributions ,  
297326        ) }   Failed: ${ JSON . stringify ( error ) } , 
298327      ) 
0 commit comments