From 71ee3d7f38e2f49d12c065f0b5bc50e70336dd7a Mon Sep 17 00:00:00 2001 From: David Sherret Date: Mon, 9 Dec 2024 16:19:08 -0500 Subject: [PATCH] fix: do not error when subpath has an @ symbol (#27290) Closes https://github.com/denoland/deno/issues/27243 --- Cargo.lock | 6 +++--- Cargo.toml | 2 +- cli/tools/registry/pm.rs | 10 ++++------ .../add/add_with_subpath/wrong_constraint_jsr.out | 4 ++-- .../add/add_with_subpath/wrong_constraint_npm.out | 4 ++-- .../error_version_after_subpath/main.out | 2 +- 6 files changed, 13 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9c42621100a6df..30824206b6d69f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2192,9 +2192,9 @@ dependencies = [ [[package]] name = "deno_semver" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4756be7351289726087408984db18b9eb5e0186907673f39f858d119d0162071" +checksum = "7d1259270d66a5e6d29bb75c9289656541874f79ae9ff6c9f1c790846d5c07ba" dependencies = [ "deno_error", "monch", @@ -4569,7 +4569,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" dependencies = [ "cfg-if", - "windows-targets 0.48.5", + "windows-targets 0.52.6", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 4698acd06d7d59..f8b01164ac8fa3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,7 +58,7 @@ deno_npm = "=0.26.0" deno_path_util = "=0.2.1" deno_permissions = { version = "0.41.0", path = "./runtime/permissions" } deno_runtime = { version = "0.190.0", path = "./runtime" } -deno_semver = "=0.6.0" +deno_semver = "=0.6.1" deno_terminal = "0.2.0" napi_sym = { version = "0.111.0", path = "./ext/napi/sym" } test_util = { package = "test_server", path = "./tests/util/server" } diff --git a/cli/tools/registry/pm.rs b/cli/tools/registry/pm.rs index 5718cd3ec116fc..6f89ec7aaee3c4 100644 --- a/cli/tools/registry/pm.rs +++ b/cli/tools/registry/pm.rs @@ -432,9 +432,8 @@ pub async fn add( let mut package_reqs = Vec::with_capacity(add_flags.packages.len()); for entry_text in add_flags.packages.iter() { - let req = AddRmPackageReq::parse(entry_text).with_context(|| { - format!("Failed to parse package required: {}", entry_text) - })?; + let req = AddRmPackageReq::parse(entry_text) + .with_context(|| format!("Failed to parse package: {}", entry_text))?; match req { Ok(add_req) => package_reqs.push(add_req), @@ -805,9 +804,8 @@ pub async fn remove( let mut removed_packages = vec![]; for package in &remove_flags.packages { - let req = AddRmPackageReq::parse(package).with_context(|| { - format!("Failed to parse package required: {}", package) - })?; + let req = AddRmPackageReq::parse(package) + .with_context(|| format!("Failed to parse package: {}", package))?; let mut parsed_pkg_name = None; for config in configs.iter_mut().flatten() { match &req { diff --git a/tests/specs/add/add_with_subpath/wrong_constraint_jsr.out b/tests/specs/add/add_with_subpath/wrong_constraint_jsr.out index 7de7008e93e65b..5f6661920af922 100644 --- a/tests/specs/add/add_with_subpath/wrong_constraint_jsr.out +++ b/tests/specs/add/add_with_subpath/wrong_constraint_jsr.out @@ -1,4 +1,4 @@ -error: Failed to parse package required: jsr:@std/testing/bdd@1 +error: Failed to parse package: jsr:@std/testing/bdd@1 Caused by: - Invalid package specifier 'jsr:@std/testing/bdd@1'. Did you mean to write 'jsr:@std/testing@1/bdd'? + Invalid package specifier 'jsr:@std/testing/bdd@1'. Did you mean to write 'jsr:@std/testing@1/bdd'? If not, add a version requirement to the specifier. diff --git a/tests/specs/add/add_with_subpath/wrong_constraint_npm.out b/tests/specs/add/add_with_subpath/wrong_constraint_npm.out index 4adcf9ef6ae664..2298810bec319f 100644 --- a/tests/specs/add/add_with_subpath/wrong_constraint_npm.out +++ b/tests/specs/add/add_with_subpath/wrong_constraint_npm.out @@ -1,4 +1,4 @@ -error: Failed to parse package required: npm:preact/hooks@10 +error: Failed to parse package: npm:preact/hooks@10 Caused by: - Invalid package specifier 'npm:preact/hooks@10'. Did you mean to write 'npm:preact@10/hooks'? + Invalid package specifier 'npm:preact/hooks@10'. Did you mean to write 'npm:preact@10/hooks'? If not, add a version requirement to the specifier. diff --git a/tests/specs/npm/error_version_after_subpath/error_version_after_subpath/main.out b/tests/specs/npm/error_version_after_subpath/error_version_after_subpath/main.out index 4e5f03e23c067f..1804936f0f0bf6 100644 --- a/tests/specs/npm/error_version_after_subpath/error_version_after_subpath/main.out +++ b/tests/specs/npm/error_version_after_subpath/error_version_after_subpath/main.out @@ -1,2 +1,2 @@ -error: Invalid package specifier 'npm:react-dom/server@18.2.0'. Did you mean to write 'npm:react-dom@18.2.0/server'? +error: Invalid package specifier 'npm:react-dom/server@18.2.0'. Did you mean to write 'npm:react-dom@18.2.0/server'? If not, add a version requirement to the specifier. at [WILDCARD]/error_version_after_subpath/main.js:1:8