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 compile_glob_set, discover_entry_points, discover_plugin_entry_points,
12 discover_workspace_entry_points,
13};
14pub use infrastructure::discover_infrastructure_entry_points;
15pub use walk::{PRODUCTION_EXCLUDE_PATTERNS, SOURCE_EXTENSIONS, discover_files};
16
17const ALLOWED_HIDDEN_DIRS: &[&str] = &[".storybook", ".well-known", ".changeset", ".github"];
26
27#[cfg(test)]
28mod tests {
29 use super::*;
30
31 #[test]
34 fn allowed_hidden_dirs_count() {
35 assert_eq!(
37 ALLOWED_HIDDEN_DIRS.len(),
38 4,
39 "update tests when adding new allowed hidden dirs"
40 );
41 }
42
43 #[test]
44 fn allowed_hidden_dirs_all_start_with_dot() {
45 for dir in ALLOWED_HIDDEN_DIRS {
46 assert!(
47 dir.starts_with('.'),
48 "allowed hidden dir '{dir}' must start with '.'"
49 );
50 }
51 }
52
53 #[test]
54 fn allowed_hidden_dirs_no_duplicates() {
55 let mut seen = rustc_hash::FxHashSet::default();
56 for dir in ALLOWED_HIDDEN_DIRS {
57 assert!(seen.insert(*dir), "duplicate allowed hidden dir: {dir}");
58 }
59 }
60
61 #[test]
62 fn allowed_hidden_dirs_no_trailing_slash() {
63 for dir in ALLOWED_HIDDEN_DIRS {
64 assert!(
65 !dir.ends_with('/'),
66 "allowed hidden dir '{dir}' should not have trailing slash"
67 );
68 }
69 }
70
71 #[test]
74 fn file_id_re_exported() {
75 let id = FileId(42);
77 assert_eq!(id.0, 42);
78 }
79
80 #[test]
81 fn source_extensions_re_exported() {
82 assert!(SOURCE_EXTENSIONS.contains(&"ts"));
83 assert!(SOURCE_EXTENSIONS.contains(&"tsx"));
84 }
85
86 #[test]
87 fn compile_glob_set_re_exported() {
88 let result = compile_glob_set(&["**/*.ts".to_string()]);
89 assert!(result.is_some());
90 }
91}