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>
This commit is contained in:
danny 2026-10-13 20:32:00 +02:00
parent ec1c72d9ac
commit 3bd95343cc
8 changed files with 1130 additions and 2 deletions

View file

@ -2,6 +2,7 @@
//! child processes and listing the files that belong to the repository.
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
/// Result type of every xtask step; the error is a message for the console.
pub type TaskResult<T = ()> = Result<T, String>;
@ -17,3 +18,85 @@ pub fn repo_root() -> TaskResult<PathBuf> {
.map(Path::to_path_buf)
.ok_or_else(|| "xtask is not inside the workspace".to_string())
}
/// Resolves the name of a program for spawning.
///
/// On Windows, Node-based tools such as `pnpm` are batch shims (`pnpm.cmd`)
/// that `Command` does not find by their bare name.
pub fn program(name: &str) -> String {
if cfg!(windows) && matches!(name, "pnpm" | "npm" | "npx" | "composer") {
format!("{name}.cmd")
} else {
name.to_string()
}
}
/// Runs a program to completion with inherited stdio.
///
/// # Errors
/// Fails if the program cannot be started or exits unsuccessfully.
pub fn run(dir: &Path, name: &str, args: &[&str]) -> TaskResult {
let status = Command::new(program(name))
.args(args)
.current_dir(dir)
.status()
.map_err(|e| format!("cannot start `{name}`: {e}"))?;
if status.success() {
Ok(())
} else {
Err(format!("`{name} {}` failed ({status})", args.join(" ")))
}
}
/// Runs a program and captures its standard output as UTF-8 text.
///
/// Standard error is passed through to the console.
///
/// # Errors
/// Fails if the program cannot be started, exits unsuccessfully or prints
/// output that is not UTF-8.
pub fn capture(dir: &Path, name: &str, args: &[&str]) -> TaskResult<String> {
let output = Command::new(program(name))
.args(args)
.current_dir(dir)
.stderr(Stdio::inherit())
.output()
.map_err(|e| format!("cannot start `{name}`: {e}"))?;
if !output.status.success() {
return Err(format!(
"`{name} {}` failed ({})",
args.join(" "),
output.status
));
}
String::from_utf8(output.stdout).map_err(|e| format!("`{name}` printed non-UTF-8 output: {e}"))
}
/// Lists the repository files that are tracked or would be added by
/// `git add -A` (untracked but not ignored), as paths relative to the root
/// with forward slashes.
///
/// # Errors
/// Fails if `git` is not available or the root is not a Git repository.
pub fn repo_files(root: &Path) -> TaskResult<Vec<String>> {
let out = capture(
root,
"git",
&[
"ls-files",
"--cached",
"--others",
"--exclude-standard",
"-z",
],
)?;
let mut files: Vec<String> = out
.split('\0')
.filter(|f| !f.is_empty())
.filter(|f| root.join(f).is_file())
.map(str::to_string)
.collect();
files.sort();
files.dedup();
Ok(files)
}