Skip to content
2 changes: 1 addition & 1 deletion src/lint_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ fn filter_mypy_output(output: &str) -> String {
}

/// Filter generic linter output (fallback for non-ESLint linters)
fn filter_generic_lint(output: &str) -> String {
pub(crate) fn filter_generic_lint(output: &str) -> String {
let mut warnings = 0;
let mut errors = 0;
let mut issues: Vec<String> = Vec::new();
Expand Down
92 changes: 92 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ mod utils;
mod vitest_cmd;
mod wc_cmd;
mod wget_cmd;
mod yarn_cmd;

use anyhow::{Context, Result};
use clap::{Parser, Subcommand};
Expand Down Expand Up @@ -434,6 +435,13 @@ enum Commands {
args: Vec<String>,
},

/// Yarn workspace commands with filtered output
Yarn {
/// Yarn arguments (workspace <pkg> [run] <script> [args...])
#[arg(trailing_var_arg = true, allow_hyphen_values = true)]
args: Vec<String>,
},

/// Curl with auto-JSON detection and schema output
Curl {
/// Curl arguments (URL + options)
Expand Down Expand Up @@ -1392,6 +1400,10 @@ fn main() -> Result<()> {
}
}

Commands::Yarn { args } => {
yarn_cmd::run(&args, cli.verbose, cli.skip_env)?;
}

Commands::Ruff { args } => {
ruff_cmd::run(&args, cli.verbose)?;
}
Expand Down Expand Up @@ -1542,4 +1554,84 @@ mod tests {
_ => panic!("Expected Git Commit command"),
}
}

#[test]
fn test_yarn_workspace_basic() {
let cli =
Cli::try_parse_from(["rtk", "yarn", "workspace", "@server", "run", "test"]).unwrap();
match cli.command {
Commands::Yarn { args } => {
assert_eq!(args, vec!["workspace", "@server", "run", "test"]);
}
_ => panic!("Expected Yarn command"),
}
}

#[test]
fn test_yarn_workspace_scoped_package_with_slash() {
let cli = Cli::try_parse_from(["rtk", "yarn", "workspace", "@myorg/server", "run", "lint"])
.unwrap();
match cli.command {
Commands::Yarn { args } => {
assert_eq!(args, vec!["workspace", "@myorg/server", "run", "lint"]);
}
_ => panic!("Expected Yarn command"),
}
}

#[test]
fn test_yarn_workspace_without_run() {
let cli =
Cli::try_parse_from(["rtk", "yarn", "workspace", "@server", "test", "--coverage"])
.unwrap();
match cli.command {
Commands::Yarn { args } => {
assert_eq!(args, vec!["workspace", "@server", "test", "--coverage"]);
}
_ => panic!("Expected Yarn command"),
}
}

#[test]
fn test_yarn_workspace_extra_args() {
let cli = Cli::try_parse_from([
"rtk",
"yarn",
"workspace",
"@server",
"run",
"vitest",
"--reporter=verbose",
"--coverage",
])
.unwrap();
match cli.command {
Commands::Yarn { args } => {
assert_eq!(
args,
vec![
"workspace",
"@server",
"run",
"vitest",
"--reporter=verbose",
"--coverage"
]
);
}
_ => panic!("Expected Yarn command"),
}
}

#[test]
fn test_yarn_workspace_simple_package() {
let cli =
Cli::try_parse_from(["rtk", "yarn", "workspace", "server", "run", "build"]).unwrap();
match cli.command {
Commands::Yarn { args } => {
assert_eq!(args, vec!["workspace", "server", "run", "build"]);
}
_ => panic!("Expected Yarn command"),
}
}
}
2 changes: 1 addition & 1 deletion src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ fn filter_errors(output: &str) -> String {
result.join("\n")
}

fn extract_test_summary(output: &str, command: &str) -> String {
pub(crate) fn extract_test_summary(output: &str, command: &str) -> String {
let mut result = Vec::new();
let lines: Vec<&str> = output.lines().collect();

Expand Down
2 changes: 1 addition & 1 deletion src/tsc_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub fn run(args: &[String], verbose: u8) -> Result<()> {
}

/// Filter TypeScript compiler output - group errors by file, show every error
fn filter_tsc_output(output: &str) -> String {
pub(crate) fn filter_tsc_output(output: &str) -> String {
lazy_static::lazy_static! {
// Pattern: src/file.ts(12,5): error TS2322: Type 'string' is not assignable to type 'number'.
static ref TSC_ERROR: Regex = Regex::new(
Expand Down
Loading