@@ -15,7 +15,7 @@ import {
1515 restoreNgTokenFromDiskIfValid ,
1616} from '../auth/shared/ng-dev-token.js' ;
1717import { assertValidGithubConfig , getConfig } from './config.js' ;
18- import { addGithubTokenOption } from './git/github-yargs.js' ;
18+ import { configureGitClientWithTokenOrFromEnvironment } from './git/github-yargs.js' ;
1919import { Log } from './logging.js' ;
2020
2121/** Configuration for the firebase application used for ng-dev token management. */
@@ -48,15 +48,19 @@ export async function useNgDevService<T>(
4848 }
4949
5050 return (
51- addGithubTokenOption ( argv )
51+ argv
5252 // TODO(josephperrott): remove once stability is validated.
5353 . option ( 'github-escape-hatch' as 'githubEscapeHatch' , {
5454 type : 'boolean' ,
55- default : false ,
55+ hidden : true ,
56+ } )
57+ . option ( 'github-token' as 'githubToken' , {
58+ type : 'string' ,
59+ implies : 'github-escape-hatch' ,
5660 hidden : true ,
5761 } )
5862 . middleware (
59- async ( args : Arguments < T & { githubToken : string | null ; githubEscapeHatch : boolean } > ) => {
63+ async ( args : Arguments < T & { githubToken ? : string ; githubEscapeHatch ? : boolean } > ) => {
6064 // TODO(josephperrott): remove this guard against running multiple times after
6165 // https://github.com/yargs/yargs/issues/2223 is fixed
6266 if ( ngDevServiceMiddlewareHasRun ) {
@@ -67,17 +71,17 @@ export async function useNgDevService<T>(
6771 initializeApp ( firebaseConfig ) ;
6872 await restoreNgTokenFromDiskIfValid ( ) ;
6973
70- if ( args . githubEscapeHatch === true ) {
71- Log . warn ( 'This escape hatch should only be used if the service is erroring. Please' ) ;
72- Log . warn (
73- 'inform #dev-infra of the need to use this escape hatch so it can be triaged.' ,
74- ) ;
74+ if ( isAuthCommand ) {
75+ Log . debug ( 'Skipping ng-dev token request as this is an auth command' ) ;
7576 return ;
7677 }
77- args . githubToken = null ;
7878
79- if ( isAuthCommand ) {
80- Log . debug ( 'Skipping ng-dev token request as this is an auth command' ) ;
79+ if ( args . githubEscapeHatch === true ) {
80+ // Use the configuration helper to set up the GithubClient using the provided auth
81+ // token or environment.
82+ configureGitClientWithTokenOrFromEnvironment ( args . githubToken ) ;
83+ Log . warn ( 'This escape hatch should only be used if the service is erroring. Please' ) ;
84+ Log . warn ( 'inform #dev-infra of using this escape hatch so it can be triaged.' ) ;
8185 return ;
8286 }
8387
0 commit comments