| 
									
										
										
										
											2021-12-14 08:43:46 -08:00
										 |  |  | // Copyright 2021 Signal Messenger, LLC
 | 
					
						
							|  |  |  | // SPDX-License-Identifier: AGPL-3.0-only
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import { execSync } from 'child_process'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-27 14:01:06 -07:00
										 |  |  | const { SMARTLING_USER, SMARTLING_SECRET } = process.env; | 
					
						
							| 
									
										
										
										
											2021-12-14 08:43:46 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-27 14:01:06 -07:00
										 |  |  | if (!SMARTLING_USER) { | 
					
						
							|  |  |  |   console.error('Need to set SMARTLING_USER environment variable!'); | 
					
						
							|  |  |  |   process.exit(1); | 
					
						
							| 
									
										
										
										
											2022-08-03 14:27:34 -07:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2022-09-27 14:01:06 -07:00
										 |  |  | if (!SMARTLING_SECRET) { | 
					
						
							|  |  |  |   console.error('Need to set SMARTLING_SECRET environment variable!'); | 
					
						
							|  |  |  |   process.exit(1); | 
					
						
							| 
									
										
										
										
											2022-08-03 14:27:34 -07:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2021-12-14 08:43:46 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-27 14:01:06 -07:00
										 |  |  | console.log('Fetching latest strings!'); | 
					
						
							| 
									
										
										
										
											2021-12-14 08:43:46 -08:00
										 |  |  | console.log(); | 
					
						
							| 
									
										
										
										
											2022-09-27 14:01:06 -07:00
										 |  |  | execSync( | 
					
						
							|  |  |  |   'smartling-cli' + | 
					
						
							|  |  |  |     ` --user "${SMARTLING_USER}"` + | 
					
						
							|  |  |  |     ` --secret "${SMARTLING_SECRET}"` + | 
					
						
							|  |  |  |     ' --config .smartling.yml' + | 
					
						
							|  |  |  |     ' --verbose' + | 
					
						
							|  |  |  |     ' --format "_locales/{{.Locale}}/messages.json"' + | 
					
						
							|  |  |  |     ' files pull', | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     stdio: [null, process.stdout, process.stderr], | 
					
						
							| 
									
										
										
										
											2021-12-14 08:43:46 -08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2022-09-27 14:01:06 -07:00
										 |  |  | ); | 
					
						
							| 
									
										
										
										
											2021-12-14 08:43:46 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-27 14:01:06 -07:00
										 |  |  | console.log('Formatting newly-downloaded strings!'); | 
					
						
							|  |  |  | console.log(); | 
					
						
							| 
									
										
										
										
											2022-08-31 20:42:18 -07:00
										 |  |  | execSync('yarn format', { | 
					
						
							|  |  |  |   stdio: [null, process.stdout, process.stderr], | 
					
						
							|  |  |  | }); |