Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove WorkspaceResolver #156

Merged
merged 7 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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