Skip to content

Commit 2fc03e4

Browse files
authored
chore(cli): increase timeout in local system (#533)
1 parent 9ca316f commit 2fc03e4

File tree

5 files changed

+57
-6
lines changed

5 files changed

+57
-6
lines changed

CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,4 +729,3 @@
729729
* **vulnerability:** fixes CVE-2024-21538 (HIGH) and CVE-2025-30204 (HIGH) ([c25e0c7](https://github.com/raghavyuva/nixopus/commit/c25e0c7fa9ad742a25f95ae7e2a780a881cad573))
730730

731731

732-

cli/app/commands/install/command.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def main_install_callback(value: bool):
102102
def development(
103103
path: str = typer.Option(None, "--path", "-p", help="Installation directory (defaults to current directory)"),
104104
verbose: bool = typer.Option(False, "--verbose", "-v", help="Show more details while installing"),
105-
timeout: int = typer.Option(300, "--timeout", "-t", help="How long to wait for each step (in seconds)"),
105+
timeout: int = typer.Option(1800, "--timeout", "-t", help="How long to wait for each step (in seconds)"),
106106
force: bool = typer.Option(False, "--force", "-f", help="Replace files if they already exist"),
107107
dry_run: bool = typer.Option(False, "--dry-run", "-d", help="See what would happen, but don't make changes"),
108108
config_file: str = typer.Option(

cli/app/commands/install/development.py

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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("")

cli/app/commands/service/up.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,15 @@ def up(self) -> UpResult:
8989
def execute(self) -> UpResult:
9090
self.logger.debug(f"Starting services: {self.config.name}")
9191

92+
# Handle dry-run mode
93+
if self.config.dry_run:
94+
self.logger.debug("[DRY RUN] Would start services")
95+
return self._create_result(
96+
success=True,
97+
error=None,
98+
docker_output="[DRY RUN] Services would be started"
99+
)
100+
92101
success, docker_output = self.docker_service.start_services(
93102
self.config.name, self.config.detach, self.config.env_file, self.config.compose_file
94103
)

cli/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "nixopus"
3-
version = "0.1.17"
3+
version = "0.1.18"
44
description = "A CLI for Nixopus"
55
authors = ["Nixopus <[email protected]>"]
66
readme = "README.md"

0 commit comments

Comments
 (0)