@@ -76,7 +76,20 @@ def __init__(
7676 branch = branch ,
7777 )
7878
79- self .install_path = os .path .abspath (os .path .expanduser (install_path )) if install_path else os .getcwd ()
79+ # safe fallback incase cwd is not accessible
80+ if install_path :
81+ self .install_path = os .path .abspath (os .path .expanduser (install_path ))
82+ else :
83+ try :
84+ self .install_path = os .getcwd ()
85+ except (FileNotFoundError , OSError ) as e :
86+ # cwd is not accessible
87+ # Fall back to user's home directory
88+ self .install_path = os .path .expanduser ("~/nixopus-dev" )
89+ os .makedirs (self .install_path , exist_ok = True )
90+ if logger :
91+ logger .warning (f"Current directory is not accessible: { e } " )
92+ logger .info (f"Using default installation path: { self .install_path } " )
8093
8194 # Check platform and WSL requirement for Windows
8295 self ._check_platform_support ()
@@ -182,7 +195,7 @@ def _get_config(self, key: str, user_config=None, defaults=None):
182195 if key == "api_env_file_path" :
183196 return os .path .join (self .install_path , "api" , ".env" )
184197 if key == "view_env_file_path" :
185- return os .path .join (self .install_path , "view" , ".env.local " )
198+ return os .path .join (self .install_path , "view" , ".env" )
186199 if key == "ssh_key_path" :
187200 return os .path .expanduser ("~/.ssh/id_rsa_nixopus" )
188201
@@ -322,16 +335,28 @@ def _create_env_files(self):
322335 api_env_file = self ._get_config ("api_env_file_path" )
323336 view_env_file = self ._get_config ("view_env_file_path" )
324337
338+ if self .dry_run :
339+ self .logger .info (f"[DRY RUN] Would create environment files:" )
340+ self .logger .info (f" - API: { api_env_file } " )
341+ self .logger .info (f" - View: { view_env_file } " )
342+ return
343+
325344 FileManager .create_directory (FileManager .get_directory_path (api_env_file ), logger = self .logger )
326345 FileManager .create_directory (FileManager .get_directory_path (view_env_file ), logger = self .logger )
327346
347+ # Get combined env file path
348+ full_source_path = self ._get_config ("full_source_path" )
349+ combined_env_file = os .path .join (full_source_path , ".env" )
350+ FileManager .create_directory (FileManager .get_directory_path (combined_env_file ), logger = self .logger )
351+
328352 services = [
329353 ("api" , "services.api.env" , api_env_file ),
330354 ("view" , "services.view.env" , view_env_file ),
331355 ]
332356
333357 env_manager = BaseEnvironmentManager (self .logger )
334358
359+ # Create individual service env files
335360 for service_name , service_key , env_file in services :
336361 env_values = self ._config .get_service_env_values (service_key )
337362 updated_env_values = self ._update_environment_variables (env_values )
@@ -343,6 +368,24 @@ def _create_env_files(self):
343368 raise Exception (f"{ env_file_permissions_failed } { service_name } : { file_perm_error } " )
344369 self .logger .debug (created_env_file .format (service_name = service_name , env_file = env_file ))
345370
371+ # Create combined env file with both API and view variables (for docker-compose)
372+ api_env_values = self ._config .get_service_env_values ("services.api.env" )
373+ view_env_values = self ._config .get_service_env_values ("services.view.env" )
374+
375+ combined_env_values = {}
376+ combined_env_values .update (self ._update_environment_variables (api_env_values ))
377+ combined_env_values .update (self ._update_environment_variables (view_env_values ))
378+
379+ success , error = env_manager .write_env_file (combined_env_file , combined_env_values )
380+ if not success :
381+ raise Exception (f"{ env_file_creation_failed } combined: { error } " )
382+
383+ file_perm_success , file_perm_error = FileManager .set_permissions (combined_env_file , 0o644 )
384+ if not file_perm_success :
385+ raise Exception (f"{ env_file_permissions_failed } combined: { file_perm_error } " )
386+
387+ self .logger .debug (created_env_file .format (service_name = "combined" , env_file = combined_env_file ))
388+
346389 def _update_environment_variables (self , env_values : dict ) -> dict :
347390 """Update environment variables with development-specific values"""
348391 updated_env = env_values .copy ()
@@ -648,7 +691,7 @@ def _show_success_message(self):
648691 self .logger .info (" Configuration Files:" )
649692 self .logger .info (f" • Config Dir: { os .path .join (self .install_path , 'nixopus-dev' )} " )
650693 self .logger .info (f" • Backend: { os .path .join (self .install_path , 'api' , '.env' )} " )
651- self .logger .info (f" • Frontend: { os .path .join (self .install_path , 'view' , '.env.local ' )} " )
694+ self .logger .info (f" • Frontend: { os .path .join (self .install_path , 'view' , '.env' )} " )
652695 self .logger .info (f" • Caddy: { os .path .join (self .install_path , 'helpers' , 'caddy.json' )} " )
653696 self .logger .info (" • SSH Key: ~/.ssh/id_rsa_nixopus" )
654697 self .logger .info ("" )
0 commit comments