diff --git a/xtask/src/bin/main.rs b/xtask/src/bin/main.rs index 0babb5fa0..790b44abb 100644 --- a/xtask/src/bin/main.rs +++ b/xtask/src/bin/main.rs @@ -24,7 +24,7 @@ enum Commands { quick: bool, }, /// Bump loco version in all dependencies places - BumpVersion { + DeprecatedBumpVersion { #[arg(name = "VERSION")] new_version: Version, #[arg(short, long, action = SetFalse)] @@ -51,7 +51,7 @@ fn main() -> eyre::Result<()> { println!("{}", xtask::out::print_ci_results(&res)); xtask::CmdExit::ok() } - Commands::BumpVersion { + Commands::DeprecatedBumpVersion { new_version, exclude_starters, } => { @@ -75,7 +75,18 @@ fn main() -> eyre::Result<()> { xtask::CmdExit::ok() } Commands::Bump { new_version } => { - versions::bump_version(&new_version.to_string()); + let meta = MetadataCommand::new() + .manifest_path("./Cargo.toml") + .current_dir(&project_dir) + .exec() + .unwrap(); + let root: &Package = meta.root_package().unwrap(); + if xtask::prompt::confirmation(&format!( + "upgrading loco version from {} to {}", + root.version, new_version, + ))? { + versions::bump_version(&new_version.to_string())?; + } xtask::CmdExit::ok() } }; diff --git a/xtask/src/versions.rs b/xtask/src/versions.rs index 8865b2ae2..260541700 100644 --- a/xtask/src/versions.rs +++ b/xtask/src/versions.rs @@ -2,6 +2,12 @@ use std::path::Path; use regex::Regex; +use crate::{ + ci, + errors::{Error, Result}, + out, +}; + fn bump_version_in_file( file_path: &str, version_regex: &str, @@ -31,12 +37,15 @@ fn bump_version_in_file( } } -pub fn bump_version(version: &str) { - for cargo in [ +pub fn bump_version(version: &str) -> Result<()> { + let starters = [ "starters/saas/Cargo.toml", - "starters/saas/migration/Cargo.toml", - ] { - // turn starters to local + "starters/rest-api/Cargo.toml", + "starters/lightweight-service/Cargo.toml", + ]; + + // turn starters to local "../../" version for testing + for cargo in starters { bump_version_in_file( cargo, // loco-rs = { version =".." @@ -44,8 +53,25 @@ pub fn bump_version(version: &str) { r#"loco-rs = { path="../../""#, false, ); + } + + println!("Testing starters CI"); + let starter_projects: Vec = ci::run_all_in_folder(Path::new("starters"))?; + + println!("Starters CI results:"); + println!("{}", out::print_ci_results(&starter_projects)); + for starter in &starter_projects { + if !starter.is_valid() { + return Err(Error::Message(format!( + "starter {} ins not passing the CI", + starter.path.display() + ))); + } + } - // turn starters from local to version + // all oK + // turn starters from local to version + for cargo in starters { bump_version_in_file( cargo, // loco-rs = { path =".." @@ -69,4 +95,5 @@ pub fn bump_version(version: &str) { // sync new version to subcrates in main Cargo.toml let loco_gen_dep = format!(r#"loco-gen = {{ version = "{version}","#); bump_version_in_file("Cargo.toml", r"(?m)^loco-gen [^,]*,", &loco_gen_dep, false); + Ok(()) }