rudimentary makefile, first "self-serving" version, enable NO_BROWSER flag

feat/vaults
Tomáš Mládek 2020-08-30 23:13:09 +02:00
parent 7faa12a44f
commit c27abd6cac
5 changed files with 31 additions and 4 deletions

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
/dist
/target
**/*.rs.bk

2
Cargo.lock generated
View File

@ -1710,7 +1710,7 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "upend-rust"
name = "upend"
version = "0.1.0"
dependencies = [
"actix 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -1,5 +1,5 @@
[package]
name = "upend-rust"
name = "upend"
version = "0.1.0"
authors = ["Tomáš Mládek <t@mldk.cz>"]
edition = "2018"
@ -32,4 +32,4 @@ bs58 = "0.3.1"
dotenv = "0.15.0"
xdg = "^2.1"
webbrowser = "0.5.5"
webbrowser = "0.5.5"

18
Makefile Normal file
View File

@ -0,0 +1,18 @@
all: backend frontend
rm -fr dist
mkdir dist
cp target/release/upend dist/upend
cp -r ui/dist dist/webui
backend:
cargo build --release
frontend:
cd ui && \
npm install && \
npm run build
clean:
rm -r target
rm -r ui/node_modules ui/dist

View File

@ -77,6 +77,13 @@ fn main() -> std::io::Result<()> {
.service(routes::get_raw)
.service(routes::get_lookup)
.service(routes::api_refresh)
.service(
actix_files::Files::new(
"/",
env::current_exe().unwrap().parent().unwrap().join("webui"),
)
.index_file("index.html"),
)
})
.bind(&bind)?
.run();
@ -87,7 +94,7 @@ fn main() -> std::io::Result<()> {
}
// TODO REMOVE
if !matches.is_present("NO_BROWSER") && false {
if !matches.is_present("NO_BROWSER") {
let ui_result = webbrowser::open(&format!("http://localhost:{}", bind.port()));
if ui_result.is_err() {
warn!("Could not open UI in browser!");