update_collab_source.sh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/bin/bash
  2. # Paths to your Cargo.toml files
  3. REPO_PATH="./AppFlowy-Collab"
  4. CARGO_TOML_1="./rust-lib/Cargo.toml"
  5. REPO_RELATIVE_PATH_1="../AppFlowy-Collab"
  6. CARGO_TOML_2="./appflowy_tauri/src-tauri/Cargo.toml"
  7. REPO_RELATIVE_PATH_2="../../AppFlowy-Collab"
  8. # Function to switch dependencies in a given Cargo.toml
  9. switch_deps() {
  10. local cargo_toml="$1"
  11. local repo_path="$2"
  12. if grep -q 'git = "https://github.com/AppFlowy-IO/AppFlowy-Collab"' "$cargo_toml"; then
  13. cp "$cargo_toml" "$cargo_toml.bak"
  14. # Switch to local paths
  15. for crate in collab collab-folder collab-document collab-database collab-plugins collab-user collab-define collab-sync-protocol collab-persistence; do
  16. sed -i '' \
  17. -e "s#${crate} = { git = \"https://github.com/AppFlowy-IO/AppFlowy-Collab\", rev = \"[a-f0-9]*\" }#${crate} = { path = \"$repo_path/$crate\" }#g" \
  18. "$cargo_toml"
  19. done
  20. echo "Switched to local paths in $cargo_toml."
  21. echo "🙏🏽Switch back to git dependencies by rerunning this script"
  22. else
  23. # Switch back to git dependencies
  24. cp "$cargo_toml.bak" "$cargo_toml"
  25. echo "Switched back to git dependencies in $cargo_toml."
  26. rm -rf "$cargo_toml.bak"
  27. fi
  28. }
  29. # Check if AppFlowy-Collab directory exists
  30. if [ ! -d "$REPO_PATH" ]; then
  31. echo "AppFlowy-Collab directory not found. Cloning the repository..."
  32. git clone https://github.com/AppFlowy-IO/AppFlowy-Collab.git "$REPO_PATH"
  33. fi
  34. # Switch dependencies in both Cargo.toml files
  35. switch_deps "$CARGO_TOML_1" "$REPO_RELATIVE_PATH_1"
  36. switch_deps "$CARGO_TOML_2" "$REPO_RELATIVE_PATH_2"