install_windows.sh 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. # Enable the flutter stable channel
  39. printMessage "Setting up Flutter"
  40. flutter channel stable
  41. # Add pub cache and cargo to PATH
  42. powershell '[Environment]::SetEnvironmentVariable("PATH", $Env:PATH + ";" + $Env:LOCALAPPDATA + "\Pub\Cache\Bin", [EnvironmentVariableTarget]::User)'
  43. powershell '[Environment]::SetEnvironmentVariable("PATH", $Env:PATH + ";" + $Env:USERPROFILE + "\.cargo\bin", [EnvironmentVariableTarget]::User)'
  44. # Enable linux desktop
  45. flutter config --enable-windows-desktop
  46. # Fix any problems reported by flutter doctor
  47. flutter doctor
  48. # Add the githooks directory to your git configuration
  49. printMessage "Setting up githooks."
  50. git config core.hooksPath .githooks
  51. # Install go-gitlint
  52. printMessage "Installing go-gitlint."
  53. GOLINT_FILENAME="go-gitlint_1.1.0_windows_x86_64.tar.gz"
  54. if curl --proto '=https' --tlsv1.2 -sSfL https://github.com/llorllale/go-gitlint/releases/download/1.1.0/${GOLINT_FILENAME} -o ${GOLINT_FILENAME}; then
  55. tar -zxv --directory .githooks/. -f ${GOLINT_FILENAME} gitlint.exe
  56. rm ${GOLINT_FILENAME}
  57. else
  58. printError "Failed to install go-gitlint"
  59. fi
  60. # Change to the frontend directory
  61. cd frontend
  62. # Install cargo make
  63. printMessage "Installing cargo-make."
  64. $USERPROFILE/.cargo/bin/cargo install --force cargo-make
  65. # Install duckscript
  66. printMessage "Installing duckscript."
  67. $USERPROFILE/.cargo/bin/cargo install --force duckscript_cli
  68. # Enable vcpkg integration
  69. # Note: Requires admin
  70. printMessage "Setting up vcpkg."
  71. vcpkg integrate install
  72. # Check prerequisites
  73. printMessage "Checking prerequisites."
  74. PATH="$PATH;$LOCALAPPDATA\Pub\Cache\bin" bash -c '$USERPROFILE/.cargo/bin/cargo make flowy_dev'