1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-24 15:19:26 -05:00

chore: rename DENO_REGISTRY_URL to JSR_URL (#22414)

This commit is contained in:
Nayeem Rahman 2024-02-14 18:30:44 +00:00 committed by GitHub
parent b5d122de32
commit 012a9d8aeb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 30 additions and 30 deletions

View file

@ -102,9 +102,9 @@ pub fn npm_registry_default_url() -> &'static Url {
&NPM_REGISTRY_DEFAULT_URL &NPM_REGISTRY_DEFAULT_URL
} }
pub fn deno_registry_url() -> &'static Url { pub fn jsr_url() -> &'static Url {
static DENO_REGISTRY_URL: Lazy<Url> = Lazy::new(|| { static JSR_URL: Lazy<Url> = Lazy::new(|| {
let env_var_name = "DENO_REGISTRY_URL"; let env_var_name = "JSR_URL";
if let Ok(registry_url) = std::env::var(env_var_name) { if let Ok(registry_url) = std::env::var(env_var_name) {
// ensure there is a trailing slash for the directory // ensure there is a trailing slash for the directory
let registry_url = format!("{}/", registry_url.trim_end_matches('/')); let registry_url = format!("{}/", registry_url.trim_end_matches('/'));
@ -125,17 +125,17 @@ pub fn deno_registry_url() -> &'static Url {
Url::parse("https://jsr.io/").unwrap() Url::parse("https://jsr.io/").unwrap()
}); });
&DENO_REGISTRY_URL &JSR_URL
} }
pub fn deno_registry_api_url() -> &'static Url { pub fn jsr_api_url() -> &'static Url {
static DENO_REGISTRY_API_URL: Lazy<Url> = Lazy::new(|| { static JSR_API_URL: Lazy<Url> = Lazy::new(|| {
let mut deno_registry_api_url = deno_registry_url().clone(); let mut jsr_api_url = jsr_url().clone();
deno_registry_api_url.set_path("api/"); jsr_api_url.set_path("api/");
deno_registry_api_url jsr_api_url
}); });
&DENO_REGISTRY_API_URL &JSR_API_URL
} }
pub fn ts_config_to_emit_options( pub fn ts_config_to_emit_options(
@ -2018,10 +2018,10 @@ mod test {
} }
#[test] #[test]
fn deno_registry_urls() { fn jsr_urls() {
let reg_url = deno_registry_url(); let reg_url = jsr_url();
assert!(reg_url.as_str().ends_with('/')); assert!(reg_url.as_str().ends_with('/'));
let reg_api_url = deno_registry_api_url(); let reg_api_url = jsr_api_url();
assert!(reg_api_url.as_str().ends_with('/')); assert!(reg_api_url.as_str().ends_with('/'));
} }
} }

4
cli/cache/mod.rs vendored
View file

