diff options
Diffstat (limited to 'ext')
-rw-r--r-- | ext/fs/Cargo.toml | 3 | ||||
-rw-r--r-- | ext/fs/interface.rs | 58 | ||||
-rw-r--r-- | ext/fs/lib.rs | 1 | ||||
-rw-r--r-- | ext/node/Cargo.toml | 5 | ||||
-rw-r--r-- | ext/node/errors.rs | 2 | ||||
-rw-r--r-- | ext/node/lib.rs | 2 | ||||
-rw-r--r-- | ext/node/package_json.rs | 33 | ||||
-rw-r--r-- | ext/node/resolution.rs | 4 |
8 files changed, 32 insertions, 76 deletions
diff --git a/ext/fs/Cargo.toml b/ext/fs/Cargo.toml index b5634a3a3..ad8d9683d 100644 --- a/ext/fs/Cargo.toml +++ b/ext/fs/Cargo.toml @@ -14,12 +14,11 @@ description = "Ops for interacting with the file system" path = "lib.rs" [features] -sync_fs = ["deno_config/sync"] +sync_fs = [] [dependencies] async-trait.workspace = true base32.workspace = true -deno_config = { workspace = true, default-features = false } deno_core.workspace = true deno_io.workspace = true deno_permissions.workspace = true diff --git a/ext/fs/interface.rs b/ext/fs/interface.rs index 09e16aff1..af4beb248 100644 --- a/ext/fs/interface.rs +++ b/ext/fs/interface.rs @@ -337,64 +337,6 @@ pub trait FileSystem: std::fmt::Debug + MaybeSend + MaybeSync { } } -pub struct DenoConfigFsAdapter<'a>(&'a dyn FileSystem); - -impl<'a> DenoConfigFsAdapter<'a> { - pub fn new(fs: &'a dyn FileSystem) -> Self { - Self(fs) - } -} - -impl<'a> deno_config::fs::DenoConfigFs for DenoConfigFsAdapter<'a> { - fn read_to_string_lossy( - &self, - path: &Path, - ) -> Result<String, std::io::Error> { - self - .0 - .read_text_file_lossy_sync(path, None) - .map_err(|err| err.into_io_error()) - } - - fn stat_sync( - &self, - path: &Path, - ) -> Result<deno_config::fs::FsMetadata, std::io::Error> { - self - .0 - .stat_sync(path) - .map(|stat| deno_config::fs::FsMetadata { - is_file: stat.is_file, - is_directory: stat.is_directory, - is_symlink: stat.is_symlink, - }) - .map_err(|err| err.into_io_error()) - } - - fn read_dir( - &self, - path: &Path, - ) -> Result<Vec<deno_config::fs::FsDirEntry>, std::io::Error> { - self - .0 - .read_dir_sync(path) - .map_err(|err| err.into_io_error()) - .map(|entries| { - entries - .into_iter() - .map(|e| deno_config::fs::FsDirEntry { - path: path.join(e.name), - metadata: deno_config::fs::FsMetadata { - is_file: e.is_file, - is_directory: e.is_directory, - is_symlink: e.is_symlink, - }, - }) - .collect() - }) - } -} - // Like String::from_utf8_lossy but operates on owned values #[inline(always)] fn string_from_utf8_lossy(buf: Vec<u8>) -> String { diff --git a/ext/fs/lib.rs b/ext/fs/lib.rs index a60408f9b..2dce04b32 100644 --- a/ext/fs/lib.rs +++ b/ext/fs/lib.rs @@ -9,7 +9,6 @@ pub mod sync; pub use crate::in_memory_fs::InMemoryFs; pub use crate::interface::AccessCheckCb; pub use crate::interface::AccessCheckFn; -pub use crate::interface::DenoConfigFsAdapter; pub use crate::interface::FileSystem; pub use crate::interface::FileSystemRc; pub use crate::interface::FsDirEntry; diff --git a/ext/node/Cargo.toml b/ext/node/Cargo.toml index dafb3a0c8..ed168eace 100644 --- a/ext/node/Cargo.toml +++ b/ext/node/Cargo.toml @@ -13,6 +13,9 @@ description = "Node compatibility for Deno" [lib] path = "lib.rs" +[features] +sync_fs = ["deno_package_json/sync"] + [dependencies] aead-gcm-stream = "0.1" aes.workspace = true @@ -23,13 +26,13 @@ bytes.workspace = true cbc.workspace = true const-oid = "0.9.5" data-encoding.workspace = true -deno_config = { workspace = true, default-features = false, features = ["package_json"] } deno_core.workspace = true deno_fetch.workspace = true deno_fs.workspace = true deno_io.workspace = true deno_media_type.workspace = true deno_net.workspace = true +deno_package_json.workspace = true deno_permissions.workspace = true deno_whoami = "0.1.0" digest = { version = "0.10.5", features = ["core-api", "std"] } diff --git a/ext/node/errors.rs b/ext/node/errors.rs index 98b207e86..11bb011f8 100644 --- a/ext/node/errors.rs +++ b/ext/node/errors.rs @@ -315,7 +315,7 @@ impl NodeJsErrorCoded for PathToDeclarationUrlError { pub struct PackageJsonLoadError( #[source] #[from] - pub deno_config::package_json::PackageJsonLoadError, + pub deno_package_json::PackageJsonLoadError, ); impl NodeJsErrorCoded for PackageJsonLoadError { diff --git a/ext/node/lib.rs b/ext/node/lib.rs index 5be0fffa1..6f7185148 100644 --- a/ext/node/lib.rs +++ b/ext/node/lib.rs @@ -32,7 +32,7 @@ mod path; mod polyfill; mod resolution; -pub use deno_config::package_json::PackageJson; +pub use deno_package_json::PackageJson; pub use ops::ipc::ChildPipeFd; pub use ops::ipc::IpcJsonStreamResource; use ops::vm; diff --git a/ext/node/package_json.rs b/ext/node/package_json.rs index b28207db8..877acfc7a 100644 --- a/ext/node/package_json.rs +++ b/ext/node/package_json.rs @@ -1,8 +1,7 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -use deno_config::package_json::PackageJson; -use deno_config::package_json::PackageJsonRc; -use deno_fs::DenoConfigFsAdapter; +use deno_package_json::PackageJson; +use deno_package_json::PackageJsonRc; use std::cell::RefCell; use std::collections::HashMap; use std::io::ErrorKind; @@ -24,9 +23,7 @@ impl PackageJsonThreadLocalCache { } } -impl deno_config::package_json::PackageJsonCache - for PackageJsonThreadLocalCache -{ +impl deno_package_json::PackageJsonCache for PackageJsonThreadLocalCache { fn get(&self, path: &Path) -> Option<PackageJsonRc> { CACHE.with(|cache| cache.borrow().get(path).cloned()) } @@ -36,6 +33,20 @@ impl deno_config::package_json::PackageJsonCache } } +pub struct DenoPkgJsonFsAdapter<'a>(pub &'a dyn deno_fs::FileSystem); + +impl<'a> deno_package_json::fs::DenoPkgJsonFs for DenoPkgJsonFsAdapter<'a> { + fn read_to_string_lossy( + &self, + path: &Path, + ) -> Result<String, std::io::Error> { + self + .0 + .read_text_file_lossy_sync(path, None) + .map_err(|err| err.into_io_error()) + } +} + /// Helper to load a package.json file using the thread local cache /// in deno_node. pub fn load_pkg_json( @@ -44,14 +55,16 @@ pub fn load_pkg_json( ) -> Result<Option<PackageJsonRc>, PackageJsonLoadError> { let result = PackageJson::load_from_path( path, - &DenoConfigFsAdapter::new(fs), + &DenoPkgJsonFsAdapter(fs), Some(&PackageJsonThreadLocalCache), ); match result { Ok(pkg_json) => Ok(Some(pkg_json)), - Err(deno_config::package_json::PackageJsonLoadError::Io { - source, .. - }) if source.kind() == ErrorKind::NotFound => Ok(None), + Err(deno_package_json::PackageJsonLoadError::Io { source, .. }) + if source.kind() == ErrorKind::NotFound => + { + Ok(None) + } Err(err) => Err(PackageJsonLoadError(err)), } } diff --git a/ext/node/resolution.rs b/ext/node/resolution.rs index cf30305a9..476b4f59c 100644 --- a/ext/node/resolution.rs +++ b/ext/node/resolution.rs @@ -5,7 +5,6 @@ use std::collections::HashMap; use std::path::Path; use std::path::PathBuf; -use deno_config::package_json::PackageJsonRc; use deno_core::anyhow::bail; use deno_core::error::AnyError; use deno_core::serde_json::Map; @@ -14,6 +13,7 @@ use deno_core::url::Url; use deno_core::ModuleSpecifier; use deno_fs::FileSystemRc; use deno_media_type::MediaType; +use deno_package_json::PackageJsonRc; use crate::errors; use crate::errors::CanonicalizingPkgJsonDirError; @@ -56,7 +56,7 @@ use crate::PathClean; pub static DEFAULT_CONDITIONS: &[&str] = &["deno", "node", "import"]; pub static REQUIRE_CONDITIONS: &[&str] = &["require", "node"]; -pub type NodeModuleKind = deno_config::package_json::NodeModuleKind; +pub type NodeModuleKind = deno_package_json::NodeModuleKind; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum NodeResolutionMode { |