mirror of
https://github.com/denoland/deno.git
synced 2024-11-24 15:19:26 -05:00
fix(config): regression - should not discover npm workspace for nested deno.json not in workspace (#24559)
Closes #24554
This commit is contained in:
parent
1711158984
commit
9510a8b7d1
16 changed files with 81 additions and 29 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -1308,9 +1308,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "deno_config"
|
||||
version = "0.22.0"
|
||||
version = "0.22.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "866d351087e70f8db42d04a773b9a96444d2653ef4bb0fb104fe562b819a57c9"
|
||||
checksum = "83df0c14d89f4e6e7ff91bfea0b4d5a0a33b4385c517ff4d8b4236d9834561e3"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"deno_semver",
|
||||
|
|
|
@ -101,7 +101,7 @@ console_static_text = "=0.8.1"
|
|||
data-encoding = "2.3.3"
|
||||
data-url = "=0.3.0"
|
||||
deno_cache_dir = "=0.10.0"
|
||||
deno_config = { version = "=0.22.0", default-features = false }
|
||||
deno_config = { version = "=0.22.2", default-features = false }
|
||||
dlopen2 = "0.6.1"
|
||||
ecb = "=0.1.2"
|
||||
elliptic-curve = { version = "0.13.4", features = ["alloc", "arithmetic", "ecdh", "std", "pem"] }
|
||||
|
|
|
@ -2,13 +2,12 @@
|
|||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use deno_config::workspace::Workspace;
|
||||
use deno_core::anyhow::Context;
|
||||
use deno_core::error::AnyError;
|
||||
use deno_core::parking_lot::Mutex;
|
||||
use deno_core::parking_lot::MutexGuard;
|
||||
use deno_runtime::deno_node::PackageJson;
|
||||
|
||||
use crate::args::ConfigFile;
|
||||
use crate::cache;
|
||||
use crate::util::fs::atomic_write_file_with_retries;
|
||||
use crate::Flags;
|
||||
|
@ -92,8 +91,7 @@ impl CliLockfile {
|
|||
|
||||
pub fn discover(
|
||||
flags: &Flags,
|
||||
maybe_config_file: Option<&ConfigFile>,
|
||||
maybe_package_json: Option<&PackageJson>,
|
||||
workspace: &Workspace,
|
||||
) -> Result<Option<CliLockfile>, AnyError> {
|
||||
if flags.no_lock
|
||||
|| matches!(
|
||||
|
@ -109,23 +107,9 @@ impl CliLockfile {
|
|||
|
||||
let filename = match flags.lock {
|
||||
Some(ref lock) => PathBuf::from(lock),
|
||||
None => match maybe_config_file {
|
||||
Some(config_file) => {
|
||||
if config_file.specifier.scheme() == "file" {
|
||||
match config_file.resolve_lockfile_path()? {
|
||||
Some(path) => path,
|
||||
None => return Ok(None),
|
||||
}
|
||||
} else {
|
||||
return Ok(None);
|
||||
}
|
||||
}
|
||||
None => match maybe_package_json {
|
||||
Some(package_json) => {
|
||||
package_json.path.parent().unwrap().join("deno.lock")
|
||||
}
|
||||
None => return Ok(None),
|
||||
},
|
||||
None => match workspace.resolve_lockfile_path()? {
|
||||
Some(path) => path,
|
||||
None => return Ok(None),
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -902,11 +902,7 @@ impl CliOptions {
|
|||
}),
|
||||
)?;
|
||||
|
||||
let maybe_lock_file = CliLockfile::discover(
|
||||
&flags,
|
||||
root_folder.deno_json.as_deref(),
|
||||
root_folder.pkg_json.as_deref(),
|
||||
)?;
|
||||
let maybe_lock_file = CliLockfile::discover(&flags, &workspace)?;
|
||||
|
||||
log::debug!("Finished config loading.");
|
||||
|
||||
|
|
17
tests/specs/npm/workspace_sub_deno_json/__test__.jsonc
Normal file
17
tests/specs/npm/workspace_sub_deno_json/__test__.jsonc
Normal file
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"tempDir": true,
|
||||
"tests": {
|
||||
"member": {
|
||||
"args": "run --allow-read member/main.ts",
|
||||
"output": "member.out"
|
||||
},
|
||||
"member_with_deno_json": {
|
||||
"args": "run --allow-read member_with_deno_json/main.ts",
|
||||
"output": "member.out"
|
||||
},
|
||||
"non_member": {
|
||||
"args": "run --allow-read non_member/main.ts",
|
||||
"output": "non_member.out"
|
||||
}
|
||||
}
|
||||
}
|
6
tests/specs/npm/workspace_sub_deno_json/member.out
Normal file
6
tests/specs/npm/workspace_sub_deno_json/member.out
Normal file
|
@ -0,0 +1,6 @@
|
|||
Warning "nodeModulesDir" field can only be specified in the workspace root deno.json file.
|
||||
at file:///[WILDLINE]/member_with_deno_json/deno.jsonc
|
||||
Download http://localhost:4260/chalk
|
||||
Download http://localhost:4260/chalk/chalk-5.0.1.tgz
|
||||
Initialize chalk@5.0.1
|
||||
true
|
4
tests/specs/npm/workspace_sub_deno_json/member/main.ts
Normal file
4
tests/specs/npm/workspace_sub_deno_json/member/main.ts
Normal file
|
@ -0,0 +1,4 @@
|
|||
import chalk from "npm:chalk@5";
|
||||
|
||||
const stat = Deno.statSync(new URL("../node_modules", import.meta.url));
|
||||
console.log(chalk.green(stat.isDirectory));
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"name": "member",
|
||||
"version": "1.0.0"
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
// will cause a warning
|
||||
"nodeModulesDir": true
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
import chalk from "npm:chalk@5";
|
||||
|
||||
const stat = Deno.statSync(new URL("../node_modules", import.meta.url));
|
||||
console.log(chalk.green(stat.isDirectory));
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"name": "member-with-deno-json",
|
||||
"version": "1.0.0"
|
||||
}
|
4
tests/specs/npm/workspace_sub_deno_json/non_member.out
Normal file
4
tests/specs/npm/workspace_sub_deno_json/non_member.out
Normal file
|
@ -0,0 +1,4 @@
|
|||
Download http://localhost:4260/chalk
|
||||
Download http://localhost:4260/chalk/chalk-5.0.1.tgz
|
||||
Initialize chalk@5.0.1
|
||||
true
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"nodeModulesDir": true
|
||||
}
|
15
tests/specs/npm/workspace_sub_deno_json/non_member/deno.lock
Normal file
15
tests/specs/npm/workspace_sub_deno_json/non_member/deno.lock
Normal file
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"version": "3",
|
||||
"packages": {
|
||||
"specifiers": {
|
||||
"npm:chalk@5": "npm:chalk@5.0.1"
|
||||
},
|
||||
"npm": {
|
||||
"chalk@5.0.1": {
|
||||
"integrity": "sha512-Fo07WOYGqMfCWHOzSXOt2CxDbC6skS/jO9ynEcmpANMoPrD+W1r1K6Vx7iNm+AQmETU1Xr2t+n8nzkV9t6xh3w==",
|
||||
"dependencies": {}
|
||||
}
|
||||
}
|
||||
},
|
||||
"remote": {}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
import chalk from "npm:chalk@5";
|
||||
|
||||
const stat = Deno.statSync(new URL("node_modules", import.meta.url));
|
||||
console.log(chalk.green(stat.isDirectory));
|
3
tests/specs/npm/workspace_sub_deno_json/package.json
Normal file
3
tests/specs/npm/workspace_sub_deno_json/package.json
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"workspaces": ["./member", "./member_with_deno_json"]
|
||||
}
|
Loading…
Reference in a new issue