2016-04-28 20:50:03 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -e -o pipefail
|
|
|
|
|
|
|
|
cd `dirname $0`
|
|
|
|
|
2016-09-13 12:49:23 -04:00
|
|
|
PACKAGES=(core
|
|
|
|
compiler
|
|
|
|
common
|
|
|
|
forms
|
|
|
|
platform-browser
|
|
|
|
platform-browser-dynamic
|
|
|
|
platform-server
|
|
|
|
platform-webworker
|
|
|
|
platform-webworker-dynamic
|
|
|
|
http
|
|
|
|
upgrade
|
2016-11-09 16:33:33 -05:00
|
|
|
router
|
2016-09-13 12:49:23 -04:00
|
|
|
compiler-cli
|
2016-11-22 12:10:23 -05:00
|
|
|
language-service
|
2016-09-13 12:49:23 -04:00
|
|
|
benchpress)
|
|
|
|
BUILD_ALL=true
|
|
|
|
BUNDLE=true
|
2016-11-18 12:24:57 -05:00
|
|
|
VERSION_PREFIX=$(node -p "require('./package.json').version")
|
|
|
|
VERSION_SUFFIX="-$(git log --oneline -1 | awk '{print $1}')"
|
|
|
|
ROUTER_VERSION_PREFIX=$(node -p "require('./package.json').version.replace(/^2/, '3')")
|
|
|
|
REMOVE_BENCHPRESS=false
|
2016-09-13 12:49:23 -04:00
|
|
|
|
|
|
|
for ARG in "$@"; do
|
|
|
|
case "$ARG" in
|
|
|
|
--packages=*)
|
|
|
|
PACKAGES_STR=${ARG#--packages=}
|
|
|
|
PACKAGES=( ${PACKAGES_STR//,/ } )
|
|
|
|
BUILD_ALL=false
|
|
|
|
;;
|
|
|
|
--bundle=*)
|
|
|
|
BUNDLE=( "${ARG#--bundle=}" )
|
|
|
|
;;
|
2016-11-18 12:24:57 -05:00
|
|
|
--publish)
|
|
|
|
VERSION_SUFFIX=""
|
|
|
|
REMOVE_BENCHPRESS=true
|
|
|
|
;;
|
2016-09-13 12:49:23 -04:00
|
|
|
*)
|
|
|
|
echo "Unknown option $ARG."
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2016-05-02 01:54:19 -04:00
|
|
|
|
2016-11-18 12:24:57 -05:00
|
|
|
VERSION="${VERSION_PREFIX}${VERSION_SUFFIX}"
|
|
|
|
ROUTER_VERSION="${ROUTER_VERSION_PREFIX}${VERSION_SUFFIX}"
|
|
|
|
echo "====== BUILDING: Version ${VERSION} (Router ${ROUTER_VERSION})"
|
|
|
|
|
2016-09-13 12:49:23 -04:00
|
|
|
export NODE_PATH=${NODE_PATH}:$(pwd)/dist/all:$(pwd)/dist/tools
|
|
|
|
TSC="node --max-old-space-size=3000 dist/tools/@angular/tsc-wrapped/src/main"
|
|
|
|
UGLIFYJS=`pwd`/node_modules/.bin/uglifyjs
|
2016-05-19 18:28:25 -04:00
|
|
|
TSCONFIG=./tools/tsconfig.json
|
2016-09-13 12:49:23 -04:00
|
|
|
echo "====== (tools)COMPILING: \$(npm bin)/tsc -p ${TSCONFIG} ====="
|
|
|
|
rm -rf ./dist/tools/
|
|
|
|
mkdir -p ./dist/tools/
|
2016-05-19 18:28:25 -04:00
|
|
|
$(npm bin)/tsc -p ${TSCONFIG}
|
2016-09-13 12:49:23 -04:00
|
|
|
|
2016-05-31 13:43:21 -04:00
|
|
|
cp ./tools/@angular/tsc-wrapped/package.json ./dist/tools/@angular/tsc-wrapped
|
2016-05-19 18:28:25 -04:00
|
|
|
|
2016-09-13 12:49:23 -04:00
|
|
|
if [[ ${BUILD_ALL} == true ]]; then
|
|
|
|
rm -rf ./dist/all/
|
|
|
|
mkdir -p ./dist/all/
|
|
|
|
|
|
|
|
echo "====== Copying files needed for e2e tests ====="
|
|
|
|
cp -r ./modules/playground ./dist/all/
|
|
|
|
cp -r ./modules/playground/favicon.ico ./dist/
|
|
|
|
#rsync -aP ./modules/playground/* ./dist/all/playground/
|
|
|
|
mkdir ./dist/all/playground/vendor
|
|
|
|
cd ./dist/all/playground/vendor
|
|
|
|
ln -s ../../../../node_modules/core-js/client/core.js .
|
|
|
|
ln -s ../../../../node_modules/zone.js/dist/zone.js .
|
|
|
|
ln -s ../../../../node_modules/zone.js/dist/long-stack-trace-zone.js .
|
|
|
|
ln -s ../../../../node_modules/systemjs/dist/system.src.js .
|
2016-11-02 16:20:46 -04:00
|
|
|
ln -s ../../../../node_modules/base64-js .
|
2016-09-13 12:49:23 -04:00
|
|
|
ln -s ../../../../node_modules/reflect-metadata/Reflect.js .
|
|
|
|
ln -s ../../../../node_modules/rxjs .
|
|
|
|
ln -s ../../../../node_modules/angular/angular.js .
|
2016-10-30 17:25:42 -04:00
|
|
|
ln -s ../../../../node_modules/hammerjs/hammer.js .
|
2016-09-13 12:49:23 -04:00
|
|
|
cd -
|
|
|
|
|
|
|
|
echo "====== Copying files needed for benchmarks ====="
|
|
|
|
cp -r ./modules/benchmarks ./dist/all/
|
|
|
|
cp -r ./modules/benchmarks/favicon.ico ./dist/
|
|
|
|
mkdir ./dist/all/benchmarks/vendor
|
|
|
|
cd ./dist/all/benchmarks/vendor
|
|
|
|
ln -s ../../../../node_modules/core-js/client/core.js .
|
|
|
|
ln -s ../../../../node_modules/zone.js/dist/zone.js .
|
|
|
|
ln -s ../../../../node_modules/zone.js/dist/long-stack-trace-zone.js .
|
|
|
|
ln -s ../../../../node_modules/systemjs/dist/system.src.js .
|
|
|
|
ln -s ../../../../node_modules/reflect-metadata/Reflect.js .
|
|
|
|
ln -s ../../../../node_modules/rxjs .
|
|
|
|
ln -s ../../../../node_modules/angular/angular.js .
|
|
|
|
ln -s ../../../../bower_components/polymer .
|
|
|
|
ln -s ../../../../node_modules/incremental-dom/dist/incremental-dom-cjs.js
|
|
|
|
cd -
|
|
|
|
|
|
|
|
TSCONFIG=./modules/tsconfig.json
|
|
|
|
echo "====== (all)COMPILING: \$(npm bin)/tsc -p ${TSCONFIG} ====="
|
|
|
|
# compile ts code
|
|
|
|
$TSC -p modules/tsconfig.json
|
|
|
|
|
|
|
|
rm -rf ./dist/packages-dist
|
|
|
|
fi
|
|
|
|
|
|
|
|
for PACKAGE in ${PACKAGES[@]}
|
2016-04-28 20:50:03 -04:00
|
|
|
do
|
2016-08-30 21:07:40 -04:00
|
|
|
PWD=`pwd`
|
|
|
|
SRCDIR=${PWD}/modules/@angular/${PACKAGE}
|
|
|
|
DESTDIR=${PWD}/dist/packages-dist/${PACKAGE}
|
2016-05-20 12:08:39 -04:00
|
|
|
UMD_ES5_PATH=${DESTDIR}/bundles/${PACKAGE}.umd.js
|
2016-08-30 21:07:40 -04:00
|
|
|
UMD_TESTING_ES5_PATH=${DESTDIR}/bundles/${PACKAGE}-testing.umd.js
|
2016-10-20 22:35:35 -04:00
|
|
|
UMD_STATIC_ES5_PATH=${DESTDIR}/bundles/${PACKAGE}-static.umd.js
|
2016-11-09 16:33:33 -05:00
|
|
|
UMD_UPGRADE_ES5_PATH=${DESTDIR}/bundles/${PACKAGE}-upgrade.umd.js
|
2016-05-20 12:08:39 -04:00
|
|
|
UMD_ES5_MIN_PATH=${DESTDIR}/bundles/${PACKAGE}.umd.min.js
|
2016-10-20 22:35:35 -04:00
|
|
|
UMD_STATIC_ES5_MIN_PATH=${DESTDIR}/bundles/${PACKAGE}-static.umd.min.js
|
2016-11-09 16:33:33 -05:00
|
|
|
UMD_UPGRADE_ES5_MIN_PATH=${DESTDIR}/bundles/${PACKAGE}-upgrade.umd.min.js
|
2016-11-16 12:17:19 -05:00
|
|
|
|
|
|
|
if [[ ${PACKAGE} != router ]]; then
|
|
|
|
LICENSE_BANNER=${PWD}/modules/@angular/license-banner.txt
|
|
|
|
fi
|
|
|
|
if [[ ${PACKAGE} == router ]]; then
|
|
|
|
LICENSE_BANNER=${PWD}/modules/@angular/router-license-banner.txt
|
|
|
|
fi
|
2016-04-28 20:50:03 -04:00
|
|
|
|
2016-09-13 12:49:23 -04:00
|
|
|
rm -rf ${DESTDIR}
|
|
|
|
|
2016-09-14 10:40:58 -04:00
|
|
|
echo "====== COMPILING: ${TSC} -p ${SRCDIR}/tsconfig-build.json ====="
|
2016-09-08 18:01:22 -04:00
|
|
|
$TSC -p ${SRCDIR}/tsconfig-build.json
|
2016-05-03 16:43:35 -04:00
|
|
|
|
2016-11-09 16:33:33 -05:00
|
|
|
if [[ -e ${SRCDIR}/tsconfig-upgrade.json ]]; then
|
|
|
|
echo "====== COMPILING: ${TSC} -p ${SRCDIR}/tsconfig-upgrade.json ====="
|
|
|
|
$TSC -p ${SRCDIR}/tsconfig-upgrade.json
|
|
|
|
fi
|
|
|
|
|
2016-04-28 20:50:03 -04:00
|
|
|
cp ${SRCDIR}/package.json ${DESTDIR}/
|
2016-09-14 20:08:48 -04:00
|
|
|
cp ${PWD}/modules/@angular/README.md ${DESTDIR}/
|
2016-04-28 20:50:03 -04:00
|
|
|
|
2016-08-30 21:07:40 -04:00
|
|
|
if [[ -e ${SRCDIR}/tsconfig-testing.json ]]; then
|
|
|
|
echo "====== COMPILING TESTING: ${TSC} -p ${SRCDIR}/tsconfig-testing.json"
|
|
|
|
$TSC -p ${SRCDIR}/tsconfig-testing.json
|
|
|
|
fi
|
2016-04-28 20:50:03 -04:00
|
|
|
|
|
|
|
echo "====== TSC 1.8 d.ts compat for ${DESTDIR} ====="
|
|
|
|
# safely strips 'readonly' specifier from d.ts files to make them compatible with tsc 1.8
|
2016-06-20 18:25:55 -04:00
|
|
|
if [ "$(uname)" == "Darwin" ]; then
|
2016-08-30 21:07:40 -04:00
|
|
|
find ${DESTDIR} -type f -name '*.d.ts' -print0 | xargs -0 sed -i '' -e 's/\(^ *(static |private )*\)*readonly */\1/g'
|
|
|
|
find ${DESTDIR} -type f -name '*.d.ts' -print0 | xargs -0 sed -i '' -e 's/\/\/\/ <reference types="node" \/>//g'
|
|
|
|
find ${DESTDIR} -type f -name '*.d.ts' -print0 | xargs -0 sed -i '' -E 's/^( +)abstract ([[:alnum:]]+\:)/\1\2/g'
|
2016-04-28 20:50:03 -04:00
|
|
|
else
|
2016-06-20 18:25:55 -04:00
|
|
|
find ${DESTDIR} -type f -name '*.d.ts' -print0 | xargs -0 sed -i -e 's/\(^ *(static |private )*\)*readonly */\1/g'
|
2016-08-30 21:07:40 -04:00
|
|
|
find ${DESTDIR} -type f -name '*.d.ts' -print0 | xargs -0 sed -i -e 's/\/\/\/ <reference types="node" \/>//g'
|
2016-06-20 18:25:55 -04:00
|
|
|
find ${DESTDIR} -type f -name '*.d.ts' -print0 | xargs -0 sed -i -E 's/^( +)abstract ([[:alnum:]]+\:)/\1\2/g'
|
2016-04-28 20:50:03 -04:00
|
|
|
fi
|
|
|
|
|
2016-09-13 12:49:23 -04:00
|
|
|
if [[ ${PACKAGE} == benchpress ]]; then
|
|
|
|
cp ${SRCDIR}/*.md ${DESTDIR}
|
|
|
|
cp -r ${SRCDIR}/docs ${DESTDIR}
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ${BUNDLE} == true && ${PACKAGE} != compiler-cli && ${PACKAGE} != benchpress ]]; then
|
2016-05-03 12:24:09 -04:00
|
|
|
|
|
|
|
echo "====== BUNDLING: ${SRCDIR} ====="
|
2016-05-20 12:08:39 -04:00
|
|
|
mkdir ${DESTDIR}/bundles
|
|
|
|
|
2016-06-21 17:44:36 -04:00
|
|
|
(
|
|
|
|
cd ${SRCDIR}
|
2016-08-30 21:07:40 -04:00
|
|
|
echo "====== Rollup ${PACKAGE} index"
|
2016-06-21 17:44:36 -04:00
|
|
|
../../../node_modules/.bin/rollup -c rollup.config.js
|
2016-08-30 21:07:40 -04:00
|
|
|
cat ${LICENSE_BANNER} > ${UMD_ES5_PATH}.tmp
|
|
|
|
cat ${UMD_ES5_PATH} >> ${UMD_ES5_PATH}.tmp
|
|
|
|
mv ${UMD_ES5_PATH}.tmp ${UMD_ES5_PATH}
|
|
|
|
$UGLIFYJS -c --screw-ie8 --comments -o ${UMD_ES5_MIN_PATH} ${UMD_ES5_PATH}
|
|
|
|
|
|
|
|
if [[ -e rollup-testing.config.js ]]; then
|
|
|
|
echo "====== Rollup ${PACKAGE} testing"
|
|
|
|
../../../node_modules/.bin/rollup -c rollup-testing.config.js
|
|
|
|
echo "{\"main\": \"../bundles/${PACKAGE}-testing.umd.js\"}" > ${DESTDIR}/testing/package.json
|
|
|
|
cat ${LICENSE_BANNER} > ${UMD_TESTING_ES5_PATH}.tmp
|
|
|
|
cat ${UMD_TESTING_ES5_PATH} >> ${UMD_TESTING_ES5_PATH}.tmp
|
|
|
|
mv ${UMD_TESTING_ES5_PATH}.tmp ${UMD_TESTING_ES5_PATH}
|
|
|
|
fi
|
2016-10-20 22:35:35 -04:00
|
|
|
|
|
|
|
if [[ -e rollup-static.config.js ]]; then
|
|
|
|
echo "====== Rollup ${PACKAGE} static"
|
|
|
|
../../../node_modules/.bin/rollup -c rollup-static.config.js
|
|
|
|
# create dir because it doesn't exist yet, we should move the src code here and remove this line
|
|
|
|
mkdir ${DESTDIR}/static
|
|
|
|
echo "{\"main\": \"../bundles/${PACKAGE}-static.umd.js\"}" > ${DESTDIR}/static/package.json
|
|
|
|
cat ${LICENSE_BANNER} > ${UMD_STATIC_ES5_PATH}.tmp
|
|
|
|
cat ${UMD_STATIC_ES5_PATH} >> ${UMD_STATIC_ES5_PATH}.tmp
|
|
|
|
mv ${UMD_STATIC_ES5_PATH}.tmp ${UMD_STATIC_ES5_PATH}
|
|
|
|
$UGLIFYJS -c --screw-ie8 --comments -o ${UMD_STATIC_ES5_MIN_PATH} ${UMD_STATIC_ES5_PATH}
|
|
|
|
fi
|
2016-11-09 16:33:33 -05:00
|
|
|
|
|
|
|
if [[ -e rollup-upgrade.config.js ]]; then
|
|
|
|
echo "====== Rollup ${PACKAGE} upgrade"
|
|
|
|
../../../node_modules/.bin/rollup -c rollup-upgrade.config.js
|
|
|
|
# create dir because it doesn't exist yet, we should move the src code here and remove this line
|
|
|
|
mkdir ${DESTDIR}/upgrade
|
|
|
|
echo "{\"main\": \"../bundles/${PACKAGE}-upgrade.umd.js\"}" > ${DESTDIR}/upgrade/package.json
|
|
|
|
cat ${LICENSE_BANNER} > ${UMD_UPGRADE_ES5_PATH}.tmp
|
|
|
|
cat ${UMD_UPGRADE_ES5_PATH} >> ${UMD_UPGRADE_ES5_PATH}.tmp
|
|
|
|
mv ${UMD_UPGRADE_ES5_PATH}.tmp ${UMD_UPGRADE_ES5_PATH}
|
|
|
|
$UGLIFYJS -c --screw-ie8 --comments -o ${UMD_UPGRADE_ES5_MIN_PATH} ${UMD_UPGRADE_ES5_PATH}
|
|
|
|
fi
|
2016-06-21 17:44:36 -04:00
|
|
|
) 2>&1 | grep -v "as external dependency"
|
2016-05-03 16:43:35 -04:00
|
|
|
fi
|
2016-11-22 16:39:41 -05:00
|
|
|
|
|
|
|
(
|
|
|
|
echo "====== VERSION: Updating version references"
|
|
|
|
cd ${DESTDIR}
|
|
|
|
echo "====== EXECUTE: perl -p -i -e \"s/0\.0\.0\-PLACEHOLDER/${VERSION}/g\" $""(grep -ril 0\.0\.0\-PLACEHOLDER .)"
|
|
|
|
perl -p -i -e "s/0\.0\.0\-PLACEHOLDER/${VERSION}/g" $(grep -ril 0\.0\.0\-PLACEHOLDER .) < /dev/null 2> /dev/null
|
|
|
|
echo "====== EXECUTE: perl -p -i -e \"s/0\.0\.0\-ROUTERPLACEHOLDER/${ROUTER_VERSION}/g\" $""(grep -ril 0\.0\.0\-ROUTERPLACEHOLDER .)"
|
|
|
|
perl -p -i -e "s/0\.0\.0\-ROUTERPLACEHOLDER/${ROUTER_VERSION}/g" $(grep -ril 0\.0\.0\-ROUTERPLACEHOLDER .) < /dev/null 2> /dev/null
|
|
|
|
)
|
2016-04-28 20:50:03 -04:00
|
|
|
done
|
2016-09-07 19:04:33 -04:00
|
|
|
|
2016-11-18 12:24:57 -05:00
|
|
|
echo ""
|
2016-11-15 23:59:32 -05:00
|
|
|
echo "====== Building examples: ./modules/@angular/examples/build.sh ====="
|
2016-09-13 18:58:45 -04:00
|
|
|
./modules/@angular/examples/build.sh
|
2016-11-18 12:24:57 -05:00
|
|
|
|
|
|
|
if [[ ${REMOVE_BENCHPRESS} == true ]]; then
|
|
|
|
echo ""
|
|
|
|
echo "==== Removing benchpress from publication"
|
|
|
|
rm -r dist/packages-dist/benchpress
|
|
|
|
fi
|