Previously, when one wanted to try out the changes from a PR before it was merged, they had to check out the PR locally and build the Angular packages themselves (which is time-consuming and wasteful given that the packages have already been built on CI). This commit persists all Angular packages on each build as `.tgz` files, which can be used to install dependencies on an project (supported by both [npm][1] and [yarn][2]). In addition to individual `.tgz` files for each package, a `.tgz` file including all packages is also stored, which can be used to test the packages locally by overwriting the ones in the `node_modules/` directory of a project. CircleCI [build artifacts][3] an be used for longer-term storage of the outputs of a build and are designed to be useful around the time of the build, which suits our needs. [1]: https://docs.npmjs.com/cli/install.html [2]: https://yarnpkg.com/lang/en/docs/cli/add [3]: https://circleci.com/docs/2.0/artifacts PR Close #33321
		
			
				
	
	
		
			38 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			38 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
| #!/usr/bin/env bash
 | |
| 
 | |
| set -eu -o pipefail
 | |
| 
 | |
| readonly prNumber="$1"
 | |
| readonly prLastSha="${2:0:7}"
 | |
| readonly inputDir="$PROJECT_ROOT/$3"
 | |
| readonly outputDir="$PROJECT_ROOT/$4"
 | |
| readonly fileSuffix="-pr$prNumber-$prLastSha.tgz"
 | |
| 
 | |
| echo "Creating compressed archives for packages in '$inputDir'."
 | |
| 
 | |
| # Create or clean-up the output directory.
 | |
| echo "  Preparing output directory: $outputDir"
 | |
| rm -rf "$outputDir"
 | |
| mkdir -p "$outputDir"
 | |
| 
 | |
| # Create a compressed archive containing all packages.
 | |
| # (This is useful for copying all packages into `node_modules/` (without changing `package.json`).)
 | |
| outputFileName=all$fileSuffix
 | |
| echo "  Creating archive with all packages --> '$outputFileName'..."
 | |
| tar --create --gzip --directory "$inputDir" --file "$outputDir/$outputFileName" --transform s/^\./packages/ .
 | |
| 
 | |
| # Create a compressed archive for each package.
 | |
| # (This is useful for referencing the path/URL to the resulting archive in `package.json`.)
 | |
| for dir in $inputDir/*
 | |
| do
 | |
|   packageName=`basename "$dir"`
 | |
|   outputFileName="$packageName$fileSuffix"
 | |
|   outputFilePath="$outputDir/$outputFileName"
 | |
| 
 | |
|   echo "  Processing package '$packageName' --> '$outputFileName'..."
 | |
| 
 | |
|   tar --create --gzip --directory "$dir" --file "$outputFilePath" --transform s/^\./package/ .
 | |
| done
 | |
| 
 | |
| echo "Done creating compressed archives."
 |