summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/tools/registry/mod.rs63
-rw-r--r--cli/tools/registry/paths.rs30
-rw-r--r--tests/specs/publish/byonm_dep/publish.out1
-rw-r--r--tests/specs/publish/excluded_deno_jsonc/__test__.jsonc14
-rw-r--r--tests/specs/publish/excluded_deno_jsonc/deno.jsonc5
-rw-r--r--tests/specs/publish/excluded_deno_jsonc/mod.out6
-rw-r--r--tests/specs/publish/excluded_deno_jsonc/mod.ts2
7 files changed, 83 insertions, 38 deletions
diff --git a/cli/tools/registry/mod.rs b/cli/tools/registry/mod.rs
index 1d1e5c54e..495f24588 100644
--- a/cli/tools/registry/mod.rs
+++ b/cli/tools/registry/mod.rs
@@ -151,35 +151,40 @@ async fn prepare_publish(
.map(|c| c.files)
.unwrap_or_else(|| FilePatterns::new_with_base(root_dir.to_path_buf()));
- let diagnostics_collector = diagnostics_collector.clone();
- let tarball = deno_core::unsync::spawn_blocking(move || {
- let bare_node_builtins = cli_options.unstable_bare_node_builtins();
- let unfurler = SpecifierUnfurler::new(
- &mapped_resolver,
- sloppy_imports_resolver.as_ref(),
- bare_node_builtins,
- );
- let root_specifier =
- ModuleSpecifier::from_directory_path(&root_dir).unwrap();
- let publish_paths = paths::collect_publish_paths(
- &root_dir,
- &cli_options,
- &diagnostics_collector,
- file_patterns,
- )?;
- collect_excluded_module_diagnostics(
- &root_specifier,
- &graph,
- &publish_paths,
- &diagnostics_collector,
- );
- tar::create_gzipped_tarball(
- &publish_paths,
- LazyGraphSourceParser::new(&source_cache, &graph),
- &diagnostics_collector,
- &unfurler,
- )
- .context("Failed to create a tarball")
+ let tarball = deno_core::unsync::spawn_blocking({
+ let diagnostics_collector = diagnostics_collector.clone();
+ let config_path = config_path.clone();
+ move || {
+ let bare_node_builtins = cli_options.unstable_bare_node_builtins();
+ let unfurler = SpecifierUnfurler::new(
+ &mapped_resolver,
+ sloppy_imports_resolver.as_ref(),
+ bare_node_builtins,
+ );
+ let root_specifier =
+ ModuleSpecifier::from_directory_path(&root_dir).unwrap();
+ let publish_paths =
+ paths::collect_publish_paths(paths::CollectPublishPathsOptions {
+ root_dir: &root_dir,
+ cli_options: &cli_options,
+ diagnostics_collector: &diagnostics_collector,
+ file_patterns,
+ force_include_paths: vec![config_path],
+ })?;
+ collect_excluded_module_diagnostics(
+ &root_specifier,
+ &graph,
+ &publish_paths,
+ &diagnostics_collector,
+ );
+ tar::create_gzipped_tarball(
+ &publish_paths,
+ LazyGraphSourceParser::new(&source_cache, &graph),
+ &diagnostics_collector,
+ &unfurler,
+ )
+ .context("Failed to create a tarball")
+ }
})
.await??;
diff --git a/cli/tools/registry/paths.rs b/cli/tools/registry/paths.rs
index 12282b77a..721ef6ece 100644
--- a/cli/tools/registry/paths.rs
+++ b/cli/tools/registry/paths.rs
@@ -217,17 +217,29 @@ pub struct CollectedPublishPath {
pub relative_path: String,
}
+pub struct CollectPublishPathsOptions<'a> {
+ pub root_dir: &'a Path,
+ pub cli_options: &'a CliOptions,
+ pub file_patterns: FilePatterns,
+ pub force_include_paths: Vec<PathBuf>,
+ pub diagnostics_collector: &'a PublishDiagnosticsCollector,
+}
+
pub fn collect_publish_paths(
- root_dir: &Path,
- cli_options: &CliOptions,
- diagnostics_collector: &PublishDiagnosticsCollector,
- file_patterns: FilePatterns,
+ opts: CollectPublishPathsOptions,
) -> Result<Vec<CollectedPublishPath>, AnyError> {
+ let diagnostics_collector = opts.diagnostics_collector;
let publish_paths =
- collect_paths(cli_options, diagnostics_collector, file_patterns)?;
- let mut paths = HashSet::with_capacity(publish_paths.len());
- let mut result = Vec::with_capacity(publish_paths.len());
- for path in publish_paths {
+ collect_paths(opts.cli_options, diagnostics_collector, opts.file_patterns)?;
+ let publish_paths_set = publish_paths.iter().cloned().collect::<HashSet<_>>();
+ let capacity = publish_paths.len() + opts.force_include_paths.len();
+ let mut paths = HashSet::with_capacity(capacity);
+ let mut result = Vec::with_capacity(capacity);
+ let force_include_paths = opts
+ .force_include_paths
+ .into_iter()
+ .filter(|path| !publish_paths_set.contains(path));
+ for path in publish_paths.into_iter().chain(force_include_paths) {
let Ok(specifier) = ModuleSpecifier::from_file_path(&path) else {
diagnostics_collector
.to_owned()
@@ -238,7 +250,7 @@ pub fn collect_publish_paths(
continue;
};
- let Ok(relative_path) = path.strip_prefix(root_dir) else {
+ let Ok(relative_path) = path.strip_prefix(opts.root_dir) else {
diagnostics_collector
.to_owned()
.push(PublishDiagnostic::InvalidPath {
diff --git a/tests/specs/publish/byonm_dep/publish.out b/tests/specs/publish/byonm_dep/publish.out
index f3b8a0dcc..a7433f86f 100644
--- a/tests/specs/publish/byonm_dep/publish.out
+++ b/tests/specs/publish/byonm_dep/publish.out
@@ -2,5 +2,6 @@ Check file:///[WILDLINE]/mod.ts
Checking for slow types in the public API...
Check file:///[WILDLINE]/mod.ts
Simulating publish of @scope/package@0.0.0 with files:
+ file:///[WILDLINE]/deno.jsonc (300B)
file:///[WILDLINE]/mod.ts (129B)
Warning Aborting due to --dry-run
diff --git a/tests/specs/publish/excluded_deno_jsonc/__test__.jsonc b/tests/specs/publish/excluded_deno_jsonc/__test__.jsonc
new file mode 100644
index 000000000..4e8607ae8
--- /dev/null
+++ b/tests/specs/publish/excluded_deno_jsonc/__test__.jsonc
@@ -0,0 +1,14 @@
+{
+ "tempDir": true,
+ "steps": [{
+ "args": [
+ "eval",
+ "Deno.writeTextFileSync('.gitignore', 'deno.jsonc')"
+ ],
+ "output": "[WILDCARD]"
+ }, {
+ "args": "publish --dry-run",
+ "output": "mod.out",
+ "exitCode": 0
+ }]
+}
diff --git a/tests/specs/publish/excluded_deno_jsonc/deno.jsonc b/tests/specs/publish/excluded_deno_jsonc/deno.jsonc
new file mode 100644
index 000000000..fe4300ad6
--- /dev/null
+++ b/tests/specs/publish/excluded_deno_jsonc/deno.jsonc
@@ -0,0 +1,5 @@
+{
+ "name": "@scope/pkg",
+ "version": "1.0.0",
+ "exports": "./mod.ts"
+}
diff --git a/tests/specs/publish/excluded_deno_jsonc/mod.out b/tests/specs/publish/excluded_deno_jsonc/mod.out
new file mode 100644
index 000000000..7c8db25a2
--- /dev/null
+++ b/tests/specs/publish/excluded_deno_jsonc/mod.out
@@ -0,0 +1,6 @@
+Check file:///[WILDLINE]mod.ts
+Checking for slow types in the public API...
+Simulating publish of @scope/pkg@1.0.0 with files:
+ file:///[WILDLINE]/deno.jsonc (74B)
+ file:///[WILDLINE]/mod.ts (22B)
+Warning Aborting due to --dry-run
diff --git a/tests/specs/publish/excluded_deno_jsonc/mod.ts b/tests/specs/publish/excluded_deno_jsonc/mod.ts
new file mode 100644
index 000000000..816fdefaa
--- /dev/null
+++ b/tests/specs/publish/excluded_deno_jsonc/mod.ts
@@ -0,0 +1,2 @@
+export class Test {
+}