mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
fix(cache): cache excluded modules explicitly provided on the command line (#30442)
Some checks are pending
ci / test release linux-x86_64 (push) Blocked by required conditions
ci / test debug macos-x86_64 (push) Blocked by required conditions
ci / test release macos-x86_64 (push) Blocked by required conditions
ci / test debug windows-x86_64 (push) Blocked by required conditions
ci / test release windows-x86_64 (push) Blocked by required conditions
ci / build libs (push) Blocked by required conditions
ci / test release macos-aarch64 (push) Blocked by required conditions
ci / bench release linux-x86_64 (push) Blocked by required conditions
ci / lint debug linux-x86_64 (push) Blocked by required conditions
ci / lint debug macos-x86_64 (push) Blocked by required conditions
ci / lint debug windows-x86_64 (push) Blocked by required conditions
ci / test debug linux-x86_64 (push) Blocked by required conditions
ci / pre-build (push) Waiting to run
ci / test debug linux-aarch64 (push) Blocked by required conditions
ci / test release linux-aarch64 (push) Blocked by required conditions
ci / test debug macos-aarch64 (push) Blocked by required conditions
ci / publish canary (push) Blocked by required conditions
Some checks are pending
ci / test release linux-x86_64 (push) Blocked by required conditions
ci / test debug macos-x86_64 (push) Blocked by required conditions
ci / test release macos-x86_64 (push) Blocked by required conditions
ci / test debug windows-x86_64 (push) Blocked by required conditions
ci / test release windows-x86_64 (push) Blocked by required conditions
ci / build libs (push) Blocked by required conditions
ci / test release macos-aarch64 (push) Blocked by required conditions
ci / bench release linux-x86_64 (push) Blocked by required conditions
ci / lint debug linux-x86_64 (push) Blocked by required conditions
ci / lint debug macos-x86_64 (push) Blocked by required conditions
ci / lint debug windows-x86_64 (push) Blocked by required conditions
ci / test debug linux-x86_64 (push) Blocked by required conditions
ci / pre-build (push) Waiting to run
ci / test debug linux-aarch64 (push) Blocked by required conditions
ci / test release linux-aarch64 (push) Blocked by required conditions
ci / test debug macos-aarch64 (push) Blocked by required conditions
ci / publish canary (push) Blocked by required conditions
This commit is contained in:
parent
75f1a9d5de
commit
ce1d2c8b04
14 changed files with 161 additions and 65 deletions
|
@ -55,6 +55,11 @@ pub struct CheckSpecifiersOptions<'a> {
|
|||
pub allow_unknown_media_types: bool,
|
||||
}
|
||||
|
||||
pub struct CollectSpecifiersOptions {
|
||||
/// Whether to include paths that are specified even if they're ignored.
|
||||
pub include_ignored_specified: bool,
|
||||
}
|
||||
|
||||
impl MainModuleGraphContainer {
|
||||
pub fn new(
|
||||
cli_options: Arc<CliOptions>,
|
||||
|
@ -103,8 +108,9 @@ impl MainModuleGraphContainer {
|
|||
pub async fn load_and_type_check_files(
|
||||
&self,
|
||||
files: &[String],
|
||||
options: CollectSpecifiersOptions,
|
||||
) -> Result<(), AnyError> {
|
||||
let specifiers = self.collect_specifiers(files)?;
|
||||
let specifiers = self.collect_specifiers(files, options)?;
|
||||
|
||||
if specifiers.is_empty() {
|
||||
log::warn!("{} No matching files found.", colors::yellow("Warning"));
|
||||
|
@ -116,6 +122,7 @@ impl MainModuleGraphContainer {
|
|||
pub fn collect_specifiers(
|
||||
&self,
|
||||
files: &[String],
|
||||
options: CollectSpecifiersOptions,
|
||||
) -> Result<Vec<ModuleSpecifier>, AnyError> {
|
||||
let excludes = self.cli_options.workspace().resolve_config_excludes()?;
|
||||
let include_patterns =
|
||||
|
@ -129,8 +136,14 @@ impl MainModuleGraphContainer {
|
|||
exclude: excludes,
|
||||
};
|
||||
collect_specifiers(
|
||||
file_patterns,
|
||||
self.cli_options.vendor_dir_path().map(ToOwned::to_owned),
|
||||
crate::util::fs::CollectSpecifiersOptions {
|
||||
file_patterns,
|
||||
vendor_folder: self
|
||||
.cli_options
|
||||
.vendor_dir_path()
|
||||
.map(ToOwned::to_owned),
|
||||
include_ignored_specified: options.include_ignored_specified,
|
||||
},
|
||||
|e| is_script_ext(e.path),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -89,6 +89,7 @@ pub fn init(options: InitLoggingOptions) {
|
|||
// https://github.com/swc-project/swc/blob/74d6478be1eb8cdf1df096c360c159db64b64d8a/crates/swc_ecma_codegen/src/macros.rs#L112
|
||||
// We suppress them here to avoid flooding our CI logs in integration tests.
|
||||
.filter_module("swc_ecma_codegen", log::LevelFilter::Off)
|
||||
.filter_module("swc_common::source_map", log::LevelFilter::Off)
|
||||
.filter_module("swc_ecma_transforms_optimization", log::LevelFilter::Off)
|
||||
.filter_module("swc_ecma_parser", log::LevelFilter::Error)
|
||||
.filter_module("swc_ecma_lexer", log::LevelFilter::Error)
|
||||
|
|
|
@ -43,6 +43,7 @@ use crate::ops;
|
|||
use crate::tools::test::TestFilter;
|
||||
use crate::tools::test::format_test_error;
|
||||
use crate::util::file_watcher;
|
||||
use crate::util::fs::CollectSpecifiersOptions;
|
||||
use crate::util::fs::collect_specifiers;
|
||||
use crate::util::path::is_script_ext;
|
||||
use crate::util::path::matches_pattern_or_exact_path;
|
||||
|
@ -452,8 +453,11 @@ pub async fn run_benchmarks(
|
|||
.iter()
|
||||
.map(|(_, bench_options)| {
|
||||
collect_specifiers(
|
||||
bench_options.files.clone(),
|
||||
cli_options.vendor_dir_path().map(ToOwned::to_owned),
|
||||
CollectSpecifiersOptions {
|
||||
file_patterns: bench_options.files.clone(),
|
||||
vendor_folder: cli_options.vendor_dir_path().map(ToOwned::to_owned),
|
||||
include_ignored_specified: false,
|
||||
},
|
||||
is_supported_bench_path,
|
||||
)
|
||||
})
|
||||
|
@ -550,8 +554,13 @@ pub async fn run_benchmarks_with_watch(
|
|||
.iter()
|
||||
.map(|(_, bench_options)| {
|
||||
collect_specifiers(
|
||||
bench_options.files.clone(),
|
||||
cli_options.vendor_dir_path().map(ToOwned::to_owned),
|
||||
CollectSpecifiersOptions {
|
||||
file_patterns: bench_options.files.clone(),
|
||||
vendor_folder: cli_options
|
||||
.vendor_dir_path()
|
||||
.map(ToOwned::to_owned),
|
||||
include_ignored_specified: false,
|
||||
},
|
||||
is_supported_bench_path,
|
||||
)
|
||||
})
|
||||
|
|
|
@ -8,6 +8,7 @@ use deno_terminal::colors;
|
|||
use crate::args::CheckFlags;
|
||||
use crate::args::Flags;
|
||||
use crate::factory::CliFactory;
|
||||
use crate::graph_container::CollectSpecifiersOptions;
|
||||
use crate::util::extract;
|
||||
|
||||
pub async fn check(
|
||||
|
@ -18,8 +19,12 @@ pub async fn check(
|
|||
|
||||
let main_graph_container = factory.main_module_graph_container().await?;
|
||||
|
||||
let specifiers =
|
||||
main_graph_container.collect_specifiers(&check_flags.files)?;
|
||||
let specifiers = main_graph_container.collect_specifiers(
|
||||
&check_flags.files,
|
||||
CollectSpecifiersOptions {
|
||||
include_ignored_specified: false,
|
||||
},
|
||||
)?;
|
||||
if specifiers.is_empty() {
|
||||
log::warn!("{} No matching files found.", colors::yellow("Warning"));
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ use crate::args::Flags;
|
|||
use crate::colors;
|
||||
use crate::display;
|
||||
use crate::factory::CliFactory;
|
||||
use crate::graph_container::CollectSpecifiersOptions;
|
||||
use crate::graph_container::ModuleGraphContainer;
|
||||
use crate::graph_container::ModuleGraphUpdatePermit;
|
||||
use crate::graph_util::BuildGraphRequest;
|
||||
|
@ -207,7 +208,12 @@ async fn clean_except(
|
|||
let sys = factory.sys();
|
||||
let options = factory.cli_options()?;
|
||||
let main_graph_container = factory.main_module_graph_container().await?;
|
||||
let roots = main_graph_container.collect_specifiers(entrypoints)?;
|
||||
let roots = main_graph_container.collect_specifiers(
|
||||
entrypoints,
|
||||
CollectSpecifiersOptions {
|
||||
include_ignored_specified: true,
|
||||
},
|
||||
)?;
|
||||
let http_cache = factory.global_http_cache()?;
|
||||
let local_or_global_http_cache = factory.http_cache()?.clone();
|
||||
let deno_dir = factory.deno_dir()?.clone();
|
||||
|
|
|
@ -39,6 +39,7 @@ use crate::graph_util::graph_exit_integrity_errors;
|
|||
use crate::graph_util::graph_walk_errors;
|
||||
use crate::sys::CliSys;
|
||||
use crate::tsc::get_types_declaration_file_text;
|
||||
use crate::util::fs::CollectSpecifiersOptions;
|
||||
use crate::util::fs::collect_specifiers;
|
||||
|
||||
const JSON_SCHEMA_VERSION: u8 = 1;
|
||||
|
@ -127,17 +128,20 @@ pub async fn doc(
|
|||
let sys = CliSys::default();
|
||||
|
||||
let module_specifiers = collect_specifiers(
|
||||
FilePatterns {
|
||||
base: cli_options.initial_cwd().to_path_buf(),
|
||||
include: Some(
|
||||
PathOrPatternSet::from_include_relative_path_or_patterns(
|
||||
cli_options.initial_cwd(),
|
||||
source_files,
|
||||
)?,
|
||||
),
|
||||
exclude: Default::default(),
|
||||
CollectSpecifiersOptions {
|
||||
file_patterns: FilePatterns {
|
||||
base: cli_options.initial_cwd().to_path_buf(),
|
||||
include: Some(
|
||||
PathOrPatternSet::from_include_relative_path_or_patterns(
|
||||
cli_options.initial_cwd(),
|
||||
source_files,
|
||||
)?,
|
||||
),
|
||||
exclude: Default::default(),
|
||||
},
|
||||
vendor_folder: cli_options.vendor_dir_path().map(ToOwned::to_owned),
|
||||
include_ignored_specified: false,
|
||||
},
|
||||
cli_options.vendor_dir_path().map(ToOwned::to_owned),
|
||||
|_| true,
|
||||
)?;
|
||||
let graph = module_graph_creator
|
||||
|
|
|
@ -39,6 +39,7 @@ use crate::args::resolve_no_prompt;
|
|||
use crate::factory::CliFactory;
|
||||
use crate::file_fetcher::CreateCliFileFetcherOptions;
|
||||
use crate::file_fetcher::create_cli_file_fetcher;
|
||||
use crate::graph_container::CollectSpecifiersOptions;
|
||||
use crate::graph_container::ModuleGraphContainer;
|
||||
use crate::jsr::JsrFetchResolver;
|
||||
use crate::npm::NpmFetchResolver;
|
||||
|
@ -231,7 +232,12 @@ pub(crate) async fn install_from_entrypoints(
|
|||
let factory = CliFactory::from_flags(flags.clone());
|
||||
let emitter = factory.emitter()?;
|
||||
let main_graph_container = factory.main_module_graph_container().await?;
|
||||
let specifiers = main_graph_container.collect_specifiers(entrypoints)?;
|
||||
let specifiers = main_graph_container.collect_specifiers(
|
||||
entrypoints,
|
||||
CollectSpecifiersOptions {
|
||||
include_ignored_specified: true,
|
||||
},
|
||||
)?;
|
||||
main_graph_container
|
||||
.check_specifiers(
|
||||
&specifiers,
|
||||
|
@ -371,9 +377,12 @@ async fn install_global(
|
|||
factory
|
||||
.main_module_graph_container()
|
||||
.await?
|
||||
.load_and_type_check_files(std::slice::from_ref(
|
||||
&install_flags_global.module_url,
|
||||
))
|
||||
.load_and_type_check_files(
|
||||
std::slice::from_ref(&install_flags_global.module_url),
|
||||
CollectSpecifiersOptions {
|
||||
include_ignored_specified: true,
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
|
||||
if matches!(flags.config_flag, ConfigFlag::Discover)
|
||||
|
|
|
@ -81,6 +81,7 @@ use crate::graph_util::has_graph_root_local_dependent_changed;
|
|||
use crate::ops;
|
||||
use crate::util::extract::extract_doc_tests;
|
||||
use crate::util::file_watcher;
|
||||
use crate::util::fs::CollectSpecifiersOptions;
|
||||
use crate::util::fs::collect_specifiers;
|
||||
use crate::util::path::get_extension;
|
||||
use crate::util::path::is_script_ext;
|
||||
|
@ -1537,15 +1538,21 @@ fn collect_specifiers_with_test_mode(
|
|||
// todo(dsherret): there's no need to collect twice as it's slow
|
||||
let vendor_folder = cli_options.vendor_dir_path();
|
||||
let module_specifiers = collect_specifiers(
|
||||
files.clone(),
|
||||
vendor_folder.map(ToOwned::to_owned),
|
||||
CollectSpecifiersOptions {
|
||||
file_patterns: files.clone(),
|
||||
vendor_folder: vendor_folder.map(ToOwned::to_owned),
|
||||
include_ignored_specified: false,
|
||||
},
|
||||
is_supported_test_path_predicate,
|
||||
)?;
|
||||
|
||||
if *include_inline {
|
||||
return collect_specifiers(
|
||||
files,
|
||||
vendor_folder.map(ToOwned::to_owned),
|
||||
CollectSpecifiersOptions {
|
||||
file_patterns: files,
|
||||
vendor_folder: vendor_folder.map(ToOwned::to_owned),
|
||||
include_ignored_specified: false,
|
||||
},
|
||||
|e| is_supported_test_ext(e.path),
|
||||
)
|
||||
.map(|specifiers| {
|
||||
|
@ -1787,8 +1794,13 @@ pub async fn run_tests_with_watch(
|
|||
.iter()
|
||||
.map(|(_, test_options)| {
|
||||
collect_specifiers(
|
||||
test_options.files.clone(),
|
||||
cli_options.vendor_dir_path().map(ToOwned::to_owned),
|
||||
CollectSpecifiersOptions {
|
||||
file_patterns: test_options.files.clone(),
|
||||
vendor_folder: cli_options
|
||||
.vendor_dir_path()
|
||||
.map(ToOwned::to_owned),
|
||||
include_ignored_specified: false,
|
||||
},
|
||||
if workspace_test_options.doc {
|
||||
Box::new(|e: WalkEntry| is_supported_test_ext(e.path))
|
||||
as Box<dyn Fn(WalkEntry) -> bool>
|
||||
|
|
|
@ -74,18 +74,29 @@ pub fn canonicalize_path_maybe_not_exists(
|
|||
)
|
||||
}
|
||||
|
||||
pub struct CollectSpecifiersOptions {
|
||||
pub file_patterns: FilePatterns,
|
||||
pub vendor_folder: Option<PathBuf>,
|
||||
/// Whether to include paths that are specified even if they're ignored.
|
||||
pub include_ignored_specified: bool,
|
||||
}
|
||||
|
||||
/// Collects module specifiers that satisfy the given predicate as a file path, by recursively walking `include`.
|
||||
/// Specifiers that start with http and https are left intact.
|
||||
/// Note: This ignores all .git and node_modules folders.
|
||||
pub fn collect_specifiers(
|
||||
mut files: FilePatterns,
|
||||
vendor_folder: Option<PathBuf>,
|
||||
options: CollectSpecifiersOptions,
|
||||
predicate: impl Fn(WalkEntry) -> bool,
|
||||
) -> Result<Vec<ModuleSpecifier>, AnyError> {
|
||||
let CollectSpecifiersOptions {
|
||||
mut file_patterns,
|
||||
vendor_folder,
|
||||
include_ignored_specified: always_include_specified,
|
||||
} = options;
|
||||
let mut prepared = vec![];
|
||||
|
||||
// break out the remote specifiers
|
||||
if let Some(include_mut) = &mut files.include {
|
||||
// break out the remote specifiers and explicitly specified paths
|
||||
if let Some(include_mut) = &mut file_patterns.include {
|
||||
let includes = std::mem::take(include_mut);
|
||||
let path_or_patterns = includes.into_path_or_patterns();
|
||||
let mut result = Vec::with_capacity(path_or_patterns.len());
|
||||
|
@ -94,7 +105,9 @@ pub fn collect_specifiers(
|
|||
PathOrPattern::Path(path) => {
|
||||
if path.is_dir() {
|
||||
result.push(PathOrPattern::Path(path));
|
||||
} else if !files.exclude.matches_path(&path) {
|
||||
} else if always_include_specified
|
||||
|| !file_patterns.exclude.matches_path(&path)
|
||||
{
|
||||
let url = specifier_from_file_path(&path)?;
|
||||
prepared.push(url);
|
||||
}
|
||||
|
@ -119,7 +132,7 @@ pub fn collect_specifiers(
|
|||
.ignore_git_folder()
|
||||
.ignore_node_modules()
|
||||
.set_vendor_folder(vendor_folder)
|
||||
.collect_file_patterns(&CliSys::default(), files);
|
||||
.collect_file_patterns(&CliSys::default(), file_patterns);
|
||||
let mut collected_files_as_urls = collected_files
|
||||
.iter()
|
||||
.map(|f| specifier_from_file_path(f).unwrap())
|
||||
|
@ -217,24 +230,27 @@ mod tests {
|
|||
};
|
||||
|
||||
let result = collect_specifiers(
|
||||
FilePatterns {
|
||||
base: root_dir_path.to_path_buf(),
|
||||
include: Some(
|
||||
PathOrPatternSet::from_include_relative_path_or_patterns(
|
||||
root_dir_path.as_path(),
|
||||
&[
|
||||
"http://localhost:8080".to_string(),
|
||||
"./".to_string(),
|
||||
"https://localhost:8080".to_string(),
|
||||
],
|
||||
)
|
||||
.unwrap(),
|
||||
),
|
||||
exclude: PathOrPatternSet::new(vec![PathOrPattern::Path(
|
||||
ignore_dir_path.to_path_buf(),
|
||||
)]),
|
||||
CollectSpecifiersOptions {
|
||||
file_patterns: FilePatterns {
|
||||
base: root_dir_path.to_path_buf(),
|
||||
include: Some(
|
||||
PathOrPatternSet::from_include_relative_path_or_patterns(
|
||||
root_dir_path.as_path(),
|
||||
&[
|
||||
"http://localhost:8080".to_string(),
|
||||
"./".to_string(),
|
||||
"https://localhost:8080".to_string(),
|
||||
],
|
||||
)
|
||||
.unwrap(),
|
||||
),
|
||||
exclude: PathOrPatternSet::new(vec![PathOrPattern::Path(
|
||||
ignore_dir_path.to_path_buf(),
|
||||
)]),
|
||||
},
|
||||
vendor_folder: None,
|
||||
include_ignored_specified: false,
|
||||
},
|
||||
None,
|
||||
predicate,
|
||||
)
|
||||
.unwrap();
|
||||
|
@ -268,19 +284,22 @@ mod tests {
|
|||
"file://"
|
||||
};
|
||||
let result = collect_specifiers(
|
||||
FilePatterns {
|
||||
base: root_dir_path.to_path_buf(),
|
||||
include: Some(PathOrPatternSet::new(vec![
|
||||
PathOrPattern::new(&format!(
|
||||
"{}{}",
|
||||
scheme,
|
||||
root_dir_path.join("child").to_string().replace('\\', "/")
|
||||
))
|
||||
.unwrap(),
|
||||
])),
|
||||
exclude: Default::default(),
|
||||
CollectSpecifiersOptions {
|
||||
file_patterns: FilePatterns {
|
||||
base: root_dir_path.to_path_buf(),
|
||||
include: Some(PathOrPatternSet::new(vec![
|
||||
PathOrPattern::new(&format!(
|
||||
"{}{}",
|
||||
scheme,
|
||||
root_dir_path.join("child").to_string().replace('\\', "/")
|
||||
))
|
||||
.unwrap(),
|
||||
])),
|
||||
exclude: Default::default(),
|
||||
},
|
||||
vendor_folder: None,
|
||||
include_ignored_specified: false,
|
||||
},
|
||||
None,
|
||||
predicate,
|
||||
)
|
||||
.unwrap();
|
||||
|
|
4
tests/specs/install/entrypoint_ignored/__test__.jsonc
Normal file
4
tests/specs/install/entrypoint_ignored/__test__.jsonc
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"args": "install --allow-import -e ignore/main.ts",
|
||||
"output": "install.out"
|
||||
}
|
5
tests/specs/install/entrypoint_ignored/deno.json
Normal file
5
tests/specs/install/entrypoint_ignored/deno.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"exclude": [
|
||||
"ignore"
|
||||
]
|
||||
}
|
6
tests/specs/install/entrypoint_ignored/deno.lock
generated
Normal file
6
tests/specs/install/entrypoint_ignored/deno.lock
generated
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"version": "5",
|
||||
"remote": {
|
||||
"http://localhost:4545/welcome.ts": "7353d5fcbc36c45d26bcbca478cf973092523b07c45999f41319820092b4de31"
|
||||
}
|
||||
}
|
1
tests/specs/install/entrypoint_ignored/ignore/main.ts
Normal file
1
tests/specs/install/entrypoint_ignored/ignore/main.ts
Normal file
|
@ -0,0 +1 @@
|
|||
import "http://localhost:4545/welcome.ts";
|
2
tests/specs/install/entrypoint_ignored/install.out
Normal file
2
tests/specs/install/entrypoint_ignored/install.out
Normal file
|
@ -0,0 +1,2 @@
|
|||
Download http://localhost:4545/welcome.ts
|
||||
[WILDCARD]
|
Loading…
Add table
Add a link
Reference in a new issue