huskies: merge 1037
This commit is contained in:
+2566
-175
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,30 @@
|
|||||||
|
//! CLI binary that regenerates `.huskies/source-map.json` from scratch.
|
||||||
|
//!
|
||||||
|
//! Usage: `source-map-regen [--project-root <path>]`
|
||||||
|
//!
|
||||||
|
//! Scans every tracked Rust and TypeScript file in the project via `git ls-files`,
|
||||||
|
//! extracts public item signatures, and writes a fresh sorted JSON map. The output
|
||||||
|
//! is byte-identical across runs on the same source tree (deterministic).
|
||||||
|
//!
|
||||||
|
//! Intended to be called from the pre-commit quality gate (`script/check`) so that
|
||||||
|
//! every commit captures an accurate, stale-entry-free snapshot of the source map.
|
||||||
|
|
||||||
|
use source_map_gen::regenerate_source_map;
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let args: Vec<String> = std::env::args().collect();
|
||||||
|
let root = parse_arg(&args, "--project-root").unwrap_or_else(|| ".".to_string());
|
||||||
|
let root_path = Path::new(&root);
|
||||||
|
let map_path = root_path.join(".huskies").join("source-map.json");
|
||||||
|
|
||||||
|
if let Err(e) = regenerate_source_map(root_path, &map_path) {
|
||||||
|
eprintln!("source-map-regen: {e}");
|
||||||
|
std::process::exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Parse a flag value from an argument list (e.g. `--flag value`).
|
||||||
|
fn parse_arg(args: &[String], flag: &str) -> Option<String> {
|
||||||
|
args.windows(2).find(|w| w[0] == flag).map(|w| w[1].clone())
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user