diff options
| author | David Sherret <dsherret@users.noreply.github.com> | 2024-07-03 20:54:33 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-04 00:54:33 +0000 |
| commit | 147411e64b22fe74cb258125acab83f9182c9f81 (patch) | |
| tree | a1f63dcbf0404c20534986b10f02b649df5a3ad5 /cli/tools/registry/publish_order.rs | |
| parent | dd6d19e12051fac2ea5639f621501f4710a1b8e1 (diff) | |
feat: npm workspace and better Deno workspace support (#24334)
Adds much better support for the unstable Deno workspaces as well as
support for npm workspaces. npm workspaces is still lacking in that we
only install packages into the root node_modules folder. We'll make it
smarter over time in order for it to figure out when to add node_modules
folders within packages.
This includes a breaking change in config file resolution where we stop
searching for config files on the first found package.json unless it's
in a workspace. For the previous behaviour, the root deno.json needs to
be updated to be a workspace by adding `"workspace":
["./path-to-pkg-json-folder-goes-here"]`. See details in
https://github.com/denoland/deno_config/pull/66
Closes #24340
Closes #24159
Closes #24161
Closes #22020
Closes #18546
Closes #16106
Closes #24160
Diffstat (limited to 'cli/tools/registry/publish_order.rs')
| -rw-r--r-- | cli/tools/registry/publish_order.rs | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/cli/tools/registry/publish_order.rs b/cli/tools/registry/publish_order.rs index ad0f72272..ad77a56bb 100644 --- a/cli/tools/registry/publish_order.rs +++ b/cli/tools/registry/publish_order.rs @@ -5,7 +5,7 @@ use std::collections::HashSet; use std::collections::VecDeque; use deno_ast::ModuleSpecifier; -use deno_config::WorkspaceMemberConfig; +use deno_config::workspace::JsrPackageConfig; use deno_core::anyhow::bail; use deno_core::error::AnyError; use deno_graph::ModuleGraph; @@ -114,7 +114,7 @@ impl PublishOrderGraph { pub fn build_publish_order_graph( graph: &ModuleGraph, - roots: &[WorkspaceMemberConfig], + roots: &[JsrPackageConfig], ) -> Result<PublishOrderGraph, AnyError> { let packages = build_pkg_deps(graph, roots)?; Ok(build_publish_order_graph_from_pkgs_deps(packages)) @@ -122,18 +122,23 @@ pub fn build_publish_order_graph( fn build_pkg_deps( graph: &deno_graph::ModuleGraph, - roots: &[WorkspaceMemberConfig], + roots: &[JsrPackageConfig], ) -> Result<HashMap<String, HashSet<String>>, AnyError> { let mut members = HashMap::with_capacity(roots.len()); let mut seen_modules = HashSet::with_capacity(graph.modules().count()); let roots = roots .iter() - .map(|r| (ModuleSpecifier::from_file_path(&r.dir_path).unwrap(), r)) + .map(|r| { + ( + ModuleSpecifier::from_directory_path(r.config_file.dir_path()).unwrap(), + r, + ) + }) .collect::<Vec<_>>(); - for (root_dir_url, root) in &roots { + for (root_dir_url, pkg_config) in &roots { let mut deps = HashSet::new(); let mut pending = VecDeque::new(); - pending.extend(root.config_file.resolve_export_value_urls()?); + pending.extend(pkg_config.config_file.resolve_export_value_urls()?); while let Some(specifier) = pending.pop_front() { let Some(module) = graph.get(&specifier).and_then(|m| m.js()) else { continue; @@ -168,12 +173,12 @@ fn build_pkg_deps( specifier.as_str().starts_with(dir_url.as_str()) }); if let Some(root) = found_root { - deps.insert(root.1.package_name.clone()); + deps.insert(root.1.name.clone()); } } } } - members.insert(root.package_name.clone(), deps); + members.insert(pkg_config.name.clone(), deps); } Ok(members) } |
