//! The setup app trusts exactly what the app's updater trusts: the public //! key in the app's tauri.conf.json. Read at build time so there is one //! copy of it in the repository. use std::path::{Path, PathBuf}; fn main() { // The frontend is embedded only when tauri's `custom-protocol` feature is // on; without it the window points at devUrl and the exe we hand a tester // shows "localhost refused to connect". It is a default feature, so this // only fires when something turned the defaults off — and it fires at // build time rather than on the tester's machine. if tauri_build::is_dev() && std::env::var("PROFILE").as_deref() == Ok("release") { panic!("SoulStream Setup: a release build needs the `custom-protocol` feature (on by default); without it the window loads devUrl and is blank"); } let manifest = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap()); let conf = manifest.join("../../src-tauri/tauri.conf.json"); println!("cargo:rerun-if-changed={}", conf.display()); // tauri-build tracks the config, not the frontend the exe embeds: without // this, a changed Setup.svelte rebuilds `setup/dist` and cargo hands back // yesterday's binary, still carrying yesterday's window. println!("cargo:rerun-if-changed={}", manifest.join("../dist").display()); let text = std::fs::read_to_string(&conf).expect("read src-tauri/tauri.conf.json"); let json: serde_json::Value = serde_json::from_str(&text).expect("parse tauri.conf.json"); let pubkey = json["plugins"]["updater"]["pubkey"] .as_str() .filter(|s| !s.is_empty()) .expect("plugins.updater.pubkey in src-tauri/tauri.conf.json"); let out = Path::new(&std::env::var("OUT_DIR").unwrap()).join("pubkey.rs"); std::fs::write(&out, format!("pub const PUBKEY: &str = {pubkey:?};\n")).expect("write pubkey.rs"); tauri_build::build(); }