fix: add --all to cargo fmt in script/test and autoformat codebase

cargo fmt without --all fails with "Failed to find targets" in
workspace repos. This was blocking every story's gates. Also ran
cargo fmt --all to fix all existing formatting issues.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
dave
2026-04-13 14:07:08 +00:00
parent ed2526ce41
commit 845b85e7a7
128 changed files with 3566 additions and 2395 deletions
+92 -27
View File
@@ -4,8 +4,7 @@ use std::path::Path;
const STORY_KIT_README: &str = include_str!("../../../../.huskies/README.md");
const BOT_TOML_MATRIX_EXAMPLE: &str =
include_str!("../../../../.huskies/bot.toml.matrix.example");
const BOT_TOML_MATRIX_EXAMPLE: &str = include_str!("../../../../.huskies/bot.toml.matrix.example");
const BOT_TOML_WHATSAPP_META_EXAMPLE: &str =
include_str!("../../../../.huskies/bot.toml.whatsapp-meta.example");
const BOT_TOML_WHATSAPP_TWILIO_EXAMPLE: &str =
@@ -194,9 +193,7 @@ pub fn detect_components_toml(root: &Path) -> String {
// No tech stack markers detected — emit a single generic component
// with an empty setup list. The ONBOARDING_PROMPT instructs the chat
// agent to inspect the project and replace this with real definitions.
sections.push(
"[[component]]\nname = \"app\"\npath = \".\"\nsetup = []\n".to_string(),
);
sections.push("[[component]]\nname = \"app\"\npath = \".\"\nsetup = []\n".to_string());
}
sections.join("\n")
@@ -826,9 +823,18 @@ mod tests {
let mcp_path = dir.path().join(".mcp.json");
assert!(mcp_path.exists(), ".mcp.json should be created by scaffold");
let content = fs::read_to_string(&mcp_path).unwrap();
assert!(content.contains("4242"), ".mcp.json should reference the given port");
assert!(content.contains("localhost"), ".mcp.json should reference localhost");
assert!(content.contains("huskies"), ".mcp.json should name the huskies server");
assert!(
content.contains("4242"),
".mcp.json should reference the given port"
);
assert!(
content.contains("localhost"),
".mcp.json should reference localhost"
);
assert!(
content.contains("huskies"),
".mcp.json should name the huskies server"
);
}
#[test]
@@ -976,7 +982,10 @@ mod tests {
fs::write(dir.path().join("go.mod"), "module example.com/app\n").unwrap();
let toml = detect_components_toml(dir.path());
assert!(!toml.contains("cargo"), "go project must not contain cargo commands");
assert!(
!toml.contains("cargo"),
"go project must not contain cargo commands"
);
assert!(toml.contains("go build"), "go project must use Go tooling");
}
@@ -986,8 +995,14 @@ mod tests {
fs::write(dir.path().join("package.json"), "{}").unwrap();
let toml = detect_components_toml(dir.path());
assert!(!toml.contains("cargo"), "node project must not contain cargo commands");
assert!(toml.contains("npm install"), "node project must use npm tooling");
assert!(
!toml.contains("cargo"),
"node project must not contain cargo commands"
);
assert!(
toml.contains("npm install"),
"node project must use npm tooling"
);
}
#[test]
@@ -995,9 +1010,15 @@ mod tests {
let dir = tempdir().unwrap();
let toml = detect_components_toml(dir.path());
assert!(!toml.contains("cargo"), "unknown stack must not contain cargo commands");
assert!(
!toml.contains("cargo"),
"unknown stack must not contain cargo commands"
);
// setup list must be empty
assert!(toml.contains("setup = []"), "unknown stack must have empty setup list");
assert!(
toml.contains("setup = []"),
"unknown stack must have empty setup list"
);
}
#[test]
@@ -1047,7 +1068,10 @@ mod tests {
fs::write(dir.path().join("Cargo.toml"), "[package]\nname = \"x\"\n").unwrap();
let script = detect_script_test(dir.path());
assert!(script.contains("cargo test"), "Rust project should run cargo test");
assert!(
script.contains("cargo test"),
"Rust project should run cargo test"
);
assert!(!script.contains("No tests configured"));
}
@@ -1057,7 +1081,10 @@ mod tests {
fs::write(dir.path().join("package.json"), "{}").unwrap();
let script = detect_script_test(dir.path());
assert!(script.contains("npm test"), "Node project without pnpm-lock should run npm test");
assert!(
script.contains("npm test"),
"Node project without pnpm-lock should run npm test"
);
assert!(!script.contains("No tests configured"));
}
@@ -1068,18 +1095,31 @@ mod tests {
fs::write(dir.path().join("pnpm-lock.yaml"), "").unwrap();
let script = detect_script_test(dir.path());
assert!(script.contains("pnpm test"), "Node project with pnpm-lock should run pnpm test");
assert!(
script.contains("pnpm test"),
"Node project with pnpm-lock should run pnpm test"
);
// "pnpm test" is a substring of itself; verify there's no bare "npm test" line
assert!(!script.lines().any(|l| l.trim() == "npm test"), "should not use npm when pnpm-lock.yaml is present");
assert!(
!script.lines().any(|l| l.trim() == "npm test"),
"should not use npm when pnpm-lock.yaml is present"
);
}
#[test]
fn detect_script_test_pyproject_toml_adds_pytest() {
let dir = tempdir().unwrap();
fs::write(dir.path().join("pyproject.toml"), "[project]\nname = \"x\"\n").unwrap();
fs::write(
dir.path().join("pyproject.toml"),
"[project]\nname = \"x\"\n",
)
.unwrap();
let script = detect_script_test(dir.path());
assert!(script.contains("pytest"), "Python project should run pytest");
assert!(
script.contains("pytest"),
"Python project should run pytest"
);
assert!(!script.contains("No tests configured"));
}
@@ -1089,7 +1129,10 @@ mod tests {
fs::write(dir.path().join("requirements.txt"), "flask\n").unwrap();
let script = detect_script_test(dir.path());
assert!(script.contains("pytest"), "Python project (requirements.txt) should run pytest");
assert!(
script.contains("pytest"),
"Python project (requirements.txt) should run pytest"
);
}
#[test]
@@ -1098,7 +1141,10 @@ mod tests {
fs::write(dir.path().join("go.mod"), "module example.com/app\n").unwrap();
let script = detect_script_test(dir.path());
assert!(script.contains("go test ./..."), "Go project should run go test ./...");
assert!(
script.contains("go test ./..."),
"Go project should run go test ./..."
);
assert!(!script.contains("No tests configured"));
}
@@ -1109,8 +1155,14 @@ mod tests {
fs::write(dir.path().join("package.json"), "{}").unwrap();
let script = detect_script_test(dir.path());
assert!(script.contains("go test ./..."), "multi-stack should include Go test command");
assert!(script.contains("npm test"), "multi-stack should include Node test command");
assert!(
script.contains("go test ./..."),
"multi-stack should include Go test command"
);
assert!(
script.contains("npm test"),
"multi-stack should include Node test command"
);
}
#[test]
@@ -1128,13 +1180,23 @@ mod tests {
#[test]
fn scaffold_script_test_contains_detected_commands_for_rust() {
let dir = tempdir().unwrap();
fs::write(dir.path().join("Cargo.toml"), "[package]\nname = \"myapp\"\n").unwrap();
fs::write(
dir.path().join("Cargo.toml"),
"[package]\nname = \"myapp\"\n",
)
.unwrap();
scaffold_story_kit(dir.path(), 3001).unwrap();
let content = fs::read_to_string(dir.path().join("script/test")).unwrap();
assert!(content.contains("cargo test"), "Rust project scaffold should set cargo test in script/test");
assert!(!content.contains("No tests configured"), "should not use stub when stack is detected");
assert!(
content.contains("cargo test"),
"Rust project scaffold should set cargo test in script/test"
);
assert!(
!content.contains("No tests configured"),
"should not use stub when stack is detected"
);
}
#[test]
@@ -1143,7 +1205,10 @@ mod tests {
scaffold_story_kit(dir.path(), 3001).unwrap();
let content = fs::read_to_string(dir.path().join("script/test")).unwrap();
assert!(content.contains("No tests configured"), "unknown stack should use the generic stub");
assert!(
content.contains("No tests configured"),
"unknown stack should use the generic stub"
);
}
// --- generate_project_toml ---