Skip to content

Commit 8c5b2ca

Browse files
mikolalysenkoclaude
andcommitted
fix: use pnpm dlx instead of deprecated pnpx
Replace pnpx with pnpm dlx for better compatibility. pnpx has been deprecated since pnpm v7 in favor of pnpm dlx. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 2e97344 commit 8c5b2ca

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

crates/socket-patch-cli/src/commands/setup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub async fn run(args: SetupArgs) -> i32 {
5454
if !args.json {
5555
println!("Found {} package.json file(s)", package_json_files.len());
5656
if pm == PackageManager::Pnpm {
57-
println!("Detected pnpm project (using pnpx)");
57+
println!("Detected pnpm project (using pnpm dlx)");
5858
}
5959
}
6060

crates/socket-patch-core/src/package_json/detect.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ fn socket_patch_command(pm: PackageManager) -> &'static str {
1010
match pm {
1111
PackageManager::Npm => "npx @socketsecurity/socket-patch apply --silent --ecosystems npm",
1212
PackageManager::Pnpm => {
13-
"pnpx @socketsecurity/socket-patch apply --silent --ecosystems npm"
13+
"pnpm dlx @socketsecurity/socket-patch apply --silent --ecosystems npm"
1414
}
1515
}
1616
}
@@ -294,10 +294,10 @@ mod tests {
294294
}
295295

296296
#[test]
297-
fn test_configured_str_pnpx_pattern() {
298-
let content = r#"{"scripts":{"postinstall":"pnpx @socketsecurity/socket-patch apply --silent --ecosystems npm"}}"#;
297+
fn test_configured_str_pnpm_dlx_pattern() {
298+
let content = r#"{"scripts":{"postinstall":"pnpm dlx @socketsecurity/socket-patch apply --silent --ecosystems npm"}}"#;
299299
let status = is_setup_configured_str(content);
300-
// "pnpx @socketsecurity/socket-patch apply" contains "socket-patch apply"
300+
// "pnpm dlx @socketsecurity/socket-patch apply" contains "socket-patch apply"
301301
assert!(status.postinstall_configured);
302302
}
303303

@@ -315,7 +315,7 @@ mod tests {
315315
fn test_generate_empty_pnpm() {
316316
assert_eq!(
317317
generate_updated_script("", PackageManager::Pnpm),
318-
"pnpx @socketsecurity/socket-patch apply --silent --ecosystems npm"
318+
"pnpm dlx @socketsecurity/socket-patch apply --silent --ecosystems npm"
319319
);
320320
}
321321

@@ -331,7 +331,7 @@ mod tests {
331331
fn test_generate_prepend_pnpm() {
332332
assert_eq!(
333333
generate_updated_script("echo done", PackageManager::Pnpm),
334-
"pnpx @socketsecurity/socket-patch apply --silent --ecosystems npm && echo done"
334+
"pnpm dlx @socketsecurity/socket-patch apply --silent --ecosystems npm && echo done"
335335
);
336336
}
337337

@@ -374,8 +374,8 @@ mod tests {
374374
let (modified, new_postinstall, new_dependencies) =
375375
update_package_json_object(&mut pkg, PackageManager::Pnpm);
376376
assert!(modified);
377-
assert!(new_postinstall.contains("pnpx @socketsecurity/socket-patch apply"));
378-
assert!(new_dependencies.contains("pnpx @socketsecurity/socket-patch apply"));
377+
assert!(new_postinstall.contains("pnpm dlx @socketsecurity/socket-patch apply"));
378+
assert!(new_dependencies.contains("pnpm dlx @socketsecurity/socket-patch apply"));
379379
}
380380

381381
#[test]
@@ -446,16 +446,16 @@ mod tests {
446446
let (modified, new_content, _, new_pi, _, new_dep) =
447447
update_package_json_content(content, PackageManager::Pnpm).unwrap();
448448
assert!(modified);
449-
assert!(new_pi.contains("pnpx @socketsecurity/socket-patch apply"));
450-
assert!(new_dep.contains("pnpx @socketsecurity/socket-patch apply"));
449+
assert!(new_pi.contains("pnpm dlx @socketsecurity/socket-patch apply"));
450+
assert!(new_dep.contains("pnpm dlx @socketsecurity/socket-patch apply"));
451451
let parsed: serde_json::Value = serde_json::from_str(&new_content).unwrap();
452452
assert!(parsed["scripts"]["postinstall"]
453453
.as_str()
454454
.unwrap()
455-
.contains("pnpx"));
455+
.contains("pnpm dlx"));
456456
assert!(parsed["scripts"]["dependencies"]
457457
.as_str()
458458
.unwrap()
459-
.contains("pnpx"));
459+
.contains("pnpm dlx"));
460460
}
461461
}

crates/socket-patch-core/src/package_json/update.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ mod tests {
208208
let result = update_package_json(&pkg, false, PackageManager::Pnpm).await;
209209
assert_eq!(result.status, UpdateStatus::Updated);
210210
let content = fs::read_to_string(&pkg).await.unwrap();
211-
assert!(content.contains("pnpx @socketsecurity/socket-patch apply"));
211+
assert!(content.contains("pnpm dlx @socketsecurity/socket-patch apply"));
212212
}
213213

214214
#[tokio::test]

0 commit comments

Comments
 (0)