diff --git a/CHANGELOG.md b/CHANGELOG.md index a4a7aec73..968e5bfe1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,13 +5,20 @@ #### 🚀 Updates - Added colors to command line `--help` menus. +- Added canary support to all applicable tools. + - New `--canary` flag for `proto install`. + - Canary release will always be the latest, and can be re-installed. - Updated the following locations to support partial versions and aliases: - Tool versions in `.prototools`. - Pinning a default version with `proto install --pin`. - Setting global version with `proto global`. - Setting local version with `proto local`. +- TOML API + - Added `install.download_url_canary` and `install.checksum_url_canary` settings. - WASM API - Added `command_exists`, `is_musl`, and `get_target_triple` helper functions. + - Added `skip_install` field to `NativeInstallOutput`. + - Added `skip_uninstall` field to `NativeUninstallOutput`. #### ⚙️ Internal diff --git a/crates/cli/src/commands/install.rs b/crates/cli/src/commands/install.rs index d65b1e1b7..9ef2cfb4d 100644 --- a/crates/cli/src/commands/install.rs +++ b/crates/cli/src/commands/install.rs @@ -14,10 +14,18 @@ pub struct InstallArgs { #[arg(required = true, help = "ID of tool")] pub id: Id, - #[arg(default_value = "latest", help = "Version or alias of tool")] + #[arg( + default_value = "latest", + help = "Version or alias of tool", + group = "version-type" + )] pub spec: Option, - #[arg(long, help = "Install a canary (next, nightly, etc) version")] + #[arg( + long, + help = "Install a canary (next, nightly, etc) version", + group = "version-type" + )] pub canary: bool, #[arg(long, help = "Pin version as the global default")] @@ -36,7 +44,7 @@ pub async fn internal_install(args: InstallArgs) -> SystemResult { args.spec.clone().unwrap_or_default() }; - if !args.canary && tool.is_setup(&version).await? { + if !version.is_canary() && tool.is_setup(&version).await? { info!( "{} has already been installed at {}", tool.get_name(), diff --git a/crates/cli/src/commands/run.rs b/crates/cli/src/commands/run.rs index 5a4725c20..cbbb09ee8 100644 --- a/crates/cli/src/commands/run.rs +++ b/crates/cli/src/commands/run.rs @@ -49,14 +49,12 @@ pub async fn run(args: ArgsRef) -> SystemResult { // Install the tool debug!("Auto-install setting is configured, attempting to install"); - let resolved_version = tool.get_resolved_version(); - internal_install(InstallArgs { - canary: resolved_version.is_canary(), + canary: false, id: args.id.clone(), pin: false, passthrough: vec![], - spec: Some(resolved_version.to_unresolved_spec()), + spec: Some(tool.get_resolved_version().to_unresolved_spec()), }) .await?; diff --git a/crates/core/src/version.rs b/crates/core/src/version.rs index eaa3c4423..94882ff99 100644 --- a/crates/core/src/version.rs +++ b/crates/core/src/version.rs @@ -23,6 +23,10 @@ impl UnresolvedVersionSpec { Ok(Self::from_str(value.as_ref())?) } + pub fn is_canary(&self) -> bool { + matches!(self, UnresolvedVersionSpec::Canary) + } + pub fn to_spec(&self) -> VersionSpec { match self { UnresolvedVersionSpec::Canary => VersionSpec::Alias("canary".to_owned()), diff --git a/crates/pdk/src/helpers.rs b/crates/pdk/src/helpers.rs index b8de01519..e3c85fd5d 100644 --- a/crates/pdk/src/helpers.rs +++ b/crates/pdk/src/helpers.rs @@ -61,7 +61,8 @@ where } /// Fetch the provided URL, deserialize the response as JSON, -/// and cache the response in memory for the duration of the WASM instance. +/// and cache the response in memory for the duration of the WASM function call. +/// Caches *does not* persist across function calls. pub fn fetch_url_with_cache(url: U) -> anyhow::Result where R: DeserializeOwned, diff --git a/crates/pdk/src/macros.rs b/crates/pdk/src/macros.rs index 5a1fe75e1..56287ace2 100644 --- a/crates/pdk/src/macros.rs +++ b/crates/pdk/src/macros.rs @@ -69,12 +69,6 @@ macro_rules! err { 1, )) }; - ($msg:literal, $code:expr) => { - Err(WithReturnCode::new( - PluginError::Message($msg.into()).into(), - $code, - )) - }; ($msg:expr) => { Err(WithReturnCode::new($msg, 1)) };