mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 07:14:47 -05:00
perf: upgrade to deno_semver 0.7 (#27426)
This commit is contained in:
parent
c30f3450c6
commit
ece718eb3e
30 changed files with 282 additions and 147 deletions
88
Cargo.lock
generated
88
Cargo.lock
generated
|
@ -677,6 +677,28 @@ dependencies = [
|
|||
"itoa",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "capacity_builder"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f2d24a6dcf0cd402a21b65d35340f3a49ff3475dc5fdac91d22d2733e6641c6"
|
||||
dependencies = [
|
||||
"capacity_builder_macros",
|
||||
"ecow",
|
||||
"hipstr",
|
||||
"itoa",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "capacity_builder_macros"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b4a6cae9efc04cc6cbb8faf338d2c497c165c83e74509cf4dbedea948bbf6e5"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn 2.0.87",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "caseless"
|
||||
version = "0.2.1"
|
||||
|
@ -1230,7 +1252,7 @@ dependencies = [
|
|||
"boxed_error",
|
||||
"bytes",
|
||||
"cache_control",
|
||||
"capacity_builder",
|
||||
"capacity_builder 0.5.0",
|
||||
"chrono",
|
||||
"clap",
|
||||
"clap_complete",
|
||||
|
@ -1469,9 +1491,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "deno_config"
|
||||
version = "0.40.0"
|
||||
version = "0.41.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "459b0bf193d2f9a177d18064a4888062ba0716312f56dbda8f1319444a8b2544"
|
||||
checksum = "8afa3beb6b9e0604cfe0380d30f88c5b758d44e228d5a5fc42ae637ccfb7d089"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"deno_package_json",
|
||||
|
@ -1510,7 +1532,7 @@ dependencies = [
|
|||
"bit-set",
|
||||
"bit-vec",
|
||||
"bytes",
|
||||
"capacity_builder",
|
||||
"capacity_builder 0.1.3",
|
||||
"cooked-waker",
|
||||
"deno_core_icudata",
|
||||
"deno_ops",
|
||||
|
@ -1724,13 +1746,13 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "deno_graph"
|
||||
version = "0.86.4"
|
||||
version = "0.86.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8502f5dd37f522c76e92961ec6e855f40bc351d50d62bc0752cc19517eed8ec"
|
||||
checksum = "f669d96d63841d9ba10f86b161d898678ce05bc1e3c9ee1c1f7449a68eed2b64"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
"capacity_builder",
|
||||
"capacity_builder 0.5.0",
|
||||
"data-url",
|
||||
"deno_ast",
|
||||
"deno_semver",
|
||||
|
@ -1865,9 +1887,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "deno_lockfile"
|
||||
version = "0.23.2"
|
||||
version = "0.24.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "559c19feb00af0c34f0bd4a20e56e12463fafd5c5069d6005f3ce33008027eea"
|
||||
checksum = "632e835a53ed667d62fdd766c5780fe8361c831d3e3fbf1a760a0b7896657587"
|
||||
dependencies = [
|
||||
"deno_semver",
|
||||
"serde",
|
||||
|
@ -2026,12 +2048,13 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "deno_npm"
|
||||
version = "0.26.0"
|
||||
version = "0.27.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2f125a5dba7839c46394a0a9c835da9fe60f5f412587ab4956a76492a1cc6a8"
|
||||
checksum = "5f818ad5dc4c206b50b5cfa6f10b4b94b127e15c8342c152768eba40c225ca23"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
"capacity_builder 0.5.0",
|
||||
"deno_error",
|
||||
"deno_lockfile",
|
||||
"deno_semver",
|
||||
"futures",
|
||||
|
@ -2053,6 +2076,7 @@ dependencies = [
|
|||
"boxed_error",
|
||||
"deno_cache_dir",
|
||||
"deno_core",
|
||||
"deno_error",
|
||||
"deno_npm",
|
||||
"deno_semver",
|
||||
"deno_unsync",
|
||||
|
@ -2090,10 +2114,11 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "deno_package_json"
|
||||
version = "0.2.1"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "80b0a3d81c592624a1ae15332a04b4dc2b7c163ef1dfc7c60171f736d1babdf5"
|
||||
checksum = "81d72db99fdebfc371d7be16972c18a47daa7a29cb5fbb3900ab2114b1f42d96"
|
||||
dependencies = [
|
||||
"boxed_error",
|
||||
"deno_error",
|
||||
"deno_path_util",
|
||||
"deno_semver",
|
||||
|
@ -2120,7 +2145,7 @@ dependencies = [
|
|||
name = "deno_permissions"
|
||||
version = "0.43.0"
|
||||
dependencies = [
|
||||
"capacity_builder",
|
||||
"capacity_builder 0.5.0",
|
||||
"deno_core",
|
||||
"deno_path_util",
|
||||
"deno_terminal 0.2.0",
|
||||
|
@ -2225,11 +2250,14 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "deno_semver"
|
||||
version = "0.6.1"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7d1259270d66a5e6d29bb75c9289656541874f79ae9ff6c9f1c790846d5c07ba"
|
||||
checksum = "4775271f9b5602482698f76d24ea9ed8ba27af7f587a7e9a876916300c542435"
|
||||
dependencies = [
|
||||
"capacity_builder 0.5.0",
|
||||
"deno_error",
|
||||
"ecow",
|
||||
"hipstr",
|
||||
"monch",
|
||||
"once_cell",
|
||||
"serde",
|
||||
|
@ -2896,6 +2924,15 @@ dependencies = [
|
|||
"spki",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ecow"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e42fc0a93992b20c58b99e59d61eaf1635a25bfbe49e4275c34ba0aee98119ba"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ed25519"
|
||||
version = "2.2.3"
|
||||
|
@ -3832,6 +3869,17 @@ dependencies = [
|
|||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hipstr"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "97971ffc85d4c98de12e2608e992a43f5294ebb625fdb045b27c731b64c4c6d6"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_bytes",
|
||||
"sptr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hkdf"
|
||||
version = "0.12.4"
|
||||
|
@ -7003,6 +7051,12 @@ dependencies = [
|
|||
"der",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sptr"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b9b39299b249ad65f3b7e96443bad61c02ca5cd3589f46cb6d610a0fd6c0d6a"
|
||||
|
||||
[[package]]
|
||||
name = "sqlformat"
|
||||
version = "0.3.2"
|
||||
|
|
12
Cargo.toml
12
Cargo.toml
|
@ -51,14 +51,14 @@ deno_ast = { version = "=0.44.0", features = ["transpiling"] }
|
|||
deno_core = { version = "0.327.0" }
|
||||
|
||||
deno_bench_util = { version = "0.178.0", path = "./bench_util" }
|
||||
deno_config = { version = "=0.40.0", features = ["workspace", "sync"] }
|
||||
deno_lockfile = "=0.23.2"
|
||||
deno_config = { version = "=0.41.0", features = ["workspace", "sync"] }
|
||||
deno_lockfile = "=0.24.0"
|
||||
deno_media_type = { version = "0.2.0", features = ["module_specifier"] }
|
||||
deno_npm = "=0.26.0"
|
||||
deno_npm = "=0.27.0"
|
||||
deno_path_util = "=0.2.2"
|
||||
deno_permissions = { version = "0.43.0", path = "./runtime/permissions" }
|
||||
deno_runtime = { version = "0.192.0", path = "./runtime" }
|
||||
deno_semver = "=0.6.1"
|
||||
deno_semver = "=0.7.1"
|
||||
deno_terminal = "0.2.0"
|
||||
napi_sym = { version = "0.114.0", path = "./ext/napi/sym" }
|
||||
test_util = { package = "test_server", path = "./tests/util/server" }
|
||||
|
@ -108,7 +108,7 @@ boxed_error = "0.2.3"
|
|||
brotli = "6.0.0"
|
||||
bytes = "1.4.0"
|
||||
cache_control = "=0.2.0"
|
||||
capacity_builder = "0.1.3"
|
||||
capacity_builder = "0.5.0"
|
||||
cbc = { version = "=0.1.2", features = ["alloc"] }
|
||||
# Note: Do not use the "clock" feature of chrono, as it links us to CoreFoundation on macOS.
|
||||
# Instead use util::time::utc_now()
|
||||
|
@ -120,7 +120,7 @@ data-encoding = "2.3.3"
|
|||
data-url = "=0.3.1"
|
||||
deno_cache_dir = "=0.15.0"
|
||||
deno_error = "=0.5.2"
|
||||
deno_package_json = { version = "0.2.1", default-features = false }
|
||||
deno_package_json = { version = "0.3.0", default-features = false }
|
||||
deno_unsync = "0.4.2"
|
||||
dlopen2 = "0.6.1"
|
||||
ecb = "=0.1.2"
|
||||
|
|
|
@ -74,7 +74,7 @@ deno_config.workspace = true
|
|||
deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] }
|
||||
deno_doc = { version = "=0.161.3", features = ["rust", "comrak"] }
|
||||
deno_error.workspace = true
|
||||
deno_graph = { version = "=0.86.4" }
|
||||
deno_graph = { version = "=0.86.5" }
|
||||
deno_lint = { version = "=0.68.2", features = ["docs"] }
|
||||
deno_lockfile.workspace = true
|
||||
deno_npm.workspace = true
|
||||
|
|
|
@ -31,6 +31,7 @@ use deno_npm::resolution::ValidSerializedNpmResolutionSnapshot;
|
|||
use deno_npm::NpmSystemInfo;
|
||||
use deno_path_util::normalize_path;
|
||||
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;
|
||||
|
@ -992,24 +993,24 @@ impl CliOptions {
|
|||
// https://nodejs.org/api/process.html
|
||||
match target.as_str() {
|
||||
"aarch64-apple-darwin" => NpmSystemInfo {
|
||||
os: "darwin".to_string(),
|
||||
cpu: "arm64".to_string(),
|
||||
os: "darwin".into(),
|
||||
cpu: "arm64".into(),
|
||||
},
|
||||
"aarch64-unknown-linux-gnu" => NpmSystemInfo {
|
||||
os: "linux".to_string(),
|
||||
cpu: "arm64".to_string(),
|
||||
os: "linux".into(),
|
||||
cpu: "arm64".into(),
|
||||
},
|
||||
"x86_64-apple-darwin" => NpmSystemInfo {
|
||||
os: "darwin".to_string(),
|
||||
cpu: "x64".to_string(),
|
||||
os: "darwin".into(),
|
||||
cpu: "x64".into(),
|
||||
},
|
||||
"x86_64-unknown-linux-gnu" => NpmSystemInfo {
|
||||
os: "linux".to_string(),
|
||||
cpu: "x64".to_string(),
|
||||
os: "linux".into(),
|
||||
cpu: "x64".into(),
|
||||
},
|
||||
"x86_64-pc-windows-msvc" => NpmSystemInfo {
|
||||
os: "win32".to_string(),
|
||||
cpu: "x64".to_string(),
|
||||
os: "win32".into(),
|
||||
cpu: "x64".into(),
|
||||
},
|
||||
value => {
|
||||
log::warn!(
|
||||
|
@ -1946,15 +1947,17 @@ pub fn has_flag_env_var(name: &str) -> bool {
|
|||
pub fn npm_pkg_req_ref_to_binary_command(
|
||||
req_ref: &NpmPackageReqReference,
|
||||
) -> String {
|
||||
let binary_name = req_ref.sub_path().unwrap_or(req_ref.req().name.as_str());
|
||||
binary_name.to_string()
|
||||
req_ref
|
||||
.sub_path()
|
||||
.map(|s| s.to_string())
|
||||
.unwrap_or_else(|| req_ref.req().name.to_string())
|
||||
}
|
||||
|
||||
pub fn config_to_deno_graph_workspace_member(
|
||||
config: &ConfigFile,
|
||||
) -> Result<deno_graph::WorkspaceMember, AnyError> {
|
||||
let name = match &config.json.name {
|
||||
Some(name) => name.clone(),
|
||||
let name: StackString = match &config.json.name {
|
||||
Some(name) => name.as_str().into(),
|
||||
None => bail!("Missing 'name' field in config file."),
|
||||
};
|
||||
let version = match &config.json.version {
|
||||
|
|
|
@ -11,19 +11,20 @@ use deno_package_json::PackageJsonDepValueParseError;
|
|||
use deno_package_json::PackageJsonDepWorkspaceReq;
|
||||
use deno_semver::npm::NpmPackageReqReference;
|
||||
use deno_semver::package::PackageReq;
|
||||
use deno_semver::StackString;
|
||||
use deno_semver::VersionReq;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct InstallNpmRemotePkg {
|
||||
pub alias: Option<String>,
|
||||
pub alias: Option<StackString>,
|
||||
pub base_dir: PathBuf,
|
||||
pub req: PackageReq,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct InstallNpmWorkspacePkg {
|
||||
pub alias: Option<String>,
|
||||
pub alias: Option<StackString>,
|
||||
pub target_dir: PathBuf,
|
||||
}
|
||||
|
||||
|
@ -31,7 +32,7 @@ pub struct InstallNpmWorkspacePkg {
|
|||
#[error("Failed to install '{}'\n at {}", alias, location)]
|
||||
pub struct PackageJsonDepValueParseWithLocationError {
|
||||
pub location: Url,
|
||||
pub alias: String,
|
||||
pub alias: StackString,
|
||||
#[source]
|
||||
pub source: PackageJsonDepValueParseError,
|
||||
}
|
||||
|
@ -100,10 +101,8 @@ impl NpmInstallDepsProvider {
|
|||
let mut pkg_pkgs = Vec::with_capacity(
|
||||
deps.dependencies.len() + deps.dev_dependencies.len(),
|
||||
);
|
||||
for (alias, dep) in deps
|
||||
.dependencies
|
||||
.into_iter()
|
||||
.chain(deps.dev_dependencies.into_iter())
|
||||
for (alias, dep) in
|
||||
deps.dependencies.iter().chain(deps.dev_dependencies.iter())
|
||||
{
|
||||
let dep = match dep {
|
||||
Ok(dep) => dep,
|
||||
|
@ -111,8 +110,8 @@ impl NpmInstallDepsProvider {
|
|||
pkg_json_dep_errors.push(
|
||||
PackageJsonDepValueParseWithLocationError {
|
||||
location: pkg_json.specifier(),
|
||||
alias,
|
||||
source: err,
|
||||
alias: alias.clone(),
|
||||
source: err.clone(),
|
||||
},
|
||||
);
|
||||
continue;
|
||||
|
@ -121,28 +120,28 @@ impl NpmInstallDepsProvider {
|
|||
match dep {
|
||||
PackageJsonDepValue::Req(pkg_req) => {
|
||||
let workspace_pkg = workspace_npm_pkgs.iter().find(|pkg| {
|
||||
pkg.matches_req(&pkg_req)
|
||||
pkg.matches_req(pkg_req)
|
||||
// do not resolve to the current package
|
||||
&& pkg.pkg_json.path != pkg_json.path
|
||||
});
|
||||
|
||||
if let Some(pkg) = workspace_pkg {
|
||||
workspace_pkgs.push(InstallNpmWorkspacePkg {
|
||||
alias: Some(alias),
|
||||
alias: Some(alias.clone()),
|
||||
target_dir: pkg.pkg_json.dir_path().to_path_buf(),
|
||||
});
|
||||
} else {
|
||||
pkg_pkgs.push(InstallNpmRemotePkg {
|
||||
alias: Some(alias),
|
||||
alias: Some(alias.clone()),
|
||||
base_dir: pkg_json.dir_path().to_path_buf(),
|
||||
req: pkg_req,
|
||||
req: pkg_req.clone(),
|
||||
});
|
||||
}
|
||||
}
|
||||
PackageJsonDepValue::Workspace(workspace_version_req) => {
|
||||
let version_req = match workspace_version_req {
|
||||
PackageJsonDepWorkspaceReq::VersionReq(version_req) => {
|
||||
version_req
|
||||
version_req.clone()
|
||||
}
|
||||
PackageJsonDepWorkspaceReq::Tilde
|
||||
| PackageJsonDepWorkspaceReq::Caret => {
|
||||
|
@ -150,10 +149,10 @@ impl NpmInstallDepsProvider {
|
|||
}
|
||||
};
|
||||
if let Some(pkg) = workspace_npm_pkgs.iter().find(|pkg| {
|
||||
pkg.matches_name_and_version_req(&alias, &version_req)
|
||||
pkg.matches_name_and_version_req(alias, &version_req)
|
||||
}) {
|
||||
workspace_pkgs.push(InstallNpmWorkspacePkg {
|
||||
alias: Some(alias),
|
||||
alias: Some(alias.clone()),
|
||||
target_dir: pkg.pkg_json.dir_path().to_path_buf(),
|
||||
});
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@ use deno_runtime::deno_node;
|
|||
use deno_runtime::deno_permissions::PermissionsContainer;
|
||||
use deno_semver::jsr::JsrDepPackageReq;
|
||||
use deno_semver::package::PackageNv;
|
||||
use deno_semver::SmallStackString;
|
||||
use import_map::ImportMapError;
|
||||
use node_resolver::InNpmPackageChecker;
|
||||
use std::collections::HashSet;
|
||||
|
@ -680,7 +681,7 @@ impl ModuleGraphBuilder {
|
|||
for (from, to) in graph.packages.mappings() {
|
||||
lockfile.insert_package_specifier(
|
||||
JsrDepPackageReq::jsr(from.clone()),
|
||||
to.version.to_string(),
|
||||
to.version.to_custom_string::<SmallStackString>(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,8 @@ use deno_semver::package::PackageNv;
|
|||
use deno_semver::package::PackageNvReference;
|
||||
use deno_semver::package::PackageReq;
|
||||
use deno_semver::package::PackageReqReference;
|
||||
use deno_semver::SmallStackString;
|
||||
use deno_semver::StackString;
|
||||
use deno_semver::Version;
|
||||
use import_map::ImportMap;
|
||||
use node_resolver::NodeResolutionKind;
|
||||
|
@ -278,9 +280,16 @@ impl<'a> TsResponseImportMapper<'a> {
|
|||
{
|
||||
let mut segments = jsr_path.split('/');
|
||||
let name = if jsr_path.starts_with('@') {
|
||||
format!("{}/{}", segments.next()?, segments.next()?)
|
||||
let scope = segments.next()?;
|
||||
let name = segments.next()?;
|
||||
capacity_builder::StringBuilder::<StackString>::build(|builder| {
|
||||
builder.append(scope);
|
||||
builder.append("/");
|
||||
builder.append(name);
|
||||
})
|
||||
.unwrap()
|
||||
} else {
|
||||
segments.next()?.to_string()
|
||||
StackString::from(segments.next()?)
|
||||
};
|
||||
let version = Version::parse_standard(segments.next()?).ok()?;
|
||||
let nv = PackageNv { name, version };
|
||||
|
@ -290,7 +299,9 @@ impl<'a> TsResponseImportMapper<'a> {
|
|||
&path,
|
||||
Some(&self.file_referrer),
|
||||
)?;
|
||||
let sub_path = (export != ".").then_some(export);
|
||||
let sub_path = (export != ".")
|
||||
.then_some(export)
|
||||
.map(SmallStackString::from_string);
|
||||
let mut req = None;
|
||||
req = req.or_else(|| {
|
||||
let import_map = self.maybe_import_map?;
|
||||
|
|
|
@ -18,6 +18,7 @@ use deno_graph::ModuleSpecifier;
|
|||
use deno_semver::jsr::JsrPackageReqReference;
|
||||
use deno_semver::package::PackageNv;
|
||||
use deno_semver::package::PackageReq;
|
||||
use deno_semver::StackString;
|
||||
use deno_semver::Version;
|
||||
use serde::Deserialize;
|
||||
use std::collections::HashMap;
|
||||
|
@ -33,8 +34,8 @@ pub struct JsrCacheResolver {
|
|||
/// The `module_graph` fields of the version infos should be forcibly absent.
|
||||
/// It can be large and we don't want to store it.
|
||||
info_by_nv: DashMap<PackageNv, Option<Arc<JsrPackageVersionInfo>>>,
|
||||
info_by_name: DashMap<String, Option<Arc<JsrPackageInfo>>>,
|
||||
workspace_scope_by_name: HashMap<String, ModuleSpecifier>,
|
||||
info_by_name: DashMap<StackString, Option<Arc<JsrPackageInfo>>>,
|
||||
workspace_scope_by_name: HashMap<StackString, ModuleSpecifier>,
|
||||
cache: Arc<dyn HttpCache>,
|
||||
}
|
||||
|
||||
|
@ -59,7 +60,7 @@ impl JsrCacheResolver {
|
|||
continue;
|
||||
};
|
||||
let nv = PackageNv {
|
||||
name: jsr_pkg_config.name.clone(),
|
||||
name: jsr_pkg_config.name.as_str().into(),
|
||||
version: version.clone(),
|
||||
};
|
||||
info_by_name.insert(
|
||||
|
@ -125,8 +126,8 @@ impl JsrCacheResolver {
|
|||
return nv.value().clone();
|
||||
}
|
||||
let maybe_get_nv = || {
|
||||
let name = req.name.clone();
|
||||
let package_info = self.package_info(&name)?;
|
||||
let name = &req.name;
|
||||
let package_info = self.package_info(name)?;
|
||||
// Find the first matching version of the package which is cached.
|
||||
let mut versions = package_info.versions.keys().collect::<Vec<_>>();
|
||||
versions.sort();
|
||||
|
@ -144,7 +145,10 @@ impl JsrCacheResolver {
|
|||
self.package_version_info(&nv).is_some()
|
||||
})
|
||||
.cloned()?;
|
||||
Some(PackageNv { name, version })
|
||||
Some(PackageNv {
|
||||
name: name.clone(),
|
||||
version,
|
||||
})
|
||||
};
|
||||
let nv = maybe_get_nv();
|
||||
self.nv_by_req.insert(req.clone(), nv.clone());
|
||||
|
@ -216,7 +220,10 @@ impl JsrCacheResolver {
|
|||
None
|
||||
}
|
||||
|
||||
pub fn package_info(&self, name: &str) -> Option<Arc<JsrPackageInfo>> {
|
||||
pub fn package_info(
|
||||
&self,
|
||||
name: &StackString,
|
||||
) -> Option<Arc<JsrPackageInfo>> {
|
||||
if let Some(info) = self.info_by_name.get(name) {
|
||||
return info.value().clone();
|
||||
}
|
||||
|
@ -226,7 +233,7 @@ impl JsrCacheResolver {
|
|||
serde_json::from_slice::<JsrPackageInfo>(&meta_bytes).ok()
|
||||
};
|
||||
let info = read_cached_package_info().map(Arc::new);
|
||||
self.info_by_name.insert(name.to_string(), info.clone());
|
||||
self.info_by_name.insert(name.clone(), info.clone());
|
||||
info
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,9 @@ pub mod tests {
|
|||
&self,
|
||||
nv: &PackageNv,
|
||||
) -> Result<Arc<Vec<String>>, AnyError> {
|
||||
let Some(exports_by_version) = self.package_versions.get(&nv.name) else {
|
||||
let Some(exports_by_version) =
|
||||
self.package_versions.get(nv.name.as_str())
|
||||
else {
|
||||
return Err(anyhow!("Package not found."));
|
||||
};
|
||||
let Some(exports) = exports_by_version.get(&nv.version) else {
|
||||
|
|
|
@ -560,11 +560,11 @@ impl ManagedCliNpmResolver {
|
|||
&self,
|
||||
) -> Result<(), Box<PackageJsonDepValueParseWithLocationError>> {
|
||||
for err in self.npm_install_deps_provider.pkg_json_dep_errors() {
|
||||
match &err.source {
|
||||
deno_package_json::PackageJsonDepValueParseError::VersionReq(_) => {
|
||||
match err.source.as_kind() {
|
||||
deno_package_json::PackageJsonDepValueParseErrorKind::VersionReq(_) => {
|
||||
return Err(Box::new(err.clone()));
|
||||
}
|
||||
deno_package_json::PackageJsonDepValueParseError::Unsupported {
|
||||
deno_package_json::PackageJsonDepValueParseErrorKind::Unsupported {
|
||||
..
|
||||
} => {
|
||||
// only warn for this one
|
||||
|
|
|
@ -4,6 +4,7 @@ use std::collections::HashMap;
|
|||
use std::collections::HashSet;
|
||||
use std::sync::Arc;
|
||||
|
||||
use capacity_builder::StringBuilder;
|
||||
use deno_core::error::AnyError;
|
||||
use deno_lockfile::NpmPackageDependencyLockfileInfo;
|
||||
use deno_lockfile::NpmPackageLockfileInfo;
|
||||
|
@ -24,6 +25,7 @@ use deno_npm::NpmSystemInfo;
|
|||
use deno_semver::jsr::JsrDepPackageReq;
|
||||
use deno_semver::package::PackageNv;
|
||||
use deno_semver::package::PackageReq;
|
||||
use deno_semver::SmallStackString;
|
||||
use deno_semver::VersionReq;
|
||||
|
||||
use crate::args::CliLockfile;
|
||||
|
@ -336,7 +338,13 @@ fn populate_lockfile_from_snapshot(
|
|||
let id = &snapshot.resolve_package_from_deno_module(nv).unwrap().id;
|
||||
lockfile.insert_package_specifier(
|
||||
JsrDepPackageReq::npm(package_req.clone()),
|
||||
format!("{}{}", id.nv.version, id.peer_deps_serialized()),
|
||||
{
|
||||
StringBuilder::<SmallStackString>::build(|builder| {
|
||||
builder.append(&id.nv.version);
|
||||
builder.append(&id.peer_dependencies);
|
||||
})
|
||||
.unwrap()
|
||||
},
|
||||
);
|
||||
}
|
||||
for package in snapshot.all_packages_for_every_system() {
|
||||
|
|
|
@ -28,8 +28,10 @@ fn default_bin_name(package: &NpmResolutionPackage) -> &str {
|
|||
.id
|
||||
.nv
|
||||
.name
|
||||
.as_str()
|
||||
.rsplit_once('/')
|
||||
.map_or(package.id.nv.name.as_str(), |(_, name)| name)
|
||||
.map(|(_, name)| name)
|
||||
.unwrap_or(package.id.nv.name.as_str())
|
||||
}
|
||||
|
||||
pub fn warn_missing_entrypoint(
|
||||
|
|
|
@ -38,6 +38,7 @@ use deno_resolver::npm::normalize_pkg_name_for_node_modules_deno_folder;
|
|||
use deno_runtime::deno_fs;
|
||||
use deno_runtime::deno_node::NodePermissions;
|
||||
use deno_semver::package::PackageNv;
|
||||
use deno_semver::StackString;
|
||||
use node_resolver::errors::PackageFolderResolveError;
|
||||
use node_resolver::errors::PackageFolderResolveIoError;
|
||||
use node_resolver::errors::PackageNotFoundError;
|
||||
|
@ -355,8 +356,10 @@ async fn sync_resolution_with_fs(
|
|||
let package_partitions =
|
||||
snapshot.all_system_packages_partitioned(system_info);
|
||||
let mut cache_futures = FuturesUnordered::new();
|
||||
let mut newest_packages_by_name: HashMap<&String, &NpmResolutionPackage> =
|
||||
HashMap::with_capacity(package_partitions.packages.len());
|
||||
let mut newest_packages_by_name: HashMap<
|
||||
&StackString,
|
||||
&NpmResolutionPackage,
|
||||
> = HashMap::with_capacity(package_partitions.packages.len());
|
||||
let bin_entries = Rc::new(RefCell::new(bin_entries::BinEntries::new()));
|
||||
let mut lifecycle_scripts =
|
||||
super::common::lifecycle_scripts::LifecycleScripts::new(
|
||||
|
@ -536,7 +539,7 @@ async fn sync_resolution_with_fs(
|
|||
}
|
||||
}
|
||||
|
||||
let mut found_names: HashMap<&String, &PackageNv> = HashMap::new();
|
||||
let mut found_names: HashMap<&StackString, &PackageNv> = HashMap::new();
|
||||
|
||||
// set of node_modules in workspace packages that we've already ensured exist
|
||||
let mut existing_child_node_modules_dirs: HashSet<PathBuf> = HashSet::new();
|
||||
|
@ -1012,10 +1015,10 @@ fn get_package_folder_id_from_folder_name(
|
|||
) -> Option<NpmPackageCacheFolderId> {
|
||||
let folder_name = folder_name.replace('+', "/");
|
||||
let (name, ending) = folder_name.rsplit_once('@')?;
|
||||
let name = if let Some(encoded_name) = name.strip_prefix('_') {
|
||||
mixed_case_package_name_decode(encoded_name)?
|
||||
let name: StackString = if let Some(encoded_name) = name.strip_prefix('_') {
|
||||
StackString::from_string(mixed_case_package_name_decode(encoded_name)?)
|
||||
} else {
|
||||
name.to_string()
|
||||
name.into()
|
||||
};
|
||||
let (raw_version, copy_index) = match ending.split_once('_') {
|
||||
Some((raw_version, copy_index)) => {
|
||||
|
|
|
@ -6,6 +6,7 @@ use std::collections::BTreeMap;
|
|||
use std::collections::HashMap;
|
||||
use std::io::Write;
|
||||
|
||||
use capacity_builder::BytesAppendable;
|
||||
use deno_ast::swc::common::source_map;
|
||||
use deno_ast::MediaType;
|
||||
use deno_core::anyhow::bail;
|
||||
|
@ -21,6 +22,7 @@ use deno_npm::resolution::SerializedNpmResolutionSnapshotPackage;
|
|||
use deno_npm::resolution::ValidSerializedNpmResolutionSnapshot;
|
||||
use deno_npm::NpmPackageId;
|
||||
use deno_semver::package::PackageReq;
|
||||
use deno_semver::StackString;
|
||||
use indexmap::IndexMap;
|
||||
|
||||
use crate::standalone::virtual_fs::VirtualDirectory;
|
||||
|
@ -224,7 +226,10 @@ impl RemoteModulesStoreBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
fn write<'a>(&'a self, builder: &mut capacity_builder::BytesBuilder<'a>) {
|
||||
fn write<'a, TBytes: capacity_builder::BytesType>(
|
||||
&'a self,
|
||||
builder: &mut capacity_builder::BytesBuilder<'a, TBytes>,
|
||||
) {
|
||||
builder.append_le(self.specifiers.len() as u32);
|
||||
builder.append_le(self.redirects.len() as u32);
|
||||
for (specifier, offset) in &self.specifiers {
|
||||
|
@ -581,12 +586,13 @@ fn deserialize_npm_snapshot(
|
|||
#[allow(clippy::needless_lifetimes)] // clippy bug
|
||||
fn parse_package_dep<'a>(
|
||||
id_to_npm_id: &'a impl Fn(usize) -> Result<NpmPackageId, AnyError>,
|
||||
) -> impl Fn(&[u8]) -> Result<(&[u8], (String, NpmPackageId)), AnyError> + 'a
|
||||
) -> impl Fn(&[u8]) -> Result<(&[u8], (StackString, NpmPackageId)), AnyError> + 'a
|
||||
{
|
||||
|input| {
|
||||
let (input, req) = read_string_lossy(input)?;
|
||||
let (input, id) = read_u32_as_usize(input)?;
|
||||
Ok((input, (req.into_owned(), id_to_npm_id(id)?)))
|
||||
let req = StackString::from_cow(req);
|
||||
Ok((input, (req, id_to_npm_id(id)?)))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -343,14 +343,14 @@ impl deno_doc::html::HrefResolver for DocResolver {
|
|||
let name = &res.req().name;
|
||||
Some((
|
||||
format!("https://www.npmjs.com/package/{name}"),
|
||||
name.to_owned(),
|
||||
name.to_string(),
|
||||
))
|
||||
}
|
||||
"jsr" => {
|
||||
let res =
|
||||
deno_semver::jsr::JsrPackageReqReference::from_str(module).ok()?;
|
||||
let name = &res.req().name;
|
||||
Some((format!("https://jsr.io/{name}"), name.to_owned()))
|
||||
Some((format!("https://jsr.io/{name}"), name.to_string()))
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
|
|
|
@ -278,8 +278,10 @@ fn add_npm_packages_to_json(
|
|||
});
|
||||
if let Some(pkg) = maybe_package {
|
||||
if let Some(module) = module.as_object_mut() {
|
||||
module
|
||||
.insert("npmPackage".to_string(), pkg.id.as_serialized().into());
|
||||
module.insert(
|
||||
"npmPackage".to_string(),
|
||||
pkg.id.as_serialized().into_string().into(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -296,7 +298,7 @@ fn add_npm_packages_to_json(
|
|||
{
|
||||
dep.insert(
|
||||
"npmPackage".to_string(),
|
||||
pkg.id.as_serialized().into(),
|
||||
pkg.id.as_serialized().into_string().into(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -324,19 +326,19 @@ fn add_npm_packages_to_json(
|
|||
let mut json_packages = serde_json::Map::with_capacity(sorted_packages.len());
|
||||
for pkg in sorted_packages {
|
||||
let mut kv = serde_json::Map::new();
|
||||
kv.insert("name".to_string(), pkg.id.nv.name.clone().into());
|
||||
kv.insert("name".to_string(), pkg.id.nv.name.to_string().into());
|
||||
kv.insert("version".to_string(), pkg.id.nv.version.to_string().into());
|
||||
let mut deps = pkg.dependencies.values().collect::<Vec<_>>();
|
||||
deps.sort();
|
||||
let deps = deps
|
||||
.into_iter()
|
||||
.map(|id| serde_json::Value::String(id.as_serialized()))
|
||||
.map(|id| serde_json::Value::String(id.as_serialized().into_string()))
|
||||
.collect::<Vec<_>>();
|
||||
kv.insert("dependencies".to_string(), deps.into());
|
||||
let registry_url = npmrc.get_registry_url(&pkg.id.nv.name);
|
||||
kv.insert("registryUrl".to_string(), registry_url.to_string().into());
|
||||
|
||||
json_packages.insert(pkg.id.as_serialized(), kv.into());
|
||||
json_packages.insert(pkg.id.as_serialized().into_string(), kv.into());
|
||||
}
|
||||
|
||||
json.insert("npmPackages".to_string(), json_packages.into());
|
||||
|
@ -549,7 +551,7 @@ impl<'a> GraphDisplayContext<'a> {
|
|||
None => Specifier(module.specifier().clone()),
|
||||
};
|
||||
let was_seen = !self.seen.insert(match &package_or_specifier {
|
||||
Package(package) => package.id.as_serialized(),
|
||||
Package(package) => package.id.as_serialized().into_string(),
|
||||
Specifier(specifier) => specifier.to_string(),
|
||||
});
|
||||
let header_text = if was_seen {
|
||||
|
@ -631,7 +633,8 @@ impl<'a> GraphDisplayContext<'a> {
|
|||
));
|
||||
if let Some(package) = self.npm_info.packages.get(dep_id) {
|
||||
if !package.dependencies.is_empty() {
|
||||
let was_seen = !self.seen.insert(package.id.as_serialized());
|
||||
let was_seen =
|
||||
!self.seen.insert(package.id.as_serialized().into_string());
|
||||
if was_seen {
|
||||
child.text = format!("{} {}", child.text, colors::gray("*"));
|
||||
} else {
|
||||
|
|
|
@ -161,11 +161,11 @@ pub async fn infer_name_from_url(
|
|||
let npm_ref = npm_ref.into_inner();
|
||||
if let Some(sub_path) = npm_ref.sub_path {
|
||||
if !sub_path.contains('/') {
|
||||
return Some(sub_path);
|
||||
return Some(sub_path.to_string());
|
||||
}
|
||||
}
|
||||
if !npm_ref.req.name.contains('/') {
|
||||
return Some(npm_ref.req.name);
|
||||
return Some(npm_ref.req.name.into_string());
|
||||
}
|
||||
return None;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ use deno_semver::jsr::JsrPackageReqReference;
|
|||
use deno_semver::npm::NpmPackageReqReference;
|
||||
use deno_semver::package::PackageNv;
|
||||
use deno_semver::package::PackageReq;
|
||||
use deno_semver::StackString;
|
||||
use deno_semver::Version;
|
||||
use deno_semver::VersionReq;
|
||||
use deps::KeyPath;
|
||||
|
@ -283,7 +284,7 @@ fn package_json_dependency_entry(
|
|||
(npm_package.into(), selected.version_req)
|
||||
} else {
|
||||
(
|
||||
selected.import_name,
|
||||
selected.import_name.into_string(),
|
||||
format!("npm:{}@{}", npm_package, selected.version_req),
|
||||
)
|
||||
}
|
||||
|
@ -292,7 +293,7 @@ fn package_json_dependency_entry(
|
|||
let scope_replaced = jsr_package.replace('/', "__");
|
||||
let version_req =
|
||||
format!("npm:@jsr/{scope_replaced}@{}", selected.version_req);
|
||||
(selected.import_name, version_req)
|
||||
(selected.import_name.into_string(), version_req)
|
||||
} else {
|
||||
(selected.package_name, selected.version_req)
|
||||
}
|
||||
|
@ -549,10 +550,10 @@ pub async fn add(
|
|||
}
|
||||
|
||||
struct SelectedPackage {
|
||||
import_name: String,
|
||||
import_name: StackString,
|
||||
package_name: String,
|
||||
version_req: String,
|
||||
selected_version: String,
|
||||
selected_version: StackString,
|
||||
}
|
||||
|
||||
enum NotFoundHelp {
|
||||
|
@ -683,7 +684,7 @@ async fn find_package_and_select_version_for_req(
|
|||
import_name: add_package_req.alias,
|
||||
package_name: prefixed_name,
|
||||
version_req: format!("{}{}", range_symbol, &nv.version),
|
||||
selected_version: nv.version.to_string(),
|
||||
selected_version: nv.version.to_custom_string::<StackString>(),
|
||||
}))
|
||||
}
|
||||
|
||||
|
@ -705,7 +706,7 @@ enum AddRmPackageReqValue {
|
|||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct AddRmPackageReq {
|
||||
alias: String,
|
||||
alias: StackString,
|
||||
value: AddRmPackageReqValue,
|
||||
}
|
||||
|
||||
|
@ -753,7 +754,11 @@ impl AddRmPackageReq {
|
|||
return Ok(Err(PackageReq::from_str(entry_text)?));
|
||||
}
|
||||
|
||||
(maybe_prefix.unwrap(), Some(alias.to_string()), entry_text)
|
||||
(
|
||||
maybe_prefix.unwrap(),
|
||||
Some(StackString::from(alias)),
|
||||
entry_text,
|
||||
)
|
||||
}
|
||||
None => return Ok(Err(PackageReq::from_str(entry_text)?)),
|
||||
},
|
||||
|
@ -765,7 +770,7 @@ impl AddRmPackageReq {
|
|||
JsrPackageReqReference::from_str(&format!("jsr:{}", entry_text))?;
|
||||
let package_req = req_ref.into_inner().req;
|
||||
Ok(Ok(AddRmPackageReq {
|
||||
alias: maybe_alias.unwrap_or_else(|| package_req.name.to_string()),
|
||||
alias: maybe_alias.unwrap_or_else(|| package_req.name.clone()),
|
||||
value: AddRmPackageReqValue::Jsr(package_req),
|
||||
}))
|
||||
}
|
||||
|
@ -785,7 +790,7 @@ impl AddRmPackageReq {
|
|||
);
|
||||
}
|
||||
Ok(Ok(AddRmPackageReq {
|
||||
alias: maybe_alias.unwrap_or_else(|| package_req.name.to_string()),
|
||||
alias: maybe_alias.unwrap_or_else(|| package_req.name.clone()),
|
||||
value: AddRmPackageReqValue::Npm(package_req),
|
||||
}))
|
||||
}
|
||||
|
@ -878,14 +883,14 @@ mod test {
|
|||
assert_eq!(
|
||||
AddRmPackageReq::parse("jsr:foo").unwrap().unwrap(),
|
||||
AddRmPackageReq {
|
||||
alias: "foo".to_string(),
|
||||
alias: "foo".into(),
|
||||
value: AddRmPackageReqValue::Jsr(PackageReq::from_str("foo").unwrap())
|
||||
}
|
||||
);
|
||||
assert_eq!(
|
||||
AddRmPackageReq::parse("alias@jsr:foo").unwrap().unwrap(),
|
||||
AddRmPackageReq {
|
||||
alias: "alias".to_string(),
|
||||
alias: "alias".into(),
|
||||
value: AddRmPackageReqValue::Jsr(PackageReq::from_str("foo").unwrap())
|
||||
}
|
||||
);
|
||||
|
@ -894,7 +899,7 @@ mod test {
|
|||
.unwrap()
|
||||
.unwrap(),
|
||||
AddRmPackageReq {
|
||||
alias: "@alias/pkg".to_string(),
|
||||
alias: "@alias/pkg".into(),
|
||||
value: AddRmPackageReqValue::Npm(
|
||||
PackageReq::from_str("foo@latest").unwrap()
|
||||
)
|
||||
|
@ -905,7 +910,7 @@ mod test {
|
|||
.unwrap()
|
||||
.unwrap(),
|
||||
AddRmPackageReq {
|
||||
alias: "@alias/pkg".to_string(),
|
||||
alias: "@alias/pkg".into(),
|
||||
value: AddRmPackageReqValue::Jsr(PackageReq::from_str("foo").unwrap())
|
||||
}
|
||||
);
|
||||
|
@ -914,7 +919,7 @@ mod test {
|
|||
.unwrap()
|
||||
.unwrap(),
|
||||
AddRmPackageReq {
|
||||
alias: "alias".to_string(),
|
||||
alias: "alias".into(),
|
||||
value: AddRmPackageReqValue::Jsr(
|
||||
PackageReq::from_str("foo@^1.5.0").unwrap()
|
||||
)
|
||||
|
|
|
@ -27,6 +27,7 @@ use deno_semver::npm::NpmPackageReqReference;
|
|||
use deno_semver::package::PackageNv;
|
||||
use deno_semver::package::PackageReq;
|
||||
use deno_semver::package::PackageReqReference;
|
||||
use deno_semver::StackString;
|
||||
use deno_semver::Version;
|
||||
use deno_semver::VersionReq;
|
||||
use import_map::ImportMap;
|
||||
|
@ -139,13 +140,7 @@ pub enum KeyPart {
|
|||
Scopes,
|
||||
Dependencies,
|
||||
DevDependencies,
|
||||
String(String),
|
||||
}
|
||||
|
||||
impl From<String> for KeyPart {
|
||||
fn from(value: String) -> Self {
|
||||
KeyPart::String(value)
|
||||
}
|
||||
String(StackString),
|
||||
}
|
||||
|
||||
impl From<PackageJsonDepKind> for KeyPart {
|
||||
|
@ -164,7 +159,7 @@ impl KeyPart {
|
|||
KeyPart::Scopes => "scopes",
|
||||
KeyPart::Dependencies => "dependencies",
|
||||
KeyPart::DevDependencies => "devDependencies",
|
||||
KeyPart::String(s) => s,
|
||||
KeyPart::String(s) => s.as_str(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -217,12 +212,12 @@ fn import_map_entries(
|
|||
.chain(import_map.scopes().flat_map(|scope| {
|
||||
let path = KeyPath::from_parts([
|
||||
KeyPart::Scopes,
|
||||
scope.raw_key.to_string().into(),
|
||||
KeyPart::String(scope.raw_key.into()),
|
||||
]);
|
||||
|
||||
scope.imports.entries().map(move |entry| {
|
||||
let mut full_path = path.clone();
|
||||
full_path.push(KeyPart::String(entry.raw_key.to_string()));
|
||||
full_path.push(KeyPart::String(entry.raw_key.into()));
|
||||
(full_path, entry)
|
||||
})
|
||||
}))
|
||||
|
@ -338,7 +333,7 @@ fn add_deps_from_package_json(
|
|||
package_json: &PackageJsonRc,
|
||||
mut filter: impl DepFilter,
|
||||
package_dep_kind: PackageJsonDepKind,
|
||||
package_json_deps: PackageJsonDepsMap,
|
||||
package_json_deps: &PackageJsonDepsMap,
|
||||
deps: &mut Vec<Dep>,
|
||||
) {
|
||||
for (k, v) in package_json_deps {
|
||||
|
@ -353,7 +348,7 @@ fn add_deps_from_package_json(
|
|||
deno_package_json::PackageJsonDepValue::Req(req) => {
|
||||
let alias = k.as_str();
|
||||
let alias = (alias != req.name).then(|| alias.to_string());
|
||||
if !filter.should_include(alias.as_deref(), &req, DepKind::Npm) {
|
||||
if !filter.should_include(alias.as_deref(), req, DepKind::Npm) {
|
||||
continue;
|
||||
}
|
||||
let id = DepId(deps.len());
|
||||
|
@ -362,9 +357,12 @@ fn add_deps_from_package_json(
|
|||
kind: DepKind::Npm,
|
||||
location: DepLocation::PackageJson(
|
||||
package_json.clone(),
|
||||
KeyPath::from_parts([package_dep_kind.into(), k.into()]),
|
||||
KeyPath::from_parts([
|
||||
package_dep_kind.into(),
|
||||
KeyPart::String(k.clone()),
|
||||
]),
|
||||
),
|
||||
req,
|
||||
req: req.clone(),
|
||||
alias,
|
||||
})
|
||||
}
|
||||
|
@ -377,14 +375,14 @@ fn add_deps_from_package_json(
|
|||
package_json,
|
||||
filter,
|
||||
PackageJsonDepKind::Normal,
|
||||
package_json_deps.dependencies,
|
||||
&package_json_deps.dependencies,
|
||||
deps,
|
||||
);
|
||||
iterate(
|
||||
package_json,
|
||||
filter,
|
||||
PackageJsonDepKind::Dev,
|
||||
package_json_deps.dev_dependencies,
|
||||
&package_json_deps.dev_dependencies,
|
||||
deps,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ use deno_core::anyhow::bail;
|
|||
use deno_core::error::AnyError;
|
||||
use deno_semver::package::PackageNv;
|
||||
use deno_semver::package::PackageReq;
|
||||
use deno_semver::StackString;
|
||||
use deno_semver::VersionReq;
|
||||
use deno_terminal::colors;
|
||||
|
||||
|
@ -31,7 +32,7 @@ struct OutdatedPackage {
|
|||
latest: String,
|
||||
semver_compatible: String,
|
||||
current: String,
|
||||
name: String,
|
||||
name: StackString,
|
||||
}
|
||||
|
||||
#[allow(clippy::print_stdout)]
|
||||
|
|
|
@ -21,6 +21,7 @@ use deno_core::anyhow::Context;
|
|||
use deno_core::error::AnyError;
|
||||
use deno_core::unsync::spawn;
|
||||
use deno_core::url::Url;
|
||||
use deno_semver::SmallStackString;
|
||||
use deno_semver::Version;
|
||||
use once_cell::sync::Lazy;
|
||||
use std::borrow::Cow;
|
||||
|
@ -255,7 +256,7 @@ async fn print_release_notes(
|
|||
let is_deno_2_rc = new_semver.major == 2
|
||||
&& new_semver.minor == 0
|
||||
&& new_semver.patch == 0
|
||||
&& new_semver.pre.first() == Some(&"rc".to_string());
|
||||
&& new_semver.pre.first().map(|s| s.as_str()) == Some("rc");
|
||||
|
||||
if is_deno_2_rc || is_switching_from_deno1_to_deno2 {
|
||||
log::info!(
|
||||
|
@ -674,7 +675,7 @@ impl RequestedVersion {
|
|||
);
|
||||
};
|
||||
|
||||
if semver.pre.contains(&"rc".to_string()) {
|
||||
if semver.pre.contains(&SmallStackString::from_static("rc")) {
|
||||
(ReleaseChannel::Rc, passed_version)
|
||||
} else {
|
||||
(ReleaseChannel::Stable, passed_version)
|
||||
|
|
|
@ -9,6 +9,7 @@ use deno_package_json::PackageJsonDepValue;
|
|||
use deno_package_json::PackageJsonRc;
|
||||
use deno_path_util::url_to_file_path;
|
||||
use deno_semver::package::PackageReq;
|
||||
use deno_semver::StackString;
|
||||
use deno_semver::Version;
|
||||
use node_resolver::env::NodeResolverEnv;
|
||||
use node_resolver::errors::PackageFolderResolveError;
|
||||
|
@ -30,7 +31,7 @@ use super::ResolvePkgFolderFromDenoReqError;
|
|||
#[derive(Debug, Error)]
|
||||
pub enum ByonmResolvePkgFolderFromDenoReqError {
|
||||
#[error("Could not find \"{}\" in a node_modules folder. Deno expects the node_modules/ directory to be up to date. Did you forget to run `deno install`?", .0)]
|
||||
MissingAlias(String),
|
||||
MissingAlias(StackString),
|
||||
#[error(transparent)]
|
||||
PackageJson(#[from] PackageJsonLoadError),
|
||||
#[error("Could not find a matching package for 'npm:{}' in the node_modules directory. Ensure you have all your JSR and npm dependencies listed in your deno.json or package.json, then run `deno install`. Alternatively, turn on auto-install by specifying `\"nodeModulesDir\": \"auto\"` in your deno.json file.", .0)]
|
||||
|
@ -177,16 +178,14 @@ impl<Fs: DenoResolverFs, TEnv: NodeResolverEnv> ByonmNpmResolver<Fs, TEnv> {
|
|||
&self,
|
||||
req: &PackageReq,
|
||||
referrer: &Url,
|
||||
) -> Result<Option<(PackageJsonRc, String)>, PackageJsonLoadError> {
|
||||
) -> Result<Option<(PackageJsonRc, StackString)>, PackageJsonLoadError> {
|
||||
fn resolve_alias_from_pkg_json(
|
||||
req: &PackageReq,
|
||||
pkg_json: &PackageJson,
|
||||
) -> Option<String> {
|
||||
) -> Option<StackString> {
|
||||
let deps = pkg_json.resolve_local_package_json_deps();
|
||||
for (key, value) in deps
|
||||
.dependencies
|
||||
.into_iter()
|
||||
.chain(deps.dev_dependencies.into_iter())
|
||||
for (key, value) in
|
||||
deps.dependencies.iter().chain(deps.dev_dependencies.iter())
|
||||
{
|
||||
if let Ok(value) = value {
|
||||
match value {
|
||||
|
@ -194,12 +193,14 @@ impl<Fs: DenoResolverFs, TEnv: NodeResolverEnv> ByonmNpmResolver<Fs, TEnv> {
|
|||
if dep_req.name == req.name
|
||||
&& dep_req.version_req.intersects(&req.version_req)
|
||||
{
|
||||
return Some(key);
|
||||
return Some(key.clone());
|
||||
}
|
||||
}
|
||||
PackageJsonDepValue::Workspace(_workspace) => {
|
||||
if key == req.name && req.version_req.tag() == Some("workspace") {
|
||||
return Some(key);
|
||||
if key.as_str() == req.name
|
||||
&& req.version_req.tag() == Some("workspace")
|
||||
{
|
||||
return Some(key.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -246,7 +247,7 @@ impl<Fs: DenoResolverFs, TEnv: NodeResolverEnv> ByonmNpmResolver<Fs, TEnv> {
|
|||
if let Ok(Some(dep_pkg_json)) =
|
||||
self.load_pkg_json(&pkg_folder.join("package.json"))
|
||||
{
|
||||
if dep_pkg_json.name.as_ref() == Some(&req.name) {
|
||||
if dep_pkg_json.name.as_deref() == Some(req.name.as_str()) {
|
||||
let matches_req = dep_pkg_json
|
||||
.version
|
||||
.as_ref()
|
||||
|
|
|
@ -318,6 +318,8 @@ impl<TEnv: NodeResolverEnv> NodeResolver<TEnv> {
|
|||
resolution_mode: ResolutionMode,
|
||||
resolution_kind: NodeResolutionKind,
|
||||
) -> Result<Url, PackageSubpathResolveError> {
|
||||
// todo(dsherret): don't allocate a string here (maybe use an
|
||||
// enum that says the subpath is not prefixed with a ./)
|
||||
let package_subpath = package_subpath
|
||||
.map(|s| format!("./{s}"))
|
||||
.unwrap_or_else(|| ".".to_string());
|
||||
|
|
|
@ -23,6 +23,7 @@ async-trait.workspace = true
|
|||
base64.workspace = true
|
||||
boxed_error.workspace = true
|
||||
deno_cache_dir.workspace = true
|
||||
deno_error.workspace = true
|
||||
deno_npm.workspace = true
|
||||
deno_semver.workspace = true
|
||||
deno_unsync = { workspace = true, features = ["tokio"] }
|
||||
|
|
|
@ -15,6 +15,7 @@ use deno_npm::npm_rc::ResolvedNpmRc;
|
|||
use deno_npm::registry::NpmPackageInfo;
|
||||
use deno_npm::NpmPackageCacheFolderId;
|
||||
use deno_semver::package::PackageNv;
|
||||
use deno_semver::StackString;
|
||||
use deno_semver::Version;
|
||||
use http::HeaderName;
|
||||
use http::HeaderValue;
|
||||
|
@ -260,7 +261,7 @@ impl<TEnv: NpmCacheEnv> NpmCache<TEnv> {
|
|||
.and_then(|cache_id| {
|
||||
Some(NpmPackageCacheFolderId {
|
||||
nv: PackageNv {
|
||||
name: cache_id.name,
|
||||
name: StackString::from_string(cache_id.name),
|
||||
version: Version::parse_from_npm(&cache_id.version).ok()?,
|
||||
},
|
||||
copy_index: cache_id.copy_index,
|
||||
|
|
|
@ -18,6 +18,7 @@ use deno_unsync::sync::MultiRuntimeAsyncValueCreator;
|
|||
use futures::future::LocalBoxFuture;
|
||||
use futures::FutureExt;
|
||||
use parking_lot::Mutex;
|
||||
use thiserror::Error;
|
||||
use url::Url;
|
||||
|
||||
use crate::remote::maybe_auth_header_for_npm_registry;
|
||||
|
@ -28,6 +29,31 @@ use crate::NpmCacheSetting;
|
|||
type LoadResult = Result<FutureResult, Arc<AnyError>>;
|
||||
type LoadFuture = LocalBoxFuture<'static, LoadResult>;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
#[error(transparent)]
|
||||
pub struct AnyhowJsError(pub AnyError);
|
||||
|
||||
impl deno_error::JsErrorClass for AnyhowJsError {
|
||||
fn get_class(&self) -> &'static str {
|
||||
"generic"
|
||||
}
|
||||
|
||||
fn get_message(&self) -> std::borrow::Cow<'static, str> {
|
||||
self.0.to_string().into()
|
||||
}
|
||||
|
||||
fn get_additional_properties(
|
||||
&self,
|
||||
) -> Option<
|
||||
Vec<(
|
||||
std::borrow::Cow<'static, str>,
|
||||
std::borrow::Cow<'static, str>,
|
||||
)>,
|
||||
> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
enum FutureResult {
|
||||
PackageNotExists,
|
||||
|
@ -157,9 +183,9 @@ impl<TEnv: NpmCacheEnv> RegistryInfoProvider<TEnv> {
|
|||
Ok(None) => Err(NpmRegistryPackageInfoLoadError::PackageNotExists {
|
||||
package_name: name.to_string(),
|
||||
}),
|
||||
Err(err) => {
|
||||
Err(NpmRegistryPackageInfoLoadError::LoadError(Arc::new(err)))
|
||||
}
|
||||
Err(err) => Err(NpmRegistryPackageInfoLoadError::LoadError(Arc::new(
|
||||
AnyhowJsError(err),
|
||||
))),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -236,7 +236,7 @@ mod test {
|
|||
#[test]
|
||||
pub fn test_verify_tarball() {
|
||||
let package = PackageNv {
|
||||
name: "package".to_string(),
|
||||
name: "package".into(),
|
||||
version: Version::parse_from_npm("1.0.0").unwrap(),
|
||||
};
|
||||
let actual_checksum =
|
||||
|
|
|
@ -183,7 +183,7 @@ impl PermissionState {
|
|||
PermissionState::Prompt if prompt => {
|
||||
let msg = {
|
||||
let info = info();
|
||||
StringBuilder::build(|builder| {
|
||||
StringBuilder::<String>::build(|builder| {
|
||||
builder.append(name);
|
||||
builder.append(" access");
|
||||
if let Some(info) = &info {
|
||||
|
@ -498,7 +498,7 @@ impl<TQuery: QueryDescriptor> UnaryPermission<TQuery> {
|
|||
}
|
||||
let maybe_formatted_display_name =
|
||||
desc.map(|d| format_display_name(d.display_name()));
|
||||
let message = StringBuilder::build(|builder| {
|
||||
let message = StringBuilder::<String>::build(|builder| {
|
||||
builder.append(TQuery::flag_name());
|
||||
builder.append(" access");
|
||||
if let Some(display_name) = &maybe_formatted_display_name {
|
||||
|
|
|
@ -218,7 +218,7 @@ fn npm_module_check_then_error() {
|
|||
"npm:@denotest/breaking-change-between-versions",
|
||||
)
|
||||
.unwrap(),
|
||||
"1.0.0".to_string(),
|
||||
"1.0.0".into(),
|
||||
);
|
||||
lockfile_path.write(lockfile.as_json_string());
|
||||
temp_dir.write(
|
||||
|
@ -236,7 +236,7 @@ fn npm_module_check_then_error() {
|
|||
"npm:@denotest/breaking-change-between-versions",
|
||||
)
|
||||
.unwrap(),
|
||||
"2.0.0".to_string(),
|
||||
"2.0.0".into(),
|
||||
);
|
||||
lockfile_path.write(lockfile.as_json_string());
|
||||
|
||||
|
|
|
@ -159,7 +159,7 @@ console.log(version);"#,
|
|||
.get_mut(
|
||||
&JsrDepPackageReq::from_str("jsr:@denotest/no-module-graph@0.1").unwrap(),
|
||||
)
|
||||
.unwrap() = "0.1.0".to_string();
|
||||
.unwrap() = "0.1.0".into();
|
||||
lockfile_path.write(lockfile.as_json_string());
|
||||
|
||||
test_context
|
||||
|
|
Loading…
Reference in a new issue