diff --git a/module/move/willbe/src/action/publish.rs b/module/move/willbe/src/action/publish.rs index 6788a11f1c..c426e01fd3 100644 --- a/module/move/willbe/src/action/publish.rs +++ b/module/move/willbe/src/action/publish.rs @@ -11,6 +11,7 @@ mod private use _path::AbsolutePath; use workspace::Workspace; use package::Package; + use channel::Channel; /// Represents a report of publishing packages #[ derive( Debug, Default, Clone ) ] @@ -107,7 +108,7 @@ mod private /// # Returns /// A Result containing a `PublishPlan` if successful, or an `Error` otherwise. #[ cfg_attr( feature = "tracing", tracing::instrument ) ] - pub fn publish_plan( patterns : Vec< String >, dry : bool, temp : bool ) -> Result< package::PublishPlan, Error > + pub fn publish_plan( patterns : Vec< String >, channel : Channel, dry : bool, temp : bool ) -> Result< package::PublishPlan, Error > { let mut paths = HashSet::new(); // find all packages by specified folders @@ -173,6 +174,7 @@ mod private let roots = packages_to_publish.iter().map( | p | package_map.get( p ).unwrap().crate_dir() ).collect::< Vec< _ > >(); let plan = package::PublishPlan::former() + .channel( channel ) .workspace_dir( CrateDir::try_from( workspace_root_dir ).unwrap() ) .option_base_temp_dir( dir.clone() ) .dry( dry ) diff --git a/module/move/willbe/src/command/mod.rs b/module/move/willbe/src/command/mod.rs index 74f58a48bc..0360feb96f 100644 --- a/module/move/willbe/src/command/mod.rs +++ b/module/move/willbe/src/command/mod.rs @@ -20,6 +20,11 @@ pub( crate ) mod private .kind( Type::List( Type::String.into(), ',' ) ) .optional( true ) .end() + .property( "channel" ) + .hint( "Release channels for rust." ) + .kind( Type::String ) + .optional( true ) + .end() .property( "dry" ) .hint( "Enables 'dry run'. Does not publish, only simulates. Default is `true`." ) .kind( Type::Bool ) diff --git a/module/move/willbe/src/command/publish.rs b/module/move/willbe/src/command/publish.rs index 9b1d09eff0..ca085f3b31 100644 --- a/module/move/willbe/src/command/publish.rs +++ b/module/move/willbe/src/command/publish.rs @@ -8,10 +8,13 @@ mod private use wtools::error::{ Result, for_app::Context }; use former::Former; use std::fmt::Write; + use channel::Channel; #[ derive( Former ) ] struct PublishProperties { + #[ former( default = Channel::Stable ) ] + channel : Channel, #[ former( default = true ) ] dry : bool, #[ former( default = true ) ] @@ -29,8 +32,8 @@ mod private let patterns : Vec< _ > = o.args.get_owned( 0 ).unwrap_or_else( || vec![ "./".into() ] ); - let PublishProperties { dry, temp } = o.props.try_into()?; - let plan = action::publish_plan( patterns, dry, temp ).context( "Failed to plan the publication process" )?; + let PublishProperties { channel, dry, temp } = o.props.try_into()?; + let plan = action::publish_plan( patterns, channel, dry, temp ).context( "Failed to plan the publication process" )?; let mut formatted_plan = String::new(); writeln!( &mut formatted_plan, "Tree :" )?; @@ -75,6 +78,7 @@ mod private { let mut this = Self::former(); + this = if let Some( v ) = value.get_owned( "channel" ) { this.channel::< Channel >( { let v : String = v; Channel::try_from( v )? } ) } else { this }; this = if let Some( v ) = value.get_owned( "dry" ) { this.dry::< bool >( v ) } else { this }; this = if let Some( v ) = value.get_owned( "temp" ) { this.temp::< bool >( v ) } else { this }; diff --git a/module/move/willbe/src/entity/channel.rs b/module/move/willbe/src/entity/channel.rs index e9611212d1..a266890aab 100644 --- a/module/move/willbe/src/entity/channel.rs +++ b/module/move/willbe/src/entity/channel.rs @@ -34,6 +34,20 @@ mod private } } } + + impl TryFrom< String > for Channel + { + type Error = error::for_app::Error; + fn try_from( value : String ) -> Result< Self, Self::Error > + { + Ok( match value.as_ref() + { + "stable" => Self::Stable, + "nightly" => Self::Nightly, + other => error::for_app::bail!( "Unexpected channel value. Expected [stable, channel]. Got: `{other}`" ), + }) + } + } /// Retrieves a list of available channels. /// diff --git a/module/move/willbe/src/entity/package.rs b/module/move/willbe/src/entity/package.rs index 9e1f281ebc..19940502b6 100644 --- a/module/move/willbe/src/entity/package.rs +++ b/module/move/willbe/src/entity/package.rs @@ -35,6 +35,7 @@ mod private use diff::crate_diff; use version::version_revert; use error_tools::for_app::Error; + use channel::Channel; /// #[ derive( Debug, Clone ) ] @@ -364,6 +365,7 @@ mod private { workspace_dir : CrateDir, package : Package, + channel : Channel, base_temp_dir : Option< PathBuf >, #[ former( default = true ) ] dry : bool, @@ -378,6 +380,7 @@ mod private let pack = cargo::PackOptions { path : crate_dir.as_ref().into(), + channel : self.channel, allow_dirty : self.dry, no_verify : self.dry, temp_path : self.base_temp_dir.clone(), @@ -508,6 +511,9 @@ mod private /// optional as not all operations will require temporary storage. The type used is `PathBuf` which allows /// manipulation of the filesystem paths. pub base_temp_dir : Option< PathBuf >, + + /// Release channels for rust. + pub channel : Channel, /// `dry` - A boolean value indicating whether to do a dry run. If set to `true`, the application performs /// a simulated run without making any actual changes. If set to `false`, the operations are actually executed. @@ -617,6 +623,7 @@ mod private where IntoPackage : Into< Package >, { + let channel = self.storage.channel.unwrap_or_default(); let mut plan = PublishSinglePackagePlanner::former(); if let Some( workspace ) = &self.storage.workspace_dir { @@ -631,6 +638,7 @@ mod private plan = plan.dry( dry ); } let plan = plan + .channel( channel ) .package( package ) .perform(); let mut plans = self.storage.plans.unwrap_or_default(); diff --git a/module/move/willbe/src/tool/cargo.rs b/module/move/willbe/src/tool/cargo.rs index 2d28da4d96..0edc77a7e1 100644 --- a/module/move/willbe/src/tool/cargo.rs +++ b/module/move/willbe/src/tool/cargo.rs @@ -9,12 +9,14 @@ mod private use former::Former; use process_tools::process::*; use wtools::error::Result; + use channel::Channel; /// Represents pack options #[ derive( Debug, Former, Clone ) ] pub struct PackOptions { - pub( crate ) path : PathBuf, + pub( crate ) path : PathBuf, + pub( crate ) channel : Channel, #[ former( default = true ) ] pub( crate ) allow_dirty : bool, #[ former( default = true ) ] @@ -36,7 +38,7 @@ mod private { fn to_pack_args( &self ) -> Vec< String > { - [ "package".to_string() ] + [ "run".to_string(), self.channel.to_string(), "cargo".into(), "package".into() ] .into_iter() .chain( if self.allow_dirty { Some( "--allow-dirty".to_string() ) } else { None } ) .chain( if self.no_verify { Some( "--no-verify".to_string() ) } else { None } ) @@ -60,7 +62,7 @@ mod private )] pub fn pack( args : PackOptions ) -> Result< Report > { - let ( program, options ) = ( "cargo", args.to_pack_args() ); + let ( program, options ) = ( "rustup", args.to_pack_args() ); if args.dry {