mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 20:29:11 +00:00
fix(vendor): strip jsr version meta module graph data (#29120)
This removes the `moduleGraphX` data from the `<version>_meta.json` files for jsr packages when copying from the global cache to the local one. This property is not really useful to vendor because it's just a performance optimization when downloading the files and someone may be changing the data in the files leading to the `moduleGraph` data to be out of date.
This commit is contained in:
parent
9fd7d463bd
commit
2bc8b9b7c7
4 changed files with 32 additions and 24 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -1687,9 +1687,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "deno_cache_dir"
|
||||
version = "0.19.2"
|
||||
version = "0.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "502c5f3120fe5b32908e9a4b3af95b7e1a35e8fa758d87155b03a3810655c9f0"
|
||||
checksum = "869a62459ded73382e018c7c58a07df170ba5f5befb67e18ee10494e769efe2a"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"base32",
|
||||
|
|
|
@ -56,7 +56,7 @@ repository = "https://github.com/denoland/deno"
|
|||
deno_ast = { version = "=0.46.6", features = ["transpiling"] }
|
||||
deno_core = { version = "0.345.0" }
|
||||
|
||||
deno_cache_dir = "=0.19.2"
|
||||
deno_cache_dir = "=0.20.0"
|
||||
deno_config = { version = "=0.54.2", features = ["workspace"] }
|
||||
deno_doc = "=0.172.0"
|
||||
deno_error = "=0.5.6"
|
||||
|
|
|
@ -47,6 +47,7 @@ use deno_lib::args::NPM_PROCESS_STATE;
|
|||
use deno_lib::version::DENO_VERSION_INFO;
|
||||
use deno_lib::worker::StorageKeyResolver;
|
||||
use deno_npm::NpmSystemInfo;
|
||||
use deno_resolver::factory::resolve_jsr_url;
|
||||
use deno_runtime::deno_permissions::PermissionsOptions;
|
||||
use deno_runtime::inspector_server::InspectorServer;
|
||||
use deno_semver::npm::NpmPackageReqReference;
|
||||
|
@ -67,27 +68,7 @@ use thiserror::Error;
|
|||
use crate::sys::CliSys;
|
||||
|
||||
pub fn jsr_url() -> &'static Url {
|
||||
static JSR_URL: Lazy<Url> = Lazy::new(|| {
|
||||
let env_var_name = "JSR_URL";
|
||||
if let Ok(registry_url) = std::env::var(env_var_name) {
|
||||
// ensure there is a trailing slash for the directory
|
||||
let registry_url = format!("{}/", registry_url.trim_end_matches('/'));
|
||||
match Url::parse(®istry_url) {
|
||||
Ok(url) => {
|
||||
return url;
|
||||
}
|
||||
Err(err) => {
|
||||
log::debug!(
|
||||
"Invalid {} environment variable: {:#}",
|
||||
env_var_name,
|
||||
err,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Url::parse("https://jsr.io/").unwrap()
|
||||
});
|
||||
static JSR_URL: Lazy<Url> = Lazy::new(|| resolve_jsr_url(&CliSys::default()));
|
||||
|
||||
&JSR_URL
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ use sys_traits::SystemRandom;
|
|||
use sys_traits::SystemTimeNow;
|
||||
use sys_traits::ThreadSleep;
|
||||
use thiserror::Error;
|
||||
use url::Url;
|
||||
|
||||
use crate::npm::managed::ManagedInNpmPkgCheckerCreateOptions;
|
||||
use crate::npm::managed::ManagedNpmResolverCreateOptions;
|
||||
|
@ -127,6 +128,25 @@ pub enum ConfigDiscoveryOption {
|
|||
Disabled,
|
||||
}
|
||||
|
||||
/// Resolves the JSR regsitry URL to use for the given system.
|
||||
pub fn resolve_jsr_url(sys: &impl sys_traits::EnvVar) -> Url {
|
||||
let env_var_name = "JSR_URL";
|
||||
if let Ok(registry_url) = sys.env_var(env_var_name) {
|
||||
// ensure there is a trailing slash for the directory
|
||||
let registry_url = format!("{}/", registry_url.trim_end_matches('/'));
|
||||
match Url::parse(®istry_url) {
|
||||
Ok(url) => {
|
||||
return url;
|
||||
}
|
||||
Err(err) => {
|
||||
log::debug!("Invalid {} environment variable: {:#}", env_var_name, err,);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Url::parse("https://jsr.io/").unwrap()
|
||||
}
|
||||
|
||||
#[async_trait::async_trait(?Send)]
|
||||
pub trait SpecifiedImportMapProvider:
|
||||
std::fmt::Debug + MaybeSend + MaybeSync
|
||||
|
@ -259,6 +279,7 @@ pub struct WorkspaceFactory<TSys: WorkspaceFactorySys + sys_traits::ThreadSleep>
|
|||
deno_dir_path: DenoDirPathProviderRc<TSys>,
|
||||
global_http_cache: Deferred<GlobalHttpCacheRc<TSys>>,
|
||||
http_cache: Deferred<GlobalOrLocalHttpCache<TSys>>,
|
||||
jsr_url: Deferred<Url>,
|
||||
node_modules_dir_path: Deferred<Option<PathBuf>>,
|
||||
npm_cache_dir: Deferred<NpmCacheDirRc>,
|
||||
npmrc: Deferred<ResolvedNpmRcRc>,
|
||||
|
@ -288,6 +309,7 @@ impl<TSys: WorkspaceFactorySys> WorkspaceFactory<TSys> {
|
|||
sys,
|
||||
global_http_cache: Default::default(),
|
||||
http_cache: Default::default(),
|
||||
jsr_url: Default::default(),
|
||||
node_modules_dir_path: Default::default(),
|
||||
npm_cache_dir: Default::default(),
|
||||
npmrc: Default::default(),
|
||||
|
@ -305,6 +327,10 @@ impl<TSys: WorkspaceFactorySys> WorkspaceFactory<TSys> {
|
|||
self.workspace_directory = Deferred::from(workspace_directory);
|
||||
}
|
||||
|
||||
pub fn jsr_url(&self) -> &Url {
|
||||
self.jsr_url.get_or_init(|| resolve_jsr_url(&self.sys))
|
||||
}
|
||||
|
||||
pub fn initial_cwd(&self) -> &PathBuf {
|
||||
&self.initial_cwd
|
||||
}
|
||||
|
@ -453,6 +479,7 @@ impl<TSys: WorkspaceFactorySys> WorkspaceFactory<TSys> {
|
|||
local_path.clone(),
|
||||
global_cache,
|
||||
deno_cache_dir::GlobalToLocalCopy::Allow,
|
||||
self.jsr_url().clone(),
|
||||
);
|
||||
Ok(new_rc(local_cache).into())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue