From 256950ddb6ff7029944f9da14147211d8cc20b7c Mon Sep 17 00:00:00 2001 From: Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com> Date: Thu, 16 Jan 2025 11:33:38 -0800 Subject: [PATCH] fix(outdated): retain strict semver specifier when updating (#27701) Fixes https://github.com/denoland/deno/issues/27697 If it's a strict bound (e.g. `1.0.0` as opposed to `^1.0.0` or other), retain the strictness when we update --- cli/tools/registry/pm/outdated.rs | 8 +++++++- tests/specs/update/deno_json/filtered/deno.json.out | 2 +- .../update/deno_json/update_latest/deno.json.out | 8 ++++---- .../update/deno_json/update_latest/deno.lock.out | 12 ++++++------ .../update/external_import_map/import_map.json.out | 2 +- .../filtered/member_b_package.json.out | 2 +- .../update_latest/subdir/member_a_deno.json.out | 4 ++-- .../update_latest/subdir/member_b_package.json.out | 4 ++-- .../update/package_json/update_latest/deno.lock.out | 4 ++-- .../package_json/update_latest/package.json.out | 2 +- 10 files changed, 27 insertions(+), 21 deletions(-) diff --git a/cli/tools/registry/pm/outdated.rs b/cli/tools/registry/pm/outdated.rs index 939c30b5c1..610ad48c1d 100644 --- a/cli/tools/registry/pm/outdated.rs +++ b/cli/tools/registry/pm/outdated.rs @@ -280,9 +280,15 @@ fn choose_new_version_req( if preferred.version <= resolved?.version { return None; } + let exact = if let Some(range) = dep.req.version_req.range() { + range.0[0].start == range.0[0].end + } else { + false + }; Some( VersionReq::parse_from_specifier( - format!("^{}", preferred.version).as_str(), + format!("{}{}", if exact { "" } else { "^" }, preferred.version) + .as_str(), ) .unwrap(), ) diff --git a/tests/specs/update/deno_json/filtered/deno.json.out b/tests/specs/update/deno_json/filtered/deno.json.out index 4458e2d037..2ad36ca1ec 100644 --- a/tests/specs/update/deno_json/filtered/deno.json.out +++ b/tests/specs/update/deno_json/filtered/deno.json.out @@ -5,7 +5,7 @@ "@denotest/subtract": "jsr:@denotest/subtract@^0.2.0", "@denotest/with-subpath": "jsr:@denotest/multiple-exports@0.5.0/data-json", "@denotest/breaking-change-between-versions": "npm:@denotest/breaking-change-between-versions@1.0.0", - "@denotest/bin": "npm:@denotest/bin@^1.0.0", + "@denotest/bin": "npm:@denotest/bin@1.0.0", "@denotest/has-patch-versions": "npm:@denotest/has-patch-versions@^0.1.0" }, "scopes": { diff --git a/tests/specs/update/deno_json/update_latest/deno.json.out b/tests/specs/update/deno_json/update_latest/deno.json.out index 5e4e99bd66..2b5d1f95d7 100644 --- a/tests/specs/update/deno_json/update_latest/deno.json.out +++ b/tests/specs/update/deno_json/update_latest/deno.json.out @@ -3,9 +3,9 @@ "@denotest/add": "jsr:@denotest/add@^1.0.0", "@denotest/add/": "jsr:/@denotest/add@^1.0.0/", "@denotest/subtract": "jsr:@denotest/subtract@^1.0.0", - "@denotest/with-subpath": "jsr:@denotest/multiple-exports@^1.0.0/data-json", - "@denotest/breaking-change-between-versions": "npm:@denotest/breaking-change-between-versions@^2.0.0", - "@denotest/bin": "npm:@denotest/bin@^1.0.0", + "@denotest/with-subpath": "jsr:@denotest/multiple-exports@1.0.0/data-json", + "@denotest/breaking-change-between-versions": "npm:@denotest/breaking-change-between-versions@2.0.0", + "@denotest/bin": "npm:@denotest/bin@1.0.0", "@denotest/has-patch-versions": "npm:@denotest/has-patch-versions@^0.2.0" }, "scopes": { @@ -13,7 +13,7 @@ "@denotest/add": "jsr:@denotest/add@^1.0.0", "@denotest/add/": "jsr:/@denotest/add@^1.0.0/", "@denotest/subtract": "jsr:@denotest/subtract@^1.0.0", - "@denotest/with-subpath": "jsr:@denotest/multiple-exports@^1.0.0/data-json" + "@denotest/with-subpath": "jsr:@denotest/multiple-exports@1.0.0/data-json" } } } diff --git a/tests/specs/update/deno_json/update_latest/deno.lock.out b/tests/specs/update/deno_json/update_latest/deno.lock.out index ad83546ab1..88403fc77e 100644 --- a/tests/specs/update/deno_json/update_latest/deno.lock.out +++ b/tests/specs/update/deno_json/update_latest/deno.lock.out @@ -2,10 +2,10 @@ "version": "4", "specifiers": { "jsr:@denotest/add@1": "1.0.0", - "jsr:@denotest/multiple-exports@1": "1.0.0", + "jsr:@denotest/multiple-exports@1.0.0": "1.0.0", "jsr:@denotest/subtract@1": "1.0.0", - "npm:@denotest/bin@1": "1.0.0", - "npm:@denotest/breaking-change-between-versions@2": "2.0.0", + "npm:@denotest/bin@1.0.0": "1.0.0", + "npm:@denotest/breaking-change-between-versions@2.0.0": "2.0.0", "npm:@denotest/has-patch-versions@0.2": "0.2.0" }, "jsr": { @@ -33,10 +33,10 @@ "workspace": { "dependencies": [ "jsr:@denotest/add@1", - "jsr:@denotest/multiple-exports@1", + "jsr:@denotest/multiple-exports@1.0.0", "jsr:@denotest/subtract@1", - "npm:@denotest/bin@1", - "npm:@denotest/breaking-change-between-versions@2", + "npm:@denotest/bin@1.0.0", + "npm:@denotest/breaking-change-between-versions@2.0.0", "npm:@denotest/has-patch-versions@0.2" ] } diff --git a/tests/specs/update/external_import_map/import_map.json.out b/tests/specs/update/external_import_map/import_map.json.out index b4e24decbc..998f49eec7 100644 --- a/tests/specs/update/external_import_map/import_map.json.out +++ b/tests/specs/update/external_import_map/import_map.json.out @@ -2,7 +2,7 @@ "imports": { "@denotest/add": "jsr:@denotest/add@^1.0.0", "@denotest/subtract": "jsr:@denotest/subtract@^1.0.0", - "@denotest/breaking-change-between-versions": "npm:@denotest/breaking-change-between-versions@^2.0.0", + "@denotest/breaking-change-between-versions": "npm:@denotest/breaking-change-between-versions@2.0.0", "@denotest/has-patch-versions": "npm:@denotest/has-patch-versions@^0.2.0" } } diff --git a/tests/specs/update/mixed_workspace/filtered/member_b_package.json.out b/tests/specs/update/mixed_workspace/filtered/member_b_package.json.out index 7e582feeab..ee3c0a8548 100644 --- a/tests/specs/update/mixed_workspace/filtered/member_b_package.json.out +++ b/tests/specs/update/mixed_workspace/filtered/member_b_package.json.out @@ -3,6 +3,6 @@ "version": "0.1.0", "dependencies": { "@denotest/has-patch-versions": "0.1.0", - "aliased": "npm:@denotest/bin@^1.0.0" + "aliased": "npm:@denotest/bin@1.0.0" } } diff --git a/tests/specs/update/mixed_workspace/update_latest/subdir/member_a_deno.json.out b/tests/specs/update/mixed_workspace/update_latest/subdir/member_a_deno.json.out index 9210123b82..bda55c6ec5 100644 --- a/tests/specs/update/mixed_workspace/update_latest/subdir/member_a_deno.json.out +++ b/tests/specs/update/mixed_workspace/update_latest/subdir/member_a_deno.json.out @@ -4,7 +4,7 @@ "imports": { "@denotest/add": "jsr:@denotest/add@^1.0.0", "@denotest/add/": "jsr:/@denotest/add@^1.0.0/", - "@denotest/with-subpath": "jsr:@denotest/multiple-exports@^1.0.0/data-json", - "@denotest/breaking-change-between-versions": "npm:@denotest/breaking-change-between-versions@^2.0.0" + "@denotest/with-subpath": "jsr:@denotest/multiple-exports@1.0.0/data-json", + "@denotest/breaking-change-between-versions": "npm:@denotest/breaking-change-between-versions@2.0.0" } } diff --git a/tests/specs/update/mixed_workspace/update_latest/subdir/member_b_package.json.out b/tests/specs/update/mixed_workspace/update_latest/subdir/member_b_package.json.out index 1426fcd7f8..9118e94654 100644 --- a/tests/specs/update/mixed_workspace/update_latest/subdir/member_b_package.json.out +++ b/tests/specs/update/mixed_workspace/update_latest/subdir/member_b_package.json.out @@ -2,7 +2,7 @@ "name": "@denotest/member-b", "version": "0.1.0", "dependencies": { - "@denotest/has-patch-versions": "^0.2.0", - "aliased": "npm:@denotest/bin@^1.0.0" + "@denotest/has-patch-versions": "0.2.0", + "aliased": "npm:@denotest/bin@1.0.0" } } diff --git a/tests/specs/update/package_json/update_latest/deno.lock.out b/tests/specs/update/package_json/update_latest/deno.lock.out index 9a9b1bad5e..6723c8d475 100644 --- a/tests/specs/update/package_json/update_latest/deno.lock.out +++ b/tests/specs/update/package_json/update_latest/deno.lock.out @@ -2,7 +2,7 @@ "version": "4", "specifiers": { "npm:@denotest/bin@1": "1.0.0", - "npm:@denotest/breaking-change-between-versions@2": "2.0.0", + "npm:@denotest/breaking-change-between-versions@2.0.0": "2.0.0", "npm:@denotest/has-patch-versions@0.2": "0.2.0" }, "npm": { @@ -20,7 +20,7 @@ "packageJson": { "dependencies": [ "npm:@denotest/bin@1", - "npm:@denotest/breaking-change-between-versions@2", + "npm:@denotest/breaking-change-between-versions@2.0.0", "npm:@denotest/has-patch-versions@0.2" ] } diff --git a/tests/specs/update/package_json/update_latest/package.json.out b/tests/specs/update/package_json/update_latest/package.json.out index fb483d78bd..ac3c3ff460 100644 --- a/tests/specs/update/package_json/update_latest/package.json.out +++ b/tests/specs/update/package_json/update_latest/package.json.out @@ -1,7 +1,7 @@ { "dependencies": { "@denotest/has-patch-versions": "^0.2.0", - "@denotest/breaking-change-between-versions": "^2.0.0" + "@denotest/breaking-change-between-versions": "2.0.0" }, "devDependencies": { "aliased": "npm:@denotest/bin@^1.0.0"