master
barrett-land Revert adom-nucleus -> adom-project-manager; repoint viewers to adom-2dboard / adom-schematic aa8944a 2mo ago
// Single-source the app version from package.json — the version the wiki actually
// publishes (`adom-wiki pkg publish` reads package.json). Historically the app reported
// env!("CARGO_PKG_VERSION") from Cargo.toml, which release.sh never kept in lockstep with
// package.json, so the update check compared a stale Cargo.toml version against the newer
// published version and showed a permanent phantom "Update available". Deriving the
// version from package.json at build time makes that class of bug impossible: the binary's
// reported version is always exactly the published version.
use std::fs;

fn main() {
    println!("cargo:rerun-if-changed=package.json");
    let ver = fs::read_to_string("package.json")
        .ok()
        .and_then(|s| {
            s.split("\"version\"")
                .nth(1)
                .and_then(|r| r.split('"').nth(1))
                .map(str::to_string)
        })
        .unwrap_or_else(|| env!("CARGO_PKG_VERSION").to_string());
    println!("cargo:rustc-env=APP_VERSION={ver}");
}