Skip to content

Commit

Permalink
feat: lockfile v3 (denoland#20424)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed Sep 8, 2023
1 parent 9cac560 commit c521c5f
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 52 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ deno_runtime = { version = "0.126.0", path = "./runtime" }
napi_sym = { version = "0.48.0", path = "./cli/napi/sym" }
deno_bench_util = { version = "0.112.0", path = "./bench_util" }
test_util = { path = "./test_util" }
deno_lockfile = "0.16.2"
deno_lockfile = "0.17.1"
deno_media_type = { version = "0.1.1", features = ["module_specifier"] }
deno_npm = "0.13.0"
deno_npm = "0.14.0"
deno_semver = "0.4.0"

# exts
Expand Down
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ deno_npm.workspace = true
deno_runtime = { workspace = true, features = ["dont_create_runtime_snapshot", "exclude_runtime_main_js", "include_js_files_for_snapshotting"] }
deno_semver.workspace = true
deno_task_shell = "=0.13.2"
eszip = "=0.51.0"
eszip = "=0.52.0"
napi_sym.workspace = true

async-trait.workspace = true
Expand Down
17 changes: 10 additions & 7 deletions cli/npm/resolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,13 +369,16 @@ fn populate_lockfile_from_snapshot(
snapshot: &NpmResolutionSnapshot,
) -> Result<(), AnyError> {
for (package_req, nv) in snapshot.package_reqs() {
lockfile.insert_npm_specifier(
package_req.to_string(),
snapshot
.resolve_package_from_deno_module(nv)
.unwrap()
.id
.as_serialized(),
lockfile.insert_package_specifier(
format!("npm:{}", package_req),
format!(
"npm:{}",
snapshot
.resolve_package_from_deno_module(nv)
.unwrap()
.id
.as_serialized()
),
);
}
for package in snapshot.all_packages_for_every_system() {
Expand Down
12 changes: 6 additions & 6 deletions cli/tests/integration/check_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,9 @@ fn npm_module_check_then_error() {
lockfile.read_json::<deno_lockfile::LockfileContent>();

// make the specifier resolve to version 1
lockfile_content.npm.specifiers.insert(
"@denotest/breaking-change-between-versions".to_string(),
"@denotest/[email protected]".to_string(),
lockfile_content.packages.specifiers.insert(
"npm:@denotest/breaking-change-between-versions".to_string(),
"npm:@denotest/[email protected]".to_string(),
);
lockfile.write_json(&lockfile_content);
temp_dir.write(
Expand All @@ -385,9 +385,9 @@ 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.npm.specifiers.insert(
"@denotest/breaking-change-between-versions".to_string(),
"@denotest/[email protected]".to_string(),
lockfile_content.packages.specifiers.insert(
"npm:@denotest/breaking-change-between-versions".to_string(),
"npm:@denotest/[email protected]".to_string(),
);
lockfile.write_json(&lockfile_content);

Expand Down
26 changes: 13 additions & 13 deletions cli/tests/integration/npm_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,7 @@ fn lock_file_missing_top_level_package() {
"\n",
"Caused by:\n",
" 0: The lockfile is corrupt. You can recreate it with --lock-write\n",
" 1: Could not find referenced package '[email protected]' in the list of packages.\n"
" 1: Could not find '[email protected]' in the list of packages.\n"
)
);
}
Expand All @@ -1280,13 +1280,12 @@ fn lock_file_lock_write() {

// write a lock file with borked integrity
let lock_file_content = r#"{
"version": "2",
"remote": {},
"npm": {
"version": "3",
"packages": {
"specifiers": {
"[email protected]": "[email protected]"
"npm:[email protected]": "npm:[email protected]"
},
"packages": {
"npm": {
"[email protected]": {
"integrity": "sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw==",
"dependencies": {}
Expand Down Expand Up @@ -1472,7 +1471,8 @@ fn lock_file_lock_write() {
}
}
}
}
},
"remote": {}
}
"#;
temp_dir.write("deno.lock", lock_file_content);
Expand Down Expand Up @@ -1514,17 +1514,17 @@ fn auto_discover_lock_file() {

// write a lock file with borked integrity
let lock_file_content = r#"{
"version": "2",
"remote": {},
"npm": {
"specifiers": { "@denotest/bin": "@denotest/[email protected]" },
"packages": {
"version": "3",
"packages": {
"specifiers": { "npm:@denotest/bin": "npm:@denotest/[email protected]" },
"npm": {
"@denotest/[email protected]": {
"integrity": "sha512-foobar",
"dependencies": {}
}
}
}
},
"remote": {}
}"#;
temp_dir.write("deno.lock", lock_file_content);

Expand Down
39 changes: 23 additions & 16 deletions cli/tests/integration/run_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ fn lock_redirects() {
.run()
.skip_output_check();
let initial_lockfile_text = r#"{
"version": "2",
"version": "3",
"redirects": {
"https://localhost:4546/run/001_hello.js": "https://localhost:4545/run/001_hello.js"
},
Expand All @@ -1012,7 +1012,7 @@ fn lock_redirects() {

// now try changing where the redirect occurs in the lockfile
temp_dir.write("deno.lock", r#"{
"version": "2",
"version": "3",
"redirects": {
"https://localhost:4546/run/001_hello.js": "https://localhost:4545/echo.ts"
},
Expand Down Expand Up @@ -1044,24 +1044,24 @@ fn lock_redirects() {
util::assertions::assert_wildcard_match(
&temp_dir.read_to_string("deno.lock"),
r#"{
"version": "2",
"redirects": {
"https://localhost:4546/run/001_hello.js": "https://localhost:4545/echo.ts"
},
"remote": {
"https://localhost:4545/echo.ts": "829eb4d67015a695d70b2a33c78b631b29eea1dbac491a6bfcf394af2a2671c2",
"https://localhost:4545/run/001_hello.js": "c479db5ea26965387423ca438bb977d0b4788d5901efcef52f69871e4c1048c5"
},
"npm": {
"version": "3",
"packages": {
"specifiers": {
"@denotest/esm-basic": "@denotest/[email protected]"
"npm:@denotest/esm-basic": "npm:@denotest/[email protected]"
},
"packages": {
"npm": {
"@denotest/[email protected]": {
"integrity": "sha512-[WILDCARD]",
"dependencies": {}
}
}
},
"redirects": {
"https://localhost:4546/run/001_hello.js": "https://localhost:4545/echo.ts"
},
"remote": {
"https://localhost:4545/echo.ts": "829eb4d67015a695d70b2a33c78b631b29eea1dbac491a6bfcf394af2a2671c2",
"https://localhost:4545/run/001_hello.js": "c479db5ea26965387423ca438bb977d0b4788d5901efcef52f69871e4c1048c5"
}
}
"#,
Expand Down Expand Up @@ -4515,9 +4515,16 @@ fn permission_prompt_strips_ansi_codes_and_control_chars() {
console.write_line(
r#"Deno.permissions.request({ name: "env", variable: "\rDo you like ice cream? y/n" });"#
);
console.expect(
"┌ ⚠️ Deno requests env access to \"Do you like ice cream? y/n\".",
)
// will be uppercase on windows
let env_name = if cfg!(windows) {
"DO YOU LIKE ICE CREAM? Y/N"
} else {
"Do you like ice cream? y/n"
};
console.expect(format!(
"┌ ⚠️ Deno requests env access to \"{}\".",
env_name
))
});

util::with_pty(&["repl"], |mut console| {
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/testdata/lockfile/no_dts/deno.lock.out

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c521c5f

Please sign in to comment.