deploy.sh 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #!/usr/bin/env bash
  2. set -e
  3. GH=false
  4. DAY_RELEASE=false
  5. for ARG in "$@"; do
  6. case "$ARG" in
  7. -gh)
  8. GH=true
  9. ;;
  10. -dr)
  11. DAY_RELEASE=true
  12. ;;
  13. esac
  14. done
  15. cd $(dirname $0)/../..
  16. ROOT_DIR="$(pwd)"
  17. DIST_DIR="$(pwd)/dist"
  18. VERSION=$(node -p "require('./package.json').version")
  19. echo "Start build version: ${VERSION}"
  20. echo ""
  21. echo "Generate color less"
  22. echo ""
  23. node ./scripts/color-less.js
  24. echo '===== need mock'
  25. sed -i "s/const MOCK_MODULES = !environment.production/const MOCK_MODULES = true/g" ${ROOT_DIR}/src/app/delon.module.ts
  26. sed -i "s/if (!environment.production)/if (true)/g" ${ROOT_DIR}/src/app/layout/default/default.component.ts
  27. if [[ ${DAY_RELEASE} == true ]]; then
  28. NG_ALAIN_VERSION=$(node -p "require('./node_modules/ng-alain/package.json').version")
  29. echo "Current ng-alain version: ${NG_ALAIN_VERSION}"
  30. echo ""
  31. echo "Day Build, Muse be download @delon build packages"
  32. git clone --depth 1 https://github.com/ng-alain/delon-builds.git
  33. rm -rf node_modules/@delon
  34. rm -rf node_modules/ng-alain
  35. echo "Copies"
  36. rsync -am delon-builds/ node_modules/
  37. NG_ALAIN_VERSION=$(node -p "require('./node_modules/ng-alain/package.json').version")
  38. echo "After ng-alain version: ${NG_ALAIN_VERSION}"
  39. fi
  40. echo ""
  41. echo "Build angular"
  42. echo ""
  43. if [[ ${GH} == true ]]; then
  44. $(npm bin)/ng build --prod --build-optimizer --base-href /ng-alain/
  45. else
  46. $(npm bin)/ng build --prod --build-optimizer
  47. fi
  48. cp -f ${DIST_DIR}/index.html ${DIST_DIR}/404.html
  49. if [[ ${GH} == true ]]; then
  50. commitAuthorName=$(git --no-pager show -s --format='%an' HEAD)
  51. if [[ ${commitAuthorName} != 'cipchk' ]] && [[ ${commitAuthorName} != '卡色' ]]; then
  52. echo "Warning: Just only cipchk or 卡色 user (current: ${commitAuthorName})"
  53. exit 0
  54. fi
  55. if [ -z ${NG_ALAIN_BUILDS_TOKEN} ]; then
  56. echo "Error: No access token for GitHub could be found." \
  57. "Please set the environment variable 'NG_ALAIN_BUILDS_TOKEN'."
  58. exit 0
  59. fi
  60. echo ""
  61. echo "Deploy by gh-pages"
  62. echo ""
  63. $(npm bin)/gh-pages -d dist -r "https://${NG_ALAIN_BUILDS_TOKEN}@github.com/ng-alain/ng-alain.git"
  64. fi
  65. echo "Finished"