Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 2 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
49 changes: 35 additions & 14 deletions src/workspace/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use deno_package_json::PackageJsonRc;
use deno_semver::package::PackageNv;
use deno_semver::package::PackageReq;
use deno_semver::RangeSetOrTag;
use deno_semver::Version;
use deno_semver::VersionReq;
use discovery::discover_workspace_config_files;
use discovery::ConfigFileDiscovery;
Expand Down Expand Up @@ -59,6 +60,7 @@ pub use resolver::CreateResolverOptions;
pub use resolver::MappedResolution;
pub use resolver::MappedResolutionError;
pub use resolver::PackageJsonDepResolution;
pub use resolver::ResolverWorkspaceJsrPackage;
pub use resolver::SpecifiedImportMap;
pub use resolver::WorkspaceResolvePkgJsonFolderError;
pub use resolver::WorkspaceResolvePkgJsonFolderErrorKind;
Expand Down Expand Up @@ -384,27 +386,46 @@ impl Workspace {
.filter_map(|f| f.deno_json.as_ref())
}

pub fn resolver_jsr_pkgs(
&self,
) -> impl Iterator<Item = ResolverWorkspaceJsrPackage> + '_ {
self.deno_jsons().filter_map(|config_file| {
let name = config_file.json.name.as_ref()?;
let version = config_file
.json
.version
.as_ref()
.and_then(|v| Version::parse_standard(v).ok());
let exports_config = config_file.to_exports_config().ok()?;
Some(ResolverWorkspaceJsrPackage {
base: Url::from_directory_path(config_file.dir_path()).unwrap(),
name: name.to_string(),
version,
exports: exports_config.into_map(),
})
})
}

pub fn package_jsons(&self) -> impl Iterator<Item = &PackageJsonRc> {
self
.config_folders
.values()
.filter_map(|f| f.pkg_json.as_ref())
}

pub fn jsr_packages(self: &WorkspaceRc) -> Vec<JsrPackageConfig> {
self
.deno_jsons()
.filter_map(|c| {
if !c.is_package() {
return None;
}
Some(JsrPackageConfig {
member_dir: self.resolve_member_dir(&c.specifier),
name: c.json.name.clone()?,
config_file: c.clone(),
})
pub fn jsr_packages<'a>(
self: &'a WorkspaceRc,
) -> impl Iterator<Item = JsrPackageConfig> + 'a {
self.deno_jsons().filter_map(|c| {
if !c.is_package() {
return None;
}
Some(JsrPackageConfig {
member_dir: self.resolve_member_dir(&c.specifier),
name: c.json.name.clone()?,
config_file: c.clone(),
})
.collect()
})
}

pub fn npm_packages(self: &WorkspaceRc) -> Vec<NpmPackageConfig> {
Expand Down Expand Up @@ -1163,7 +1184,7 @@ impl WorkspaceDirectory {
}
}
if self.dir_url == self.workspace.root_dir {
self.workspace.jsr_packages()
self.workspace.jsr_packages().collect()
} else {
// nothing to publish
Vec::new()
Expand Down
Loading