package.sh 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. VERSION=$(grep "\"version\"" package.json | sed 's/\s*\"version\": \"\([^\"]*\).*/\1/')
  26. DIR="release/threema-web-$VERSION"
  27. echo "+ Create release directory..."
  28. mkdir -p $DIR/{dist,partials,directives,node_modules,partials/messenger.receiver,files}
  29. echo "+ Copy code..."
  30. cp -R index.html dist/ $DIR/
  31. cp -R public/* $DIR/
  32. cp -R src/partials/*.html $DIR/partials/
  33. cp -R src/partials/messenger.receiver/*.html $DIR/partials/messenger.receiver/
  34. cp -R src/directives/*.html $DIR/directives/
  35. echo "+ Copy dependencies..."
  36. targets=(
  37. angular/angular.js
  38. angular/angular-csp.css
  39. angular-aria/angular-aria.min.js
  40. angular-animate/angular-animate.min.js
  41. angular-sanitize/angular-sanitize.min.js
  42. angular-route/angular-route.min.js
  43. babel-es6-polyfill/browser-polyfill.min.js
  44. msgpack-lite/dist/msgpack.min.js
  45. tweetnacl/nacl-fast.min.js
  46. file-saver/FileSaver.min.js
  47. js-sha256/build/sha256.min.js
  48. chunked-dc/dist/chunked-dc.es5.js
  49. saltyrtc-client/dist/saltyrtc-client.es5.js
  50. saltyrtc-task-webrtc/dist/saltyrtc-task-webrtc.es5.js
  51. webrtc-adapter/out/adapter_no_edge.js
  52. qrcode-generator/js/qrcode.js
  53. angular-qrcode/angular-qrcode.js
  54. angularjs-scroll-glue/src/scrollglue.js
  55. angular-material/angular-material.min.js
  56. angular-material/angular-material.min.css
  57. croppie/croppie.min.js
  58. croppie/croppie.css
  59. autolinker/dist/Autolinker.min.js
  60. angular-ui-router/release/angular-ui-router.min.js
  61. messageformat/messageformat.min.js
  62. angular-translate/dist/angular-translate.min.js
  63. angular-translate/dist/angular-translate-loader-static-files/angular-translate-loader-static-files.min.js
  64. angular-translate/dist/angular-translate-interpolation-messageformat/angular-translate-interpolation-messageformat.min.js
  65. angular-inview/angular-inview.js
  66. angular-messages/angular-messages.min.js
  67. )
  68. for target in "${targets[@]}"; do
  69. install -D "node_modules/$target" "$DIR/node_modules/$target"
  70. done
  71. echo "+ Update version number..."
  72. sed -i "s/\[\[VERSION\]\]/${VERSION}/g" $DIR/index.html $DIR/dist/app.js
  73. echo "+ Update permissions..."
  74. find $DIR/ -type f -exec chmod 644 {} \;
  75. find $DIR/ -type d -exec chmod 755 {} \;
  76. echo "+ Put everything in an archive..."
  77. cd release
  78. tar cfz "../dist/threema-web-$VERSION.tar.gz" $(basename "$DIR")
  79. cd ..
  80. echo -e "\nDone."