Kaynağa Gözat

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

* chore: add script

* chore: update script

* chore: update bytes version

* chore: submit lock file
Nathan.fooo 1 yıl önce
ebeveyn
işleme
56687581f2

+ 2 - 1
frontend/appflowy_tauri/.gitignore

@@ -27,4 +27,5 @@ dist-ssr
 **/src/services/backend/events/
 **/src/appflowy_app/i18n/translations/
 
-coverage
+coverage
+**/AppFlowy-Collab

+ 2 - 2
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",
 ]

+ 8 - 14
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" }
-
 
 
 

+ 8 - 14
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" }

+ 1 - 1
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"

+ 1 - 1
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]

+ 1 - 1
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"

+ 1 - 1
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"}

+ 1 - 1
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"

+ 1 - 1
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"

+ 1 - 1
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" }

+ 41 - 0
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"