zap_bootstrap.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/bash
  2. #
  3. # Copyright (c) 2022 Project CHIP Authors
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. #
  17. function _get_fullpath() {
  18. cd "$(dirname "$1")" && echo "$PWD/$(basename "$1")"
  19. }
  20. function _usage() {
  21. cat <<EOF
  22. Invalid arguments passed.
  23. Usage:
  24. zap_bootstrap.sh -> install and update required packages
  25. zap_bootstrap.sh -c -> run a clean bootstrap, install packages from scratch
  26. EOF
  27. exit 1
  28. }
  29. set -e
  30. if [ -z "$ZAP_DEVELOPMENT_PATH" ]; then
  31. echo 'Please set $ZAP_DEVELOPMENT_PATH to your zap checkout'
  32. exit 1
  33. fi
  34. (
  35. cd "$ZAP_DEVELOPMENT_PATH"
  36. if [ $# -eq 0 ]; then
  37. echo "Running ZAP bootstrap"
  38. if ! npm list installed-check &>/dev/null; then
  39. npm install installed-check
  40. fi
  41. if ! ./node_modules/.bin/installed-check -c &>/dev/null; then
  42. npm install
  43. fi
  44. elif [ $# -eq 1 ] && [ "$1" = "-c" ]; then
  45. echo "Running clean ZAP bootstrap"
  46. npm ci
  47. npm run version-stamp
  48. npm rebuild canvas --update-binary
  49. npm run build-spa
  50. else
  51. _usage
  52. fi
  53. )
  54. echo "ZAP bootstrap done!"