@@ -107,7 +107,7 @@ def generate_start_command(repo_path: Path, program_type: str, info: dict) -> st
107107
108108def scan_repository_folder (folder_path : str , existing_ports : set [int ]) -> list [ImportBundle ]:
109109 """
110- Scan a folder for repositories and generate import bundles with error handling .
110+ Scan a folder for repositories and ZIP files, generate import bundles.
111111
112112 Args:
113113 folder_path: Path to the folder containing repositories
@@ -122,34 +122,65 @@ def scan_repository_folder(folder_path: str, existing_ports: set[int]) -> list[I
122122 folder = Path (folder_path )
123123
124124 if not folder .exists ():
125- print (f"⚠ Folder does not exist: { folder_path } " )
126125 return bundles
127126
128127 if not folder .is_dir ():
129- print (f"⚠ Path is not a directory: { folder_path } " )
130128 return bundles
131129
132- # Scan all subdirectories
133- for repo_path in folder .iterdir ():
130+ zip_files_to_process = []
131+ dirs_to_scan = []
132+
133+ for item in folder .iterdir ():
134134 try :
135- # Skip non-directories and hidden folders
136- if not repo_path .is_dir () or repo_path .name .startswith ("." ):
135+ if item .name .startswith ("." ):
137136 continue
138137
139- # Skip common non-project folders
140- skip_folders = {"node_modules" , ".git" , "__pycache__" , "venv" , ".venv" , "dist" , "build" }
141- if repo_path .name in skip_folders :
138+ if item .is_file () and item .suffix .lower () == ".zip" :
139+ zip_files_to_process .append (item )
140+ elif item .is_dir ():
141+ skip_folders = {"node_modules" , ".git" , "__pycache__" , "venv" , ".venv" , "dist" , "build" }
142+ if item .name not in skip_folders :
143+ dirs_to_scan .append (item )
144+ except Exception :
145+ continue
146+
147+ for zip_path in zip_files_to_process :
148+ try :
149+ extracted_dir = folder / zip_path .stem
150+ if extracted_dir .exists ():
142151 continue
143152
153+ if not zipfile .is_zipfile (zip_path ):
154+ continue
155+
156+ with zipfile .ZipFile (zip_path , "r" ) as zip_ref :
157+ total_size = sum (info .file_size for info in zip_ref .infolist ())
158+ if total_size > 1024 * 1024 * 1024 :
159+ continue
160+ zip_ref .extractall (extracted_dir )
161+
162+ dirs_to_scan .append (extracted_dir )
163+ except Exception :
164+ continue
165+
166+ for repo_path in dirs_to_scan :
167+ try :
144168 program_type = detect_program_type (repo_path )
169+ if not program_type :
170+ for subdir in repo_path .iterdir ():
171+ if subdir .is_dir () and not subdir .name .startswith ("." ):
172+ program_type = detect_program_type (subdir )
173+ if program_type :
174+ repo_path = subdir
175+ break
176+
145177 if not program_type :
146178 continue
147179
148180 info = extract_package_info (repo_path , program_type )
149181 port = get_default_port (program_type , existing_ports )
150182 existing_ports .add (port )
151183
152- # Sanitize name - remove invalid characters
153184 safe_name = info ["name" ].replace ("@" , "" ).replace ("/" , "-" )[:100 ]
154185
155186 service = ServiceCreate (
@@ -158,22 +189,22 @@ def scan_repository_folder(folder_path: str, existing_ports: set[int]) -> list[I
158189 category = "auto-discovered" ,
159190 tags = ["auto-discovered" , program_type ],
160191 tech_stack = [program_type ],
161- dependencies = info ["dependencies" ][:10 ], # Limit to first 10
192+ dependencies = info ["dependencies" ][:10 ],
162193 config_paths = [str (repo_path )],
163194 port = port ,
164195 local_url = f"http://localhost:{ port } " ,
165196 healthcheck_url = f"http://localhost:{ port } /health" ,
166197 working_directory = str (repo_path ),
167198 start_command = generate_start_command (repo_path , program_type , info ),
168- stop_command = "" , # Will use PID-based termination
199+ stop_command = "" ,
169200 restart_command = "" ,
170201 env_overrides = {"PORT" : str (port )},
171202 )
172203
173204 bundle = ImportBundle (
174205 service = service ,
175206 requested_port = port ,
176- auto_assign_port = False , # Use the specified port
207+ auto_assign_port = False ,
177208 auto_create_db = False ,
178209 meta = {
179210 "source" : "auto_discovery" ,
@@ -183,12 +214,11 @@ def scan_repository_folder(folder_path: str, existing_ports: set[int]) -> list[I
183214 )
184215
185216 bundles .append (bundle )
186- except Exception as e :
187- print (f"⚠ Error processing { repo_path .name } : { e } " )
217+ except Exception :
188218 continue
189219
190- except Exception as e :
191- print ( f"✗ Error scanning folder { folder_path } : { e } " )
220+ except Exception :
221+ pass
192222
193223 return bundles
194224
0 commit comments