From d6ecf6c2438e7a2907eb0dc885ff160ebe9c5fb5 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Tue, 27 Aug 2024 22:07:18 -0400 Subject: [PATCH 1/5] feat: improve lockfile v4 to store normalized version constraints --- Cargo.lock | 35 ++++++++++++---- Cargo.toml | 7 +++- cli/Cargo.toml | 2 +- cli/args/lockfile.rs | 16 +++++--- cli/graph_util.rs | 41 +++++++++++-------- cli/lsp/documents.rs | 8 ++-- cli/lsp/jsr.rs | 25 ++++++----- cli/module_loader.rs | 3 +- cli/npm/managed/mod.rs | 3 +- cli/npm/managed/resolution.rs | 13 ++---- tests/Cargo.toml | 1 + tests/integration/check_tests.rs | 15 +++++-- tests/integration/jsr_tests.rs | 26 +++++++----- tests/integration/npm_tests.rs | 4 +- tests/integration/run_tests.rs | 24 +++++------ .../future_install_local_deno/deno.lock.out | 12 +++--- .../future_install_node_modules/deno.lock.out | 4 +- .../specs/lockfile/adding_jsr_dep/lock01.out | 2 +- .../specs/lockfile/adding_jsr_dep/lock02.out | 4 +- .../adding_jsr_export_new_dep/lock01.out | 4 +- .../adding_jsr_export_new_dep/lock02.out | 6 +-- .../specs/lockfile/adding_npm_dep/lock01.out | 2 +- .../specs/lockfile/adding_npm_dep/lock02.out | 4 +- .../frozen_lockfile/frozen_new_dep_cache.out | 6 +-- .../frozen_new_dep_dynamic_jsr.out | 6 +-- .../frozen_new_dep_dynamic_npm.out | 6 +-- .../frozen_new_dep_jsr_cache.out | 6 +-- .../frozen_new_dep_jsr_run.out | 6 +-- .../frozen_lockfile/frozen_new_dep_run.out | 6 +-- .../frozen_package_json_changed.out | 6 +-- .../frozen_package_json_changed_install.out | 6 +-- .../frozen_lockfile/no_lockfile_run.out | 2 +- .../lockfile/only_package_json/deno.lock.out | 4 +- .../adding_npm_dep_in_dynamic_import/lock.out | 4 +- .../dynamic_npm_resolution_failure/main.out | 2 +- tests/specs/remove/basic/add_lock.out | 8 ++-- .../workspaces/lockfile/expected-lock.out | 2 +- 37 files changed, 185 insertions(+), 146 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d97b04d4aa40d1..afebcdedf2c4b0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -750,6 +750,7 @@ dependencies = [ "deno_core", "deno_fetch", "deno_lockfile", + "deno_semver", "deno_terminal 0.2.0", "deno_tls", "deno_tower_lsp", @@ -1172,7 +1173,7 @@ dependencies = [ "deno_graph", "deno_lint", "deno_lockfile", - "deno_npm", + "deno_npm 0.24.0", "deno_package_json", "deno_runtime", "deno_semver", @@ -1734,10 +1735,11 @@ dependencies = [ [[package]] name = "deno_lockfile" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d4e132d2930cf5fbbec8323f4ac98952ca3d1c4ff74d770bbdd7c2588b1783" +checksum = "fb68a4a666c69eabd8fe505d6fdc4ed4a2d962fe1680dbfa8b0c8a2975d58ed0" dependencies = [ + "deno_semver", "serde", "serde_json", "thiserror", @@ -1883,8 +1885,25 @@ dependencies = [ [[package]] name = "deno_npm" version = "0.24.0" +dependencies = [ + "anyhow", + "async-trait", + "deno_lockfile", + "deno_semver", + "futures", + "log", + "monch", + "serde", + "serde_json", + "thiserror", + "url", +] + +[[package]] +name = "deno_npm" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cafaa830cea11b37ad838ed9508c9cc00ac0235fdd42b3b31aa74d5cd6fe3d92" +checksum = "efb2dd7efaf478d780a6ca43e6127667d5329ed9a5ff89f42cec0dc21ee58342" dependencies = [ "anyhow", "async-trait", @@ -2008,9 +2027,9 @@ dependencies = [ [[package]] name = "deno_semver" -version = "0.5.10" +version = "0.5.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56feaf035e29320d11adf89eafa14f5447d3089deb1ce7de61ba7969195f5ff1" +checksum = "eef522937758930b9d6897631fa94bc69bcbbe78613c939ab2054ca96191afbd" dependencies = [ "monch", "once_cell", @@ -2815,15 +2834,13 @@ dependencies = [ [[package]] name = "eszip" version = "0.76.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b3a54eb4f58493897fc2627e76e6714c9b52c84213c923ab1601a5daf722b00" dependencies = [ "anyhow", "async-trait", "base64 0.21.7", "deno_ast", "deno_graph", - "deno_npm", + "deno_npm 0.25.0", "deno_semver", "futures", "hashlink", diff --git a/Cargo.toml b/Cargo.toml index 10166396058dce..ead3e0f48eff0e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,10 +48,11 @@ deno_ast = { version = "=0.41.2", features = ["transpiling"] } deno_core = { version = "0.306.0" } deno_bench_util = { version = "0.160.0", path = "./bench_util" } -deno_lockfile = "=0.22.0" +deno_lockfile = "=0.23.0" deno_media_type = { version = "0.1.4", features = ["module_specifier"] } deno_permissions = { version = "0.26.0", path = "./runtime/permissions" } deno_runtime = { version = "0.175.0", path = "./runtime" } +deno_semver = "=0.5.12" deno_terminal = "0.2.0" napi_sym = { version = "0.96.0", path = "./cli/napi/sym" } test_util = { package = "test_server", path = "./tests/util/server" } @@ -394,3 +395,7 @@ opt-level = 3 opt-level = 3 [profile.release.package.zstd-sys] opt-level = 3 + +[patch.crates-io] +deno_npm = { path = "../deno_npm" } +eszip = { path = "../eszip" } diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 33a169458bb76c..1d177cd326364f 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -75,7 +75,7 @@ deno_lockfile.workspace = true deno_npm = "=0.24.0" deno_package_json.workspace = true deno_runtime = { workspace = true, features = ["include_js_files_for_snapshotting"] } -deno_semver = "=0.5.10" +deno_semver.workspace = true deno_task_shell = "=0.17.0" deno_terminal.workspace = true eszip = "=0.76.0" diff --git a/cli/args/lockfile.rs b/cli/args/lockfile.rs index 30db49b7acf0ad..5bc18e66eee0ff 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() @@ -215,6 +218,7 @@ impl CliLockfile { Ok(Some(lockfile)) } + pub fn read_from_path( file_path: PathBuf, frozen: bool, diff --git a/cli/graph_util.rs b/cli/graph_util.rs index 6f0e6acd90d213..82dc231986c0d2 100644 --- a/cli/graph_util.rs +++ b/cli/graph_util.rs @@ -44,8 +44,9 @@ use deno_graph::SpecifierError; use deno_runtime::deno_fs::FileSystem; use deno_runtime::deno_node; use deno_runtime::deno_permissions::PermissionsContainer; +use deno_semver::jsr::JsrDepPackageReq; use deno_semver::package::PackageNv; -use deno_semver::package::PackageReq; +use deno_semver::Version; use import_map::ImportMapError; use std::collections::HashSet; use std::path::PathBuf; @@ -463,7 +464,7 @@ impl ModuleGraphBuilder { .content .packages .jsr - .get(&package_nv.to_string()) + .get(package_nv) .map(|s| LoaderChecksum::new(s.integrity.clone())) } @@ -477,7 +478,7 @@ impl ModuleGraphBuilder { self .0 .lock() - .insert_package(package_nv.to_string(), checksum.into_string()); + .insert_package(package_nv.clone(), checksum.into_string()); } } @@ -556,16 +557,21 @@ impl ModuleGraphBuilder { } } } - for (key, value) in &lockfile.content.packages.specifiers { - if let Some(key) = key - .strip_prefix("jsr:") - .and_then(|key| PackageReq::from_str(key).ok()) - { - if let Some(value) = value - .strip_prefix("jsr:") - .and_then(|value| PackageNv::from_str(value).ok()) - { - graph.packages.add_nv(key, value); + for (req_dep, value) in &lockfile.content.packages.specifiers { + match req_dep.kind { + deno_semver::package::PackageKind::Jsr => { + if let Ok(version) = Version::parse_standard(&value) { + graph.packages.add_nv( + req_dep.req.clone(), + PackageNv { + name: req_dep.req.name.clone(), + version, + }, + ); + } + } + deno_semver::package::PackageKind::Npm => { + // ignore } } } @@ -603,16 +609,15 @@ impl ModuleGraphBuilder { if has_jsr_package_mappings_changed { for (from, to) in graph.packages.mappings() { lockfile.insert_package_specifier( - format!("jsr:{}", from), - format!("jsr:{}", to), + JsrDepPackageReq::jsr(from.clone()), + to.version.to_string(), ); } } // jsr packages if has_jsr_package_deps_changed { - for (name, deps) in graph.packages.packages_with_deps() { - lockfile - .add_package_deps(&name.to_string(), deps.map(|s| s.to_string())); + for (nv, deps) in graph.packages.packages_with_deps() { + lockfile.add_package_deps(&nv, deps.cloned()); } } } diff --git a/cli/lsp/documents.rs b/cli/lsp/documents.rs index 80c5a4dc57c658..dcfdb0d006396e 100644 --- a/cli/lsp/documents.rs +++ b/cli/lsp/documents.rs @@ -1410,11 +1410,9 @@ impl Documents { if let Some(lockfile) = config_data.lockfile.as_ref() { let reqs = npm_reqs_by_scope.entry(Some(scope.clone())).or_default(); let lockfile = lockfile.lock(); - for key in lockfile.content.packages.specifiers.keys() { - if let Some(key) = key.strip_prefix("npm:") { - if let Ok(req) = PackageReq::from_str(key) { - reqs.insert(req); - } + for dep_req in lockfile.content.packages.specifiers.keys() { + if dep_req.kind == deno_semver::package::PackageKind::Npm { + reqs.insert(dep_req.req.clone()); } } } diff --git a/cli/lsp/jsr.rs b/cli/lsp/jsr.rs index c0a82383d3915f..6c591637c8c71b 100644 --- a/cli/lsp/jsr.rs +++ b/cli/lsp/jsr.rs @@ -92,20 +92,23 @@ impl JsrCacheResolver { } } if let Some(lockfile) = config_data.and_then(|d| d.lockfile.as_ref()) { - for (req_url, nv_url) in &lockfile.lock().content.packages.specifiers { - let Some(req) = req_url.strip_prefix("jsr:") else { - continue; - }; - let Some(nv) = nv_url.strip_prefix("jsr:") else { - continue; - }; - let Ok(req) = PackageReq::from_str(req) else { - continue; + for (dep_req, version) in &lockfile.lock().content.packages.specifiers { + let req = match dep_req.kind { + deno_semver::package::PackageKind::Jsr => &dep_req.req, + deno_semver::package::PackageKind::Npm => { + continue; + } }; - let Ok(nv) = PackageNv::from_str(nv) else { + let Ok(version) = Version::parse_standard(version) else { continue; }; - nv_by_req.insert(req, Some(nv)); + nv_by_req.insert( + req.clone(), + Some(PackageNv { + name: req.name.clone(), + version, + }), + ); } } Self { diff --git a/cli/module_loader.rs b/cli/module_loader.rs index 3208d1365798c9..acd3e886e2a4e8 100644 --- a/cli/module_loader.rs +++ b/cli/module_loader.rs @@ -771,7 +771,8 @@ impl ModuleLoader lib, root_permissions, ) - .await?; + .await + .inspect_err(|err| eprintln!("FOUND: {:?}", err))?; update_permit.commit(); Ok(()) } diff --git a/cli/npm/managed/mod.rs b/cli/npm/managed/mod.rs index 8f82ddea2028d5..a0148c6482abee 100644 --- a/cli/npm/managed/mod.rs +++ b/cli/npm/managed/mod.rs @@ -406,8 +406,7 @@ impl ManagedCliNpmResolver { } } if result.dependencies_result.is_ok() { - result.dependencies_result = - self.cache_packages().await.map_err(AnyError::from); + result.dependencies_result = self.cache_packages().await; } result diff --git a/cli/npm/managed/resolution.rs b/cli/npm/managed/resolution.rs index 3d13e173539f9a..486e87816b2cb6 100644 --- a/cli/npm/managed/resolution.rs +++ b/cli/npm/managed/resolution.rs @@ -22,6 +22,7 @@ use deno_npm::NpmPackageCacheFolderId; use deno_npm::NpmPackageId; use deno_npm::NpmResolutionPackage; use deno_npm::NpmSystemInfo; +use deno_semver::jsr::JsrDepPackageReq; use deno_semver::package::PackageNv; use deno_semver::package::PackageReq; use deno_semver::VersionReq; @@ -329,16 +330,10 @@ fn populate_lockfile_from_snapshot( ) { let mut lockfile = lockfile.lock(); for (package_req, nv) in snapshot.package_reqs() { + let id = &snapshot.resolve_package_from_deno_module(nv).unwrap().id; lockfile.insert_package_specifier( - format!("npm:{}", package_req), - format!( - "npm:{}", - snapshot - .resolve_package_from_deno_module(nv) - .unwrap() - .id - .as_serialized() - ), + JsrDepPackageReq::npm(package_req.clone()), + format!("{}{}", id.nv.version, id.peer_deps_serialized()), ); } for package in snapshot.all_packages_for_every_system() { diff --git a/tests/Cargo.toml b/tests/Cargo.toml index 0c14b6993bffc7..bb84c224962025 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -41,6 +41,7 @@ deno_cache_dir = { workspace = true } deno_core = { workspace = true, features = ["include_js_files_for_snapshotting", "unsafe_use_unprotected_platform"] } deno_fetch.workspace = true deno_lockfile.workspace = true +deno_semver.workspace = true deno_terminal.workspace = true deno_tls.workspace = true fastwebsockets = { workspace = true, features = ["upgrade", "unstable-split"] } diff --git a/tests/integration/check_tests.rs b/tests/integration/check_tests.rs index f0e3dfb5ad8fe2..ce464135bb6ce3 100644 --- a/tests/integration/check_tests.rs +++ b/tests/integration/check_tests.rs @@ -1,6 +1,7 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. use deno_lockfile::NewLockfileOptions; +use deno_semver::jsr::JsrDepPackageReq; use test_util as util; use test_util::itest; use util::env_vars_for_npm_tests; @@ -372,8 +373,11 @@ fn npm_module_check_then_error() { // make the specifier resolve to version 1 lockfile.content.packages.specifiers.insert( - "npm:@denotest/breaking-change-between-versions".to_string(), - "npm:@denotest/breaking-change-between-versions@1.0.0".to_string(), + JsrDepPackageReq::from_str( + "npm:@denotest/breaking-change-between-versions", + ) + .unwrap(), + "1.0.0".to_string(), ); lockfile_path.write(lockfile.as_json_string()); temp_dir.write( @@ -387,8 +391,11 @@ fn npm_module_check_then_error() { // now update the lockfile to use version 2 instead, which should cause a // type checking error because the oldName no longer exists lockfile.content.packages.specifiers.insert( - "npm:@denotest/breaking-change-between-versions".to_string(), - "npm:@denotest/breaking-change-between-versions@2.0.0".to_string(), + JsrDepPackageReq::from_str( + "npm:@denotest/breaking-change-between-versions", + ) + .unwrap(), + "2.0.0".to_string(), ); lockfile_path.write(lockfile.as_json_string()); diff --git a/tests/integration/jsr_tests.rs b/tests/integration/jsr_tests.rs index f31b53f276cf39..af5b24fe4198c9 100644 --- a/tests/integration/jsr_tests.rs +++ b/tests/integration/jsr_tests.rs @@ -6,6 +6,8 @@ use deno_core::serde_json::json; use deno_core::serde_json::Value; use deno_lockfile::Lockfile; use deno_lockfile::NewLockfileOptions; +use deno_semver::jsr::JsrDepPackageReq; +use deno_semver::package::PackageNv; use test_util as util; use url::Url; use util::assert_contains; @@ -154,8 +156,10 @@ console.log(version);"#, .content .packages .specifiers - .get_mut("jsr:@denotest/no-module-graph@0.1") - .unwrap() = "jsr:@denotest/no-module-graph@0.1.0".to_string(); + .get_mut( + &JsrDepPackageReq::from_str("jsr:@denotest/no-module-graph@0.1").unwrap(), + ) + .unwrap() = "0.1.0".to_string(); lockfile_path.write(lockfile.as_json_string()); test_context @@ -276,9 +280,9 @@ console.log(version);"#, overwrite: false, }) .unwrap(); - let pkg_name = "@denotest/no-module-graph@0.1.1"; - let original_integrity = get_lockfile_pkg_integrity(&lockfile, pkg_name); - set_lockfile_pkg_integrity(&mut lockfile, pkg_name, "bad_integrity"); + let pkg_nv = "@denotest/no-module-graph@0.1.1"; + let original_integrity = get_lockfile_pkg_integrity(&lockfile, pkg_nv); + set_lockfile_pkg_integrity(&mut lockfile, pkg_nv, "bad_integrity"); lockfile_path.write(lockfile.as_json_string()); let actual_integrity = @@ -317,7 +321,7 @@ Investigate the lockfile; delete it to regenerate the lockfile or --reload to re .assert_exit_code(10); // now update to the correct integrity - set_lockfile_pkg_integrity(&mut lockfile, pkg_name, &original_integrity); + set_lockfile_pkg_integrity(&mut lockfile, pkg_nv, &original_integrity); lockfile_path.write(lockfile.as_json_string()); // should pass now @@ -329,7 +333,7 @@ Investigate the lockfile; delete it to regenerate the lockfile or --reload to re .assert_exit_code(0); // now update to a bad integrity again - set_lockfile_pkg_integrity(&mut lockfile, pkg_name, "bad_integrity"); + set_lockfile_pkg_integrity(&mut lockfile, pkg_nv, "bad_integrity"); lockfile_path.write(lockfile.as_json_string()); // shouldn't matter because we have a vendor folder @@ -400,12 +404,12 @@ If you modified your global cache, run again with the --reload flag to restore i .assert_exit_code(10); } -fn get_lockfile_pkg_integrity(lockfile: &Lockfile, pkg_name: &str) -> String { +fn get_lockfile_pkg_integrity(lockfile: &Lockfile, pkg_nv: &str) -> String { lockfile .content .packages .jsr - .get(pkg_name) + .get(&PackageNv::from_str(pkg_nv).unwrap()) .unwrap() .integrity .clone() @@ -413,14 +417,14 @@ fn get_lockfile_pkg_integrity(lockfile: &Lockfile, pkg_name: &str) -> String { fn set_lockfile_pkg_integrity( lockfile: &mut Lockfile, - pkg_name: &str, + pkg_nv: &str, integrity: &str, ) { lockfile .content .packages .jsr - .get_mut(pkg_name) + .get_mut(&PackageNv::from_str(pkg_nv).unwrap()) .unwrap() .integrity = integrity.to_string(); } diff --git a/tests/integration/npm_tests.rs b/tests/integration/npm_tests.rs index d75b8768995f1a..2a29e8ab258a09 100644 --- a/tests/integration/npm_tests.rs +++ b/tests/integration/npm_tests.rs @@ -1219,7 +1219,7 @@ fn lock_file_lock_write() { let lock_file_content = r#"{ "version": "4", "specifiers": { - "npm:cowsay@1.5.0": "npm:cowsay@1.5.0" + "npm:cowsay@1.5.0": "1.5.0" }, "npm": { "ansi-regex@3.0.1": { @@ -1430,7 +1430,7 @@ fn auto_discover_lock_file() { let lock_file_content = r#"{ "version": "4", "specifiers": { - "npm:@denotest/bin": "npm:@denotest/bin@1.0.0" + "npm:@denotest/bin": "1.0.0" }, "npm": { "@denotest/bin@1.0.0": { diff --git a/tests/integration/run_tests.rs b/tests/integration/run_tests.rs index ad20b77e1367f8..ef37d48751e989 100644 --- a/tests/integration/run_tests.rs +++ b/tests/integration/run_tests.rs @@ -923,7 +923,7 @@ fn lock_redirects() { r#"{ "version": "4", "specifiers": { - "npm:@denotest/esm-basic": "npm:@denotest/esm-basic@1.0.0" + "npm:@denotest/esm-basic@*": "1.0.0" }, "npm": { "@denotest/esm-basic@1.0.0": { @@ -974,8 +974,8 @@ fn lock_deno_json_package_json_deps() { lockfile.assert_matches_json(json!({ "version": "4", "specifiers": { - "jsr:@denotest/module-graph@1.4": "jsr:@denotest/module-graph@1.4.0", - "npm:@denotest/esm-basic": "npm:@denotest/esm-basic@1.0.0" + "jsr:@denotest/module-graph@1.4": "1.4.0", + "npm:@denotest/esm-basic@*": "1.0.0" }, "jsr": { "@denotest/module-graph@1.4.0": { @@ -990,7 +990,7 @@ fn lock_deno_json_package_json_deps() { "workspace": { "dependencies": [ "jsr:@denotest/module-graph@1.4", - "npm:@denotest/esm-basic" + "npm:@denotest/esm-basic@*" ] } })); @@ -1022,8 +1022,8 @@ fn lock_deno_json_package_json_deps() { lockfile.assert_matches_json(json!({ "version": "4", "specifiers": { - "jsr:@denotest/module-graph@1.4": "jsr:@denotest/module-graph@1.4.0", - "npm:@denotest/esm-basic": "npm:@denotest/esm-basic@1.0.0" + "jsr:@denotest/module-graph@1.4": "1.4.0", + "npm:@denotest/esm-basic@*": "1.0.0" }, "jsr": { "@denotest/module-graph@1.4.0": { @@ -1041,7 +1041,7 @@ fn lock_deno_json_package_json_deps() { ], "packageJson": { "dependencies": [ - "npm:@denotest/esm-basic" + "npm:@denotest/esm-basic@*" ] } } @@ -1059,7 +1059,7 @@ fn lock_deno_json_package_json_deps() { lockfile.assert_matches_json(json!({ "version": "4", "specifiers": { - "jsr:@denotest/module-graph@1.4": "jsr:@denotest/module-graph@1.4.0", + "jsr:@denotest/module-graph@1.4": "1.4.0", }, "jsr": { "@denotest/module-graph@1.4.0": { @@ -1143,8 +1143,8 @@ fn lock_deno_json_package_json_deps_workspace() { lockfile.assert_matches_json(json!({ "version": "4", "specifiers": { - "npm:@denotest/cjs-default-export@1": "npm:@denotest/cjs-default-export@1.0.0", - "npm:@denotest/esm-basic@1": "npm:@denotest/esm-basic@1.0.0" + "npm:@denotest/cjs-default-export@1": "1.0.0", + "npm:@denotest/esm-basic@1": "1.0.0" }, "npm": { "@denotest/cjs-default-export@1.0.0": { @@ -1186,8 +1186,8 @@ fn lock_deno_json_package_json_deps_workspace() { let expected_lockfile = json!({ "version": "4", "specifiers": { - "npm:@denotest/cjs-default-export@1": "npm:@denotest/cjs-default-export@1.0.0", - "npm:@denotest/esm-basic@1": "npm:@denotest/esm-basic@1.0.0" + "npm:@denotest/cjs-default-export@1": "1.0.0", + "npm:@denotest/esm-basic@1": "1.0.0" }, "npm": { "@denotest/cjs-default-export@1.0.0": { diff --git a/tests/specs/install/future_install_local_deno/deno.lock.out b/tests/specs/install/future_install_local_deno/deno.lock.out index 04bfc9b3a70bb4..5c9582fff4eb2b 100644 --- a/tests/specs/install/future_install_local_deno/deno.lock.out +++ b/tests/specs/install/future_install_local_deno/deno.lock.out @@ -1,9 +1,9 @@ { "version": "4", "specifiers": { - "jsr:@denotest/add": "jsr:@denotest/add@1.0.0", - "jsr:@std/testing": "jsr:@std/testing@1.0.0", - "npm:@denotest/esm-basic@^1.0.0": "npm:@denotest/esm-basic@1.0.0" + "jsr:@denotest/add@*": "1.0.0", + "jsr:@std/testing@*": "1.0.0", + "npm:@denotest/esm-basic@1": "1.0.0" }, "jsr": { "@denotest/add@1.0.0": { @@ -26,9 +26,9 @@ }, "workspace": { "dependencies": [ - "jsr:@denotest/add", - "jsr:@std/testing", - "npm:@denotest/esm-basic@^1.0.0" + "jsr:@denotest/add@*", + "jsr:@std/testing@*", + "npm:@denotest/esm-basic@1" ] } } diff --git a/tests/specs/install/future_install_node_modules/deno.lock.out b/tests/specs/install/future_install_node_modules/deno.lock.out index c8071adadca858..3a6ae85868e845 100644 --- a/tests/specs/install/future_install_node_modules/deno.lock.out +++ b/tests/specs/install/future_install_node_modules/deno.lock.out @@ -1,7 +1,7 @@ { "version": "4", "specifiers": { - "npm:@denotest/esm-basic": "npm:@denotest/esm-basic@1.0.0" + "npm:@denotest/esm-basic@*": "1.0.0" }, "npm": { "@denotest/esm-basic@1.0.0": { @@ -11,7 +11,7 @@ "workspace": { "packageJson": { "dependencies": [ - "npm:@denotest/esm-basic" + "npm:@denotest/esm-basic@*" ] } } diff --git a/tests/specs/lockfile/adding_jsr_dep/lock01.out b/tests/specs/lockfile/adding_jsr_dep/lock01.out index fcdb22ae1bb44d..7f5c7540738008 100644 --- a/tests/specs/lockfile/adding_jsr_dep/lock01.out +++ b/tests/specs/lockfile/adding_jsr_dep/lock01.out @@ -1,7 +1,7 @@ { "version": "4", "specifiers": { - "jsr:@denotest/add@1": "jsr:@denotest/add@1.0.0" + "jsr:@denotest/add@1": "1.0.0" }, "jsr": { "@denotest/add@1.0.0": { diff --git a/tests/specs/lockfile/adding_jsr_dep/lock02.out b/tests/specs/lockfile/adding_jsr_dep/lock02.out index f069c5a2f7c520..6519df0b35b879 100644 --- a/tests/specs/lockfile/adding_jsr_dep/lock02.out +++ b/tests/specs/lockfile/adding_jsr_dep/lock02.out @@ -1,8 +1,8 @@ { "version": "4", "specifiers": { - "jsr:@denotest/add@1": "jsr:@denotest/add@1.0.0", - "jsr:@denotest/subtract@1": "jsr:@denotest/subtract@1.0.0" + "jsr:@denotest/add@1": "1.0.0", + "jsr:@denotest/subtract@1": "1.0.0" }, "jsr": { "@denotest/add@1.0.0": { diff --git a/tests/specs/lockfile/adding_jsr_export_new_dep/lock01.out b/tests/specs/lockfile/adding_jsr_export_new_dep/lock01.out index a2ce254a3f320d..d3b8f82e7b2bfc 100644 --- a/tests/specs/lockfile/adding_jsr_export_new_dep/lock01.out +++ b/tests/specs/lockfile/adding_jsr_export_new_dep/lock01.out @@ -1,8 +1,8 @@ { "version": "4", "specifiers": { - "jsr:@denotest/add@1": "jsr:@denotest/add@1.0.0", - "jsr:@denotest/different-deps-per-export@1": "jsr:@denotest/different-deps-per-export@1.0.0" + "jsr:@denotest/add@1": "1.0.0", + "jsr:@denotest/different-deps-per-export@1": "1.0.0" }, "jsr": { "@denotest/add@1.0.0": { diff --git a/tests/specs/lockfile/adding_jsr_export_new_dep/lock02.out b/tests/specs/lockfile/adding_jsr_export_new_dep/lock02.out index d4825c32d0fb9a..ddb1dfca01c39c 100644 --- a/tests/specs/lockfile/adding_jsr_export_new_dep/lock02.out +++ b/tests/specs/lockfile/adding_jsr_export_new_dep/lock02.out @@ -1,9 +1,9 @@ { "version": "4", "specifiers": { - "jsr:@denotest/add@1": "jsr:@denotest/add@1.0.0", - "jsr:@denotest/different-deps-per-export@1": "jsr:@denotest/different-deps-per-export@1.0.0", - "jsr:@denotest/subtract@1": "jsr:@denotest/subtract@1.0.0" + "jsr:@denotest/add@1": "1.0.0", + "jsr:@denotest/different-deps-per-export@1": "1.0.0", + "jsr:@denotest/subtract@1": "1.0.0" }, "jsr": { "@denotest/add@1.0.0": { diff --git a/tests/specs/lockfile/adding_npm_dep/lock01.out b/tests/specs/lockfile/adding_npm_dep/lock01.out index 0ed6aa8c780e9b..82b6a5b3db2bca 100644 --- a/tests/specs/lockfile/adding_npm_dep/lock01.out +++ b/tests/specs/lockfile/adding_npm_dep/lock01.out @@ -1,7 +1,7 @@ { "version": "4", "specifiers": { - "npm:@denotest/add@1": "npm:@denotest/add@1.0.0" + "npm:@denotest/add@1": "1.0.0" }, "npm": { "@denotest/add@1.0.0": { diff --git a/tests/specs/lockfile/adding_npm_dep/lock02.out b/tests/specs/lockfile/adding_npm_dep/lock02.out index 7a9da8d293a65c..f22cbc42800d1b 100644 --- a/tests/specs/lockfile/adding_npm_dep/lock02.out +++ b/tests/specs/lockfile/adding_npm_dep/lock02.out @@ -1,8 +1,8 @@ { "version": "4", "specifiers": { - "npm:@denotest/add@1": "npm:@denotest/add@1.0.0", - "npm:@denotest/subtract@1": "npm:@denotest/subtract@1.0.0" + "npm:@denotest/add@1": "1.0.0", + "npm:@denotest/subtract@1": "1.0.0" }, "npm": { "@denotest/add@1.0.0": { diff --git a/tests/specs/lockfile/frozen_lockfile/frozen_new_dep_cache.out b/tests/specs/lockfile/frozen_lockfile/frozen_new_dep_cache.out index a66e090a2ecb43..55ada3dc3ee6be 100644 --- a/tests/specs/lockfile/frozen_lockfile/frozen_new_dep_cache.out +++ b/tests/specs/lockfile/frozen_lockfile/frozen_new_dep_cache.out @@ -1,8 +1,8 @@ error: The lockfile is out of date. Run `deno cache --frozen=false` or rerun with `--frozen=false` to update it. changes: - 4 | - "npm:@denotest/add@1": "npm:@denotest/add@1.0.0" - 4 | + "npm:@denotest/add@1": "npm:@denotest/add@1.0.0", - 5 | + "npm:@denotest/subtract@1": "npm:@denotest/subtract@1.0.0" + 4 | - "npm:@denotest/add@1": "1.0.0" + 4 | + "npm:@denotest/add@1": "1.0.0", + 5 | + "npm:@denotest/subtract@1": "1.0.0" 9 | - } 10 | + }, 11 | + "@denotest/subtract@1.0.0": { diff --git a/tests/specs/lockfile/frozen_lockfile/frozen_new_dep_dynamic_jsr.out b/tests/specs/lockfile/frozen_lockfile/frozen_new_dep_dynamic_jsr.out index 7051ecbfa5ee37..e2b29706c03f57 100644 --- a/tests/specs/lockfile/frozen_lockfile/frozen_new_dep_dynamic_jsr.out +++ b/tests/specs/lockfile/frozen_lockfile/frozen_new_dep_dynamic_jsr.out @@ -3,9 +3,9 @@ Download http://127.0.0.1:4250/@denotest/add/1.0.0_meta.json Download http://127.0.0.1:4250/@denotest/add/1.0.0/mod.ts error: Uncaught (in promise) TypeError: The lockfile is out of date. Run `deno cache --frozen=false` or rerun with `--frozen=false` to update it. changes: - 4 | - "npm:@denotest/add@1": "npm:@denotest/add@1.0.0" - 4 | + "jsr:@denotest/add@1": "jsr:@denotest/add@1.0.0", - 5 | + "npm:@denotest/add@1": "npm:@denotest/add@1.0.0" + 4 | - "npm:@denotest/add@1": "1.0.0" + 4 | + "jsr:@denotest/add@1": "1.0.0", + 5 | + "npm:@denotest/add@1": "1.0.0" 6 | + }, 7 | + "jsr": { 8 | + "@denotest/add@1.0.0": { diff --git a/tests/specs/lockfile/frozen_lockfile/frozen_new_dep_dynamic_npm.out b/tests/specs/lockfile/frozen_lockfile/frozen_new_dep_dynamic_npm.out index 749c69587e62c0..368d8de5e1f616 100644 --- a/tests/specs/lockfile/frozen_lockfile/frozen_new_dep_dynamic_npm.out +++ b/tests/specs/lockfile/frozen_lockfile/frozen_new_dep_dynamic_npm.out @@ -1,9 +1,9 @@ Download http://localhost:4260/@denotest/subtract error: Uncaught (in promise) TypeError: The lockfile is out of date. Run `deno cache --frozen=false` or rerun with `--frozen=false` to update it. changes: - 4 | - "npm:@denotest/add@1": "npm:@denotest/add@1.0.0" - 4 | + "npm:@denotest/add@1": "npm:@denotest/add@1.0.0", - 5 | + "npm:@denotest/subtract@1": "npm:@denotest/subtract@1.0.0" + 4 | - "npm:@denotest/add@1": "1.0.0" + 4 | + "npm:@denotest/add@1": "1.0.0", + 5 | + "npm:@denotest/subtract@1": "1.0.0" 9 | - } 10 | + }, 11 | + "@denotest/subtract@1.0.0": { diff --git a/tests/specs/lockfile/frozen_lockfile/frozen_new_dep_jsr_cache.out b/tests/specs/lockfile/frozen_lockfile/frozen_new_dep_jsr_cache.out index 9e77bce8585320..5265400ec35e99 100644 --- a/tests/specs/lockfile/frozen_lockfile/frozen_new_dep_jsr_cache.out +++ b/tests/specs/lockfile/frozen_lockfile/frozen_new_dep_jsr_cache.out @@ -1,10 +1,10 @@ error: The lockfile is out of date. Run `deno cache --frozen=false` or rerun with `--frozen=false` to update it. changes: - 4 | - "jsr:@denotest/add@1": "jsr:@denotest/add@1.0.0" + 4 | - "jsr:@denotest/add@1": "1.0.0" 5 | - }, 6 | - "jsr": { - 4 | + "jsr:@denotest/add@0.2.0": "jsr:@denotest/add@0.2.0", - 5 | + "jsr:@denotest/add@1": "jsr:@denotest/add@1.0.0" + 4 | + "jsr:@denotest/add@0.2.0": "0.2.0", + 5 | + "jsr:@denotest/add@1": "1.0.0" 6 | + }, 7 | + "jsr": { 8 | + "@denotest/add@0.2.0": { diff --git a/tests/specs/lockfile/frozen_lockfile/frozen_new_dep_jsr_run.out b/tests/specs/lockfile/frozen_lockfile/frozen_new_dep_jsr_run.out index 0222ca35572843..215427a0d06014 100644 --- a/tests/specs/lockfile/frozen_lockfile/frozen_new_dep_jsr_run.out +++ b/tests/specs/lockfile/frozen_lockfile/frozen_new_dep_jsr_run.out @@ -2,11 +2,11 @@ Download http://127.0.0.1:4250/@denotest/add/0.2.0_meta.json Download http://127.0.0.1:4250/@denotest/add/0.2.0/mod.ts error: The lockfile is out of date. Run `deno cache --frozen=false` or rerun with `--frozen=false` to update it. changes: - 4 | - "jsr:@denotest/add@1": "jsr:@denotest/add@1.0.0" + 4 | - "jsr:@denotest/add@1": "1.0.0" 5 | - }, 6 | - "jsr": { - 4 | + "jsr:@denotest/add@0.2.0": "jsr:@denotest/add@0.2.0", - 5 | + "jsr:@denotest/add@1": "jsr:@denotest/add@1.0.0" + 4 | + "jsr:@denotest/add@0.2.0": "0.2.0", + 5 | + "jsr:@denotest/add@1": "1.0.0" 6 | + }, 7 | + "jsr": { 8 | + "@denotest/add@0.2.0": { diff --git a/tests/specs/lockfile/frozen_lockfile/frozen_new_dep_run.out b/tests/specs/lockfile/frozen_lockfile/frozen_new_dep_run.out index d8ab302b7ad5ab..351afbae7c866a 100644 --- a/tests/specs/lockfile/frozen_lockfile/frozen_new_dep_run.out +++ b/tests/specs/lockfile/frozen_lockfile/frozen_new_dep_run.out @@ -1,9 +1,9 @@ Download http://localhost:4260/@denotest/subtract error: The lockfile is out of date. Run `deno cache --frozen=false` or rerun with `--frozen=false` to update it. changes: - 4 | - "npm:@denotest/add@1": "npm:@denotest/add@1.0.0" - 4 | + "npm:@denotest/add@1": "npm:@denotest/add@1.0.0", - 5 | + "npm:@denotest/subtract@1": "npm:@denotest/subtract@1.0.0" + 4 | - "npm:@denotest/add@1": "1.0.0" + 4 | + "npm:@denotest/add@1": "1.0.0", + 5 | + "npm:@denotest/subtract@1": "1.0.0" 9 | - } 10 | + }, 11 | + "@denotest/subtract@1.0.0": { diff --git a/tests/specs/lockfile/frozen_lockfile/frozen_package_json_changed.out b/tests/specs/lockfile/frozen_lockfile/frozen_package_json_changed.out index 60a01158dd6d16..05d1ca3753279a 100644 --- a/tests/specs/lockfile/frozen_lockfile/frozen_package_json_changed.out +++ b/tests/specs/lockfile/frozen_lockfile/frozen_package_json_changed.out @@ -1,9 +1,9 @@ Download http://localhost:4260/@denotest/bin error: The lockfile is out of date. Run `deno cache --frozen=false`, `deno install --frozen=false`, or rerun with `--frozen=false` to update it. changes: - 4 | - "npm:@denotest/add@1": "npm:@denotest/add@1.0.0" - 4 | + "npm:@denotest/add@1": "npm:@denotest/add@1.0.0", - 5 | + "npm:@denotest/bin@0.7.0": "npm:@denotest/bin@0.7.0" + 4 | - "npm:@denotest/add@1": "1.0.0" + 4 | + "npm:@denotest/add@1": "1.0.0", + 5 | + "npm:@denotest/bin@0.7.0": "0.7.0" 9 | - } 10 | + }, 11 | + "@denotest/bin@0.7.0": { diff --git a/tests/specs/lockfile/frozen_lockfile/frozen_package_json_changed_install.out b/tests/specs/lockfile/frozen_lockfile/frozen_package_json_changed_install.out index 39717959668788..112edc411f43ae 100644 --- a/tests/specs/lockfile/frozen_lockfile/frozen_package_json_changed_install.out +++ b/tests/specs/lockfile/frozen_lockfile/frozen_package_json_changed_install.out @@ -1,8 +1,8 @@ error: The lockfile is out of date. Run `deno cache --frozen=false`, `deno install --frozen=false`, or rerun with `--frozen=false` to update it. changes: - 4 | - "npm:@denotest/add@1": "npm:@denotest/add@1.0.0" - 4 | + "npm:@denotest/add@1": "npm:@denotest/add@1.0.0", - 5 | + "npm:@denotest/bin@0.7.0": "npm:@denotest/bin@0.7.0" + 4 | - "npm:@denotest/add@1": "1.0.0" + 4 | + "npm:@denotest/add@1": "1.0.0", + 5 | + "npm:@denotest/bin@0.7.0": "0.7.0" 9 | - } 10 | + }, 11 | + "@denotest/bin@0.7.0": { diff --git a/tests/specs/lockfile/frozen_lockfile/no_lockfile_run.out b/tests/specs/lockfile/frozen_lockfile/no_lockfile_run.out index e482c469ffa658..f04aea55cbdd20 100644 --- a/tests/specs/lockfile/frozen_lockfile/no_lockfile_run.out +++ b/tests/specs/lockfile/frozen_lockfile/no_lockfile_run.out @@ -5,7 +5,7 @@ changes: 1 | +{ 2 | + "version": "4", 3 | + "specifiers": { - 4 | + "npm:@denotest/add@1": "npm:@denotest/add@1.0.0" + 4 | + "npm:@denotest/add@1": "1.0.0" 5 | + }, 6 | + "npm": { 7 | + "@denotest/add@1.0.0": { diff --git a/tests/specs/lockfile/only_package_json/deno.lock.out b/tests/specs/lockfile/only_package_json/deno.lock.out index 395190a66a4d0f..d390a59c1312ba 100644 --- a/tests/specs/lockfile/only_package_json/deno.lock.out +++ b/tests/specs/lockfile/only_package_json/deno.lock.out @@ -1,7 +1,7 @@ { "version": "4", "specifiers": { - "npm:@denotest/esm-basic": "npm:@denotest/esm-basic@1.0.0" + "npm:@denotest/esm-basic@*": "1.0.0" }, "npm": { "@denotest/esm-basic@1.0.0": [WILDCARD] @@ -9,7 +9,7 @@ "workspace": { "packageJson": { "dependencies": [ - "npm:@denotest/esm-basic" + "npm:@denotest/esm-basic@*" ] } } diff --git a/tests/specs/npm/adding_npm_dep_in_dynamic_import/lock.out b/tests/specs/npm/adding_npm_dep_in_dynamic_import/lock.out index c8caafc079d3ec..e80d56bd87a14b 100644 --- a/tests/specs/npm/adding_npm_dep_in_dynamic_import/lock.out +++ b/tests/specs/npm/adding_npm_dep_in_dynamic_import/lock.out @@ -1,8 +1,8 @@ { "version": "4", "specifiers": { - "npm:@denotest/add": "npm:@denotest/add@1.0.0", - "npm:@denotest/subtract": "npm:@denotest/subtract@1.0.0" + "npm:@denotest/add@*": "1.0.0", + "npm:@denotest/subtract@*": "1.0.0" }, "npm": { "@denotest/add@1.0.0": { diff --git a/tests/specs/npm/dynamic_npm_resolution_failure/main.out b/tests/specs/npm/dynamic_npm_resolution_failure/main.out index 03c733567b90aa..756d9459d90ef3 100644 --- a/tests/specs/npm/dynamic_npm_resolution_failure/main.out +++ b/tests/specs/npm/dynamic_npm_resolution_failure/main.out @@ -6,7 +6,7 @@ Download http://localhost:4260/chalk/chalk-5.0.1.tgz Hi TypeError: Error in @denotest/dep-cannot-parse@1.0.0 parsing version requirement for dependency: @denotest/esm-basic@unknown-scheme:unknown -Invalid npm version requirement. Unexpected character. +Invalid version requirement. Unexpected character. unknown-scheme:unknown ~ at async file:///[WILDLINE]main.ts:5:3 { diff --git a/tests/specs/remove/basic/add_lock.out b/tests/specs/remove/basic/add_lock.out index 99127b95decbaa..1f6589380ebc86 100644 --- a/tests/specs/remove/basic/add_lock.out +++ b/tests/specs/remove/basic/add_lock.out @@ -1,8 +1,8 @@ { "version": "4", "specifiers": { - "jsr:@std/assert@^1.0.0": "jsr:@std/assert@1.0.0", - "jsr:@std/http@^1.0.0": "jsr:@std/http@1.0.0" + "jsr:@std/assert@1": "1.0.0", + "jsr:@std/http@1": "1.0.0" }, "jsr": { "@std/assert@1.0.0": { @@ -14,8 +14,8 @@ }, "workspace": { "dependencies": [ - "jsr:@std/assert@^1.0.0", - "jsr:@std/http@^1.0.0" + "jsr:@std/assert@1", + "jsr:@std/http@1" ] } } diff --git a/tests/specs/workspaces/lockfile/expected-lock.out b/tests/specs/workspaces/lockfile/expected-lock.out index fc387c76076f26..1559be08580b0b 100644 --- a/tests/specs/workspaces/lockfile/expected-lock.out +++ b/tests/specs/workspaces/lockfile/expected-lock.out @@ -1,7 +1,7 @@ { "version": "4", "specifiers": { - "jsr:@denotest/add@1": "jsr:@denotest/add@1.0.0" + "jsr:@denotest/add@1": "1.0.0" }, "jsr": { "@denotest/add@1.0.0": { From fc11c294a1bef02a211af42dce28517bf045e0c9 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Tue, 27 Aug 2024 22:16:45 -0400 Subject: [PATCH 2/5] update to released version --- Cargo.lock | 25 +++++-------------------- Cargo.toml | 4 ---- cli/Cargo.toml | 4 ++-- 3 files changed, 7 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index afebcdedf2c4b0..04a28e815db1e5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1173,7 +1173,7 @@ dependencies = [ "deno_graph", "deno_lint", "deno_lockfile", - "deno_npm 0.24.0", + "deno_npm", "deno_package_json", "deno_runtime", "deno_semver", @@ -1882,23 +1882,6 @@ dependencies = [ "yoke", ] -[[package]] -name = "deno_npm" -version = "0.24.0" -dependencies = [ - "anyhow", - "async-trait", - "deno_lockfile", - "deno_semver", - "futures", - "log", - "monch", - "serde", - "serde_json", - "thiserror", - "url", -] - [[package]] name = "deno_npm" version = "0.25.0" @@ -2833,14 +2816,16 @@ dependencies = [ [[package]] name = "eszip" -version = "0.76.0" +version = "0.77.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d14989a45cef01c2dd79546bec3c392a7bbb3e9928bbf71acae5551bb4e71be9" dependencies = [ "anyhow", "async-trait", "base64 0.21.7", "deno_ast", "deno_graph", - "deno_npm 0.25.0", + "deno_npm", "deno_semver", "futures", "hashlink", diff --git a/Cargo.toml b/Cargo.toml index ead3e0f48eff0e..bd6b3e08459cd9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -395,7 +395,3 @@ opt-level = 3 opt-level = 3 [profile.release.package.zstd-sys] opt-level = 3 - -[patch.crates-io] -deno_npm = { path = "../deno_npm" } -eszip = { path = "../eszip" } diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 1d177cd326364f..b4bd5cdebc37e1 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -72,13 +72,13 @@ deno_emit = "=0.44.0" deno_graph = { version = "=0.81.3" } deno_lint = { version = "=0.63.1", features = ["docs"] } deno_lockfile.workspace = true -deno_npm = "=0.24.0" +deno_npm = "=0.25.0" deno_package_json.workspace = true deno_runtime = { workspace = true, features = ["include_js_files_for_snapshotting"] } deno_semver.workspace = true deno_task_shell = "=0.17.0" deno_terminal.workspace = true -eszip = "=0.76.0" +eszip = "=0.77.0" libsui = "0.3.0" napi_sym.workspace = true node_resolver.workspace = true From 01811ea12608123ef3dff370f2e0813af7adde93 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Tue, 27 Aug 2024 22:30:15 -0400 Subject: [PATCH 3/5] lint --- cli/graph_util.rs | 4 ++-- cli/module_loader.rs | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/cli/graph_util.rs b/cli/graph_util.rs index 82dc231986c0d2..f3d9cac33558eb 100644 --- a/cli/graph_util.rs +++ b/cli/graph_util.rs @@ -560,7 +560,7 @@ impl ModuleGraphBuilder { for (req_dep, value) in &lockfile.content.packages.specifiers { match req_dep.kind { deno_semver::package::PackageKind::Jsr => { - if let Ok(version) = Version::parse_standard(&value) { + if let Ok(version) = Version::parse_standard(value) { graph.packages.add_nv( req_dep.req.clone(), PackageNv { @@ -617,7 +617,7 @@ impl ModuleGraphBuilder { // jsr packages if has_jsr_package_deps_changed { for (nv, deps) in graph.packages.packages_with_deps() { - lockfile.add_package_deps(&nv, deps.cloned()); + lockfile.add_package_deps(nv, deps.cloned()); } } } diff --git a/cli/module_loader.rs b/cli/module_loader.rs index acd3e886e2a4e8..3208d1365798c9 100644 --- a/cli/module_loader.rs +++ b/cli/module_loader.rs @@ -771,8 +771,7 @@ impl ModuleLoader lib, root_permissions, ) - .await - .inspect_err(|err| eprintln!("FOUND: {:?}", err))?; + .await?; update_permit.commit(); Ok(()) } From 05e6cf1f529483f8a7bb38448d64652242c27fc6 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Wed, 28 Aug 2024 11:27:33 -0400 Subject: [PATCH 4/5] fix some errors --- Cargo.lock | 5 +- cli/Cargo.toml | 2 +- cli/graph_util.rs | 54 +++++++++++++++++-- tests/integration/npm_tests.rs | 7 --- tests/integration/run_tests.rs | 30 ----------- .../dynamic_npm_resolution_failure/main.out | 8 +-- .../npm/invalid_package_name/__test__.jsonc | 5 ++ .../npm/invalid_package_name/main.js | 0 tests/specs/npm/invalid_package_name/main.out | 3 ++ .../package_json/invalid_value/__test__.jsonc | 21 ++++++++ .../run}/package_json/invalid_value/error.ts | 0 .../package_json/invalid_value/error.ts.out | 5 ++ .../run}/package_json/invalid_value/ok.ts | 0 .../run}/package_json/invalid_value/ok.ts.out | 0 .../package_json/invalid_value/package.json | 0 .../run/package_json/invalid_value/task.out | 5 ++ .../npm/invalid_package_name/main.out | 2 - .../package_json/invalid_value/error.ts.out | 4 -- .../package_json/invalid_value/task.out | 2 - 19 files changed, 98 insertions(+), 55 deletions(-) create mode 100644 tests/specs/npm/invalid_package_name/__test__.jsonc rename tests/{testdata => specs}/npm/invalid_package_name/main.js (100%) create mode 100644 tests/specs/npm/invalid_package_name/main.out create mode 100644 tests/specs/run/package_json/invalid_value/__test__.jsonc rename tests/{testdata => specs/run}/package_json/invalid_value/error.ts (100%) create mode 100644 tests/specs/run/package_json/invalid_value/error.ts.out rename tests/{testdata => specs/run}/package_json/invalid_value/ok.ts (100%) rename tests/{testdata => specs/run}/package_json/invalid_value/ok.ts.out (100%) rename tests/{testdata => specs/run}/package_json/invalid_value/package.json (100%) create mode 100644 tests/specs/run/package_json/invalid_value/task.out delete mode 100644 tests/testdata/npm/invalid_package_name/main.out delete mode 100644 tests/testdata/package_json/invalid_value/error.ts.out delete mode 100644 tests/testdata/package_json/invalid_value/task.out diff --git a/Cargo.lock b/Cargo.lock index 04a28e815db1e5..bd60eac053d869 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3787,15 +3787,16 @@ dependencies = [ [[package]] name = "import_map" -version = "0.20.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "373b8288ad259df0d1314e3e8b2fff0e5e63f22e01bc54ecd2c3c7ad77b9200c" +checksum = "351a787decc56f38d65d16d32687265045d6d6a4531b4a0e1b649def3590354e" dependencies = [ "indexmap", "log", "percent-encoding", "serde", "serde_json", + "thiserror", "url", ] diff --git a/cli/Cargo.toml b/cli/Cargo.toml index b4bd5cdebc37e1..616dae92e07f47 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -115,7 +115,7 @@ http.workspace = true http-body.workspace = true http-body-util.workspace = true hyper-util.workspace = true -import_map = { version = "=0.20.0", features = ["ext"] } +import_map = { version = "=0.20.1", features = ["ext"] } indexmap.workspace = true jsonc-parser.workspace = true jupyter_runtime = { package = "runtimelib", version = "=0.14.0" } diff --git a/cli/graph_util.rs b/cli/graph_util.rs index f3d9cac33558eb..c8432b67ee9200 100644 --- a/cli/graph_util.rs +++ b/cli/graph_util.rs @@ -49,6 +49,8 @@ use deno_semver::package::PackageNv; use deno_semver::Version; use import_map::ImportMapError; use std::collections::HashSet; +use std::error::Error; +use std::ops::Deref; use std::path::PathBuf; use std::sync::Arc; @@ -111,7 +113,7 @@ pub fn graph_valid( ModuleGraphError::ModuleError(error) => { enhanced_lockfile_error_message(error) .or_else(|| enhanced_sloppy_imports_error_message(fs, error)) - .unwrap_or_else(|| format!("{}", error)) + .unwrap_or_else(|| format_deno_graph_error(error)) } }; @@ -165,7 +167,10 @@ pub fn graph_valid( } else { // finally surface the npm resolution result if let Err(err) = &graph.npm_dep_graph_result { - return Err(custom_error(get_error_class_name(err), format!("{}", err))); + return Err(custom_error( + get_error_class_name(err), + format_deno_graph_error(err.as_ref().deref()), + )); } Ok(()) } @@ -731,7 +736,7 @@ pub fn error_for_any_npm_specifier( /// Adds more explanatory information to a resolution error. pub fn enhanced_resolution_error_message(error: &ResolutionError) -> String { - let mut message = format!("{error}"); + let mut message = format_deno_graph_error(error); if let Some(specifier) = get_resolution_error_bare_node_specifier(error) { if !*DENO_DISABLE_PEDANTIC_NODE_WARNINGS { @@ -1027,6 +1032,49 @@ impl deno_graph::source::JsrUrlProvider for CliJsrUrlProvider { } } +// todo(dsherret): We should change ModuleError to use thiserror so that +// we don't need to do this. +fn format_deno_graph_error(err: &dyn Error) -> String { + use std::fmt::Write; + + let mut message = format!("{}", err); + let mut maybe_source = err.source(); + + if maybe_source.is_some() { + let mut past_message = message.clone(); + let mut count = 0; + let mut display_count = 0; + while let Some(source) = maybe_source { + let current_message = format!("{}", source); + maybe_source = source.source(); + + // sometimes an error might be repeated due to + // being boxed multiple times in another AnyError + if current_message != past_message { + write!(message, "\n {}: ", display_count,).unwrap(); + for (i, line) in current_message.lines().enumerate() { + if i > 0 { + write!(message, "\n {}", line).unwrap(); + } else { + write!(message, "{}", line).unwrap(); + } + } + display_count += 1; + } + + if count > 8 { + write!(message, "\n {}: ...", count).unwrap(); + break; + } + + past_message = current_message; + count += 1; + } + } + + message +} + #[cfg(test)] mod test { use std::sync::Arc; diff --git a/tests/integration/npm_tests.rs b/tests/integration/npm_tests.rs index 2a29e8ab258a09..1ff7ef0d8fde88 100644 --- a/tests/integration/npm_tests.rs +++ b/tests/integration/npm_tests.rs @@ -272,13 +272,6 @@ itest!(nonexistent_file_node_modules_dir { exit_code: 1, }); -itest!(invalid_package_name { - args: "run -A --quiet npm/invalid_package_name/main.js", - output: "npm/invalid_package_name/main.out", - envs: env_vars_for_npm_tests(), - exit_code: 1, -}); - itest!(require_json { args: "run -A --quiet npm/require_json/main.js", output: "npm/require_json/main.out", diff --git a/tests/integration/run_tests.rs b/tests/integration/run_tests.rs index ef37d48751e989..64e9d1c22aacd0 100644 --- a/tests/integration/run_tests.rs +++ b/tests/integration/run_tests.rs @@ -3462,36 +3462,6 @@ fn package_json_with_deno_json() { assert_contains!(output, "Skipping top level install."); } -#[test] -fn package_json_error_dep_value_test() { - let context = TestContextBuilder::for_npm() - .use_copy_temp_dir("package_json/invalid_value") - .cwd("package_json/invalid_value") - .build(); - - // should run fine when not referencing a failing dep entry - context - .new_command() - .args("run ok.ts") - .run() - .assert_matches_file("package_json/invalid_value/ok.ts.out"); - - // should fail when referencing a failing dep entry - context - .new_command() - .args("run error.ts") - .run() - .assert_exit_code(1) - .assert_matches_file("package_json/invalid_value/error.ts.out"); - - // should output a warning about the failing dep entry - context - .new_command() - .args("task test") - .run() - .assert_matches_file("package_json/invalid_value/task.out"); -} - #[test] fn package_json_no_node_modules_dir_created() { // it should not create a node_modules directory diff --git a/tests/specs/npm/dynamic_npm_resolution_failure/main.out b/tests/specs/npm/dynamic_npm_resolution_failure/main.out index 756d9459d90ef3..a795f0233a73c2 100644 --- a/tests/specs/npm/dynamic_npm_resolution_failure/main.out +++ b/tests/specs/npm/dynamic_npm_resolution_failure/main.out @@ -5,10 +5,10 @@ Download http://localhost:4260/@denotest/dep-cannot-parse Download http://localhost:4260/chalk/chalk-5.0.1.tgz Hi TypeError: Error in @denotest/dep-cannot-parse@1.0.0 parsing version requirement for dependency: @denotest/esm-basic@unknown-scheme:unknown - -Invalid version requirement. Unexpected character. - unknown-scheme:unknown - ~ + 0: Invalid version requirement + 1: Unexpected character. + unknown-scheme:unknown + ~ at async file:///[WILDLINE]main.ts:5:3 { code: "ERR_MODULE_NOT_FOUND" } diff --git a/tests/specs/npm/invalid_package_name/__test__.jsonc b/tests/specs/npm/invalid_package_name/__test__.jsonc new file mode 100644 index 00000000000000..34db0174e55cd8 --- /dev/null +++ b/tests/specs/npm/invalid_package_name/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run -A main.js", + "output": "main.out", + "exitCode": 1 +} diff --git a/tests/testdata/npm/invalid_package_name/main.js b/tests/specs/npm/invalid_package_name/main.js similarity index 100% rename from tests/testdata/npm/invalid_package_name/main.js rename to tests/specs/npm/invalid_package_name/main.js diff --git a/tests/specs/npm/invalid_package_name/main.out b/tests/specs/npm/invalid_package_name/main.out new file mode 100644 index 00000000000000..09c989dea0fcd2 --- /dev/null +++ b/tests/specs/npm/invalid_package_name/main.out @@ -0,0 +1,3 @@ +error: Invalid package specifier 'npm:@foo' + 0: Did not contain a valid package name + at [WILDCARD]/invalid_package_name/main.js:1:22 diff --git a/tests/specs/run/package_json/invalid_value/__test__.jsonc b/tests/specs/run/package_json/invalid_value/__test__.jsonc new file mode 100644 index 00000000000000..c960dd3027c58f --- /dev/null +++ b/tests/specs/run/package_json/invalid_value/__test__.jsonc @@ -0,0 +1,21 @@ +{ + "tempDir": true, + "tests": { + // should run fine when not referencing a failing dep entry + "run_ok": { + "args": "run ok.ts", + "output": "ok.ts.out" + }, + // should fail when referencing a failing dep entry + "run_error": { + "args": "run error.ts", + "exitCode": 1, + "output": "error.ts.out" + }, + // should output a warning about the failing dep entry + "task_test": { + "args": "task test", + "output": "task.out" + } + } +} diff --git a/tests/testdata/package_json/invalid_value/error.ts b/tests/specs/run/package_json/invalid_value/error.ts similarity index 100% rename from tests/testdata/package_json/invalid_value/error.ts rename to tests/specs/run/package_json/invalid_value/error.ts diff --git a/tests/specs/run/package_json/invalid_value/error.ts.out b/tests/specs/run/package_json/invalid_value/error.ts.out new file mode 100644 index 00000000000000..37796d6da15cd4 --- /dev/null +++ b/tests/specs/run/package_json/invalid_value/error.ts.out @@ -0,0 +1,5 @@ +error: Invalid version requirement + 0: Unexpected character. + invalid stuff that won't parse + ~ + at file:///[WILDCARD]/error.ts:2:23 diff --git a/tests/testdata/package_json/invalid_value/ok.ts b/tests/specs/run/package_json/invalid_value/ok.ts similarity index 100% rename from tests/testdata/package_json/invalid_value/ok.ts rename to tests/specs/run/package_json/invalid_value/ok.ts diff --git a/tests/testdata/package_json/invalid_value/ok.ts.out b/tests/specs/run/package_json/invalid_value/ok.ts.out similarity index 100% rename from tests/testdata/package_json/invalid_value/ok.ts.out rename to tests/specs/run/package_json/invalid_value/ok.ts.out diff --git a/tests/testdata/package_json/invalid_value/package.json b/tests/specs/run/package_json/invalid_value/package.json similarity index 100% rename from tests/testdata/package_json/invalid_value/package.json rename to tests/specs/run/package_json/invalid_value/package.json diff --git a/tests/specs/run/package_json/invalid_value/task.out b/tests/specs/run/package_json/invalid_value/task.out new file mode 100644 index 00000000000000..d0adb052561671 --- /dev/null +++ b/tests/specs/run/package_json/invalid_value/task.out @@ -0,0 +1,5 @@ +Download http://localhost:4260/@denotest/esm-basic +Download http://localhost:4260/@denotest/esm-basic/1.0.0.tgz +Initialize @denotest/esm-basic@1.0.0 +Task test echo 1 +1 diff --git a/tests/testdata/npm/invalid_package_name/main.out b/tests/testdata/npm/invalid_package_name/main.out deleted file mode 100644 index b4a421bd7f5d87..00000000000000 --- a/tests/testdata/npm/invalid_package_name/main.out +++ /dev/null @@ -1,2 +0,0 @@ -error: Invalid package specifier 'npm:@foo'. Did not contain a valid package name. - at [WILDCARD]/invalid_package_name/main.js:1:22 diff --git a/tests/testdata/package_json/invalid_value/error.ts.out b/tests/testdata/package_json/invalid_value/error.ts.out deleted file mode 100644 index 80893ede0a8d8d..00000000000000 --- a/tests/testdata/package_json/invalid_value/error.ts.out +++ /dev/null @@ -1,4 +0,0 @@ -error: Invalid npm version requirement. Unexpected character. - invalid stuff that won't parse - ~ - at file:///[WILDCARD]/error.ts:2:23 diff --git a/tests/testdata/package_json/invalid_value/task.out b/tests/testdata/package_json/invalid_value/task.out deleted file mode 100644 index 79249d1757c382..00000000000000 --- a/tests/testdata/package_json/invalid_value/task.out +++ /dev/null @@ -1,2 +0,0 @@ -Task test echo 1 -1 From 07ef29f11cf193d95d922246288fd1a6dc0e45f0 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Wed, 28 Aug 2024 11:33:58 -0400 Subject: [PATCH 5/5] lint --- tools/lint.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/lint.js b/tools/lint.js index 8c2e0f5949bf16..5f97e3cb74a3e4 100755 --- a/tools/lint.js +++ b/tools/lint.js @@ -213,7 +213,7 @@ async function ensureNoNewITests() { "lsp_tests.rs": 0, "node_compat_tests.rs": 4, "node_unit_tests.rs": 2, - "npm_tests.rs": 93, + "npm_tests.rs": 92, "pm_tests.rs": 0, "publish_tests.rs": 0, "repl_tests.rs": 0,