mirror of
https://github.com/denoland/deno
synced 2024-08-25 02:57:22 +00:00
fix(publish): always include config file when publishing (#23797)
Closes https://github.com/denoland/deno/issues/23796
This commit is contained in:
parent
432792a46c
commit
c0e3b6ed9d
|
@ -151,35 +151,40 @@ async fn prepare_publish(
|
||||||
.map(|c| c.files)
|
.map(|c| c.files)
|
||||||
.unwrap_or_else(|| FilePatterns::new_with_base(root_dir.to_path_buf()));
|
.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({
|
||||||
let tarball = deno_core::unsync::spawn_blocking(move || {
|
let diagnostics_collector = diagnostics_collector.clone();
|
||||||
let bare_node_builtins = cli_options.unstable_bare_node_builtins();
|
let config_path = config_path.clone();
|
||||||
let unfurler = SpecifierUnfurler::new(
|
move || {
|
||||||
&mapped_resolver,
|
let bare_node_builtins = cli_options.unstable_bare_node_builtins();
|
||||||
sloppy_imports_resolver.as_ref(),
|
let unfurler = SpecifierUnfurler::new(
|
||||||
bare_node_builtins,
|
&mapped_resolver,
|
||||||
);
|
sloppy_imports_resolver.as_ref(),
|
||||||
let root_specifier =
|
bare_node_builtins,
|
||||||
ModuleSpecifier::from_directory_path(&root_dir).unwrap();
|
);
|
||||||
let publish_paths = paths::collect_publish_paths(
|
let root_specifier =
|
||||||
&root_dir,
|
ModuleSpecifier::from_directory_path(&root_dir).unwrap();
|
||||||
&cli_options,
|
let publish_paths =
|
||||||
&diagnostics_collector,
|
paths::collect_publish_paths(paths::CollectPublishPathsOptions {
|
||||||
file_patterns,
|
root_dir: &root_dir,
|
||||||
)?;
|
cli_options: &cli_options,
|
||||||
collect_excluded_module_diagnostics(
|
diagnostics_collector: &diagnostics_collector,
|
||||||
&root_specifier,
|
file_patterns,
|
||||||
&graph,
|
force_include_paths: vec![config_path],
|
||||||
&publish_paths,
|
})?;
|
||||||
&diagnostics_collector,
|
collect_excluded_module_diagnostics(
|
||||||
);
|
&root_specifier,
|
||||||
tar::create_gzipped_tarball(
|
&graph,
|
||||||
&publish_paths,
|
&publish_paths,
|
||||||
LazyGraphSourceParser::new(&source_cache, &graph),
|
&diagnostics_collector,
|
||||||
&diagnostics_collector,
|
);
|
||||||
&unfurler,
|
tar::create_gzipped_tarball(
|
||||||
)
|
&publish_paths,
|
||||||
.context("Failed to create a tarball")
|
LazyGraphSourceParser::new(&source_cache, &graph),
|
||||||
|
&diagnostics_collector,
|
||||||
|
&unfurler,
|
||||||
|
)
|
||||||
|
.context("Failed to create a tarball")
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.await??;
|
.await??;
|
||||||
|
|
||||||
|
|
|
@ -217,17 +217,29 @@ pub struct CollectedPublishPath {
|
||||||
pub relative_path: String,
|
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(
|
pub fn collect_publish_paths(
|
||||||
root_dir: &Path,
|
opts: CollectPublishPathsOptions,
|
||||||
cli_options: &CliOptions,
|
|
||||||
diagnostics_collector: &PublishDiagnosticsCollector,
|
|
||||||
file_patterns: FilePatterns,
|
|
||||||
) -> Result<Vec<CollectedPublishPath>, AnyError> {
|
) -> Result<Vec<CollectedPublishPath>, AnyError> {
|
||||||
|
let diagnostics_collector = opts.diagnostics_collector;
|
||||||
let publish_paths =
|
let publish_paths =
|
||||||
collect_paths(cli_options, diagnostics_collector, file_patterns)?;
|
collect_paths(opts.cli_options, diagnostics_collector, opts.file_patterns)?;
|
||||||
let mut paths = HashSet::with_capacity(publish_paths.len());
|
let publish_paths_set = publish_paths.iter().cloned().collect::<HashSet<_>>();
|
||||||
let mut result = Vec::with_capacity(publish_paths.len());
|
let capacity = publish_paths.len() + opts.force_include_paths.len();
|
||||||
for path in publish_paths {
|
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 {
|
let Ok(specifier) = ModuleSpecifier::from_file_path(&path) else {
|
||||||
diagnostics_collector
|
diagnostics_collector
|
||||||
.to_owned()
|
.to_owned()
|
||||||
|
@ -238,7 +250,7 @@ pub fn collect_publish_paths(
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
let Ok(relative_path) = path.strip_prefix(root_dir) else {
|
let Ok(relative_path) = path.strip_prefix(opts.root_dir) else {
|
||||||
diagnostics_collector
|
diagnostics_collector
|
||||||
.to_owned()
|
.to_owned()
|
||||||
.push(PublishDiagnostic::InvalidPath {
|
.push(PublishDiagnostic::InvalidPath {
|
||||||
|
|
|
@ -2,5 +2,6 @@ Check file:///[WILDLINE]/mod.ts
|
||||||
Checking for slow types in the public API...
|
Checking for slow types in the public API...
|
||||||
Check file:///[WILDLINE]/mod.ts
|
Check file:///[WILDLINE]/mod.ts
|
||||||
Simulating publish of @scope/package@0.0.0 with files:
|
Simulating publish of @scope/package@0.0.0 with files:
|
||||||
|
file:///[WILDLINE]/deno.jsonc (300B)
|
||||||
file:///[WILDLINE]/mod.ts (129B)
|
file:///[WILDLINE]/mod.ts (129B)
|
||||||
Warning Aborting due to --dry-run
|
Warning Aborting due to --dry-run
|
||||||
|
|
14
tests/specs/publish/excluded_deno_jsonc/__test__.jsonc
Normal file
14
tests/specs/publish/excluded_deno_jsonc/__test__.jsonc
Normal file
|
@ -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
|
||||||
|
}]
|
||||||
|
}
|
5
tests/specs/publish/excluded_deno_jsonc/deno.jsonc
Normal file
5
tests/specs/publish/excluded_deno_jsonc/deno.jsonc
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"name": "@scope/pkg",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"exports": "./mod.ts"
|
||||||
|
}
|
6
tests/specs/publish/excluded_deno_jsonc/mod.out
Normal file
6
tests/specs/publish/excluded_deno_jsonc/mod.out
Normal file
|
@ -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
|
2
tests/specs/publish/excluded_deno_jsonc/mod.ts
Normal file
2
tests/specs/publish/excluded_deno_jsonc/mod.ts
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
export class Test {
|
||||||
|
}
|
Loading…
Reference in a new issue