From 4bbf417531dce010befb1549be744c8a1a3233cf Mon Sep 17 00:00:00 2001 From: slhx agent Date: Fri, 12 Jun 2026 13:32:12 +0200 Subject: [PATCH] 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 --- hemx-xtask/src/main.rs | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/hemx-xtask/src/main.rs b/hemx-xtask/src/main.rs index 3a80476..4d56c3b 100644 --- a/hemx-xtask/src/main.rs +++ b/hemx-xtask/src/main.rs @@ -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"));