setup 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #!/bin/bash
  2. message() {
  3. echo "CutBox Setup: ${1}"
  4. }
  5. EXISTS_FAILED=""
  6. EXISTS_CHECK=0
  7. exists_check() {
  8. cross_mark="✗"
  9. check_mark="✓"
  10. if [ $# -ne 1 ]; then
  11. message "exists_check: No arguments provided"
  12. exit 1
  13. else
  14. if [ -x $1 ]; then
  15. printf "${check_mark}"
  16. else
  17. printf "${cross_mark}"
  18. EXISTS_CHECK=1
  19. EXISTS_FAILED="${EXISTS_FAILED} ${1}"
  20. fi
  21. fi
  22. }
  23. WHICH_FAILED=""
  24. WHICH_CHECK=0
  25. which_check() {
  26. cross_mark="✗"
  27. check_mark="✓"
  28. if [ $# -ne 1 ]; then
  29. message "which_check: No arguments provided"
  30. exit 1
  31. else
  32. if [ -x "$(which $1)" ]; then
  33. printf "${check_mark}"
  34. else
  35. printf "${cross_mark}"
  36. WHICH_CHECK=1
  37. WHICH_FAILED="${WHICH_FAILED} ${1}"
  38. fi
  39. fi
  40. }
  41. NPM_FAILED=""
  42. NPM_CHECK=0
  43. npm_check() {
  44. cross_mark="✗"
  45. check_mark="✓"
  46. if [ $# -ne 1 ]; then
  47. message "npm_check: No arguments provided"
  48. exit 1
  49. else
  50. if [ -x "$(npm exec which $1)" ]; then
  51. printf "${check_mark}"
  52. else
  53. printf "${cross_mark}"
  54. NPM_CHECK=1
  55. NPM_FAILED="${NPM_FAILED} ${1}"
  56. fi
  57. fi
  58. }
  59. if [ -x "$(which brew)" ]; then
  60. message "Running brew bundle, npm install and pip install -r requirements.txt"
  61. brew bundle
  62. npm install
  63. pip install -r requirements.txt
  64. else
  65. message "Homebrew must be installed and working."
  66. exit 1
  67. fi
  68. PROJECT_DIR=$(git rev-parse --show-toplevel)
  69. cat <<EOF
  70. PLEASE NOTE: CutBox expects:
  71. Build/Test & release tooling...
  72. - [$(which_check brew)] homebrew (in case anything is missing)
  73. - [$(which_check pod)] cocoapods
  74. - [$(which_check xcpretty)] xcpretty
  75. - [$(which_check jv)] jv (json validator)
  76. - [$(exists_check /usr/local/opt/llvm/bin/llvm-cov)] llvm-cov /usr/local/opt/llvm/bin/llvm-cov
  77. For release...
  78. - [$(which_check cmark)] cmark
  79. - [$(which_check npm)] npm
  80. - [$(npm_check appdmg)] appdmg
  81. - [$(npm_check semver)] semver
  82. anything missing? (Get help at https://gitter.im/CutBox/Lobby)
  83. =========================================================================================="
  84. Install Pods
  85. EOF
  86. pushd $PROJECT_DIR/CutBox || exit 1
  87. pod install
  88. popd || exit 1
  89. echo "To build run: bin/build"
  90. if [[ $WHICH_CHECK == 1 || $NPM_CHECK == 1 || $EXISTS_CHECK == 1 ]]; then
  91. echo "Something missing? Setup cannot find:
  92. ${WHICH_FAILED}
  93. ${NPM_FAILED}."
  94. exit 1
  95. fi
  96. exit 0