build.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/bash
  2. if [ -n "$2" ]; then
  3. type="$2"
  4. else
  5. type="development"
  6. fi
  7. buildResource() {
  8. if [ ! -d "cordova" ]; then
  9. echo "current path is wrong! Please use tools/build.sh xxx to run!"
  10. exit 1
  11. fi
  12. # build resources
  13. echo "------- begin build vue project MODE[$type] -------"
  14. npm run build-"$type"
  15. echo "------- vue project build over[$type] -------"
  16. }
  17. enterCordova() {
  18. # enter cordova project
  19. cd cordova
  20. # del tem file
  21. rm -rf www/cordova.js
  22. }
  23. buildAndroid() {
  24. echo "------- begin build android project[$type] -------"
  25. # build android package
  26. cordova build android --release -- --keystore="../config/release.keystore" --alias=tianwang --storePassword=wanbits --password=wanbits
  27. echo "------- android project build over[$type] -------"
  28. }
  29. buildIOS() {
  30. echo "------- begin build ios project[$type] -------"
  31. # build ios package
  32. cordova build ios
  33. echo "------- ios project build over[$type] -------"
  34. }
  35. help() {
  36. echo "use:
  37. no params build android with dev
  38. android [type] -- build android [type: dev pub, default:dev]
  39. help -- show help info
  40. ios [type] -- build ios [type: dev pub, default:dev]"
  41. exit
  42. }
  43. # build app
  44. if [ -n "$1" ]; then
  45. if [ "$1" == "android" ]; then
  46. buildResource
  47. enterCordova
  48. buildAndroid
  49. elif [ "$1" == "ios" ]; then
  50. buildResource
  51. enterCordova
  52. buildIOS
  53. elif [ "$1" == "help" ]; then
  54. help
  55. else
  56. help
  57. fi
  58. else
  59. buildResource
  60. enterCordova
  61. buildAndroid
  62. fi
  63. echo "------- all [$type] done -------"