"use strict" ; import { GitHubClient } from "./github" ; import { formatMessage , sleep } from "./utils" ; const githubToken = process . env . GITHUB_TOKEN ; const githubRepository = process . env . GITHUB_REPOSITORY || "Microsoft/TypeScript" ; /**
 * This is the main entry point for the program, and is invoked
 * at the bottom of this file.
 */ async function main ( ) { try { let parts = githubRepository . split ( "/" ) ; let owner = parts [ 0 ] ; let repo = parts [ 1 ] ; let github = new GitHubClient ( { token : githubToken } ) ; await printRecentPullRequests ( github , owner , repo ) ; } catch ( e ) { console . error ( e . stack ) ; process . exit ( - 1 ) ; } } param github param owner param repo returns async function printRecentPullRequests ( github , owner , repo ) { let pullRequests = await github . listPullRequests ( owner , repo , { per_page : 5 } ) ; console . log ( `Last ${ pullRequests . length } pull request(s):` ) ; for ( let pullRequest of pullRequests ) { console . log ( `  #${ pullRequest . number } ${ pullRequest . title . trim ( ) } - @${ pullRequest . user . login }` ) ; console . log ( `    [${ pullRequest . html_url }]` ) ; console . log ( ) ; let commits = await github . listPullRequestCommits ( owner , repo , pullRequest . number , { per_page : 5 } ) ; console . log ( `    Last ${ commits . length } commit(s):` ) ; for ( let commit of commits ) { let author = commit . author ? commit . author . login : commit . committer ? commit . committer . login : commit . commit . author ? commit . commit . author . name : commit . commit . committer ? commit . commit . committer . name : "unknown" ; let message = formatMessage ( commit . commit . message , 60 , 100 ) ; let firstLine = message . shift ( ) ; console . log ( `      ${ commit . sha . substr ( 0 , 8 ) } ${ firstLine }${ message . length > 0 ? "..." : "" } - @${ author } on ${ commit . commit . author . date }` ) ; if ( message . length > 0 ) { for ( let line of message ) { console . log ( `        | ${ line }` ) ; } console . log ( ) ; } } console . log ( ) ; let comments = await github . listPullRequestComments ( owner , repo , pullRequest . number , { per_page : 5 } ) ; if ( comments . length ) { console . log ( `    Last ${ comments . length } comment(s):` ) ; for ( let comment of comments ) { console . log ( `      @${ comment . user . login } commented on ${ comment . commit_id . substr ( 0 , 8 ) } at ${ comment . created_at }:` ) ; for ( let line of formatMessage ( comment . body , 100 ) ) { console . log ( `        | ${ line }` ) ; } console . log ( ) ; } console . log ( ) ; } } } main ( ) ;