From b708a13eb02510925b5fd964fe933b4896093185 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Wed, 28 Aug 2024 14:17:47 -0400 Subject: feat: improve lockfile v4 to store normalized version constraints and be more terse (#25247) Stores normalized version constraints in the lockfile, which will improve reproducibility and will fix a bug with duplicate specifiers ending up in the lockfile. Also, gets rid of some duplicate data in the specifiers area of the lockfile. --- cli/args/lockfile.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'cli/args') diff --git a/cli/args/lockfile.rs b/cli/args/lockfile.rs index 8817975cf..3b6bcc2e5 100644 --- a/cli/args/lockfile.rs +++ b/cli/args/lockfile.rs @@ -1,6 +1,6 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -use std::collections::BTreeSet; +use std::collections::HashSet; use std::path::PathBuf; use deno_config::deno_json::ConfigFile; @@ -12,6 +12,7 @@ use deno_core::parking_lot::MutexGuard; use deno_lockfile::WorkspaceMemberConfig; use deno_package_json::PackageJsonDepValue; use deno_runtime::deno_node::PackageJson; +use deno_semver::jsr::JsrDepPackageReq; use crate::cache; use crate::util::fs::atomic_write_file_with_retries; @@ -98,7 +99,9 @@ impl CliLockfile { flags: &Flags, workspace: &Workspace, ) -> Result, AnyError> { - fn pkg_json_deps(maybe_pkg_json: Option<&PackageJson>) -> BTreeSet { + fn pkg_json_deps( + maybe_pkg_json: Option<&PackageJson>, + ) -> HashSet { let Some(pkg_json) = maybe_pkg_json else { return Default::default(); }; @@ -107,21 +110,21 @@ impl CliLockfile { .values() .filter_map(|dep| dep.as_ref().ok()) .filter_map(|dep| match dep { - PackageJsonDepValue::Req(req) => Some(req), + PackageJsonDepValue::Req(req) => { + Some(JsrDepPackageReq::npm(req.clone())) + } PackageJsonDepValue::Workspace(_) => None, }) - .map(|r| format!("npm:{}", r)) .collect() } fn deno_json_deps( maybe_deno_json: Option<&ConfigFile>, - ) -> BTreeSet { + ) -> HashSet { maybe_deno_json .map(|c| { crate::args::deno_json::deno_json_deps(c) .into_iter() - .map(|req| req.to_string()) .collect() }) .unwrap_or_default() @@ -207,6 +210,7 @@ impl CliLockfile { Ok(Some(lockfile)) } + pub fn read_from_path( file_path: PathBuf, frozen: bool, -- cgit v1.2.3