diff options
author | Marvin Hagemeister <marvin@deno.com> | 2024-02-23 15:56:49 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-23 15:56:49 +0100 |
commit | cddefecfff38215cef509aa6c0a2119682b49c15 (patch) | |
tree | 206068bb1eee956000404711f3aa8788080eed18 /cli/tools/registry/mod.rs | |
parent | 55fa61abc6490f98eb1bbd8ca02b34974fb54cb2 (diff) |
feat: infer dependencies from package.json (#22563)
<!--
Before submitting a PR, please read
https://docs.deno.com/runtime/manual/references/contributing
1. Give the PR a descriptive title.
Examples of good title:
- fix(std/http): Fix race condition in server
- docs(console): Update docstrings
- feat(doc): Handle nested reexports
Examples of bad title:
- fix #7123
- update docs
- fix bugs
2. Ensure there is a related issue and it is referenced in the PR text.
3. Ensure there are tests that cover the changes.
4. Ensure `cargo test` passes.
5. Ensure `./tools/format.js` passes without changing files.
6. Ensure `./tools/lint.js` passes.
7. Open as a draft PR if your work is still in progress. The CI won't
run
all steps, but you can add '[ci]' to a commit message to force it to.
8. If you would like to run the benchmarks on the CI, add the 'ci-bench'
label.
-->
This PR enhances the `deno publish` command to infer dependencies from
`package.json` if present.
Diffstat (limited to 'cli/tools/registry/mod.rs')
-rw-r--r-- | cli/tools/registry/mod.rs | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/cli/tools/registry/mod.rs b/cli/tools/registry/mod.rs index aea5dc634..ab02bc8d5 100644 --- a/cli/tools/registry/mod.rs +++ b/cli/tools/registry/mod.rs @@ -34,6 +34,7 @@ use crate::cache::ParsedSourceCache; use crate::factory::CliFactory; use crate::graph_util::ModuleGraphCreator; use crate::http_util::HttpClient; +use crate::resolver::MappedSpecifierResolver; use crate::tools::check::CheckOptions; use crate::tools::lint::no_slow_types; use crate::tools::registry::diagnostics::PublishDiagnostic; @@ -85,7 +86,7 @@ async fn prepare_publish( deno_json: &ConfigFile, source_cache: Arc<ParsedSourceCache>, graph: Arc<deno_graph::ModuleGraph>, - import_map: Arc<ImportMap>, + mapped_resolver: Arc<MappedSpecifierResolver>, diagnostics_collector: &PublishDiagnosticsCollector, ) -> Result<Rc<PreparedPublishPackage>, AnyError> { let config_path = deno_json.specifier.to_file_path().unwrap(); @@ -131,7 +132,7 @@ async fn prepare_publish( let diagnostics_collector = diagnostics_collector.clone(); let tarball = deno_core::unsync::spawn_blocking(move || { - let unfurler = ImportMapUnfurler::new(&import_map); + let unfurler = ImportMapUnfurler::new(&mapped_resolver); tar::create_gzipped_tarball( &dir_path, LazyGraphSourceParser::new(&source_cache, &graph), @@ -654,7 +655,7 @@ async fn prepare_packages_for_publishing( allow_slow_types: bool, diagnostics_collector: &PublishDiagnosticsCollector, deno_json: ConfigFile, - import_map: Arc<ImportMap>, + mapped_resolver: Arc<MappedSpecifierResolver>, ) -> Result<PreparePackagesData, AnyError> { let members = deno_json.to_workspace_members()?; let module_graph_creator = cli_factory.module_graph_creator().await?.as_ref(); @@ -684,7 +685,7 @@ async fn prepare_packages_for_publishing( let results = members .into_iter() .map(|member| { - let import_map = import_map.clone(); + let mapped_resolver = mapped_resolver.clone(); let graph = graph.clone(); async move { let package = prepare_publish( @@ -692,7 +693,7 @@ async fn prepare_packages_for_publishing( &member.config_file, source_cache.clone(), graph, - import_map, + mapped_resolver, diagnostics_collector, ) .await @@ -806,6 +807,11 @@ pub async fn publish( Arc::new(ImportMap::new(Url::parse("file:///dev/null").unwrap())) }); + let mapped_resolver = Arc::new(MappedSpecifierResolver::new( + Some(import_map), + cli_factory.package_json_deps_provider().clone(), + )); + let directory_path = cli_factory.cli_options().initial_cwd(); let cli_options = cli_factory.cli_options(); @@ -823,7 +829,7 @@ pub async fn publish( publish_flags.allow_slow_types, &diagnostics_collector, config_file.clone(), - import_map, + mapped_resolver, ) .await?; |