From bf237c6241f53122e37341a0dda65ef9e3b51a49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Mon, 23 Jan 2023 23:41:02 +0100 Subject: refactor: Move lockfile to a separate crate (#17503) Moves the lockfile implementation to a separate crate so other projects like Deploy can use it as well. --- cli/npm/registry.rs | 13 ------------- cli/npm/resolution/mod.rs | 7 +++++-- 2 files changed, 5 insertions(+), 15 deletions(-) (limited to 'cli/npm') diff --git a/cli/npm/registry.rs b/cli/npm/registry.rs index 0b35079de..97397350d 100644 --- a/cli/npm/registry.rs +++ b/cli/npm/registry.rs @@ -184,19 +184,6 @@ pub struct NpmPackageVersionDistInfo { } impl NpmPackageVersionDistInfo { - #[cfg(test)] - pub fn new( - tarball: String, - shasum: String, - integrity: Option, - ) -> Self { - Self { - tarball, - shasum, - integrity, - } - } - pub fn integrity(&self) -> Cow { self .integrity diff --git a/cli/npm/resolution/mod.rs b/cli/npm/resolution/mod.rs index c4d05598c..f10678cbe 100644 --- a/cli/npm/resolution/mod.rs +++ b/cli/npm/resolution/mod.rs @@ -397,10 +397,13 @@ impl NpmResolution { pub fn lock(&self, lockfile: &mut Lockfile) -> Result<(), AnyError> { let snapshot = self.snapshot.read(); for (package_req, package_id) in snapshot.package_reqs.iter() { - lockfile.insert_npm_specifier(package_req, package_id); + lockfile.insert_npm_specifier( + package_req.to_string(), + package_id.as_serialized(), + ); } for package in snapshot.all_packages() { - lockfile.check_or_insert_npm_package(&package)?; + lockfile.check_or_insert_npm_package(package.into())?; } Ok(()) } -- cgit v1.2.3