use crate::deploy::build_frontend_assets;
use crate::dev::build;
use anyhow::{Context, Result};
pub fn run() -> Result<()> {
let app_root = std::env::current_dir().context("reading current directory")?;
anyhow::ensure!(
app_root.join("Cargo.toml").is_file(),
"no Cargo.toml in the current directory - run `xr optimize` from inside a Larust app"
);
crate::build_cache::maybe_notify(&app_root);
build_frontend_assets(&app_root)?;
println!("xr optimize: building optimized Rust release...");
let binary = build(&app_root, true)?
.context("release build produced no binary artifact - check your app's [[bin]] target")?;
println!(
"xr optimize: production artifacts are ready ({}). Run `xr deploy` to publish them.",
binary.display()
);
Ok(())
}