2023-11-28 02:54:31 +00:00
|
|
|
use std::collections::HashMap;
|
|
|
|
|
2023-05-23 15:55:21 +00:00
|
|
|
use serde::Deserialize;
|
|
|
|
|
2024-01-11 06:42:03 +00:00
|
|
|
use flowy_server_pub::af_cloud_config::AFCloudConfiguration;
|
|
|
|
use flowy_server_pub::supabase_config::SupabaseConfiguration;
|
|
|
|
use flowy_server_pub::AuthenticatorType;
|
2023-07-05 12:57:09 +00:00
|
|
|
|
2023-05-23 15:55:21 +00:00
|
|
|
#[derive(Deserialize, Debug)]
|
2023-11-20 12:54:47 +00:00
|
|
|
pub struct AppFlowyDartConfiguration {
|
2023-11-28 02:54:31 +00:00
|
|
|
/// The root path of the application
|
|
|
|
pub root: String,
|
2024-01-30 01:33:34 +00:00
|
|
|
pub app_version: String,
|
2023-11-20 12:54:47 +00:00
|
|
|
/// This path will be used to store the user data
|
|
|
|
pub custom_app_path: String,
|
|
|
|
pub origin_app_path: String,
|
|
|
|
pub device_id: String,
|
2023-11-28 02:54:31 +00:00
|
|
|
pub authenticator_type: AuthenticatorType,
|
2023-11-20 12:54:47 +00:00
|
|
|
pub(crate) supabase_config: SupabaseConfiguration,
|
|
|
|
pub(crate) appflowy_cloud_config: AFCloudConfiguration,
|
2023-11-28 02:54:31 +00:00
|
|
|
#[serde(default)]
|
|
|
|
pub(crate) envs: HashMap<String, String>,
|
2023-05-23 15:55:21 +00:00
|
|
|
}
|
|
|
|
|
2023-11-20 12:54:47 +00:00
|
|
|
impl AppFlowyDartConfiguration {
|
|
|
|
pub fn from_str(s: &str) -> Self {
|
|
|
|
serde_json::from_str::<AppFlowyDartConfiguration>(s).unwrap()
|
2023-11-17 07:38:56 +00:00
|
|
|
}
|
|
|
|
|
2023-11-28 02:54:31 +00:00
|
|
|
pub fn write_env(&self) {
|
|
|
|
self.authenticator_type.write_env();
|
2024-01-11 22:26:43 +00:00
|
|
|
self.appflowy_cloud_config.write_env();
|
|
|
|
self.supabase_config.write_env();
|
2023-11-28 02:54:31 +00:00
|
|
|
|
|
|
|
for (k, v) in self.envs.iter() {
|
|
|
|
std::env::set_var(k, v);
|
|
|
|
}
|
2023-05-23 15:55:21 +00:00
|
|
|
}
|
|
|
|
}
|