2525
2626import * as Octokit from "@octokit/rest" ;
2727import * as fs from "fs" ;
28+ import * as os from "os" ;
29+ import * as path from "path" ;
2830
2931import { camelize } from "../lib/utils" ;
3032
33+ // ignores TLS certificate error
34+ // process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
35+
36+ const tokenFile = path . join ( os . homedir ( ) , "github_token.txt" ) ;
37+ const authToken = fs
38+ . readFileSync ( tokenFile , "utf8" )
39+ . toString ( )
40+ . trim ( ) ;
41+ console . log ( `Using OAuth token ${ authToken } \n` ) ;
42+
3143const octokit = new Octokit ( {
44+ auth : authToken ,
3245 host : "api.github.com" ,
3346 protocol : "https" ,
3447 request : {
35- timeout : 5000
36- }
48+ timeout : 5000 ,
49+ } ,
3750} ) ;
3851
3952const repoInfo = {
@@ -45,7 +58,7 @@ const commitList: ICommit[] = [];
4558octokit . repos
4659 . getLatestRelease ( repoInfo )
4760 . then ( ( { data : { tag_name } } ) => {
48- console . log ( " Getting commits " + tag_name + " ..master" ) ;
61+ console . log ( ` Getting commits ${ tag_name } ..master` ) ;
4962 // get the commits between the most recent release and the head of master
5063 return octokit . repos . compareCommits ( {
5164 base : tag_name ,
@@ -61,7 +74,7 @@ octokit.repos
6174 fields : [ ] ,
6275 sha : commitInfo . sha ,
6376 submitter :
64- commitInfo . commit . author . name != null
77+ commitInfo . commit . author . name !== null
6578 ? commitInfo . commit . author . name
6679 : commitInfo . author . login ,
6780 title : commitInfo . commit . message ,
@@ -88,7 +101,7 @@ octokit.repos
88101 if ( fieldMatch ) {
89102 commit . fields . push ( {
90103 tag : fieldMatch [ 1 ] ,
91- text : addLinks ( line ) + " (#" + commit . pushRequestNum + ")" ,
104+ text : ` ${ addLinks ( line ) } (# ${ commit . pushRequestNum } )` ,
92105 } ) ;
93106 }
94107 }
@@ -114,28 +127,26 @@ octokit.repos
114127 }
115128 contributors . add ( commit . submitter ) ;
116129 }
117- entries . sort ( ( a , b ) => {
118- return a . tag . localeCompare ( b . tag ) ;
119- } ) ;
130+ entries . sort ( ( a , b ) => a . tag . localeCompare ( b . tag ) ) ;
120131
121132 console . log ( "\n---- formatted changelog entries: ----" ) ;
122133 for ( const entry of entries ) {
123- console . log ( "- " + entry . text ) ;
134+ console . log ( `- ${ entry . text } ` ) ;
124135 }
125136
126137 console . log ( "\n---- PRs with missing changelog entries: ----" ) ;
127138 for ( const missing of noFields ) {
128- console . log ( "- " + missing . replace ( / [ \r \n ] + / , "\r\n " ) ) ;
139+ console . log ( `- ${ missing . replace ( / [ \r \n ] + / , "\r\n " ) } ` ) ;
129140 }
130141
131142 console . log ( "\n---- thanks ----" ) ;
132143 console . log ( "Thanks to our contributors!" ) ;
133144 contributors . forEach ( contributor => {
134- console . log ( "- " + contributor ) ;
145+ console . log ( `- ${ contributor } ` ) ;
135146 } ) ;
136147 } )
137148 . catch ( error => {
138- console . log ( " Error:" + error ) ;
149+ console . log ( ` Error: ${ error } ` ) ;
139150 } ) ;
140151
141152const cache = new Map < string , boolean > ( ) ;
@@ -158,9 +169,9 @@ function addLinks(text: string): string {
158169 let match = regex . exec ( text ) ;
159170 while ( match !== null ) {
160171 if ( isRule ( match [ 1 ] ) ) {
161- result +=
162- text . slice ( lastIndex , match . index ) +
163- `[ ${ match [ 0 ] } ](https://palantir.github.io/tslint/rules/${ match [ 1 ] } /)`;
172+ result += ` ${ text . slice ( lastIndex , match . index ) } [ ${
173+ match [ 0 ]
174+ } ](https://palantir.github.io/tslint/rules/${ match [ 1 ] } /)`;
164175 lastIndex = regex . lastIndex ;
165176 }
166177 match = regex . exec ( text ) ;
0 commit comments