@smbcloud / cli / commits / 50fdadc

fix framework detection

Seto committed Sep 18, 2025 at 17:48 UTC 50fdadc48e1f1235c3051227c44a98fd59a1b2ee
1 file changed +18 -8
crates/smbcloud-model/src/runner.rs
+18 -8
@@ -1,7 +1,11 @@
1 use {
2 crate::error_codes::{ErrorCode::UnsupportedRunner, ErrorResponse},
3 serde::{Deserialize, Serialize},
4 - std::{fs, path::PathBuf},
4 + std::{
5 + fmt::{self, Display, Formatter},
6 + fs,
7 + path::PathBuf,
8 + },
9 };
10
11 #[derive(Debug, Serialize, Deserialize)]
@@ -12,6 +16,12 @@ pub enum Runner {
16 Swift,
17 }
18
19 +impl Display for Runner {
20 + fn fmt(&self, f: &mut Formatter) -> fmt::Result {
21 + write!(f, "{:?}", self)
22 + }
23 +}
24 +
25 #[derive(Debug, Serialize, Deserialize)]
26 #[tsync::tsync]
27 pub enum NodeJsFramework {
@@ -34,11 +44,11 @@ pub enum SwiftFramework {
44 impl Runner {
45 pub fn from(repo_path: &PathBuf) -> Result<Runner, ErrorResponse> {
46 if repo_path.join("package.json").exists()
37 - && (next_config_exists() || astro_config_exists())
47 + && (next_config_exists(repo_path) || astro_config_exists(repo_path))
48 {
39 - if next_config_exists() {
49 + if next_config_exists(repo_path) {
50 return Ok(Runner::NodeJs);
41 - } else if astro_config_exists() {
51 + } else if astro_config_exists(repo_path) {
52 return Ok(Runner::NodeJs);
53 } else {
54 return Err(ErrorResponse::Error {
@@ -62,8 +72,8 @@ impl Runner {
72 }
73
74 // Helper function to detect any next.config.* file
65 -fn next_config_exists() -> bool {
66 - if let Ok(entries) = fs::read_dir(".") {
75 +fn next_config_exists(repo_path: &PathBuf) -> bool {
76 + if let Ok(entries) = fs::read_dir(repo_path) {
77 for entry in entries.flatten() {
78 let filename = entry.file_name();
79 let filename_str = filename.to_string_lossy();
@@ -76,8 +86,8 @@ fn next_config_exists() -> bool {
86 }
87
88 // Helper function to detect any astro.config.* file
79 -fn astro_config_exists() -> bool {
80 - if let Ok(entries) = fs::read_dir(".") {
89 +fn astro_config_exists(repo_path: &PathBuf) -> bool {
90 + if let Ok(entries) = fs::read_dir(repo_path) {
91 for entry in entries.flatten() {
92 let filename = entry.file_name();
93 let filename_str = filename.to_string_lossy();