feat(workout): make created apps self-service

Write a standalone hemx-workout command into created apps and verify it carries dev, test, build, mobile-release, mobile-verify, runtime integrity, and store blocker checks outside the monorepo.

req: examples/006
This commit is contained in:
slhx agent
2026-06-12 13:32:12 +02:00
parent 3f0cf0a7cb
commit 4bbf417531
+19 -7
View File
@@ -143,14 +143,10 @@ fn create_workout_app(destination: &Path) -> std::io::Result<()> {
.replace(
"path = \"../../hemx-build\"",
&format!("path = \"{}\"", root.join("hemx-build").display()),
)
.replace("hemx_workout_example", "hemx_workout_app"),
)?;
replace_in_file(
&destination.join("src/main.rs"),
"hemx_workout_example",
"hemx_workout_app",
),
)?;
replace_in_tree(destination, "hemx_workout_example", "hemx_workout_app")?;
replace_in_tree(destination, "hemx-workout-example", "workout-app")?;
write_workout_app_command(destination)?;
fs::write(
destination.join("CREATED.md"),
@@ -175,6 +171,17 @@ fn replace_in_file(path: &Path, from: &str, to: &str) -> std::io::Result<()> {
fs::write(path, contents.replace(from, to))
}
fn replace_in_tree(path: &Path, from: &str, to: &str) -> std::io::Result<()> {
if path.is_dir() {
for entry in fs::read_dir(path)? {
replace_in_tree(&entry?.path(), from, to)?;
}
} else {
replace_in_file(path, from, to)?;
}
Ok(())
}
fn write_workout_app_command(destination: &Path) -> std::io::Result<()> {
let script_path = destination.join("hemx-workout");
fs::write(&script_path, workout_app_command_script())?;
@@ -1070,8 +1077,13 @@ mod tests {
assert!(manifest.contains("edition = \"2021\""));
assert!(manifest.contains("hemx-build"));
let main_rs = fs::read_to_string(destination.join("src/main.rs")).expect("main rs");
let e2e_rs = fs::read_to_string(destination.join("tests/e2e.rs")).expect("e2e rs");
assert!(main_rs.contains("hemx_workout_app"));
assert!(e2e_rs.contains("hemx_workout_app"));
assert!(e2e_rs.contains("CARGO_BIN_EXE_workout-app"));
assert!(!main_rs.contains("hemx_workout_example"));
assert!(!e2e_rs.contains("hemx_workout_example"));
assert!(!e2e_rs.contains("hemx-workout-example"));
let command = fs::read_to_string(destination.join("hemx-workout")).expect("command");
assert!(command.contains("mobile-release"));
assert!(command.contains("mobile-verify"));