package.sh 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. echo -e " _____ _ _ _ _ _ "
  4. echo -e "|_ _| |_ ___ ___ ___ _____ ___| | | |___| |_ "
  5. echo -e " | | | | _| -_| -_| | .'| | | | -_| . | \e[32m_\e[0m "
  6. echo -e " |_| |_|_|_| |___|___|_|_|_|__,|_____|___|___|\e[32m|_|\e[0m\n"
  7. echo -e "Creating release distribution for Threema Web\n"
  8. # Test whether we're in the root dir
  9. if [ ! -f "package.json" ]; then
  10. echo "Error: package.json not found."
  11. echo "Please run this script from the root directory of this repository."
  12. exit 1
  13. fi
  14. # Clean up release directory
  15. if [ -e "release" ]; then
  16. while true; do
  17. read -r -p "Release directory exists. Delete it? (y/n) " input
  18. case $input in
  19. y|Y ) echo -e "\n+ Delete release directory..."; rm -r release; break;;
  20. n|N ) echo "Aborting."; exit 1;;
  21. * ) echo "Invalid input.";;
  22. esac
  23. done
  24. fi
  25. echo "+ Create release directory..."
  26. mkdir -p release/{dist,partials,directives,node_modules,partials/messenger.receiver,files}
  27. echo "+ Copy code..."
  28. cp -R index.html dist/ release/
  29. cp -R public/* release/
  30. cp -R src/partials/*.html release/partials/
  31. cp -R src/partials/messenger.receiver/*.html release/partials/messenger.receiver/
  32. cp -R src/directives/*.html release/directives/
  33. echo "+ Copy dependencies..."
  34. mkdir -p release/node_modules/angular/
  35. cp node_modules/angular/angular.js release/node_modules/angular/
  36. cp node_modules/angular/angular-csp.css release/node_modules/angular/
  37. mkdir -p release/node_modules/angular-aria/
  38. cp node_modules/angular-aria/angular-aria.min.js release/node_modules/angular-aria/
  39. mkdir -p release/node_modules/angular-animate/
  40. cp node_modules/angular-animate/angular-animate.min.js release/node_modules/angular-animate/
  41. mkdir -p release/node_modules/angular-sanitize/
  42. cp node_modules/angular-sanitize/angular-sanitize.min.js release/node_modules/angular-sanitize/
  43. mkdir -p release/node_modules/angular-route/
  44. cp node_modules/angular-route/angular-route.min.js release/node_modules/angular-route/
  45. mkdir -p release/node_modules/babel-es6-polyfill/
  46. cp node_modules/babel-es6-polyfill/browser-polyfill.min.js release/node_modules/babel-es6-polyfill/
  47. mkdir -p release/node_modules/msgpack-lite/dist/
  48. cp node_modules/msgpack-lite/dist/msgpack.min.js release/node_modules/msgpack-lite/dist/
  49. mkdir -p release/node_modules/tweetnacl/
  50. cp node_modules/tweetnacl/nacl-fast.min.js release/node_modules/tweetnacl/
  51. mkdir -p release/node_modules/file-saver/
  52. cp node_modules/file-saver/FileSaver.min.js release/node_modules/file-saver/
  53. mkdir -p release/node_modules/js-sha256/build/
  54. cp node_modules/js-sha256/build/sha256.min.js release/node_modules/js-sha256/build/
  55. mkdir -p release/node_modules/chunked-dc/dist/
  56. cp node_modules/chunked-dc/dist/chunked-dc.es5.js release/node_modules/chunked-dc/dist/
  57. mkdir -p release/node_modules/saltyrtc-client/dist/
  58. cp node_modules/saltyrtc-client/dist/saltyrtc-client.es5.js release/node_modules/saltyrtc-client/dist/
  59. mkdir -p release/node_modules/saltyrtc-task-webrtc/dist/
  60. cp node_modules/saltyrtc-task-webrtc/dist/saltyrtc-task-webrtc.es5.js release/node_modules/saltyrtc-task-webrtc/dist/
  61. mkdir -p release/node_modules/webrtc-adapter/out/
  62. cp node_modules/webrtc-adapter/out/adapter_no_edge.js release/node_modules/webrtc-adapter/out/
  63. mkdir -p release/node_modules/qrcode-generator/js/
  64. cp node_modules/qrcode-generator/js/qrcode.js release/node_modules/qrcode-generator/js/
  65. mkdir -p release/node_modules/angular-qrcode/
  66. cp node_modules/angular-qrcode/angular-qrcode.js release/node_modules/angular-qrcode/
  67. mkdir -p release/node_modules/angularjs-scroll-glue/src/
  68. cp node_modules/angularjs-scroll-glue/src/scrollglue.js release/node_modules/angularjs-scroll-glue/src/
  69. mkdir -p release/node_modules/angular-material/
  70. cp node_modules/angular-material/angular-material.min.js release/node_modules/angular-material/
  71. cp node_modules/angular-material/angular-material.min.css release/node_modules/angular-material/
  72. mkdir -p release/node_modules/croppie/
  73. cp node_modules/croppie/croppie.min.js release/node_modules/croppie/
  74. cp node_modules/croppie/croppie.css release/node_modules/croppie/
  75. mkdir -p release/node_modules/autolinker/dist/
  76. cp node_modules/autolinker/dist/Autolinker.min.js release/node_modules/autolinker/dist/
  77. mkdir -p release/node_modules/angular-ui-router/release/
  78. cp node_modules/angular-ui-router/release/angular-ui-router.min.js release/node_modules/angular-ui-router/release/
  79. mkdir -p release/node_modules/messageformat/
  80. cp node_modules/messageformat/messageformat.min.js release/node_modules/messageformat/
  81. mkdir -p release/node_modules/angular-translate/dist/{.,angular-translate-loader-static-files,angular-translate-interpolation-messageformat}
  82. cp node_modules/angular-translate/dist/angular-translate.min.js release/node_modules/angular-translate/dist/
  83. cp node_modules/angular-translate/dist/angular-translate-loader-static-files/angular-translate-loader-static-files.min.js release/node_modules/angular-translate/dist/angular-translate-loader-static-files/
  84. cp node_modules/angular-translate/dist/angular-translate-interpolation-messageformat/angular-translate-interpolation-messageformat.min.js release/node_modules/angular-translate/dist/angular-translate-interpolation-messageformat/
  85. mkdir -p release/node_modules/angular-inview/
  86. cp node_modules/angular-inview/angular-inview.js release/node_modules/angular-inview/
  87. mkdir -p release/node_modules/angular-messages/
  88. cp node_modules/angular-messages/angular-messages.min.js release/node_modules/angular-messages/
  89. echo "+ Update version number..."
  90. VERSION=$(grep "\"version\"" package.json | sed 's/\s*\"version\": \"\([^\"]*\).*/\1/')
  91. sed -i "s/\[\[VERSION\]\]/${VERSION}/g" release/index.html release/dist/app.js
  92. echo "+ Update permissions..."
  93. find release/ -type f -exec chmod 644 {} \;
  94. find release/ -type d -exec chmod 755 {} \;
  95. echo "+ Put everything in an archive..."
  96. tar cfz dist/release.tar.gz release/
  97. echo -e "\nDone."