Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

feat: using script to update the collab source. (#3508)

Nathan.fooo56687581f216
diff --git a/frontend/appflowy_tauri/.gitignore b/frontend/appflowy_tauri/.gitignore
index 5a5eb4ad6e..6a6338d33e 100644
--- a/frontend/appflowy_tauri/.gitignore
+++ b/frontend/appflowy_tauri/.gitignore
@@ -27,4 +27,5 @@ dist-ssr
**/src/services/backend/events/
**/src/appflowy_app/i18n/translations/
-coverage
\ No newline at end of file
+coverage
+**/AppFlowy-Collab
\ No newline at end of file
diff --git a/frontend/appflowy_tauri/src-tauri/Cargo.lock b/frontend/appflowy_tauri/src-tauri/Cargo.lock
index f7e0329369..34ab186016 100644
--- a/frontend/appflowy_tauri/src-tauri/Cargo.lock
+++ b/frontend/appflowy_tauri/src-tauri/Cargo.lock
@@ -521,9 +521,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
[[package]]
name = "bytes"
-version = "1.4.0"
+version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be"
+checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223"
dependencies = [
"serde",
]
diff --git a/frontend/appflowy_tauri/src-tauri/Cargo.toml b/frontend/appflowy_tauri/src-tauri/Cargo.toml
index fc3f85b6c5..b51d43fd0c 100644
--- a/frontend/appflowy_tauri/src-tauri/Cargo.toml
+++ b/frontend/appflowy_tauri/src-tauri/Cargo.toml
@@ -36,10 +36,14 @@ custom-protocol = ["tauri/custom-protocol"]
client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "8f8f6a" }
# ⚠️⚠️⚠️
-# Please using the following command to update the revision id
-# Current directory: frontend
-# Run the script:
-# scripts/tool/update_collab_rev.sh new_rev_id
+# Please use the following script to update collab.
+# Working directory: frontend
+#
+# To update the commit ID, run:
+# scripts/tool/update_collab_rev.sh new_rev_id
+#
+# To switch to the local path, run:
+# scripts/tool/update_collab_source.sh
# ⚠️⚠️⚠️️
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bf3a19" }
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bf3a19" }
@@ -51,16 +55,6 @@ collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "b
collab-define = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bf3a19" }
collab-sync-protocol = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bf3a19" }
-#collab = { path = "../../../../AppFlowy-Collab/collab" }
-#collab-folder = { path = "../../../../AppFlowy-Collab/collab-folder" }
-#collab-document = { path = "../../../../AppFlowy-Collab/collab-document" }
-#collab-database = { path = "../../../../AppFlowy-Collab/collab-database" }
-#collab-plugins = { path = "../../../../AppFlowy-Collab/collab-plugins" }
-#collab-persistence = { path = "../../../../AppFlowy-Collab/collab-persistence" }
-#collab-user = { path = "../../../../AppFlowy-Collab/collab-user" }
-#collab-define = { path = "../../../../AppFlowy-Collab/collab-define" }
-#collab-sync-protocol = { path = "../../../../AppFlowy-Collab/collab-sync-protocol" }
-
diff --git a/frontend/rust-lib/Cargo.toml b/frontend/rust-lib/Cargo.toml
index c7c2a9b951..7731d6b95e 100644
--- a/frontend/rust-lib/Cargo.toml
+++ b/frontend/rust-lib/Cargo.toml
@@ -78,10 +78,14 @@ incremental = false
client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "8f8f6a" }
# ⚠️⚠️⚠️
-# Please using the following command to update the revision id
-# Current directory: frontend
-# Run the script:
-# scripts/tool/update_collab_rev.sh new_rev_id
+# Please use the following script to update collab.
+# Working directory: frontend
+#
+# To update the commit ID, run:
+# scripts/tool/update_collab_rev.sh new_rev_id
+#
+# To switch to the local path, run:
+# scripts/tool/update_collab_source.sh
# ⚠️⚠️⚠️️
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bf3a19" }
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bf3a19" }
@@ -92,13 +96,3 @@ collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "b
collab-define = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bf3a19" }
collab-sync-protocol = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bf3a19" }
collab-persistence = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bf3a19" }
-
-#collab = { path = "../AppFlowy-Collab/collab" }
-#collab-folder = { path = "../AppFlowy-Collab/collab-folder" }
-#collab-database= { path = "../AppFlowy-Collab/collab-database" }
-#collab-document = { path = "../AppFlowy-Collab/collab-document" }
-#collab-plugins = { path = "../AppFlowy-Collab/collab-plugins" }
-#collab-persistence = { path = "../AppFlowy-Collab/collab-persistence" }
-#collab-user = { path = "../AppFlowy-Collab/collab-user" }
-#collab-define = { path = "../AppFlowy-Collab/collab-define" }
-#collab-sync-protocol = { path = "../AppFlowy-Collab/collab-sync-protocol" }
diff --git a/frontend/rust-lib/dart-ffi/Cargo.toml b/frontend/rust-lib/dart-ffi/Cargo.toml
index 76e6540309..3000f5e922 100644
--- a/frontend/rust-lib/dart-ffi/Cargo.toml
+++ b/frontend/rust-lib/dart-ffi/Cargo.toml
@@ -19,7 +19,7 @@ tokio = { version = "1.26", features = ["full", "rt-multi-thread", "tracing"] }
log = "0.4.17"
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0" }
-bytes = { version = "1.4" }
+bytes = { version = "1.5" }
crossbeam-utils = "0.8.15"
lazy_static = "1.4.0"
parking_lot = "0.12.1"
diff --git a/frontend/rust-lib/flowy-config/Cargo.toml b/frontend/rust-lib/flowy-config/Cargo.toml
index 1df04bdb14..1870a11230 100644
--- a/frontend/rust-lib/flowy-config/Cargo.toml
+++ b/frontend/rust-lib/flowy-config/Cargo.toml
@@ -13,7 +13,7 @@ flowy-error = { workspace = true }
flowy-derive = { path = "../../../shared-lib/flowy-derive" }
protobuf = {version = "2.28.0"}
-bytes = { version = "1.4" }
+bytes = { version = "1.5" }
strum_macros = "0.21"
[build-dependencies]
diff --git a/frontend/rust-lib/flowy-core/Cargo.toml b/frontend/rust-lib/flowy-core/Cargo.toml
index e9f7951540..4af2d7ae2e 100644
--- a/frontend/rust-lib/flowy-core/Cargo.toml
+++ b/frontend/rust-lib/flowy-core/Cargo.toml
@@ -33,7 +33,7 @@ flowy-storage = { workspace = true }
tracing = { version = "0.1", features = ["log"] }
futures-core = { version = "0.3", default-features = false }
-bytes = "1.4"
+bytes = "1.5"
tokio = { version = "1.26", features = ["full"] }
console-subscriber = { version = "0.1.8", optional = true }
parking_lot = "0.12.1"
diff --git a/frontend/rust-lib/flowy-database2/Cargo.toml b/frontend/rust-lib/flowy-database2/Cargo.toml
index 61573968fa..39c084d5ae 100644
--- a/frontend/rust-lib/flowy-database2/Cargo.toml
+++ b/frontend/rust-lib/flowy-database2/Cargo.toml
@@ -20,7 +20,7 @@ flowy-error = { workspace = true, features = ["impl_from_dispatch_error", "impl_
lib-dispatch = { workspace = true }
tokio = { version = "1.26", features = ["sync"] }
flowy-task= { workspace = true }
-bytes = { version = "1.4" }
+bytes = { version = "1.5" }
tracing = { version = "0.1", features = ["log"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = {version = "1.0"}
diff --git a/frontend/rust-lib/flowy-document2/Cargo.toml b/frontend/rust-lib/flowy-document2/Cargo.toml
index b87c17aa26..f3354e1697 100644
--- a/frontend/rust-lib/flowy-document2/Cargo.toml
+++ b/frontend/rust-lib/flowy-document2/Cargo.toml
@@ -20,7 +20,7 @@ lib-dispatch = { workspace = true }
lib-infra = { path = "../../../shared-lib/lib-infra" }
protobuf = {version = "2.28.0"}
-bytes = { version = "1.4" }
+bytes = { version = "1.5" }
nanoid = "0.4.0"
parking_lot = "0.12.1"
strum_macros = "0.21"
diff --git a/frontend/rust-lib/flowy-folder2/Cargo.toml b/frontend/rust-lib/flowy-folder2/Cargo.toml
index 4cf15268c6..4a17ab1e81 100644
--- a/frontend/rust-lib/flowy-folder2/Cargo.toml
+++ b/frontend/rust-lib/flowy-folder2/Cargo.toml
@@ -19,7 +19,7 @@ unicode-segmentation = "1.10"
tracing = { version = "0.1", features = ["log"] }
flowy-error = { path = "../flowy-error", features = ["impl_from_dispatch_error"]}
lib-dispatch = { workspace = true }
-bytes = { version = "1.4" }
+bytes = { version = "1.5" }
lib-infra = { path = "../../../shared-lib/lib-infra" }
tokio = { version = "1.26", features = ["full"] }
nanoid = "0.4.0"
diff --git a/frontend/rust-lib/flowy-notification/Cargo.toml b/frontend/rust-lib/flowy-notification/Cargo.toml
index 6c93f1c66e..64dab43b40 100644
--- a/frontend/rust-lib/flowy-notification/Cargo.toml
+++ b/frontend/rust-lib/flowy-notification/Cargo.toml
@@ -9,7 +9,7 @@ edition = "2018"
lazy_static = { version = "1.4.0" }
protobuf = { version = "2.28.0" }
tracing = { version = "0.1", features = ["log"] }
-bytes = { version = "1.4" }
+bytes = { version = "1.5" }
serde = "1.0"
flowy-derive = { path = "../../../shared-lib/flowy-derive" }
diff --git a/frontend/scripts/tool/update_collab_source.sh b/frontend/scripts/tool/update_collab_source.sh
new file mode 100755
index 0000000000..c4d88e8eac
--- /dev/null
+++ b/frontend/scripts/tool/update_collab_source.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+# 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
+ for crate in collab collab-folder collab-document collab-database collab-plugins collab-user collab-define collab-sync-protocol collab-persistence; do
+ sed -i '' \
+ -e "s#${crate} = { git = \"https://github.com/AppFlowy-IO/AppFlowy-Collab\", rev = \"[a-f0-9]*\" }#${crate} = { path = \"$repo_path/$crate\" }#g" \
+ "$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"
+switch_deps "$CARGO_TOML_2" "$REPO_RELATIVE_PATH_2"