Files
craft-repo-status-app/crates/craft-status-app/build.rs
T
Brandon ThomasandClaude Opus 5.5 e621098b09 Port the UI to TypeScript and ban raw JavaScript
All UI code moves to strict TypeScript in ui/src/, compiled by tsc (no
bundler) to ui/build/, which index.html loads; the app's build.rs runs the
compile so every cargo build ships the current UI. Sources import each
other as ./x.ts so node --test runs them directly, and the data types
mirror crates/craft-core/src/model.rs.

app.ts now exports start(api) and main.ts wires it to Tauri or the browser
preview, so the UI can be tested in happy-dom against a fake host: sorting,
dragging, clicks, the window picker, status, the urgent view and shortcuts.
Sort toggling and drop placement move into model.ts with unit tests. The
inline error-reporting script becomes report.ts.

CLAUDE.md records the rule: no .js/.mjs/.cjs/.jsx files, inline scripts,
inline handlers or javascript: URLs. ui/src/repo.test.ts enforces it in
make test; make check adds a tsc type-check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 23:56:15 -04:00

38 lines
1.0 KiB
Rust

use std::path::Path;
use std::process::Command;
fn main() {
build_ui();
tauri_build::build()
}
/// Compiles the TypeScript UI (ui/src/) to ui/build/ before Tauri embeds
/// ui/, so every cargo build of the app ships the current UI.
fn build_ui() {
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../..");
for path in [
"ui/src",
"tsconfig.json",
"tsconfig.build.json",
"package.json",
"package-lock.json",
] {
println!("cargo:rerun-if-changed={}", root.join(path).display());
}
if !root.join("node_modules/.bin/tsc").exists() {
panic!(
"TypeScript isn't installed: run `npm ci` in {}",
root.display()
);
}
let status = Command::new("npm")
.args(["run", "--silent", "build"])
.current_dir(&root)
.status()
.expect("couldn't run npm; the UI build needs Node.js 24+");
assert!(
status.success(),
"the UI's TypeScript failed to compile (npm run build)"
);
}