setup 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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 installs, npm install and pip install -r requirements.txt"
  61. brew install coreutils
  62. brew install node
  63. brew install ripgrep
  64. brew install cmark
  65. brew install cocoapods
  66. brew install carthage
  67. brew install llvm
  68. npm install
  69. pip install -r requirements.txt
  70. else
  71. message "Homebrew must be installed and working."
  72. exit 1
  73. fi
  74. PROJECT_DIR=$(git rev-parse --show-toplevel)
  75. cat <<EOF
  76. PLEASE NOTE: CutBox expects:
  77. Build/Test & release tooling...
  78. - [$(which_check brew)] homebrew (in case anything is missing)
  79. - [$(which_check pod)] cocoapods
  80. - [$(which_check xcpretty)] xcpretty
  81. - [$(which_check jv)] jv (json validator)
  82. - [$(exists_check /usr/local/opt/llvm/bin/llvm-cov)] llvm-cov /usr/local/opt/llvm/bin/llvm-cov
  83. For release...
  84. - [$(which_check cmark)] cmark
  85. - [$(which_check npm)] npm
  86. - [$(npm_check appdmg)] appdmg
  87. - [$(npm_check semver)] semver
  88. anything missing? (Get help at https://gitter.im/CutBox/Lobby)
  89. =========================================================================================="
  90. Install Pods
  91. EOF
  92. pushd $PROJECT_DIR/CutBox || exit 1
  93. pod install
  94. popd || exit 1
  95. echo "To build run: bin/build"
  96. if [[ $WHICH_CHECK == 1 || $NPM_CHECK == 1 || $EXISTS_CHECK == 1 ]]; then
  97. echo "Something missing? Setup cannot find:
  98. ${WHICH_FAILED}
  99. ${NPM_FAILED}."
  100. exit 1
  101. fi
  102. exit 0