| 
									
										
										
										
											2020-08-26 13:49:43 -07:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @license | 
					
						
							|  |  |  |  * Copyright Google LLC All Rights Reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Use of this source code is governed by an MIT-style license that can be | 
					
						
							|  |  |  |  * found in the LICENSE file at https://angular.io/license
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-01 16:06:56 -07:00
										 |  |  | import {GitClient} from '../../utils/git/index'; | 
					
						
							| 
									
										
										
										
											2020-08-26 13:49:43 -07:00
										 |  |  | import {getCaretakerConfig} from '../config'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-14 11:24:15 -07:00
										 |  |  | import {CiModule} from './ci'; | 
					
						
							|  |  |  | import {G3Module} from './g3'; | 
					
						
							|  |  |  | import {GithubQueriesModule} from './github'; | 
					
						
							|  |  |  | import {ServicesModule} from './services'; | 
					
						
							| 
									
										
										
										
											2020-08-26 13:49:43 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-14 11:24:15 -07:00
										 |  |  | /** List of modules checked for the caretaker check command. */ | 
					
						
							|  |  |  | const moduleList = [ | 
					
						
							|  |  |  |   GithubQueriesModule, | 
					
						
							|  |  |  |   ServicesModule, | 
					
						
							|  |  |  |   CiModule, | 
					
						
							|  |  |  |   G3Module, | 
					
						
							|  |  |  | ]; | 
					
						
							| 
									
										
										
										
											2020-08-26 13:49:43 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | /** Check the status of services which Angular caretakers need to monitor. */ | 
					
						
							|  |  |  | export async function checkServiceStatuses(githubToken: string) { | 
					
						
							|  |  |  |   /** The configuration for the caretaker commands. */ | 
					
						
							|  |  |  |   const config = getCaretakerConfig(); | 
					
						
							|  |  |  |   /** The GitClient for interacting with git and Github. */ | 
					
						
							|  |  |  |   const git = new GitClient(githubToken, config); | 
					
						
							| 
									
										
										
										
											2020-10-28 10:22:15 -07:00
										 |  |  |   // Prevent logging of the git commands being executed during the check.
 | 
					
						
							|  |  |  |   GitClient.LOG_COMMANDS = false; | 
					
						
							| 
									
										
										
										
											2020-09-14 11:24:15 -07:00
										 |  |  |   /** List of instances of Caretaker Check modules */ | 
					
						
							|  |  |  |   const caretakerCheckModules = moduleList.map(module => new module(git, config)); | 
					
						
							| 
									
										
										
										
											2020-08-26 13:49:43 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-14 11:24:15 -07:00
										 |  |  |   // Module's `data` is casted as Promise<unknown> because the data types of the `module`'s `data`
 | 
					
						
							|  |  |  |   // promises do not match typings, however our usage here is only to determine when the promise
 | 
					
						
							|  |  |  |   // resolves.
 | 
					
						
							|  |  |  |   await Promise.all(caretakerCheckModules.map(module => module.data as Promise<unknown>)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   for (const module of caretakerCheckModules) { | 
					
						
							|  |  |  |     await module.printToTerminal(); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2020-08-26 13:49:43 -07:00
										 |  |  | } |