From 9988318ac3875118a62b89408a4c082740c0d155 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20P=C5=82askonka?= Date: Mon, 26 Feb 2024 12:55:30 +0100 Subject: [PATCH 1/2] Added build placeholder replace. --- src/actions/init.rs | 56 ++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/src/actions/init.rs b/src/actions/init.rs index 3aa6ca7..b9add43 100644 --- a/src/actions/init.rs +++ b/src/actions/init.rs @@ -104,31 +104,48 @@ impl InitAction { } }; - replace_in_file( - cargo_toml_path.clone(), + Self::replace_package_placeholder( + init, + &odra_location, + &cargo_toml_path, "#odra_dependency", - format!( - "odra = {{ {} }}", - toml::to_string(&Self::odra_project_dependency( - odra_location.clone(), - "odra", - init - )) - .unwrap() - .trim_end() - .replace('\n', ", ") - ) - .as_str(), + "odra", ); + Self::replace_package_placeholder( + init, + &odra_location, + &cargo_toml_path, + "#odra_test_dependency", + "odra-test", + ); + Self::replace_package_placeholder( + init, + &odra_location, + &cargo_toml_path, + "#odra_build_dependency", + "odra-build", + ); + + rename_file(cargo_toml_path, "Cargo.toml"); + log::info("Done!"); + } + fn replace_package_placeholder( + init: bool, + odra_location: &OdraLocation, + cargo_toml_path: &PathBuf, + placeholder: &str, + crate_name: &str, + ) { replace_in_file( cargo_toml_path.clone(), - "#odra_test_dependency", + placeholder, format!( - "odra-test = {{ {} }}", + "{} = {{ {} }}", + crate_name, toml::to_string(&Self::odra_project_dependency( - odra_location, - "odra-test", + odra_location.clone(), + crate_name, init )) .unwrap() @@ -137,9 +154,6 @@ impl InitAction { ) .as_str(), ); - - rename_file(cargo_toml_path, "Cargo.toml"); - log::info("Done!"); } fn assert_dir_is_empty(dir: PathBuf) { if dir.read_dir().unwrap().next().is_some() { From 3ba697af03616d94ce977189d9fb233cbfdc5634 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20P=C5=82askonka?= Date: Mon, 26 Feb 2024 13:31:41 +0100 Subject: [PATCH 2/2] Enabled tests on development version of Odra --- .github/workflows/ci-cargo-odra.yml | 4 ++-- justfile | 2 +- src/actions/init.rs | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-cargo-odra.yml b/.github/workflows/ci-cargo-odra.yml index a37880a..8e16ba9 100644 --- a/.github/workflows/ci-cargo-odra.yml +++ b/.github/workflows/ci-cargo-odra.yml @@ -32,7 +32,7 @@ jobs: - run: just prepare - run: just check-lint - run: just install -# - run: just test-project-generation-on-future-odra -# - run: just test-workspace-generation-on-future-odra + - run: just test-project-generation-on-future-odra + - run: just test-workspace-generation-on-future-odra - run: just test-project-generation-on-stable-odra - run: just test-workspace-generation-on-stable-odra diff --git a/justfile b/justfile index 34f6ac4..3706dc2 100644 --- a/justfile +++ b/justfile @@ -1,4 +1,4 @@ -DEVELOPMENT_ODRA_BRANCH := "release/0.8.0" +DEVELOPMENT_ODRA_BRANCH := "release/0.9.0" BINARYEN_VERSION := "version_116" BINARYEN_CHECKSUM := "c55b74f3109cdae97490faf089b0286d3bba926bb6ea5ed00c8c784fc53718fd" diff --git a/src/actions/init.rs b/src/actions/init.rs index b9add43..8dcefab 100644 --- a/src/actions/init.rs +++ b/src/actions/init.rs @@ -1,6 +1,6 @@ //! Module responsible for initializing an Odra project. -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use cargo_generate::{GenerateArgs, TemplatePath, Vcs}; use cargo_toml::{Dependency, DependencyDetail}; @@ -133,12 +133,12 @@ impl InitAction { fn replace_package_placeholder( init: bool, odra_location: &OdraLocation, - cargo_toml_path: &PathBuf, + cargo_toml_path: &Path, placeholder: &str, crate_name: &str, ) { replace_in_file( - cargo_toml_path.clone(), + cargo_toml_path.to_path_buf(), placeholder, format!( "{} = {{ {} }}",