syncable_cli/analyzer/runtime/
detection.rs

1use super::javascript::RuntimeDetectionResult;
2use std::path::Path;
3
4/// Generic runtime detection engine that can be extended for other languages
5pub struct RuntimeDetectionEngine;
6
7impl RuntimeDetectionEngine {
8    /// Detect the primary runtime and package manager for a project
9    pub fn detect_primary_runtime(project_path: &Path) -> RuntimeDetectionResult {
10        use super::javascript::RuntimeDetector;
11
12        let js_detector = RuntimeDetector::new(project_path.to_path_buf());
13        js_detector.detect_js_runtime_and_package_manager()
14    }
15
16    /// Get all available package managers in a project
17    pub fn get_all_package_managers(project_path: &Path) -> Vec<super::javascript::PackageManager> {
18        use super::javascript::RuntimeDetector;
19
20        let js_detector = RuntimeDetector::new(project_path.to_path_buf());
21        js_detector.detect_all_package_managers()
22    }
23
24    /// Check if a project uses a specific runtime
25    pub fn uses_runtime(project_path: &Path, runtime: &str) -> bool {
26        let detection = Self::detect_primary_runtime(project_path);
27        detection.runtime.as_str() == runtime
28    }
29}