v0.1.0-pre.054
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// file: kb-app-demo-desktop/src/app_state.rs
|
||||
// version: 6
|
||||
// version: 8
|
||||
|
||||
//! Shared Tauri application state and startup initialization.
|
||||
|
||||
@@ -28,6 +28,7 @@ pub(crate) struct AppState {
|
||||
impl crate::AppState {
|
||||
/// Initializes configuration, logging and shared runtime state.
|
||||
pub(crate) fn initialize() -> kb_core::Result<crate::AppState> {
|
||||
load_workspace_dotenv();
|
||||
let config_path = resolve_config_path();
|
||||
let app_config = match kb_config::read_config_json_file(&config_path) {
|
||||
std::result::Result::Ok(config) => config,
|
||||
@@ -179,6 +180,23 @@ impl crate::AppState {
|
||||
}
|
||||
}
|
||||
|
||||
fn load_workspace_dotenv() {
|
||||
let workspace_path = crate::workspace_root_dir().join(".env");
|
||||
load_dotenv_path(&workspace_path);
|
||||
let desktop_path = crate::workspace_root_dir().join("kb-app-demo-desktop/.env");
|
||||
load_dotenv_path(&desktop_path);
|
||||
}
|
||||
|
||||
fn load_dotenv_path(path: &std::path::Path) {
|
||||
let result = dotenvy::from_path(path);
|
||||
if let std::result::Result::Err(error) = result {
|
||||
if matches!(error, dotenvy::Error::Io(ref io_error) if io_error.kind() == std::io::ErrorKind::NotFound) {
|
||||
return;
|
||||
}
|
||||
eprintln!("cannot load {}: {error}", path.display());
|
||||
}
|
||||
}
|
||||
|
||||
fn convert_logging_config(config: &kb_config::LoggingConfig) -> kb_logging::LoggingConfig {
|
||||
let mut targets = std::vec::Vec::<kb_logging::LogTargetConfig>::new();
|
||||
for target in &config.targets {
|
||||
|
||||
Reference in New Issue
Block a user