From 2a829e6d80ecb4815f380fe38ff0feeb29f273d5 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Wed, 13 Sep 2023 12:04:10 -0400 Subject: [PATCH] refactor: upgrade to deno_semver 0.5 (#293) --- Cargo.lock | 4 +- Cargo.toml | 2 +- src/graph.rs | 94 +++++++++---------- src/lib.rs | 2 +- src/{deno.rs => packages.rs} | 14 +-- src/source.rs | 12 +-- tests/integration_test.rs | 4 +- ....txt => JsrSpecifiers_ModuleGraphInfo.txt} | 22 ++--- ...s_ModuleGraphInfo_ModifiedCachedFiles.txt} | 28 +++--- ...xt => JsrSpecifiers_NoModuleGraphInfo.txt} | 48 +++++----- ...rs_NoPath.txt => JsrSpecifiers_NoPath.txt} | 20 ++-- ....txt => JsrSpecifiers_PackageNotExist.txt} | 18 ++-- ...srSpecifiers_SamePackageMultipleTimes.txt} | 36 +++---- ....txt => JsrSpecifiers_VersionNotExist.txt} | 18 ++-- ... => JsrSpecifiers_WorkspaceNotMatched.txt} | 26 ++--- ...paces.txt => JsrSpecifiers_Workspaces.txt} | 12 +-- 16 files changed, 179 insertions(+), 181 deletions(-) rename src/{deno.rs => packages.rs} (89%) rename tests/specs/graph/{DenoSpecifiers_ModuleGraphInfo.txt => JsrSpecifiers_ModuleGraphInfo.txt} (90%) rename tests/specs/graph/{DenoSpecifiers_ModuleGraphInfo_ModifiedCachedFiles.txt => JsrSpecifiers_ModuleGraphInfo_ModifiedCachedFiles.txt} (88%) rename tests/specs/graph/{DenoSpecifiers_NoModuleGraphInfo.txt => JsrSpecifiers_NoModuleGraphInfo.txt} (71%) rename tests/specs/graph/{DenoSpecifiers_NoPath.txt => JsrSpecifiers_NoPath.txt} (68%) rename tests/specs/graph/{DenoSpecifiers_PackageNotExist.txt => JsrSpecifiers_PackageNotExist.txt} (62%) rename tests/specs/graph/{DenoSpecifiers_SamePackageMultipleTimes.txt => JsrSpecifiers_SamePackageMultipleTimes.txt} (73%) rename tests/specs/graph/{DenoSpecifiers_VersionNotExist.txt => JsrSpecifiers_VersionNotExist.txt} (68%) rename tests/specs/graph/{DenoSpecifiers_WorkspaceNotMatched.txt => JsrSpecifiers_WorkspaceNotMatched.txt} (81%) rename tests/specs/graph/{DenoSpecifiers_Workspaces.txt => JsrSpecifiers_Workspaces.txt} (85%) diff --git a/Cargo.lock b/Cargo.lock index a270b8ad3..8ee15d49c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -213,9 +213,9 @@ dependencies = [ [[package]] name = "deno_semver" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f739a9d90c47e2af7e2fcbae0976360f3fb5292f7288a084d035ed44d12a288" +checksum = "594fd570fecc994ef602b96214f9d6c8ae11e60e29e37e89ab90af7f6b7f9d00" dependencies = [ "monch", "once_cell", diff --git a/Cargo.toml b/Cargo.toml index 6add858b8..7aa52af93 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,7 @@ anyhow = "1.0.43" async-trait = "0.1.68" data-url = "0.3.0" deno_ast = { version = "0.29.0", features = ["dep_graph", "module_specifier"] } -deno_semver = "0.4.0" +deno_semver = "0.5.0" futures = "0.3.26" indexmap = { version = "2", features = ["serde"] } monch = "0.4.3" diff --git a/src/graph.rs b/src/graph.rs index cedd5b064..320156fdc 100644 --- a/src/graph.rs +++ b/src/graph.rs @@ -11,13 +11,13 @@ use crate::DefaultModuleAnalyzer; use crate::ImportAttributes; use crate::ReferrerImports; -use crate::deno::resolve_version; -use crate::deno::DenoPackageInfo; -use crate::deno::DenoPackageVersionInfo; -use crate::deno::DenoSpecifierSnapshot; use crate::module_specifier::resolve_import; use crate::module_specifier::ModuleSpecifier; use crate::module_specifier::SpecifierError; +use crate::packages::resolve_version; +use crate::packages::JsrPackageInfo; +use crate::packages::JsrPackageVersionInfo; +use crate::packages::PackageSpecifiers; use crate::source::*; use anyhow::anyhow; @@ -28,7 +28,7 @@ use deno_ast::LineAndColumnIndex; use deno_ast::MediaType; use deno_ast::SourcePos; use deno_ast::SourceTextInfo; -use deno_semver::deno::DenoPackageReqReference; +use deno_semver::jsr::JsrPackageReqReference; use deno_semver::npm::NpmPackageNvReference; use deno_semver::npm::NpmPackageReqReference; use deno_semver::package::PackageNv; @@ -1237,9 +1237,9 @@ pub struct ModuleGraph { pub npm_packages: Vec, #[serde(skip_serializing)] pub has_node_specifier: bool, - #[serde(rename = "deno")] - #[serde(skip_serializing_if = "DenoSpecifierSnapshot::is_empty")] - pub deno_specifiers: DenoSpecifierSnapshot, + #[serde(rename = "packages")] + #[serde(skip_serializing_if = "PackageSpecifiers::is_empty")] + pub packages: PackageSpecifiers, } impl ModuleGraph { @@ -1252,7 +1252,7 @@ impl ModuleGraph { redirects: Default::default(), npm_packages: Default::default(), has_node_specifier: false, - deno_specifiers: Default::default(), + packages: Default::default(), } } @@ -2053,7 +2053,7 @@ impl From for PendingInfoResponse { #[derive(Clone)] struct DenoPackageVersionInfoExt { base_url: Url, - inner: Arc, + inner: Arc, } struct PendingInfo { @@ -2087,9 +2087,9 @@ struct PendingNpmState { pending_resolutions: Vec, } -struct PendingDenoResolutionItem { +struct PendingJsrResolutionItem { specifier: ModuleSpecifier, - package_ref: DenoPackageReqReference, + package_ref: JsrPackageReqReference, maybe_range: Option, } @@ -2104,12 +2104,12 @@ type PendingResult = Shared>>>; #[derive(Default)] -struct PendingDenoState { +struct PendingJsrState { pending_package_info_loads: - HashMap>>>, + HashMap>>>, pending_package_version_info_loads: - HashMap>>, - pending_resolutions: Vec, + HashMap>>, + pending_resolutions: Vec, pending_content_loads: FuturesUnordered>, } @@ -2117,7 +2117,7 @@ struct PendingDenoState { #[derive(Default)] struct PendingState { pending: FuturesOrdered, - deno: PendingDenoState, + jsr: PendingJsrState, npm: PendingNpmState, pending_specifiers: HashMap>>, @@ -2167,7 +2167,7 @@ impl std::fmt::Display for BuildDiagnostic { #[derive(Debug, Clone)] pub enum BuildDiagnosticKind { ConstraintNotMatchedWorkspaceVersion { - reference: DenoPackageReqReference, + reference: JsrPackageReqReference, workspace_version: Version, }, } @@ -2321,7 +2321,7 @@ impl<'a, 'graph> Builder<'a, 'graph> { } if self.state.pending.is_empty() { - let should_restart = self.resolve_pending_deno_specifiers().await; + let should_restart = self.resolve_pending_jsr_specifiers().await; if should_restart { self.restart(provided_roots, provided_imports).await; return; @@ -2338,7 +2338,7 @@ impl<'a, 'graph> Builder<'a, 'graph> { } // handle any pending content loads from the Deno registry - self.handle_deno_registry_pending_content_loads().await; + self.handle_jsr_registry_pending_content_loads().await; // enrich with cache info from the loader self.fill_graph_with_cache_info(); @@ -2367,17 +2367,17 @@ impl<'a, 'graph> Builder<'a, 'graph> { } } - async fn resolve_pending_deno_specifiers(&mut self) -> bool { + async fn resolve_pending_jsr_specifiers(&mut self) -> bool { // first load the package information let pending_resolutions = - std::mem::take(&mut self.state.deno.pending_resolutions); + std::mem::take(&mut self.state.jsr.pending_resolutions); let mut pending_version_resolutions = Vec::with_capacity(pending_resolutions.len()); for pending_resolution in pending_resolutions { let package_name = &pending_resolution.package_ref.req().name; let fut = self .state - .deno + .jsr .pending_package_info_loads .get(package_name) .unwrap() @@ -2386,7 +2386,7 @@ impl<'a, 'graph> Builder<'a, 'graph> { Ok(Some(info)) => { // resolve the best version out of the existing versions first let package_req = pending_resolution.package_ref.req(); - match self.resolve_deno_version(&info, package_req) { + match self.resolve_jsr_version(&info, package_req) { Some(version) => { // now queue a pending load for that version information let package_nv = PackageNv { @@ -2395,7 +2395,7 @@ impl<'a, 'graph> Builder<'a, 'graph> { }; self .graph - .deno_specifiers + .packages .add(package_req.clone(), package_nv.clone()); self.queue_load_package_version_info(&package_nv); @@ -2451,7 +2451,7 @@ impl<'a, 'graph> Builder<'a, 'graph> { for (nv, resolution_item) in pending_version_resolutions { let version_info_result = self .state - .deno + .jsr .pending_package_version_info_loads .get_mut(&nv) .unwrap() @@ -2526,8 +2526,8 @@ impl<'a, 'graph> Builder<'a, 'graph> { } } - async fn handle_deno_registry_pending_content_loads(&mut self) { - while let Some(item) = self.state.deno.pending_content_loads.next().await { + async fn handle_jsr_registry_pending_content_loads(&mut self) { + while let Some(item) = self.state.jsr.pending_content_loads.next().await { match item.result { Ok(Some(response)) => { match response { @@ -2540,7 +2540,7 @@ impl<'a, 'graph> Builder<'a, 'graph> { ModuleError::LoadingErr( item.specifier, item.maybe_range, - Arc::new(anyhow!("Loader should never return an external specifier for a deno: specifier.")), + Arc::new(anyhow!("Loader should never return an external specifier for a jsr: specifier.")), ), )), ); @@ -2655,16 +2655,14 @@ impl<'a, 'graph> Builder<'a, 'graph> { async move { self.fill(roots, imports).await }.boxed_local() } - fn resolve_deno_version( + fn resolve_jsr_version( &mut self, - package_info: &DenoPackageInfo, + package_info: &JsrPackageInfo, package_req: &PackageReq, ) -> Option { // try to find in the list of existing versions first - if let Some(existing_versions) = self - .graph - .deno_specifiers - .versions_by_name(&package_req.name) + if let Some(existing_versions) = + self.graph.packages.versions_by_name(&package_req.name) { if let Some(version) = resolve_version( &package_req.version_req, @@ -2772,8 +2770,8 @@ impl<'a, 'graph> Builder<'a, 'graph> { } let maybe_range = maybe_range.map(ToOwned::to_owned); - if specifier.scheme() == "deno" { - self.load_deno_specifier(specifier.clone(), maybe_range, is_dynamic); + if specifier.scheme() == "jsr" { + self.load_jsr_specifier(specifier.clone(), maybe_range, is_dynamic); return; } else if let Some(npm_resolver) = self.npm_resolver { if specifier.scheme() == "npm" { @@ -2816,13 +2814,13 @@ impl<'a, 'graph> Builder<'a, 'graph> { self.load_pending_module(&specifier, maybe_range, &specifier, is_dynamic); } - fn load_deno_specifier( + fn load_jsr_specifier( &mut self, specifier: Url, maybe_range: Option, is_dynamic: bool, ) { - match DenoPackageReqReference::from_specifier(&specifier) { + match JsrPackageReqReference::from_specifier(&specifier) { Ok(package_ref) => { for workspace_member in &self.workspace_members { if workspace_member.nv.name == package_ref.req().name { @@ -2860,9 +2858,9 @@ impl<'a, 'graph> Builder<'a, 'graph> { self.queue_load_package_info(package_name); self .state - .deno + .jsr .pending_resolutions - .push(PendingDenoResolutionItem { + .push(PendingJsrResolutionItem { specifier, package_ref, maybe_range, @@ -2962,7 +2960,7 @@ impl<'a, 'graph> Builder<'a, 'graph> { fn queue_load_package_info(&mut self, package_name: &str) { if self .state - .deno + .jsr .pending_package_info_loads .contains_key(package_name) { @@ -2984,7 +2982,7 @@ impl<'a, 'graph> Builder<'a, 'graph> { let data = fut.await.map_err(Arc::new)?; match data { Some(LoadResponse::Module { content, .. }) => { - let package_info: DenoPackageInfo = + let package_info: JsrPackageInfo = serde_json::from_str(&content).map_err(|e| Arc::new(e.into()))?; Ok(Some(Arc::new(package_info))) } @@ -2994,7 +2992,7 @@ impl<'a, 'graph> Builder<'a, 'graph> { .boxed_local(); self .state - .deno + .jsr .pending_package_info_loads .insert(package_name.to_string(), fut.shared()); } @@ -3002,7 +3000,7 @@ impl<'a, 'graph> Builder<'a, 'graph> { fn queue_load_package_version_info(&mut self, package_nv: &PackageNv) { if self .state - .deno + .jsr .pending_package_version_info_loads .contains_key(package_nv) { @@ -3026,7 +3024,7 @@ impl<'a, 'graph> Builder<'a, 'graph> { let data = fut.await.map_err(Arc::new)?; match data { Some(LoadResponse::Module { content, .. }) => { - let version_info: DenoPackageVersionInfo = + let version_info: JsrPackageVersionInfo = serde_json::from_str(&content).map_err(|e| Arc::new(e.into()))?; Ok(Arc::new(version_info)) } @@ -3036,7 +3034,7 @@ impl<'a, 'graph> Builder<'a, 'graph> { .boxed_local(); self .state - .deno + .jsr .pending_package_version_info_loads .insert(package_nv.clone(), fut.shared()); } @@ -3121,7 +3119,7 @@ impl<'a, 'graph> Builder<'a, 'graph> { let (content, maybe_module_analyzer) = match content_or_module_info { ContentOrModuleInfo::Content(content) => (content, None), ContentOrModuleInfo::ModuleInfo(info) => { - self.state.deno.pending_content_loads.push({ + self.state.jsr.pending_content_loads.push({ let specifier = specifier.clone(); let maybe_range = maybe_referrer.clone(); let module_info = info.clone(); diff --git a/src/lib.rs b/src/lib.rs index 09d1da821..288ac1330 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,7 +8,7 @@ mod module_specifier; #[cfg(feature = "type_tracing")] pub mod type_tracer; -pub mod deno; +pub mod packages; pub mod source; mod text_encoding; diff --git a/src/deno.rs b/src/packages.rs similarity index 89% rename from src/deno.rs rename to src/packages.rs index 345704f20..d60c3eb29 100644 --- a/src/deno.rs +++ b/src/packages.rs @@ -13,23 +13,23 @@ use serde::Serialize; use crate::ModuleInfo; #[derive(Serialize, Deserialize, Clone)] -pub struct DenoPackageInfo { - pub versions: HashMap, +pub struct JsrPackageInfo { + pub versions: HashMap, } #[derive(Serialize, Deserialize, Clone, Default)] -pub struct DenoPackageInfoVersion { +pub struct JsrPackageInfoVersion { // currently not supported because it doesn't work in workspaces // pub main: Option, } #[derive(Serialize, Deserialize, Clone, Default)] -pub struct DenoPackageVersionInfo { +pub struct JsrPackageVersionInfo { #[serde(rename = "moduleGraph1")] pub module_graph: Option, } -impl DenoPackageVersionInfo { +impl JsrPackageVersionInfo { pub fn module_info(&self, specifier: &str) -> Option { let module_graph = self.module_graph.as_ref()?.as_object()?; let module_info = module_graph.get(specifier)?; @@ -38,14 +38,14 @@ impl DenoPackageVersionInfo { } #[derive(Debug, Clone, Default, Serialize)] -pub struct DenoSpecifierSnapshot { +pub struct PackageSpecifiers { #[serde(flatten)] package_reqs: BTreeMap, #[serde(skip_serializing)] packages_by_name: HashMap>, } -impl DenoSpecifierSnapshot { +impl PackageSpecifiers { pub fn is_empty(&self) -> bool { self.package_reqs.is_empty() } diff --git a/src/source.rs b/src/source.rs index a497cf2a0..0e18c1e9f 100644 --- a/src/source.rs +++ b/src/source.rs @@ -1,9 +1,9 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -use crate::deno::DenoPackageInfo; -use crate::deno::DenoPackageVersionInfo; use crate::graph::Range; use crate::module_specifier::resolve_import; +use crate::packages::JsrPackageInfo; +use crate::packages::JsrPackageVersionInfo; use crate::text_encoding::strip_bom_mut; use crate::ModuleInfo; use deno_semver::package::PackageNv; @@ -75,7 +75,7 @@ pub type LoadFuture = LocalBoxFuture<'static, LoadResult>; pub enum CacheSetting { /// Attempts to load a specifier from the cache. /// - /// This is used to see whether the specifier is in the cache for `deno:` specifiers. + /// This is used to see whether the specifier is in the cache for `jsr:` specifiers. /// * If it is, then it will use the source provided to get the module information. /// * If not, then it will use the manifest information to do resolution and /// issue a separate request to the `load` method in order to get the source. @@ -84,7 +84,7 @@ pub enum CacheSetting { Use, /// Loads a specifier where the implementation should not load /// from an internal cache. This is only ever done when loading - /// `deno:` specifier module information and the version constraint + /// `jsr:` specifier module information and the version constraint /// cannot be resolved. Reload, } @@ -342,7 +342,7 @@ impl MemoryLoader { pub fn add_deno_package_info( &mut self, name: &str, - package_info: &DenoPackageInfo, + package_info: &JsrPackageInfo, ) { let specifier = DEFAULT_DENO_REGISTRY_URL .join(&format!("{}/meta.json", name)) @@ -354,7 +354,7 @@ impl MemoryLoader { pub fn add_deno_version_info( &mut self, nv: &PackageNv, - version_info: &DenoPackageVersionInfo, + version_info: &JsrPackageVersionInfo, ) { let specifier = DEFAULT_DENO_REGISTRY_URL .join(&format!("{}/{}_meta.json", nv.name, nv.version)) diff --git a/tests/integration_test.rs b/tests/integration_test.rs index e88628046..4e251fbce 100644 --- a/tests/integration_test.rs +++ b/tests/integration_test.rs @@ -233,7 +233,7 @@ async fn test_npm_version_not_found_then_found() { } #[tokio::test] -async fn test_deno_version_not_found_then_found() { +async fn test_jsr_version_not_found_then_found() { #[derive(Default)] struct TestLoader { requests: Vec<(String, CacheSetting)>, @@ -254,7 +254,7 @@ async fn test_deno_version_not_found_then_found() { Ok(Some(LoadResponse::Module { specifier: specifier.clone(), maybe_headers: None, - content: "import 'deno:@scope/a@1.2/mod.ts".into(), + content: "import 'jsr:@scope/a@1.2/mod.ts".into(), })) }), "https://registry-staging.deno.com/@scope/a/meta.json" => { diff --git a/tests/specs/graph/DenoSpecifiers_ModuleGraphInfo.txt b/tests/specs/graph/JsrSpecifiers_ModuleGraphInfo.txt similarity index 90% rename from tests/specs/graph/DenoSpecifiers_ModuleGraphInfo.txt rename to tests/specs/graph/JsrSpecifiers_ModuleGraphInfo.txt index c4c6fe2d1..9228c6665 100644 --- a/tests/specs/graph/DenoSpecifiers_ModuleGraphInfo.txt +++ b/tests/specs/graph/JsrSpecifiers_ModuleGraphInfo.txt @@ -25,7 +25,7 @@ }, { "kind": "import", "range": [[1, 2], [3, 4]], - "specifier": "deno:@scope/b/mod.ts", + "specifier": "jsr:@scope/b/mod.ts", "specifierRange": [[5, 6], [7, 8]] }] } @@ -54,7 +54,7 @@ } # mod.ts -import 'deno:@scope/a@^1.0/mod.ts'; +import 'jsr:@scope/a@^1.0/mod.ts'; # https://registry-staging.deno.com/@scope/a/1.0.0/mod.ts @@ -85,9 +85,9 @@ import './c.ts'; "kind": "esm", "dependencies": [ { - "specifier": "deno:@scope/a@^1.0/mod.ts", + "specifier": "jsr:@scope/a@^1.0/mod.ts", "code": { - "specifier": "deno:@scope/a@^1.0/mod.ts", + "specifier": "jsr:@scope/a@^1.0/mod.ts", "span": { "start": { "line": 0, @@ -95,13 +95,13 @@ import './c.ts'; }, "end": { "line": 0, - "character": 34 + "character": 33 } } } } ], - "size": 37, + "size": 36, "mediaType": "TypeScript", "specifier": "file:///mod.ts" }, @@ -125,9 +125,9 @@ import './c.ts'; } }, { - "specifier": "deno:@scope/b/mod.ts", + "specifier": "jsr:@scope/b/mod.ts", "code": { - "specifier": "deno:@scope/b/mod.ts", + "specifier": "jsr:@scope/b/mod.ts", "span": { "start": { "line": 5, @@ -231,10 +231,10 @@ import './c.ts'; } ], "redirects": { - "deno:@scope/a@^1.0/mod.ts": "https://registry-staging.deno.com/@scope/a/1.0.0/mod.ts", - "deno:@scope/b/mod.ts": "https://registry-staging.deno.com/@scope/b/9.0.0/mod.ts" + "jsr:@scope/a@^1.0/mod.ts": "https://registry-staging.deno.com/@scope/a/1.0.0/mod.ts", + "jsr:@scope/b/mod.ts": "https://registry-staging.deno.com/@scope/b/9.0.0/mod.ts" }, - "deno": { + "packages": { "@scope/a@^1.0": "@scope/a@1.0.0", "@scope/b": "@scope/b@9.0.0" } diff --git a/tests/specs/graph/DenoSpecifiers_ModuleGraphInfo_ModifiedCachedFiles.txt b/tests/specs/graph/JsrSpecifiers_ModuleGraphInfo_ModifiedCachedFiles.txt similarity index 88% rename from tests/specs/graph/DenoSpecifiers_ModuleGraphInfo_ModifiedCachedFiles.txt rename to tests/specs/graph/JsrSpecifiers_ModuleGraphInfo_ModifiedCachedFiles.txt index 48773b55a..9df316ebc 100644 --- a/tests/specs/graph/DenoSpecifiers_ModuleGraphInfo_ModifiedCachedFiles.txt +++ b/tests/specs/graph/JsrSpecifiers_ModuleGraphInfo_ModifiedCachedFiles.txt @@ -25,7 +25,7 @@ }, { "kind": "import", "range": [[1, 2], [3, 4]], - "specifier": "deno:@scope/b/mod.ts", + "specifier": "jsr:@scope/b/mod.ts", "specifierRange": [[5, 6], [7, 8]] }] }, @@ -63,7 +63,7 @@ } # mod.ts -import 'deno:@scope/a@^1.0/mod.ts'; +import 'jsr:@scope/a@^1.0/mod.ts'; # cache:https://registry-staging.deno.com/@scope/a/1.0.0/mod.ts import './a.ts'; @@ -75,7 +75,7 @@ import './b.ts'; 1; // will be ignored # cache:https://registry-staging.deno.com/@scope/a/1.0.0/c.ts -import 'deno:@scope/b/mod.ts'; +import 'jsr:@scope/b/mod.ts'; # cache:https://registry-staging.deno.com/@scope/b/9.0.0/mod.ts 4; @@ -90,9 +90,9 @@ import 'deno:@scope/b/mod.ts'; "kind": "esm", "dependencies": [ { - "specifier": "deno:@scope/a@^1.0/mod.ts", + "specifier": "jsr:@scope/a@^1.0/mod.ts", "code": { - "specifier": "deno:@scope/a@^1.0/mod.ts", + "specifier": "jsr:@scope/a@^1.0/mod.ts", "span": { "start": { "line": 0, @@ -100,13 +100,13 @@ import 'deno:@scope/b/mod.ts'; }, "end": { "line": 0, - "character": 34 + "character": 33 } } } } ], - "size": 36, + "size": 35, "mediaType": "TypeScript", "specifier": "file:///mod.ts" }, @@ -162,9 +162,9 @@ import 'deno:@scope/b/mod.ts'; "kind": "esm", "dependencies": [ { - "specifier": "deno:@scope/b/mod.ts", + "specifier": "jsr:@scope/b/mod.ts", "code": { - "specifier": "deno:@scope/b/mod.ts", + "specifier": "jsr:@scope/b/mod.ts", "span": { "start": { "line": 0, @@ -172,13 +172,13 @@ import 'deno:@scope/b/mod.ts'; }, "end": { "line": 0, - "character": 29 + "character": 28 } } } } ], - "size": 31, + "size": 30, "mediaType": "TypeScript", "specifier": "https://registry-staging.deno.com/@scope/a/1.0.0/c.ts" }, @@ -214,10 +214,10 @@ import 'deno:@scope/b/mod.ts'; } ], "redirects": { - "deno:@scope/a@^1.0/mod.ts": "https://registry-staging.deno.com/@scope/a/1.0.0/mod.ts", - "deno:@scope/b/mod.ts": "https://registry-staging.deno.com/@scope/b/9.0.0/mod.ts" + "jsr:@scope/a@^1.0/mod.ts": "https://registry-staging.deno.com/@scope/a/1.0.0/mod.ts", + "jsr:@scope/b/mod.ts": "https://registry-staging.deno.com/@scope/b/9.0.0/mod.ts" }, - "deno": { + "packages": { "@scope/a@^1.0": "@scope/a@1.0.0", "@scope/b": "@scope/b@9.0.0" } diff --git a/tests/specs/graph/DenoSpecifiers_NoModuleGraphInfo.txt b/tests/specs/graph/JsrSpecifiers_NoModuleGraphInfo.txt similarity index 71% rename from tests/specs/graph/DenoSpecifiers_NoModuleGraphInfo.txt rename to tests/specs/graph/JsrSpecifiers_NoModuleGraphInfo.txt index afffdf2b7..04e7ee618 100644 --- a/tests/specs/graph/DenoSpecifiers_NoModuleGraphInfo.txt +++ b/tests/specs/graph/JsrSpecifiers_NoModuleGraphInfo.txt @@ -34,15 +34,15 @@ {} # mod.ts -import 'deno:@scope/a/mod.ts' -import 'deno:@scope/c@3.0.0/mod.ts' +import 'jsr:@scope/a/mod.ts' +import 'jsr:@scope/c@3.0.0/mod.ts' # https://registry-staging.deno.com/@scope/a/1.0.1/mod.ts -import 'deno:@scope/b@2/sub_dir/sub.ts'; +import 'jsr:@scope/b@2/sub_dir/sub.ts'; # https://registry-staging.deno.com/@scope/b/2.0.0/sub_dir/sub.ts // should still resolve to 3.0.0 because that was resolved earlier -import 'deno:@scope/c@3/mod.ts'; +import 'jsr:@scope/c@3/mod.ts'; # https://registry-staging.deno.com/@scope/c/3.0.0/mod.ts console.log(1); @@ -57,9 +57,9 @@ console.log(1); "kind": "esm", "dependencies": [ { - "specifier": "deno:@scope/a/mod.ts", + "specifier": "jsr:@scope/a/mod.ts", "code": { - "specifier": "deno:@scope/a/mod.ts", + "specifier": "jsr:@scope/a/mod.ts", "span": { "start": { "line": 0, @@ -67,15 +67,15 @@ console.log(1); }, "end": { "line": 0, - "character": 29 + "character": 28 } } } }, { - "specifier": "deno:@scope/c@3.0.0/mod.ts", + "specifier": "jsr:@scope/c@3.0.0/mod.ts", "code": { - "specifier": "deno:@scope/c@3.0.0/mod.ts", + "specifier": "jsr:@scope/c@3.0.0/mod.ts", "span": { "start": { "line": 1, @@ -83,13 +83,13 @@ console.log(1); }, "end": { "line": 1, - "character": 35 + "character": 34 } } } } ], - "size": 66, + "size": 64, "mediaType": "TypeScript", "specifier": "file:///mod.ts" }, @@ -97,9 +97,9 @@ console.log(1); "kind": "esm", "dependencies": [ { - "specifier": "deno:@scope/b@2/sub_dir/sub.ts", + "specifier": "jsr:@scope/b@2/sub_dir/sub.ts", "code": { - "specifier": "deno:@scope/b@2/sub_dir/sub.ts", + "specifier": "jsr:@scope/b@2/sub_dir/sub.ts", "span": { "start": { "line": 0, @@ -107,13 +107,13 @@ console.log(1); }, "end": { "line": 0, - "character": 39 + "character": 38 } } } } ], - "size": 41, + "size": 40, "mediaType": "TypeScript", "specifier": "https://registry-staging.deno.com/@scope/a/1.0.1/mod.ts" }, @@ -121,9 +121,9 @@ console.log(1); "kind": "esm", "dependencies": [ { - "specifier": "deno:@scope/c@3/mod.ts", + "specifier": "jsr:@scope/c@3/mod.ts", "code": { - "specifier": "deno:@scope/c@3/mod.ts", + "specifier": "jsr:@scope/c@3/mod.ts", "span": { "start": { "line": 1, @@ -131,13 +131,13 @@ console.log(1); }, "end": { "line": 1, - "character": 31 + "character": 30 } } } } ], - "size": 100, + "size": 99, "mediaType": "TypeScript", "specifier": "https://registry-staging.deno.com/@scope/b/2.0.0/sub_dir/sub.ts" }, @@ -149,12 +149,12 @@ console.log(1); } ], "redirects": { - "deno:@scope/a/mod.ts": "https://registry-staging.deno.com/@scope/a/1.0.1/mod.ts", - "deno:@scope/b@2/sub_dir/sub.ts": "https://registry-staging.deno.com/@scope/b/2.0.0/sub_dir/sub.ts", - "deno:@scope/c@3.0.0/mod.ts": "https://registry-staging.deno.com/@scope/c/3.0.0/mod.ts", - "deno:@scope/c@3/mod.ts": "https://registry-staging.deno.com/@scope/c/3.0.0/mod.ts" + "jsr:@scope/a/mod.ts": "https://registry-staging.deno.com/@scope/a/1.0.1/mod.ts", + "jsr:@scope/b@2/sub_dir/sub.ts": "https://registry-staging.deno.com/@scope/b/2.0.0/sub_dir/sub.ts", + "jsr:@scope/c@3.0.0/mod.ts": "https://registry-staging.deno.com/@scope/c/3.0.0/mod.ts", + "jsr:@scope/c@3/mod.ts": "https://registry-staging.deno.com/@scope/c/3.0.0/mod.ts" }, - "deno": { + "packages": { "@scope/a": "@scope/a@1.0.1", "@scope/b@2": "@scope/b@2.0.0", "@scope/c@3.0.0": "@scope/c@3.0.0", diff --git a/tests/specs/graph/DenoSpecifiers_NoPath.txt b/tests/specs/graph/JsrSpecifiers_NoPath.txt similarity index 68% rename from tests/specs/graph/DenoSpecifiers_NoPath.txt rename to tests/specs/graph/JsrSpecifiers_NoPath.txt index 793a8ea03..c591ad336 100644 --- a/tests/specs/graph/DenoSpecifiers_NoPath.txt +++ b/tests/specs/graph/JsrSpecifiers_NoPath.txt @@ -9,7 +9,7 @@ {} # mod.ts -import 'deno:@scope/a' // no subpath +import 'jsr:@scope/a' // no subpath # output { @@ -17,17 +17,13 @@ import 'deno:@scope/a' // no subpath "file:///mod.ts" ], "modules": [ - { - "specifier": "deno:@scope/a", - "error": "Missing path in package specifier 'deno:@scope/a' (ex. specify deno:@scope/a/mod.ts)" - }, { "kind": "esm", "dependencies": [ { - "specifier": "deno:@scope/a", + "specifier": "jsr:@scope/a", "code": { - "specifier": "deno:@scope/a", + "specifier": "jsr:@scope/a", "span": { "start": { "line": 0, @@ -35,19 +31,23 @@ import 'deno:@scope/a' // no subpath }, "end": { "line": 0, - "character": 22 + "character": 21 } } } } ], - "size": 37, + "size": 36, "mediaType": "TypeScript", "specifier": "file:///mod.ts" + }, + { + "specifier": "jsr:@scope/a", + "error": "Missing path in package specifier 'jsr:@scope/a' (ex. specify jsr:@scope/a/mod.ts)" } ], "redirects": {}, - "deno": { + "packages": { "@scope/a": "@scope/a@1.0.0" } } diff --git a/tests/specs/graph/DenoSpecifiers_PackageNotExist.txt b/tests/specs/graph/JsrSpecifiers_PackageNotExist.txt similarity index 62% rename from tests/specs/graph/DenoSpecifiers_PackageNotExist.txt rename to tests/specs/graph/JsrSpecifiers_PackageNotExist.txt index cb26e8bb0..9bbcf3b7c 100644 --- a/tests/specs/graph/DenoSpecifiers_PackageNotExist.txt +++ b/tests/specs/graph/JsrSpecifiers_PackageNotExist.txt @@ -1,5 +1,5 @@ # mod.ts -import 'deno:@scope/a/mod.ts'; +import 'jsr:@scope/a/mod.ts'; # output { @@ -7,17 +7,13 @@ import 'deno:@scope/a/mod.ts'; "file:///mod.ts" ], "modules": [ - { - "specifier": "deno:@scope/a/mod.ts", - "error": "Unknown package: @scope/a\n Specifier: deno:@scope/a/mod.ts" - }, { "kind": "esm", "dependencies": [ { - "specifier": "deno:@scope/a/mod.ts", + "specifier": "jsr:@scope/a/mod.ts", "code": { - "specifier": "deno:@scope/a/mod.ts", + "specifier": "jsr:@scope/a/mod.ts", "span": { "start": { "line": 0, @@ -25,15 +21,19 @@ import 'deno:@scope/a/mod.ts'; }, "end": { "line": 0, - "character": 29 + "character": 28 } } } } ], - "size": 31, + "size": 30, "mediaType": "TypeScript", "specifier": "file:///mod.ts" + }, + { + "specifier": "jsr:@scope/a/mod.ts", + "error": "Unknown package: @scope/a\n Specifier: jsr:@scope/a/mod.ts" } ], "redirects": {} diff --git a/tests/specs/graph/DenoSpecifiers_SamePackageMultipleTimes.txt b/tests/specs/graph/JsrSpecifiers_SamePackageMultipleTimes.txt similarity index 73% rename from tests/specs/graph/DenoSpecifiers_SamePackageMultipleTimes.txt rename to tests/specs/graph/JsrSpecifiers_SamePackageMultipleTimes.txt index ef53dd95d..fbe71dca6 100644 --- a/tests/specs/graph/DenoSpecifiers_SamePackageMultipleTimes.txt +++ b/tests/specs/graph/JsrSpecifiers_SamePackageMultipleTimes.txt @@ -12,7 +12,7 @@ "dependencies": [{ "kind": "import", "range": [[1, 2], [3, 4]], - "specifier": "deno:@scope/b@1/mod.ts", + "specifier": "jsr:@scope/b@1/mod.ts", "specifierRange": [[5, 6], [7, 8]] }] } @@ -33,14 +33,14 @@ {} # https://registry-staging.deno.com/@scope/a/1.0.0/mod.ts -import "deno:@scope/b@1/mod.ts"; +import "jsr:@scope/b@1/mod.ts"; # https://registry-staging.deno.com/@scope/b/1.1.0/mod.ts console.log(1); # mod.ts -import "deno:@scope/a@^1.0/mod.ts"; -import "deno:@scope/b@1.1/mod.ts"; +import "jsr:@scope/a@^1.0/mod.ts"; +import "jsr:@scope/b@1.1/mod.ts"; # output { @@ -52,9 +52,9 @@ import "deno:@scope/b@1.1/mod.ts"; "kind": "esm", "dependencies": [ { - "specifier": "deno:@scope/a@^1.0/mod.ts", + "specifier": "jsr:@scope/a@^1.0/mod.ts", "code": { - "specifier": "deno:@scope/a@^1.0/mod.ts", + "specifier": "jsr:@scope/a@^1.0/mod.ts", "span": { "start": { "line": 0, @@ -62,15 +62,15 @@ import "deno:@scope/b@1.1/mod.ts"; }, "end": { "line": 0, - "character": 34 + "character": 33 } } } }, { - "specifier": "deno:@scope/b@1.1/mod.ts", + "specifier": "jsr:@scope/b@1.1/mod.ts", "code": { - "specifier": "deno:@scope/b@1.1/mod.ts", + "specifier": "jsr:@scope/b@1.1/mod.ts", "span": { "start": { "line": 1, @@ -78,13 +78,13 @@ import "deno:@scope/b@1.1/mod.ts"; }, "end": { "line": 1, - "character": 33 + "character": 32 } } } } ], - "size": 71, + "size": 69, "mediaType": "TypeScript", "specifier": "file:///mod.ts" }, @@ -92,9 +92,9 @@ import "deno:@scope/b@1.1/mod.ts"; "kind": "esm", "dependencies": [ { - "specifier": "deno:@scope/b@1/mod.ts", + "specifier": "jsr:@scope/b@1/mod.ts", "code": { - "specifier": "deno:@scope/b@1/mod.ts", + "specifier": "jsr:@scope/b@1/mod.ts", "span": { "start": { "line": 5, @@ -108,7 +108,7 @@ import "deno:@scope/b@1.1/mod.ts"; } } ], - "size": 33, + "size": 32, "mediaType": "TypeScript", "specifier": "https://registry-staging.deno.com/@scope/a/1.0.0/mod.ts" }, @@ -120,11 +120,11 @@ import "deno:@scope/b@1.1/mod.ts"; } ], "redirects": { - "deno:@scope/a@^1.0/mod.ts": "https://registry-staging.deno.com/@scope/a/1.0.0/mod.ts", - "deno:@scope/b@1.1/mod.ts": "https://registry-staging.deno.com/@scope/b/1.1.0/mod.ts", - "deno:@scope/b@1/mod.ts": "https://registry-staging.deno.com/@scope/b/1.1.0/mod.ts" + "jsr:@scope/a@^1.0/mod.ts": "https://registry-staging.deno.com/@scope/a/1.0.0/mod.ts", + "jsr:@scope/b@1.1/mod.ts": "https://registry-staging.deno.com/@scope/b/1.1.0/mod.ts", + "jsr:@scope/b@1/mod.ts": "https://registry-staging.deno.com/@scope/b/1.1.0/mod.ts" }, - "deno": { + "packages": { "@scope/a@^1.0": "@scope/a@1.0.0", "@scope/b@1.1": "@scope/b@1.1.0", "@scope/b@1": "@scope/b@1.1.0" diff --git a/tests/specs/graph/DenoSpecifiers_VersionNotExist.txt b/tests/specs/graph/JsrSpecifiers_VersionNotExist.txt similarity index 68% rename from tests/specs/graph/DenoSpecifiers_VersionNotExist.txt rename to tests/specs/graph/JsrSpecifiers_VersionNotExist.txt index 3a7f76973..6439bf8aa 100644 --- a/tests/specs/graph/DenoSpecifiers_VersionNotExist.txt +++ b/tests/specs/graph/JsrSpecifiers_VersionNotExist.txt @@ -6,7 +6,7 @@ } # mod.ts -import 'deno:@scope/a@1.0.1/mod.ts'; +import 'jsr:@scope/a@1.0.1/mod.ts'; # output { @@ -14,17 +14,13 @@ import 'deno:@scope/a@1.0.1/mod.ts'; "file:///mod.ts" ], "modules": [ - { - "specifier": "deno:@scope/a@1.0.1/mod.ts", - "error": "Could not find constraint in the list of versions: @scope/a@1.0.1\n Specifier: deno:@scope/a@1.0.1/mod.ts" - }, { "kind": "esm", "dependencies": [ { - "specifier": "deno:@scope/a@1.0.1/mod.ts", + "specifier": "jsr:@scope/a@1.0.1/mod.ts", "code": { - "specifier": "deno:@scope/a@1.0.1/mod.ts", + "specifier": "jsr:@scope/a@1.0.1/mod.ts", "span": { "start": { "line": 0, @@ -32,15 +28,19 @@ import 'deno:@scope/a@1.0.1/mod.ts'; }, "end": { "line": 0, - "character": 35 + "character": 34 } } } } ], - "size": 37, + "size": 36, "mediaType": "TypeScript", "specifier": "file:///mod.ts" + }, + { + "specifier": "jsr:@scope/a@1.0.1/mod.ts", + "error": "Could not find constraint in the list of versions: @scope/a@1.0.1\n Specifier: jsr:@scope/a@1.0.1/mod.ts" } ], "redirects": {} diff --git a/tests/specs/graph/DenoSpecifiers_WorkspaceNotMatched.txt b/tests/specs/graph/JsrSpecifiers_WorkspaceNotMatched.txt similarity index 81% rename from tests/specs/graph/DenoSpecifiers_WorkspaceNotMatched.txt rename to tests/specs/graph/JsrSpecifiers_WorkspaceNotMatched.txt index 4a9ed4f7e..b0ca4c53e 100644 --- a/tests/specs/graph/DenoSpecifiers_WorkspaceNotMatched.txt +++ b/tests/specs/graph/JsrSpecifiers_WorkspaceNotMatched.txt @@ -24,11 +24,11 @@ import "./members/a/mod.ts"; # members/a/mod.ts -import 'deno:@scope/b@2/mod.ts'; // this one will match +import 'jsr:@scope/b@2/mod.ts'; // this one will match import './next.ts'; # members/a/next.ts -import 'deno:@scope/b@2.0.3/mod.ts'; // this one will not match the workspace member +import 'jsr:@scope/b@2.0.3/mod.ts'; // this one will not match the workspace member # members/b/mod.ts console.log("Test"); @@ -43,9 +43,9 @@ console.log("Test"); "kind": "esm", "dependencies": [ { - "specifier": "deno:@scope/b@2/mod.ts", + "specifier": "jsr:@scope/b@2/mod.ts", "code": { - "specifier": "deno:@scope/b@2/mod.ts", + "specifier": "jsr:@scope/b@2/mod.ts", "span": { "start": { "line": 0, @@ -53,7 +53,7 @@ console.log("Test"); }, "end": { "line": 0, - "character": 31 + "character": 30 } } } @@ -75,7 +75,7 @@ console.log("Test"); } } ], - "size": 76, + "size": 75, "mediaType": "TypeScript", "specifier": "file:///members/a/mod.ts" }, @@ -83,9 +83,9 @@ console.log("Test"); "kind": "esm", "dependencies": [ { - "specifier": "deno:@scope/b@2.0.3/mod.ts", + "specifier": "jsr:@scope/b@2.0.3/mod.ts", "code": { - "specifier": "deno:@scope/b@2.0.3/mod.ts", + "specifier": "jsr:@scope/b@2.0.3/mod.ts", "span": { "start": { "line": 0, @@ -93,13 +93,13 @@ console.log("Test"); }, "end": { "line": 0, - "character": 35 + "character": 34 } } } } ], - "size": 85, + "size": 84, "mediaType": "TypeScript", "specifier": "file:///members/a/next.ts" }, @@ -139,10 +139,10 @@ console.log("Test"); } ], "redirects": { - "deno:@scope/b@2.0.3/mod.ts": "https://registry-staging.deno.com/@scope/b/2.0.3/mod.ts", - "deno:@scope/b@2/mod.ts": "file:///members/b/mod.ts" + "jsr:@scope/b@2.0.3/mod.ts": "https://registry-staging.deno.com/@scope/b/2.0.3/mod.ts", + "jsr:@scope/b@2/mod.ts": "file:///members/b/mod.ts" }, - "deno": { + "packages": { "@scope/b@2.0.3": "@scope/b@2.0.3" } } diff --git a/tests/specs/graph/DenoSpecifiers_Workspaces.txt b/tests/specs/graph/JsrSpecifiers_Workspaces.txt similarity index 85% rename from tests/specs/graph/DenoSpecifiers_Workspaces.txt rename to tests/specs/graph/JsrSpecifiers_Workspaces.txt index 1e7380353..a4880b287 100644 --- a/tests/specs/graph/DenoSpecifiers_Workspaces.txt +++ b/tests/specs/graph/JsrSpecifiers_Workspaces.txt @@ -14,7 +14,7 @@ import "./members/a/mod.ts"; # members/a/mod.ts -import 'deno:@scope/b@2/mod.ts'; +import 'jsr:@scope/b@2/mod.ts'; # members/b/mod.ts console.log("Test"); @@ -29,9 +29,9 @@ console.log("Test"); "kind": "esm", "dependencies": [ { - "specifier": "deno:@scope/b@2/mod.ts", + "specifier": "jsr:@scope/b@2/mod.ts", "code": { - "specifier": "deno:@scope/b@2/mod.ts", + "specifier": "jsr:@scope/b@2/mod.ts", "span": { "start": { "line": 0, @@ -39,13 +39,13 @@ console.log("Test"); }, "end": { "line": 0, - "character": 31 + "character": 30 } } } } ], - "size": 33, + "size": 32, "mediaType": "TypeScript", "specifier": "file:///members/a/mod.ts" }, @@ -81,6 +81,6 @@ console.log("Test"); } ], "redirects": { - "deno:@scope/b@2/mod.ts": "file:///members/b/mod.ts" + "jsr:@scope/b@2/mod.ts": "file:///members/b/mod.ts" } }