mirror of
https://github.com/denoland/deno.git
synced 2025-02-01 12:16:11 -05:00
Merge remote-tracking branch 'upstream/main' into check-workspace-member-compiler-options
This commit is contained in:
commit
60de9fa6b1
1197 changed files with 5219 additions and 4838 deletions
|
@ -13,7 +13,7 @@
|
|||
},
|
||||
"exec": {
|
||||
"commands": [{
|
||||
"command": "rustfmt --config imports_granularity=item",
|
||||
"command": "rustfmt --config imports_granularity=item --config group_imports=StdExternalCrate",
|
||||
"exts": ["rs"]
|
||||
}]
|
||||
},
|
||||
|
|
2
.github/mtime_cache/action.js
vendored
2
.github/mtime_cache/action.js
vendored
|
@ -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
|
||||
// Node.js v20.x to run actions, so this is Node code and not Deno code.
|
||||
|
||||
|
|
30
.github/workflows/ci.generate.ts
vendored
30
.github/workflows/ci.generate.ts
vendored
|
@ -1,5 +1,5 @@
|
|||
#!/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";
|
||||
|
||||
// Bump this number when you want to purge the cache.
|
||||
|
@ -716,6 +716,19 @@ const ci = {
|
|||
"df -h",
|
||||
].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
|
||||
// of our build mode
|
||||
|
@ -762,10 +775,11 @@ const ci = {
|
|||
"cd target/release",
|
||||
"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",
|
||||
"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",
|
||||
"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"),
|
||||
},
|
||||
{
|
||||
|
@ -790,8 +804,9 @@ const ci = {
|
|||
"cd target/release",
|
||||
"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",
|
||||
"strip denort",
|
||||
"zip -r denort-${{ matrix.arch }}-apple-darwin.zip denort",
|
||||
"cd ../release-slim",
|
||||
"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",
|
||||
]
|
||||
.join("\n"),
|
||||
|
@ -808,7 +823,8 @@ const ci = {
|
|||
run: [
|
||||
"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",
|
||||
"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",
|
||||
].join("\n"),
|
||||
},
|
||||
|
|
23
.github/workflows/ci.yml
vendored
23
.github/workflows/ci.yml
vendored
|
@ -419,6 +419,15 @@ jobs:
|
|||
df -h
|
||||
cargo build --release --locked --all-targets
|
||||
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
|
||||
if: '!(matrix.skip) && (matrix.job == ''test'')'
|
||||
run: 'target/${{ matrix.profile }}/deno eval "console.log(1+2)" | grep 3'
|
||||
|
@ -448,10 +457,11 @@ jobs:
|
|||
cd target/release
|
||||
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
|
||||
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
|
||||
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)
|
||||
if: |-
|
||||
!(matrix.skip) && (matrix.os == 'macos' &&
|
||||
|
@ -467,8 +477,9 @@ jobs:
|
|||
cd target/release
|
||||
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
|
||||
strip denort
|
||||
zip -r denort-${{ matrix.arch }}-apple-darwin.zip denort
|
||||
cd ../release-slim
|
||||
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
|
||||
- name: Pre-release (windows)
|
||||
if: |-
|
||||
|
@ -480,7 +491,7 @@ jobs:
|
|||
run: |-
|
||||
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
|
||||
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
|
||||
- name: Upload canary to dl.deno.land
|
||||
if: |-
|
||||
|
|
10
Cargo.lock
generated
10
Cargo.lock
generated
|
@ -1736,14 +1736,12 @@ dependencies = [
|
|||
"deno_path_util 0.3.0",
|
||||
"deno_permissions",
|
||||
"filetime",
|
||||
"getrandom",
|
||||
"junction",
|
||||
"libc",
|
||||
"nix",
|
||||
"rand",
|
||||
"rayon",
|
||||
"serde",
|
||||
"sys_traits",
|
||||
"thiserror 2.0.3",
|
||||
"winapi",
|
||||
"windows-sys 0.59.0",
|
||||
|
@ -2041,6 +2039,7 @@ dependencies = [
|
|||
"sm3",
|
||||
"spki",
|
||||
"stable_deref_trait",
|
||||
"sys_traits",
|
||||
"thiserror 2.0.3",
|
||||
"tokio",
|
||||
"tokio-eld",
|
||||
|
@ -2260,6 +2259,7 @@ dependencies = [
|
|||
"serde",
|
||||
"signal-hook",
|
||||
"signal-hook-registry",
|
||||
"sys_traits",
|
||||
"tempfile",
|
||||
"test_server",
|
||||
"thiserror 2.0.3",
|
||||
|
@ -7679,12 +7679,14 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "sys_traits"
|
||||
version = "0.1.1"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a5a12729b699487bb50163466e87be7197871d83d04cc6815d430cf7c893bbd7"
|
||||
checksum = "6683465f4e1d8fd75069cbc36c646258c05b7d8d6676bcb5d71968b99b7d5ae2"
|
||||
dependencies = [
|
||||
"filetime",
|
||||
"getrandom",
|
||||
"libc",
|
||||
"parking_lot",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
# Copyright 2018-2025 the Deno authors. MIT license.
|
||||
|
||||
[workspace]
|
||||
resolver = "2"
|
||||
|
@ -194,7 +194,7 @@ slab = "0.4"
|
|||
smallvec = "1.8"
|
||||
socket2 = { version = "0.5.3", features = ["all"] }
|
||||
spki = "0.7.2"
|
||||
sys_traits = "=0.1.1"
|
||||
sys_traits = "=0.1.4"
|
||||
tar = "=0.4.40"
|
||||
tempfile = "3.4.0"
|
||||
termcolor = "1.1.3"
|
||||
|
@ -252,6 +252,11 @@ incremental = true
|
|||
lto = true
|
||||
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
|
||||
[profile.release-with-debug]
|
||||
inherits = "release"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
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
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
# Copyright 2018-2025 the Deno authors. MIT license.
|
||||
|
||||
[package]
|
||||
name = "deno_bench_util"
|
||||
|
|
|
@ -7,7 +7,6 @@ use deno_bench_util::bench_js_sync;
|
|||
use deno_bench_util::bench_or_profile;
|
||||
use deno_bench_util::bencher::benchmark_group;
|
||||
use deno_bench_util::bencher::Bencher;
|
||||
|
||||
use deno_core::Extension;
|
||||
|
||||
#[op2]
|
||||
|
|
|
@ -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_or_profile;
|
||||
|
|
|
@ -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 deno_core::v8;
|
||||
use deno_core::Extension;
|
||||
|
|
|
@ -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 profiling;
|
||||
|
||||
|
|
|
@ -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::StaticBenchFn;
|
||||
use bencher::TestDescAndFn;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
# Copyright 2018-2025 the Deno authors. MIT license.
|
||||
|
||||
[package]
|
||||
name = "deno"
|
||||
|
@ -158,7 +158,7 @@ shell-escape = "=0.1.5"
|
|||
spki = { version = "0.7", features = ["pem"] }
|
||||
sqlformat = "=0.3.2"
|
||||
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
|
||||
tempfile.workspace = true
|
||||
text-size = "=1.1.0"
|
||||
|
@ -187,6 +187,7 @@ nix.workspace = true
|
|||
[dev-dependencies]
|
||||
deno_bench_util.workspace = true
|
||||
pretty_assertions.workspace = true
|
||||
sys_traits = { workspace = true, features = ["memory"] }
|
||||
test_util.workspace = true
|
||||
|
||||
[package.metadata.winres]
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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::collections::HashSet;
|
||||
|
@ -43,11 +43,10 @@ use log::Level;
|
|||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::args::resolve_no_prompt;
|
||||
use crate::util::fs::canonicalize_path;
|
||||
|
||||
use super::flags_net;
|
||||
use super::jsr_url;
|
||||
use crate::args::resolve_no_prompt;
|
||||
use crate::util::fs::canonicalize_path;
|
||||
|
||||
#[derive(Clone, Debug, Default, Eq, PartialEq)]
|
||||
pub enum ConfigFlag {
|
||||
|
@ -6067,9 +6066,10 @@ pub fn resolve_urls(urls: Vec<String>) -> Vec<String> {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
use super::*;
|
||||
|
||||
/// Creates vector of strings, Vec<String>
|
||||
macro_rules! svec {
|
||||
($($x:expr),* $(,)?) => (vec![$($x.to_string().into()),*]);
|
||||
|
|
|
@ -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_runtime::deno_permissions::NetDescriptor;
|
||||
use std::net::IpAddr;
|
||||
use std::str::FromStr;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct ParsePortError(String);
|
||||
|
|
|
@ -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::serde_json;
|
||||
|
|
|
@ -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::path::PathBuf;
|
||||
|
@ -10,21 +10,19 @@ use deno_core::error::AnyError;
|
|||
use deno_core::parking_lot::Mutex;
|
||||
use deno_core::parking_lot::MutexGuard;
|
||||
use deno_core::serde_json;
|
||||
use deno_lockfile::Lockfile;
|
||||
use deno_lockfile::WorkspaceMemberConfig;
|
||||
use deno_package_json::PackageJsonDepValue;
|
||||
use deno_path_util::fs::atomic_write_file_with_retries;
|
||||
use deno_runtime::deno_fs::FsSysTraitsAdapter;
|
||||
use deno_runtime::deno_node::PackageJson;
|
||||
use deno_semver::jsr::JsrDepPackageReq;
|
||||
|
||||
use crate::args::deno_json::import_map_deps;
|
||||
use crate::cache;
|
||||
use crate::Flags;
|
||||
|
||||
use crate::args::DenoSubcommand;
|
||||
use crate::args::InstallFlags;
|
||||
|
||||
use deno_lockfile::Lockfile;
|
||||
use crate::cache;
|
||||
use crate::sys::CliSys;
|
||||
use crate::Flags;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct CliLockfileReadFromPathOptions {
|
||||
|
@ -36,6 +34,7 @@ pub struct CliLockfileReadFromPathOptions {
|
|||
|
||||
#[derive(Debug)]
|
||||
pub struct CliLockfile {
|
||||
sys: CliSys,
|
||||
lockfile: Mutex<Lockfile>,
|
||||
pub filename: PathBuf,
|
||||
frozen: bool,
|
||||
|
@ -92,7 +91,7 @@ impl CliLockfile {
|
|||
// do an atomic write to reduce the chance of multiple deno
|
||||
// processes corrupting the file
|
||||
atomic_write_file_with_retries(
|
||||
&FsSysTraitsAdapter::new_real(),
|
||||
&self.sys,
|
||||
&lockfile.filename,
|
||||
&bytes,
|
||||
cache::CACHE_PERM,
|
||||
|
@ -103,6 +102,7 @@ impl CliLockfile {
|
|||
}
|
||||
|
||||
pub fn discover(
|
||||
sys: &CliSys,
|
||||
flags: &Flags,
|
||||
workspace: &Workspace,
|
||||
maybe_external_import_map: Option<&serde_json::Value>,
|
||||
|
@ -165,11 +165,14 @@ impl CliLockfile {
|
|||
.unwrap_or(false)
|
||||
});
|
||||
|
||||
let lockfile = Self::read_from_path(CliLockfileReadFromPathOptions {
|
||||
let lockfile = Self::read_from_path(
|
||||
sys,
|
||||
CliLockfileReadFromPathOptions {
|
||||
file_path,
|
||||
frozen,
|
||||
skip_write: flags.internal.lockfile_skip_write,
|
||||
})?;
|
||||
},
|
||||
)?;
|
||||
|
||||
// initialize the lockfile with the workspace's configuration
|
||||
let root_url = workspace.root_dir();
|
||||
|
@ -225,6 +228,7 @@ impl CliLockfile {
|
|||
}
|
||||
|
||||
pub fn read_from_path(
|
||||
sys: &CliSys,
|
||||
opts: CliLockfileReadFromPathOptions,
|
||||
) -> Result<CliLockfile, AnyError> {
|
||||
let lockfile = match std::fs::read_to_string(&opts.file_path) {
|
||||
|
@ -243,6 +247,7 @@ impl CliLockfile {
|
|||
}
|
||||
};
|
||||
Ok(CliLockfile {
|
||||
sys: sys.clone(),
|
||||
filename: lockfile.filename.clone(),
|
||||
lockfile: Mutex::new(lockfile),
|
||||
frozen: opts.frozen,
|
||||
|
|
159
cli/args/mod.rs
159
cli/args/mod.rs
|
@ -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;
|
||||
mod flags;
|
||||
|
@ -7,71 +7,6 @@ mod import_map;
|
|||
mod lockfile;
|
||||
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::collections::BTreeSet;
|
||||
use std::collections::HashMap;
|
||||
|
@ -84,18 +19,81 @@ use std::net::SocketAddr;
|
|||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
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 thiserror::Error;
|
||||
|
||||
use crate::cache::DenoDirProvider;
|
||||
use crate::file_fetcher::CliFileFetcher;
|
||||
use crate::sys::CliSys;
|
||||
use crate::util::fs::canonicalize_path_maybe_not_exists;
|
||||
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 {
|
||||
static NPM_REGISTRY_DEFAULT_URL: Lazy<Url> = Lazy::new(|| {
|
||||
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
|
||||
// home dir and then merge them.
|
||||
// 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) {
|
||||
Ok(Some((source, path))) => {
|
||||
return try_to_parse_npmrc(source, &path).map(|r| (r, Some(path)));
|
||||
|
@ -739,6 +737,7 @@ pub struct CliOptions {
|
|||
npmrc: Arc<ResolvedNpmRc>,
|
||||
maybe_lockfile: Option<Arc<CliLockfile>>,
|
||||
maybe_external_import_map: Option<(PathBuf, serde_json::Value)>,
|
||||
sys: CliSys,
|
||||
overrides: CliOptionOverrides,
|
||||
pub start_dir: Arc<WorkspaceDirectory>,
|
||||
pub deno_dir_provider: Arc<DenoDirProvider>,
|
||||
|
@ -748,6 +747,7 @@ pub struct CliOptions {
|
|||
impl CliOptions {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
sys: &CliSys,
|
||||
flags: Arc<Flags>,
|
||||
initial_cwd: PathBuf,
|
||||
maybe_lockfile: Option<Arc<CliLockfile>>,
|
||||
|
@ -773,8 +773,10 @@ impl CliOptions {
|
|||
}
|
||||
|
||||
let maybe_lockfile = maybe_lockfile.filter(|_| !force_global_cache);
|
||||
let deno_dir_provider =
|
||||
Arc::new(DenoDirProvider::new(flags.internal.cache_path.clone()));
|
||||
let deno_dir_provider = Arc::new(DenoDirProvider::new(
|
||||
sys.clone(),
|
||||
flags.internal.cache_path.clone(),
|
||||
));
|
||||
let maybe_node_modules_folder = resolve_node_modules_folder(
|
||||
&initial_cwd,
|
||||
&flags,
|
||||
|
@ -796,11 +798,12 @@ impl CliOptions {
|
|||
maybe_external_import_map,
|
||||
start_dir,
|
||||
deno_dir_provider,
|
||||
sys: sys.clone(),
|
||||
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 =
|
||||
std::env::current_dir().with_context(|| "Failed getting cwd.")?;
|
||||
let maybe_vendor_override = flags.vendor.map(|v| match v {
|
||||
|
@ -844,7 +847,7 @@ impl CliOptions {
|
|||
ConfigFlag::Discover => {
|
||||
if let Some(start_paths) = flags.config_path_args(&initial_cwd) {
|
||||
WorkspaceDirectory::discover(
|
||||
&FsSysTraitsAdapter::new_real(),
|
||||
sys,
|
||||
WorkspaceDiscoverStart::Paths(&start_paths),
|
||||
&resolve_workspace_discover_options(),
|
||||
)?
|
||||
|
@ -855,7 +858,7 @@ impl CliOptions {
|
|||
ConfigFlag::Path(path) => {
|
||||
let config_path = normalize_path(initial_cwd.join(path));
|
||||
WorkspaceDirectory::discover(
|
||||
&FsSysTraitsAdapter::new_real(),
|
||||
sys,
|
||||
WorkspaceDiscoverStart::ConfigFile(&config_path),
|
||||
&resolve_workspace_discover_options(),
|
||||
)?
|
||||
|
@ -879,6 +882,7 @@ impl CliOptions {
|
|||
};
|
||||
|
||||
let maybe_lock_file = CliLockfile::discover(
|
||||
sys,
|
||||
&flags,
|
||||
&start_dir.workspace,
|
||||
external_import_map.as_ref().map(|(_, v)| v),
|
||||
|
@ -887,6 +891,7 @@ impl CliOptions {
|
|||
log::debug!("Finished config loading.");
|
||||
|
||||
Self::new(
|
||||
sys,
|
||||
flags,
|
||||
initial_cwd,
|
||||
maybe_lock_file.map(Arc::new),
|
||||
|
@ -911,11 +916,13 @@ impl CliOptions {
|
|||
None
|
||||
};
|
||||
let lockfile = CliLockfile::discover(
|
||||
&self.sys,
|
||||
&self.flags,
|
||||
&start_dir.workspace,
|
||||
external_import_map.as_ref().map(|(_, v)| v),
|
||||
)?;
|
||||
Self::new(
|
||||
&self.sys,
|
||||
self.flags.clone(),
|
||||
self.initial_cwd().to_path_buf(),
|
||||
lockfile.map(Arc::new),
|
||||
|
|
|
@ -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::sync::Arc;
|
||||
|
|
|
@ -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 cache = await caches.open(cacheName);
|
||||
|
|
|
@ -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 () => {
|
||||
await new Deno.Command("echo", { args: ["deno"] }).output();
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
Deno.bench("date_now", { n: 5e5 }, () => {
|
||||
|
|
|
@ -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
|
||||
|
||||
let [total, count] = typeof Deno !== "undefined"
|
||||
|
|
|
@ -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 current = "";
|
||||
|
|
|
@ -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 */
|
||||
import results from "./deno.json" assert { type: "json" };
|
||||
|
|
|
@ -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
|
||||
|
||||
let [total, count] = typeof Deno !== "undefined"
|
||||
|
|
|
@ -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_json;
|
||||
use deno_core::serde_json::json;
|
||||
use deno_core::serde_json::Value;
|
||||
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::PathRef;
|
||||
use tower_lsp::lsp_types as lsp;
|
||||
|
|
|
@ -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_main;
|
||||
|
|
|
@ -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_stderr)]
|
||||
|
||||
use deno_core::error::AnyError;
|
||||
use deno_core::serde_json;
|
||||
use deno_core::serde_json::Value;
|
||||
use std::collections::HashMap;
|
||||
use std::convert::From;
|
||||
use std::env;
|
||||
|
@ -15,6 +12,10 @@ use std::path::PathBuf;
|
|||
use std::process::Command;
|
||||
use std::process::Stdio;
|
||||
use std::time::SystemTime;
|
||||
|
||||
use deno_core::error::AnyError;
|
||||
use deno_core::serde_json;
|
||||
use deno_core::serde_json::Value;
|
||||
use test_util::PathRef;
|
||||
|
||||
mod lsp;
|
||||
|
|
|
@ -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";
|
||||
|
||||
|
|
|
@ -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 { createRequire } from "module";
|
||||
|
|
|
@ -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
|
||||
|
||||
const queueMicrotask = globalThis.queueMicrotask || process.nextTick;
|
||||
|
|
|
@ -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
|
||||
|
||||
let [total, count] = typeof Deno !== "undefined"
|
||||
|
|
|
@ -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
|
||||
|
||||
#include <stdlib.h>
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 response = new TextEncoder().encode(
|
||||
|
|
|
@ -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
|
||||
|
||||
const queueMicrotask = globalThis.queueMicrotask || process.nextTick;
|
||||
|
|
|
@ -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
|
||||
|
||||
const queueMicrotask = globalThis.queueMicrotask || process.nextTick;
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
const queueMicrotask = globalThis.queueMicrotask || process.nextTick;
|
||||
|
|
14
cli/build.rs
14
cli/build.rs
|
@ -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::path::PathBuf;
|
||||
|
@ -8,16 +8,18 @@ use deno_runtime::*;
|
|||
mod shared;
|
||||
|
||||
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::AnyError;
|
||||
use deno_core::op2;
|
||||
use deno_core::OpState;
|
||||
use serde::Serialize;
|
||||
use std::collections::HashMap;
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
|
|
11
cli/cache/cache_db.rs
vendored
11
cli/cache/cache_db.rs
vendored
|
@ -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::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::Params;
|
||||
use once_cell::sync::OnceCell;
|
||||
use std::io::IsTerminal;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
use super::FastInsecureHasher;
|
||||
|
||||
|
|
2
cli/cache/caches.rs
vendored
2
cli/cache/caches.rs
vendored
|
@ -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::sync::Arc;
|
||||
|
|
9
cli/cache/check.rs
vendored
9
cli/cache/check.rs
vendored
|
@ -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::CacheDBConfiguration;
|
||||
use super::cache_db::CacheDBHash;
|
||||
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 {
|
||||
table_initializer: concat!(
|
||||
|
|
5
cli/cache/code_cache.rs
vendored
5
cli/cache/code_cache.rs
vendored
|
@ -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;
|
||||
|
||||
|
@ -7,12 +7,11 @@ use deno_core::error::AnyError;
|
|||
use deno_runtime::code_cache;
|
||||
use deno_runtime::deno_webstorage::rusqlite::params;
|
||||
|
||||
use crate::worker::CliCodeCache;
|
||||
|
||||
use super::cache_db::CacheDB;
|
||||
use super::cache_db::CacheDBConfiguration;
|
||||
use super::cache_db::CacheDBHash;
|
||||
use super::cache_db::CacheFailure;
|
||||
use crate::worker::CliCodeCache;
|
||||
|
||||
pub static CODE_CACHE_DB: CacheDBConfiguration = CacheDBConfiguration {
|
||||
table_initializer: concat!(
|
||||
|
|
2
cli/cache/common.rs
vendored
2
cli/cache/common.rs
vendored
|
@ -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;
|
||||
|
||||
|
|
20
cli/cache/deno_dir.rs
vendored
20
cli/cache/deno_dir.rs
vendored
|
@ -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 once_cell::sync::OnceCell;
|
||||
|
||||
use super::DiskCache;
|
||||
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
use crate::sys::CliSys;
|
||||
|
||||
/// Lazily creates the deno dir which might be useful in scenarios
|
||||
/// where functionality wants to continue if the DENO_DIR can't be created.
|
||||
pub struct DenoDirProvider {
|
||||
sys: CliSys,
|
||||
maybe_custom_root: Option<PathBuf>,
|
||||
deno_dir: OnceCell<Result<DenoDir, DenoDirResolutionError>>,
|
||||
}
|
||||
|
||||
impl DenoDirProvider {
|
||||
pub fn new(maybe_custom_root: Option<PathBuf>) -> Self {
|
||||
pub fn new(sys: CliSys, maybe_custom_root: Option<PathBuf>) -> Self {
|
||||
Self {
|
||||
sys,
|
||||
maybe_custom_root,
|
||||
deno_dir: Default::default(),
|
||||
}
|
||||
|
@ -26,7 +29,9 @@ impl DenoDirProvider {
|
|||
pub fn get_or_create(&self) -> Result<&DenoDir, DenoDirResolutionError> {
|
||||
self
|
||||
.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()
|
||||
.map_err(|err| match err {
|
||||
DenoDirResolutionError::NoCacheOrHomeDir => {
|
||||
|
@ -53,6 +58,7 @@ pub struct DenoDir {
|
|||
|
||||
impl DenoDir {
|
||||
pub fn new(
|
||||
sys: CliSys,
|
||||
maybe_custom_root: Option<PathBuf>,
|
||||
) -> Result<Self, deno_cache_dir::DenoDirResolutionError> {
|
||||
let root = deno_cache_dir::resolve_deno_dir(
|
||||
|
@ -64,7 +70,7 @@ impl DenoDir {
|
|||
|
||||
let deno_dir = Self {
|
||||
root,
|
||||
gen_cache: DiskCache::new(&gen_path),
|
||||
gen_cache: DiskCache::new(sys, &gen_path),
|
||||
};
|
||||
|
||||
Ok(deno_dir)
|
||||
|
|
39
cli/cache/disk_cache.rs
vendored
39
cli/cache/disk_cache.rs
vendored
|
@ -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::fs;
|
||||
use std::path::Component;
|
||||
|
@ -15,16 +8,26 @@ use std::path::PathBuf;
|
|||
use std::path::Prefix;
|
||||
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)]
|
||||
pub struct DiskCache {
|
||||
sys: CliSys,
|
||||
pub location: PathBuf,
|
||||
}
|
||||
|
||||
impl DiskCache {
|
||||
/// `location` must be an absolute path.
|
||||
pub fn new(location: &Path) -> Self {
|
||||
pub fn new(sys: CliSys, location: &Path) -> Self {
|
||||
assert!(location.is_absolute());
|
||||
Self {
|
||||
sys,
|
||||
location: location.to_owned(),
|
||||
}
|
||||
}
|
||||
|
@ -121,25 +124,21 @@ impl DiskCache {
|
|||
|
||||
pub fn set(&self, filename: &Path, data: &[u8]) -> std::io::Result<()> {
|
||||
let path = self.location.join(filename);
|
||||
atomic_write_file_with_retries(
|
||||
&FsSysTraitsAdapter::new_real(),
|
||||
&path,
|
||||
data,
|
||||
CACHE_PERM,
|
||||
)
|
||||
atomic_write_file_with_retries(&self.sys, &path, data, CACHE_PERM)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use test_util::TempDir;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_set_get_cache_file() {
|
||||
let temp_dir = TempDir::new();
|
||||
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");
|
||||
cache.set(&path, b"hello").unwrap();
|
||||
assert_eq!(cache.get(&path).unwrap(), b"hello");
|
||||
|
@ -153,7 +152,7 @@ mod tests {
|
|||
PathBuf::from("/deno_dir/")
|
||||
};
|
||||
|
||||
let cache = DiskCache::new(&cache_location);
|
||||
let cache = DiskCache::new(CliSys::default(), &cache_location);
|
||||
|
||||
let mut test_cases = vec![
|
||||
(
|
||||
|
@ -209,7 +208,7 @@ mod tests {
|
|||
} else {
|
||||
"/foo"
|
||||
};
|
||||
let cache = DiskCache::new(&PathBuf::from(p));
|
||||
let cache = DiskCache::new(CliSys::default(), &PathBuf::from(p));
|
||||
|
||||
let mut test_cases = vec![
|
||||
(
|
||||
|
@ -257,7 +256,7 @@ mod tests {
|
|||
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"];
|
||||
|
||||
|
|
6
cli/cache/emit.rs
vendored
6
cli/cache/emit.rs
vendored
|
@ -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;
|
||||
|
||||
|
@ -160,11 +160,13 @@ mod test {
|
|||
use test_util::TempDir;
|
||||
|
||||
use super::*;
|
||||
use crate::sys::CliSys;
|
||||
|
||||
#[test]
|
||||
pub fn emit_cache_general_use() {
|
||||
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 {
|
||||
disk_cache: disk_cache.clone(),
|
||||
file_serializer: EmitFileSerializer {
|
||||
|
|
2
cli/cache/fast_check.rs
vendored
2
cli/cache/fast_check.rs
vendored
|
@ -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_graph::FastCheckCacheItem;
|
||||
|
|
2
cli/cache/incremental.rs
vendored
2
cli/cache/incremental.rs
vendored
|
@ -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::path::Path;
|
||||
|
|
37
cli/cache/mod.rs
vendored
37
cli/cache/mod.rs
vendored
|
@ -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 crate::file_fetcher::CliFetchNoFollowErrorKind;
|
||||
use crate::file_fetcher::CliFileFetcher;
|
||||
use crate::file_fetcher::FetchNoFollowOptions;
|
||||
use crate::file_fetcher::FetchPermissionsOptionRef;
|
||||
use std::collections::HashMap;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
use deno_ast::MediaType;
|
||||
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::LoadResponse;
|
||||
use deno_graph::source::Loader;
|
||||
use deno_runtime::deno_fs::FsSysTraitsAdapter;
|
||||
use deno_runtime::deno_permissions::PermissionsContainer;
|
||||
use node_resolver::InNpmPackageChecker;
|
||||
use std::collections::HashMap;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::args::jsr_url;
|
||||
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 caches;
|
||||
|
@ -44,6 +45,8 @@ pub use caches::Caches;
|
|||
pub use check::TypeCheckCache;
|
||||
pub use code_cache::CodeCache;
|
||||
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::DenoDirProvider;
|
||||
pub use disk_cache::DiskCache;
|
||||
|
@ -55,13 +58,9 @@ pub use node::NodeAnalysisCache;
|
|||
pub use parsed_source::LazyGraphSourceParser;
|
||||
pub use parsed_source::ParsedSourceCache;
|
||||
|
||||
/// Permissions used to save a file in the disk caches.
|
||||
pub use deno_cache_dir::CACHE_PERM;
|
||||
|
||||
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 type GlobalHttpCache = deno_cache_dir::GlobalHttpCache<CliSys>;
|
||||
pub type LocalHttpCache = deno_cache_dir::LocalHttpCache<CliSys>;
|
||||
pub type LocalLspHttpCache = deno_cache_dir::LocalLspHttpCache<CliSys>;
|
||||
pub use deno_cache_dir::HttpCache;
|
||||
|
||||
pub struct FetchCacherOptions {
|
||||
|
@ -80,7 +79,7 @@ pub struct FetchCacher {
|
|||
in_npm_pkg_checker: Arc<dyn InNpmPackageChecker>,
|
||||
module_info_cache: Arc<ModuleInfoCache>,
|
||||
permissions: PermissionsContainer,
|
||||
sys: FsSysTraitsAdapter,
|
||||
sys: CliSys,
|
||||
is_deno_publish: bool,
|
||||
cache_info_enabled: bool,
|
||||
}
|
||||
|
@ -91,7 +90,7 @@ impl FetchCacher {
|
|||
global_http_cache: Arc<GlobalHttpCache>,
|
||||
in_npm_pkg_checker: Arc<dyn InNpmPackageChecker>,
|
||||
module_info_cache: Arc<ModuleInfoCache>,
|
||||
sys: FsSysTraitsAdapter,
|
||||
sys: CliSys,
|
||||
options: FetchCacherOptions,
|
||||
) -> Self {
|
||||
Self {
|
||||
|
|
2
cli/cache/module_info.rs
vendored
2
cli/cache/module_info.rs
vendored
|
@ -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;
|
||||
|
||||
|
|
5
cli/cache/node.rs
vendored
5
cli/cache/node.rs
vendored
|
@ -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::serde_json;
|
||||
use deno_runtime::deno_webstorage::rusqlite::params;
|
||||
|
||||
use crate::node::CliCjsAnalysis;
|
||||
|
||||
use super::cache_db::CacheDB;
|
||||
use super::cache_db::CacheDBConfiguration;
|
||||
use super::cache_db::CacheFailure;
|
||||
use super::CacheDBHash;
|
||||
use crate::node::CliCjsAnalysis;
|
||||
|
||||
pub static NODE_ANALYSIS_CACHE_DB: CacheDBConfiguration =
|
||||
CacheDBConfiguration {
|
||||
|
|
2
cli/cache/parsed_source.rs
vendored
2
cli/cache/parsed_source.rs
vendored
|
@ -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::sync::Arc;
|
||||
|
|
|
@ -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/>
|
||||
use deno_core::serde_json::Value;
|
||||
|
|
|
@ -4,6 +4,7 @@ disallowed-methods = [
|
|||
]
|
||||
disallowed-types = [
|
||||
{ path = "reqwest::Client", reason = "use crate::http_util::HttpClient instead" },
|
||||
{ path = "sys_traits::impls::RealSys", reason = "use crate::sys::CliSys instead" },
|
||||
]
|
||||
ignore-interior-mutability = [
|
||||
"lsp_types::Uri",
|
||||
|
|
13
cli/emit.rs
13
cli/emit.rs
|
@ -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 crate::cache::FastInsecureHasher;
|
||||
use crate::cache::ParsedSourceCache;
|
||||
use crate::resolver::CjsTracker;
|
||||
use std::sync::Arc;
|
||||
|
||||
use deno_ast::EmittedSourceText;
|
||||
use deno_ast::ModuleKind;
|
||||
|
@ -21,7 +18,11 @@ use deno_core::ModuleSpecifier;
|
|||
use deno_graph::MediaType;
|
||||
use deno_graph::Module;
|
||||
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)]
|
||||
pub struct Emitter {
|
||||
|
|
|
@ -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:
|
||||
//! - AnyError: a generic wrapper that can encapsulate any type of error.
|
||||
|
|
146
cli/factory.rs
146
cli/factory.rs
|
@ -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::get_root_cert_store;
|
||||
|
@ -32,6 +70,8 @@ use crate::module_loader::CliModuleLoaderFactory;
|
|||
use crate::module_loader::ModuleLoadPreparer;
|
||||
use crate::node::CliCjsCodeAnalyzer;
|
||||
use crate::node::CliNodeCodeTranslator;
|
||||
use crate::node::CliNodeResolver;
|
||||
use crate::node::CliPackageJsonResolver;
|
||||
use crate::npm::create_cli_npm_resolver;
|
||||
use crate::npm::create_in_npm_pkg_checker;
|
||||
use crate::npm::CliByonmNpmResolverCreateOptions;
|
||||
|
@ -49,7 +89,8 @@ use crate::resolver::CliResolverOptions;
|
|||
use crate::resolver::CliSloppyImportsResolver;
|
||||
use crate::resolver::NpmModuleLoader;
|
||||
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::TypeChecker;
|
||||
use crate::tools::coverage::CoverageCollector;
|
||||
|
@ -64,46 +105,6 @@ use crate::util::progress_bar::ProgressBar;
|
|||
use crate::util::progress_bar::ProgressBarStyle;
|
||||
use crate::worker::CliMainWorkerFactory;
|
||||
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 {
|
||||
cell: OnceCell<RootCertStore>,
|
||||
|
@ -211,13 +212,14 @@ struct CliFactoryServices {
|
|||
module_info_cache: Deferred<Arc<ModuleInfoCache>>,
|
||||
module_load_preparer: Deferred<Arc<ModuleLoadPreparer>>,
|
||||
node_code_translator: Deferred<Arc<CliNodeCodeTranslator>>,
|
||||
node_resolver: Deferred<Arc<NodeResolver>>,
|
||||
node_resolver: Deferred<Arc<CliNodeResolver>>,
|
||||
npm_cache_dir: Deferred<Arc<NpmCacheDir>>,
|
||||
npm_req_resolver: Deferred<Arc<CliNpmReqResolver>>,
|
||||
npm_resolver: Deferred<Arc<dyn CliNpmResolver>>,
|
||||
parsed_source_cache: Deferred<Arc<ParsedSourceCache>>,
|
||||
permission_desc_parser: Deferred<Arc<RuntimePermissionDescriptorParser>>,
|
||||
pkg_json_resolver: Deferred<Arc<PackageJsonResolver>>,
|
||||
permission_desc_parser:
|
||||
Deferred<Arc<RuntimePermissionDescriptorParser<CliSys>>>,
|
||||
pkg_json_resolver: Deferred<Arc<CliPackageJsonResolver>>,
|
||||
resolver: Deferred<Arc<CliResolver>>,
|
||||
root_cert_store_provider: Deferred<Arc<dyn RootCertStoreProvider>>,
|
||||
root_permissions_container: Deferred<PermissionsContainer>,
|
||||
|
@ -267,7 +269,7 @@ impl CliFactory {
|
|||
|
||||
pub fn cli_options(&self) -> Result<&Arc<CliOptions>, AnyError> {
|
||||
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> {
|
||||
self.services.global_http_cache.get_or_try_init(|| {
|
||||
Ok(Arc::new(GlobalHttpCache::new(
|
||||
FsSysTraitsAdapter(self.fs().clone()),
|
||||
self.sys(),
|
||||
self.deno_dir()?.remote_folder_path(),
|
||||
)))
|
||||
})
|
||||
|
@ -368,6 +370,7 @@ impl CliFactory {
|
|||
Ok(Arc::new(CliFileFetcher::new(
|
||||
self.http_cache()?.clone(),
|
||||
self.http_client_provider().clone(),
|
||||
self.sys(),
|
||||
self.blob_store().clone(),
|
||||
Some(self.text_only_progress_bar().clone()),
|
||||
!cli_options.no_remote(),
|
||||
|
@ -378,7 +381,11 @@ impl CliFactory {
|
|||
}
|
||||
|
||||
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(
|
||||
|
@ -404,11 +411,10 @@ impl CliFactory {
|
|||
|
||||
pub fn npm_cache_dir(&self) -> Result<&Arc<NpmCacheDir>, AnyError> {
|
||||
self.services.npm_cache_dir.get_or_try_init(|| {
|
||||
let fs = self.fs();
|
||||
let global_path = self.deno_dir()?.npm_folder_path();
|
||||
let cli_options = self.cli_options()?;
|
||||
Ok(Arc::new(NpmCacheDir::new(
|
||||
&FsSysTraitsAdapter(fs.clone()),
|
||||
&self.sys(),
|
||||
global_path,
|
||||
cli_options.npmrc().get_all_known_registries_urls(),
|
||||
)))
|
||||
|
@ -423,12 +429,11 @@ impl CliFactory {
|
|||
.npm_resolver
|
||||
.get_or_try_init_async(
|
||||
async {
|
||||
let fs = self.fs();
|
||||
let cli_options = self.cli_options()?;
|
||||
create_cli_npm_resolver(if cli_options.use_byonm() {
|
||||
CliNpmResolverCreateOptions::Byonm(
|
||||
CliByonmNpmResolverCreateOptions {
|
||||
sys: FsSysTraitsAdapter(fs.clone()),
|
||||
sys: self.sys(),
|
||||
pkg_json_resolver: self.pkg_json_resolver().clone(),
|
||||
root_node_modules_dir: Some(
|
||||
match cli_options.node_modules_dir_path() {
|
||||
|
@ -452,7 +457,7 @@ impl CliFactory {
|
|||
cli_options.workspace(),
|
||||
),
|
||||
),
|
||||
sys: FsSysTraitsAdapter(self.fs().clone()),
|
||||
sys: self.sys(),
|
||||
snapshot: match cli_options.resolve_npm_resolution_snapshot()? {
|
||||
Some(snapshot) => {
|
||||
CliNpmResolverManagedSnapshotOption::Specified(Some(
|
||||
|
@ -499,7 +504,7 @@ impl CliFactory {
|
|||
.get_or_try_init(|| {
|
||||
Ok(self.cli_options()?.unstable_sloppy_imports().then(|| {
|
||||
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
|
||||
.services
|
||||
.node_resolver
|
||||
.get_or_try_init_async(
|
||||
async {
|
||||
Ok(Arc::new(NodeResolver::new(
|
||||
Ok(Arc::new(CliNodeResolver::new(
|
||||
self.in_npm_pkg_checker()?.clone(),
|
||||
RealIsBuiltInNodeModuleChecker,
|
||||
self
|
||||
|
@ -675,7 +680,7 @@ impl CliFactory {
|
|||
.clone()
|
||||
.into_npm_pkg_folder_resolver(),
|
||||
self.pkg_json_resolver().clone(),
|
||||
FsSysTraitsAdapter(self.fs().clone()),
|
||||
self.sys(),
|
||||
)))
|
||||
}
|
||||
.boxed_local(),
|
||||
|
@ -711,7 +716,7 @@ impl CliFactory {
|
|||
.clone()
|
||||
.into_npm_pkg_folder_resolver(),
|
||||
self.pkg_json_resolver().clone(),
|
||||
FsSysTraitsAdapter(self.fs().clone()),
|
||||
self.sys(),
|
||||
)))
|
||||
})
|
||||
.await
|
||||
|
@ -727,7 +732,7 @@ impl CliFactory {
|
|||
let npm_resolver = self.npm_resolver().await?;
|
||||
Ok(Arc::new(CliNpmReqResolver::new(NpmReqResolverOptions {
|
||||
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(),
|
||||
node_resolver: self.node_resolver().await?.clone(),
|
||||
npm_req_resolver: npm_resolver.clone().into_npm_req_resolver(),
|
||||
|
@ -736,12 +741,11 @@ impl CliFactory {
|
|||
.await
|
||||
}
|
||||
|
||||
pub fn pkg_json_resolver(&self) -> &Arc<PackageJsonResolver> {
|
||||
self.services.pkg_json_resolver.get_or_init(|| {
|
||||
Arc::new(PackageJsonResolver::new(FsSysTraitsAdapter(
|
||||
self.fs().clone(),
|
||||
)))
|
||||
})
|
||||
pub fn pkg_json_resolver(&self) -> &Arc<CliPackageJsonResolver> {
|
||||
self
|
||||
.services
|
||||
.pkg_json_resolver
|
||||
.get_or_init(|| Arc::new(CliPackageJsonResolver::new(self.sys())))
|
||||
}
|
||||
|
||||
pub async fn type_checker(&self) -> Result<&Arc<TypeChecker>, AnyError> {
|
||||
|
@ -787,7 +791,7 @@ impl CliFactory {
|
|||
self.parsed_source_cache().clone(),
|
||||
self.resolver().await?.clone(),
|
||||
self.root_permissions_container()?.clone(),
|
||||
FsSysTraitsAdapter(self.fs().clone()),
|
||||
self.sys(),
|
||||
)))
|
||||
})
|
||||
.await
|
||||
|
@ -877,10 +881,9 @@ impl CliFactory {
|
|||
|
||||
pub fn permission_desc_parser(
|
||||
&self,
|
||||
) -> Result<&Arc<RuntimePermissionDescriptorParser>, AnyError> {
|
||||
) -> Result<&Arc<RuntimePermissionDescriptorParser<CliSys>>, AnyError> {
|
||||
self.services.permission_desc_parser.get_or_try_init(|| {
|
||||
let fs = self.fs().clone();
|
||||
Ok(Arc::new(RuntimePermissionDescriptorParser::new(fs)))
|
||||
Ok(Arc::new(RuntimePermissionDescriptorParser::new(self.sys())))
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -987,7 +990,7 @@ impl CliFactory {
|
|||
),
|
||||
self.parsed_source_cache().clone(),
|
||||
self.resolver().await?.clone(),
|
||||
FsSysTraitsAdapter(self.fs().clone()),
|
||||
self.sys(),
|
||||
)),
|
||||
node_resolver.clone(),
|
||||
npm_resolver.clone(),
|
||||
|
@ -995,6 +998,7 @@ impl CliFactory {
|
|||
self.root_cert_store_provider().clone(),
|
||||
self.root_permissions_container()?.clone(),
|
||||
StorageKeyResolver::from_options(cli_options),
|
||||
self.sys(),
|
||||
cli_options.sub_command().clone(),
|
||||
self.create_cli_main_worker_options()?,
|
||||
self.cli_options()?.otel_config(),
|
||||
|
@ -1151,7 +1155,7 @@ impl WorkspaceDirFilesFactory {
|
|||
|
||||
pub fn permission_desc_parser(
|
||||
&self,
|
||||
) -> Result<&Arc<RuntimePermissionDescriptorParser>, AnyError> {
|
||||
) -> Result<&Arc<RuntimePermissionDescriptorParser<CliSys>>, AnyError> {
|
||||
self.cli_factory.permission_desc_parser()
|
||||
}
|
||||
|
||||
|
|
|
@ -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::collections::HashMap;
|
||||
|
@ -24,7 +24,6 @@ use deno_core::url::Url;
|
|||
use deno_core::ModuleSpecifier;
|
||||
use deno_error::JsError;
|
||||
use deno_graph::source::LoaderChecksum;
|
||||
use deno_runtime::deno_fs::FsSysTraitsAdapter;
|
||||
use deno_runtime::deno_permissions::CheckSpecifierKind;
|
||||
use deno_runtime::deno_permissions::PermissionCheckError;
|
||||
use deno_runtime::deno_permissions::PermissionsContainer;
|
||||
|
@ -38,6 +37,7 @@ use crate::cache::HttpCache;
|
|||
use crate::colors;
|
||||
use crate::http_util::get_response_body_with_progress;
|
||||
use crate::http_util::HttpClientProvider;
|
||||
use crate::sys::CliSys;
|
||||
use crate::util::progress_bar::ProgressBar;
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||
|
@ -267,7 +267,7 @@ pub struct FetchNoFollowOptions<'a> {
|
|||
|
||||
type DenoCacheDirFileFetcher = deno_cache_dir::file_fetcher::FileFetcher<
|
||||
BlobStoreAdapter,
|
||||
FsSysTraitsAdapter,
|
||||
CliSys,
|
||||
HttpClientAdapter,
|
||||
>;
|
||||
|
||||
|
@ -279,9 +279,11 @@ pub struct CliFileFetcher {
|
|||
}
|
||||
|
||||
impl CliFileFetcher {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
http_cache: Arc<dyn HttpCache>,
|
||||
http_client_provider: Arc<HttpClientProvider>,
|
||||
sys: CliSys,
|
||||
blob_store: Arc<BlobStore>,
|
||||
progress_bar: Option<ProgressBar>,
|
||||
allow_remote: bool,
|
||||
|
@ -289,7 +291,6 @@ impl CliFileFetcher {
|
|||
download_log_level: log::Level,
|
||||
) -> Self {
|
||||
let memory_files = Arc::new(MemoryFiles::default());
|
||||
let sys = FsSysTraitsAdapter::new_real();
|
||||
let auth_tokens = AuthTokens::new_from_sys(&sys);
|
||||
let file_fetcher = DenoCacheDirFileFetcher::new(
|
||||
BlobStoreAdapter(blob_store),
|
||||
|
@ -497,10 +498,6 @@ fn validate_scheme(specifier: &Url) -> Result<(), UnsupportedSchemeError> {
|
|||
|
||||
#[cfg(test)]
|
||||
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::HttpClient;
|
||||
use deno_core::resolve_url;
|
||||
|
@ -508,6 +505,10 @@ mod tests {
|
|||
use deno_runtime::deno_web::InMemoryBlobPart;
|
||||
use test_util::TempDir;
|
||||
|
||||
use super::*;
|
||||
use crate::cache::GlobalHttpCache;
|
||||
use crate::http_util::HttpClientProvider;
|
||||
|
||||
fn setup(
|
||||
cache_setting: CacheSetting,
|
||||
maybe_temp_dir: Option<TempDir>,
|
||||
|
@ -538,13 +539,11 @@ mod tests {
|
|||
let temp_dir = maybe_temp_dir.unwrap_or_default();
|
||||
let location = temp_dir.path().join("remote").to_path_buf();
|
||||
let blob_store: Arc<BlobStore> = Default::default();
|
||||
let cache = Arc::new(GlobalHttpCache::new(
|
||||
FsSysTraitsAdapter::new_real(),
|
||||
location,
|
||||
));
|
||||
let cache = Arc::new(GlobalHttpCache::new(CliSys::default(), location));
|
||||
let file_fetcher = CliFileFetcher::new(
|
||||
cache.clone(),
|
||||
Arc::new(HttpClientProvider::new(None, None)),
|
||||
CliSys::default(),
|
||||
blob_store.clone(),
|
||||
None,
|
||||
true,
|
||||
|
@ -754,11 +753,9 @@ mod tests {
|
|||
// invocation and indicates to "cache bust".
|
||||
let location = temp_dir.path().join("remote").to_path_buf();
|
||||
let file_fetcher = CliFileFetcher::new(
|
||||
Arc::new(GlobalHttpCache::new(
|
||||
FsSysTraitsAdapter::new_real(),
|
||||
location,
|
||||
)),
|
||||
Arc::new(GlobalHttpCache::new(CliSys::default(), location)),
|
||||
Arc::new(HttpClientProvider::new(None, None)),
|
||||
CliSys::default(),
|
||||
Default::default(),
|
||||
None,
|
||||
true,
|
||||
|
@ -783,14 +780,13 @@ mod tests {
|
|||
let specifier =
|
||||
resolve_url("http://localhost:4545/subdir/mismatch_ext.ts").unwrap();
|
||||
|
||||
let http_cache = Arc::new(GlobalHttpCache::new(
|
||||
FsSysTraitsAdapter::new_real(),
|
||||
location.clone(),
|
||||
));
|
||||
let http_cache =
|
||||
Arc::new(GlobalHttpCache::new(CliSys::default(), location.clone()));
|
||||
let file_modified_01 = {
|
||||
let file_fetcher = CliFileFetcher::new(
|
||||
http_cache.clone(),
|
||||
Arc::new(HttpClientProvider::new(None, None)),
|
||||
CliSys::default(),
|
||||
Default::default(),
|
||||
None,
|
||||
true,
|
||||
|
@ -810,11 +806,9 @@ mod tests {
|
|||
|
||||
let file_modified_02 = {
|
||||
let file_fetcher = CliFileFetcher::new(
|
||||
Arc::new(GlobalHttpCache::new(
|
||||
FsSysTraitsAdapter::new_real(),
|
||||
location,
|
||||
)),
|
||||
Arc::new(GlobalHttpCache::new(CliSys::default(), location)),
|
||||
Arc::new(HttpClientProvider::new(None, None)),
|
||||
CliSys::default(),
|
||||
Default::default(),
|
||||
None,
|
||||
true,
|
||||
|
@ -940,15 +934,14 @@ mod tests {
|
|||
resolve_url("http://localhost:4548/subdir/mismatch_ext.ts").unwrap();
|
||||
let redirected_specifier =
|
||||
resolve_url("http://localhost:4546/subdir/mismatch_ext.ts").unwrap();
|
||||
let http_cache = Arc::new(GlobalHttpCache::new(
|
||||
FsSysTraitsAdapter::new_real(),
|
||||
location.clone(),
|
||||
));
|
||||
let http_cache =
|
||||
Arc::new(GlobalHttpCache::new(CliSys::default(), location.clone()));
|
||||
|
||||
let metadata_file_modified_01 = {
|
||||
let file_fetcher = CliFileFetcher::new(
|
||||
http_cache.clone(),
|
||||
Arc::new(HttpClientProvider::new(None, None)),
|
||||
CliSys::default(),
|
||||
Default::default(),
|
||||
None,
|
||||
true,
|
||||
|
@ -971,6 +964,7 @@ mod tests {
|
|||
let file_fetcher = CliFileFetcher::new(
|
||||
http_cache.clone(),
|
||||
Arc::new(HttpClientProvider::new(None, None)),
|
||||
CliSys::default(),
|
||||
Default::default(),
|
||||
None,
|
||||
true,
|
||||
|
@ -1075,11 +1069,9 @@ mod tests {
|
|||
let temp_dir = TempDir::new();
|
||||
let location = temp_dir.path().join("remote").to_path_buf();
|
||||
let file_fetcher = CliFileFetcher::new(
|
||||
Arc::new(GlobalHttpCache::new(
|
||||
FsSysTraitsAdapter::new_real(),
|
||||
location,
|
||||
)),
|
||||
Arc::new(GlobalHttpCache::new(CliSys::default(), location)),
|
||||
Arc::new(HttpClientProvider::new(None, None)),
|
||||
CliSys::default(),
|
||||
Default::default(),
|
||||
None,
|
||||
false,
|
||||
|
@ -1113,11 +1105,9 @@ mod tests {
|
|||
let temp_dir = TempDir::new();
|
||||
let location = temp_dir.path().join("remote").to_path_buf();
|
||||
let file_fetcher_01 = CliFileFetcher::new(
|
||||
Arc::new(GlobalHttpCache::new(
|
||||
FsSysTraitsAdapter::new_real(),
|
||||
location.clone(),
|
||||
)),
|
||||
Arc::new(GlobalHttpCache::new(CliSys::default(), location.clone())),
|
||||
Arc::new(HttpClientProvider::new(None, None)),
|
||||
CliSys::default(),
|
||||
Default::default(),
|
||||
None,
|
||||
true,
|
||||
|
@ -1125,11 +1115,9 @@ mod tests {
|
|||
log::Level::Info,
|
||||
);
|
||||
let file_fetcher_02 = CliFileFetcher::new(
|
||||
Arc::new(GlobalHttpCache::new(
|
||||
FsSysTraitsAdapter::new_real(),
|
||||
location,
|
||||
)),
|
||||
Arc::new(GlobalHttpCache::new(CliSys::default(), location)),
|
||||
Arc::new(HttpClientProvider::new(None, None)),
|
||||
CliSys::default(),
|
||||
Default::default(),
|
||||
None,
|
||||
true,
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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::ops::Deref;
|
||||
|
@ -27,7 +27,6 @@ use deno_graph::ResolutionError;
|
|||
use deno_graph::SpecifierError;
|
||||
use deno_graph::WorkspaceFastCheckOption;
|
||||
use deno_resolver::sloppy_imports::SloppyImportsResolutionKind;
|
||||
use deno_runtime::deno_fs::FsSysTraitsAdapter;
|
||||
use deno_runtime::deno_node;
|
||||
use deno_runtime::deno_permissions::PermissionsContainer;
|
||||
use deno_semver::jsr::JsrDepPackageReq;
|
||||
|
@ -55,6 +54,7 @@ use crate::resolver::CjsTracker;
|
|||
use crate::resolver::CliResolver;
|
||||
use crate::resolver::CliSloppyImportsResolver;
|
||||
use crate::resolver::SloppyImportsCachedFs;
|
||||
use crate::sys::CliSys;
|
||||
use crate::tools::check;
|
||||
use crate::tools::check::TypeChecker;
|
||||
use crate::util::file_watcher::WatcherCommunicator;
|
||||
|
@ -78,7 +78,7 @@ pub struct GraphValidOptions {
|
|||
/// for the CLI.
|
||||
pub fn graph_valid(
|
||||
graph: &ModuleGraph,
|
||||
sys: &FsSysTraitsAdapter,
|
||||
sys: &CliSys,
|
||||
roots: &[ModuleSpecifier],
|
||||
options: GraphValidOptions,
|
||||
) -> Result<(), AnyError> {
|
||||
|
@ -138,7 +138,7 @@ pub struct GraphWalkErrorsOptions {
|
|||
/// and enhances them with CLI information.
|
||||
pub fn graph_walk_errors<'a>(
|
||||
graph: &'a ModuleGraph,
|
||||
sys: &'a FsSysTraitsAdapter,
|
||||
sys: &'a CliSys,
|
||||
roots: &'a [ModuleSpecifier],
|
||||
options: GraphWalkErrorsOptions,
|
||||
) -> impl Iterator<Item = AnyError> + 'a {
|
||||
|
@ -441,7 +441,7 @@ pub struct ModuleGraphBuilder {
|
|||
parsed_source_cache: Arc<ParsedSourceCache>,
|
||||
resolver: Arc<CliResolver>,
|
||||
root_permissions_container: PermissionsContainer,
|
||||
sys: FsSysTraitsAdapter,
|
||||
sys: CliSys,
|
||||
}
|
||||
|
||||
impl ModuleGraphBuilder {
|
||||
|
@ -460,7 +460,7 @@ impl ModuleGraphBuilder {
|
|||
parsed_source_cache: Arc<ParsedSourceCache>,
|
||||
resolver: Arc<CliResolver>,
|
||||
root_permissions_container: PermissionsContainer,
|
||||
sys: FsSysTraitsAdapter,
|
||||
sys: CliSys,
|
||||
) -> Self {
|
||||
Self {
|
||||
caches,
|
||||
|
@ -834,7 +834,7 @@ pub fn enhanced_resolution_error_message(error: &ResolutionError) -> String {
|
|||
}
|
||||
|
||||
fn enhanced_sloppy_imports_error_message(
|
||||
sys: &FsSysTraitsAdapter,
|
||||
sys: &CliSys,
|
||||
error: &ModuleError,
|
||||
) -> Option<String> {
|
||||
match error {
|
||||
|
|
|
@ -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 crate::version;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use std::thread::ThreadId;
|
||||
|
||||
use boxed_error::Boxed;
|
||||
use deno_cache_dir::file_fetcher::RedirectHeaderParseError;
|
||||
|
@ -23,12 +24,11 @@ use http::header::CONTENT_LENGTH;
|
|||
use http::HeaderMap;
|
||||
use http::StatusCode;
|
||||
use http_body_util::BodyExt;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use std::thread::ThreadId;
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::util::progress_bar::UpdateGuard;
|
||||
use crate::version;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SendError {
|
||||
#[error(transparent)]
|
||||
|
|
|
@ -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() {
|
||||
let mut args = vec!["cargo", "test", "-p", "cli_tests", "--features", "run"];
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
import { core, primordials } from "ext:core/mod.js";
|
||||
|
|
|
@ -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
|
||||
|
||||
/*
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
2
cli/js/40_lint_types.d.ts
vendored
2
cli/js/40_lint_types.d.ts
vendored
|
@ -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 {
|
||||
type: string;
|
||||
|
|
|
@ -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 { escapeName, withPermissions } from "ext:cli/40_test_common.js";
|
||||
|
|
|
@ -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 { serializePermissions } from "ext:runtime/10_permissions.js";
|
||||
const ops = core.ops;
|
||||
|
|
10
cli/jsr.rs
10
cli/jsr.rs
|
@ -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 deno_core::serde_json;
|
||||
use deno_graph::packages::JsrPackageInfo;
|
||||
use deno_graph::packages::JsrPackageVersionInfo;
|
||||
use deno_semver::package::PackageNv;
|
||||
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
|
||||
/// just reads the cache. Keep in sync!
|
||||
|
|
|
@ -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 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;
|
||||
use deno_config::workspace::MappedResolution;
|
||||
use deno_lint::diagnostic::LintDiagnosticRange;
|
||||
use std::borrow::Cow;
|
||||
use std::cmp::Ordering;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::HashSet;
|
||||
use std::path::Path;
|
||||
|
||||
use deno_ast::SourceRange;
|
||||
use deno_ast::SourceRangedForSpanned;
|
||||
use deno_ast::SourceTextInfo;
|
||||
use deno_config::workspace::MappedResolution;
|
||||
use deno_core::error::custom_error;
|
||||
use deno_core::error::AnyError;
|
||||
use deno_core::serde::Deserialize;
|
||||
|
@ -27,6 +17,7 @@ use deno_core::serde::Serialize;
|
|||
use deno_core::serde_json;
|
||||
use deno_core::serde_json::json;
|
||||
use deno_core::ModuleSpecifier;
|
||||
use deno_lint::diagnostic::LintDiagnosticRange;
|
||||
use deno_path_util::url_to_file_path;
|
||||
use deno_runtime::deno_node::PathClean;
|
||||
use deno_semver::jsr::JsrPackageNvReference;
|
||||
|
@ -44,16 +35,25 @@ use node_resolver::NodeResolutionKind;
|
|||
use node_resolver::ResolutionMode;
|
||||
use once_cell::sync::Lazy;
|
||||
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 tower_lsp::lsp_types as lsp;
|
||||
use tower_lsp::lsp_types::Position;
|
||||
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
|
||||
/// fixes we treat them the same.
|
||||
static FIX_ALL_ERROR_CODES: Lazy<HashMap<&'static str, &'static str>> =
|
||||
|
|
|
@ -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::GlobalHttpCache;
|
||||
|
@ -7,16 +17,7 @@ use crate::cache::LocalLspHttpCache;
|
|||
use crate::lsp::config::Config;
|
||||
use crate::lsp::logging::lsp_log;
|
||||
use crate::lsp::logging::lsp_warn;
|
||||
|
||||
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;
|
||||
use crate::sys::CliSys;
|
||||
|
||||
pub fn calculate_fs_version(
|
||||
cache: &LspCache,
|
||||
|
@ -92,12 +93,11 @@ impl LspCache {
|
|||
})
|
||||
.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");
|
||||
let global = Arc::new(GlobalHttpCache::new(
|
||||
FsSysTraitsAdapter::new_real(),
|
||||
deno_dir.remote_folder_path(),
|
||||
));
|
||||
let global =
|
||||
Arc::new(GlobalHttpCache::new(sys, deno_dir.remote_folder_path()));
|
||||
Self {
|
||||
deno_dir,
|
||||
global,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -12,12 +12,11 @@ use lsp_types::Uri;
|
|||
use tower_lsp::lsp_types as lsp;
|
||||
use tower_lsp::lsp_types::ConfigurationItem;
|
||||
|
||||
use crate::lsp::repl::get_repl_workspace_settings;
|
||||
|
||||
use super::config::WorkspaceSettings;
|
||||
use super::config::SETTINGS_SECTION;
|
||||
use super::lsp_custom;
|
||||
use super::testing::lsp_custom as testing_lsp_custom;
|
||||
use crate::lsp::repl::get_repl_workspace_settings;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum TestingNotification {
|
||||
|
|
|
@ -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 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 std::cell::RefCell;
|
||||
use std::collections::HashSet;
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
|
||||
use deno_ast::swc::ast;
|
||||
use deno_ast::swc::visit::Visit;
|
||||
|
@ -25,13 +21,17 @@ use deno_core::ModuleSpecifier;
|
|||
use lazy_regex::lazy_regex;
|
||||
use once_cell::sync::Lazy;
|
||||
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::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 EXPORT_MODIFIER: Lazy<Regex> = lazy_regex!(r"\bexport\b");
|
||||
|
|
|
@ -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::config::Config;
|
||||
|
@ -12,33 +34,10 @@ use super::registries::ModuleRegistry;
|
|||
use super::resolver::LspResolver;
|
||||
use super::search::PackageSearchApi;
|
||||
use super::tsc;
|
||||
|
||||
use crate::graph_util::to_node_resolution_mode;
|
||||
use crate::jsr::JsrFetchResolver;
|
||||
use crate::util::path::is_importable_ext;
|
||||
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> =
|
||||
lazy_regex::lazy_regex!(r#"^file:/{2}(?:/[A-Za-z]:)?"#);
|
||||
|
@ -822,16 +821,18 @@ fn get_workspace_completions(
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::collections::HashMap;
|
||||
|
||||
use deno_core::resolve_url;
|
||||
use pretty_assertions::assert_eq;
|
||||
use test_util::TempDir;
|
||||
|
||||
use super::*;
|
||||
use crate::cache::HttpCache;
|
||||
use crate::lsp::cache::LspCache;
|
||||
use crate::lsp::documents::Documents;
|
||||
use crate::lsp::documents::LanguageId;
|
||||
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(
|
||||
open_sources: &[(&str, &str, i32, LanguageId)],
|
||||
|
|
|
@ -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_config::deno_json::DenoJsonCache;
|
||||
|
@ -36,18 +45,9 @@ use deno_lint::linter::LintConfig as DenoLintConfig;
|
|||
use deno_npm::npm_rc::ResolvedNpmRc;
|
||||
use deno_package_json::PackageJsonCache;
|
||||
use deno_path_util::url_to_file_path;
|
||||
use deno_runtime::deno_fs::FsSysTraitsAdapter;
|
||||
use deno_runtime::deno_node::PackageJson;
|
||||
use indexmap::IndexSet;
|
||||
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 super::logging::lsp_log;
|
||||
|
@ -65,6 +65,7 @@ use crate::file_fetcher::CliFileFetcher;
|
|||
use crate::lsp::logging::lsp_warn;
|
||||
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;
|
||||
|
@ -1227,7 +1228,7 @@ impl ConfigData {
|
|||
Ok(scope_dir_path) => {
|
||||
let paths = [scope_dir_path];
|
||||
WorkspaceDirectory::discover(
|
||||
&FsSysTraitsAdapter::new_real(),
|
||||
&CliSys::default(),
|
||||
match specified_config {
|
||||
Some(config_path) => {
|
||||
deno_config::workspace::WorkspaceDiscoverStart::ConfigFile(
|
||||
|
@ -1617,9 +1618,7 @@ impl ConfigData {
|
|||
|| unstable.contains("sloppy-imports");
|
||||
let sloppy_imports_resolver = unstable_sloppy_imports.then(|| {
|
||||
Arc::new(CliSloppyImportsResolver::new(
|
||||
SloppyImportsCachedFs::new_without_stat_cache(
|
||||
FsSysTraitsAdapter::new_real(),
|
||||
),
|
||||
SloppyImportsCachedFs::new_without_stat_cache(CliSys::default()),
|
||||
))
|
||||
});
|
||||
let resolver = Arc::new(resolver);
|
||||
|
@ -1922,17 +1921,20 @@ impl ConfigTree {
|
|||
|
||||
#[cfg(test)]
|
||||
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 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();
|
||||
test_fs.setup_text_files(vec![(
|
||||
config_path.to_string_lossy().to_string(),
|
||||
json_text,
|
||||
)]);
|
||||
memory_sys
|
||||
.fs_create_dir_all(config_path.parent().unwrap())
|
||||
.unwrap();
|
||||
memory_sys.fs_write(&config_path, json_text).unwrap();
|
||||
let workspace_dir = Arc::new(
|
||||
WorkspaceDirectory::discover(
|
||||
&FsSysTraitsAdapter(test_fs.clone()),
|
||||
&memory_sys,
|
||||
deno_config::workspace::WorkspaceDiscoverStart::ConfigFile(
|
||||
&config_path,
|
||||
),
|
||||
|
@ -2009,11 +2011,14 @@ fn resolve_lockfile_from_path(
|
|||
lockfile_path: PathBuf,
|
||||
frozen: bool,
|
||||
) -> Option<CliLockfile> {
|
||||
match CliLockfile::read_from_path(CliLockfileReadFromPathOptions {
|
||||
match CliLockfile::read_from_path(
|
||||
&CliSys::default(),
|
||||
CliLockfileReadFromPathOptions {
|
||||
file_path: lockfile_path,
|
||||
frozen,
|
||||
skip_write: false,
|
||||
}) {
|
||||
},
|
||||
) {
|
||||
Ok(value) => {
|
||||
if value.filename.exists() {
|
||||
if let Ok(specifier) = ModuleSpecifier::from_file_path(&value.filename)
|
||||
|
|
|
@ -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 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::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 std::collections::HashMap;
|
||||
use std::collections::HashSet;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::atomic::AtomicUsize;
|
||||
use std::sync::Arc;
|
||||
use std::thread;
|
||||
|
||||
use deno_ast::MediaType;
|
||||
use deno_config::deno_json::LintConfig;
|
||||
|
@ -48,7 +28,6 @@ use deno_graph::SpecifierError;
|
|||
use deno_lint::linter::LintConfig as DenoLintConfig;
|
||||
use deno_resolver::sloppy_imports::SloppyImportsResolution;
|
||||
use deno_resolver::sloppy_imports::SloppyImportsResolutionKind;
|
||||
use deno_runtime::deno_fs::FsSysTraitsAdapter;
|
||||
use deno_runtime::deno_node;
|
||||
use deno_runtime::tokio_util::create_basic_runtime;
|
||||
use deno_semver::jsr::JsrPackageReqReference;
|
||||
|
@ -57,18 +36,39 @@ use deno_semver::package::PackageReq;
|
|||
use import_map::ImportMap;
|
||||
use import_map::ImportMapError;
|
||||
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::Mutex;
|
||||
use tokio::time::Duration;
|
||||
use tokio_util::sync::CancellationToken;
|
||||
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)]
|
||||
pub struct DiagnosticServerUpdateMessage {
|
||||
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::NoLocal(specifier) => {
|
||||
let maybe_sloppy_resolution = CliSloppyImportsResolver::new(
|
||||
SloppyImportsCachedFs::new(FsSysTraitsAdapter::new_real())
|
||||
SloppyImportsCachedFs::new(CliSys::default())
|
||||
).resolve(specifier, SloppyImportsResolutionKind::Execution);
|
||||
let data = maybe_sloppy_resolution.as_ref().map(|res| {
|
||||
json!({
|
||||
|
@ -1646,6 +1646,12 @@ fn generate_deno_diagnostics(
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::sync::Arc;
|
||||
|
||||
use deno_config::deno_json::ConfigFile;
|
||||
use pretty_assertions::assert_eq;
|
||||
use test_util::TempDir;
|
||||
|
||||
use super::*;
|
||||
use crate::lsp::cache::LspCache;
|
||||
use crate::lsp::config::Config;
|
||||
|
@ -1656,11 +1662,6 @@ mod tests {
|
|||
use crate::lsp::language_server::StateSnapshot;
|
||||
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 {
|
||||
let root_url = resolve_url("file:///").unwrap();
|
||||
let root_uri = url_to_uri(&root_url).unwrap();
|
||||
|
|
|
@ -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 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;
|
||||
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 dashmap::DashMap;
|
||||
use deno_ast::swc::visit::VisitWith;
|
||||
|
@ -36,20 +35,21 @@ use indexmap::IndexMap;
|
|||
use indexmap::IndexSet;
|
||||
use node_resolver::NodeResolutionKind;
|
||||
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 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] =
|
||||
["data", "blob", "file", "http", "https"];
|
||||
|
||||
|
@ -1754,9 +1754,6 @@ fn bytes_to_content(
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::lsp::cache::LspCache;
|
||||
|
||||
use deno_config::deno_json::ConfigFile;
|
||||
use deno_config::deno_json::ConfigParseOptions;
|
||||
use deno_core::serde_json;
|
||||
|
@ -1764,6 +1761,9 @@ mod tests {
|
|||
use pretty_assertions::assert_eq;
|
||||
use test_util::TempDir;
|
||||
|
||||
use super::*;
|
||||
use crate::lsp::cache::LspCache;
|
||||
|
||||
async fn setup() -> (Documents, LspCache, TempDir) {
|
||||
let temp_dir = TempDir::new();
|
||||
temp_dir.create_dir_all(".deno_dir");
|
||||
|
|
|
@ -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 deno_cache_dir::HttpCache;
|
||||
use deno_core::anyhow::anyhow;
|
||||
|
@ -21,11 +18,15 @@ use deno_semver::package::PackageReq;
|
|||
use deno_semver::StackString;
|
||||
use deno_semver::Version;
|
||||
use serde::Deserialize;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
use super::config::ConfigData;
|
||||
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`!
|
||||
#[derive(Debug)]
|
||||
|
|
|
@ -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_cache_dir::file_fetcher::CacheSetting;
|
||||
|
@ -17,7 +28,6 @@ use deno_core::ModuleSpecifier;
|
|||
use deno_graph::GraphKind;
|
||||
use deno_graph::Resolution;
|
||||
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::RootCertStoreProvider;
|
||||
use deno_semver::jsr::JsrPackageReqReference;
|
||||
|
@ -28,16 +38,6 @@ use node_resolver::NodeResolutionKind;
|
|||
use node_resolver::ResolutionMode;
|
||||
use serde::Deserialize;
|
||||
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::UnboundedReceiver;
|
||||
use tokio::sync::mpsc::UnboundedSender;
|
||||
|
@ -109,6 +109,7 @@ use crate::lsp::config::ConfigWatchedFileType;
|
|||
use crate::lsp::logging::init_log_file;
|
||||
use crate::lsp::tsc::file_text_changes_to_workspace_edit;
|
||||
use crate::lsp::urls::LspUrlKind;
|
||||
use crate::sys::CliSys;
|
||||
use crate::tools::fmt::format_file;
|
||||
use crate::tools::fmt::format_parsed_source;
|
||||
use crate::tools::upgrade::check_for_upgrades_for_lsp;
|
||||
|
@ -280,7 +281,7 @@ impl LanguageServer {
|
|||
.await?;
|
||||
graph_util::graph_valid(
|
||||
&graph,
|
||||
&FsSysTraitsAdapter(factory.fs().clone()),
|
||||
&CliSys::default(),
|
||||
&roots,
|
||||
graph_util::GraphValidOptions {
|
||||
kind: GraphKind::All,
|
||||
|
@ -962,6 +963,7 @@ impl Inner {
|
|||
let file_fetcher = CliFileFetcher::new(
|
||||
self.cache.global().clone(),
|
||||
self.http_client_provider.clone(),
|
||||
CliSys::default(),
|
||||
Default::default(),
|
||||
None,
|
||||
true,
|
||||
|
@ -3613,7 +3615,7 @@ impl Inner {
|
|||
let workspace = match config_data {
|
||||
Some(d) => d.member_dir.clone(),
|
||||
None => Arc::new(WorkspaceDirectory::discover(
|
||||
&FsSysTraitsAdapter::new_real(),
|
||||
&CliSys::default(),
|
||||
deno_config::workspace::WorkspaceDiscoverStart::Paths(&[
|
||||
initial_cwd.clone()
|
||||
]),
|
||||
|
@ -3634,6 +3636,7 @@ impl Inner {
|
|||
)?),
|
||||
};
|
||||
let cli_options = CliOptions::new(
|
||||
&CliSys::default(),
|
||||
Arc::new(Flags {
|
||||
internal: InternalFlags {
|
||||
cache_path: Some(self.cache.deno_dir().root.clone()),
|
||||
|
@ -3962,10 +3965,11 @@ impl Inner {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
use test_util::TempDir;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_walk_workspace() {
|
||||
let temp_dir = TempDir::new();
|
||||
|
|
|
@ -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::io::prelude::*;
|
||||
use std::path::Path;
|
||||
|
@ -12,6 +9,10 @@ use std::sync::atomic::Ordering;
|
|||
use std::thread;
|
||||
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_LOG_LEVEL: AtomicUsize = AtomicUsize::new(log::Level::Info as usize);
|
||||
static LSP_WARN_LEVEL: AtomicUsize =
|
||||
|
|
|
@ -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::Serialize;
|
||||
|
|
|
@ -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::unsync::spawn;
|
||||
pub use repl::ReplCompletionItem;
|
||||
pub use repl::ReplLanguageServer;
|
||||
use tower_lsp::LspService;
|
||||
use tower_lsp::Server;
|
||||
|
||||
use self::diagnostics::should_send_diagnostic_batch_index_notifications;
|
||||
use crate::lsp::language_server::LanguageServer;
|
||||
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 cache;
|
||||
|
|
|
@ -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 deno_core::anyhow::anyhow;
|
||||
|
@ -8,15 +10,13 @@ use deno_npm::npm_rc::NpmRc;
|
|||
use deno_semver::package::PackageNv;
|
||||
use deno_semver::Version;
|
||||
use serde::Deserialize;
|
||||
use std::sync::Arc;
|
||||
|
||||
use super::search::PackageSearchApi;
|
||||
use crate::args::npm_registry_url;
|
||||
use crate::file_fetcher::CliFileFetcher;
|
||||
use crate::file_fetcher::TextDecodedFile;
|
||||
use crate::npm::NpmFetchResolver;
|
||||
|
||||
use super::search::PackageSearchApi;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct CliNpmSearchApi {
|
||||
file_fetcher: Arc<CliFileFetcher>,
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -52,10 +52,12 @@ fn is_process_active(process_id: u32) -> bool {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::is_process_active;
|
||||
use std::process::Command;
|
||||
|
||||
use test_util::deno_exe_path;
|
||||
|
||||
use super::is_process_active;
|
||||
|
||||
#[test]
|
||||
fn process_active() {
|
||||
// launch a long running process
|
||||
|
|
|
@ -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:
|
||||
// https://github.com/pillarjs/path-to-regexp/ which is licensed as follows:
|
||||
|
@ -26,15 +26,16 @@
|
|||
// 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::error::AnyError;
|
||||
use fancy_regex::Regex as FancyRegex;
|
||||
use once_cell::sync::Lazy;
|
||||
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> =
|
||||
lazy_regex::lazy_regex!(r"([.+*?=^!:${}()\[\]|/\\])");
|
||||
|
|
|
@ -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::collections::HashMap;
|
||||
use std::collections::VecDeque;
|
||||
|
@ -12,6 +8,11 @@ use std::sync::Arc;
|
|||
use std::time::Duration;
|
||||
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;
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, PartialEq, Eq)]
|
||||
|
|
|
@ -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
|
||||
// https://github.com/microsoft/vscode/blob/main/extensions/typescript-language-features/src/languageFeatures/refactor.ts
|
||||
|
|
|
@ -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 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 std::borrow::Cow;
|
||||
use std::collections::HashMap;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
use deno_cache_dir::file_fetcher::CacheSetting;
|
||||
use deno_core::anyhow::anyhow;
|
||||
|
@ -32,15 +17,30 @@ use deno_core::url::Position;
|
|||
use deno_core::url::Url;
|
||||
use deno_core::ModuleSpecifier;
|
||||
use deno_graph::Dependency;
|
||||
use deno_runtime::deno_fs::FsSysTraitsAdapter;
|
||||
use log::error;
|
||||
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 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 COMPONENT: &percent_encoding::AsciiSet = &percent_encoding::CONTROLS
|
||||
.add(b' ')
|
||||
|
@ -430,13 +430,12 @@ impl ModuleRegistry {
|
|||
http_client_provider: Arc<HttpClientProvider>,
|
||||
) -> Self {
|
||||
// the http cache should always be the global one for registry completions
|
||||
let http_cache = Arc::new(GlobalHttpCache::new(
|
||||
FsSysTraitsAdapter::new_real(),
|
||||
location.clone(),
|
||||
));
|
||||
let http_cache =
|
||||
Arc::new(GlobalHttpCache::new(CliSys::default(), location.clone()));
|
||||
let file_fetcher = CliFileFetcher::new(
|
||||
http_cache.clone(),
|
||||
http_client_provider,
|
||||
CliSys::default(),
|
||||
Default::default(),
|
||||
None,
|
||||
true,
|
||||
|
@ -1129,9 +1128,10 @@ FetchPermissionsOptionRef::AllowAll,
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use test_util::TempDir;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_validate_registry_configuration() {
|
||||
assert!(validate_config(&RegistryConfigurationJson {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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 deno_ast::MediaType;
|
||||
|
@ -19,9 +26,6 @@ use deno_resolver::cjs::IsCjsResolutionMode;
|
|||
use deno_resolver::npm::NpmReqResolverOptions;
|
||||
use deno_resolver::DenoResolverOptions;
|
||||
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_semver::jsr::JsrPackageReqReference;
|
||||
use deno_semver::npm::NpmPackageReqReference;
|
||||
|
@ -31,12 +35,6 @@ use indexmap::IndexMap;
|
|||
use node_resolver::InNpmPackageChecker;
|
||||
use node_resolver::NodeResolutionKind;
|
||||
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::jsr::JsrCacheResolver;
|
||||
|
@ -51,6 +49,8 @@ use crate::http_util::HttpClientProvider;
|
|||
use crate::lsp::config::Config;
|
||||
use crate::lsp::config::ConfigData;
|
||||
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::CliByonmNpmResolverCreateOptions;
|
||||
use crate::npm::CliManagedInNpmPkgCheckerCreateOptions;
|
||||
|
@ -66,6 +66,7 @@ use crate::resolver::CliResolver;
|
|||
use crate::resolver::CliResolverOptions;
|
||||
use crate::resolver::IsCjsResolver;
|
||||
use crate::resolver::WorkerCliNpmGraphResolver;
|
||||
use crate::sys::CliSys;
|
||||
use crate::tsc::into_specifier_and_media_type;
|
||||
use crate::util::progress_bar::ProgressBar;
|
||||
use crate::util::progress_bar::ProgressBarStyle;
|
||||
|
@ -77,9 +78,9 @@ struct LspScopeResolver {
|
|||
is_cjs_resolver: Arc<IsCjsResolver>,
|
||||
jsr_resolver: Option<Arc<JsrCacheResolver>>,
|
||||
npm_resolver: Option<Arc<dyn CliNpmResolver>>,
|
||||
node_resolver: Option<Arc<NodeResolver>>,
|
||||
node_resolver: Option<Arc<CliNodeResolver>>,
|
||||
npm_pkg_req_resolver: Option<Arc<CliNpmReqResolver>>,
|
||||
pkg_json_resolver: Arc<PackageJsonResolver>,
|
||||
pkg_json_resolver: Arc<CliPackageJsonResolver>,
|
||||
redirect_resolver: Option<Arc<RedirectResolver>>,
|
||||
graph_imports: Arc<IndexMap<ModuleSpecifier, GraphImport>>,
|
||||
dep_info: Arc<Mutex<Arc<ScopeDepInfo>>>,
|
||||
|
@ -383,7 +384,7 @@ impl LspResolver {
|
|||
pub fn pkg_json_resolver(
|
||||
&self,
|
||||
referrer: &ModuleSpecifier,
|
||||
) -> &Arc<PackageJsonResolver> {
|
||||
) -> &Arc<CliPackageJsonResolver> {
|
||||
let resolver = self.get_scope_resolver(Some(referrer));
|
||||
&resolver.pkg_json_resolver
|
||||
}
|
||||
|
@ -591,22 +592,22 @@ struct ResolverFactoryServices {
|
|||
cli_resolver: Deferred<Arc<CliResolver>>,
|
||||
in_npm_pkg_checker: Deferred<Arc<dyn InNpmPackageChecker>>,
|
||||
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_resolver: Option<Arc<dyn CliNpmResolver>>,
|
||||
}
|
||||
|
||||
struct ResolverFactory<'a> {
|
||||
config_data: Option<&'a Arc<ConfigData>>,
|
||||
pkg_json_resolver: Arc<PackageJsonResolver>,
|
||||
sys: FsSysTraitsAdapter,
|
||||
pkg_json_resolver: Arc<CliPackageJsonResolver>,
|
||||
sys: CliSys,
|
||||
services: ResolverFactoryServices,
|
||||
}
|
||||
|
||||
impl<'a> ResolverFactory<'a> {
|
||||
pub fn new(config_data: Option<&'a Arc<ConfigData>>) -> Self {
|
||||
let sys = FsSysTraitsAdapter::new_real();
|
||||
let pkg_json_resolver = Arc::new(PackageJsonResolver::new(sys.clone()));
|
||||
let sys = CliSys::default();
|
||||
let pkg_json_resolver = Arc::new(CliPackageJsonResolver::new(sys.clone()));
|
||||
Self {
|
||||
config_data,
|
||||
pkg_json_resolver,
|
||||
|
@ -621,7 +622,7 @@ impl<'a> ResolverFactory<'a> {
|
|||
cache: &LspCache,
|
||||
) {
|
||||
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 {
|
||||
CliNpmResolverCreateOptions::Byonm(CliByonmNpmResolverCreateOptions {
|
||||
sys,
|
||||
|
@ -656,7 +657,7 @@ impl<'a> ResolverFactory<'a> {
|
|||
}
|
||||
None => CliNpmResolverManagedSnapshotOption::Specified(None),
|
||||
},
|
||||
sys: FsSysTraitsAdapter::new_real(),
|
||||
sys: CliSys::default(),
|
||||
npm_cache_dir,
|
||||
// Use an "only" cache setting in order to make the
|
||||
// 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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
.services
|
||||
.node_resolver
|
||||
.get_or_init(|| {
|
||||
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(),
|
||||
RealIsBuiltInNodeModuleChecker,
|
||||
npm_resolver.clone().into_npm_pkg_folder_resolver(),
|
||||
|
|
|
@ -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_semver::package::PackageNv;
|
||||
use deno_semver::Version;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
pub trait PackageSearchApi {
|
||||
|
@ -15,10 +16,12 @@ pub trait PackageSearchApi {
|
|||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
use deno_core::anyhow::anyhow;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use deno_core::anyhow::anyhow;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct TestPackageSearchApi {
|
||||
/// [(name -> [(version -> [export])])]
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue