From 552e3c550c35e77f19a42d6863d7928ca909aaee Mon Sep 17 00:00:00 2001 From: Dillon DuPont Date: Thu, 19 Jun 2025 09:12:38 -0400 Subject: [PATCH] Keep demo dir --- scripts/playground-docker.sh | 45 +++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/scripts/playground-docker.sh b/scripts/playground-docker.sh index 191878c5..61b57901 100644 --- a/scripts/playground-docker.sh +++ b/scripts/playground-docker.sh @@ -56,9 +56,21 @@ print_success "Docker is installed and running!" # Save the original working directory ORIGINAL_DIR="$(pwd)" -# Directories used by the script DEMO_DIR="$HOME/.cua" -REPO_DIR="$DEMO_DIR/cua" +mkdir -p "$DEMO_DIR" + + +# Check if we're already in the cua repository +# Look for the specific trycua identifier in pyproject.toml +if [[ -f "pyproject.toml" ]] && grep -q "gh@trycua.com" "pyproject.toml"; then + print_success "Already in C/ua repository - using current directory" + REPO_DIR="$ORIGINAL_DIR" + USE_EXISTING_REPO=true +else + # Directories used by the script when not in repo + REPO_DIR="$DEMO_DIR/cua" + USE_EXISTING_REPO=false +fi # Function to clean up on exit cleanup() { @@ -167,22 +179,27 @@ else exit 1 fi -# Create demo directory -mkdir -p "$DEMO_DIR" +print_success "All checks passed! 🎉" -# Clone or update the repository -if [[ ! -d "$REPO_DIR" ]]; then - print_info "Cloning C/ua repository..." - cd "$DEMO_DIR" - git clone https://github.com/trycua/cua.git -else - print_info "Updating C/ua repository..." +# Create demo directory and handle repository +if [[ "$USE_EXISTING_REPO" == "true" ]]; then + print_info "Using existing repository in current directory" + cd "$REPO_DIR" +else + # Clone or update the repository + if [[ ! -d "$REPO_DIR" ]]; then + print_info "Cloning C/ua repository..." + cd "$DEMO_DIR" + git clone https://github.com/trycua/cua.git + else + print_info "Updating C/ua repository..." + cd "$REPO_DIR" + git pull origin main + fi + cd "$REPO_DIR" - git pull origin main fi -cd "$REPO_DIR" - # Create .env.local file with API keys ENV_FILE="$REPO_DIR/.env.local" if [[ ! -f "$ENV_FILE" ]]; then