use std::path::Path;
const COMPILED_ASSETS: &[(&str, &str)] = &[
("static/css/output.css", "npm run build-css"),
("static/js/editor.bundle.js", "npm run build-js"),
];
fn main() {
let mut missing = Vec::new();
for (path, command) in COMPILED_ASSETS {
println!("cargo:rerun-if-changed={path}");
if !Path::new(path).exists() {
missing.push((path, command));
}
}
if missing.is_empty() {
return;
}
eprintln!("error: missing compiled front-end assets:");
for (path, command) in &missing {
eprintln!(" - {path} (generate with: {command})");
}
eprintln!(
"\n\
These files are generated and not checked into git, so they are absent\n\
from git clones and from GitHub's auto-generated tag archives.\n\
Building them requires Node.js:\n\
\n\
\tnpm install\n\
\tnpm run build-css\n\
\tnpm run build-js\n\
\n\
Without them the web UI (`cook server`, `cook build web`) renders\n\
unstyled pages. To build without Node.js, use a source drop that ships\n\
them prebuilt: the `cook-<version>-source.tar.gz` asset on the GitHub\n\
release, or the crates.io package (`cargo install cookcli`)."
);
std::process::exit(1);
}