Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Audit 12/12 #673

Merged
merged 3 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
- [Rust](https://github.com/moonrepo/tools/blob/master/tools/rust/CHANGELOG.md)
- [Schema (TOML, JSON, YAML)](https://github.com/moonrepo/tools/blob/master/tools/internal-schema/CHANGELOG.md)

## Unreleased

#### 🐞 Fixes

- Fixed an issue where the globals directory may not exist for the `pre_run` hook.
- Fixed invalid Nushell syntax generated from `proto activate`.

## 0.43.1

#### 🐞 Fixes
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ starbase_archive = { version = "0.9.0", features = [
] }
starbase_events = { version = "0.6.3" }
starbase_sandbox = { version = "0.8.0" }
starbase_shell = { version = "0.6.6", features = ["miette"] }
starbase_shell = { version = "0.6.7", features = ["miette"] }
starbase_styles = { version = "0.4.7" }
starbase_utils = { version = "0.9.1", default-features = false, features = [
"json",
Expand Down
6 changes: 6 additions & 0 deletions crates/cli/src/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use proto_core::{detect_version, Id, ProtoError, Tool, UnresolvedVersionSpec};
use proto_pdk_api::{ExecutableConfig, RunHook, RunHookResult};
use proto_shim::exec_command_and_replace;
use starbase::AppResult;
use starbase_utils::fs;
use std::env;
use std::ffi::OsStr;
use std::process::Command;
Expand Down Expand Up @@ -214,6 +215,11 @@ pub async fn run(session: ProtoSession, args: RunArgs) -> AppResult {
let globals_dir = tool.locate_globals_dir().await?;
let globals_prefix = tool.locate_globals_prefix().await?;

// Ensure directory exists as some tools require it
if let Some(dir) = &globals_dir {
let _ = fs::create_dir_all(dir);
}

tool.plugin
.call_func_with(
"pre_run",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,16 @@ def _proto_activate_hook [] {

$data | get env | items { |k, v|
if $v == null {
hide_env $k
hide-env $k
} else {
load-env { ($k): $v }
}
}

let path_list = $env.__ORIG_PATH | split row (char esep)

$data | get paths | reverse | each { |p|
let path_list = ($path_list | prepend $p)
}
let path_list = [
...($data | get paths | default [])
...($env.__ORIG_PATH | split row (char esep))
];

$env.PATH = ($path_list | uniq)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
source: crates/cli/tests/outdated_test.rs
expression: "vec![fs::read_to_string(sandbox.path().join(\".proto/.prototools\")).unwrap(),\n fs::read_to_string(sandbox.path().join(\"a/.prototools\")).unwrap(),\n fs::read_to_string(sandbox.path().join(\"a/b/.prototools\")).unwrap(),]"
expression: "vec![fs::read_to_string(sandbox.path().join(\".proto/.prototools\")).unwrap(),\nfs::read_to_string(sandbox.path().join(\"a/.prototools\")).unwrap(),\nfs::read_to_string(sandbox.path().join(\"a/b/.prototools\")).unwrap(),]"
---
[
"go = \"1.19.13\"\n",
"node = \"19.9.0\"\n",
"npm = \"9.9.3\"\n",
"npm = \"9.9.4\"\n",
]
6 changes: 5 additions & 1 deletion crates/core/src/proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ pub struct ProtoEnvironment {
impl ProtoEnvironment {
pub fn new() -> miette::Result<Self> {
let home = home_dir().ok_or(ProtoError::MissingHomeDir)?;
let root = path_var("PROTO_HOME").unwrap_or_else(|| home.join(".proto"));
let mut root = path_var("PROTO_HOME").unwrap_or_else(|| home.join(".proto"));

if let Ok(rel_root) = root.strip_prefix("~") {
root = home.join(rel_root);
}

Self::from(root, home)
}
Expand Down
Loading