fix(cli): Support deno.lock with only package.json present + fix DENO_FUTURE install interactions with lockfile (#23918)

Fixes #23571.

Previously, we required a `deno.json` to be present (or the `--lock`
flag) in order for us to resolve a `deno.lock` file. This meant that if
you were using deno in an npm-first project deno wouldn't use a
lockfile.

Additionally, while I was fixing that, I discovered there were a couple
bugs keeping the future `install` command from using a lockfile.

With this PR, `install` will actually resolve the lockfile (or create
one if not present), and update it if it's not up-to-date. This also
speeds up `deno install`, as we can use the lockfile to skip work during
npm resolution.
This commit is contained in:
Nathan Whitaker 2024-05-23 12:31:05 -07:00 committed by GitHub
parent 20dad295e2
commit 5de30c5323
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 184 additions and 22 deletions

View file

@ -852,8 +852,11 @@ impl CliOptions {
maybe_package_json = discover_package_json(&flags, None, &initial_cwd)?;
}
let maybe_lock_file =
lockfile::discover(&flags, maybe_config_file.as_ref())?;
let maybe_lock_file = lockfile::discover(
&flags,
maybe_config_file.as_ref(),
maybe_package_json.as_ref(),
)?;
Self::new(
flags,
initial_cwd,