0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-02-07 23:06:50 -05:00

Merge remote-tracking branch 'upstream/main' into check-workspace-member-compiler-options

This commit is contained in:
Nayeem Rahman 2025-01-01 09:58:24 +00:00
commit 60de9fa6b1
1197 changed files with 5219 additions and 4838 deletions

View file

@ -13,7 +13,7 @@
}, },
"exec": { "exec": {
"commands": [{ "commands": [{
"command": "rustfmt --config imports_granularity=item", "command": "rustfmt --config imports_granularity=item --config group_imports=StdExternalCrate",
"exts": ["rs"] "exts": ["rs"]
}] }]
}, },

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
// This file contains the implementation of a Github Action. Github uses // This file contains the implementation of a Github Action. Github uses
// Node.js v20.x to run actions, so this is Node code and not Deno code. // Node.js v20.x to run actions, so this is Node code and not Deno code.

View file

@ -1,5 +1,5 @@
#!/usr/bin/env -S deno run --allow-write=. --lock=./tools/deno.lock.json #!/usr/bin/env -S deno run --allow-write=. --lock=./tools/deno.lock.json
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
import { stringify } from "jsr:@std/yaml@^0.221/stringify"; import { stringify } from "jsr:@std/yaml@^0.221/stringify";
// Bump this number when you want to purge the cache. // Bump this number when you want to purge the cache.
@ -716,6 +716,19 @@ const ci = {
"df -h", "df -h",
].join("\n"), ].join("\n"),
}, },
{
name: "Build denort release",
if: [
"matrix.job == 'test' &&",
"matrix.profile == 'release' &&",
"github.repository == 'denoland/deno'",
].join("\n"),
run: [
"df -h",
"cargo build --profile=release-slim --locked --bin denort",
"df -h",
].join("\n"),
},
{ {
// Run a minimal check to ensure that binary is not corrupted, regardless // Run a minimal check to ensure that binary is not corrupted, regardless
// of our build mode // of our build mode
@ -762,10 +775,11 @@ const ci = {
"cd target/release", "cd target/release",
"zip -r deno-${{ matrix.arch }}-unknown-linux-gnu.zip deno", "zip -r deno-${{ matrix.arch }}-unknown-linux-gnu.zip deno",
"shasum -a 256 deno-${{ matrix.arch }}-unknown-linux-gnu.zip > deno-${{ matrix.arch }}-unknown-linux-gnu.zip.sha256sum", "shasum -a 256 deno-${{ matrix.arch }}-unknown-linux-gnu.zip > deno-${{ matrix.arch }}-unknown-linux-gnu.zip.sha256sum",
"strip denort",
"zip -r denort-${{ matrix.arch }}-unknown-linux-gnu.zip denort",
"shasum -a 256 denort-${{ matrix.arch }}-unknown-linux-gnu.zip > denort-${{ matrix.arch }}-unknown-linux-gnu.zip.sha256sum",
"./deno types > lib.deno.d.ts", "./deno types > lib.deno.d.ts",
"cd ../release-slim",
"zip -r ../release/denort-${{ matrix.arch }}-unknown-linux-gnu.zip denort",
"cd ../release",
"shasum -a 256 denort-${{ matrix.arch }}-unknown-linux-gnu.zip > denort-${{ matrix.arch }}-unknown-linux-gnu.zip.sha256sum",
].join("\n"), ].join("\n"),
}, },
{ {
@ -790,8 +804,9 @@ const ci = {
"cd target/release", "cd target/release",
"zip -r deno-${{ matrix.arch }}-apple-darwin.zip deno", "zip -r deno-${{ matrix.arch }}-apple-darwin.zip deno",
"shasum -a 256 deno-${{ matrix.arch }}-apple-darwin.zip > deno-${{ matrix.arch }}-apple-darwin.zip.sha256sum", "shasum -a 256 deno-${{ matrix.arch }}-apple-darwin.zip > deno-${{ matrix.arch }}-apple-darwin.zip.sha256sum",
"strip denort", "cd ../release-slim",
"zip -r denort-${{ matrix.arch }}-apple-darwin.zip denort", "zip -r ../release/denort-${{ matrix.arch }}-apple-darwin.zip denort",
"cd ../release",
"shasum -a 256 denort-${{ matrix.arch }}-apple-darwin.zip > denort-${{ matrix.arch }}-apple-darwin.zip.sha256sum", "shasum -a 256 denort-${{ matrix.arch }}-apple-darwin.zip > denort-${{ matrix.arch }}-apple-darwin.zip.sha256sum",
] ]
.join("\n"), .join("\n"),
@ -808,7 +823,8 @@ const ci = {
run: [ run: [
"Compress-Archive -CompressionLevel Optimal -Force -Path target/release/deno.exe -DestinationPath target/release/deno-${{ matrix.arch }}-pc-windows-msvc.zip", "Compress-Archive -CompressionLevel Optimal -Force -Path target/release/deno.exe -DestinationPath target/release/deno-${{ matrix.arch }}-pc-windows-msvc.zip",
"Get-FileHash target/release/deno-${{ matrix.arch }}-pc-windows-msvc.zip -Algorithm SHA256 | Format-List > target/release/deno-${{ matrix.arch }}-pc-windows-msvc.zip.sha256sum", "Get-FileHash target/release/deno-${{ matrix.arch }}-pc-windows-msvc.zip -Algorithm SHA256 | Format-List > target/release/deno-${{ matrix.arch }}-pc-windows-msvc.zip.sha256sum",
"Compress-Archive -CompressionLevel Optimal -Force -Path target/release/denort.exe -DestinationPath target/release/denort-${{ matrix.arch }}-pc-windows-msvc.zip",
"Compress-Archive -CompressionLevel Optimal -Force -Path target/release-slim/denort.exe -DestinationPath target/release/denort-${{ matrix.arch }}-pc-windows-msvc.zip",
"Get-FileHash target/release/denort-${{ matrix.arch }}-pc-windows-msvc.zip -Algorithm SHA256 | Format-List > target/release/denort-${{ matrix.arch }}-pc-windows-msvc.zip.sha256sum", "Get-FileHash target/release/denort-${{ matrix.arch }}-pc-windows-msvc.zip -Algorithm SHA256 | Format-List > target/release/denort-${{ matrix.arch }}-pc-windows-msvc.zip.sha256sum",
].join("\n"), ].join("\n"),
}, },

View file

