mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
* refactor: rename flowy-folder-deps to flowy-folder-pub * chore: rename crates * chore: move flowy-task to lib-infra * chore: rename crates * refactor: user manager dir
46 lines
1.2 KiB
Rust
46 lines
1.2 KiB
Rust
use std::collections::HashMap;
|
|
|
|
use serde::Deserialize;
|
|
|
|
use flowy_server_pub::af_cloud_config::AFCloudConfiguration;
|
|
use flowy_server_pub::supabase_config::SupabaseConfiguration;
|
|
use flowy_server_pub::AuthenticatorType;
|
|
|
|
#[derive(Deserialize, Debug)]
|
|
pub struct AppFlowyDartConfiguration {
|
|
/// The root path of the application
|
|
pub root: String,
|
|
/// This path will be used to store the user data
|
|
pub custom_app_path: String,
|
|
pub origin_app_path: String,
|
|
pub device_id: String,
|
|
pub authenticator_type: AuthenticatorType,
|
|
pub(crate) supabase_config: SupabaseConfiguration,
|
|
pub(crate) appflowy_cloud_config: AFCloudConfiguration,
|
|
#[serde(default)]
|
|
pub(crate) envs: HashMap<String, String>,
|
|
}
|
|
|
|
impl AppFlowyDartConfiguration {
|
|
pub fn from_str(s: &str) -> Self {
|
|
serde_json::from_str::<AppFlowyDartConfiguration>(s).unwrap()
|
|
}
|
|
|
|
pub fn write_env(&self) {
|
|
self.authenticator_type.write_env();
|
|
match self.authenticator_type {
|
|
AuthenticatorType::AppFlowyCloud => {
|
|
self.appflowy_cloud_config.write_env();
|
|
},
|
|
AuthenticatorType::Supabase => {
|
|
self.supabase_config.write_env();
|
|
},
|
|
_ => {},
|
|
}
|
|
|
|
for (k, v) in self.envs.iter() {
|
|
std::env::set_var(k, v);
|
|
}
|
|
}
|
|
}
|