@ -1,6 +1,6 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
use crate::args::deno_registry_url; use crate::args::jsr_url;
use crate::args::CacheSetting; use crate::args::CacheSetting;
use crate::errors::get_error_class_name; use crate::errors::get_error_class_name;
use crate::file_fetcher::FetchOptions; use crate::file_fetcher::FetchOptions;
@ -168,7 +168,7 @@ impl FetchCacher {
impl Loader for FetchCacher { impl Loader for FetchCacher {
fn registry_url(&self) -> &Url { fn registry_url(&self) -> &Url {
deno_registry_url() jsr_url()
} }
fn get_cache_info(&self, specifier: &ModuleSpecifier) -> Option<CacheInfo> { fn get_cache_info(&self, specifier: &ModuleSpecifier) -> Option<CacheInfo> {

View file

@ -385,7 +385,7 @@ impl CliFactory {
let nv = PackageNv::from_str(nv).ok()?; let nv = PackageNv::from_str(nv).ok()?;
Some( Some(
deno_graph::source::recommended_registry_package_url( deno_graph::source::recommended_registry_package_url(
crate::args::deno_registry_url(), crate::args::jsr_url(),
&nv, &nv,
) )
.to_string(), .to_string(),

View file

@ -1,6 +1,6 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
use crate::args::deno_registry_url; use crate::args::jsr_url;
use deno_cache_dir::HttpCache; use deno_cache_dir::HttpCache;
use deno_core::parking_lot::Mutex; use deno_core::parking_lot::Mutex;
use deno_core::serde_json; use deno_core::serde_json;
@ -51,8 +51,8 @@ impl JsrResolver {
if info_by_nv.contains_key(nv) { if info_by_nv.contains_key(nv) {
continue; continue;
} }
let Ok(meta_url) = deno_registry_url() let Ok(meta_url) =
.join(&format!("{}/{}_meta.json", &nv.name, &nv.version)) jsr_url().join(&format!("{}/{}_meta.json", &nv.name, &nv.version))
else { else {
continue; continue;
}; };
@ -89,7 +89,7 @@ impl JsrResolver {
let nv = self.nv_by_req.get(req_ref.req())?; let nv = self.nv_by_req.get(req_ref.req())?;
let info = self.info_by_nv.get(nv)?; let info = self.info_by_nv.get(nv)?;
let path = info.export(&normalize_export_name(req_ref.sub_path()))?; let path = info.export(&normalize_export_name(req_ref.sub_path()))?;
deno_registry_url() jsr_url()
.join(&format!("{}/{}/{}", &nv.name, &nv.version, &path)) .join(&format!("{}/{}/{}", &nv.name, &nv.version, &path))
.ok() .ok()
} }

View file

@ -22,8 +22,8 @@ use lsp_types::Url;
use serde::Serialize; use serde::Serialize;
use sha2::Digest; use sha2::Digest;
use crate::args::deno_registry_api_url; use crate::args::jsr_api_url;
use crate::args::deno_registry_url; use crate::args::jsr_url;
use crate::args::CliOptions; use crate::args::CliOptions;
use crate::args::Flags; use crate::args::Flags;
use crate::args::PublishFlags; use crate::args::PublishFlags;
@ -454,8 +454,8 @@ async fn perform_publish(
auth_method: AuthMethod, auth_method: AuthMethod,
) -> Result<(), AnyError> { ) -> Result<(), AnyError> {
let client = http_client.client()?; let client = http_client.client()?;
let registry_api_url = deno_registry_api_url().to_string(); let registry_api_url = jsr_api_url().to_string();
let registry_url = deno_registry_url().to_string(); let registry_url = jsr_url().to_string();
let packages = prepared_package_by_name let packages = prepared_package_by_name
.values() .values()

View file

@ -709,8 +709,8 @@ impl TestCommandBuilder {
if !envs.contains_key("DENO_NO_UPDATE_CHECK") { if !envs.contains_key("DENO_NO_UPDATE_CHECK") {
envs.insert("DENO_NO_UPDATE_CHECK".to_string(), "1".to_string()); envs.insert("DENO_NO_UPDATE_CHECK".to_string(), "1".to_string());
} }
if !envs.contains_key("DENO_REGISTRY_URL") { if !envs.contains_key("JSR_URL") {
envs.insert("DENO_REGISTRY_URL".to_string(), jsr_registry_unset_url()); envs.insert("JSR_URL".to_string(), jsr_registry_unset_url());
} }
for key in &self.envs_remove { for key in &self.envs_remove {
envs.remove(key); envs.remove(key);

View file

@ -59,7 +59,7 @@ pub fn env_vars_for_npm_tests() -> Vec<(String, String)> {
pub fn env_vars_for_jsr_tests() -> Vec<(String, String)> { pub fn env_vars_for_jsr_tests() -> Vec<(String, String)> {
vec![ vec![
("DENO_REGISTRY_URL".to_string(), jsr_registry_url()), ("JSR_URL".to_string(), jsr_registry_url()),
("NO_COLOR".to_string(), "1".to_string()), ("NO_COLOR".to_string(), "1".to_string()),
] ]
} }
@ -114,7 +114,7 @@ pub fn jsr_registry_url() -> String {
} }
pub fn jsr_registry_unset_url() -> String { pub fn jsr_registry_unset_url() -> String {
"http://DENO_REGISTRY_URL.is.unset".to_string() "http://JSR_URL.is.unset".to_string()
} }
pub fn std_path() -> PathRef { pub fn std_path() -> PathRef {
@ -463,7 +463,7 @@ pub fn deno_cmd_with_deno_dir(deno_dir: &TempDir) -> TestCommandBuilder {
TestCommandBuilder::new(deno_dir.clone()) TestCommandBuilder::new(deno_dir.clone())
.env("DENO_DIR", deno_dir.path()) .env("DENO_DIR", deno_dir.path())
.env("NPM_CONFIG_REGISTRY", npm_registry_unset_url()) .env("NPM_CONFIG_REGISTRY", npm_registry_unset_url())
.env("DENO_REGISTRY_URL", jsr_registry_unset_url()) .env("JSR_URL", jsr_registry_unset_url())
} }
pub fn run_powershell_script_file( pub fn run_powershell_script_file(

View file

@ -524,7 +524,7 @@ impl LspClientBuilder {
command command
.env("DENO_DIR", deno_dir.path()) .env("DENO_DIR", deno_dir.path())
.env("NPM_CONFIG_REGISTRY", npm_registry_url()) .env("NPM_CONFIG_REGISTRY", npm_registry_url())
.env("DENO_REGISTRY_URL", jsr_registry_url()) .env("JSR_URL", jsr_registry_url())
// turn on diagnostic synchronization communication // turn on diagnostic synchronization communication
.env( .env(
"DENO_DONT_USE_INTERNAL_LSP_DIAGNOSTIC_SYNC_FLAG", "DENO_DONT_USE_INTERNAL_LSP_DIAGNOSTIC_SYNC_FLAG",