@ -419,6 +419,15 @@ jobs:
df -h df -h
cargo build --release --locked --all-targets cargo build --release --locked --all-targets
df -h df -h
- name: Build denort release
if: |-
!(matrix.skip) && (matrix.job == 'test' &&
matrix.profile == 'release' &&
github.repository == 'denoland/deno')
run: |-
df -h
cargo build --profile=release-slim --locked --bin denort
df -h
- name: Check deno binary - name: Check deno binary
if: '!(matrix.skip) && (matrix.job == ''test'')' if: '!(matrix.skip) && (matrix.job == ''test'')'
run: 'target/${{ matrix.profile }}/deno eval "console.log(1+2)" | grep 3' run: 'target/${{ matrix.profile }}/deno eval "console.log(1+2)" | grep 3'
@ -448,10 +457,11 @@ jobs:
cd target/release cd target/release
zip -r deno-${{ matrix.arch }}-unknown-linux-gnu.zip deno zip -r deno-${{ matrix.arch }}-unknown-linux-gnu.zip deno
shasum -a 256 deno-${{ matrix.arch }}-unknown-linux-gnu.zip > deno-${{ matrix.arch }}-unknown-linux-gnu.zip.sha256sum shasum -a 256 deno-${{ matrix.arch }}-unknown-linux-gnu.zip > deno-${{ matrix.arch }}-unknown-linux-gnu.zip.sha256sum
strip denort
zip -r denort-${{ matrix.arch }}-unknown-linux-gnu.zip denort
shasum -a 256 denort-${{ matrix.arch }}-unknown-linux-gnu.zip > denort-${{ matrix.arch }}-unknown-linux-gnu.zip.sha256sum
./deno types > lib.deno.d.ts ./deno types > lib.deno.d.ts
cd ../release-slim
zip -r ../release/denort-${{ matrix.arch }}-unknown-linux-gnu.zip denort
cd ../release
shasum -a 256 denort-${{ matrix.arch }}-unknown-linux-gnu.zip > denort-${{ matrix.arch }}-unknown-linux-gnu.zip.sha256sum
- name: Pre-release (mac) - name: Pre-release (mac)
if: |- if: |-
!(matrix.skip) && (matrix.os == 'macos' && !(matrix.skip) && (matrix.os == 'macos' &&
@ -467,8 +477,9 @@ jobs:
cd target/release cd target/release
zip -r deno-${{ matrix.arch }}-apple-darwin.zip deno zip -r deno-${{ matrix.arch }}-apple-darwin.zip deno
shasum -a 256 deno-${{ matrix.arch }}-apple-darwin.zip > deno-${{ matrix.arch }}-apple-darwin.zip.sha256sum shasum -a 256 deno-${{ matrix.arch }}-apple-darwin.zip > deno-${{ matrix.arch }}-apple-darwin.zip.sha256sum
strip denort cd ../release-slim
zip -r denort-${{ matrix.arch }}-apple-darwin.zip denort zip -r ../release/denort-${{ matrix.arch }}-apple-darwin.zip denort
cd ../release
shasum -a 256 denort-${{ matrix.arch }}-apple-darwin.zip > denort-${{ matrix.arch }}-apple-darwin.zip.sha256sum shasum -a 256 denort-${{ matrix.arch }}-apple-darwin.zip > denort-${{ matrix.arch }}-apple-darwin.zip.sha256sum
- name: Pre-release (windows) - name: Pre-release (windows)
if: |- if: |-
@ -480,7 +491,7 @@ jobs:
run: |- run: |-
Compress-Archive -CompressionLevel Optimal -Force -Path target/release/deno.exe -DestinationPath target/release/deno-${{ matrix.arch }}-pc-windows-msvc.zip Compress-Archive -CompressionLevel Optimal -Force -Path target/release/deno.exe -DestinationPath target/release/deno-${{ matrix.arch }}-pc-windows-msvc.zip
Get-FileHash target/release/deno-${{ matrix.arch }}-pc-windows-msvc.zip -Algorithm SHA256 | Format-List > target/release/deno-${{ matrix.arch }}-pc-windows-msvc.zip.sha256sum Get-FileHash target/release/deno-${{ matrix.arch }}-pc-windows-msvc.zip -Algorithm SHA256 | Format-List > target/release/deno-${{ matrix.arch }}-pc-windows-msvc.zip.sha256sum
Compress-Archive -CompressionLevel Optimal -Force -Path target/release/denort.exe -DestinationPath target/release/denort-${{ matrix.arch }}-pc-windows-msvc.zip Compress-Archive -CompressionLevel Optimal -Force -Path target/release-slim/denort.exe -DestinationPath target/release/denort-${{ matrix.arch }}-pc-windows-msvc.zip
Get-FileHash target/release/denort-${{ matrix.arch }}-pc-windows-msvc.zip -Algorithm SHA256 | Format-List > target/release/denort-${{ matrix.arch }}-pc-windows-msvc.zip.sha256sum Get-FileHash target/release/denort-${{ matrix.arch }}-pc-windows-msvc.zip -Algorithm SHA256 | Format-List > target/release/denort-${{ matrix.arch }}-pc-windows-msvc.zip.sha256sum
- name: Upload canary to dl.deno.land - name: Upload canary to dl.deno.land
if: |- if: |-

10
Cargo.lock generated
View file

@ -1736,14 +1736,12 @@ dependencies = [
"deno_path_util 0.3.0", "deno_path_util 0.3.0",
"deno_permissions", "deno_permissions",
"filetime", "filetime",
"getrandom",
"junction", "junction",
"libc", "libc",
"nix", "nix",
"rand", "rand",
"rayon", "rayon",
"serde", "serde",
"sys_traits",
"thiserror 2.0.3", "thiserror 2.0.3",
"winapi", "winapi",
"windows-sys 0.59.0", "windows-sys 0.59.0",
@ -2041,6 +2039,7 @@ dependencies = [
"sm3", "sm3",
"spki", "spki",
"stable_deref_trait", "stable_deref_trait",
"sys_traits",
"thiserror 2.0.3", "thiserror 2.0.3",
"tokio", "tokio",
"tokio-eld", "tokio-eld",
@ -2260,6 +2259,7 @@ dependencies = [
"serde", "serde",
"signal-hook", "signal-hook",
"signal-hook-registry", "signal-hook-registry",
"sys_traits",
"tempfile", "tempfile",
"test_server", "test_server",
"thiserror 2.0.3", "thiserror 2.0.3",
@ -7679,12 +7679,14 @@ dependencies = [
[[package]] [[package]]
name = "sys_traits" name = "sys_traits"
version = "0.1.1" version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5a12729b699487bb50163466e87be7197871d83d04cc6815d430cf7c893bbd7" checksum = "6683465f4e1d8fd75069cbc36c646258c05b7d8d6676bcb5d71968b99b7d5ae2"
dependencies = [ dependencies = [
"filetime",
"getrandom", "getrandom",
"libc", "libc",
"parking_lot",
"windows-sys 0.59.0", "windows-sys 0.59.0",
] ]

View file

@ -1,4 +1,4 @@
# Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. # Copyright 2018-2025 the Deno authors. MIT license.
[workspace] [workspace]
resolver = "2" resolver = "2"
@ -194,7 +194,7 @@ slab = "0.4"
smallvec = "1.8" smallvec = "1.8"
socket2 = { version = "0.5.3", features = ["all"] } socket2 = { version = "0.5.3", features = ["all"] }
spki = "0.7.2" spki = "0.7.2"
sys_traits = "=0.1.1" sys_traits = "=0.1.4"
tar = "=0.4.40" tar = "=0.4.40"
tempfile = "3.4.0" tempfile = "3.4.0"
termcolor = "1.1.3" termcolor = "1.1.3"
@ -252,6 +252,11 @@ incremental = true
lto = true lto = true
opt-level = 'z' # Optimize for size opt-level = 'z' # Optimize for size
[profile.release-slim]
inherits = "release"
panic = "abort"
strip = "symbols"
# Build release with debug symbols: cargo build --profile=release-with-debug # Build release with debug symbols: cargo build --profile=release-with-debug
[profile.release-with-debug] [profile.release-with-debug]
inherits = "release" inherits = "release"

View file

@ -1,6 +1,6 @@
MIT License MIT License
Copyright 2018-2024 the Deno authors Copyright 2018-2025 the Deno authors
Permission is hereby granted, free of charge, to any person obtaining a copy of Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in this software and associated documentation files (the "Software"), to deal in

View file

@ -1,4 +1,4 @@
# Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. # Copyright 2018-2025 the Deno authors. MIT license.
[package] [package]
name = "deno_bench_util" name = "deno_bench_util"

View file

@ -7,7 +7,6 @@ use deno_bench_util::bench_js_sync;
use deno_bench_util::bench_or_profile; use deno_bench_util::bench_or_profile;
use deno_bench_util::bencher::benchmark_group; use deno_bench_util::bencher::benchmark_group;
use deno_bench_util::bencher::Bencher; use deno_bench_util::bencher::Bencher;
use deno_core::Extension; use deno_core::Extension;
#[op2] #[op2]

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use deno_bench_util::bench_js_sync_with; use deno_bench_util::bench_js_sync_with;
use deno_bench_util::bench_or_profile; use deno_bench_util::bench_or_profile;

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use bencher::Bencher; use bencher::Bencher;
use deno_core::v8; use deno_core::v8;
use deno_core::Extension; use deno_core::Extension;

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
mod js_runtime; mod js_runtime;
mod profiling; mod profiling;

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use bencher::DynBenchFn; use bencher::DynBenchFn;
use bencher::StaticBenchFn; use bencher::StaticBenchFn;
use bencher::TestDescAndFn; use bencher::TestDescAndFn;

View file

@ -1,4 +1,4 @@
# Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. # Copyright 2018-2025 the Deno authors. MIT license.
[package] [package]
name = "deno" name = "deno"
@ -158,7 +158,7 @@ shell-escape = "=0.1.5"
spki = { version = "0.7", features = ["pem"] } spki = { version = "0.7", features = ["pem"] }
sqlformat = "=0.3.2" sqlformat = "=0.3.2"
strsim = "0.11.1" strsim = "0.11.1"
sys_traits = { workspace = true, features = ["libc", "real", "winapi"] } sys_traits = { workspace = true, features = ["getrandom", "filetime", "libc", "real", "strip_unc", "winapi"] }
tar.workspace = true tar.workspace = true
tempfile.workspace = true tempfile.workspace = true
text-size = "=1.1.0" text-size = "=1.1.0"
@ -187,6 +187,7 @@ nix.workspace = true
[dev-dependencies] [dev-dependencies]
deno_bench_util.workspace = true deno_bench_util.workspace = true
pretty_assertions.workspace = true pretty_assertions.workspace = true
sys_traits = { workspace = true, features = ["memory"] }
test_util.workspace = true test_util.workspace = true
[package.metadata.winres] [package.metadata.winres]

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use std::collections::HashSet; use std::collections::HashSet;

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use std::borrow::Cow; use std::borrow::Cow;
use std::collections::HashSet; use std::collections::HashSet;
@ -43,11 +43,10 @@ use log::Level;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use crate::args::resolve_no_prompt;
use crate::util::fs::canonicalize_path;
use super::flags_net; use super::flags_net;
use super::jsr_url; use super::jsr_url;
use crate::args::resolve_no_prompt;
use crate::util::fs::canonicalize_path;
#[derive(Clone, Debug, Default, Eq, PartialEq)] #[derive(Clone, Debug, Default, Eq, PartialEq)]
pub enum ConfigFlag { pub enum ConfigFlag {
@ -6067,9 +6066,10 @@ pub fn resolve_urls(urls: Vec<String>) -> Vec<String> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use super::*;
/// Creates vector of strings, Vec<String> /// Creates vector of strings, Vec<String>
macro_rules! svec { macro_rules! svec {
($($x:expr),* $(,)?) => (vec![$($x.to_string().into()),*]); ($($x:expr),* $(,)?) => (vec![$($x.to_string().into()),*]);

View file

@ -1,9 +1,10 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use std::net::IpAddr;
use std::str::FromStr;
use deno_core::url::Url; use deno_core::url::Url;
use deno_runtime::deno_permissions::NetDescriptor; use deno_runtime::deno_permissions::NetDescriptor;
use std::net::IpAddr;
use std::str::FromStr;
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
pub struct ParsePortError(String); pub struct ParsePortError(String);

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use deno_core::error::AnyError; use deno_core::error::AnyError;
use deno_core::serde_json; use deno_core::serde_json;

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use std::collections::HashSet; use std::collections::HashSet;
use std::path::PathBuf; use std::path::PathBuf;
@ -10,21 +10,19 @@ use deno_core::error::AnyError;
use deno_core::parking_lot::Mutex; use deno_core::parking_lot::Mutex;
use deno_core::parking_lot::MutexGuard; use deno_core::parking_lot::MutexGuard;
use deno_core::serde_json; use deno_core::serde_json;
use deno_lockfile::Lockfile;
use deno_lockfile::WorkspaceMemberConfig; use deno_lockfile::WorkspaceMemberConfig;
use deno_package_json::PackageJsonDepValue; use deno_package_json::PackageJsonDepValue;
use deno_path_util::fs::atomic_write_file_with_retries; use deno_path_util::fs::atomic_write_file_with_retries;
use deno_runtime::deno_fs::FsSysTraitsAdapter;
use deno_runtime::deno_node::PackageJson; use deno_runtime::deno_node::PackageJson;
use deno_semver::jsr::JsrDepPackageReq; use deno_semver::jsr::JsrDepPackageReq;
use crate::args::deno_json::import_map_deps; use crate::args::deno_json::import_map_deps;
use crate::cache;
use crate::Flags;
use crate::args::DenoSubcommand; use crate::args::DenoSubcommand;
use crate::args::InstallFlags; use crate::args::InstallFlags;
use crate::cache;
use deno_lockfile::Lockfile; use crate::sys::CliSys;
use crate::Flags;
#[derive(Debug)] #[derive(Debug)]
pub struct CliLockfileReadFromPathOptions { pub struct CliLockfileReadFromPathOptions {
@ -36,6 +34,7 @@ pub struct CliLockfileReadFromPathOptions {
#[derive(Debug)] #[derive(Debug)]
pub struct CliLockfile { pub struct CliLockfile {
sys: CliSys,
lockfile: Mutex<Lockfile>, lockfile: Mutex<Lockfile>,
pub filename: PathBuf, pub filename: PathBuf,
frozen: bool, frozen: bool,
@ -92,7 +91,7 @@ impl CliLockfile {
// do an atomic write to reduce the chance of multiple deno // do an atomic write to reduce the chance of multiple deno
// processes corrupting the file // processes corrupting the file
atomic_write_file_with_retries( atomic_write_file_with_retries(
&FsSysTraitsAdapter::new_real(), &self.sys,
&lockfile.filename, &lockfile.filename,
&bytes, &bytes,
cache::CACHE_PERM, cache::CACHE_PERM,
@ -103,6 +102,7 @@ impl CliLockfile {
} }
pub fn discover( pub fn discover(
sys: &CliSys,
flags: &Flags, flags: &Flags,
workspace: &Workspace, workspace: &Workspace,
maybe_external_import_map: Option<&serde_json::Value>, maybe_external_import_map: Option<&serde_json::Value>,
@ -165,11 +165,14 @@ impl CliLockfile {
.unwrap_or(false) .unwrap_or(false)
}); });
let lockfile = Self::read_from_path(CliLockfileReadFromPathOptions { let lockfile = Self::read_from_path(
file_path, sys,
frozen, CliLockfileReadFromPathOptions {
skip_write: flags.internal.lockfile_skip_write, file_path,
})?; frozen,
skip_write: flags.internal.lockfile_skip_write,
},
)?;
// initialize the lockfile with the workspace's configuration // initialize the lockfile with the workspace's configuration
let root_url = workspace.root_dir(); let root_url = workspace.root_dir();
@ -225,6 +228,7 @@ impl CliLockfile {
} }
pub fn read_from_path( pub fn read_from_path(
sys: &CliSys,
opts: CliLockfileReadFromPathOptions, opts: CliLockfileReadFromPathOptions,
) -> Result<CliLockfile, AnyError> { ) -> Result<CliLockfile, AnyError> {
let lockfile = match std::fs::read_to_string(&opts.file_path) { let lockfile = match std::fs::read_to_string(&opts.file_path) {
@ -243,6 +247,7 @@ impl CliLockfile {
} }
}; };
Ok(CliLockfile { Ok(CliLockfile {
sys: sys.clone(),
filename: lockfile.filename.clone(), filename: lockfile.filename.clone(),
lockfile: Mutex::new(lockfile), lockfile: Mutex::new(lockfile),
frozen: opts.frozen, frozen: opts.frozen,

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
pub mod deno_json; pub mod deno_json;
mod flags; mod flags;
@ -7,71 +7,6 @@ mod import_map;
mod lockfile; mod lockfile;
mod package_json; mod package_json;
use deno_ast::MediaType;
use deno_ast::SourceMapOption;
use deno_cache_dir::file_fetcher::CacheSetting;
use deno_config::deno_json::NodeModulesDirMode;
use deno_config::workspace::CreateResolverOptions;
use deno_config::workspace::FolderConfigs;
use deno_config::workspace::PackageJsonDepResolution;
use deno_config::workspace::VendorEnablement;
use deno_config::workspace::Workspace;
use deno_config::workspace::WorkspaceDirectory;
use deno_config::workspace::WorkspaceDirectoryEmptyOptions;
use deno_config::workspace::WorkspaceDiscoverOptions;
use deno_config::workspace::WorkspaceDiscoverStart;
use deno_config::workspace::WorkspaceLintConfig;
use deno_config::workspace::WorkspaceResolver;
use deno_core::resolve_url_or_path;
use deno_graph::GraphKind;
use deno_lint::linter::LintConfig as DenoLintConfig;
use deno_npm::npm_rc::NpmRc;
use deno_npm::npm_rc::ResolvedNpmRc;
use deno_npm::resolution::ValidSerializedNpmResolutionSnapshot;
use deno_npm::NpmSystemInfo;
use deno_path_util::normalize_path;
use deno_runtime::deno_fs::FsSysTraitsAdapter;
use deno_semver::npm::NpmPackageReqReference;
use deno_semver::StackString;
use deno_telemetry::OtelConfig;
use deno_telemetry::OtelRuntimeConfig;
use import_map::resolve_import_map_value_from_specifier;
pub use deno_config::deno_json::BenchConfig;
pub use deno_config::deno_json::ConfigFile;
pub use deno_config::deno_json::FmtOptionsConfig;
pub use deno_config::deno_json::LintRulesConfig;
pub use deno_config::deno_json::ProseWrap;
pub use deno_config::deno_json::TsConfig;
pub use deno_config::deno_json::TsConfigForEmit;
pub use deno_config::deno_json::TsConfigType;
pub use deno_config::deno_json::TsTypeLib;
pub use deno_config::glob::FilePatterns;
pub use deno_json::check_warn_tsconfig;
pub use flags::*;
pub use lockfile::CliLockfile;
pub use lockfile::CliLockfileReadFromPathOptions;
pub use package_json::NpmInstallDepsProvider;
pub use package_json::PackageJsonDepValueParseWithLocationError;
use deno_ast::ModuleSpecifier;
use deno_core::anyhow::bail;
use deno_core::anyhow::Context;
use deno_core::error::AnyError;
use deno_core::serde_json;
use deno_core::url::Url;
use deno_runtime::deno_permissions::PermissionsOptions;
use deno_runtime::deno_tls::deno_native_certs::load_native_certs;
use deno_runtime::deno_tls::rustls;
use deno_runtime::deno_tls::rustls::RootCertStore;
use deno_runtime::deno_tls::rustls_pemfile;
use deno_runtime::deno_tls::webpki_roots;
use deno_runtime::inspector_server::InspectorServer;
use deno_terminal::colors;
use dotenvy::from_filename;
use once_cell::sync::Lazy;
use serde::Deserialize;
use serde::Serialize;
use std::borrow::Cow; use std::borrow::Cow;
use std::collections::BTreeSet; use std::collections::BTreeSet;
use std::collections::HashMap; use std::collections::HashMap;
@ -84,18 +19,81 @@ use std::net::SocketAddr;
use std::path::Path; use std::path::Path;
use std::path::PathBuf; use std::path::PathBuf;
use std::sync::Arc; use std::sync::Arc;
use deno_ast::MediaType;
use deno_ast::ModuleSpecifier;
use deno_ast::SourceMapOption;
use deno_cache_dir::file_fetcher::CacheSetting;
pub use deno_config::deno_json::BenchConfig;
pub use deno_config::deno_json::ConfigFile;
use deno_config::deno_json::FmtConfig;
pub use deno_config::deno_json::FmtOptionsConfig;
use deno_config::deno_json::LintConfig;
pub use deno_config::deno_json::LintRulesConfig;
use deno_config::deno_json::NodeModulesDirMode;
pub use deno_config::deno_json::ProseWrap;
use deno_config::deno_json::TestConfig;
pub use deno_config::deno_json::TsConfig;
pub use deno_config::deno_json::TsConfigForEmit;
pub use deno_config::deno_json::TsConfigType;
pub use deno_config::deno_json::TsTypeLib;
pub use deno_config::glob::FilePatterns;
use deno_config::workspace::CreateResolverOptions;
use deno_config::workspace::FolderConfigs;
use deno_config::workspace::PackageJsonDepResolution;
use deno_config::workspace::VendorEnablement;
use deno_config::workspace::Workspace;
use deno_config::workspace::WorkspaceDirectory;
use deno_config::workspace::WorkspaceDirectoryEmptyOptions;
use deno_config::workspace::WorkspaceDiscoverOptions;
use deno_config::workspace::WorkspaceDiscoverStart;
use deno_config::workspace::WorkspaceLintConfig;
use deno_config::workspace::WorkspaceResolver;
use deno_core::anyhow::bail;
use deno_core::anyhow::Context;
use deno_core::error::AnyError;
use deno_core::resolve_url_or_path;
use deno_core::serde_json;
use deno_core::url::Url;
use deno_graph::GraphKind;
pub use deno_json::check_warn_tsconfig;
use deno_lint::linter::LintConfig as DenoLintConfig;
use deno_npm::npm_rc::NpmRc;
use deno_npm::npm_rc::ResolvedNpmRc;
use deno_npm::resolution::ValidSerializedNpmResolutionSnapshot;
use deno_npm::NpmSystemInfo;
use deno_path_util::normalize_path;
use deno_runtime::deno_permissions::PermissionsOptions;
use deno_runtime::deno_tls::deno_native_certs::load_native_certs;
use deno_runtime::deno_tls::rustls;
use deno_runtime::deno_tls::rustls::RootCertStore;
use deno_runtime::deno_tls::rustls_pemfile;
use deno_runtime::deno_tls::webpki_roots;
use deno_runtime::inspector_server::InspectorServer;
use deno_semver::npm::NpmPackageReqReference;
use deno_semver::StackString;
use deno_telemetry::OtelConfig;
use deno_telemetry::OtelRuntimeConfig;
use deno_terminal::colors;
use dotenvy::from_filename;
pub use flags::*;
use import_map::resolve_import_map_value_from_specifier;
pub use lockfile::CliLockfile;
pub use lockfile::CliLockfileReadFromPathOptions;
use once_cell::sync::Lazy;
pub use package_json::NpmInstallDepsProvider;
pub use package_json::PackageJsonDepValueParseWithLocationError;
use serde::Deserialize;
use serde::Serialize;
use sys_traits::EnvHomeDir; use sys_traits::EnvHomeDir;
use thiserror::Error; use thiserror::Error;
use crate::cache::DenoDirProvider; use crate::cache::DenoDirProvider;
use crate::file_fetcher::CliFileFetcher; use crate::file_fetcher::CliFileFetcher;
use crate::sys::CliSys;
use crate::util::fs::canonicalize_path_maybe_not_exists; use crate::util::fs::canonicalize_path_maybe_not_exists;
use crate::version; use crate::version;
use deno_config::deno_json::FmtConfig;
use deno_config::deno_json::LintConfig;
use deno_config::deno_json::TestConfig;
pub fn npm_registry_url() -> &'static Url { pub fn npm_registry_url() -> &'static Url {
static NPM_REGISTRY_DEFAULT_URL: Lazy<Url> = Lazy::new(|| { static NPM_REGISTRY_DEFAULT_URL: Lazy<Url> = Lazy::new(|| {
let env_var_name = "NPM_CONFIG_REGISTRY"; let env_var_name = "NPM_CONFIG_REGISTRY";
@ -522,7 +520,7 @@ fn discover_npmrc(
// TODO(bartlomieju): update to read both files - one in the project root and one and // TODO(bartlomieju): update to read both files - one in the project root and one and
// home dir and then merge them. // home dir and then merge them.
// 3. Try `.npmrc` in the user's home directory // 3. Try `.npmrc` in the user's home directory
if let Some(home_dir) = sys_traits::impls::RealSys.env_home_dir() { if let Some(home_dir) = crate::sys::CliSys::default().env_home_dir() {
match try_to_read_npmrc(&home_dir) { match try_to_read_npmrc(&home_dir) {
Ok(Some((source, path))) => { Ok(Some((source, path))) => {
return try_to_parse_npmrc(source, &path).map(|r| (r, Some(path))); return try_to_parse_npmrc(source, &path).map(|r| (r, Some(path)));
@ -739,6 +737,7 @@ pub struct CliOptions {
npmrc: Arc<ResolvedNpmRc>, npmrc: Arc<ResolvedNpmRc>,
maybe_lockfile: Option<Arc<CliLockfile>>, maybe_lockfile: Option<Arc<CliLockfile>>,
maybe_external_import_map: Option<(PathBuf, serde_json::Value)>, maybe_external_import_map: Option<(PathBuf, serde_json::Value)>,
sys: CliSys,
overrides: CliOptionOverrides, overrides: CliOptionOverrides,
pub start_dir: Arc<WorkspaceDirectory>, pub start_dir: Arc<WorkspaceDirectory>,
pub deno_dir_provider: Arc<DenoDirProvider>, pub deno_dir_provider: Arc<DenoDirProvider>,
@ -748,6 +747,7 @@ pub struct CliOptions {
impl CliOptions { impl CliOptions {
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
pub fn new( pub fn new(
sys: &CliSys,
flags: Arc<Flags>, flags: Arc<Flags>,
initial_cwd: PathBuf, initial_cwd: PathBuf,
maybe_lockfile: Option<Arc<CliLockfile>>, maybe_lockfile: Option<Arc<CliLockfile>>,
@ -773,8 +773,10 @@ impl CliOptions {
} }
let maybe_lockfile = maybe_lockfile.filter(|_| !force_global_cache); let maybe_lockfile = maybe_lockfile.filter(|_| !force_global_cache);
let deno_dir_provider = let deno_dir_provider = Arc::new(DenoDirProvider::new(
Arc::new(DenoDirProvider::new(flags.internal.cache_path.clone())); sys.clone(),
flags.internal.cache_path.clone(),
));
let maybe_node_modules_folder = resolve_node_modules_folder( let maybe_node_modules_folder = resolve_node_modules_folder(
&initial_cwd, &initial_cwd,
&flags, &flags,
@ -796,11 +798,12 @@ impl CliOptions {
maybe_external_import_map, maybe_external_import_map,
start_dir, start_dir,
deno_dir_provider, deno_dir_provider,
sys: sys.clone(),
scope_options, scope_options,
}) })
} }
pub fn from_flags(flags: Arc<Flags>) -> Result<Self, AnyError> { pub fn from_flags(sys: &CliSys, flags: Arc<Flags>) -> Result<Self, AnyError> {
let initial_cwd = let initial_cwd =
std::env::current_dir().with_context(|| "Failed getting cwd.")?; std::env::current_dir().with_context(|| "Failed getting cwd.")?;
let maybe_vendor_override = flags.vendor.map(|v| match v { let maybe_vendor_override = flags.vendor.map(|v| match v {
@ -844,7 +847,7 @@ impl CliOptions {
ConfigFlag::Discover => { ConfigFlag::Discover => {
if let Some(start_paths) = flags.config_path_args(&initial_cwd) { if let Some(start_paths) = flags.config_path_args(&initial_cwd) {
WorkspaceDirectory::discover( WorkspaceDirectory::discover(
&FsSysTraitsAdapter::new_real(), sys,
WorkspaceDiscoverStart::Paths(&start_paths), WorkspaceDiscoverStart::Paths(&start_paths),
&resolve_workspace_discover_options(), &resolve_workspace_discover_options(),
)? )?
@ -855,7 +858,7 @@ impl CliOptions {
ConfigFlag::Path(path) => { ConfigFlag::Path(path) => {
let config_path = normalize_path(initial_cwd.join(path)); let config_path = normalize_path(initial_cwd.join(path));
WorkspaceDirectory::discover( WorkspaceDirectory::discover(
&FsSysTraitsAdapter::new_real(), sys,
WorkspaceDiscoverStart::ConfigFile(&config_path), WorkspaceDiscoverStart::ConfigFile(&config_path),
&resolve_workspace_discover_options(), &resolve_workspace_discover_options(),
)? )?
@ -879,6 +882,7 @@ impl CliOptions {
}; };
let maybe_lock_file = CliLockfile::discover( let maybe_lock_file = CliLockfile::discover(
sys,
&flags, &flags,
&start_dir.workspace, &start_dir.workspace,
external_import_map.as_ref().map(|(_, v)| v), external_import_map.as_ref().map(|(_, v)| v),
@ -887,6 +891,7 @@ impl CliOptions {
log::debug!("Finished config loading."); log::debug!("Finished config loading.");
Self::new( Self::new(
sys,
flags, flags,
initial_cwd, initial_cwd,
maybe_lock_file.map(Arc::new), maybe_lock_file.map(Arc::new),
@ -911,11 +916,13 @@ impl CliOptions {
None None
}; };
let lockfile = CliLockfile::discover( let lockfile = CliLockfile::discover(
&self.sys,
&self.flags, &self.flags,
&start_dir.workspace, &start_dir.workspace,
external_import_map.as_ref().map(|(_, v)| v), external_import_map.as_ref().map(|(_, v)| v),
)?; )?;
Self::new( Self::new(
&self.sys,
self.flags.clone(), self.flags.clone(),
self.initial_cwd().to_path_buf(), self.initial_cwd().to_path_buf(),
lockfile.map(Arc::new), lockfile.map(Arc::new),

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use std::path::PathBuf; use std::path::PathBuf;
use std::sync::Arc; use std::sync::Arc;

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
const cacheName = "cache-v1"; const cacheName = "cache-v1";
const cache = await caches.open(cacheName); const cache = await caches.open(cacheName);

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
Deno.bench("echo deno", async () => { Deno.bench("echo deno", async () => {
await new Deno.Command("echo", { args: ["deno"] }).output(); await new Deno.Command("echo", { args: ["deno"] }).output();

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
// deno-lint-ignore-file no-console // deno-lint-ignore-file no-console

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
// v8 builtin that's close to the upper bound non-NOPs // v8 builtin that's close to the upper bound non-NOPs
Deno.bench("date_now", { n: 5e5 }, () => { Deno.bench("date_now", { n: 5e5 }, () => {

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
// deno-lint-ignore-file no-console no-process-globals // deno-lint-ignore-file no-console no-process-globals
let [total, count] = typeof Deno !== "undefined" let [total, count] = typeof Deno !== "undefined"

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
let total = 5; let total = 5;
let current = ""; let current = "";

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
/** @jsx h */ /** @jsx h */
import results from "./deno.json" assert { type: "json" }; import results from "./deno.json" assert { type: "json" };

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
// deno-lint-ignore-file no-console no-process-globals // deno-lint-ignore-file no-console no-process-globals
let [total, count] = typeof Deno !== "undefined" let [total, count] = typeof Deno !== "undefined"

View file

@ -1,14 +1,15 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use std::collections::HashMap;
use std::path::Path;
use std::str::FromStr;
use std::time::Duration;
use deno_core::serde::Deserialize; use deno_core::serde::Deserialize;
use deno_core::serde_json; use deno_core::serde_json;
use deno_core::serde_json::json; use deno_core::serde_json::json;
use deno_core::serde_json::Value; use deno_core::serde_json::Value;
use lsp_types::Uri; use lsp_types::Uri;
use std::collections::HashMap;
use std::path::Path;
use std::str::FromStr;
use std::time::Duration;
use test_util::lsp::LspClientBuilder; use test_util::lsp::LspClientBuilder;
use test_util::PathRef; use test_util::PathRef;
use tower_lsp::lsp_types as lsp; use tower_lsp::lsp_types as lsp;

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use deno_bench_util::bencher::benchmark_group; use deno_bench_util::bencher::benchmark_group;
use deno_bench_util::bencher::benchmark_main; use deno_bench_util::bencher::benchmark_main;

View file

@ -1,11 +1,8 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
#![allow(clippy::print_stdout)] #![allow(clippy::print_stdout)]
#![allow(clippy::print_stderr)] #![allow(clippy::print_stderr)]
use deno_core::error::AnyError;
use deno_core::serde_json;
use deno_core::serde_json::Value;
use std::collections::HashMap; use std::collections::HashMap;
use std::convert::From; use std::convert::From;
use std::env; use std::env;
@ -15,6 +12,10 @@ use std::path::PathBuf;
use std::process::Command; use std::process::Command;
use std::process::Stdio; use std::process::Stdio;
use std::time::SystemTime; use std::time::SystemTime;
use deno_core::error::AnyError;
use deno_core::serde_json;
use deno_core::serde_json::Value;
use test_util::PathRef; use test_util::PathRef;
mod lsp; mod lsp;

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
import { loadTestLibrary } from "../../../tests/napi/common.js"; import { loadTestLibrary } from "../../../tests/napi/common.js";

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
import { bench, run } from "mitata"; import { bench, run } from "mitata";
import { createRequire } from "module"; import { createRequire } from "module";

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
// deno-lint-ignore-file no-console no-process-globals // deno-lint-ignore-file no-console no-process-globals
const queueMicrotask = globalThis.queueMicrotask || process.nextTick; const queueMicrotask = globalThis.queueMicrotask || process.nextTick;

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
// deno-lint-ignore-file no-console no-process-globals // deno-lint-ignore-file no-console no-process-globals
let [total, count] = typeof Deno !== "undefined" let [total, count] = typeof Deno !== "undefined"

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
// From https://github.com/just-js/benchmarks/tree/main/01-stdio // From https://github.com/just-js/benchmarks/tree/main/01-stdio
#include <stdlib.h> #include <stdlib.h>

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
// //
// From https://github.com/just-js/benchmarks/tree/main/01-stdio // From https://github.com/just-js/benchmarks/tree/main/01-stdio

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
const listener = Deno.listen({ port: 4500 }); const listener = Deno.listen({ port: 4500 });
const response = new TextEncoder().encode( const response = new TextEncoder().encode(

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
// deno-lint-ignore-file no-console no-process-globals // deno-lint-ignore-file no-console no-process-globals
const queueMicrotask = globalThis.queueMicrotask || process.nextTick; const queueMicrotask = globalThis.queueMicrotask || process.nextTick;

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
// deno-lint-ignore-file no-console no-process-globals // deno-lint-ignore-file no-console no-process-globals
const queueMicrotask = globalThis.queueMicrotask || process.nextTick; const queueMicrotask = globalThis.queueMicrotask || process.nextTick;

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
// deno-lint-ignore-file no-console // deno-lint-ignore-file no-console

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
// deno-lint-ignore-file no-console no-process-globals // deno-lint-ignore-file no-console no-process-globals
const queueMicrotask = globalThis.queueMicrotask || process.nextTick; const queueMicrotask = globalThis.queueMicrotask || process.nextTick;

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use std::env; use std::env;
use std::path::PathBuf; use std::path::PathBuf;
@ -8,16 +8,18 @@ use deno_runtime::*;
mod shared; mod shared;
mod ts { mod ts {
use super::*; use std::collections::HashMap;
use std::io::Write;
use std::path::Path;
use std::path::PathBuf;
use deno_core::error::custom_error; use deno_core::error::custom_error;
use deno_core::error::AnyError; use deno_core::error::AnyError;
use deno_core::op2; use deno_core::op2;
use deno_core::OpState; use deno_core::OpState;
use serde::Serialize; use serde::Serialize;
use std::collections::HashMap;
use std::io::Write; use super::*;
use std::path::Path;
use std::path::PathBuf;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]

11
cli/cache/cache_db.rs vendored
View file

@ -1,4 +1,9 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use std::io::IsTerminal;
use std::path::Path;
use std::path::PathBuf;
use std::sync::Arc;
use deno_core::error::AnyError; use deno_core::error::AnyError;
use deno_core::parking_lot::Mutex; use deno_core::parking_lot::Mutex;
@ -9,10 +14,6 @@ use deno_runtime::deno_webstorage::rusqlite::Connection;
use deno_runtime::deno_webstorage::rusqlite::OptionalExtension; use deno_runtime::deno_webstorage::rusqlite::OptionalExtension;
use deno_runtime::deno_webstorage::rusqlite::Params; use deno_runtime::deno_webstorage::rusqlite::Params;
use once_cell::sync::OnceCell; use once_cell::sync::OnceCell;
use std::io::IsTerminal;
use std::path::Path;
use std::path::PathBuf;
use std::sync::Arc;
use super::FastInsecureHasher; use super::FastInsecureHasher;

2
cli/cache/caches.rs vendored
View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use std::path::PathBuf; use std::path::PathBuf;
use std::sync::Arc; use std::sync::Arc;

9
cli/cache/check.rs vendored
View file

@ -1,12 +1,13 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use deno_ast::ModuleSpecifier;
use deno_core::error::AnyError;
use deno_runtime::deno_webstorage::rusqlite::params;
use super::cache_db::CacheDB; use super::cache_db::CacheDB;
use super::cache_db::CacheDBConfiguration; use super::cache_db::CacheDBConfiguration;
use super::cache_db::CacheDBHash; use super::cache_db::CacheDBHash;
use super::cache_db::CacheFailure; use super::cache_db::CacheFailure;
use deno_ast::ModuleSpecifier;
use deno_core::error::AnyError;
use deno_runtime::deno_webstorage::rusqlite::params;
pub static TYPE_CHECK_CACHE_DB: CacheDBConfiguration = CacheDBConfiguration { pub static TYPE_CHECK_CACHE_DB: CacheDBConfiguration = CacheDBConfiguration {
table_initializer: concat!( table_initializer: concat!(

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use std::sync::Arc; use std::sync::Arc;
@ -7,12 +7,11 @@ use deno_core::error::AnyError;
use deno_runtime::code_cache; use deno_runtime::code_cache;
use deno_runtime::deno_webstorage::rusqlite::params; use deno_runtime::deno_webstorage::rusqlite::params;
use crate::worker::CliCodeCache;
use super::cache_db::CacheDB; use super::cache_db::CacheDB;
use super::cache_db::CacheDBConfiguration; use super::cache_db::CacheDBConfiguration;
use super::cache_db::CacheDBHash; use super::cache_db::CacheDBHash;
use super::cache_db::CacheFailure; use super::cache_db::CacheFailure;
use crate::worker::CliCodeCache;
pub static CODE_CACHE_DB: CacheDBConfiguration = CacheDBConfiguration { pub static CODE_CACHE_DB: CacheDBConfiguration = CacheDBConfiguration {
table_initializer: concat!( table_initializer: concat!(

2
cli/cache/common.rs vendored
View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use std::hash::Hasher; use std::hash::Hasher;

20
cli/cache/deno_dir.rs vendored
View file

@ -1,23 +1,26 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use std::env;
use std::path::PathBuf;
use deno_cache_dir::DenoDirResolutionError; use deno_cache_dir::DenoDirResolutionError;
use once_cell::sync::OnceCell; use once_cell::sync::OnceCell;
use super::DiskCache; use super::DiskCache;
use crate::sys::CliSys;
use std::env;
use std::path::PathBuf;
/// Lazily creates the deno dir which might be useful in scenarios /// Lazily creates the deno dir which might be useful in scenarios
/// where functionality wants to continue if the DENO_DIR can't be created. /// where functionality wants to continue if the DENO_DIR can't be created.
pub struct DenoDirProvider { pub struct DenoDirProvider {
sys: CliSys,
maybe_custom_root: Option<PathBuf>, maybe_custom_root: Option<PathBuf>,
deno_dir: OnceCell<Result<DenoDir, DenoDirResolutionError>>, deno_dir: OnceCell<Result<DenoDir, DenoDirResolutionError>>,
} }
impl DenoDirProvider { impl DenoDirProvider {
pub fn new(maybe_custom_root: Option<PathBuf>) -> Self { pub fn new(sys: CliSys, maybe_custom_root: Option<PathBuf>) -> Self {
Self { Self {
sys,
maybe_custom_root, maybe_custom_root,
deno_dir: Default::default(), deno_dir: Default::default(),
} }
@ -26,7 +29,9 @@ impl DenoDirProvider {
pub fn get_or_create(&self) -> Result<&DenoDir, DenoDirResolutionError> { pub fn get_or_create(&self) -> Result<&DenoDir, DenoDirResolutionError> {
self self
.deno_dir .deno_dir
.get_or_init(|| DenoDir::new(self.maybe_custom_root.clone())) .get_or_init(|| {
DenoDir::new(self.sys.clone(), self.maybe_custom_root.clone())
})
.as_ref() .as_ref()
.map_err(|err| match err { .map_err(|err| match err {
DenoDirResolutionError::NoCacheOrHomeDir => { DenoDirResolutionError::NoCacheOrHomeDir => {
@ -53,6 +58,7 @@ pub struct DenoDir {
impl DenoDir { impl DenoDir {
pub fn new( pub fn new(
sys: CliSys,
maybe_custom_root: Option<PathBuf>, maybe_custom_root: Option<PathBuf>,
) -> Result<Self, deno_cache_dir::DenoDirResolutionError> { ) -> Result<Self, deno_cache_dir::DenoDirResolutionError> {
let root = deno_cache_dir::resolve_deno_dir( let root = deno_cache_dir::resolve_deno_dir(
@ -64,7 +70,7 @@ impl DenoDir {
let deno_dir = Self { let deno_dir = Self {
root, root,
gen_cache: DiskCache::new(&gen_path), gen_cache: DiskCache::new(sys, &gen_path),
}; };
Ok(deno_dir) Ok(deno_dir)

View file

@ -1,12 +1,5 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use super::CACHE_PERM;
use deno_cache_dir::url_to_filename;
use deno_core::url::Host;
use deno_core::url::Url;
use deno_path_util::fs::atomic_write_file_with_retries;
use deno_runtime::deno_fs::FsSysTraitsAdapter;
use std::ffi::OsStr; use std::ffi::OsStr;
use std::fs; use std::fs;
use std::path::Component; use std::path::Component;
@ -15,16 +8,26 @@ use std::path::PathBuf;
use std::path::Prefix; use std::path::Prefix;
use std::str; use std::str;
use deno_cache_dir::url_to_filename;
use deno_core::url::Host;
use deno_core::url::Url;
use deno_path_util::fs::atomic_write_file_with_retries;
use super::CACHE_PERM;
use crate::sys::CliSys;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct DiskCache { pub struct DiskCache {
sys: CliSys,
pub location: PathBuf, pub location: PathBuf,
} }
impl DiskCache { impl DiskCache {
/// `location` must be an absolute path. /// `location` must be an absolute path.
pub fn new(location: &Path) -> Self { pub fn new(sys: CliSys, location: &Path) -> Self {
assert!(location.is_absolute()); assert!(location.is_absolute());
Self { Self {
sys,
location: location.to_owned(), location: location.to_owned(),
} }
} }
@ -121,25 +124,21 @@ impl DiskCache {
pub fn set(&self, filename: &Path, data: &[u8]) -> std::io::Result<()> { pub fn set(&self, filename: &Path, data: &[u8]) -> std::io::Result<()> {
let path = self.location.join(filename); let path = self.location.join(filename);
atomic_write_file_with_retries( atomic_write_file_with_retries(&self.sys, &path, data, CACHE_PERM)
&FsSysTraitsAdapter::new_real(),
&path,
data,
CACHE_PERM,
)
} }
} }
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use test_util::TempDir; use test_util::TempDir;
use super::*;
#[test] #[test]
fn test_set_get_cache_file() { fn test_set_get_cache_file() {
let temp_dir = TempDir::new(); let temp_dir = TempDir::new();
let sub_dir = temp_dir.path().join("sub_dir"); let sub_dir = temp_dir.path().join("sub_dir");
let cache = DiskCache::new(&sub_dir.to_path_buf()); let cache = DiskCache::new(CliSys::default(), &sub_dir.to_path_buf());
let path = PathBuf::from("foo/bar.txt"); let path = PathBuf::from("foo/bar.txt");
cache.set(&path, b"hello").unwrap(); cache.set(&path, b"hello").unwrap();
assert_eq!(cache.get(&path).unwrap(), b"hello"); assert_eq!(cache.get(&path).unwrap(), b"hello");
@ -153,7 +152,7 @@ mod tests {
PathBuf::from("/deno_dir/") PathBuf::from("/deno_dir/")
}; };
let cache = DiskCache::new(&cache_location); let cache = DiskCache::new(CliSys::default(), &cache_location);
let mut test_cases = vec![ let mut test_cases = vec![
( (
@ -209,7 +208,7 @@ mod tests {
} else { } else {
"/foo" "/foo"
}; };
let cache = DiskCache::new(&PathBuf::from(p)); let cache = DiskCache::new(CliSys::default(), &PathBuf::from(p));
let mut test_cases = vec![ let mut test_cases = vec![
( (
@ -257,7 +256,7 @@ mod tests {
PathBuf::from("/deno_dir/") PathBuf::from("/deno_dir/")
}; };
let cache = DiskCache::new(&cache_location); let cache = DiskCache::new(CliSys::default(), &cache_location);
let mut test_cases = vec!["unknown://localhost/test.ts"]; let mut test_cases = vec!["unknown://localhost/test.ts"];

6
cli/cache/emit.rs vendored
View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use std::path::PathBuf; use std::path::PathBuf;
@ -160,11 +160,13 @@ mod test {
use test_util::TempDir; use test_util::TempDir;
use super::*; use super::*;
use crate::sys::CliSys;
#[test] #[test]
pub fn emit_cache_general_use() { pub fn emit_cache_general_use() {
let temp_dir = TempDir::new(); let temp_dir = TempDir::new();
let disk_cache = DiskCache::new(temp_dir.path().as_path()); let disk_cache =
DiskCache::new(CliSys::default(), temp_dir.path().as_path());
let cache = EmitCache { let cache = EmitCache {
disk_cache: disk_cache.clone(), disk_cache: disk_cache.clone(),
file_serializer: EmitFileSerializer { file_serializer: EmitFileSerializer {

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use deno_core::error::AnyError; use deno_core::error::AnyError;
use deno_graph::FastCheckCacheItem; use deno_graph::FastCheckCacheItem;

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use std::collections::HashMap; use std::collections::HashMap;
use std::path::Path; use std::path::Path;

37
cli/cache/mod.rs vendored
View file

@ -1,10 +1,8 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use crate::args::jsr_url; use std::collections::HashMap;
use crate::file_fetcher::CliFetchNoFollowErrorKind; use std::path::PathBuf;
use crate::file_fetcher::CliFileFetcher; use std::sync::Arc;
use crate::file_fetcher::FetchNoFollowOptions;
use crate::file_fetcher::FetchPermissionsOptionRef;
use deno_ast::MediaType; use deno_ast::MediaType;
use deno_cache_dir::file_fetcher::CacheSetting; use deno_cache_dir::file_fetcher::CacheSetting;
@ -18,12 +16,15 @@ use deno_graph::source::CacheInfo;
use deno_graph::source::LoadFuture; use deno_graph::source::LoadFuture;
use deno_graph::source::LoadResponse; use deno_graph::source::LoadResponse;
use deno_graph::source::Loader; use deno_graph::source::Loader;
use deno_runtime::deno_fs::FsSysTraitsAdapter;
use deno_runtime::deno_permissions::PermissionsContainer; use deno_runtime::deno_permissions::PermissionsContainer;
use node_resolver::InNpmPackageChecker; use node_resolver::InNpmPackageChecker;
use std::collections::HashMap;
use std::path::PathBuf; use crate::args::jsr_url;
use std::sync::Arc; use crate::file_fetcher::CliFetchNoFollowErrorKind;
use crate::file_fetcher::CliFileFetcher;
use crate::file_fetcher::FetchNoFollowOptions;
use crate::file_fetcher::FetchPermissionsOptionRef;
use crate::sys::CliSys;
mod cache_db; mod cache_db;
mod caches; mod caches;
@ -44,6 +45,8 @@ pub use caches::Caches;
pub use check::TypeCheckCache; pub use check::TypeCheckCache;
pub use code_cache::CodeCache; pub use code_cache::CodeCache;
pub use common::FastInsecureHasher; pub use common::FastInsecureHasher;
/// Permissions used to save a file in the disk caches.
pub use deno_cache_dir::CACHE_PERM;
pub use deno_dir::DenoDir; pub use deno_dir::DenoDir;
pub use deno_dir::DenoDirProvider; pub use deno_dir::DenoDirProvider;
pub use disk_cache::DiskCache; pub use disk_cache::DiskCache;
@ -55,13 +58,9 @@ pub use node::NodeAnalysisCache;
pub use parsed_source::LazyGraphSourceParser; pub use parsed_source::LazyGraphSourceParser;
pub use parsed_source::ParsedSourceCache; pub use parsed_source::ParsedSourceCache;
/// Permissions used to save a file in the disk caches. pub type GlobalHttpCache = deno_cache_dir::GlobalHttpCache<CliSys>;
pub use deno_cache_dir::CACHE_PERM; pub type LocalHttpCache = deno_cache_dir::LocalHttpCache<CliSys>;
pub type LocalLspHttpCache = deno_cache_dir::LocalLspHttpCache<CliSys>;
pub type GlobalHttpCache = deno_cache_dir::GlobalHttpCache<FsSysTraitsAdapter>;
pub type LocalHttpCache = deno_cache_dir::LocalHttpCache<FsSysTraitsAdapter>;
pub type LocalLspHttpCache =
deno_cache_dir::LocalLspHttpCache<FsSysTraitsAdapter>;
pub use deno_cache_dir::HttpCache; pub use deno_cache_dir::HttpCache;
pub struct FetchCacherOptions { pub struct FetchCacherOptions {
@ -80,7 +79,7 @@ pub struct FetchCacher {
in_npm_pkg_checker: Arc<dyn InNpmPackageChecker>, in_npm_pkg_checker: Arc<dyn InNpmPackageChecker>,
module_info_cache: Arc<ModuleInfoCache>, module_info_cache: Arc<ModuleInfoCache>,
permissions: PermissionsContainer, permissions: PermissionsContainer,
sys: FsSysTraitsAdapter, sys: CliSys,
is_deno_publish: bool, is_deno_publish: bool,
cache_info_enabled: bool, cache_info_enabled: bool,
} }
@ -91,7 +90,7 @@ impl FetchCacher {
global_http_cache: Arc<GlobalHttpCache>, global_http_cache: Arc<GlobalHttpCache>,
in_npm_pkg_checker: Arc<dyn InNpmPackageChecker>, in_npm_pkg_checker: Arc<dyn InNpmPackageChecker>,
module_info_cache: Arc<ModuleInfoCache>, module_info_cache: Arc<ModuleInfoCache>,
sys: FsSysTraitsAdapter, sys: CliSys,
options: FetchCacherOptions, options: FetchCacherOptions,
) -> Self { ) -> Self {
Self { Self {

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use std::sync::Arc; use std::sync::Arc;

5
cli/cache/node.rs vendored
View file

@ -1,15 +1,14 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use deno_core::error::AnyError; use deno_core::error::AnyError;
use deno_core::serde_json; use deno_core::serde_json;
use deno_runtime::deno_webstorage::rusqlite::params; use deno_runtime::deno_webstorage::rusqlite::params;
use crate::node::CliCjsAnalysis;
use super::cache_db::CacheDB; use super::cache_db::CacheDB;
use super::cache_db::CacheDBConfiguration; use super::cache_db::CacheDBConfiguration;
use super::cache_db::CacheFailure; use super::cache_db::CacheFailure;
use super::CacheDBHash; use super::CacheDBHash;
use crate::node::CliCjsAnalysis;
pub static NODE_ANALYSIS_CACHE_DB: CacheDBConfiguration = pub static NODE_ANALYSIS_CACHE_DB: CacheDBConfiguration =
CacheDBConfiguration { CacheDBConfiguration {

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use std::collections::HashMap; use std::collections::HashMap;
use std::sync::Arc; use std::sync::Arc;

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
/// <https://chromedevtools.github.io/devtools-protocol/tot/> /// <https://chromedevtools.github.io/devtools-protocol/tot/>
use deno_core::serde_json::Value; use deno_core::serde_json::Value;

View file

@ -4,6 +4,7 @@ disallowed-methods = [
] ]
disallowed-types = [ disallowed-types = [
{ path = "reqwest::Client", reason = "use crate::http_util::HttpClient instead" }, { path = "reqwest::Client", reason = "use crate::http_util::HttpClient instead" },
{ path = "sys_traits::impls::RealSys", reason = "use crate::sys::CliSys instead" },
] ]
ignore-interior-mutability = [ ignore-interior-mutability = [
"lsp_types::Uri", "lsp_types::Uri",

View file

@ -1,9 +1,6 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use crate::cache::EmitCache; use std::sync::Arc;
use crate::cache::FastInsecureHasher;
use crate::cache::ParsedSourceCache;
use crate::resolver::CjsTracker;
use deno_ast::EmittedSourceText; use deno_ast::EmittedSourceText;
use deno_ast::ModuleKind; use deno_ast::ModuleKind;
@ -21,7 +18,11 @@ use deno_core::ModuleSpecifier;
use deno_graph::MediaType; use deno_graph::MediaType;
use deno_graph::Module; use deno_graph::Module;
use deno_graph::ModuleGraph; use deno_graph::ModuleGraph;
use std::sync::Arc;
use crate::cache::EmitCache;
use crate::cache::FastInsecureHasher;
use crate::cache::ParsedSourceCache;
use crate::resolver::CjsTracker;
#[derive(Debug)] #[derive(Debug)]
pub struct Emitter { pub struct Emitter {

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
//! There are many types of errors in Deno: //! There are many types of errors in Deno:
//! - AnyError: a generic wrapper that can encapsulate any type of error. //! - AnyError: a generic wrapper that can encapsulate any type of error.

View file

@ -1,4 +1,42 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use std::collections::BTreeSet;
use std::collections::HashSet;
use std::future::Future;
use std::path::PathBuf;
use std::sync::Arc;
use deno_ast::ModuleSpecifier;
use deno_cache_dir::file_fetcher::File;
use deno_cache_dir::npm::NpmCacheDir;
use deno_config::glob::FilePatterns;
use deno_config::workspace::PackageJsonDepResolution;
use deno_config::workspace::WorkspaceDirectory;
use deno_config::workspace::WorkspaceResolver;
use deno_core::anyhow::anyhow;
use deno_core::error::AnyError;
use deno_core::futures::FutureExt;
use deno_core::FeatureChecker;
use deno_path_util::url_to_file_path;
use deno_resolver::cjs::IsCjsResolutionMode;
use deno_resolver::npm::NpmReqResolverOptions;
use deno_resolver::DenoResolverOptions;
use deno_resolver::NodeAndNpmReqResolver;
use deno_runtime::deno_fs;
use deno_runtime::deno_fs::RealFs;
use deno_runtime::deno_node::RealIsBuiltInNodeModuleChecker;
use deno_runtime::deno_permissions::Permissions;
use deno_runtime::deno_permissions::PermissionsContainer;
use deno_runtime::deno_permissions::PermissionsOptions;
use deno_runtime::deno_tls::rustls::RootCertStore;
use deno_runtime::deno_tls::RootCertStoreProvider;
use deno_runtime::deno_web::BlobStore;
use deno_runtime::inspector_server::InspectorServer;
use deno_runtime::permissions::RuntimePermissionDescriptorParser;
use log::warn;
use node_resolver::analyze::NodeCodeTranslator;
use node_resolver::InNpmPackageChecker;
use once_cell::sync::OnceCell;
use crate::args::check_warn_tsconfig; use crate::args::check_warn_tsconfig;
use crate::args::get_root_cert_store; use crate::args::get_root_cert_store;
@ -32,6 +70,8 @@ use crate::module_loader::CliModuleLoaderFactory;
use crate::module_loader::ModuleLoadPreparer; use crate::module_loader::ModuleLoadPreparer;
use crate::node::CliCjsCodeAnalyzer; use crate::node::CliCjsCodeAnalyzer;
use crate::node::CliNodeCodeTranslator; use crate::node::CliNodeCodeTranslator;
use crate::node::CliNodeResolver;
use crate::node::CliPackageJsonResolver;
use crate::npm::create_cli_npm_resolver; use crate::npm::create_cli_npm_resolver;
use crate::npm::create_in_npm_pkg_checker; use crate::npm::create_in_npm_pkg_checker;
use crate::npm::CliByonmNpmResolverCreateOptions; use crate::npm::CliByonmNpmResolverCreateOptions;
@ -49,7 +89,8 @@ use crate::resolver::CliResolverOptions;
use crate::resolver::CliSloppyImportsResolver; use crate::resolver::CliSloppyImportsResolver;
use crate::resolver::NpmModuleLoader; use crate::resolver::NpmModuleLoader;
use crate::resolver::SloppyImportsCachedFs; use crate::resolver::SloppyImportsCachedFs;
use crate::standalone::DenoCompileBinaryWriter; use crate::standalone::binary::DenoCompileBinaryWriter;
use crate::sys::CliSys;
use crate::tools::check::MaybeDiagnostics; use crate::tools::check::MaybeDiagnostics;
use crate::tools::check::TypeChecker; use crate::tools::check::TypeChecker;
use crate::tools::coverage::CoverageCollector; use crate::tools::coverage::CoverageCollector;
@ -64,46 +105,6 @@ use crate::util::progress_bar::ProgressBar;
use crate::util::progress_bar::ProgressBarStyle; use crate::util::progress_bar::ProgressBarStyle;
use crate::worker::CliMainWorkerFactory; use crate::worker::CliMainWorkerFactory;
use crate::worker::CliMainWorkerOptions; use crate::worker::CliMainWorkerOptions;
use std::collections::BTreeSet;
use std::collections::HashSet;
use std::path::PathBuf;
use deno_ast::ModuleSpecifier;
use deno_cache_dir::file_fetcher::File;
use deno_cache_dir::npm::NpmCacheDir;
use deno_config::glob::FilePatterns;
use deno_config::workspace::PackageJsonDepResolution;
use deno_config::workspace::WorkspaceDirectory;
use deno_config::workspace::WorkspaceResolver;
use deno_core::anyhow::anyhow;
use deno_core::error::AnyError;
use deno_core::futures::FutureExt;
use deno_core::FeatureChecker;
use deno_path_util::url_to_file_path;
use deno_resolver::cjs::IsCjsResolutionMode;
use deno_resolver::npm::NpmReqResolverOptions;
use deno_resolver::DenoResolverOptions;
use deno_resolver::NodeAndNpmReqResolver;
use deno_runtime::deno_fs;
use deno_runtime::deno_fs::FsSysTraitsAdapter;
use deno_runtime::deno_node::NodeResolver;
use deno_runtime::deno_node::PackageJsonResolver;
use deno_runtime::deno_node::RealIsBuiltInNodeModuleChecker;
use deno_runtime::deno_permissions::Permissions;
use deno_runtime::deno_permissions::PermissionsContainer;
use deno_runtime::deno_permissions::PermissionsOptions;
use deno_runtime::deno_tls::rustls::RootCertStore;
use deno_runtime::deno_tls::RootCertStoreProvider;
use deno_runtime::deno_web::BlobStore;
use deno_runtime::inspector_server::InspectorServer;
use deno_runtime::permissions::RuntimePermissionDescriptorParser;
use log::warn;
use node_resolver::analyze::NodeCodeTranslator;
use node_resolver::InNpmPackageChecker;
use once_cell::sync::OnceCell;
use std::future::Future;
use std::sync::Arc;
struct CliRootCertStoreProvider { struct CliRootCertStoreProvider {
cell: OnceCell<RootCertStore>, cell: OnceCell<RootCertStore>,
@ -211,13 +212,14 @@ struct CliFactoryServices {
module_info_cache: Deferred<Arc<ModuleInfoCache>>, module_info_cache: Deferred<Arc<ModuleInfoCache>>,
module_load_preparer: Deferred<Arc<ModuleLoadPreparer>>, module_load_preparer: Deferred<Arc<ModuleLoadPreparer>>,
node_code_translator: Deferred<Arc<CliNodeCodeTranslator>>, node_code_translator: Deferred<Arc<CliNodeCodeTranslator>>,
node_resolver: Deferred<Arc<NodeResolver>>, node_resolver: Deferred<Arc<CliNodeResolver>>,
npm_cache_dir: Deferred<Arc<NpmCacheDir>>, npm_cache_dir: Deferred<Arc<NpmCacheDir>>,
npm_req_resolver: Deferred<Arc<CliNpmReqResolver>>, npm_req_resolver: Deferred<Arc<CliNpmReqResolver>>,
npm_resolver: Deferred<Arc<dyn CliNpmResolver>>, npm_resolver: Deferred<Arc<dyn CliNpmResolver>>,
parsed_source_cache: Deferred<Arc<ParsedSourceCache>>, parsed_source_cache: Deferred<Arc<ParsedSourceCache>>,
permission_desc_parser: Deferred<Arc<RuntimePermissionDescriptorParser>>, permission_desc_parser:
pkg_json_resolver: Deferred<Arc<PackageJsonResolver>>, Deferred<Arc<RuntimePermissionDescriptorParser<CliSys>>>,
pkg_json_resolver: Deferred<Arc<CliPackageJsonResolver>>,
resolver: Deferred<Arc<CliResolver>>, resolver: Deferred<Arc<CliResolver>>,
root_cert_store_provider: Deferred<Arc<dyn RootCertStoreProvider>>, root_cert_store_provider: Deferred<Arc<dyn RootCertStoreProvider>>,
root_permissions_container: Deferred<PermissionsContainer>, root_permissions_container: Deferred<PermissionsContainer>,
@ -267,7 +269,7 @@ impl CliFactory {
pub fn cli_options(&self) -> Result<&Arc<CliOptions>, AnyError> { pub fn cli_options(&self) -> Result<&Arc<CliOptions>, AnyError> {
self.services.cli_options.get_or_try_init(|| { self.services.cli_options.get_or_try_init(|| {
CliOptions::from_flags(self.flags.clone()).map(Arc::new) CliOptions::from_flags(&self.sys(), self.flags.clone()).map(Arc::new)
}) })
} }
@ -330,7 +332,7 @@ impl CliFactory {
pub fn global_http_cache(&self) -> Result<&Arc<GlobalHttpCache>, AnyError> { pub fn global_http_cache(&self) -> Result<&Arc<GlobalHttpCache>, AnyError> {
self.services.global_http_cache.get_or_try_init(|| { self.services.global_http_cache.get_or_try_init(|| {
Ok(Arc::new(GlobalHttpCache::new( Ok(Arc::new(GlobalHttpCache::new(
FsSysTraitsAdapter(self.fs().clone()), self.sys(),
self.deno_dir()?.remote_folder_path(), self.deno_dir()?.remote_folder_path(),
))) )))
}) })
@ -368,6 +370,7 @@ impl CliFactory {
Ok(Arc::new(CliFileFetcher::new( Ok(Arc::new(CliFileFetcher::new(
self.http_cache()?.clone(), self.http_cache()?.clone(),
self.http_client_provider().clone(), self.http_client_provider().clone(),
self.sys(),
self.blob_store().clone(), self.blob_store().clone(),
Some(self.text_only_progress_bar().clone()), Some(self.text_only_progress_bar().clone()),
!cli_options.no_remote(), !cli_options.no_remote(),
@ -378,7 +381,11 @@ impl CliFactory {
} }
pub fn fs(&self) -> &Arc<dyn deno_fs::FileSystem> { pub fn fs(&self) -> &Arc<dyn deno_fs::FileSystem> {
self.services.fs.get_or_init(|| Arc::new(deno_fs::RealFs)) self.services.fs.get_or_init(|| Arc::new(RealFs))
}
pub fn sys(&self) -> CliSys {
CliSys::default() // very cheap to make
} }
pub fn in_npm_pkg_checker( pub fn in_npm_pkg_checker(
@ -404,11 +411,10 @@ impl CliFactory {
pub fn npm_cache_dir(&self) -> Result<&Arc<NpmCacheDir>, AnyError> { pub fn npm_cache_dir(&self) -> Result<&Arc<NpmCacheDir>, AnyError> {
self.services.npm_cache_dir.get_or_try_init(|| { self.services.npm_cache_dir.get_or_try_init(|| {
let fs = self.fs();
let global_path = self.deno_dir()?.npm_folder_path(); let global_path = self.deno_dir()?.npm_folder_path();
let cli_options = self.cli_options()?; let cli_options = self.cli_options()?;
Ok(Arc::new(NpmCacheDir::new( Ok(Arc::new(NpmCacheDir::new(
&FsSysTraitsAdapter(fs.clone()), &self.sys(),
global_path, global_path,
cli_options.npmrc().get_all_known_registries_urls(), cli_options.npmrc().get_all_known_registries_urls(),
))) )))
@ -423,12 +429,11 @@ impl CliFactory {
.npm_resolver .npm_resolver
.get_or_try_init_async( .get_or_try_init_async(
async { async {
let fs = self.fs();
let cli_options = self.cli_options()?; let cli_options = self.cli_options()?;
create_cli_npm_resolver(if cli_options.use_byonm() { create_cli_npm_resolver(if cli_options.use_byonm() {
CliNpmResolverCreateOptions::Byonm( CliNpmResolverCreateOptions::Byonm(
CliByonmNpmResolverCreateOptions { CliByonmNpmResolverCreateOptions {
sys: FsSysTraitsAdapter(fs.clone()), sys: self.sys(),
pkg_json_resolver: self.pkg_json_resolver().clone(), pkg_json_resolver: self.pkg_json_resolver().clone(),
root_node_modules_dir: Some( root_node_modules_dir: Some(
match cli_options.node_modules_dir_path() { match cli_options.node_modules_dir_path() {
@ -452,7 +457,7 @@ impl CliFactory {
cli_options.workspace(), cli_options.workspace(),
), ),
), ),
sys: FsSysTraitsAdapter(self.fs().clone()), sys: self.sys(),
snapshot: match cli_options.resolve_npm_resolution_snapshot()? { snapshot: match cli_options.resolve_npm_resolution_snapshot()? {
Some(snapshot) => { Some(snapshot) => {
CliNpmResolverManagedSnapshotOption::Specified(Some( CliNpmResolverManagedSnapshotOption::Specified(Some(
@ -499,7 +504,7 @@ impl CliFactory {
.get_or_try_init(|| { .get_or_try_init(|| {
Ok(self.cli_options()?.unstable_sloppy_imports().then(|| { Ok(self.cli_options()?.unstable_sloppy_imports().then(|| {
Arc::new(CliSloppyImportsResolver::new(SloppyImportsCachedFs::new( Arc::new(CliSloppyImportsResolver::new(SloppyImportsCachedFs::new(
FsSysTraitsAdapter(self.fs().clone()), self.sys(),
))) )))
})) }))
}) })
@ -660,13 +665,13 @@ impl CliFactory {
)) ))
} }
pub async fn node_resolver(&self) -> Result<&Arc<NodeResolver>, AnyError> { pub async fn node_resolver(&self) -> Result<&Arc<CliNodeResolver>, AnyError> {
self self
.services .services
.node_resolver .node_resolver
.get_or_try_init_async( .get_or_try_init_async(
async { async {
Ok(Arc::new(NodeResolver::new( Ok(Arc::new(CliNodeResolver::new(
self.in_npm_pkg_checker()?.clone(), self.in_npm_pkg_checker()?.clone(),
RealIsBuiltInNodeModuleChecker, RealIsBuiltInNodeModuleChecker,
self self
@ -675,7 +680,7 @@ impl CliFactory {
.clone() .clone()
.into_npm_pkg_folder_resolver(), .into_npm_pkg_folder_resolver(),
self.pkg_json_resolver().clone(), self.pkg_json_resolver().clone(),
FsSysTraitsAdapter(self.fs().clone()), self.sys(),
))) )))
} }
.boxed_local(), .boxed_local(),
@ -711,7 +716,7 @@ impl CliFactory {
.clone() .clone()
.into_npm_pkg_folder_resolver(), .into_npm_pkg_folder_resolver(),
self.pkg_json_resolver().clone(), self.pkg_json_resolver().clone(),
FsSysTraitsAdapter(self.fs().clone()), self.sys(),
))) )))
}) })
.await .await
@ -727,7 +732,7 @@ impl CliFactory {
let npm_resolver = self.npm_resolver().await?; let npm_resolver = self.npm_resolver().await?;
Ok(Arc::new(CliNpmReqResolver::new(NpmReqResolverOptions { Ok(Arc::new(CliNpmReqResolver::new(NpmReqResolverOptions {
byonm_resolver: (npm_resolver.clone()).into_maybe_byonm(), byonm_resolver: (npm_resolver.clone()).into_maybe_byonm(),
sys: FsSysTraitsAdapter(self.fs().clone()), sys: self.sys(),
in_npm_pkg_checker: self.in_npm_pkg_checker()?.clone(), in_npm_pkg_checker: self.in_npm_pkg_checker()?.clone(),
node_resolver: self.node_resolver().await?.clone(), node_resolver: self.node_resolver().await?.clone(),
npm_req_resolver: npm_resolver.clone().into_npm_req_resolver(), npm_req_resolver: npm_resolver.clone().into_npm_req_resolver(),
@ -736,12 +741,11 @@ impl CliFactory {
.await .await
} }
pub fn pkg_json_resolver(&self) -> &Arc<PackageJsonResolver> { pub fn pkg_json_resolver(&self) -> &Arc<CliPackageJsonResolver> {
self.services.pkg_json_resolver.get_or_init(|| { self
Arc::new(PackageJsonResolver::new(FsSysTraitsAdapter( .services
self.fs().clone(), .pkg_json_resolver
))) .get_or_init(|| Arc::new(CliPackageJsonResolver::new(self.sys())))
})
} }
pub async fn type_checker(&self) -> Result<&Arc<TypeChecker>, AnyError> { pub async fn type_checker(&self) -> Result<&Arc<TypeChecker>, AnyError> {
@ -787,7 +791,7 @@ impl CliFactory {
self.parsed_source_cache().clone(), self.parsed_source_cache().clone(),
self.resolver().await?.clone(), self.resolver().await?.clone(),
self.root_permissions_container()?.clone(), self.root_permissions_container()?.clone(),
FsSysTraitsAdapter(self.fs().clone()), self.sys(),
))) )))
}) })
.await .await
@ -877,10 +881,9 @@ impl CliFactory {
pub fn permission_desc_parser( pub fn permission_desc_parser(
&self, &self,
) -> Result<&Arc<RuntimePermissionDescriptorParser>, AnyError> { ) -> Result<&Arc<RuntimePermissionDescriptorParser<CliSys>>, AnyError> {
self.services.permission_desc_parser.get_or_try_init(|| { self.services.permission_desc_parser.get_or_try_init(|| {
let fs = self.fs().clone(); Ok(Arc::new(RuntimePermissionDescriptorParser::new(self.sys())))
Ok(Arc::new(RuntimePermissionDescriptorParser::new(fs)))
}) })
} }
@ -987,7 +990,7 @@ impl CliFactory {
), ),
self.parsed_source_cache().clone(), self.parsed_source_cache().clone(),
self.resolver().await?.clone(), self.resolver().await?.clone(),
FsSysTraitsAdapter(self.fs().clone()), self.sys(),
)), )),
node_resolver.clone(), node_resolver.clone(),
npm_resolver.clone(), npm_resolver.clone(),
@ -995,6 +998,7 @@ impl CliFactory {
self.root_cert_store_provider().clone(), self.root_cert_store_provider().clone(),
self.root_permissions_container()?.clone(), self.root_permissions_container()?.clone(),
StorageKeyResolver::from_options(cli_options), StorageKeyResolver::from_options(cli_options),
self.sys(),
cli_options.sub_command().clone(), cli_options.sub_command().clone(),
self.create_cli_main_worker_options()?, self.create_cli_main_worker_options()?,
self.cli_options()?.otel_config(), self.cli_options()?.otel_config(),
@ -1151,7 +1155,7 @@ impl WorkspaceDirFilesFactory {
pub fn permission_desc_parser( pub fn permission_desc_parser(
&self, &self,
) -> Result<&Arc<RuntimePermissionDescriptorParser>, AnyError> { ) -> Result<&Arc<RuntimePermissionDescriptorParser<CliSys>>, AnyError> {
self.cli_factory.permission_desc_parser() self.cli_factory.permission_desc_parser()
} }

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use std::borrow::Cow; use std::borrow::Cow;
use std::collections::HashMap; use std::collections::HashMap;
@ -24,7 +24,6 @@ use deno_core::url::Url;
use deno_core::ModuleSpecifier; use deno_core::ModuleSpecifier;
use deno_error::JsError; use deno_error::JsError;
use deno_graph::source::LoaderChecksum; use deno_graph::source::LoaderChecksum;
use deno_runtime::deno_fs::FsSysTraitsAdapter;
use deno_runtime::deno_permissions::CheckSpecifierKind; use deno_runtime::deno_permissions::CheckSpecifierKind;
use deno_runtime::deno_permissions::PermissionCheckError; use deno_runtime::deno_permissions::PermissionCheckError;
use deno_runtime::deno_permissions::PermissionsContainer; use deno_runtime::deno_permissions::PermissionsContainer;
@ -38,6 +37,7 @@ use crate::cache::HttpCache;
use crate::colors; use crate::colors;
use crate::http_util::get_response_body_with_progress; use crate::http_util::get_response_body_with_progress;
use crate::http_util::HttpClientProvider; use crate::http_util::HttpClientProvider;
use crate::sys::CliSys;
use crate::util::progress_bar::ProgressBar; use crate::util::progress_bar::ProgressBar;
#[derive(Debug, Clone, Eq, PartialEq)] #[derive(Debug, Clone, Eq, PartialEq)]
@ -267,7 +267,7 @@ pub struct FetchNoFollowOptions<'a> {
type DenoCacheDirFileFetcher = deno_cache_dir::file_fetcher::FileFetcher< type DenoCacheDirFileFetcher = deno_cache_dir::file_fetcher::FileFetcher<
BlobStoreAdapter, BlobStoreAdapter,
FsSysTraitsAdapter, CliSys,
HttpClientAdapter, HttpClientAdapter,
>; >;
@ -279,9 +279,11 @@ pub struct CliFileFetcher {
} }
impl CliFileFetcher { impl CliFileFetcher {
#[allow(clippy::too_many_arguments)]
pub fn new( pub fn new(
http_cache: Arc<dyn HttpCache>, http_cache: Arc<dyn HttpCache>,
http_client_provider: Arc<HttpClientProvider>, http_client_provider: Arc<HttpClientProvider>,
sys: CliSys,
blob_store: Arc<BlobStore>, blob_store: Arc<BlobStore>,
progress_bar: Option<ProgressBar>, progress_bar: Option<ProgressBar>,
allow_remote: bool, allow_remote: bool,
@ -289,7 +291,6 @@ impl CliFileFetcher {
download_log_level: log::Level, download_log_level: log::Level,
) -> Self { ) -> Self {
let memory_files = Arc::new(MemoryFiles::default()); let memory_files = Arc::new(MemoryFiles::default());
let sys = FsSysTraitsAdapter::new_real();
let auth_tokens = AuthTokens::new_from_sys(&sys); let auth_tokens = AuthTokens::new_from_sys(&sys);
let file_fetcher = DenoCacheDirFileFetcher::new( let file_fetcher = DenoCacheDirFileFetcher::new(
BlobStoreAdapter(blob_store), BlobStoreAdapter(blob_store),
@ -497,10 +498,6 @@ fn validate_scheme(specifier: &Url) -> Result<(), UnsupportedSchemeError> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::cache::GlobalHttpCache;
use crate::http_util::HttpClientProvider;
use super::*;
use deno_cache_dir::file_fetcher::FetchNoFollowErrorKind; use deno_cache_dir::file_fetcher::FetchNoFollowErrorKind;
use deno_cache_dir::file_fetcher::HttpClient; use deno_cache_dir::file_fetcher::HttpClient;
use deno_core::resolve_url; use deno_core::resolve_url;
@ -508,6 +505,10 @@ mod tests {
use deno_runtime::deno_web::InMemoryBlobPart; use deno_runtime::deno_web::InMemoryBlobPart;
use test_util::TempDir; use test_util::TempDir;
use super::*;
use crate::cache::GlobalHttpCache;
use crate::http_util::HttpClientProvider;
fn setup( fn setup(
cache_setting: CacheSetting, cache_setting: CacheSetting,
maybe_temp_dir: Option<TempDir>, maybe_temp_dir: Option<TempDir>,
@ -538,13 +539,11 @@ mod tests {
let temp_dir = maybe_temp_dir.unwrap_or_default(); let temp_dir = maybe_temp_dir.unwrap_or_default();
let location = temp_dir.path().join("remote").to_path_buf(); let location = temp_dir.path().join("remote").to_path_buf();
let blob_store: Arc<BlobStore> = Default::default(); let blob_store: Arc<BlobStore> = Default::default();
let cache = Arc::new(GlobalHttpCache::new( let cache = Arc::new(GlobalHttpCache::new(CliSys::default(), location));
FsSysTraitsAdapter::new_real(),
location,
));
let file_fetcher = CliFileFetcher::new( let file_fetcher = CliFileFetcher::new(
cache.clone(), cache.clone(),
Arc::new(HttpClientProvider::new(None, None)), Arc::new(HttpClientProvider::new(None, None)),
CliSys::default(),
blob_store.clone(), blob_store.clone(),
None, None,
true, true,
@ -754,11 +753,9 @@ mod tests {
// invocation and indicates to "cache bust". // invocation and indicates to "cache bust".
let location = temp_dir.path().join("remote").to_path_buf(); let location = temp_dir.path().join("remote").to_path_buf();
let file_fetcher = CliFileFetcher::new( let file_fetcher = CliFileFetcher::new(
Arc::new(GlobalHttpCache::new( Arc::new(GlobalHttpCache::new(CliSys::default(), location)),
FsSysTraitsAdapter::new_real(),
location,
)),
Arc::new(HttpClientProvider::new(None, None)), Arc::new(HttpClientProvider::new(None, None)),
CliSys::default(),
Default::default(), Default::default(),
None, None,
true, true,
@ -783,14 +780,13 @@ mod tests {
let specifier = let specifier =
resolve_url("http://localhost:4545/subdir/mismatch_ext.ts").unwrap(); resolve_url("http://localhost:4545/subdir/mismatch_ext.ts").unwrap();
let http_cache = Arc::new(GlobalHttpCache::new( let http_cache =
FsSysTraitsAdapter::new_real(), Arc::new(GlobalHttpCache::new(CliSys::default(), location.clone()));
location.clone(),
));
let file_modified_01 = { let file_modified_01 = {
let file_fetcher = CliFileFetcher::new( let file_fetcher = CliFileFetcher::new(
http_cache.clone(), http_cache.clone(),
Arc::new(HttpClientProvider::new(None, None)), Arc::new(HttpClientProvider::new(None, None)),
CliSys::default(),
Default::default(), Default::default(),
None, None,
true, true,
@ -810,11 +806,9 @@ mod tests {
let file_modified_02 = { let file_modified_02 = {
let file_fetcher = CliFileFetcher::new( let file_fetcher = CliFileFetcher::new(
Arc::new(GlobalHttpCache::new( Arc::new(GlobalHttpCache::new(CliSys::default(), location)),
FsSysTraitsAdapter::new_real(),
location,
)),
Arc::new(HttpClientProvider::new(None, None)), Arc::new(HttpClientProvider::new(None, None)),
CliSys::default(),
Default::default(), Default::default(),
None, None,
true, true,
@ -940,15 +934,14 @@ mod tests {
resolve_url("http://localhost:4548/subdir/mismatch_ext.ts").unwrap(); resolve_url("http://localhost:4548/subdir/mismatch_ext.ts").unwrap();
let redirected_specifier = let redirected_specifier =
resolve_url("http://localhost:4546/subdir/mismatch_ext.ts").unwrap(); resolve_url("http://localhost:4546/subdir/mismatch_ext.ts").unwrap();
let http_cache = Arc::new(GlobalHttpCache::new( let http_cache =
FsSysTraitsAdapter::new_real(), Arc::new(GlobalHttpCache::new(CliSys::default(), location.clone()));
location.clone(),
));
let metadata_file_modified_01 = { let metadata_file_modified_01 = {
let file_fetcher = CliFileFetcher::new( let file_fetcher = CliFileFetcher::new(
http_cache.clone(), http_cache.clone(),
Arc::new(HttpClientProvider::new(None, None)), Arc::new(HttpClientProvider::new(None, None)),
CliSys::default(),
Default::default(), Default::default(),
None, None,
true, true,
@ -971,6 +964,7 @@ mod tests {
let file_fetcher = CliFileFetcher::new( let file_fetcher = CliFileFetcher::new(
http_cache.clone(), http_cache.clone(),
Arc::new(HttpClientProvider::new(None, None)), Arc::new(HttpClientProvider::new(None, None)),
CliSys::default(),
Default::default(), Default::default(),
None, None,
true, true,
@ -1075,11 +1069,9 @@ mod tests {
let temp_dir = TempDir::new(); let temp_dir = TempDir::new();
let location = temp_dir.path().join("remote").to_path_buf(); let location = temp_dir.path().join("remote").to_path_buf();
let file_fetcher = CliFileFetcher::new( let file_fetcher = CliFileFetcher::new(
Arc::new(GlobalHttpCache::new( Arc::new(GlobalHttpCache::new(CliSys::default(), location)),
FsSysTraitsAdapter::new_real(),
location,
)),
Arc::new(HttpClientProvider::new(None, None)), Arc::new(HttpClientProvider::new(None, None)),
CliSys::default(),
Default::default(), Default::default(),
None, None,
false, false,
@ -1113,11 +1105,9 @@ mod tests {
let temp_dir = TempDir::new(); let temp_dir = TempDir::new();
let location = temp_dir.path().join("remote").to_path_buf(); let location = temp_dir.path().join("remote").to_path_buf();
let file_fetcher_01 = CliFileFetcher::new( let file_fetcher_01 = CliFileFetcher::new(
Arc::new(GlobalHttpCache::new( Arc::new(GlobalHttpCache::new(CliSys::default(), location.clone())),
FsSysTraitsAdapter::new_real(),
location.clone(),
)),
Arc::new(HttpClientProvider::new(None, None)), Arc::new(HttpClientProvider::new(None, None)),
CliSys::default(),
Default::default(), Default::default(),
None, None,
true, true,
@ -1125,11 +1115,9 @@ mod tests {
log::Level::Info, log::Level::Info,
); );
let file_fetcher_02 = CliFileFetcher::new( let file_fetcher_02 = CliFileFetcher::new(
Arc::new(GlobalHttpCache::new( Arc::new(GlobalHttpCache::new(CliSys::default(), location)),
FsSysTraitsAdapter::new_real(),
location,
)),
Arc::new(HttpClientProvider::new(None, None)), Arc::new(HttpClientProvider::new(None, None)),
CliSys::default(),
Default::default(), Default::default(),
None, None,
true, true,

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use std::sync::Arc; use std::sync::Arc;

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use std::error::Error; use std::error::Error;
use std::ops::Deref; use std::ops::Deref;
@ -27,7 +27,6 @@ use deno_graph::ResolutionError;
use deno_graph::SpecifierError; use deno_graph::SpecifierError;
use deno_graph::WorkspaceFastCheckOption; use deno_graph::WorkspaceFastCheckOption;
use deno_resolver::sloppy_imports::SloppyImportsResolutionKind; use deno_resolver::sloppy_imports::SloppyImportsResolutionKind;
use deno_runtime::deno_fs::FsSysTraitsAdapter;
use deno_runtime::deno_node; use deno_runtime::deno_node;
use deno_runtime::deno_permissions::PermissionsContainer; use deno_runtime::deno_permissions::PermissionsContainer;
use deno_semver::jsr::JsrDepPackageReq; use deno_semver::jsr::JsrDepPackageReq;
@ -55,6 +54,7 @@ use crate::resolver::CjsTracker;
use crate::resolver::CliResolver; use crate::resolver::CliResolver;
use crate::resolver::CliSloppyImportsResolver; use crate::resolver::CliSloppyImportsResolver;
use crate::resolver::SloppyImportsCachedFs; use crate::resolver::SloppyImportsCachedFs;
use crate::sys::CliSys;
use crate::tools::check; use crate::tools::check;
use crate::tools::check::TypeChecker; use crate::tools::check::TypeChecker;
use crate::util::file_watcher::WatcherCommunicator; use crate::util::file_watcher::WatcherCommunicator;
@ -78,7 +78,7 @@ pub struct GraphValidOptions {
/// for the CLI. /// for the CLI.
pub fn graph_valid( pub fn graph_valid(
graph: &ModuleGraph, graph: &ModuleGraph,
sys: &FsSysTraitsAdapter, sys: &CliSys,
roots: &[ModuleSpecifier], roots: &[ModuleSpecifier],
options: GraphValidOptions, options: GraphValidOptions,
) -> Result<(), AnyError> { ) -> Result<(), AnyError> {
@ -138,7 +138,7 @@ pub struct GraphWalkErrorsOptions {
/// and enhances them with CLI information. /// and enhances them with CLI information.
pub fn graph_walk_errors<'a>( pub fn graph_walk_errors<'a>(
graph: &'a ModuleGraph, graph: &'a ModuleGraph,
sys: &'a FsSysTraitsAdapter, sys: &'a CliSys,
roots: &'a [ModuleSpecifier], roots: &'a [ModuleSpecifier],
options: GraphWalkErrorsOptions, options: GraphWalkErrorsOptions,
) -> impl Iterator<Item = AnyError> + 'a { ) -> impl Iterator<Item = AnyError> + 'a {
@ -441,7 +441,7 @@ pub struct ModuleGraphBuilder {
parsed_source_cache: Arc<ParsedSourceCache>, parsed_source_cache: Arc<ParsedSourceCache>,
resolver: Arc<CliResolver>, resolver: Arc<CliResolver>,
root_permissions_container: PermissionsContainer, root_permissions_container: PermissionsContainer,
sys: FsSysTraitsAdapter, sys: CliSys,
} }
impl ModuleGraphBuilder { impl ModuleGraphBuilder {
@ -460,7 +460,7 @@ impl ModuleGraphBuilder {
parsed_source_cache: Arc<ParsedSourceCache>, parsed_source_cache: Arc<ParsedSourceCache>,
resolver: Arc<CliResolver>, resolver: Arc<CliResolver>,
root_permissions_container: PermissionsContainer, root_permissions_container: PermissionsContainer,
sys: FsSysTraitsAdapter, sys: CliSys,
) -> Self { ) -> Self {
Self { Self {
caches, caches,
@ -834,7 +834,7 @@ pub fn enhanced_resolution_error_message(error: &ResolutionError) -> String {
} }
fn enhanced_sloppy_imports_error_message( fn enhanced_sloppy_imports_error_message(
sys: &FsSysTraitsAdapter, sys: &CliSys,
error: &ModuleError, error: &ModuleError,
) -> Option<String> { ) -> Option<String> {
match error { match error {

View file

@ -1,7 +1,8 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use crate::util::progress_bar::UpdateGuard; use std::collections::HashMap;
use crate::version; use std::sync::Arc;
use std::thread::ThreadId;
use boxed_error::Boxed; use boxed_error::Boxed;
use deno_cache_dir::file_fetcher::RedirectHeaderParseError; use deno_cache_dir::file_fetcher::RedirectHeaderParseError;
@ -23,12 +24,11 @@ use http::header::CONTENT_LENGTH;
use http::HeaderMap; use http::HeaderMap;
use http::StatusCode; use http::StatusCode;
use http_body_util::BodyExt; use http_body_util::BodyExt;
use std::collections::HashMap;
use std::sync::Arc;
use std::thread::ThreadId;
use thiserror::Error; use thiserror::Error;
use crate::util::progress_bar::UpdateGuard;
use crate::version;
#[derive(Debug, Error)] #[derive(Debug, Error)]
pub enum SendError { pub enum SendError {
#[error(transparent)] #[error(transparent)]

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
pub fn main() { pub fn main() {
let mut args = vec!["cargo", "test", "-p", "cli_tests", "--features", "run"]; let mut args = vec!["cargo", "test", "-p", "cli_tests", "--features", "run"];

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use log::debug; use log::debug;

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
// deno-lint-ignore-file // deno-lint-ignore-file
import { core, primordials } from "ext:core/mod.js"; import { core, primordials } from "ext:core/mod.js";

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
// deno-lint-ignore-file // deno-lint-ignore-file
/* /*

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
// @ts-check // @ts-check

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
// @ts-check // @ts-check

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
export interface NodeFacade { export interface NodeFacade {
type: string; type: string;

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
import { core, primordials } from "ext:core/mod.js"; import { core, primordials } from "ext:core/mod.js";
import { escapeName, withPermissions } from "ext:cli/40_test_common.js"; import { escapeName, withPermissions } from "ext:cli/40_test_common.js";

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
import { core, primordials } from "ext:core/mod.js"; import { core, primordials } from "ext:core/mod.js";
import { serializePermissions } from "ext:runtime/10_permissions.js"; import { serializePermissions } from "ext:runtime/10_permissions.js";
const ops = core.ops; const ops = core.ops;

View file

@ -1,14 +1,16 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use std::sync::Arc;
use crate::args::jsr_url;
use crate::file_fetcher::CliFileFetcher;
use dashmap::DashMap; use dashmap::DashMap;
use deno_core::serde_json; use deno_core::serde_json;
use deno_graph::packages::JsrPackageInfo; use deno_graph::packages::JsrPackageInfo;
use deno_graph::packages::JsrPackageVersionInfo; use deno_graph::packages::JsrPackageVersionInfo;
use deno_semver::package::PackageNv; use deno_semver::package::PackageNv;
use deno_semver::package::PackageReq; use deno_semver::package::PackageReq;
use std::sync::Arc;
use crate::args::jsr_url;
use crate::file_fetcher::CliFileFetcher;
/// This is similar to a subset of `JsrCacheResolver` which fetches rather than /// This is similar to a subset of `JsrCacheResolver` which fetches rather than
/// just reads the cache. Keep in sync! /// just reads the cache. Keep in sync!

View file

@ -1,25 +1,15 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use super::diagnostics::DenoDiagnostic; use std::borrow::Cow;
use super::diagnostics::DiagnosticSource; use std::cmp::Ordering;
use super::documents::Document; use std::collections::HashMap;
use super::documents::Documents; use std::collections::HashSet;
use super::language_server; use std::path::Path;
use super::resolver::LspResolver;
use super::tsc;
use super::urls::url_to_uri;
use crate::args::jsr_url;
use crate::lsp::logging::lsp_warn;
use crate::lsp::search::PackageSearchApi;
use crate::tools::lint::CliLinter;
use crate::util::path::relative_specifier;
use deno_config::workspace::MappedResolution;
use deno_lint::diagnostic::LintDiagnosticRange;
use deno_ast::SourceRange; use deno_ast::SourceRange;
use deno_ast::SourceRangedForSpanned; use deno_ast::SourceRangedForSpanned;
use deno_ast::SourceTextInfo; use deno_ast::SourceTextInfo;
use deno_config::workspace::MappedResolution;
use deno_core::error::custom_error; use deno_core::error::custom_error;
use deno_core::error::AnyError; use deno_core::error::AnyError;
use deno_core::serde::Deserialize; use deno_core::serde::Deserialize;
@ -27,6 +17,7 @@ use deno_core::serde::Serialize;
use deno_core::serde_json; use deno_core::serde_json;
use deno_core::serde_json::json; use deno_core::serde_json::json;
use deno_core::ModuleSpecifier; use deno_core::ModuleSpecifier;
use deno_lint::diagnostic::LintDiagnosticRange;
use deno_path_util::url_to_file_path; use deno_path_util::url_to_file_path;
use deno_runtime::deno_node::PathClean; use deno_runtime::deno_node::PathClean;
use deno_semver::jsr::JsrPackageNvReference; use deno_semver::jsr::JsrPackageNvReference;
@ -44,16 +35,25 @@ use node_resolver::NodeResolutionKind;
use node_resolver::ResolutionMode; use node_resolver::ResolutionMode;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use regex::Regex; use regex::Regex;
use std::borrow::Cow;
use std::cmp::Ordering;
use std::collections::HashMap;
use std::collections::HashSet;
use std::path::Path;
use text_lines::LineAndColumnIndex; use text_lines::LineAndColumnIndex;
use tower_lsp::lsp_types as lsp; use tower_lsp::lsp_types as lsp;
use tower_lsp::lsp_types::Position; use tower_lsp::lsp_types::Position;
use tower_lsp::lsp_types::Range; use tower_lsp::lsp_types::Range;
use super::diagnostics::DenoDiagnostic;
use super::diagnostics::DiagnosticSource;
use super::documents::Document;
use super::documents::Documents;
use super::language_server;
use super::resolver::LspResolver;
use super::tsc;
use super::urls::url_to_uri;
use crate::args::jsr_url;
use crate::lsp::logging::lsp_warn;
use crate::lsp::search::PackageSearchApi;
use crate::tools::lint::CliLinter;
use crate::util::path::relative_specifier;
/// Diagnostic error codes which actually are the same, and so when grouping /// Diagnostic error codes which actually are the same, and so when grouping
/// fixes we treat them the same. /// fixes we treat them the same.
static FIX_ALL_ERROR_CODES: Lazy<HashMap<&'static str, &'static str>> = static FIX_ALL_ERROR_CODES: Lazy<HashMap<&'static str, &'static str>> =

View file

@ -1,4 +1,14 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use std::collections::BTreeMap;
use std::fs;
use std::path::Path;
use std::sync::Arc;
use std::time::SystemTime;
use deno_core::url::Url;
use deno_core::ModuleSpecifier;
use deno_path_util::url_to_file_path;
use crate::cache::DenoDir; use crate::cache::DenoDir;
use crate::cache::GlobalHttpCache; use crate::cache::GlobalHttpCache;
@ -7,16 +17,7 @@ use crate::cache::LocalLspHttpCache;
use crate::lsp::config::Config; use crate::lsp::config::Config;
use crate::lsp::logging::lsp_log; use crate::lsp::logging::lsp_log;
use crate::lsp::logging::lsp_warn; use crate::lsp::logging::lsp_warn;
use crate::sys::CliSys;
use deno_core::url::Url;
use deno_core::ModuleSpecifier;
use deno_path_util::url_to_file_path;
use deno_runtime::deno_fs::FsSysTraitsAdapter;
use std::collections::BTreeMap;
use std::fs;
use std::path::Path;
use std::sync::Arc;
use std::time::SystemTime;
pub fn calculate_fs_version( pub fn calculate_fs_version(
cache: &LspCache, cache: &LspCache,
@ -92,12 +93,11 @@ impl LspCache {
}) })
.ok() .ok()
}); });
let deno_dir = DenoDir::new(global_cache_path) let sys = CliSys::default();
let deno_dir = DenoDir::new(sys.clone(), global_cache_path)
.expect("should be infallible with absolute custom root"); .expect("should be infallible with absolute custom root");
let global = Arc::new(GlobalHttpCache::new( let global =
FsSysTraitsAdapter::new_real(), Arc::new(GlobalHttpCache::new(sys, deno_dir.remote_folder_path()));
deno_dir.remote_folder_path(),
));
Self { Self {
deno_dir, deno_dir,
global, global,

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
//! //!
//! Provides information about what capabilities that are supported by the //! Provides information about what capabilities that are supported by the

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use std::sync::Arc; use std::sync::Arc;
@ -12,12 +12,11 @@ use lsp_types::Uri;
use tower_lsp::lsp_types as lsp; use tower_lsp::lsp_types as lsp;
use tower_lsp::lsp_types::ConfigurationItem; use tower_lsp::lsp_types::ConfigurationItem;
use crate::lsp::repl::get_repl_workspace_settings;
use super::config::WorkspaceSettings; use super::config::WorkspaceSettings;
use super::config::SETTINGS_SECTION; use super::config::SETTINGS_SECTION;
use super::lsp_custom; use super::lsp_custom;
use super::testing::lsp_custom as testing_lsp_custom; use super::testing::lsp_custom as testing_lsp_custom;
use crate::lsp::repl::get_repl_workspace_settings;
#[derive(Debug)] #[derive(Debug)]
pub enum TestingNotification { pub enum TestingNotification {

View file

@ -1,13 +1,9 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use crate::lsp::logging::lsp_warn; use std::cell::RefCell;
use std::collections::HashSet;
use super::analysis::source_range_to_lsp_range; use std::rc::Rc;
use super::config::CodeLensSettings; use std::sync::Arc;
use super::language_server;
use super::text::LineIndex;
use super::tsc;
use super::tsc::NavigationTree;
use deno_ast::swc::ast; use deno_ast::swc::ast;
use deno_ast::swc::visit::Visit; use deno_ast::swc::visit::Visit;
@ -25,13 +21,17 @@ use deno_core::ModuleSpecifier;
use lazy_regex::lazy_regex; use lazy_regex::lazy_regex;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use regex::Regex; use regex::Regex;
use std::cell::RefCell;
use std::collections::HashSet;
use std::rc::Rc;
use std::sync::Arc;
use tower_lsp::jsonrpc::Error as LspError; use tower_lsp::jsonrpc::Error as LspError;
use tower_lsp::lsp_types as lsp; use tower_lsp::lsp_types as lsp;
use super::analysis::source_range_to_lsp_range;
use super::config::CodeLensSettings;
use super::language_server;
use super::text::LineIndex;
use super::tsc;
use super::tsc::NavigationTree;
use crate::lsp::logging::lsp_warn;
static ABSTRACT_MODIFIER: Lazy<Regex> = lazy_regex!(r"\babstract\b"); static ABSTRACT_MODIFIER: Lazy<Regex> = lazy_regex!(r"\babstract\b");
static EXPORT_MODIFIER: Lazy<Regex> = lazy_regex!(r"\bexport\b"); static EXPORT_MODIFIER: Lazy<Regex> = lazy_regex!(r"\bexport\b");

View file

@ -1,4 +1,26 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use deno_ast::LineAndColumnIndex;
use deno_ast::SourceTextInfo;
use deno_core::resolve_path;
use deno_core::resolve_url;
use deno_core::serde::Deserialize;
use deno_core::serde::Serialize;
use deno_core::serde_json::json;
use deno_core::url::Position;
use deno_core::ModuleSpecifier;
use deno_path_util::url_to_file_path;
use deno_runtime::deno_node::SUPPORTED_BUILTIN_NODE_MODULES;
use deno_semver::jsr::JsrPackageReqReference;
use deno_semver::package::PackageNv;
use import_map::ImportMap;
use indexmap::IndexSet;
use lsp_types::CompletionList;
use node_resolver::NodeResolutionKind;
use node_resolver::ResolutionMode;
use once_cell::sync::Lazy;
use regex::Regex;
use tower_lsp::lsp_types as lsp;
use super::client::Client; use super::client::Client;
use super::config::Config; use super::config::Config;
@ -12,33 +34,10 @@ use super::registries::ModuleRegistry;
use super::resolver::LspResolver; use super::resolver::LspResolver;
use super::search::PackageSearchApi; use super::search::PackageSearchApi;
use super::tsc; use super::tsc;
use crate::graph_util::to_node_resolution_mode; use crate::graph_util::to_node_resolution_mode;
use crate::jsr::JsrFetchResolver; use crate::jsr::JsrFetchResolver;
use crate::util::path::is_importable_ext; use crate::util::path::is_importable_ext;
use crate::util::path::relative_specifier; use crate::util::path::relative_specifier;
use deno_runtime::deno_node::SUPPORTED_BUILTIN_NODE_MODULES;
use deno_ast::LineAndColumnIndex;
use deno_ast::SourceTextInfo;
use deno_core::resolve_path;
use deno_core::resolve_url;
use deno_core::serde::Deserialize;
use deno_core::serde::Serialize;
use deno_core::serde_json::json;
use deno_core::url::Position;
use deno_core::ModuleSpecifier;
use deno_path_util::url_to_file_path;
use deno_semver::jsr::JsrPackageReqReference;
use deno_semver::package::PackageNv;
use import_map::ImportMap;
use indexmap::IndexSet;
use lsp_types::CompletionList;
use node_resolver::NodeResolutionKind;
use node_resolver::ResolutionMode;
use once_cell::sync::Lazy;
use regex::Regex;
use tower_lsp::lsp_types as lsp;
static FILE_PROTO_RE: Lazy<Regex> = static FILE_PROTO_RE: Lazy<Regex> =
lazy_regex::lazy_regex!(r#"^file:/{2}(?:/[A-Za-z]:)?"#); lazy_regex::lazy_regex!(r#"^file:/{2}(?:/[A-Za-z]:)?"#);
@ -822,16 +821,18 @@ fn get_workspace_completions(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::collections::HashMap;
use deno_core::resolve_url;
use pretty_assertions::assert_eq;
use test_util::TempDir;
use super::*; use super::*;
use crate::cache::HttpCache; use crate::cache::HttpCache;
use crate::lsp::cache::LspCache; use crate::lsp::cache::LspCache;
use crate::lsp::documents::Documents; use crate::lsp::documents::Documents;
use crate::lsp::documents::LanguageId; use crate::lsp::documents::LanguageId;
use crate::lsp::search::tests::TestPackageSearchApi; use crate::lsp::search::tests::TestPackageSearchApi;
use deno_core::resolve_url;
use pretty_assertions::assert_eq;
use std::collections::HashMap;
use test_util::TempDir;
fn setup( fn setup(
open_sources: &[(&str, &str, i32, LanguageId)], open_sources: &[(&str, &str, i32, LanguageId)],

View file

@ -1,4 +1,13 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::HashMap;
use std::ops::Deref;
use std::ops::DerefMut;
use std::path::Path;
use std::path::PathBuf;
use std::sync::Arc;
use deno_ast::MediaType; use deno_ast::MediaType;
use deno_config::deno_json::DenoJsonCache; use deno_config::deno_json::DenoJsonCache;
@ -36,18 +45,9 @@ use deno_lint::linter::LintConfig as DenoLintConfig;
use deno_npm::npm_rc::ResolvedNpmRc; use deno_npm::npm_rc::ResolvedNpmRc;
use deno_package_json::PackageJsonCache; use deno_package_json::PackageJsonCache;
use deno_path_util::url_to_file_path; use deno_path_util::url_to_file_path;
use deno_runtime::deno_fs::FsSysTraitsAdapter;
use deno_runtime::deno_node::PackageJson; use deno_runtime::deno_node::PackageJson;
use indexmap::IndexSet; use indexmap::IndexSet;
use lsp_types::ClientCapabilities; use lsp_types::ClientCapabilities;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::HashMap;
use std::ops::Deref;
use std::ops::DerefMut;
use std::path::Path;
use std::path::PathBuf;
use std::sync::Arc;
use tower_lsp::lsp_types as lsp; use tower_lsp::lsp_types as lsp;
use super::logging::lsp_log; use super::logging::lsp_log;
@ -65,6 +65,7 @@ use crate::file_fetcher::CliFileFetcher;
use crate::lsp::logging::lsp_warn; use crate::lsp::logging::lsp_warn;
use crate::resolver::CliSloppyImportsResolver; use crate::resolver::CliSloppyImportsResolver;
use crate::resolver::SloppyImportsCachedFs; use crate::resolver::SloppyImportsCachedFs;
use crate::sys::CliSys;
use crate::tools::lint::CliLinter; use crate::tools::lint::CliLinter;
use crate::tools::lint::CliLinterOptions; use crate::tools::lint::CliLinterOptions;
use crate::tools::lint::LintRuleProvider; use crate::tools::lint::LintRuleProvider;
@ -1227,7 +1228,7 @@ impl ConfigData {
Ok(scope_dir_path) => { Ok(scope_dir_path) => {
let paths = [scope_dir_path]; let paths = [scope_dir_path];
WorkspaceDirectory::discover( WorkspaceDirectory::discover(
&FsSysTraitsAdapter::new_real(), &CliSys::default(),
match specified_config { match specified_config {
Some(config_path) => { Some(config_path) => {
deno_config::workspace::WorkspaceDiscoverStart::ConfigFile( deno_config::workspace::WorkspaceDiscoverStart::ConfigFile(
@ -1617,9 +1618,7 @@ impl ConfigData {
|| unstable.contains("sloppy-imports"); || unstable.contains("sloppy-imports");
let sloppy_imports_resolver = unstable_sloppy_imports.then(|| { let sloppy_imports_resolver = unstable_sloppy_imports.then(|| {
Arc::new(CliSloppyImportsResolver::new( Arc::new(CliSloppyImportsResolver::new(
SloppyImportsCachedFs::new_without_stat_cache( SloppyImportsCachedFs::new_without_stat_cache(CliSys::default()),
FsSysTraitsAdapter::new_real(),
),
)) ))
}); });
let resolver = Arc::new(resolver); let resolver = Arc::new(resolver);
@ -1922,17 +1921,20 @@ impl ConfigTree {
#[cfg(test)] #[cfg(test)]
pub async fn inject_config_file(&mut self, config_file: ConfigFile) { pub async fn inject_config_file(&mut self, config_file: ConfigFile) {
use sys_traits::FsCreateDirAll;
use sys_traits::FsWrite;
let scope = config_file.specifier.join(".").unwrap(); let scope = config_file.specifier.join(".").unwrap();
let json_text = serde_json::to_string(&config_file.json).unwrap(); let json_text = serde_json::to_string(&config_file.json).unwrap();
let test_fs = Arc::new(deno_runtime::deno_fs::InMemoryFs::default()); let memory_sys = sys_traits::impls::InMemorySys::default();
let config_path = url_to_file_path(&config_file.specifier).unwrap(); let config_path = url_to_file_path(&config_file.specifier).unwrap();
test_fs.setup_text_files(vec![( memory_sys
config_path.to_string_lossy().to_string(), .fs_create_dir_all(config_path.parent().unwrap())
json_text, .unwrap();
)]); memory_sys.fs_write(&config_path, json_text).unwrap();
let workspace_dir = Arc::new( let workspace_dir = Arc::new(
WorkspaceDirectory::discover( WorkspaceDirectory::discover(
&FsSysTraitsAdapter(test_fs.clone()), &memory_sys,
deno_config::workspace::WorkspaceDiscoverStart::ConfigFile( deno_config::workspace::WorkspaceDiscoverStart::ConfigFile(
&config_path, &config_path,
), ),
@ -2009,11 +2011,14 @@ fn resolve_lockfile_from_path(
lockfile_path: PathBuf, lockfile_path: PathBuf,
frozen: bool, frozen: bool,
) -> Option<CliLockfile> { ) -> Option<CliLockfile> {
match CliLockfile::read_from_path(CliLockfileReadFromPathOptions { match CliLockfile::read_from_path(
file_path: lockfile_path, &CliSys::default(),
frozen, CliLockfileReadFromPathOptions {
skip_write: false, file_path: lockfile_path,
}) { frozen,
skip_write: false,
},
) {
Ok(value) => { Ok(value) => {
if value.filename.exists() { if value.filename.exists() {
if let Ok(specifier) = ModuleSpecifier::from_file_path(&value.filename) if let Ok(specifier) = ModuleSpecifier::from_file_path(&value.filename)

View file

@ -1,31 +1,11 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use super::analysis; use std::collections::HashMap;
use super::client::Client; use std::collections::HashSet;
use super::config::Config; use std::path::PathBuf;
use super::documents; use std::sync::atomic::AtomicUsize;
use super::documents::Document; use std::sync::Arc;
use super::documents::Documents; use std::thread;
use super::documents::DocumentsFilter;
use super::language_server;
use super::language_server::StateSnapshot;
use super::performance::Performance;
use super::tsc;
use super::tsc::TsServer;
use super::urls::uri_parse_unencoded;
use super::urls::url_to_uri;
use super::urls::LspUrlMap;
use crate::graph_util;
use crate::graph_util::enhanced_resolution_error_message;
use crate::lsp::lsp_custom::DiagnosticBatchNotificationParams;
use crate::resolver::CliSloppyImportsResolver;
use crate::resolver::SloppyImportsCachedFs;
use crate::tools::lint::CliLinter;
use crate::tools::lint::CliLinterOptions;
use crate::tools::lint::LintRuleProvider;
use crate::tsc::DiagnosticCategory;
use crate::util::path::to_percent_decoded_str;
use deno_ast::MediaType; use deno_ast::MediaType;
use deno_config::deno_json::LintConfig; use deno_config::deno_json::LintConfig;
@ -48,7 +28,6 @@ use deno_graph::SpecifierError;
use deno_lint::linter::LintConfig as DenoLintConfig; use deno_lint::linter::LintConfig as DenoLintConfig;
use deno_resolver::sloppy_imports::SloppyImportsResolution; use deno_resolver::sloppy_imports::SloppyImportsResolution;
use deno_resolver::sloppy_imports::SloppyImportsResolutionKind; use deno_resolver::sloppy_imports::SloppyImportsResolutionKind;
use deno_runtime::deno_fs::FsSysTraitsAdapter;
use deno_runtime::deno_node; use deno_runtime::deno_node;
use deno_runtime::tokio_util::create_basic_runtime; use deno_runtime::tokio_util::create_basic_runtime;
use deno_semver::jsr::JsrPackageReqReference; use deno_semver::jsr::JsrPackageReqReference;
@ -57,18 +36,39 @@ use deno_semver::package::PackageReq;
use import_map::ImportMap; use import_map::ImportMap;
use import_map::ImportMapError; use import_map::ImportMapError;
use log::error; use log::error;
use std::collections::HashMap;
use std::collections::HashSet;
use std::path::PathBuf;
use std::sync::atomic::AtomicUsize;
use std::sync::Arc;
use std::thread;
use tokio::sync::mpsc; use tokio::sync::mpsc;
use tokio::sync::Mutex; use tokio::sync::Mutex;
use tokio::time::Duration; use tokio::time::Duration;
use tokio_util::sync::CancellationToken; use tokio_util::sync::CancellationToken;
use tower_lsp::lsp_types as lsp; use tower_lsp::lsp_types as lsp;
use super::analysis;
use super::client::Client;
use super::config::Config;
use super::documents;
use super::documents::Document;
use super::documents::Documents;
use super::documents::DocumentsFilter;
use super::language_server;
use super::language_server::StateSnapshot;
use super::performance::Performance;
use super::tsc;
use super::tsc::TsServer;
use super::urls::uri_parse_unencoded;
use super::urls::url_to_uri;
use super::urls::LspUrlMap;
use crate::graph_util;
use crate::graph_util::enhanced_resolution_error_message;
use crate::lsp::lsp_custom::DiagnosticBatchNotificationParams;
use crate::resolver::CliSloppyImportsResolver;
use crate::resolver::SloppyImportsCachedFs;
use crate::sys::CliSys;
use crate::tools::lint::CliLinter;
use crate::tools::lint::CliLinterOptions;
use crate::tools::lint::LintRuleProvider;
use crate::tsc::DiagnosticCategory;
use crate::util::path::to_percent_decoded_str;
#[derive(Debug)] #[derive(Debug)]
pub struct DiagnosticServerUpdateMessage { pub struct DiagnosticServerUpdateMessage {
pub snapshot: Arc<StateSnapshot>, pub snapshot: Arc<StateSnapshot>,
@ -1281,7 +1281,7 @@ impl DenoDiagnostic {
Self::NotInstalledNpm(pkg_req, specifier) => (lsp::DiagnosticSeverity::ERROR, format!("npm package \"{pkg_req}\" is not installed or doesn't exist."), Some(json!({ "specifier": specifier }))), Self::NotInstalledNpm(pkg_req, specifier) => (lsp::DiagnosticSeverity::ERROR, format!("npm package \"{pkg_req}\" is not installed or doesn't exist."), Some(json!({ "specifier": specifier }))),
Self::NoLocal(specifier) => { Self::NoLocal(specifier) => {
let maybe_sloppy_resolution = CliSloppyImportsResolver::new( let maybe_sloppy_resolution = CliSloppyImportsResolver::new(
SloppyImportsCachedFs::new(FsSysTraitsAdapter::new_real()) SloppyImportsCachedFs::new(CliSys::default())
).resolve(specifier, SloppyImportsResolutionKind::Execution); ).resolve(specifier, SloppyImportsResolutionKind::Execution);
let data = maybe_sloppy_resolution.as_ref().map(|res| { let data = maybe_sloppy_resolution.as_ref().map(|res| {
json!({ json!({
@ -1646,6 +1646,12 @@ fn generate_deno_diagnostics(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::sync::Arc;
use deno_config::deno_json::ConfigFile;
use pretty_assertions::assert_eq;
use test_util::TempDir;
use super::*; use super::*;
use crate::lsp::cache::LspCache; use crate::lsp::cache::LspCache;
use crate::lsp::config::Config; use crate::lsp::config::Config;
@ -1656,11 +1662,6 @@ mod tests {
use crate::lsp::language_server::StateSnapshot; use crate::lsp::language_server::StateSnapshot;
use crate::lsp::resolver::LspResolver; use crate::lsp::resolver::LspResolver;
use deno_config::deno_json::ConfigFile;
use pretty_assertions::assert_eq;
use std::sync::Arc;
use test_util::TempDir;
fn mock_config() -> Config { fn mock_config() -> Config {
let root_url = resolve_url("file:///").unwrap(); let root_url = resolve_url("file:///").unwrap();
let root_uri = url_to_uri(&root_url).unwrap(); let root_uri = url_to_uri(&root_url).unwrap();

View file

@ -1,18 +1,17 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use super::cache::calculate_fs_version; use std::borrow::Cow;
use super::cache::LspCache; use std::collections::BTreeMap;
use super::config::Config; use std::collections::HashMap;
use super::resolver::LspResolver; use std::collections::HashSet;
use super::resolver::ScopeDepInfo; use std::fs;
use super::resolver::SingleReferrerGraphResolver; use std::future::Future;
use super::testing::TestCollector; use std::ops::Range;
use super::testing::TestModule; use std::pin::Pin;
use super::text::LineIndex; use std::str::FromStr;
use super::tsc; use std::sync::atomic::AtomicBool;
use super::tsc::AssetDocument; use std::sync::atomic::Ordering;
use std::sync::Arc;
use crate::graph_util::CliJsrUrlProvider;
use dashmap::DashMap; use dashmap::DashMap;
use deno_ast::swc::visit::VisitWith; use deno_ast::swc::visit::VisitWith;
@ -36,20 +35,21 @@ use indexmap::IndexMap;
use indexmap::IndexSet; use indexmap::IndexSet;
use node_resolver::NodeResolutionKind; use node_resolver::NodeResolutionKind;
use node_resolver::ResolutionMode; use node_resolver::ResolutionMode;
use std::borrow::Cow;
use std::collections::BTreeMap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::fs;
use std::future::Future;
use std::ops::Range;
use std::pin::Pin;
use std::str::FromStr;
use std::sync::atomic::AtomicBool;
use std::sync::atomic::Ordering;
use std::sync::Arc;
use tower_lsp::lsp_types as lsp; use tower_lsp::lsp_types as lsp;
use super::cache::calculate_fs_version;
use super::cache::LspCache;
use super::config::Config;
use super::resolver::LspResolver;
use super::resolver::ScopeDepInfo;
use super::resolver::SingleReferrerGraphResolver;
use super::testing::TestCollector;
use super::testing::TestModule;
use super::text::LineIndex;
use super::tsc;
use super::tsc::AssetDocument;
use crate::graph_util::CliJsrUrlProvider;
pub const DOCUMENT_SCHEMES: [&str; 5] = pub const DOCUMENT_SCHEMES: [&str; 5] =
["data", "blob", "file", "http", "https"]; ["data", "blob", "file", "http", "https"];
@ -1754,9 +1754,6 @@ fn bytes_to_content(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use crate::lsp::cache::LspCache;
use deno_config::deno_json::ConfigFile; use deno_config::deno_json::ConfigFile;
use deno_config::deno_json::ConfigParseOptions; use deno_config::deno_json::ConfigParseOptions;
use deno_core::serde_json; use deno_core::serde_json;
@ -1764,6 +1761,9 @@ mod tests {
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use test_util::TempDir; use test_util::TempDir;
use super::*;
use crate::lsp::cache::LspCache;
async fn setup() -> (Documents, LspCache, TempDir) { async fn setup() -> (Documents, LspCache, TempDir) {
let temp_dir = TempDir::new(); let temp_dir = TempDir::new();
temp_dir.create_dir_all(".deno_dir"); temp_dir.create_dir_all(".deno_dir");

View file

@ -1,11 +1,8 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use std::collections::HashMap;
use std::sync::Arc;
use crate::args::jsr_api_url;
use crate::args::jsr_url;
use crate::file_fetcher::CliFileFetcher;
use crate::file_fetcher::TextDecodedFile;
use crate::jsr::partial_jsr_package_version_info_from_slice;
use crate::jsr::JsrFetchResolver;
use dashmap::DashMap; use dashmap::DashMap;
use deno_cache_dir::HttpCache; use deno_cache_dir::HttpCache;
use deno_core::anyhow::anyhow; use deno_core::anyhow::anyhow;
@ -21,11 +18,15 @@ use deno_semver::package::PackageReq;
use deno_semver::StackString; use deno_semver::StackString;
use deno_semver::Version; use deno_semver::Version;
use serde::Deserialize; use serde::Deserialize;
use std::collections::HashMap;
use std::sync::Arc;
use super::config::ConfigData; use super::config::ConfigData;
use super::search::PackageSearchApi; use super::search::PackageSearchApi;
use crate::args::jsr_api_url;
use crate::args::jsr_url;
use crate::file_fetcher::CliFileFetcher;
use crate::file_fetcher::TextDecodedFile;
use crate::jsr::partial_jsr_package_version_info_from_slice;
use crate::jsr::JsrFetchResolver;
/// Keep in sync with `JsrFetchResolver`! /// Keep in sync with `JsrFetchResolver`!
#[derive(Debug)] #[derive(Debug)]

View file

@ -1,4 +1,15 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::env;
use std::fmt::Write as _;
use std::path::PathBuf;
use std::str::FromStr;
use std::sync::Arc;
use deno_ast::MediaType; use deno_ast::MediaType;
use deno_cache_dir::file_fetcher::CacheSetting; use deno_cache_dir::file_fetcher::CacheSetting;
@ -17,7 +28,6 @@ use deno_core::ModuleSpecifier;
use deno_graph::GraphKind; use deno_graph::GraphKind;
use deno_graph::Resolution; use deno_graph::Resolution;
use deno_path_util::url_to_file_path; use deno_path_util::url_to_file_path;
use deno_runtime::deno_fs::FsSysTraitsAdapter;
use deno_runtime::deno_tls::rustls::RootCertStore; use deno_runtime::deno_tls::rustls::RootCertStore;
use deno_runtime::deno_tls::RootCertStoreProvider; use deno_runtime::deno_tls::RootCertStoreProvider;
use deno_semver::jsr::JsrPackageReqReference; use deno_semver::jsr::JsrPackageReqReference;
@ -28,16 +38,6 @@ use node_resolver::NodeResolutionKind;
use node_resolver::ResolutionMode; use node_resolver::ResolutionMode;
use serde::Deserialize; use serde::Deserialize;
use serde_json::from_value; use serde_json::from_value;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::env;
use std::fmt::Write as _;
use std::path::PathBuf;
use std::str::FromStr;
use std::sync::Arc;
use tokio::sync::mpsc::unbounded_channel; use tokio::sync::mpsc::unbounded_channel;
use tokio::sync::mpsc::UnboundedReceiver; use tokio::sync::mpsc::UnboundedReceiver;
use tokio::sync::mpsc::UnboundedSender; use tokio::sync::mpsc::UnboundedSender;
@ -109,6 +109,7 @@ use crate::lsp::config::ConfigWatchedFileType;
use crate::lsp::logging::init_log_file; use crate::lsp::logging::init_log_file;
use crate::lsp::tsc::file_text_changes_to_workspace_edit; use crate::lsp::tsc::file_text_changes_to_workspace_edit;
use crate::lsp::urls::LspUrlKind; use crate::lsp::urls::LspUrlKind;
use crate::sys::CliSys;
use crate::tools::fmt::format_file; use crate::tools::fmt::format_file;
use crate::tools::fmt::format_parsed_source; use crate::tools::fmt::format_parsed_source;
use crate::tools::upgrade::check_for_upgrades_for_lsp; use crate::tools::upgrade::check_for_upgrades_for_lsp;
@ -280,7 +281,7 @@ impl LanguageServer {
.await?; .await?;
graph_util::graph_valid( graph_util::graph_valid(
&graph, &graph,
&FsSysTraitsAdapter(factory.fs().clone()), &CliSys::default(),
&roots, &roots,
graph_util::GraphValidOptions { graph_util::GraphValidOptions {
kind: GraphKind::All, kind: GraphKind::All,
@ -962,6 +963,7 @@ impl Inner {
let file_fetcher = CliFileFetcher::new( let file_fetcher = CliFileFetcher::new(
self.cache.global().clone(), self.cache.global().clone(),
self.http_client_provider.clone(), self.http_client_provider.clone(),
CliSys::default(),
Default::default(), Default::default(),
None, None,
true, true,
@ -3613,7 +3615,7 @@ impl Inner {
let workspace = match config_data { let workspace = match config_data {
Some(d) => d.member_dir.clone(), Some(d) => d.member_dir.clone(),
None => Arc::new(WorkspaceDirectory::discover( None => Arc::new(WorkspaceDirectory::discover(
&FsSysTraitsAdapter::new_real(), &CliSys::default(),
deno_config::workspace::WorkspaceDiscoverStart::Paths(&[ deno_config::workspace::WorkspaceDiscoverStart::Paths(&[
initial_cwd.clone() initial_cwd.clone()
]), ]),
@ -3634,6 +3636,7 @@ impl Inner {
)?), )?),
}; };
let cli_options = CliOptions::new( let cli_options = CliOptions::new(
&CliSys::default(),
Arc::new(Flags { Arc::new(Flags {
internal: InternalFlags { internal: InternalFlags {
cache_path: Some(self.cache.deno_dir().root.clone()), cache_path: Some(self.cache.deno_dir().root.clone()),
@ -3962,10 +3965,11 @@ impl Inner {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use test_util::TempDir; use test_util::TempDir;
use super::*;
#[test] #[test]
fn test_walk_workspace() { fn test_walk_workspace() {
let temp_dir = TempDir::new(); let temp_dir = TempDir::new();

View file

@ -1,8 +1,5 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use chrono::DateTime;
use chrono::Utc;
use deno_core::parking_lot::Mutex;
use std::fs; use std::fs;
use std::io::prelude::*; use std::io::prelude::*;
use std::path::Path; use std::path::Path;
@ -12,6 +9,10 @@ use std::sync::atomic::Ordering;
use std::thread; use std::thread;
use std::time::SystemTime; use std::time::SystemTime;
use chrono::DateTime;
use chrono::Utc;
use deno_core::parking_lot::Mutex;
static LSP_DEBUG_FLAG: AtomicBool = AtomicBool::new(false); static LSP_DEBUG_FLAG: AtomicBool = AtomicBool::new(false);
static LSP_LOG_LEVEL: AtomicUsize = AtomicUsize::new(log::Level::Info as usize); static LSP_LOG_LEVEL: AtomicUsize = AtomicUsize::new(log::Level::Info as usize);
static LSP_WARN_LEVEL: AtomicUsize = static LSP_WARN_LEVEL: AtomicUsize =

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use deno_core::serde::Deserialize; use deno_core::serde::Deserialize;
use deno_core::serde::Serialize; use deno_core::serde::Serialize;

View file

@ -1,16 +1,15 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use deno_core::error::AnyError; use deno_core::error::AnyError;
use deno_core::unsync::spawn; use deno_core::unsync::spawn;
pub use repl::ReplCompletionItem;
pub use repl::ReplLanguageServer;
use tower_lsp::LspService; use tower_lsp::LspService;
use tower_lsp::Server; use tower_lsp::Server;
use self::diagnostics::should_send_diagnostic_batch_index_notifications;
use crate::lsp::language_server::LanguageServer; use crate::lsp::language_server::LanguageServer;
use crate::util::sync::AsyncFlag; use crate::util::sync::AsyncFlag;
pub use repl::ReplCompletionItem;
pub use repl::ReplLanguageServer;
use self::diagnostics::should_send_diagnostic_batch_index_notifications;
mod analysis; mod analysis;
mod cache; mod cache;

View file

@ -1,4 +1,6 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use std::sync::Arc;
use dashmap::DashMap; use dashmap::DashMap;
use deno_core::anyhow::anyhow; use deno_core::anyhow::anyhow;
@ -8,15 +10,13 @@ use deno_npm::npm_rc::NpmRc;
use deno_semver::package::PackageNv; use deno_semver::package::PackageNv;
use deno_semver::Version; use deno_semver::Version;
use serde::Deserialize; use serde::Deserialize;
use std::sync::Arc;
use super::search::PackageSearchApi;
use crate::args::npm_registry_url; use crate::args::npm_registry_url;
use crate::file_fetcher::CliFileFetcher; use crate::file_fetcher::CliFileFetcher;
use crate::file_fetcher::TextDecodedFile; use crate::file_fetcher::TextDecodedFile;
use crate::npm::NpmFetchResolver; use crate::npm::NpmFetchResolver;
use super::search::PackageSearchApi;
#[derive(Debug)] #[derive(Debug)]
pub struct CliNpmSearchApi { pub struct CliNpmSearchApi {
file_fetcher: Arc<CliFileFetcher>, file_fetcher: Arc<CliFileFetcher>,

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use std::time::Duration; use std::time::Duration;
@ -52,10 +52,12 @@ fn is_process_active(process_id: u32) -> bool {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::is_process_active;
use std::process::Command; use std::process::Command;
use test_util::deno_exe_path; use test_util::deno_exe_path;
use super::is_process_active;
#[test] #[test]
fn process_active() { fn process_active() {
// launch a long running process // launch a long running process

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
// The logic of this module is heavily influenced by path-to-regexp at: // The logic of this module is heavily influenced by path-to-regexp at:
// https://github.com/pillarjs/path-to-regexp/ which is licensed as follows: // https://github.com/pillarjs/path-to-regexp/ which is licensed as follows:
@ -26,15 +26,16 @@
// THE SOFTWARE. // THE SOFTWARE.
// //
use std::collections::HashMap;
use std::fmt;
use std::fmt::Write as _;
use std::iter::Peekable;
use deno_core::anyhow::anyhow; use deno_core::anyhow::anyhow;
use deno_core::error::AnyError; use deno_core::error::AnyError;
use fancy_regex::Regex as FancyRegex; use fancy_regex::Regex as FancyRegex;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use regex::Regex; use regex::Regex;
use std::collections::HashMap;
use std::fmt;
use std::fmt::Write as _;
use std::iter::Peekable;
static ESCAPE_STRING_RE: Lazy<Regex> = static ESCAPE_STRING_RE: Lazy<Regex> =
lazy_regex::lazy_regex!(r"([.+*?=^!:${}()\[\]|/\\])"); lazy_regex::lazy_regex!(r"([.+*?=^!:${}()\[\]|/\\])");

View file

@ -1,9 +1,5 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use deno_core::parking_lot::Mutex;
use deno_core::serde::Deserialize;
use deno_core::serde::Serialize;
use deno_core::serde_json::json;
use std::cmp; use std::cmp;
use std::collections::HashMap; use std::collections::HashMap;
use std::collections::VecDeque; use std::collections::VecDeque;
@ -12,6 +8,11 @@ use std::sync::Arc;
use std::time::Duration; use std::time::Duration;
use std::time::Instant; use std::time::Instant;
use deno_core::parking_lot::Mutex;
use deno_core::serde::Deserialize;
use deno_core::serde::Serialize;
use deno_core::serde_json::json;
use super::logging::lsp_debug; use super::logging::lsp_debug;
#[derive(Debug, Deserialize, Serialize, PartialEq, Eq)] #[derive(Debug, Deserialize, Serialize, PartialEq, Eq)]

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
// The logic of this module is heavily influenced by // The logic of this module is heavily influenced by
// https://github.com/microsoft/vscode/blob/main/extensions/typescript-language-features/src/languageFeatures/refactor.ts // https://github.com/microsoft/vscode/blob/main/extensions/typescript-language-features/src/languageFeatures/refactor.ts

View file

@ -1,24 +1,9 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use super::completions::IMPORT_COMMIT_CHARS; use std::borrow::Cow;
use super::logging::lsp_log; use std::collections::HashMap;
use super::path_to_regex::parse; use std::path::PathBuf;
use super::path_to_regex::string_to_regex; use std::sync::Arc;
use super::path_to_regex::Compiler;
use super::path_to_regex::Key;
use super::path_to_regex::MatchResult;
use super::path_to_regex::Matcher;
use super::path_to_regex::StringOrNumber;
use super::path_to_regex::StringOrVec;
use super::path_to_regex::Token;
use crate::cache::GlobalHttpCache;
use crate::cache::HttpCache;
use crate::file_fetcher::CliFileFetcher;
use crate::file_fetcher::FetchOptions;
use crate::file_fetcher::FetchPermissionsOptionRef;
use crate::file_fetcher::TextDecodedFile;
use crate::http_util::HttpClientProvider;
use deno_cache_dir::file_fetcher::CacheSetting; use deno_cache_dir::file_fetcher::CacheSetting;
use deno_core::anyhow::anyhow; use deno_core::anyhow::anyhow;
@ -32,15 +17,30 @@ use deno_core::url::Position;
use deno_core::url::Url; use deno_core::url::Url;
use deno_core::ModuleSpecifier; use deno_core::ModuleSpecifier;
use deno_graph::Dependency; use deno_graph::Dependency;
use deno_runtime::deno_fs::FsSysTraitsAdapter;
use log::error; use log::error;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use std::borrow::Cow;
use std::collections::HashMap;
use std::path::PathBuf;
use std::sync::Arc;
use tower_lsp::lsp_types as lsp; use tower_lsp::lsp_types as lsp;
use super::completions::IMPORT_COMMIT_CHARS;
use super::logging::lsp_log;
use super::path_to_regex::parse;
use super::path_to_regex::string_to_regex;
use super::path_to_regex::Compiler;
use super::path_to_regex::Key;
use super::path_to_regex::MatchResult;
use super::path_to_regex::Matcher;
use super::path_to_regex::StringOrNumber;
use super::path_to_regex::StringOrVec;
use super::path_to_regex::Token;
use crate::cache::GlobalHttpCache;
use crate::cache::HttpCache;
use crate::file_fetcher::CliFileFetcher;
use crate::file_fetcher::FetchOptions;
use crate::file_fetcher::FetchPermissionsOptionRef;
use crate::file_fetcher::TextDecodedFile;
use crate::http_util::HttpClientProvider;
use crate::sys::CliSys;
const CONFIG_PATH: &str = "/.well-known/deno-import-intellisense.json"; const CONFIG_PATH: &str = "/.well-known/deno-import-intellisense.json";
const COMPONENT: &percent_encoding::AsciiSet = &percent_encoding::CONTROLS const COMPONENT: &percent_encoding::AsciiSet = &percent_encoding::CONTROLS
.add(b' ') .add(b' ')
@ -430,13 +430,12 @@ impl ModuleRegistry {
http_client_provider: Arc<HttpClientProvider>, http_client_provider: Arc<HttpClientProvider>,
) -> Self { ) -> Self {
// the http cache should always be the global one for registry completions // the http cache should always be the global one for registry completions
let http_cache = Arc::new(GlobalHttpCache::new( let http_cache =
FsSysTraitsAdapter::new_real(), Arc::new(GlobalHttpCache::new(CliSys::default(), location.clone()));
location.clone(),
));
let file_fetcher = CliFileFetcher::new( let file_fetcher = CliFileFetcher::new(
http_cache.clone(), http_cache.clone(),
http_client_provider, http_client_provider,
CliSys::default(),
Default::default(), Default::default(),
None, None,
true, true,
@ -1129,9 +1128,10 @@ FetchPermissionsOptionRef::AllowAll,
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use test_util::TempDir; use test_util::TempDir;
use super::*;
#[test] #[test]
fn test_validate_registry_configuration() { fn test_validate_registry_configuration() {
assert!(validate_config(&RegistryConfigurationJson { assert!(validate_config(&RegistryConfigurationJson {

View file

@ -1,4 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use std::collections::HashMap; use std::collections::HashMap;

View file

@ -1,4 +1,11 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use std::borrow::Cow;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::HashMap;
use std::collections::HashSet;
use std::sync::Arc;
use dashmap::DashMap; use dashmap::DashMap;
use deno_ast::MediaType; use deno_ast::MediaType;
@ -19,9 +26,6 @@ use deno_resolver::cjs::IsCjsResolutionMode;
use deno_resolver::npm::NpmReqResolverOptions; use deno_resolver::npm::NpmReqResolverOptions;
use deno_resolver::DenoResolverOptions; use deno_resolver::DenoResolverOptions;
use deno_resolver::NodeAndNpmReqResolver; use deno_resolver::NodeAndNpmReqResolver;
use deno_runtime::deno_fs::FsSysTraitsAdapter;
use deno_runtime::deno_node::NodeResolver;
use deno_runtime::deno_node::PackageJsonResolver;
use deno_runtime::deno_node::RealIsBuiltInNodeModuleChecker; use deno_runtime::deno_node::RealIsBuiltInNodeModuleChecker;
use deno_semver::jsr::JsrPackageReqReference; use deno_semver::jsr::JsrPackageReqReference;
use deno_semver::npm::NpmPackageReqReference; use deno_semver::npm::NpmPackageReqReference;
@ -31,12 +35,6 @@ use indexmap::IndexMap;
use node_resolver::InNpmPackageChecker; use node_resolver::InNpmPackageChecker;
use node_resolver::NodeResolutionKind; use node_resolver::NodeResolutionKind;
use node_resolver::ResolutionMode; use node_resolver::ResolutionMode;
use std::borrow::Cow;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::HashMap;
use std::collections::HashSet;
use std::sync::Arc;
use super::cache::LspCache; use super::cache::LspCache;
use super::jsr::JsrCacheResolver; use super::jsr::JsrCacheResolver;
@ -51,6 +49,8 @@ use crate::http_util::HttpClientProvider;
use crate::lsp::config::Config; use crate::lsp::config::Config;
use crate::lsp::config::ConfigData; use crate::lsp::config::ConfigData;
use crate::lsp::logging::lsp_warn; use crate::lsp::logging::lsp_warn;
use crate::node::CliNodeResolver;
use crate::node::CliPackageJsonResolver;
use crate::npm::create_cli_npm_resolver_for_lsp; use crate::npm::create_cli_npm_resolver_for_lsp;
use crate::npm::CliByonmNpmResolverCreateOptions; use crate::npm::CliByonmNpmResolverCreateOptions;
use crate::npm::CliManagedInNpmPkgCheckerCreateOptions; use crate::npm::CliManagedInNpmPkgCheckerCreateOptions;
@ -66,6 +66,7 @@ use crate::resolver::CliResolver;
use crate::resolver::CliResolverOptions; use crate::resolver::CliResolverOptions;
use crate::resolver::IsCjsResolver; use crate::resolver::IsCjsResolver;
use crate::resolver::WorkerCliNpmGraphResolver; use crate::resolver::WorkerCliNpmGraphResolver;
use crate::sys::CliSys;
use crate::tsc::into_specifier_and_media_type; use crate::tsc::into_specifier_and_media_type;
use crate::util::progress_bar::ProgressBar; use crate::util::progress_bar::ProgressBar;
use crate::util::progress_bar::ProgressBarStyle; use crate::util::progress_bar::ProgressBarStyle;
@ -77,9 +78,9 @@ struct LspScopeResolver {
is_cjs_resolver: Arc<IsCjsResolver>, is_cjs_resolver: Arc<IsCjsResolver>,
jsr_resolver: Option<Arc<JsrCacheResolver>>, jsr_resolver: Option<Arc<JsrCacheResolver>>,
npm_resolver: Option<Arc<dyn CliNpmResolver>>, npm_resolver: Option<Arc<dyn CliNpmResolver>>,
node_resolver: Option<Arc<NodeResolver>>, node_resolver: Option<Arc<CliNodeResolver>>,
npm_pkg_req_resolver: Option<Arc<CliNpmReqResolver>>, npm_pkg_req_resolver: Option<Arc<CliNpmReqResolver>>,
pkg_json_resolver: Arc<PackageJsonResolver>, pkg_json_resolver: Arc<CliPackageJsonResolver>,
redirect_resolver: Option<Arc<RedirectResolver>>, redirect_resolver: Option<Arc<RedirectResolver>>,
graph_imports: Arc<IndexMap<ModuleSpecifier, GraphImport>>, graph_imports: Arc<IndexMap<ModuleSpecifier, GraphImport>>,
dep_info: Arc<Mutex<Arc<ScopeDepInfo>>>, dep_info: Arc<Mutex<Arc<ScopeDepInfo>>>,
@ -383,7 +384,7 @@ impl LspResolver {
pub fn pkg_json_resolver( pub fn pkg_json_resolver(
&self, &self,
referrer: &ModuleSpecifier, referrer: &ModuleSpecifier,
) -> &Arc<PackageJsonResolver> { ) -> &Arc<CliPackageJsonResolver> {
let resolver = self.get_scope_resolver(Some(referrer)); let resolver = self.get_scope_resolver(Some(referrer));
&resolver.pkg_json_resolver &resolver.pkg_json_resolver
} }
@ -591,22 +592,22 @@ struct ResolverFactoryServices {
cli_resolver: Deferred<Arc<CliResolver>>, cli_resolver: Deferred<Arc<CliResolver>>,
in_npm_pkg_checker: Deferred<Arc<dyn InNpmPackageChecker>>, in_npm_pkg_checker: Deferred<Arc<dyn InNpmPackageChecker>>,
is_cjs_resolver: Deferred<Arc<IsCjsResolver>>, is_cjs_resolver: Deferred<Arc<IsCjsResolver>>,
node_resolver: Deferred<Option<Arc<NodeResolver>>>, node_resolver: Deferred<Option<Arc<CliNodeResolver>>>,
npm_pkg_req_resolver: Deferred<Option<Arc<CliNpmReqResolver>>>, npm_pkg_req_resolver: Deferred<Option<Arc<CliNpmReqResolver>>>,
npm_resolver: Option<Arc<dyn CliNpmResolver>>, npm_resolver: Option<Arc<dyn CliNpmResolver>>,
} }
struct ResolverFactory<'a> { struct ResolverFactory<'a> {
config_data: Option<&'a Arc<ConfigData>>, config_data: Option<&'a Arc<ConfigData>>,
pkg_json_resolver: Arc<PackageJsonResolver>, pkg_json_resolver: Arc<CliPackageJsonResolver>,
sys: FsSysTraitsAdapter, sys: CliSys,
services: ResolverFactoryServices, services: ResolverFactoryServices,
} }
impl<'a> ResolverFactory<'a> { impl<'a> ResolverFactory<'a> {
pub fn new(config_data: Option<&'a Arc<ConfigData>>) -> Self { pub fn new(config_data: Option<&'a Arc<ConfigData>>) -> Self {
let sys = FsSysTraitsAdapter::new_real(); let sys = CliSys::default();
let pkg_json_resolver = Arc::new(PackageJsonResolver::new(sys.clone())); let pkg_json_resolver = Arc::new(CliPackageJsonResolver::new(sys.clone()));
Self { Self {
config_data, config_data,
pkg_json_resolver, pkg_json_resolver,
@ -621,7 +622,7 @@ impl<'a> ResolverFactory<'a> {
cache: &LspCache, cache: &LspCache,
) { ) {
let enable_byonm = self.config_data.map(|d| d.byonm).unwrap_or(false); let enable_byonm = self.config_data.map(|d| d.byonm).unwrap_or(false);
let sys = FsSysTraitsAdapter::new_real(); let sys = CliSys::default();
let options = if enable_byonm { let options = if enable_byonm {
CliNpmResolverCreateOptions::Byonm(CliByonmNpmResolverCreateOptions { CliNpmResolverCreateOptions::Byonm(CliByonmNpmResolverCreateOptions {
sys, sys,
@ -656,7 +657,7 @@ impl<'a> ResolverFactory<'a> {
} }
None => CliNpmResolverManagedSnapshotOption::Specified(None), None => CliNpmResolverManagedSnapshotOption::Specified(None),
}, },
sys: FsSysTraitsAdapter::new_real(), sys: CliSys::default(),
npm_cache_dir, npm_cache_dir,
// Use an "only" cache setting in order to make the // Use an "only" cache setting in order to make the
// user do an explicit "cache" command and prevent // user do an explicit "cache" command and prevent
@ -729,7 +730,7 @@ impl<'a> ResolverFactory<'a> {
}) })
} }
pub fn pkg_json_resolver(&self) -> &Arc<PackageJsonResolver> { pub fn pkg_json_resolver(&self) -> &Arc<CliPackageJsonResolver> {
&self.pkg_json_resolver &self.pkg_json_resolver
} }
@ -770,13 +771,13 @@ impl<'a> ResolverFactory<'a> {
}) })
} }
pub fn node_resolver(&self) -> Option<&Arc<NodeResolver>> { pub fn node_resolver(&self) -> Option<&Arc<CliNodeResolver>> {
self self
.services .services
.node_resolver .node_resolver
.get_or_init(|| { .get_or_init(|| {
let npm_resolver = self.services.npm_resolver.as_ref()?; let npm_resolver = self.services.npm_resolver.as_ref()?;
Some(Arc::new(NodeResolver::new( Some(Arc::new(CliNodeResolver::new(
self.in_npm_pkg_checker().clone(), self.in_npm_pkg_checker().clone(),
RealIsBuiltInNodeModuleChecker, RealIsBuiltInNodeModuleChecker,
npm_resolver.clone().into_npm_pkg_folder_resolver(), npm_resolver.clone().into_npm_pkg_folder_resolver(),

View file

@ -1,9 +1,10 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2025 the Deno authors. MIT license.
use std::sync::Arc;
use deno_core::error::AnyError; use deno_core::error::AnyError;
use deno_semver::package::PackageNv; use deno_semver::package::PackageNv;
use deno_semver::Version; use deno_semver::Version;
use std::sync::Arc;
#[async_trait::async_trait] #[async_trait::async_trait]
pub trait PackageSearchApi { pub trait PackageSearchApi {
@ -15,10 +16,12 @@ pub trait PackageSearchApi {
#[cfg(test)] #[cfg(test)]
pub mod tests { pub mod tests {
use super::*;
use deno_core::anyhow::anyhow;
use std::collections::BTreeMap; use std::collections::BTreeMap;
use deno_core::anyhow::anyhow;
use super::*;
#[derive(Debug, Default)] #[derive(Debug, Default)]
pub struct TestPackageSearchApi { pub struct TestPackageSearchApi {
/// [(name -> [(version -> [export])])] /// [(name -> [(version -> [export])])]

Some files were not shown because too many files have changed in this diff Show more