fix(setup): updated setup to work on windows reliably

This commit is contained in:
sharath 2025-05-28 10:56:46 +00:00
parent 2da6b9edef
commit ddca722b08
No known key found for this signature in database
2 changed files with 35 additions and 18 deletions

View File

@ -7,6 +7,8 @@ import subprocess
from getpass import getpass
import re
IS_WINDOWS = platform.system() == 'Windows'
# ANSI colors for pretty output
class Colors:
HEADER = '\033[95m'
@ -81,7 +83,8 @@ def check_requirements():
[cmd_to_check, '--version'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
check=True
check=True,
shell=IS_WINDOWS
)
print_success(f"{cmd} is installed")
except (subprocess.SubprocessError, FileNotFoundError):
@ -103,7 +106,8 @@ def check_docker_running():
['docker', 'info'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
check=True
check=True,
shell=IS_WINDOWS
)
print_success("Docker is running")
return True
@ -550,7 +554,8 @@ def setup_supabase():
['supabase', '--version'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
check=True
check=True,
shell=IS_WINDOWS
)
except (subprocess.SubprocessError, FileNotFoundError):
print_error("Supabase CLI is not installed.")
@ -592,19 +597,25 @@ def setup_supabase():
try:
# Login to Supabase CLI (interactive)
print_info("Logging into Supabase CLI...")
subprocess.run(['supabase', 'login'], check=True)
subprocess.run(['supabase', 'login'], check=True, shell=IS_WINDOWS)
# Link to project
print_info(f"Linking to Supabase project {project_ref}...")
subprocess.run(
['supabase', 'link', '--project-ref', project_ref],
cwd=backend_dir,
check=True
check=True,
shell=IS_WINDOWS
)
# Push database migrations
print_info("Pushing database migrations...")
subprocess.run(['supabase', 'db', 'push'], cwd=backend_dir, check=True)
subprocess.run(
['supabase', 'db', 'push'],
cwd=backend_dir,
check=True,
shell=IS_WINDOWS
)
print_success("Supabase database setup completed")
@ -628,7 +639,8 @@ def install_dependencies():
subprocess.run(
['npm', 'install'],
cwd='frontend',
check=True
check=True,
shell=IS_WINDOWS
)
print_success("Frontend dependencies installed successfully")
@ -637,14 +649,16 @@ def install_dependencies():
subprocess.run(
['poetry', 'lock'],
cwd='backend',
check=True
check=True,
shell=IS_WINDOWS
)
# Install backend dependencies
print_info("Installing backend dependencies...")
subprocess.run(
['poetry', 'install'],
cwd='backend',
check=True
check=True,
shell=IS_WINDOWS
)
print_success("Backend dependencies installed successfully")
@ -715,7 +729,7 @@ def start_suna():
# subprocess.run(['docker', 'compose', 'up', '-d'], check=True)
print_info("Building images locally...")
subprocess.run(['docker', 'compose', 'up', '-d'], check=True)
subprocess.run(['docker', 'compose', 'up', '-d'], check=True, shell=IS_WINDOWS)
# Wait for services to be ready
print_info("Waiting for services to start...")
@ -723,11 +737,10 @@ def start_suna():
# Check if services are running
result = subprocess.run(
['docker', 'compose', 'ps'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
check=True,
text=True
['docker', 'compose', 'ps', '-q'],
capture_output=True,
text=True,
shell=IS_WINDOWS
)
if "backend" in result.stdout and "frontend" in result.stdout:

View File

@ -2,12 +2,16 @@
import subprocess
import sys
import platform
IS_WINDOWS = platform.system() == 'Windows'
def check_docker_compose_up():
result = subprocess.run(
["docker", "compose", "ps", "-q"],
capture_output=True,
text=True
text=True,
shell=IS_WINDOWS
)
return len(result.stdout.strip()) > 0
@ -47,9 +51,9 @@ def main():
return
if action == "stop":
subprocess.run(["docker", "compose", "down"])
subprocess.run(["docker", "compose", "down"], shell=IS_WINDOWS)
else:
subprocess.run(["docker", "compose", "up", "-d"])
subprocess.run(["docker", "compose", "up", "-d"], shell=IS_WINDOWS)
if __name__ == "__main__":
main()