2024-07-08 05:45:57 +00:00
|
|
|
#!/usr/bin/env bash
|
2023-09-24 07:50:58 +00:00
|
|
|
|
|
|
|
# Paths to your Cargo.toml files
|
|
|
|
REPO_PATH="./AppFlowy-Collab"
|
|
|
|
CARGO_TOML_1="./rust-lib/Cargo.toml"
|
|
|
|
REPO_RELATIVE_PATH_1="../AppFlowy-Collab"
|
|
|
|
|
|
|
|
CARGO_TOML_2="./appflowy_tauri/src-tauri/Cargo.toml"
|
|
|
|
REPO_RELATIVE_PATH_2="../../AppFlowy-Collab"
|
|
|
|
|
|
|
|
# Function to switch dependencies in a given Cargo.toml
|
|
|
|
switch_deps() {
|
|
|
|
local cargo_toml="$1"
|
|
|
|
local repo_path="$2"
|
|
|
|
if grep -q 'git = "https://github.com/AppFlowy-IO/AppFlowy-Collab"' "$cargo_toml"; then
|
|
|
|
cp "$cargo_toml" "$cargo_toml.bak"
|
|
|
|
# Switch to local paths
|
2023-10-10 11:05:55 +00:00
|
|
|
for crate in collab collab-folder collab-document collab-database collab-plugins collab-user collab-entity collab-sync-protocol collab-persistence; do
|
2023-09-24 07:50:58 +00:00
|
|
|
sed -i '' \
|
2024-05-27 00:51:49 +00:00
|
|
|
-e "s#${crate} = { .*git = \"https://github.com/AppFlowy-IO/AppFlowy-Collab\".* }#${crate} = { path = \"$repo_path/$crate\" }#g" \
|
2023-09-24 07:50:58 +00:00
|
|
|
"$cargo_toml"
|
|
|
|
done
|
|
|
|
echo "Switched to local paths in $cargo_toml."
|
|
|
|
echo "🙏🏽Switch back to git dependencies by rerunning this script"
|
|
|
|
else
|
|
|
|
# Switch back to git dependencies
|
|
|
|
cp "$cargo_toml.bak" "$cargo_toml"
|
|
|
|
echo "Switched back to git dependencies in $cargo_toml."
|
|
|
|
rm -rf "$cargo_toml.bak"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Check if AppFlowy-Collab directory exists
|
|
|
|
if [ ! -d "$REPO_PATH" ]; then
|
|
|
|
echo "AppFlowy-Collab directory not found. Cloning the repository..."
|
|
|
|
git clone https://github.com/AppFlowy-IO/AppFlowy-Collab.git "$REPO_PATH"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Switch dependencies in both Cargo.toml files
|
|
|
|
switch_deps "$CARGO_TOML_1" "$REPO_RELATIVE_PATH_1"
|
2024-07-08 05:45:57 +00:00
|
|
|
switch_deps "$CARGO_TOML_2" "$REPO_RELATIVE_PATH_2"
|