Skip to content

Commit fb8758c

Browse files
jelbournkara
authored andcommitted
chore: simplify ivy/install-angular.sh
1 parent 8b76362 commit fb8758c

File tree

1 file changed

+24
-45
lines changed

1 file changed

+24
-45
lines changed

scripts/ivy/install-angular.sh

Lines changed: 24 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,66 +3,45 @@
33
set -e
44

55

6-
function prep() {
7-
echo ">>> Preparing node_modules"
6+
function clear_existing_angular_install() {
7+
echo ">>> clearing existing @angular packages in node_modules"
88
chmod -R u+w node_modules/@angular
99
rm -rf node_modules/@angular/*
1010
}
1111

12-
function buildNgPackages() {
13-
# Different operating systems have different bazel-bin paths; we want to grab that
14-
# platform portion to read the packages from angular/angular. macOS is "darwin", Linux is "k8",
15-
# and Windows is "x64_windows"
16-
bazel_fastbuild_dir=$(bazel info bazel-bin | egrep -o "/\w+-fastbuild/")
17-
18-
ngDir=$1
19-
echo ">>> Building @angular packages (from $ngDir)"
20-
pushd $ngDir
21-
yarn bazel build --define=compile=aot //packages/{animations,common,compiler,compiler-cli,core,elements,forms,platform-browser,platform-browser-dynamic,router,upgrade}:npm_package
22-
outputPath=`yarn bazel info 2>&1 | grep output_path | cut -d ':' -f 2 | cut -c 2-`${bazel_fastbuild_dir}bin/packages
12+
function build_angular_packages() {
13+
angular_repo_dir=$1
14+
echo ">>> Building @angular packages (from ${angular_repo_dir})"
15+
pushd ${angular_repo_dir}
16+
yarn bazel build --config=release --define=compile=aot //packages/{animations,common,compiler,compiler-cli,core,elements,forms,platform-browser,platform-browser-dynamic,router,upgrade}:npm_package
17+
output_path=$(yarn --silent bazel info bazel-bin 2>/dev/null)/packages
2318
popd
2419
}
2520

26-
function installNgPackage() {
21+
function install_angular_package() {
2722
name=$1
2823
echo " @angular/$name"
29-
cp -r $outputPath/$name/npm_package node_modules/@angular/$name
24+
cp -r "${output_path}/${name}/npm_package" "node_modules/@angular/${name}"
3025
}
3126

32-
function buildPackage() {
33-
name=$1
34-
echo " $name"
35-
36-
# First, fix the build definition.
37-
# Update the tsconfig to compile from index.ts instead of public-api.ts, and turn on Ivy options.
38-
node scripts/ivy/fix-tsconfig.js src/$name/tsconfig-build.json
39-
40-
# If no index.ts exists, rename public-api.ts.
41-
if [ ! -f src/$name/index.ts -a -f src/$name/public-api.ts ]
42-
then
43-
mv src/$name/public-api.ts src/$name/index.ts
44-
fi
45-
46-
node_modules/.bin/ngc -p src/$name/tsconfig-build.json
47-
}
4827

49-
if [ "$1" != "" ]
28+
if [[ "$1" != "" ]]
5029
then
51-
prep
52-
buildNgPackages $1
30+
clear_existing_angular_install
31+
build_angular_packages $1
5332

5433
echo ">>> Installing @angular packages"
55-
installNgPackage "animations"
56-
installNgPackage "common"
57-
installNgPackage "compiler"
58-
installNgPackage "compiler-cli"
59-
installNgPackage "core"
60-
installNgPackage "elements"
61-
installNgPackage "forms"
62-
installNgPackage "platform-browser"
63-
installNgPackage "platform-browser-dynamic"
64-
installNgPackage "router"
65-
installNgPackage "upgrade"
34+
install_angular_package "animations"
35+
install_angular_package "common"
36+
install_angular_package "compiler"
37+
install_angular_package "compiler-cli"
38+
install_angular_package "core"
39+
install_angular_package "elements"
40+
install_angular_package "forms"
41+
install_angular_package "platform-browser"
42+
install_angular_package "platform-browser-dynamic"
43+
install_angular_package "router"
44+
install_angular_package "upgrade"
6645

6746
chmod -R u+w node_modules/@angular
6847
else

0 commit comments

Comments
 (0)