| 
									
										
										
										
											2020-03-04 09:42:45 -08:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @license | 
					
						
							| 
									
										
										
										
											2020-05-19 12:08:49 -07:00
										 |  |  |  * Copyright Google LLC All Rights Reserved. | 
					
						
							| 
									
										
										
										
											2020-03-04 09:42:45 -08:00
										 |  |  |  * | 
					
						
							|  |  |  |  * 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
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 'use strict'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-05 19:05:54 +03:00
										 |  |  | const {resolve} = require('path'); | 
					
						
							|  |  |  | const {chmod, cp, mkdir, rm, test} = require('shelljs'); | 
					
						
							| 
									
										
										
										
											2020-03-04 09:42:45 -08:00
										 |  |  | const {baseDir, bazelBin, bazelCmd, exec, scriptPath} = require('./package-builder'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-05 19:05:54 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | module.exports = { | 
					
						
							|  |  |  |   buildDevInfraPackage, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-04 09:42:45 -08:00
										 |  |  | /** | 
					
						
							| 
									
										
										
										
											2021-04-05 19:05:54 +03:00
										 |  |  |  * Build the `@angular/dev-infra-private` npm package into `destDir`. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @param {string} destDir Path to the output directory into which we copy the npm package. | 
					
						
							|  |  |  |  *     This path should either be absolute or relative to the project root. | 
					
						
							| 
									
										
										
										
											2020-03-04 09:42:45 -08:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2021-04-05 19:05:54 +03:00
										 |  |  | function buildDevInfraPackage(destDir) { | 
					
						
							| 
									
										
										
										
											2020-03-04 09:42:45 -08:00
										 |  |  |   console.info('##############################'); | 
					
						
							|  |  |  |   console.info(`${scriptPath}:`); | 
					
						
							|  |  |  |   console.info('  Building @angular/dev-infra-private npm package'); | 
					
						
							|  |  |  |   console.info('##############################'); | 
					
						
							|  |  |  |   exec(`${bazelCmd} build //dev-infra:npm_package`); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-05 19:05:54 +03:00
										 |  |  |   // Create the output directory.
 | 
					
						
							|  |  |  |   const absDestDir = resolve(baseDir, destDir); | 
					
						
							|  |  |  |   if (!test('-d', absDestDir)) { | 
					
						
							|  |  |  |     mkdir('-p', absDestDir); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-04 09:42:45 -08:00
										 |  |  |   const buildOutputDir = `${bazelBin}/dev-infra/npm_package`; | 
					
						
							| 
									
										
										
										
											2021-04-05 19:05:54 +03:00
										 |  |  |   const distTargetDir = `${absDestDir}/dev-infra-private`; | 
					
						
							| 
									
										
										
										
											2020-03-04 09:42:45 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   console.info(`# Copy artifacts to ${distTargetDir}`); | 
					
						
							|  |  |  |   rm('-rf', distTargetDir); | 
					
						
							|  |  |  |   cp('-R', buildOutputDir, distTargetDir); | 
					
						
							|  |  |  |   chmod('-R', 'u+w', distTargetDir); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   console.info(''); | 
					
						
							|  |  |  | } |