Skip to content

Commit

Permalink
feat: embed webui assets into the binary (#385)
Browse files Browse the repository at this point in the history
  • Loading branch information
2e3s committed Sep 24, 2023
1 parent f962ccd commit 26acc28
Show file tree
Hide file tree
Showing 9 changed files with 241 additions and 143 deletions.
154 changes: 152 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions aw-client-rust/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ mod test {
use aw_client_rust::Event;
use chrono::{DateTime, Duration, Utc};
use serde_json::Map;
use std::path::PathBuf;
use std::sync::Mutex;
use std::thread;
use tokio_test::block_on;
Expand All @@ -38,10 +37,12 @@ mod test {
}

fn setup_testserver() -> rocket::Shutdown {
use aw_server::endpoints::AssetResolver;
use aw_server::endpoints::ServerState;

let state = ServerState {
datastore: Mutex::new(aw_datastore::Datastore::new_in_memory(false)),
asset_path: PathBuf::from("."), // webui won't be used, so it's invalidly set
asset_resolver: AssetResolver::new(None),
device_id: "test_id".to_string(),
};
let mut aw_config = aw_server::config::AWConfig::default();
Expand Down
1 change: 1 addition & 0 deletions aw-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ gethostname = "0.4"
uuid = { version = "1.3", features = ["serde", "v4"] }
clap = { version = "4.1", features = ["derive", "cargo"] }
log-panics = { version = "2", features = ["with-backtrace"]}
rust-embed = { version = "8.0.0", features = ["interpolate-folder-path"] }

aw-datastore = { path = "../aw-datastore" }
aw-models = { path = "../aw-models" }
Expand Down
8 changes: 8 additions & 0 deletions aw-server/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use std::error::Error;

fn main() -> Result<(), Box<dyn Error>> {
std::fs::create_dir_all("../aw-webui/dist").unwrap();
println!("cargo:rustc-env=AW_WEBUI_DIR=../aw-webui/dist");

Ok(())
}
Loading

0 comments on commit 26acc28

Please sign in to comment.