diff --git a/crates/templates/src/manager.rs b/crates/templates/src/manager.rs index 9ffbbfb368..b79f099ac0 100644 --- a/crates/templates/src/manager.rs +++ b/crates/templates/src/manager.rs @@ -746,7 +746,7 @@ mod tests { ); let content_dir = template.content_dir().as_ref().unwrap(); - let cargo = tokio::fs::read_to_string(content_dir.join("Cargo.toml")) + let cargo = tokio::fs::read_to_string(content_dir.join("Cargo.toml.tmpl")) .await .unwrap(); assert!(cargo.contains("name = \"{{project-name | kebab_case}}\"")); diff --git a/crates/templates/src/run.rs b/crates/templates/src/run.rs index 3901dbb8f5..95861886e9 100644 --- a/crates/templates/src/run.rs +++ b/crates/templates/src/run.rs @@ -344,13 +344,18 @@ impl Run { let template_parser = Self::template_parser(); let contents = paths .iter() - .map(std::fs::read) - .map(|c| { - c.map_err(|e| e.into()) - .and_then(|cc| TemplateContent::infer_from_bytes(cc, &template_parser)) - }) + .map(|path| TemplateContent::infer_from_bytes(std::fs::read(path)?, &template_parser)) .collect::, _>>()?; - let pairs = paths.into_iter().zip(contents).collect(); + // Strip optional .tmpl extension + // Templates can use this if they don't want to store files with their final extensions + let paths = paths.into_iter().map(|p| { + if p.extension().is_some_and(|e| e == "tmpl") { + p.with_extension("") + } else { + p + } + }); + let pairs = paths.zip(contents).collect(); Ok(pairs) } diff --git a/templates/http-rust/content/Cargo.toml b/templates/http-rust/content/Cargo.toml.tmpl similarity index 100% rename from templates/http-rust/content/Cargo.toml rename to templates/http-rust/content/Cargo.toml.tmpl diff --git a/templates/redis-rust/content/Cargo.toml b/templates/redis-rust/content/Cargo.toml.tmpl similarity index 100% rename from templates/redis-rust/content/Cargo.toml rename to templates/redis-rust/content/Cargo.toml.tmpl diff --git a/tests/integration.rs b/tests/integration.rs index b909740392..9e30952a35 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -485,6 +485,7 @@ Caused by: #[test] #[cfg(feature = "extern-dependencies-tests")] + #[ignore = "https://github.com/fermyon/spin/issues/2457"] // TODO: Check why python is not picking up the spin_sdk from site_packages // Currently installing to the local directory to get around it. fn http_python_template_smoke_test() -> anyhow::Result<()> {