From 4f80d83774ce5402a2b10503529fe422c998b841 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Thu, 15 Feb 2024 14:49:35 -0500 Subject: feat(unstable): single checksum per JSR package in the lockfile (#22421) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This changes the lockfile to not store JSR specifiers in the "remote" section. Instead a single JSR integrity is stored per package in the lockfile, which is a hash of the version's `x.x.x_meta.json` file, which contains hashes for every file in the package. The hashes in this file are then compared against when loading. Additionally, when using `{ "vendor": true }` in a deno.json, the files can be modified without causing lockfile errors—the checksum is only checked when copying into the vendor folder and not afterwards (eventually we should add this behaviour for non-jsr specifiers as well). As part of this change, the `vendor` folder creation is not always automatic in the LSP and running an explicit cache command is necessary. The code required to track checksums in the LSP would have been too complex for this PR, so that all goes through deno_graph now. The vendoring is still automatic when running from the CLI. --- cli/tools/coverage/mod.rs | 2 +- cli/tools/doc.rs | 4 ++-- cli/tools/vendor/test.rs | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) (limited to 'cli/tools') diff --git a/cli/tools/coverage/mod.rs b/cli/tools/coverage/mod.rs index aafef292f..5cc705741 100644 --- a/cli/tools/coverage/mod.rs +++ b/cli/tools/coverage/mod.rs @@ -523,7 +523,7 @@ pub async fn cover_files( file_fetcher.get_source(&module_specifier) } else { file_fetcher - .fetch_cached(&module_specifier, 10) + .fetch_cached(&module_specifier, None, 10) .with_context(|| { format!("Failed to fetch \"{module_specifier}\" from cache.") })? diff --git a/cli/tools/doc.rs b/cli/tools/doc.rs index d2cd0c2a2..5044e73d3 100644 --- a/cli/tools/doc.rs +++ b/cli/tools/doc.rs @@ -211,9 +211,9 @@ impl deno_doc::html::HrefResolver for DocResolver { fn resolve_usage( &self, _current_specifier: &ModuleSpecifier, - current_file: &str, + current_file: Option<&str>, ) -> Option { - Some(current_file.to_string()) + current_file.map(|f| f.to_string()) } fn resolve_source(&self, location: &deno_doc::Location) -> Option { diff --git a/cli/tools/vendor/test.rs b/cli/tools/vendor/test.rs index 7910dcf22..6a960c302 100644 --- a/cli/tools/vendor/test.rs +++ b/cli/tools/vendor/test.rs @@ -115,8 +115,7 @@ impl Loader for TestLoader { fn load( &mut self, specifier: &ModuleSpecifier, - _is_dynamic: bool, - _cache_setting: deno_graph::source::CacheSetting, + _options: deno_graph::source::LoadOptions, ) -> LoadFuture { let specifier = self.redirects.get(specifier).unwrap_or(specifier); let result = self.files.get(specifier).map(|result| match result { -- cgit v1.2.3