fallow_core/discover/
mod.rs1mod entry_points;
2mod infrastructure;
3mod parse_scripts;
4mod walk;
5
6pub use fallow_types::discover::{DiscoveredFile, EntryPoint, EntryPointSource, FileId};
8
9pub use entry_points::{
11 CategorizedEntryPoints, compile_glob_set, discover_dynamically_loaded_entry_points,
12 discover_entry_points, discover_plugin_entry_point_sets, discover_plugin_entry_points,
13 discover_workspace_entry_points,
14};
15pub use infrastructure::discover_infrastructure_entry_points;
16pub use walk::{PRODUCTION_EXCLUDE_PATTERNS, SOURCE_EXTENSIONS, discover_files};
17
18const ALLOWED_HIDDEN_DIRS: &[&str] = &[
28 ".storybook",
29 ".vitepress",
30 ".well-known",
31 ".changeset",
32 ".github",
33];
34
35#[cfg(test)]
36mod tests {
37 use super::*;
38
39 #[test]
42 fn allowed_hidden_dirs_count() {
43 assert_eq!(
45 ALLOWED_HIDDEN_DIRS.len(),
46 5,
47 "update tests when adding new allowed hidden dirs"
48 );
49 }
50
51 #[test]
52 fn allowed_hidden_dirs_all_start_with_dot() {
53 for dir in ALLOWED_HIDDEN_DIRS {
54 assert!(
55 dir.starts_with('.'),
56 "allowed hidden dir '{dir}' must start with '.'"
57 );
58 }
59 }
60
61 #[test]
62 fn allowed_hidden_dirs_no_duplicates() {
63 let mut seen = rustc_hash::FxHashSet::default();
64 for dir in ALLOWED_HIDDEN_DIRS {
65 assert!(seen.insert(*dir), "duplicate allowed hidden dir: {dir}");
66 }
67 }
68
69 #[test]
70 fn allowed_hidden_dirs_no_trailing_slash() {
71 for dir in ALLOWED_HIDDEN_DIRS {
72 assert!(
73 !dir.ends_with('/'),
74 "allowed hidden dir '{dir}' should not have trailing slash"
75 );
76 }
77 }
78
79 #[test]
82 fn file_id_re_exported() {
83 let id = FileId(42);
85 assert_eq!(id.0, 42);
86 }
87
88 #[test]
89 fn source_extensions_re_exported() {
90 assert!(SOURCE_EXTENSIONS.contains(&"ts"));
91 assert!(SOURCE_EXTENSIONS.contains(&"tsx"));
92 }
93
94 #[test]
95 fn compile_glob_set_re_exported() {
96 let result = compile_glob_set(&["**/*.ts".to_string()]);
97 assert!(result.is_some());
98 }
99}