Skip to content

Commit

Permalink
chore: remove unused features (#5196)
Browse files Browse the repository at this point in the history
* chore: remove unused features

* chore: update logs
  • Loading branch information
appflowy authored Apr 24, 2024
1 parent 9aaada9 commit 77d600a
Show file tree
Hide file tree
Showing 14 changed files with 140 additions and 144 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust_ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
af_cloud_test_ws_url: ws://localhost/ws/v1
af_cloud_test_gotrue_url: http://localhost/gotrue
run: |
DISABLE_CI_TEST_LOG="true" cargo test --no-default-features --features="rev-sqlite,dart" -- --nocapture
DISABLE_CI_TEST_LOG="true" cargo test --no-default-features --features="dart" -- --nocapture
- name: rustfmt rust-lib
run: cargo fmt --all -- --check
Expand Down
76 changes: 38 additions & 38 deletions frontend/Makefile.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#https://github.com/sagiegurari/cargo-make

extend = [
{ path = "scripts/makefile/desktop.toml" },
{ path = "scripts/makefile/mobile.toml" },
{ path = "scripts/makefile/protobuf.toml" },
{ path = "scripts/makefile/tests.toml" },
{ path = "scripts/makefile/docker.toml" },
{ path = "scripts/makefile/env.toml" },
{ path = "scripts/makefile/flutter.toml" },
{ path = "scripts/makefile/tool.toml" },
{ path = "scripts/makefile/tauri.toml" },
{ path = "scripts/makefile/web.toml" },
{ path = "scripts/makefile/desktop.toml" },
{ path = "scripts/makefile/mobile.toml" },
{ path = "scripts/makefile/protobuf.toml" },
{ path = "scripts/makefile/tests.toml" },
{ path = "scripts/makefile/docker.toml" },
{ path = "scripts/makefile/env.toml" },
{ path = "scripts/makefile/flutter.toml" },
{ path = "scripts/makefile/tool.toml" },
{ path = "scripts/makefile/tauri.toml" },
{ path = "scripts/makefile/web.toml" },
]

[config]
Expand All @@ -27,7 +27,7 @@ CARGO_MAKE_CRATE_FS_NAME = "dart_ffi"
CARGO_MAKE_CRATE_NAME = "dart-ffi"
LIB_NAME = "dart_ffi"
APPFLOWY_VERSION = "0.5.5"
FLUTTER_DESKTOP_FEATURES = "dart,rev-sqlite"
FLUTTER_DESKTOP_FEATURES = "dart"
PRODUCT_NAME = "AppFlowy"
MACOSX_DEPLOYMENT_TARGET = "11.0"
# CRATE_TYPE: https://doc.rust-lang.org/reference/linkage.html
Expand Down Expand Up @@ -162,7 +162,7 @@ CRATE_TYPE = "cdylib"
FLUTTER_OUTPUT_DIR = "Debug"
LIB_EXT = "so"
LINUX_ARCH = "arm64"
FLUTTER_DESKTOP_FEATURES = "dart,rev-sqlite,openssl_vendored"
FLUTTER_DESKTOP_FEATURES = "dart,openssl_vendored"

[env.production-linux-aarch64]
CARGO_PROFILE = "release"
Expand All @@ -174,7 +174,7 @@ FLUTTER_OUTPUT_DIR = "Release"
LIB_EXT = "so"
LINUX_ARCH = "arm64"
APP_ENVIRONMENT = "production"
FLUTTER_DESKTOP_FEATURES = "dart,rev-sqlite,openssl_vendored"
FLUTTER_DESKTOP_FEATURES = "dart,openssl_vendored"

[env.development-ios-arm64-sim]
BUILD_FLAG = "debug"
Expand Down Expand Up @@ -207,7 +207,7 @@ CRATE_TYPE = "cdylib"
FLUTTER_OUTPUT_DIR = "Debug"
LIB_EXT = "so"
PRODUCT_EXT = "apk"
FLUTTER_DESKTOP_FEATURES = "dart,rev-sqlite,openssl_vendored"
FLUTTER_DESKTOP_FEATURES = "dart,openssl_vendored"

[env.production-android]
BUILD_FLAG = "release"
Expand Down Expand Up @@ -235,24 +235,24 @@ script_runner = "@shell"
[tasks.setup-crate-type]
private = true
script = [
"""
toml = readfile ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/Cargo.toml
val = replace ${toml} "staticlib" ${CRATE_TYPE}
result = writefile ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/Cargo.toml ${val}
assert ${result}
""",
"""
toml = readfile ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/Cargo.toml
val = replace ${toml} "staticlib" ${CRATE_TYPE}
result = writefile ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/Cargo.toml ${val}
assert ${result}
""",
]
script_runner = "@duckscript"

[tasks.restore-crate-type]
private = true
script = [
"""
toml = readfile ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/Cargo.toml
val = replace ${toml} ${CRATE_TYPE} "staticlib"
result = writefile ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/Cargo.toml ${val}
assert ${result}
""",
"""
toml = readfile ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/Cargo.toml
val = replace ${toml} ${CRATE_TYPE} "staticlib"
result = writefile ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/Cargo.toml ${val}
assert ${result}
""",
]
script_runner = "@duckscript"

Expand Down Expand Up @@ -280,24 +280,24 @@ TEST_COMPILE_TARGET = "x86_64-pc-windows-msvc"
[tasks.setup-test-crate-type]
private = true
script = [
"""
toml = readfile ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/Cargo.toml
val = replace ${toml} "staticlib" ${TEST_CRATE_TYPE}
result = writefile ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/Cargo.toml ${val}
assert ${result}
""",
"""
toml = readfile ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/Cargo.toml
val = replace ${toml} "staticlib" ${TEST_CRATE_TYPE}
result = writefile ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/Cargo.toml ${val}
assert ${result}
""",
]
script_runner = "@duckscript"

[tasks.restore-test-crate-type]
private = true
script = [
"""
toml = readfile ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/Cargo.toml
val = replace ${toml} ${TEST_CRATE_TYPE} "staticlib"
result = writefile ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/Cargo.toml ${val}
assert ${result}
""",
"""
toml = readfile ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/Cargo.toml
val = replace ${toml} ${TEST_CRATE_TYPE} "staticlib"
result = writefile ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/Cargo.toml ${val}
assert ${result}
""",
]
script_runner = "@duckscript"

Expand Down
1 change: 0 additions & 1 deletion frontend/appflowy_tauri/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ lib-dispatch = { path = "../../rust-lib/lib-dispatch", features = [
"use_serde",
] }
flowy-core = { path = "../../rust-lib/flowy-core", features = [
"rev-sqlite",
"ts",
] }
flowy-user = { path = "../../rust-lib/flowy-user", features = ["tauri_ts"] }
Expand Down
1 change: 0 additions & 1 deletion frontend/appflowy_web_app/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ lib-dispatch = { path = "../../rust-lib/lib-dispatch", features = [
"use_serde",
] }
flowy-core = { path = "../../rust-lib/flowy-core", features = [
"rev-sqlite",
"ts",
] }
flowy-user = { path = "../../rust-lib/flowy-user", features = ["tauri_ts"] }
Expand Down
5 changes: 2 additions & 3 deletions frontend/rust-lib/dart-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@ serde_yaml = "0.9.27"
flowy-error = { workspace = true, features = ["impl_from_sqlite", "impl_from_dispatch_error", "impl_from_appflowy_cloud", "impl_from_reqwest", "impl_from_serde", "dart"] }

[features]
default = ["dart", "rev-sqlite"]
default = ["dart"]
dart = ["flowy-core/dart"]
rev-sqlite = ["flowy-core/rev-sqlite"]
http_sync = ["flowy-core/http_sync", "flowy-core/use_bunyan"]
http_sync = ["flowy-core/http_sync"]
openssl_vendored = ["flowy-core/openssl_vendored"]
verbose_log = []

Expand Down
3 changes: 0 additions & 3 deletions frontend/rust-lib/flowy-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,9 @@ sysinfo = "0.30.5"
semver = "1.0.22"

[features]
default = ["rev-sqlite"]
profiling = ["console-subscriber", "tokio/tracing"]
http_sync = []
native_sync = []
use_bunyan = ["lib-log/use_bunyan"]
dart = [
"flowy-user/dart",
"flowy-date/dart",
Expand All @@ -71,7 +69,6 @@ ts = [
"flowy-database2/ts",
"flowy-config/tauri_ts",
]
rev-sqlite = ["flowy-user/rev-sqlite"]
openssl_vendored = ["flowy-sqlite/openssl_vendored"]

# Enable/Disable AppFlowy Verbose Log Configuration
Expand Down
3 changes: 1 addition & 2 deletions frontend/rust-lib/flowy-core/src/integrate/trait_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use collab::preclude::CollabPlugin;
use collab_entity::CollabType;
use collab_plugins::cloud_storage::postgres::SupabaseDBPlugin;
use tokio_stream::wrappers::WatchStream;
use tracing::{debug, instrument};
use tracing::debug;

use collab_integrate::collab_builder::{
CollabCloudPluginProvider, CollabPluginProviderContext, CollabPluginProviderType,
Expand Down Expand Up @@ -325,7 +325,6 @@ impl CollabCloudPluginProvider for ServerProvider {
self.get_server_type().into()
}

#[instrument(level = "debug", skip(self, context), fields(server_type = %self.get_server_type()))]
fn get_plugins(&self, context: CollabPluginProviderContext) -> Vec<Box<dyn CollabPlugin>> {
// If the user is local, we don't need to create a sync plugin.
if self.get_server_type().is_local() {
Expand Down
4 changes: 1 addition & 3 deletions frontend/rust-lib/flowy-folder/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use parking_lot::RwLock;
use std::fmt::{Display, Formatter};
use std::ops::Deref;
use std::sync::{Arc, Weak};
use tracing::{error, info, instrument, trace};
use tracing::{error, info, instrument};

conditional_send_sync_trait! {
"[crate::manager::FolderUser] represents the user for folder.";
Expand Down Expand Up @@ -367,7 +367,6 @@ impl FolderManager {
///
/// * `none_callback`: A callback function that is invoked when `mutex_folder` contains `None`.
/// * `f2`: A callback function that is invoked when `mutex_folder` contains a `Some` value. The contained folder is passed as an argument to this callback.
#[instrument(level = "debug", skip_all)]
fn with_folder<F1, F2, Output>(&self, none_callback: F1, f2: F2) -> Output
where
F1: FnOnce() -> Output,
Expand Down Expand Up @@ -482,7 +481,6 @@ impl FolderManager {
/// again using the ID of the child view you wish to access.
#[tracing::instrument(level = "debug", skip(self))]
pub async fn get_view_pb(&self, view_id: &str) -> FlowyResult<ViewPB> {
trace!("Get view pb with id: {}", view_id);
let view_id = view_id.to_string();

let folder = self.mutex_folder.read();
Expand Down
4 changes: 1 addition & 3 deletions frontend/rust-lib/flowy-user/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2018"

[dependencies]
flowy-derive.workspace = true
flowy-sqlite = { workspace = true, optional = true }
flowy-sqlite = { workspace = true }
flowy-encrypt = { workspace = true }
flowy-error = { workspace = true, features = ["impl_from_dispatch_error", "impl_from_sqlite", "impl_from_collab_folder", "impl_from_collab_persistence"] }
flowy-folder-pub = { workspace = true }
Expand Down Expand Up @@ -57,8 +57,6 @@ rand_core = "0.6.2"
quickcheck_macros = "1.0"

[features]
default = ["rev-sqlite"]
rev-sqlite = ["flowy-sqlite"]
dart = ["flowy-codegen/dart", "flowy-notification/dart"]
tauri_ts = ["flowy-codegen/ts", "flowy-notification/tauri_ts"]

Expand Down
6 changes: 4 additions & 2 deletions frontend/rust-lib/flowy-user/src/user_manager/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ impl UserManager {

if let Ok(session) = self.get_session() {
let user = self.get_user_profile_from_disk(session.user_id).await?;

// Get the current authenticator from the environment variable
let current_authenticator = current_authenticator();

Expand All @@ -151,9 +152,10 @@ impl UserManager {

event!(
tracing::Level::INFO,
"init user session: {}:{}",
"init user session: {}:{}, authenticator: {:?}",
user.uid,
user.email
user.email,
user.authenticator,
);

self.prepare_user(&session).await;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,19 @@ impl UserManager {
Ok(())
}

#[instrument(level = "info", skip(self), err)]
pub async fn add_workspace(&self, workspace_name: &str) -> FlowyResult<UserWorkspace> {
let new_workspace = self
.cloud_services
.get_user_service()?
.create_workspace(workspace_name)
.await?;

info!(
"new workspace: {}, name:{}",
new_workspace.id, new_workspace.name
);

// save the workspace to sqlite db
let uid = self.user_id()?;
let mut conn = self.db_connection(uid)?;
Expand Down Expand Up @@ -208,7 +214,9 @@ impl UserManager {
save_user_workspaces(uid, conn, &[user_workspace])
}

#[instrument(level = "info", skip(self), err)]
pub async fn leave_workspace(&self, workspace_id: &str) -> FlowyResult<()> {
info!("leave workspace: {}", workspace_id);
self
.cloud_services
.get_user_service()?
Expand All @@ -221,7 +229,9 @@ impl UserManager {
delete_user_workspaces(conn, workspace_id)
}

#[instrument(level = "info", skip(self), err)]
pub async fn delete_workspace(&self, workspace_id: &str) -> FlowyResult<()> {
info!("delete workspace: {}", workspace_id);
self
.cloud_services
.get_user_service()?
Expand Down
6 changes: 1 addition & 5 deletions frontend/rust-lib/lib-log/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

tracing-subscriber = { version = "0.3.17", features = ["registry", "env-filter", "ansi", "json"] }
tracing-bunyan-formatter = "0.3.9"
tracing-appender = "0.2.3"
Expand All @@ -16,7 +15,4 @@ serde_json.workspace = true
serde.workspace = true
chrono = "0.4"
lazy_static = "1.4.0"
lib-infra.workspace = true

[features]
use_bunyan = []
lib-infra.workspace = true
2 changes: 1 addition & 1 deletion frontend/rust-lib/lib-log/src/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ where
) -> Result<(), std::io::Error> {
map_serializer.serialize_entry(MESSAGE, &message)?;
// map_serializer.serialize_entry(LEVEL, &format!("{}", level))?;
map_serializer.serialize_entry(TIME, &Local::now().format("%Y-%m-%d %H:%M:%S").to_string())?;
map_serializer.serialize_entry(TIME, &Local::now().format("%m-%d %H:%M:%S").to_string())?;
Ok(())
}

Expand Down
Loading

0 comments on commit 77d600a

Please sign in to comment.