install_windows.sh 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #!/bin/bash
  2. YELLOW="\e[93m"
  3. GREEN="\e[32m"
  4. RED="\e[31m"
  5. ENDCOLOR="\e[0m"
  6. printMessage() {
  7. printf "${YELLOW}AppFlowy : $1${ENDCOLOR}\n"
  8. }
  9. printSuccess() {
  10. printf "${GREEN}AppFlowy : $1${ENDCOLOR}\n"
  11. }
  12. printError() {
  13. printf "${RED}AppFlowy : $1${ENDCOLOR}\n"
  14. }
  15. # Note: This script does not install applications which are installed by the package manager. There are too many package managers out there.
  16. # Install Rust
  17. if ! rustc --version; then
  18. printMessage "The Rust programming language is required to compile AppFlowy."
  19. printMessage "It has not been detected on your system."
  20. read -p "$(printSuccess "Do you want to install Rust? [y/N]") " installrust
  21. if [ ${installrust^^} == "Y" ]; then
  22. printMessage "Installing Rust."
  23. if ! curl --proto '=https' --tlsv1.2 -sSf https://win.rustup.rs/x86_64 -o rustup-init.exe; then
  24. printError "Failed to download the Rust installer"
  25. exit 1
  26. fi
  27. start "Rust Installer" rustup-init.exe
  28. read -p "$(printSuccess "Press enter when Rust installation is done") " isDone
  29. rm rustup-init.exe
  30. $USERPROFILE/.cargo/bin/rustup toolchain install stable
  31. $USERPROFILE/.cargo/bin/rustup default stable
  32. else
  33. printMessage "Skipping Rust installation."
  34. fi
  35. else
  36. printSuccess "Rust has been detected on your system, so Rust installation has been skipped"
  37. fi
  38. printMessage "Setting up Flutter"
  39. # Get the current Flutter version
  40. FLUTTER_VERSION=$(flutter --version | grep -oP 'Flutter \K\S+')
  41. # Check if the current version is 3.7.5
  42. if [ "$FLUTTER_VERSION" = "3.7.5" ]; then
  43. echo "Flutter version is already 3.7.5"
  44. else
  45. # Get the path to the Flutter SDK
  46. FLUTTER_PATH=$(which flutter)
  47. FLUTTER_PATH=${FLUTTER_PATH%/bin/flutter}
  48. current_dir=$(pwd)
  49. cd $FLUTTER_PATH
  50. # Use git to checkout version 3.7.5 of Flutter
  51. git checkout 3.7.5
  52. # Get back to current working directory
  53. cd "$current_dir"
  54. echo "Switched to Flutter version 3.7.5"
  55. fi
  56. # Add pub cache and cargo to PATH
  57. powershell '[Environment]::SetEnvironmentVariable("PATH", $Env:PATH + ";" + $Env:LOCALAPPDATA + "\Pub\Cache\Bin", [EnvironmentVariableTarget]::User)'
  58. powershell '[Environment]::SetEnvironmentVariable("PATH", $Env:PATH + ";" + $Env:USERPROFILE + "\.cargo\bin", [EnvironmentVariableTarget]::User)'
  59. # Enable linux desktop
  60. flutter config --enable-windows-desktop
  61. # Fix any problems reported by flutter doctor
  62. flutter doctor
  63. # Add the githooks directory to your git configuration
  64. printMessage "Setting up githooks."
  65. git config core.hooksPath .githooks
  66. # Install go-gitlint
  67. printMessage "Installing go-gitlint."
  68. GOLINT_FILENAME="go-gitlint_1.1.0_windows_x86_64.tar.gz"
  69. if curl --proto '=https' --tlsv1.2 -sSfL https://github.com/llorllale/go-gitlint/releases/download/1.1.0/${GOLINT_FILENAME} -o ${GOLINT_FILENAME}; then
  70. tar -zxv --directory .githooks/. -f ${GOLINT_FILENAME} gitlint.exe
  71. rm ${GOLINT_FILENAME}
  72. else
  73. printError "Failed to install go-gitlint"
  74. fi
  75. # Change to the frontend directory
  76. cd frontend
  77. # Install cargo make
  78. printMessage "Installing cargo-make."
  79. $USERPROFILE/.cargo/bin/cargo install --force cargo-make
  80. # Install duckscript
  81. printMessage "Installing duckscript."
  82. $USERPROFILE/.cargo/bin/cargo install --force duckscript_cli
  83. # Enable vcpkg integration
  84. # Note: Requires admin
  85. printMessage "Setting up vcpkg."
  86. vcpkg integrate install
  87. # Check prerequisites
  88. printMessage "Checking prerequisites."
  89. PATH="$PATH;$LOCALAPPDATA\Pub\Cache\bin" bash -c '$USERPROFILE/.cargo/bin/cargo make appflowy-flutter-deps-tools'