From 3d8834f957aaebb1eaaaf41d97b7607679630f96 Mon Sep 17 00:00:00 2001 From: Yoshiya Hinosawa Date: Fri, 24 Jan 2025 21:47:15 +0900 Subject: [PATCH] chore: update ensure_registry_files_local to handle scoped packages (#27801) --- Cargo.lock | 1 + Cargo.toml | 1 + cli/Cargo.toml | 2 +- tests/Cargo.toml | 1 + tests/integration/npm_tests.rs | 14 ++++++++------ 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fa881fa2eb..c0f913b2de 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -880,6 +880,7 @@ dependencies = [ "tokio", "url", "uuid", + "walkdir", "zeromq", ] diff --git a/Cargo.toml b/Cargo.toml index 449a9ebc51..f6fbb4b9e6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -219,6 +219,7 @@ tower-service = "0.3.2" twox-hash = "=1.6.3" url = { version = "2.5", features = ["serde", "expose_internals"] } uuid = { version = "1.3.0", features = ["v4"] } +walkdir = "=2.3.2" webpki-root-certs = "0.26.5" webpki-roots = "0.26" which = "6" diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 631edbbb7a..580420ede1 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -170,7 +170,7 @@ tracing = { version = "0.1", features = ["log", "default"] } twox-hash.workspace = true typed-arena = "=2.0.2" uuid = { workspace = true, features = ["serde"] } -walkdir = "=2.3.2" +walkdir.workspace = true which.workspace = true zeromq.workspace = true zip = { version = "2.1.6", default-features = false, features = ["deflate-flate2"] } diff --git a/tests/Cargo.toml b/tests/Cargo.toml index 41bed83834..5b3c24cb5f 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -64,6 +64,7 @@ tokio.workspace = true tower-lsp.workspace = true url.workspace = true uuid = { workspace = true, features = ["serde"] } +walkdir.workspace = true zeromq.workspace = true [target.'cfg(unix)'.dev-dependencies] diff --git a/tests/integration/npm_tests.rs b/tests/integration/npm_tests.rs index bcbcefe731..2e57c4a13c 100644 --- a/tests/integration/npm_tests.rs +++ b/tests/integration/npm_tests.rs @@ -395,22 +395,24 @@ fn node_modules_dir_cache() { fn ensure_registry_files_local() { // ensures the registry files all point at local tarballs let registry_dir_path = util::tests_path().join("registry").join("npm"); - for entry in std::fs::read_dir(®istry_dir_path).unwrap() { + for entry in walkdir::WalkDir::new(®istry_dir_path).max_depth(2) { let entry = entry.unwrap(); if entry.metadata().unwrap().is_dir() { - let registry_json_path = registry_dir_path - .join(entry.file_name()) - .join("registry.json"); + let registry_json_path = entry.path().join("registry.json"); if registry_json_path.exists() { let file_text = std::fs::read_to_string(®istry_json_path).unwrap(); if file_text.contains(&format!( "https://registry.npmjs.org/{}/-/", - entry.file_name().to_string_lossy() + entry + .path() + .strip_prefix(®istry_dir_path) + .unwrap() + .to_string_lossy() )) { panic!( "file {} contained a reference to the npm registry", - registry_json_path + registry_json_path.display() ); } }