mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: build tauri from vscode launch (#1720)
* chore: build tauri from vscode launch * fix: unit test Co-authored-by: nathan <nathan@appflowy.io>
This commit is contained in:
parent
e6b186cc43
commit
d77c41013f
4
frontend/.vscode/launch.json
vendored
4
frontend/.vscode/launch.json
vendored
@ -94,7 +94,7 @@
|
|||||||
{
|
{
|
||||||
"type": "lldb",
|
"type": "lldb",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "AF: Tauri dev",
|
"name": "AF-tauri: Dev",
|
||||||
"cargo": {
|
"cargo": {
|
||||||
"args": [
|
"args": [
|
||||||
"build",
|
"build",
|
||||||
@ -102,7 +102,7 @@
|
|||||||
"--no-default-features"
|
"--no-default-features"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"preLaunchTask": "tauri:dev",
|
"preLaunchTask": "AF: Tauri Dev",
|
||||||
"cwd": "${workspaceRoot}/appflowy_tauri/"
|
"cwd": "${workspaceRoot}/appflowy_tauri/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
16
frontend/.vscode/tasks.json
vendored
16
frontend/.vscode/tasks.json
vendored
@ -14,7 +14,7 @@
|
|||||||
"type": "shell",
|
"type": "shell",
|
||||||
"dependsOrder": "sequence",
|
"dependsOrder": "sequence",
|
||||||
"dependsOn": [
|
"dependsOn": [
|
||||||
"AF: Rust Clean",
|
"AF: Dart Clean",
|
||||||
"AF: Flutter Clean",
|
"AF: Flutter Clean",
|
||||||
"AF: build_flowy_sdk",
|
"AF: build_flowy_sdk",
|
||||||
"AF: Flutter Pub Get",
|
"AF: Flutter Pub Get",
|
||||||
@ -32,7 +32,7 @@
|
|||||||
"type": "shell",
|
"type": "shell",
|
||||||
"dependsOrder": "sequence",
|
"dependsOrder": "sequence",
|
||||||
"dependsOn": [
|
"dependsOn": [
|
||||||
"AF: Rust Clean",
|
"AF: Dart Clean",
|
||||||
"AF: Flutter Clean",
|
"AF: Flutter Clean",
|
||||||
"AF: build_flowy_sdk_for_android",
|
"AF: build_flowy_sdk_for_android",
|
||||||
"AF: Flutter Pub Get",
|
"AF: Flutter Pub Get",
|
||||||
@ -166,7 +166,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "AF: Rust Clean",
|
"label": "AF: Dart Clean",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "cargo make dart_clean",
|
"command": "cargo make dart_clean",
|
||||||
"group": "build",
|
"group": "build",
|
||||||
@ -187,7 +187,7 @@
|
|||||||
"detail": "app_flowy"
|
"detail": "app_flowy"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "tauri:dev",
|
"label": "AF: Tauri Dev",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"isBackground": true,
|
"isBackground": true,
|
||||||
"command": "npm run dev",
|
"command": "npm run dev",
|
||||||
@ -196,5 +196,13 @@
|
|||||||
"cwd": "${workspaceFolder}/appflowy_tauri"
|
"cwd": "${workspaceFolder}/appflowy_tauri"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"label": "AF: Tauri Clean",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "cargo make tauri_clean",
|
||||||
|
"options": {
|
||||||
|
"cwd": "${workspaceFolder}"
|
||||||
|
}
|
||||||
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -1,3 +1,7 @@
|
|||||||
|
use std::env;
|
||||||
fn main() {
|
fn main() {
|
||||||
|
env::set_var("TAURI_PROTOBUF_PATH", "appflowy_tauri/src/protobuf");
|
||||||
|
env::set_var("CARGO_MAKE_WORKING_DIRECTORY", "../../../");
|
||||||
|
|
||||||
tauri_build::build()
|
tauri_build::build()
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,4 @@ http_sync = ["flowy-core/http_sync", "flowy-core/use_bunyan"]
|
|||||||
openssl_vendored = ["flowy-core/openssl_vendored"]
|
openssl_vendored = ["flowy-core/openssl_vendored"]
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
flowy-codegen = { path = "../flowy-codegen", features = [
|
flowy-codegen = { path = "../flowy-codegen", features = ["dart"] }
|
||||||
"dart",
|
|
||||||
]}
|
|
||||||
|
|
||||||
|
@ -6,17 +6,17 @@ edition = "2018"
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
lazy_static = {version = "1.4.0"}
|
lazy_static = { version = "1.4.0" }
|
||||||
protobuf = {version = "2.20.0"}
|
protobuf = { version = "2.20.0" }
|
||||||
allo-isolate = {version = "^0.1", features = ["catch-unwind",]}
|
allo-isolate = { version = "^0.1", features = ["catch-unwind"] }
|
||||||
log = "0.4.14"
|
log = "0.4.14"
|
||||||
bytes = { version = "1.0" }
|
bytes = { version = "1.0" }
|
||||||
|
|
||||||
flowy-derive = {path = "../flowy-derive" }
|
flowy-derive = { path = "../flowy-derive" }
|
||||||
lib-dispatch = {path = "../lib-dispatch" }
|
lib-dispatch = { path = "../lib-dispatch" }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
flowy-codegen = { path = "../flowy-codegen", features = ["dart"]}
|
flowy-codegen = { path = "../flowy-codegen" }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
dart = []
|
dart = ["flowy-codegen/dart"]
|
||||||
|
@ -16,7 +16,7 @@ cmd_lib = { version = "1", optional = true }
|
|||||||
protoc-rust = { version = "2", optional = true }
|
protoc-rust = { version = "2", optional = true }
|
||||||
walkdir = { version = "2", optional = true }
|
walkdir = { version = "2", optional = true }
|
||||||
similar = { version = "1.2.2", optional = true }
|
similar = { version = "1.2.2", optional = true }
|
||||||
syn = { version = "1.0.60", features = ["extra-traits", "parsing", "derive", "full"], optional = true }
|
syn = { version = "1.0.60", features = ["extra-traits", "parsing", "derive", "full"] }
|
||||||
fancy-regex = { version = "0.10.0", optional = true }
|
fancy-regex = { version = "0.10.0", optional = true }
|
||||||
lazy_static = { version = "1.4.0", optional = true }
|
lazy_static = { version = "1.4.0", optional = true }
|
||||||
tera = { version = "1.5.0", optional = true}
|
tera = { version = "1.5.0", optional = true}
|
||||||
@ -31,7 +31,6 @@ toml = {version = "0.5.8", optional = true}
|
|||||||
[features]
|
[features]
|
||||||
proto_gen = [
|
proto_gen = [
|
||||||
"similar",
|
"similar",
|
||||||
"syn",
|
|
||||||
"fancy-regex",
|
"fancy-regex",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"tera",
|
"tera",
|
||||||
@ -45,7 +44,7 @@ proto_gen = [
|
|||||||
"walkdir",
|
"walkdir",
|
||||||
"protoc-bin-vendored",
|
"protoc-bin-vendored",
|
||||||
]
|
]
|
||||||
dart_event = ["walkdir", "tera", "syn"]
|
dart_event = ["walkdir", "tera", ]
|
||||||
dart = ["proto_gen", "dart_event"]
|
dart = ["proto_gen", "dart_event"]
|
||||||
ts_event = ["walkdir", "tera", "syn"]
|
ts_event = ["walkdir", "tera", ]
|
||||||
ts = ["proto_gen", "ts_event"]
|
ts = ["proto_gen", "ts_event"]
|
@ -1,5 +1,5 @@
|
|||||||
use super::event_template::*;
|
use super::event_template::*;
|
||||||
use crate::dart_event::ast::EventASTContext;
|
use crate::ast::EventASTContext;
|
||||||
use crate::flowy_toml::{parse_crate_config_from, CrateConfig};
|
use crate::flowy_toml::{parse_crate_config_from, CrateConfig};
|
||||||
use crate::util::{is_crate_dir, is_hidden, path_string_with_component, read_file};
|
use crate::util::{is_crate_dir, is_hidden, path_string_with_component, read_file};
|
||||||
use flowy_ast::ASTResult;
|
use flowy_ast::ASTResult;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#![allow(clippy::module_inception)]
|
#![allow(clippy::module_inception)]
|
||||||
pub(crate) mod ast;
|
|
||||||
mod dart_event;
|
mod dart_event;
|
||||||
mod event_template;
|
mod event_template;
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ pub mod ts_event;
|
|||||||
#[cfg(any(feature = "proto_gen", feature = "dart_event", feature = "ts_event"))]
|
#[cfg(any(feature = "proto_gen", feature = "dart_event", feature = "ts_event"))]
|
||||||
mod flowy_toml;
|
mod flowy_toml;
|
||||||
|
|
||||||
|
pub(crate) mod ast;
|
||||||
#[cfg(any(feature = "proto_gen", feature = "dart_event", feature = "ts_event"))]
|
#[cfg(any(feature = "proto_gen", feature = "dart_event", feature = "ts_event"))]
|
||||||
pub mod util;
|
pub mod util;
|
||||||
|
|
||||||
|
@ -100,14 +100,13 @@ fn generate_ts_protobuf_files(
|
|||||||
file_names: &Vec<String>,
|
file_names: &Vec<String>,
|
||||||
protoc_bin_path: &Path,
|
protoc_bin_path: &Path,
|
||||||
) {
|
) {
|
||||||
if std::env::var("TAURI_PROTOBUF_PATH").is_err() {
|
let root = std::env::var("CARGO_MAKE_WORKING_DIRECTORY").unwrap_or("../../".to_string());
|
||||||
eprintln!("TAURI_PROTOBUF_PATH was not set, skip generate ts pb");
|
let tauri_protobuf_path =
|
||||||
return;
|
std::env::var("CARGO_MAKE_WORKING_DIRECTORY").unwrap_or("appflowy_tauri/src/protobuf".to_string());
|
||||||
}
|
|
||||||
|
|
||||||
let mut output = PathBuf::new();
|
let mut output = PathBuf::new();
|
||||||
output.push(std::env::var("CARGO_MAKE_WORKING_DIRECTORY").unwrap());
|
output.push(root);
|
||||||
output.push(std::env::var("TAURI_PROTOBUF_PATH").unwrap());
|
output.push(tauri_protobuf_path);
|
||||||
output.push("classes");
|
output.push("classes");
|
||||||
output.push(name);
|
output.push(name);
|
||||||
|
|
||||||
@ -159,12 +158,12 @@ fn generate_dart_protobuf_files(
|
|||||||
protoc_bin_path: &Path,
|
protoc_bin_path: &Path,
|
||||||
) {
|
) {
|
||||||
if std::env::var("CARGO_MAKE_WORKING_DIRECTORY").is_err() {
|
if std::env::var("CARGO_MAKE_WORKING_DIRECTORY").is_err() {
|
||||||
log::warn!("CARGO_MAKE_WORKING_DIRECTORY was not set, skip generate dart pb");
|
log::error!("CARGO_MAKE_WORKING_DIRECTORY was not set, skip generate dart pb");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if std::env::var("FLUTTER_FLOWY_SDK_PATH").is_err() {
|
if std::env::var("FLUTTER_FLOWY_SDK_PATH").is_err() {
|
||||||
log::warn!("FLUTTER_FLOWY_SDK_PATH was not set, skip generate dart pb");
|
log::error!("FLUTTER_FLOWY_SDK_PATH was not set, skip generate dart pb");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
mod event_template;
|
mod event_template;
|
||||||
|
|
||||||
use crate::dart_event::ast::EventASTContext;
|
use crate::ast::EventASTContext;
|
||||||
use crate::flowy_toml::{parse_crate_config_from, CrateConfig};
|
use crate::flowy_toml::{parse_crate_config_from, CrateConfig};
|
||||||
use crate::ts_event::event_template::{EventRenderContext, EventTemplate};
|
use crate::ts_event::event_template::{EventRenderContext, EventTemplate};
|
||||||
use crate::util::{is_crate_dir, is_hidden, path_string_with_component, read_file};
|
use crate::util::{is_crate_dir, is_hidden, path_string_with_component, read_file};
|
||||||
@ -13,10 +13,9 @@ use syn::Item;
|
|||||||
use walkdir::WalkDir;
|
use walkdir::WalkDir;
|
||||||
|
|
||||||
pub fn gen(crate_name: &str) {
|
pub fn gen(crate_name: &str) {
|
||||||
if std::env::var("TAURI_PROTOBUF_PATH").is_err() {
|
let root = std::env::var("CARGO_MAKE_WORKING_DIRECTORY").unwrap_or("../../".to_string());
|
||||||
log::warn!("TAURI_PROTOBUF_PATH was not set, skip generate ts event");
|
let tauri_protobuf_path =
|
||||||
return;
|
std::env::var("CARGO_MAKE_WORKING_DIRECTORY").unwrap_or("appflowy_tauri/src/protobuf".to_string());
|
||||||
}
|
|
||||||
|
|
||||||
let crate_path = std::fs::canonicalize(".").unwrap().as_path().display().to_string();
|
let crate_path = std::fs::canonicalize(".").unwrap().as_path().display().to_string();
|
||||||
let event_crates = parse_ts_event_files(vec![crate_path]);
|
let event_crates = parse_ts_event_files(vec![crate_path]);
|
||||||
@ -33,15 +32,7 @@ pub fn gen(crate_name: &str) {
|
|||||||
}
|
}
|
||||||
render_result.push_str(TS_FOOTER);
|
render_result.push_str(TS_FOOTER);
|
||||||
|
|
||||||
let ts_event_folder: PathBuf = [
|
let ts_event_folder: PathBuf = [&root, &tauri_protobuf_path, "events", crate_name].iter().collect();
|
||||||
&std::env::var("CARGO_MAKE_WORKING_DIRECTORY").unwrap(),
|
|
||||||
&std::env::var("TAURI_PROTOBUF_PATH").unwrap(),
|
|
||||||
"events",
|
|
||||||
crate_name,
|
|
||||||
]
|
|
||||||
.iter()
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
if !ts_event_folder.as_path().exists() {
|
if !ts_event_folder.as_path().exists() {
|
||||||
std::fs::create_dir_all(ts_event_folder.as_path()).unwrap();
|
std::fs::create_dir_all(ts_event_folder.as_path()).unwrap();
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ where
|
|||||||
pub async fn pong(&self, user: Arc<dyn RevisionUser>, client_rev_id: i64) -> Result<(), CollaborateError> {
|
pub async fn pong(&self, user: Arc<dyn RevisionUser>, client_rev_id: i64) -> Result<(), CollaborateError> {
|
||||||
let object_id = self.object_id.clone();
|
let object_id = self.object_id.clone();
|
||||||
let server_rev_id = self.rev_id();
|
let server_rev_id = self.rev_id();
|
||||||
tracing::Span::current().record("server_rev_id", &server_rev_id);
|
tracing::Span::current().record("server_rev_id", server_rev_id);
|
||||||
match server_rev_id.cmp(&client_rev_id) {
|
match server_rev_id.cmp(&client_rev_id) {
|
||||||
Ordering::Less => {
|
Ordering::Less => {
|
||||||
tracing::trace!("Client should not send ping and the server should pull the revisions from the client")
|
tracing::trace!("Client should not send ping and the server should pull the revisions from the client")
|
||||||
@ -171,7 +171,7 @@ where
|
|||||||
#[tracing::instrument(level = "debug", skip(self, revisions), fields(object_id), err)]
|
#[tracing::instrument(level = "debug", skip(self, revisions), fields(object_id), err)]
|
||||||
pub async fn reset(&self, revisions: Vec<Revision>) -> Result<(), CollaborateError> {
|
pub async fn reset(&self, revisions: Vec<Revision>) -> Result<(), CollaborateError> {
|
||||||
let object_id = self.object_id.clone();
|
let object_id = self.object_id.clone();
|
||||||
tracing::Span::current().record("object_id", &object_id.as_str());
|
tracing::Span::current().record("object_id", object_id.as_str());
|
||||||
let (_, rev_id) = pair_rev_id_from_revision_pbs(&revisions);
|
let (_, rev_id) = pair_rev_id_from_revision_pbs(&revisions);
|
||||||
let operations = make_operations_from_revisions(revisions.clone())?;
|
let operations = make_operations_from_revisions(revisions.clone())?;
|
||||||
self.persistence.reset_object(&object_id, revisions).await?;
|
self.persistence.reset_object(&object_id, revisions).await?;
|
||||||
|
@ -1,37 +1,45 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[tasks.tauri_env]
|
||||||
|
script_runner = "@rust"
|
||||||
|
script = '''
|
||||||
|
//! ```cargo
|
||||||
|
use std::env;
|
||||||
|
fn main() {
|
||||||
|
env.set_var("TAURI_PROTOBUF_PATH", "appflowy_tauri/src/protobuf");
|
||||||
|
}
|
||||||
|
'''
|
||||||
|
|
||||||
|
|
||||||
[tasks.tauri_build]
|
[tasks.tauri_build]
|
||||||
script = [
|
script = ["""
|
||||||
"""
|
|
||||||
cd appflowy_tauri/src-tauri
|
cd appflowy_tauri/src-tauri
|
||||||
npm run tauri build
|
npm run tauri build
|
||||||
""",
|
"""]
|
||||||
]
|
|
||||||
script_runner = "@shell"
|
script_runner = "@shell"
|
||||||
|
|
||||||
[tasks.tauri_pb]
|
[tasks.tauri_pb]
|
||||||
script = [
|
script = ["""
|
||||||
"""
|
|
||||||
cd appflowy_tauri/src-tauri
|
cd appflowy_tauri/src-tauri
|
||||||
cargo build
|
cargo build
|
||||||
""",
|
"""]
|
||||||
]
|
|
||||||
script_runner = "@shell"
|
script_runner = "@shell"
|
||||||
|
|
||||||
[tasks.tauri_dev]
|
[tasks.tauri_dev]
|
||||||
script = [
|
script = ["""
|
||||||
"""
|
|
||||||
cd appflowy_tauri
|
cd appflowy_tauri
|
||||||
npm run tauri dev
|
npm run tauri dev
|
||||||
""",
|
"""]
|
||||||
]
|
|
||||||
script_runner = "@shell"
|
script_runner = "@shell"
|
||||||
|
|
||||||
[tasks.tauri_clean]
|
[tasks.tauri_clean]
|
||||||
run_task = { name = [
|
run_task = { name = [
|
||||||
"rust_lib_clean",
|
"rust_lib_clean",
|
||||||
"rm_macro_build_cache",
|
"rm_macro_build_cache",
|
||||||
"rm_rust_generated_files",
|
"rm_rust_generated_files",
|
||||||
"rm_tauri_generated_protobuf_files",
|
"rm_tauri_generated_protobuf_files",
|
||||||
"rm_tauri_generated_event_files",
|
"rm_tauri_generated_event_files",
|
||||||
] }
|
] }
|
||||||
|
|
||||||
[tasks.rm_tauri_generated_protobuf_files]
|
[tasks.rm_tauri_generated_protobuf_files]
|
||||||
|
Loading…
Reference in New Issue
Block a user