Skip to content

Commit

Permalink
feat: remove WorkspaceResolver (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
nayeemrmn authored Feb 5, 2025
1 parent 8f14012 commit 8d3851d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2,101 deletions.
58 changes: 9 additions & 49 deletions src/workspace/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,27 +65,21 @@ use crate::sync::new_rc;
use crate::UrlToFilePathError;

mod discovery;
mod resolver;

pub use resolver::CreateResolverOptions;
pub use resolver::MappedResolution;
pub use resolver::MappedResolutionDiagnostic;
pub use resolver::MappedResolutionError;
pub use resolver::PackageJsonDepResolution;
pub use resolver::ResolutionKind;
pub use resolver::ResolverWorkspaceJsrPackage;
pub use resolver::SpecifiedImportMap;
pub use resolver::WorkspaceResolvePkgJsonFolderError;
pub use resolver::WorkspaceResolvePkgJsonFolderErrorKind;
pub use resolver::WorkspaceResolver;
pub use resolver::WorkspaceResolverCreateError;
pub use resolver::WorkspaceResolverDiagnostic;

#[allow(clippy::disallowed_types)]
type UrlRc = crate::sync::MaybeArc<Url>;
#[allow(clippy::disallowed_types)]
type WorkspaceRc = crate::sync::MaybeArc<Workspace>;

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ResolverWorkspaceJsrPackage {
pub base: Url,
pub name: String,
pub version: Option<Version>,
pub exports: IndexMap<String, String>,
pub is_patch: bool,
}

#[derive(Debug, Clone)]
pub struct JsrPackageConfig {
/// The package name.
Expand Down Expand Up @@ -560,14 +554,6 @@ impl Workspace {
})
}

pub fn create_resolver<TSys: FsMetadata + FsRead>(
&self,
sys: TSys,
options: CreateResolverOptions,
) -> Result<WorkspaceResolver<TSys>, WorkspaceResolverCreateError> {
WorkspaceResolver::from_workspace(self, sys, options)
}

/// Resolves a workspace directory, which can be used for deriving
/// configuration specific to a member.
pub fn resolve_member_dir(
Expand Down Expand Up @@ -2733,32 +2719,6 @@ pub mod test {
.unwrap(),
}]
);
let resolver = workspace_dir
.workspace
.create_resolver(UnreachableSys, Default::default())
.unwrap();
assert_eq!(
serde_json::from_str::<serde_json::Value>(
&resolver.maybe_import_map().unwrap().to_json()
)
.unwrap(),
json!({
"imports": {
"@scope/pkg": "jsr:@scope/pkg@1",
"@scope/pkg/": "jsr:/@scope/pkg@1/"
},
"scopes": {
"https://deno.land/x/": {
"@scope/pkg": "jsr:@scope/pkg@2",
"@scope/pkg/": "jsr:/@scope/pkg@2/"
},
"./member/": {
"@scope/pkg": "jsr:@scope/pkg@3",
"@scope/pkg/": "jsr:/@scope/pkg@3/"
}
}
})
);
}

#[test]
Expand Down
Loading

0 comments on commit 8d3851d

Please sign in to comment.