|
3 | 3 | set -e
|
4 | 4 |
|
5 | 5 |
|
6 |
| -function prep() { |
7 |
| - echo ">>> Preparing node_modules" |
| 6 | +function clear_existing_angular_install() { |
| 7 | + echo ">>> clearing existing @angular packages in node_modules" |
8 | 8 | chmod -R u+w node_modules/@angular
|
9 | 9 | rm -rf node_modules/@angular/*
|
10 | 10 | }
|
11 | 11 |
|
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 |
23 | 18 | popd
|
24 | 19 | }
|
25 | 20 |
|
26 |
| -function installNgPackage() { |
| 21 | +function install_angular_package() { |
27 | 22 | name=$1
|
28 | 23 | 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}" |
30 | 25 | }
|
31 | 26 |
|
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 |
| -} |
48 | 27 |
|
49 |
| -if [ "$1" != "" ] |
| 28 | +if [[ "$1" != "" ]] |
50 | 29 | then
|
51 |
| - prep |
52 |
| - buildNgPackages $1 |
| 30 | + clear_existing_angular_install |
| 31 | + build_angular_packages $1 |
53 | 32 |
|
54 | 33 | 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" |
66 | 45 |
|
67 | 46 | chmod -R u+w node_modules/@angular
|
68 | 47 | else
|
|
0 commit comments