Skip to content
Open
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
17 changes: 17 additions & 0 deletions src/cmds/js/npm_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use anyhow::Result;

/// Known npm subcommands that should NOT get "run" injected.
/// Shared between production code and tests to avoid drift.
/// Updated to include all 15 missing subcommands from npm 10.8.2 (issue #2663).
const NPM_SUBCOMMANDS: &[&str] = &[
"install",
"i",
Expand Down Expand Up @@ -71,6 +72,22 @@ const NPM_SUBCOMMANDS: &[&str] = &[
"start",
"stop",
"restart",
// Added in fix for #2663 - 15 missing official npm subcommands
"completion",
"edit",
"explore",
"find-dupes",
"help-search",
"hook",
"install-ci-test",
"install-test",
"ll",
"org",
"query",
"run-script",
"sbom",
"shrinkwrap",
"unstar",
];

pub fn run(args: &[String], verbose: u8, skip_env: bool) -> Result<i32> {
Expand Down
22 changes: 21 additions & 1 deletion src/cmds/python/ruff_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,30 @@ struct RuffDiagnostic {
fix: Option<RuffFix>,
}

/// Known ruff subcommands that should NOT get "check --output-format=json" injected.
/// Based on `ruff --help` output. Only "check" and "format" need special handling;
/// all other subcommands pass through unmodified.
const RUFF_SUBCOMMANDS: &[&str] = &[
"check",
"format",
"version",
"rule",
"config",
"linter",
"clean",
"server",
"analyze",
"generate-shell-completion",
"help",
];

pub fn run(args: &[String], verbose: u8) -> Result<i32> {
// Determine if this is a "check" invocation (needs JSON output for filtering)
// Only "check" subcommand or path-like arguments trigger the check filter.
let is_check = args.is_empty()
|| args[0] == "check"
|| (!args[0].starts_with('-') && args[0] != "format" && args[0] != "version");
|| (!args[0].starts_with('-')
&& !RUFF_SUBCOMMANDS.contains(&args[0].as_str()));

let is_format = args.iter().any(|a| a == "format");

Expand Down
6 changes: 6 additions & 0 deletions src/core/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,12 @@ impl Config {
}

fn get_config_path() -> Result<PathBuf> {
// Priority 1: Environment variable RTK_CONFIG_DIR for testing
if let Ok(custom_dir) = std::env::var("RTK_CONFIG_DIR") {
return Ok(PathBuf::from(custom_dir).join(CONFIG_TOML));
}

// Priority 2: Default platform-specific location
let config_dir = dirs::config_dir().unwrap_or_else(|| PathBuf::from("."));
Ok(config_dir.join(RTK_DATA_DIR).join(CONFIG_TOML))
}
Expand Down
22 changes: 15 additions & 7 deletions src/core/telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,14 @@ fn random_salt() -> String {
}

pub fn salt_file_path() -> PathBuf {
dirs::data_local_dir()
.unwrap_or_else(|| PathBuf::from("/tmp"))
.join("rtk")
.join(".device_salt")
let data_dir = if let Ok(custom_dir) = std::env::var("RTK_DATA_DIR") {
PathBuf::from(custom_dir)
} else {
dirs::data_local_dir()
.unwrap_or_else(|| PathBuf::from("/tmp"))
.join("rtk")
};
data_dir.join(".device_salt")
}

fn get_stats(tracker: &tracking::Tracker) -> (i64, Vec<String>, Option<f64>, i64, i64) {
Expand Down Expand Up @@ -439,9 +443,13 @@ fn install_method_from_path(path: &str) -> &'static str {
}

pub fn telemetry_marker_path() -> PathBuf {
let data_dir = dirs::data_local_dir()
.unwrap_or_else(|| PathBuf::from("/tmp"))
.join(RTK_DATA_DIR);
let data_dir = if let Ok(custom_dir) = std::env::var("RTK_DATA_DIR") {
PathBuf::from(custom_dir)
} else {
dirs::data_local_dir()
.unwrap_or_else(|| PathBuf::from("/tmp"))
.join(RTK_DATA_DIR)
};
let _ = std::fs::create_dir_all(&data_dir);
data_dir.join(".telemetry_last_ping")
}
Expand Down
13 changes: 9 additions & 4 deletions src/core/telemetry_cmd.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use anyhow::{Context, Result};
use clap::Subcommand;
use std::path::PathBuf;

#[derive(Debug, Subcommand)]
pub enum TelemetrySubcommand {
Expand Down Expand Up @@ -129,10 +130,14 @@ fn run_forget() -> Result<()> {
}

// Purge local tracking database (GDPR Art. 17 — right to erasure applies to local data too)
let db_path = dirs::data_local_dir()
.unwrap_or_else(|| std::path::PathBuf::from("."))
.join(super::constants::RTK_DATA_DIR)
.join(super::constants::HISTORY_DB);
let db_path = if let Ok(custom_dir) = std::env::var("RTK_DATA_DIR") {
PathBuf::from(custom_dir).join(super::constants::HISTORY_DB)
} else {
dirs::data_local_dir()
.unwrap_or_else(|| std::path::PathBuf::from("."))
.join(super::constants::RTK_DATA_DIR)
.join(super::constants::HISTORY_DB)
};
if db_path.exists() {
match std::fs::remove_file(&db_path) {
Ok(()) => println!("Local tracking database deleted: {}", db_path.display()),
Expand Down
Loading