summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.rs45
-rwxr-xr-xgit-hooks/pre-commit2
-rwxr-xr-xtools/run1
3 files changed, 42 insertions, 6 deletions
diff --git a/build.rs b/build.rs
index d506869..a61b2db 100644
--- a/build.rs
+++ b/build.rs
@@ -1,5 +1,44 @@
-// generated by `sqlx migrate build-script`
-fn main() {
+use std::{io, process::Command};
+
+fn main() -> Result<(), io::Error> {
// trigger recompilation when a new migration is added
- println!("cargo:rerun-if-changed=migrations");
+ println!("cargo::rerun-if-changed=migrations");
+
+ // rerun npm install whenever packages or npm config are changed
+ println!("cargo::rerun-if-changed=.npmrc");
+ println!("cargo::rerun-if-changed=package.json");
+ // `node_modules` and `package-lock.json` are always touched if `npm install`
+ // runs, leading to spurious rebuilds.
+ //
+ // See: <https://github.com/npm/cli/issues/7874>
+ // println!("cargo::rerun-if-changed=package-lock.json");
+ // println!("cargo::rerun-if-changed=node_modules");
+ let status = Command::new("npm").args(["install"]).status()?;
+ if !status.success() {
+ return Err(io::Error::other(format!(
+ "'npm install' exited with status {status:?}"
+ )));
+ }
+
+ // rerun `npm run build` whenever the UI changes.
+ //
+ // `node_modules` is always touched if `npm install` runs, leading to spurious
+ // rebuilds. (This duplicate is purely organizational; it reflects that the ui
+ // depends on node_modules.)
+ //
+ // See: <https://github.com/npm/cli/issues/7874>
+ // println!("cargo::rerun-if-changed=node_modules");
+ println!("cargo::rerun-if-changed=postcss.config.js");
+ println!("cargo::rerun-if-changed=svelte.config.js");
+ println!("cargo::rerun-if-changed=tailwind.config.js");
+ println!("cargo::rerun-if-changed=vite.config.js");
+ println!("cargo::rerun-if-changed=ui");
+ let status = Command::new("npm").args(["run", "build"]).status()?;
+ if !status.success() {
+ return Err(io::Error::other(format!(
+ "'npm run build' exited with status {status:?}"
+ )));
+ }
+
+ Ok(())
}
diff --git a/git-hooks/pre-commit b/git-hooks/pre-commit
index cafdb8d..cd2f9ee 100755
--- a/git-hooks/pre-commit
+++ b/git-hooks/pre-commit
@@ -4,8 +4,6 @@
# run. It gets old fast. That's why this uses `cargo check` and not `cargo
# test`, for example.
-# Make sure the UI is up to date.
-tools/build-ui
# Make sure Cargo.lock is up to date with Cargo.toml.
cargo update --locked --workspace
# Make sure there are no screamers in the code.
diff --git a/tools/run b/tools/run
index 452355e..b063eb7 100755
--- a/tools/run
+++ b/tools/run
@@ -4,5 +4,4 @@
##
## Run the server in development mode. Shorthand for `cargo run`.
-tools/build-ui
cargo run -- "$@"