Repository navigation
Basic updates - #3
Conversation
WalkthroughThis update removes the internal dependency on the "wavec" crate, replacing internal API calls with external command-line invocations of the "wavec" tool. It introduces a new Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI as Vex CLI
participant OS as System Shell
User->>CLI: vex run <main_path>
CLI->>OS: Execute "wavec run <main_path>"
OS-->>CLI: Returns status
CLI-->>User: Print error if wavec not found
User->>CLI: vex setup wavec [--version <ver>]
CLI->>OS: curl https://.../install.sh | bash -s -- [version]
CLI->>CLI: show_spinner("Installing wavec...", child)
OS-->>CLI: Returns status
CLI-->>User: Print success or error message
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15 minutes Possibly related PRs
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. ✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (3)
src/spinner.rs (2)
3-6: Consider making spinner frames configurable.The function signature is appropriate, but the hardcoded spinner frames could be made configurable for different use cases.
-pub fn show_spinner(message: &str, mut child: std::process::Child) -> std::process::ExitStatus { - let frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"]; +pub fn show_spinner(message: &str, mut child: std::process::Child) -> std::process::ExitStatus { + show_spinner_with_frames(message, child, &["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"]) +} + +pub fn show_spinner_with_frames(message: &str, mut child: std::process::Child, frames: &[&str]) -> std::process::ExitStatus {
20-24: Consider allowing graceful error handling instead of exit.The error handling immediately exits the program, which may not be appropriate for all use cases. Consider returning a
Resulttype instead.-pub fn show_spinner(message: &str, mut child: std::process::Child) -> std::process::ExitStatus { +pub fn show_spinner(message: &str, mut child: std::process::Child) -> Result<std::process::ExitStatus, Box<dyn std::error::Error>> { // ... existing code ... Err(e) => { - eprintln!("❌ Failed to wait on child process: {}", e); - std::process::exit(1); + return Err(Box::new(e)); }src/commands/setup.rs (1)
4-33: Consider cross-platform compatibility and installation verification.The current implementation has platform-specific limitations and could benefit from additional robustness:
- Windows compatibility: This implementation won't work on Windows due to bash/curl dependencies
- Installation verification: Consider verifying the installation worked by checking if
wavecis now available in PATH- Configuration: Consider making the installer URL configurable
Consider these architectural improvements:
// Add after installation fn verify_wavec_installation() -> bool { Command::new("wavec") .arg("--version") .output() .map(|output| output.status.success()) .unwrap_or(false) } // Use in install_wavec after installation if status.success() { if verify_wavec_installation() { println!("✅ wavec installed and verified successfully."); } else { eprintln!("⚠️ wavec installation completed but verification failed."); } }For Windows support, consider using PowerShell or providing Windows-specific installation instructions.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
Cargo.toml(1 hunks)src/commands/mod.rs(1 hunks)src/commands/run.rs(2 hunks)src/commands/setup.rs(1 hunks)src/main.rs(2 hunks)src/spinner.rs(1 hunks)src/version.rs(0 hunks)
💤 Files with no reviewable changes (1)
- src/version.rs
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/commands/mod.rs (2)
src/commands/check.rs (1)
check(4-51)src/commands/init.rs (1)
init(4-43)
🔇 Additional comments (8)
src/spinner.rs (2)
1-1: LGTM: Clean and appropriate imports.The imports are well-chosen for the spinner functionality - thread/Duration for timing, io::Write for flushing output.
7-19: Solid spinner implementation with proper process handling.The spinner loop correctly uses
try_wait()to avoid blocking and provides smooth animation updates. The terminal clearing with spaces is a good practice.src/commands/mod.rs (1)
5-5: LGTM: Consistent module declaration.The addition of the setup module follows the existing pattern and is properly declared.
Cargo.toml (1)
6-8: LGTM: Dependency removal aligns with architectural change.Removing the wavec crate dependency is consistent with the shift to using the external wavec CLI tool instead of the internal API.
src/main.rs (2)
5-5: LGTM: Appropriate import addition.The import of
install_wavecfrom the setup module is correctly added.
10-10: LGTM: Spinner module declaration.The spinner module is properly declared.
src/commands/run.rs (1)
4-4: LGTM: Appropriate import for external command execution.The addition of
std::process::Commandimport is necessary for the new external CLI approach.src/commands/setup.rs (1)
1-3: LGTM for imports and module structure.The imports are appropriate for the functionality being implemented.
| let status = Command::new("wavec") | ||
| .arg("run") | ||
| .arg(&main_path) | ||
| .status(); | ||
|
|
||
| match status { | ||
| Ok(s) if s.success() => (), | ||
| Ok(_) => println!("wavec not found."), | ||
| Err(_) => { | ||
| println!("wavec not found."); | ||
| println!("Run `vex setup wavec` to install the compiler."); | ||
| } | ||
| } |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Improve error handling and user messaging.
The current implementation has a few issues:
- Line 40 treats a failed exit status as "wavec not found" which is misleading - it could be a compilation error
- The error handling could be more specific about different failure modes
let status = Command::new("wavec")
.arg("run")
.arg(&main_path)
.status();
match status {
Ok(s) if s.success() => (),
- Ok(_) => println!("wavec not found."),
+ Ok(_) => println!("❌ wavec execution failed."),
Err(_) => {
- println!("wavec not found.");
+ println!("❌ wavec not found.");
println!("Run `vex setup wavec` to install the compiler.");
}
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| let status = Command::new("wavec") | |
| .arg("run") | |
| .arg(&main_path) | |
| .status(); | |
| match status { | |
| Ok(s) if s.success() => (), | |
| Ok(_) => println!("wavec not found."), | |
| Err(_) => { | |
| println!("wavec not found."); | |
| println!("Run `vex setup wavec` to install the compiler."); | |
| } | |
| } | |
| let status = Command::new("wavec") | |
| .arg("run") | |
| .arg(&main_path) | |
| .status(); | |
| match status { | |
| Ok(s) if s.success() => (), | |
| Ok(_) => println!("❌ wavec execution failed."), | |
| Err(_) => { | |
| println!("❌ wavec not found."); | |
| println!("Run `vex setup wavec` to install the compiler."); | |
| } | |
| } |
🤖 Prompt for AI Agents
In src/commands/run.rs around lines 33 to 45, the error handling for the
Command::new("wavec") execution is misleading because a non-success exit status
is treated as "wavec not found," which could actually indicate a compilation
error. To fix this, differentiate between the command not being found (Err
variant) and the command running but returning a failure status (Ok with
!success). Update the messages accordingly to reflect whether the compiler is
missing or if there was a compilation error, providing clearer guidance to the
user.
| let version_arg = match version { | ||
| Some(ver) => format!("--version {}", ver), | ||
| None => "latest".to_string(), | ||
| }; |
There was a problem hiding this comment.
Fix inconsistent version argument formatting.
The version argument formatting is inconsistent - when a version is provided, it uses --version {ver} format, but when None, it just uses "latest". This inconsistency could cause the installer script to fail.
Consider making the formatting consistent:
- let version_arg = match version {
- Some(ver) => format!("--version {}", ver),
- None => "latest".to_string(),
- };
+ let version_arg = match version {
+ Some(ver) => format!("--version {}", ver),
+ None => "--version latest".to_string(),
+ };📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| let version_arg = match version { | |
| Some(ver) => format!("--version {}", ver), | |
| None => "latest".to_string(), | |
| }; | |
| let version_arg = match version { | |
| Some(ver) => format!("--version {}", ver), | |
| None => "--version latest".to_string(), | |
| }; |
🤖 Prompt for AI Agents
In src/commands/setup.rs around lines 5 to 8, the version argument formatting is
inconsistent: it uses "--version {ver}" when a version is provided but just
"latest" when None. To fix this, ensure both cases use the same argument format
by changing the None case to "--version latest" so the installer script receives
a consistent version argument.
| let full_command = format!( | ||
| "curl -fsSL https://wave-lang.dev/install.sh | bash -s -- {}", | ||
| version_arg | ||
| ); | ||
|
|
||
| let child = Command::new("bash") | ||
| .arg("-c") | ||
| .arg(&full_command) | ||
| .stdin(Stdio::null()) | ||
| .stdout(Stdio::null()) // 로그 출력 안 함 | ||
| .stderr(Stdio::null()) | ||
| .spawn() | ||
| .expect("❌ Failed to start wavec installer"); |
There was a problem hiding this comment.
Critical security vulnerabilities and platform compatibility issues.
This implementation has several critical issues:
- Command injection vulnerability: The
version_argis directly interpolated into the shell command without sanitization - No script integrity verification: Downloading and executing scripts from external URLs without checksum verification is a security risk
- Platform compatibility: Hardcoded
bashusage won't work on Windows - Missing dependency checks: No verification that
curlandbashare available
Apply these fixes:
+use std::ffi::OsStr;
+
pub fn install_wavec(version: Option<&str>) {
+ // Validate version parameter to prevent injection
+ if let Some(ver) = version {
+ if !ver.chars().all(|c| c.is_alphanumeric() || c == '.' || c == '-') {
+ eprintln!("❌ Invalid version format");
+ return;
+ }
+ }
+
let version_arg = match version {
- Some(ver) => format!("--version {}", ver),
- None => "latest".to_string(),
+ Some(ver) => vec!["--version", ver],
+ None => vec!["--version", "latest"],
};
- println!("⬇️ Installing wavec ({})...", version_arg);
+ println!("⬇️ Installing wavec...");
- let full_command = format!(
- "curl -fsSL https://wave-lang.dev/install.sh | bash -s -- {}",
- version_arg
- );
-
- let child = Command::new("bash")
- .arg("-c")
- .arg(&full_command)
+ let mut curl_cmd = Command::new("curl");
+ curl_cmd.args(&["-fsSL", "https://wave-lang.dev/install.sh"]);
+
+ let mut bash_cmd = Command::new("bash");
+ bash_cmd.args(&["-s", "--"]).args(&version_arg);
+
+ // Chain curl output to bash input (simplified example)
+ let child = bash_cmd
.stdin(Stdio::null())
- .stdout(Stdio::null()) // 로그 출력 안 함
- .stderr(Stdio::null())
+ .stdout(Stdio::null())
+ .stderr(Stdio::piped()) // Keep stderr for error reporting
.spawn()
- .expect("❌ Failed to start wavec installer");
+ .expect("❌ Failed to start installer");Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In src/commands/setup.rs lines 12 to 24, fix the command injection by sanitizing
or validating version_arg before use; add checksum verification for the
downloaded script to ensure integrity; replace hardcoded "bash" with a
platform-appropriate method to support Windows and other OSes; and add checks to
verify that required dependencies like curl and bash are installed before
running the command.
| let status = show_spinner("Installing wavec...", child); | ||
|
|
||
| if status.success() { | ||
| println!("✅ wavec installed successfully."); | ||
| } else { | ||
| eprintln!("❌ wavec installation failed."); | ||
| } |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Improve error reporting for better user experience.
While the spinner and basic success/failure feedback are good, consider improving error reporting by capturing and displaying stderr output when installation fails.
let status = show_spinner("Installing wavec...", child);
if status.success() {
println!("✅ wavec installed successfully.");
} else {
- eprintln!("❌ wavec installation failed.");
+ eprintln!("❌ wavec installation failed. Exit code: {:?}", status.code());
+ eprintln!("Check your internet connection and try again.");
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| let status = show_spinner("Installing wavec...", child); | |
| if status.success() { | |
| println!("✅ wavec installed successfully."); | |
| } else { | |
| eprintln!("❌ wavec installation failed."); | |
| } | |
| let status = show_spinner("Installing wavec...", child); | |
| if status.success() { | |
| println!("✅ wavec installed successfully."); | |
| } else { | |
| eprintln!("❌ wavec installation failed. Exit code: {:?}", status.code()); | |
| eprintln!("Check your internet connection and try again."); | |
| } |
🤖 Prompt for AI Agents
In src/commands/setup.rs around lines 26 to 32, the current code only prints a
generic failure message when the installation fails. To improve error reporting,
capture the stderr output from the installation process and display it in the
error message. Modify the code to retrieve the error output from the child
process and include it in the eprintln! call when status.success() is false.
| } else if args.len() > 3 && args[1] == "setup" && args[2] == "wavec" { | ||
| let version = if args.len() > 5 && args[3] == "--version" { | ||
| Some(args[4].as_str()) | ||
| } else { | ||
| None | ||
| }; | ||
|
|
||
| install_wavec(version); |
There was a problem hiding this comment.
Fix the argument parsing logic for setup command.
The current logic has several issues:
- Line 27 checks
args.len() > 3but should be>= 3for basic "setup wavec" command - Line 28 checks
args.len() > 5but should be>= 5for version flag - The version parsing doesn't handle the case where
--versionis provided without a value
- } else if args.len() > 3 && args[1] == "setup" && args[2] == "wavec" {
- let version = if args.len() > 5 && args[3] == "--version" {
- Some(args[4].as_str())
+ } else if args.len() >= 3 && args[1] == "setup" && args[2] == "wavec" {
+ let version = if args.len() >= 5 && args[3] == "--version" {
+ Some(args[4].as_str())
} else {
None
};🤖 Prompt for AI Agents
In src/main.rs around lines 27 to 34, update the argument length checks to use
>= instead of > to correctly handle the minimum required arguments for the
"setup wavec" command and the version flag. Additionally, add logic to verify
that when the "--version" flag is present, a corresponding version value exists
to avoid out-of-bounds access or missing version handling. Adjust the
conditional checks and parsing accordingly to ensure robust argument validation.
Added setup command and deleted wavec dependency.
Summary by CodeRabbit
New Features
Improvements
Chores