diff --git a/registry/mavrickrishi/modules/auto-start-dev-server/README.md b/registry/mavrickrishi/modules/auto-start-dev-server/README.md new file mode 100644 index 00000000..ddb8d5e2 --- /dev/null +++ b/registry/mavrickrishi/modules/auto-start-dev-server/README.md @@ -0,0 +1,240 @@ +# Auto-Start Development Servers + +Automatically detect and start development servers for various project types when a workspace starts. This module scans your workspace for common project structures and starts the appropriate development servers in the background without manual intervention. + +## Features + +- **Multi-language support**: Detects and starts servers for Node.js, Python (Django/Flask), Ruby (Rails), Java (Spring Boot), Go, PHP, Rust, and .NET projects +- **Devcontainer integration**: Respects custom start commands defined in `.devcontainer/devcontainer.json` +- **Configurable scanning**: Adjustable directory scan depth and project type toggles +- **Non-blocking startup**: Servers start in the background with configurable startup delay +- **Comprehensive logging**: All server output and detection results logged to a central file +- **Smart detection**: Uses project-specific files and configurations to identify project types + +## Supported Project Types + +| Framework/Language | Detection Files | Start Commands | +|-------------------|----------------|----------------| +| **Node.js/npm** | `package.json` | `npm start`, `npm run dev`, `yarn start` | +| **Ruby on Rails** | `Gemfile` with rails gem | `bundle exec rails server` | +| **Django** | `manage.py` | `python manage.py runserver` | +| **Flask** | `requirements.txt` with Flask | `python app.py/main.py/run.py` | +| **Spring Boot** | `pom.xml` or `build.gradle` with spring-boot | `mvn spring-boot:run`, `gradle bootRun` | +| **Go** | `go.mod` | `go run main.go` | +| **PHP** | `composer.json` | `php -S 0.0.0.0:8080` | +| **Rust** | `Cargo.toml` | `cargo run` | +| **.NET** | `*.csproj` | `dotnet run` | + +## Usage + +```hcl +module "auto_start_dev_servers" { + source = "./modules/auto-start-dev-server" + agent_id = coder_agent.main.id + + # Optional: Configure which project types to detect + enable_npm = true + enable_rails = true + enable_django = true + enable_flask = true + enable_spring_boot = true + enable_go = true + enable_php = true + enable_rust = true + enable_dotnet = true + + # Optional: Enable devcontainer.json integration + enable_devcontainer = true + + # Optional: Workspace directory to scan (supports environment variables) + workspace_directory = "$HOME" + + # Optional: Directory scan depth (1-5) + scan_depth = 2 + + # Optional: Startup delay in seconds + startup_delay = 10 + + # Optional: Log file path + log_path = "/tmp/dev-servers.log" +} +``` + +## Configuration Options + +### Required Variables + +- `agent_id` (string): The ID of a Coder agent + +### Optional Variables + +| Variable | Type | Default | Description | +|----------|------|---------|-------------| +| `workspace_directory` | string | `"$HOME"` | Directory to scan for projects | +| `enable_npm` | bool | `true` | Enable Node.js/npm project detection | +| `enable_rails` | bool | `true` | Enable Ruby on Rails project detection | +| `enable_django` | bool | `true` | Enable Django project detection | +| `enable_flask` | bool | `true` | Enable Flask project detection | +| `enable_spring_boot` | bool | `true` | Enable Spring Boot project detection | +| `enable_go` | bool | `true` | Enable Go project detection | +| `enable_php` | bool | `true` | Enable PHP project detection | +| `enable_rust` | bool | `true` | Enable Rust project detection | +| `enable_dotnet` | bool | `true` | Enable .NET project detection | +| `enable_devcontainer` | bool | `true` | Enable devcontainer.json integration | +| `log_path` | string | `"/tmp/dev-servers.log"` | Path for logging output | +| `scan_depth` | number | `2` | Maximum directory depth to scan (1-5) | +| `startup_delay` | number | `10` | Delay in seconds before starting servers | +| `display_name` | string | `"Auto-Start Dev Servers"` | Display name for the script | + +## Devcontainer Integration + +When `enable_devcontainer` is true, the module will check for `.devcontainer/devcontainer.json` files and look for custom start commands in the VS Code settings: + +```json +{ + "customizations": { + "vscode": { + "settings": { + "npm.script.start": "npm run custom-dev-command" + } + } + } +} +``` + +If found, the custom command will be used instead of the default project detection logic. + +## Monitoring and Debugging + +### Check Running Servers + +```bash +# View all running development servers +ps aux | grep -E "(npm|rails|python|java|go|php|cargo|dotnet)" +``` + +### View Logs + +```bash +# Real-time log viewing +tail -f /tmp/dev-servers.log + +# View full log +cat /tmp/dev-servers.log +``` + +### Manual Testing + +```bash +# Test the detection script manually +cd /path/to/workspace +bash /path/to/run.sh +``` + +## Example Projects + +### Node.js Project Structure +``` +my-app/ +├── package.json # ← Detected +├── src/ +└── node_modules/ +``` + +### Django Project Structure +``` +my-project/ +├── manage.py # ← Detected +├── myapp/ +└── requirements.txt +``` + +### Spring Boot Project Structure +``` +my-service/ +├── pom.xml # ← Detected (Maven) +├── src/ +└── target/ +``` + +## Security Considerations + +- Servers are started with the same user permissions as the Coder agent +- All project detection is read-only (only checks for existence of files) +- Server processes run in the background and inherit workspace environment +- Log files contain server output which may include sensitive information + +## Troubleshooting + +### Common Issues + +1. **No servers starting**: Check that project files exist and scan depth covers your project directories +2. **Permission denied**: Ensure the script has execute permissions and dependencies are installed +3. **Wrong directory**: Verify `workspace_directory` path is correct and accessible +4. **Missing dependencies**: Install required runtimes (node, python, java, etc.) in your base image + +### Debug Mode + +Enable verbose logging by modifying the script to include debug output: + +```bash +# Add to beginning of run.sh for debugging +set -x # Enable bash debug mode +``` + +## Examples + +### Basic Usage +```hcl +module "auto_start" { + source = "./modules/auto-start-dev-server" + agent_id = coder_agent.main.id +} +``` + +### Selective Project Types +```hcl +module "auto_start" { + source = "./modules/auto-start-dev-server" + agent_id = coder_agent.main.id + + # Only enable web development projects + enable_npm = true + enable_rails = true + enable_django = true + enable_flask = true + + # Disable other project types + enable_spring_boot = false + enable_go = false + enable_php = false + enable_rust = false + enable_dotnet = false +} +``` + +### Deep Workspace Scanning +```hcl +module "auto_start" { + source = "./modules/auto-start-dev-server" + agent_id = coder_agent.main.id + + workspace_directory = "/workspaces" + scan_depth = 3 + startup_delay = 5 + log_path = "/var/log/dev-servers.log" +} +``` + +## Contributing + +This module is part of the Coder Registry. To contribute improvements: + +1. Test your changes thoroughly across different project types +2. Update documentation for any new features +3. Ensure backward compatibility with existing configurations +4. Add appropriate error handling and logging + +## License + +This module is provided under the same license as the Coder Registry. \ No newline at end of file diff --git a/registry/mavrickrishi/modules/auto-start-dev-server/main.test.ts b/registry/mavrickrishi/modules/auto-start-dev-server/main.test.ts new file mode 100644 index 00000000..c37a37a1 --- /dev/null +++ b/registry/mavrickrishi/modules/auto-start-dev-server/main.test.ts @@ -0,0 +1,109 @@ +import { describe, expect, it } from "bun:test"; +import { + runTerraformApply, + runTerraformInit, + testRequiredVariables, +} from "~test"; + +describe("auto-start-dev-server", async () => { + await runTerraformInit(import.meta.dir); + + testRequiredVariables(import.meta.dir, { + agent_id: "test-agent-123", + }); + + it("validates scan_depth range", () => { + const t1 = async () => { + await runTerraformApply(import.meta.dir, { + agent_id: "test-agent-123", + scan_depth: "0", + }); + }; + expect(t1).toThrow("Scan depth must be between 1 and 5"); + + const t2 = async () => { + await runTerraformApply(import.meta.dir, { + agent_id: "test-agent-123", + scan_depth: "6", + }); + }; + expect(t2).toThrow("Scan depth must be between 1 and 5"); + }); + + it("applies successfully with default values", async () => { + await runTerraformApply(import.meta.dir, { + agent_id: "test-agent-123", + }); + }); + + it("applies successfully with all project types enabled", async () => { + await runTerraformApply(import.meta.dir, { + agent_id: "test-agent-123", + enable_npm: "true", + enable_rails: "true", + enable_django: "true", + enable_flask: "true", + enable_spring_boot: "true", + enable_go: "true", + enable_php: "true", + enable_rust: "true", + enable_dotnet: "true", + enable_devcontainer: "true", + }); + }); + + it("applies successfully with all project types disabled", async () => { + await runTerraformApply(import.meta.dir, { + agent_id: "test-agent-123", + enable_npm: "false", + enable_rails: "false", + enable_django: "false", + enable_flask: "false", + enable_spring_boot: "false", + enable_go: "false", + enable_php: "false", + enable_rust: "false", + enable_dotnet: "false", + enable_devcontainer: "false", + }); + }); + + it("applies successfully with custom configuration", async () => { + await runTerraformApply(import.meta.dir, { + agent_id: "test-agent-123", + workspace_directory: "/custom/workspace", + scan_depth: "3", + startup_delay: "5", + log_path: "/var/log/custom-dev-servers.log", + display_name: "Custom Dev Server Startup", + }); + }); + + it("validates scan_depth boundary values", async () => { + // Test valid boundary values + await runTerraformApply(import.meta.dir, { + agent_id: "test-agent-123", + scan_depth: "1", + }); + + await runTerraformApply(import.meta.dir, { + agent_id: "test-agent-123", + scan_depth: "5", + }); + }); + + it("applies with selective project type configuration", async () => { + await runTerraformApply(import.meta.dir, { + agent_id: "test-agent-123", + enable_npm: "true", + enable_django: "true", + enable_go: "true", + enable_rails: "false", + enable_flask: "false", + enable_spring_boot: "false", + enable_php: "false", + enable_rust: "false", + enable_dotnet: "false", + }); + }); +}); \ No newline at end of file diff --git a/registry/mavrickrishi/modules/auto-start-dev-server/main.tf b/registry/mavrickrishi/modules/auto-start-dev-server/main.tf new file mode 100644 index 00000000..98473998 --- /dev/null +++ b/registry/mavrickrishi/modules/auto-start-dev-server/main.tf @@ -0,0 +1,132 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + coder = { + source = "coder/coder" + version = ">= 2.5" + } + } +} + +variable "agent_id" { + type = string + description = "The ID of a Coder agent." +} + +variable "workspace_directory" { + type = string + description = "The directory to scan for development projects." + default = "$HOME" +} + +variable "enable_npm" { + type = bool + description = "Enable auto-detection and startup of npm projects." + default = true +} + +variable "enable_rails" { + type = bool + description = "Enable auto-detection and startup of Rails projects." + default = true +} + +variable "enable_django" { + type = bool + description = "Enable auto-detection and startup of Django projects." + default = true +} + +variable "enable_flask" { + type = bool + description = "Enable auto-detection and startup of Flask projects." + default = true +} + +variable "enable_spring_boot" { + type = bool + description = "Enable auto-detection and startup of Spring Boot projects." + default = true +} + +variable "enable_go" { + type = bool + description = "Enable auto-detection and startup of Go projects." + default = true +} + +variable "enable_php" { + type = bool + description = "Enable auto-detection and startup of PHP projects." + default = true +} + +variable "enable_rust" { + type = bool + description = "Enable auto-detection and startup of Rust projects." + default = true +} + +variable "enable_dotnet" { + type = bool + description = "Enable auto-detection and startup of .NET projects." + default = true +} + +variable "enable_devcontainer" { + type = bool + description = "Enable integration with devcontainer.json configuration." + default = true +} + +variable "log_path" { + type = string + description = "The path to log development server output to." + default = "/tmp/dev-servers.log" +} + +variable "scan_depth" { + type = number + description = "Maximum directory depth to scan for projects (1-5)." + default = 2 + validation { + condition = var.scan_depth >= 1 && var.scan_depth <= 5 + error_message = "Scan depth must be between 1 and 5." + } +} + +variable "startup_delay" { + type = number + description = "Delay in seconds before starting dev servers (allows other setup to complete)." + default = 10 +} + +variable "display_name" { + type = string + description = "Display name for the auto-start dev server script." + default = "Auto-Start Dev Servers" +} + +resource "coder_script" "auto_start_dev_server" { + agent_id = var.agent_id + display_name = var.display_name + icon = "/icon/server.svg" + script = templatefile("${path.module}/run.sh", { + WORKSPACE_DIR = var.workspace_directory + ENABLE_NPM = var.enable_npm + ENABLE_RAILS = var.enable_rails + ENABLE_DJANGO = var.enable_django + ENABLE_FLASK = var.enable_flask + ENABLE_SPRING_BOOT = var.enable_spring_boot + ENABLE_GO = var.enable_go + ENABLE_PHP = var.enable_php + ENABLE_RUST = var.enable_rust + ENABLE_DOTNET = var.enable_dotnet + ENABLE_DEVCONTAINER = var.enable_devcontainer + LOG_PATH = var.log_path + SCAN_DEPTH = var.scan_depth + STARTUP_DELAY = var.startup_delay + }) + run_on_start = true +} \ No newline at end of file diff --git a/registry/mavrickrishi/modules/auto-start-dev-server/run.sh b/registry/mavrickrishi/modules/auto-start-dev-server/run.sh new file mode 100755 index 00000000..6c85c5bf --- /dev/null +++ b/registry/mavrickrishi/modules/auto-start-dev-server/run.sh @@ -0,0 +1,327 @@ +#!/usr/bin/env bash + +set -e + +# Color codes for output +BOLD='\033[0;1m' +GREEN='\033[0;32m' +YELLOW='\033[0;33m' +BLUE='\033[0;34m' +RED='\033[0;31m' +RESET='\033[0m' + +echo -e "$${BOLD}🚀 Auto-Start Development Servers$${RESET}" +echo "Workspace Directory: ${WORKSPACE_DIR}" +echo "Log Path: ${LOG_PATH}" +echo "Scan Depth: ${SCAN_DEPTH}" + +# Wait for startup delay to allow other setup to complete +if [ "${STARTUP_DELAY}" -gt 0 ]; then + echo -e "$${YELLOW}⏳ Waiting ${STARTUP_DELAY} seconds for system initialization...$${RESET}" + sleep "${STARTUP_DELAY}" +fi + +# Initialize log file +echo "=== Auto-Start Dev Servers Log ===" > "${LOG_PATH}" +echo "Started at: $(date)" >> "${LOG_PATH}" + +# Function to log messages +log_message() { + echo -e "$1" + echo "$1" >> "${LOG_PATH}" +} + +# Function to detect and start npm/yarn projects +detect_npm_projects() { + if [ "${ENABLE_NPM}" != "true" ]; then + return + fi + + log_message "$${BLUE}🔍 Scanning for Node.js/npm projects...$${RESET}" + + # Use find with maxdepth to respect scan depth + while IFS= read -r -d '' package_json; do + project_dir=$(dirname "$package_json") + log_message "$${GREEN}📦 Found Node.js project: $project_dir$${RESET}" + + cd "$project_dir" + + # Check devcontainer.json for custom start command first + if [ "${ENABLE_DEVCONTAINER}" = "true" ] && [ -f ".devcontainer/devcontainer.json" ]; then + start_cmd=$(jq -r '.customizations.vscode.settings."npm.script.start" // empty' ".devcontainer/devcontainer.json" 2>/dev/null) + if [ -n "$start_cmd" ]; then + log_message "$${YELLOW}🐳 Using devcontainer start command: $start_cmd$${RESET}" + nohup bash -c "$start_cmd" >> "${LOG_PATH}" 2>&1 & + continue + fi + fi + + # Check package.json for start script + if [ -f "package.json" ] && command -v jq &> /dev/null; then + start_script=$(jq -r '.scripts.start // empty' package.json) + dev_script=$(jq -r '.scripts.dev // empty' package.json) + + if [ -n "$start_script" ]; then + log_message "$${GREEN}🟢 Starting npm project with 'npm start' in $project_dir$${RESET}" + nohup npm start >> "${LOG_PATH}" 2>&1 & + elif [ -n "$dev_script" ]; then + log_message "$${GREEN}🟢 Starting npm project with 'npm run dev' in $project_dir$${RESET}" + nohup npm run dev >> "${LOG_PATH}" 2>&1 & + fi + elif [ -f "yarn.lock" ] && command -v yarn &> /dev/null; then + log_message "$${GREEN}🟢 Starting yarn project with 'yarn start' in $project_dir$${RESET}" + nohup yarn start >> "${LOG_PATH}" 2>&1 & + fi + + done < <(find "${WORKSPACE_DIR}" -maxdepth "${SCAN_DEPTH}" -name "package.json" -type f -print0) +} + +# Function to detect and start Rails projects +detect_rails_projects() { + if [ "${ENABLE_RAILS}" != "true" ]; then + return + fi + + log_message "$${BLUE}🔍 Scanning for Ruby on Rails projects...$${RESET}" + + while IFS= read -r -d '' gemfile; do + project_dir=$(dirname "$gemfile") + log_message "$${GREEN}💎 Found Rails project: $project_dir$${RESET}" + + cd "$project_dir" + + # Check if it's actually a Rails project + if grep -q "gem ['\"]rails['\"]" Gemfile 2>/dev/null; then + log_message "$${GREEN}🟢 Starting Rails server in $project_dir$${RESET}" + nohup bundle exec rails server >> "${LOG_PATH}" 2>&1 & + fi + + done < <(find "${WORKSPACE_DIR}" -maxdepth "${SCAN_DEPTH}" -name "Gemfile" -type f -print0) +} + +# Function to detect and start Django projects +detect_django_projects() { + if [ "${ENABLE_DJANGO}" != "true" ]; then + return + fi + + log_message "$${BLUE}🔍 Scanning for Django projects...$${RESET}" + + while IFS= read -r -d '' manage_py; do + project_dir=$(dirname "$manage_py") + log_message "$${GREEN}🐍 Found Django project: $project_dir$${RESET}" + + cd "$project_dir" + log_message "$${GREEN}🟢 Starting Django development server in $project_dir$${RESET}" + nohup python manage.py runserver 0.0.0.0:8000 >> "${LOG_PATH}" 2>&1 & + + done < <(find "${WORKSPACE_DIR}" -maxdepth "${SCAN_DEPTH}" -name "manage.py" -type f -print0) +} + +# Function to detect and start Flask projects +detect_flask_projects() { + if [ "${ENABLE_FLASK}" != "true" ]; then + return + fi + + log_message "$${BLUE}🔍 Scanning for Flask projects...$${RESET}" + + while IFS= read -r -d '' requirements_txt; do + project_dir=$(dirname "$requirements_txt") + + # Check if Flask is in requirements + if grep -q -i "flask" "$requirements_txt" 2>/dev/null; then + log_message "$${GREEN}🌶️ Found Flask project: $project_dir$${RESET}" + + cd "$project_dir" + + # Look for common Flask app files + for app_file in app.py main.py run.py; do + if [ -f "$app_file" ]; then + log_message "$${GREEN}🟢 Starting Flask application ($app_file) in $project_dir$${RESET}" + export FLASK_ENV=development + nohup python "$app_file" >> "${LOG_PATH}" 2>&1 & + break + fi + done + fi + + done < <(find "${WORKSPACE_DIR}" -maxdepth "${SCAN_DEPTH}" -name "requirements.txt" -type f -print0) +} + +# Function to detect and start Spring Boot projects +detect_spring_boot_projects() { + if [ "${ENABLE_SPRING_BOOT}" != "true" ]; then + return + fi + + log_message "$${BLUE}🔍 Scanning for Spring Boot projects...$${RESET}" + + # Maven projects + while IFS= read -r -d '' pom_xml; do + project_dir=$(dirname "$pom_xml") + + # Check if it's a Spring Boot project + if grep -q "spring-boot" "$pom_xml" 2>/dev/null; then + log_message "$${GREEN}🍃 Found Spring Boot Maven project: $project_dir$${RESET}" + + cd "$project_dir" + if command -v ./mvnw &> /dev/null; then + log_message "$${GREEN}🟢 Starting Spring Boot application with Maven wrapper in $project_dir$${RESET}" + nohup ./mvnw spring-boot:run >> "${LOG_PATH}" 2>&1 & + elif command -v mvn &> /dev/null; then + log_message "$${GREEN}🟢 Starting Spring Boot application with Maven in $project_dir$${RESET}" + nohup mvn spring-boot:run >> "${LOG_PATH}" 2>&1 & + fi + fi + + done < <(find "${WORKSPACE_DIR}" -maxdepth "${SCAN_DEPTH}" -name "pom.xml" -type f -print0) + + # Gradle projects + while IFS= read -r -d '' build_gradle; do + project_dir=$(dirname "$build_gradle") + + # Check if it's a Spring Boot project + if grep -q "spring-boot" "$build_gradle" 2>/dev/null; then + log_message "$${GREEN}🍃 Found Spring Boot Gradle project: $project_dir$${RESET}" + + cd "$project_dir" + if command -v ./gradlew &> /dev/null; then + log_message "$${GREEN}🟢 Starting Spring Boot application with Gradle wrapper in $project_dir$${RESET}" + nohup ./gradlew bootRun >> "${LOG_PATH}" 2>&1 & + elif command -v gradle &> /dev/null; then + log_message "$${GREEN}🟢 Starting Spring Boot application with Gradle in $project_dir$${RESET}" + nohup gradle bootRun >> "${LOG_PATH}" 2>&1 & + fi + fi + + done < <(find "${WORKSPACE_DIR}" -maxdepth "${SCAN_DEPTH}" -name "build.gradle" -type f -print0) +} + +# Function to detect and start Go projects +detect_go_projects() { + if [ "${ENABLE_GO}" != "true" ]; then + return + fi + + log_message "$${BLUE}🔍 Scanning for Go projects...$${RESET}" + + while IFS= read -r -d '' go_mod; do + project_dir=$(dirname "$go_mod") + log_message "$${GREEN}🐹 Found Go project: $project_dir$${RESET}" + + cd "$project_dir" + + # Look for main.go or check if there's a main function + if [ -f "main.go" ]; then + log_message "$${GREEN}🟢 Starting Go application in $project_dir$${RESET}" + nohup go run main.go >> "${LOG_PATH}" 2>&1 & + elif [ -f "cmd/main.go" ]; then + log_message "$${GREEN}🟢 Starting Go application (cmd/main.go) in $project_dir$${RESET}" + nohup go run cmd/main.go >> "${LOG_PATH}" 2>&1 & + fi + + done < <(find "${WORKSPACE_DIR}" -maxdepth "${SCAN_DEPTH}" -name "go.mod" -type f -print0) +} + +# Function to detect and start PHP projects +detect_php_projects() { + if [ "${ENABLE_PHP}" != "true" ]; then + return + fi + + log_message "$${BLUE}🔍 Scanning for PHP projects...$${RESET}" + + while IFS= read -r -d '' composer_json; do + project_dir=$(dirname "$composer_json") + log_message "$${GREEN}🐘 Found PHP project: $project_dir$${RESET}" + + cd "$project_dir" + + # Look for common PHP entry points + for entry_file in index.php public/index.php; do + if [ -f "$entry_file" ]; then + log_message "$${GREEN}🟢 Starting PHP development server in $project_dir$${RESET}" + nohup php -S 0.0.0.0:8080 -t "$(dirname "$entry_file")" >> "${LOG_PATH}" 2>&1 & + break + fi + done + + done < <(find "${WORKSPACE_DIR}" -maxdepth "${SCAN_DEPTH}" -name "composer.json" -type f -print0) +} + +# Function to detect and start Rust projects +detect_rust_projects() { + if [ "${ENABLE_RUST}" != "true" ]; then + return + fi + + log_message "$${BLUE}🔍 Scanning for Rust projects...$${RESET}" + + while IFS= read -r -d '' cargo_toml; do + project_dir=$(dirname "$cargo_toml") + log_message "$${GREEN}🦀 Found Rust project: $project_dir$${RESET}" + + cd "$project_dir" + + # Check if it's a binary project (has [[bin]] or default main.rs) + if grep -q "\[\[bin\]\]" Cargo.toml 2>/dev/null || [ -f "src/main.rs" ]; then + log_message "$${GREEN}🟢 Starting Rust application in $project_dir$${RESET}" + nohup cargo run >> "${LOG_PATH}" 2>&1 & + fi + + done < <(find "${WORKSPACE_DIR}" -maxdepth "${SCAN_DEPTH}" -name "Cargo.toml" -type f -print0) +} + +# Function to detect and start .NET projects +detect_dotnet_projects() { + if [ "${ENABLE_DOTNET}" != "true" ]; then + return + fi + + log_message "$${BLUE}🔍 Scanning for .NET projects...$${RESET}" + + while IFS= read -r -d '' csproj; do + project_dir=$(dirname "$csproj") + log_message "$${GREEN}🔷 Found .NET project: $project_dir$${RESET}" + + cd "$project_dir" + log_message "$${GREEN}🟢 Starting .NET application in $project_dir$${RESET}" + nohup dotnet run >> "${LOG_PATH}" 2>&1 & + + done < <(find "${WORKSPACE_DIR}" -maxdepth "${SCAN_DEPTH}" -name "*.csproj" -type f -print0) +} + +# Main execution +main() { + log_message "Starting auto-detection of development projects..." + + # Expand workspace directory if it contains variables + WORKSPACE_DIR=$(eval echo "${WORKSPACE_DIR}") + + # Check if workspace directory exists + if [ ! -d "$WORKSPACE_DIR" ]; then + log_message "$${RED}❌ Workspace directory does not exist: $WORKSPACE_DIR$${RESET}" + exit 1 + fi + + cd "$WORKSPACE_DIR" + + # Run all detection functions + detect_npm_projects + detect_rails_projects + detect_django_projects + detect_flask_projects + detect_spring_boot_projects + detect_go_projects + detect_php_projects + detect_rust_projects + detect_dotnet_projects + + log_message "$${GREEN}✅ Auto-start scan completed!$${RESET}" + log_message "$${YELLOW}💡 Check running processes with 'ps aux | grep -E \"(npm|rails|python|java|go|php|cargo|dotnet)\"'$${RESET}" + log_message "$${YELLOW}💡 View logs: tail -f ${LOG_PATH}$${RESET}" +} + +# Run main function +main "$@" \ No newline at end of file