From 544d6cdbab145f42719a4bdb9316edc7ec2ae523 Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Sat, 30 Nov 2024 17:07:40 -0800 Subject: [PATCH 1/2] Fallback shell. --- CHANGELOG.md | 1 + Cargo.lock | 4 ++-- Cargo.toml | 2 +- crates/cli/src/commands/setup.rs | 9 ++++++--- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fca00660..d5c7eec9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ - Added support for `~/.netrc` configuration to all HTTP requests. - Improved implementation of HTTP request/response caching. Now takes into account [HTTP cache semantics](https://github.com/kornelski/rusty-http-cache-semantics). - Updated `proto upgrade` to error if there's another process of proto currently running. +- Updated `proto setup` to default to a fallback shell if none could be detected, instead of erroring. #### 🐞 Fixes diff --git a/Cargo.lock b/Cargo.lock index 549cb9208..d34d32cbd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3687,9 +3687,9 @@ dependencies = [ [[package]] name = "starbase_shell" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c92e59e9cb8234c7d07f8260b7196c0d0cd29f4b31cfad8180bc3bcfe0c2619" +checksum = "0e5fab2d4fa242f3e4453718ad21b05e5f3126681437e5b1e04b14833de966b7" dependencies = [ "miette 7.2.0", "regex", diff --git a/Cargo.toml b/Cargo.toml index aba79adc1..04dfb9bd7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,7 +51,7 @@ starbase_archive = { version = "0.8.10", features = [ ] } starbase_events = { version = "0.6.3" } starbase_sandbox = { version = "0.7.7" } -starbase_shell = { version = "0.6.3", features = ["miette"] } +starbase_shell = { version = "0.6.4", features = ["miette"] } starbase_styles = { version = "0.4.6" } starbase_utils = { version = "0.8.13", default-features = false, features = [ "json", diff --git a/crates/cli/src/commands/setup.rs b/crates/cli/src/commands/setup.rs index 5119b75cf..ad8bf798f 100644 --- a/crates/cli/src/commands/setup.rs +++ b/crates/cli/src/commands/setup.rs @@ -6,7 +6,7 @@ use crate::shell::{ use clap::Args; use proto_shim::get_exe_file_name; use starbase::AppResult; -use starbase_shell::{BoxedShell, ShellError, ShellType}; +use starbase_shell::{BoxedShell, ShellType}; use starbase_styles::color; use std::env; use std::io::stdout; @@ -70,7 +70,7 @@ pub async fn setup(session: ProtoSession, args: SetupArgs) -> AppResult { prompt_for_shell()? } else { - return Err(ShellError::CouldNotDetectShell.into()); + ShellType::default() } } }; @@ -83,7 +83,10 @@ pub async fn setup(session: ProtoSession, args: SetupArgs) -> AppResult { &shell, "proto", vec![ - Export::Var("PROTO_HOME".into(), "$HOME/.proto".into()), + Export::Var( + "PROTO_HOME".into(), + env::var("PROTO_HOME").unwrap_or_else(|_| "$HOME/.proto".into()), + ), Export::Path(vec!["$PROTO_HOME/shims".into(), "$PROTO_HOME/bin".into()]), ], ); From 376cfc62bc23eeb1e3effd4bfe29b80b0f027a33 Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Sat, 30 Nov 2024 17:08:15 -0800 Subject: [PATCH 2/2] Update changelog. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5c7eec9e..671959942 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ #### 🐞 Fixes - Fixed the order of shell profiles/configs when applicable. +- Updated `proto setup` to inherit `PROTO_HOME` if already set, instead of defaulting to `$HOME/.proto`. #### ⚙️ Internal