Lutra/xtask/src/main.rs
danny 3bd95343cc M0.3: xtask ci, layers, assets, cleanroom, ui-licences, dev, fixtures
layers reads cargo metadata and rejects upward, sideways and tool-crate
dependencies and any path to Tauri below L6. assets checks ASSETS.md rows
and rejects committed fonts. cleanroom rejects JetBrains copyright notices,
exported IDE configuration and .idea/.jar/.icls files. deny.toml mirrors
the licence allow list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 20:32:00 +02:00

66 lines
2.2 KiB
Rust

//! Project automation for Lutra, run as `cargo xtask <command>`.
//!
//! Every subcommand prints what it checks and exits with status 1 and a
//! message when the check fails.
mod assets;
mod cleanroom;
mod layers;
mod licences;
mod lints;
mod tasks;
mod util;
use std::process::ExitCode;
/// Usage text printed for `help` and unknown subcommands.
const USAGE: &str = "usage: cargo xtask <command>
commands:
ci [--skip-ui] the full quality gate (run before every commit)
layers check the crate layering
assets check that every asset has a row in ASSETS.md
cleanroom check for JetBrains copyright notices and exported configuration
ui-licences check the licences of the frontend's production dependencies
lints-selftest prove that shipped unwrap() fails clippy and test unwrap() passes
dev [-- ARGS] run the desktop app in development mode, ARGS go to the app
fixtures create Symfony and Laravel reference projects in target/fixtures/";
/// Dispatches to the subcommand named by the first argument.
fn main() -> ExitCode {
let args: Vec<String> = std::env::args().skip(1).collect();
let Some((command, rest)) = args.split_first() else {
println!("{USAGE}");
return ExitCode::SUCCESS;
};
let result = match command.as_str() {
"ci" => tasks::ci(rest.iter().any(|a| a == "--skip-ui")),
"layers" => layers::check_workspace(),
"assets" => assets::check_repo(),
"cleanroom" => cleanroom::check_repo(),
"ui-licences" => licences::check_ui(),
"lints-selftest" => lints::selftest(),
"dev" => {
let app_args: Vec<String> = rest
.iter()
.skip_while(|a| *a != "--")
.skip(1)
.cloned()
.collect();
tasks::dev(&app_args)
}
"fixtures" => tasks::fixtures(),
"help" | "--help" | "-h" => {
println!("{USAGE}");
Ok(())
}
other => Err(format!("unknown command `{other}`\n\n{USAGE}")),
};
match result {
Ok(()) => ExitCode::SUCCESS,
Err(message) => {
eprintln!("xtask: {message}");
ExitCode::FAILURE
}
}
}