Skip to content

Commit 71f5ccf

Browse files
committed
Merge remote-tracking branch 'origin/main' into fetch-yarn3
# Conflicts: # tests/acceptance/merged_platform.rs
2 parents 02184f8 + 7b8bc90 commit 71f5ccf

File tree

13 files changed

+466
-68
lines changed

13 files changed

+466
-68
lines changed

Cargo.lock

Lines changed: 18 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "volta"
3-
version = "1.0.5"
3+
version = "1.0.6"
44
authors = ["David Herman <[email protected]>", "Charles Pierce <[email protected]>"]
55
license = "BSD-2-Clause"
66
repository = "https://github.com/volta-cli/volta"
@@ -33,7 +33,7 @@ cfg-if = "1.0"
3333
mockito = { version = "0.31.0", optional = true }
3434
test-support = { path = "crates/test-support" }
3535
textwrap = "0.14.2"
36-
which = "4.2.4"
36+
which = "4.2.5"
3737
dirs = "4.0.0"
3838
volta-migrate = { path = "crates/volta-migrate" }
3939

RELEASES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Version 1.0.6
2+
3+
- Fixed panic when `stdout` is closed (#1058)
4+
- Disabled global package interception when `--prefix` is provided (#1171)
5+
- Numerous dependency updates
6+
17
# Version 1.0.5
28

39
- Added error when attempting to install Node using `nvm` syntax (#1020)

crates/volta-core/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ os_info = "3.2.0"
3232
detect-indent = { git = "https://github.com/stefanpenner/detect-indent-rs", branch = "master" }
3333
envoy = "0.1.3"
3434
mockito = { version = "0.31.0", optional = true }
35-
regex = "1.5.4"
35+
regex = "1.5.5"
3636
dirs = "4.0.0"
3737
sha-1 = "0.10.0"
3838
hex = "0.4.3"
@@ -50,7 +50,7 @@ ci_info = "0.14.4"
5050
hyperx = "1.4.0"
5151
attohttpc = { version = "0.18.0", features = ["json"] }
5252
chain-map = "0.1.0"
53-
indexmap = "1.8.0"
53+
indexmap = "1.8.1"
5454
retry = "1.3.1"
5555
fs2 = "0.4.3"
5656

crates/volta-core/src/event.rs

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
use std::env;
44
use std::time::{SystemTime, UNIX_EPOCH};
55

6-
use serde::Serialize;
6+
use serde::{Deserialize, Serialize};
77

88
use crate::error::{ExitCode, VoltaError};
99
use crate::hook::Publish;
10-
use crate::monitor::Monitor;
10+
use crate::monitor::send_events;
1111
use crate::session::ActivityKind;
1212

1313
// the Event data that is serialized to JSON and sent the plugin
14-
#[derive(Serialize)]
14+
#[derive(Deserialize, Serialize)]
1515
pub struct Event {
1616
timestamp: u64,
17-
name: String,
18-
event: EventKind,
17+
pub name: String,
18+
pub event: EventKind,
1919
}
2020

21-
#[derive(Serialize)]
21+
#[derive(Deserialize, Serialize, PartialEq, Debug)]
2222
pub struct ErrorEnv {
2323
argv: String,
2424
exec_path: String,
@@ -27,9 +27,9 @@ pub struct ErrorEnv {
2727
platform_version: String,
2828
}
2929

30-
#[derive(Serialize)]
30+
#[derive(Deserialize, Serialize, PartialEq, Debug)]
3131
#[serde(rename_all = "lowercase")]
32-
enum EventKind {
32+
pub enum EventKind {
3333
Start,
3434
End {
3535
exit_code: i32,
@@ -42,6 +42,9 @@ enum EventKind {
4242
ToolEnd {
4343
exit_code: i32,
4444
},
45+
Args {
46+
argv: String,
47+
},
4548
}
4649

4750
impl EventKind {
@@ -122,6 +125,18 @@ impl EventLog {
122125
activity_kind,
123126
)
124127
}
128+
pub fn add_event_args(&mut self) {
129+
let argv = env::args_os()
130+
.enumerate()
131+
.fold(String::new(), |mut result, (i, arg)| {
132+
if i > 0 {
133+
result.push(' ');
134+
}
135+
result.push_str(&arg.to_string_lossy());
136+
result
137+
});
138+
self.add_event(EventKind::Args { argv }, ActivityKind::Args)
139+
}
125140

126141
fn add_event(&mut self, event_kind: EventKind, activity_kind: ActivityKind) {
127142
let event = event_kind.into_event(activity_kind);
@@ -133,8 +148,7 @@ impl EventLog {
133148
// Note: This call to unimplemented is left in, as it's not a Fallible operation that can use ErrorKind::Unimplemented
134149
Some(&Publish::Url(_)) => unimplemented!(),
135150
Some(&Publish::Bin(ref command)) => {
136-
let mut monitor = Monitor::new(command);
137-
monitor.send_events(&self.events);
151+
send_events(command, &self.events);
138152
}
139153
None => {}
140154
}
@@ -144,9 +158,10 @@ impl EventLog {
144158
#[cfg(test)]
145159
pub mod tests {
146160

147-
use super::EventLog;
161+
use super::{EventKind, EventLog};
148162
use crate::error::{ErrorKind, ExitCode};
149163
use crate::session::ActivityKind;
164+
use regex::Regex;
150165

151166
#[test]
152167
fn test_adding_events() {
@@ -156,18 +171,41 @@ pub mod tests {
156171
event_log.add_event_start(ActivityKind::Current);
157172
assert_eq!(event_log.events.len(), 1);
158173
assert_eq!(event_log.events[0].name, "current");
174+
assert_eq!(event_log.events[0].event, EventKind::Start);
159175

160176
event_log.add_event_end(ActivityKind::Pin, ExitCode::NetworkError);
161177
assert_eq!(event_log.events.len(), 2);
162178
assert_eq!(event_log.events[1].name, "pin");
179+
assert_eq!(event_log.events[1].event, EventKind::End { exit_code: 5 });
163180

164181
event_log.add_event_tool_end(ActivityKind::Version, 12);
165182
assert_eq!(event_log.events.len(), 3);
166183
assert_eq!(event_log.events[2].name, "version");
184+
assert_eq!(
185+
event_log.events[2].event,
186+
EventKind::ToolEnd { exit_code: 12 }
187+
);
167188

168189
let error = ErrorKind::BinaryExecError.into();
169190
event_log.add_event_error(ActivityKind::Install, &error);
170191
assert_eq!(event_log.events.len(), 4);
171192
assert_eq!(event_log.events[3].name, "install");
193+
// not checking the error because it has too much machine-specific info
194+
195+
event_log.add_event_args();
196+
assert_eq!(event_log.events.len(), 5);
197+
assert_eq!(event_log.events[4].name, "args");
198+
match event_log.events[4].event {
199+
EventKind::Args { ref argv } => {
200+
let re = Regex::new("volta_core").unwrap();
201+
assert!(re.is_match(argv));
202+
}
203+
_ => {
204+
panic!(
205+
"Expected EventKind::Args {{ argv }}, Got: {:?}",
206+
event_log.events[4].event
207+
);
208+
}
209+
}
172210
}
173211
}

crates/volta-core/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
mod command;
44
pub mod error;
5-
mod event;
5+
pub mod event;
66
pub mod fs;
77
mod hook;
88
pub mod inventory;

0 commit comments

Comments
 (0)