mirror of
https://github.com/pnpm/pnpm.git
synced 2026-07-19 20:22:21 -04:00
refactor(registry-mock): drop portpicker, ask the OS for a port (#360)
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
52
pacquet/Cargo.lock
generated
52
pacquet/Cargo.lock
generated
@@ -960,7 +960,7 @@ dependencies = [
|
||||
"idna",
|
||||
"ipnet",
|
||||
"once_cell",
|
||||
"rand 0.9.4",
|
||||
"rand",
|
||||
"ring",
|
||||
"thiserror 2.0.18",
|
||||
"tinyvec",
|
||||
@@ -982,7 +982,7 @@ dependencies = [
|
||||
"moka",
|
||||
"once_cell",
|
||||
"parking_lot",
|
||||
"rand 0.9.4",
|
||||
"rand",
|
||||
"resolv-conf",
|
||||
"smallvec",
|
||||
"thiserror 2.0.18",
|
||||
@@ -1507,7 +1507,7 @@ dependencies = [
|
||||
"hyper-util",
|
||||
"log",
|
||||
"pin-project-lite",
|
||||
"rand 0.9.4",
|
||||
"rand",
|
||||
"regex",
|
||||
"serde_json",
|
||||
"serde_urlencoded",
|
||||
@@ -1956,7 +1956,6 @@ dependencies = [
|
||||
"assert_cmd",
|
||||
"clap",
|
||||
"pipe-trait",
|
||||
"portpicker",
|
||||
"reqwest",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@@ -2125,15 +2124,6 @@ version = "1.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49"
|
||||
|
||||
[[package]]
|
||||
name = "portpicker"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "be97d76faf1bfab666e1375477b23fde79eccf0276e9b63b92a39d676a889ba9"
|
||||
dependencies = [
|
||||
"rand 0.8.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "potential_utf"
|
||||
version = "0.1.5"
|
||||
@@ -2235,35 +2225,14 @@ version = "6.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ca0ecfa931c29007047d1bc58e623ab12e5590e8c7cc53200d5202b69266d8a"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"rand_chacha 0.3.1",
|
||||
"rand_core 0.6.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.9.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "44c5af06bb1b7d3216d91932aed5265164bf384dc89cd6ba05cf59a35f5f76ea"
|
||||
dependencies = [
|
||||
"rand_chacha 0.9.0",
|
||||
"rand_core 0.9.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_chacha"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core 0.6.4",
|
||||
"rand_chacha",
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2273,16 +2242,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core 0.9.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
||||
dependencies = [
|
||||
"getrandom 0.2.17",
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -56,7 +56,6 @@ reqwest = { version = "0.13", default-features = false, features = [
|
||||
] }
|
||||
node-semver = { version = "2.2.0" }
|
||||
pipe-trait = { version = "0.4.0" }
|
||||
portpicker = { version = "0.1.1" }
|
||||
rayon = { version = "1.12.0" }
|
||||
rmp-serde = { version = "1.3.0" }
|
||||
rusqlite = { version = "0.39.0", features = ["bundled"] }
|
||||
|
||||
@@ -35,7 +35,6 @@ allow = [
|
||||
"BSD-3-Clause",
|
||||
"BSL-1.0",
|
||||
"ISC",
|
||||
"Unlicense", # required by portpicker, which is used by crates/registry-mock
|
||||
"Zlib", # required by foldhash, a transitive dep of rusqlite
|
||||
]
|
||||
confidence-threshold = 0.8
|
||||
|
||||
@@ -24,7 +24,6 @@ doc = false
|
||||
assert_cmd = { workspace = true }
|
||||
clap = { workspace = true }
|
||||
pipe-trait = { workspace = true }
|
||||
portpicker = { workspace = true }
|
||||
reqwest = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
|
||||
@@ -2,6 +2,7 @@ mod dirs;
|
||||
mod kill_verdaccio;
|
||||
mod mock_instance;
|
||||
mod node_registry_mock;
|
||||
mod pick_port;
|
||||
mod port_to_url;
|
||||
mod registry_anchor;
|
||||
mod registry_info;
|
||||
@@ -9,5 +10,6 @@ mod registry_info;
|
||||
pub use dirs::*;
|
||||
pub use mock_instance::*;
|
||||
pub use node_registry_mock::*;
|
||||
pub use pick_port::*;
|
||||
pub use registry_anchor::*;
|
||||
pub use registry_info::*;
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use std::env::temp_dir;
|
||||
|
||||
use clap::Parser;
|
||||
use pacquet_registry_mock::{MockInstanceOptions, PreparedRegistryInfo};
|
||||
use portpicker::pick_unused_port;
|
||||
use pacquet_registry_mock::{MockInstanceOptions, PreparedRegistryInfo, pick_unused_port};
|
||||
use reqwest::Client;
|
||||
use tokio::time::Duration;
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use crate::{
|
||||
PreparedRegistryInfo, RegistryAnchor, RegistryInfo,
|
||||
kill_verdaccio::kill_all_verdaccio_children, node_registry_mock, port_to_url::port_to_url,
|
||||
kill_verdaccio::kill_all_verdaccio_children, node_registry_mock, pick_port::pick_unused_port,
|
||||
port_to_url::port_to_url,
|
||||
};
|
||||
use assert_cmd::prelude::*;
|
||||
use pipe_trait::Pipe;
|
||||
use portpicker::pick_unused_port;
|
||||
use reqwest::Client;
|
||||
use std::{
|
||||
fs::File,
|
||||
|
||||
6
pacquet/tasks/registry-mock/src/pick_port.rs
Normal file
6
pacquet/tasks/registry-mock/src/pick_port.rs
Normal file
@@ -0,0 +1,6 @@
|
||||
use std::net::TcpListener;
|
||||
|
||||
/// Ask the OS for an unused TCP port on the loopback interface.
|
||||
pub fn pick_unused_port() -> Option<u16> {
|
||||
TcpListener::bind("127.0.0.1:0").ok()?.local_addr().ok().map(|addr| addr.port())
|
||||
}
|
||||
Reference in New Issue
Block a user