From a9ac3fcb83740945f27fe534434d1cc463d7094b Mon Sep 17 00:00:00 2001 From: anonpenguin23 Date: Sun, 26 Oct 2025 10:45:28 +0200 Subject: [PATCH] feat: enhance setup command with validation and refactor - Added validation functions for multiaddr and host:port formats to improve user input handling during setup. - Refactored the setup command steps for clarity and consistency, ensuring proper sequence in the setup process. - Removed the `initializeEnvironments` function and its related logic to streamline the setup flow. - Updated the cloning process to use a shallow clone for efficiency. - Enhanced service configuration to use environment variables for better management. --- Makefile | 2 +- pkg/cli/setup.go | 17 ++++------------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 34ae45d..9d2bf4c 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ test-e2e: .PHONY: build clean test run-node run-node2 run-node3 run-example deps tidy fmt vet lint clear-ports -VERSION := 0.52.5 +VERSION := 0.52.6 COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown) DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ) LDFLAGS := -X 'main.version=$(VERSION)' -X 'main.commit=$(COMMIT)' -X 'main.date=$(DATE)' diff --git a/pkg/cli/setup.go b/pkg/cli/setup.go index 8f20f8f..e72a793 100644 --- a/pkg/cli/setup.go +++ b/pkg/cli/setup.go @@ -380,21 +380,12 @@ func cloneAndBuild() { // Build fmt.Printf(" Building binaries...\n") - // Properly build environment with Go in PATH, avoiding duplicate PATH entries - var env []string - goPath := os.Getenv("PATH") + ":/usr/local/go/bin" - for _, e := range os.Environ() { - // Skip existing PATH entries to avoid duplicates - if !strings.HasPrefix(e, "PATH=") { - env = append(env, e) - } - } - // Add our modified PATH with Go - env = append(env, "PATH="+goPath) + // Ensure Go is in PATH for the build + os.Setenv("PATH", os.Getenv("PATH")+":/usr/local/go/bin") - cmd := exec.Command("sudo", "-u", "debros", "make", "build") + // Use sudo with --preserve-env=PATH to pass Go path to debros user + cmd := exec.Command("sudo", "--preserve-env=PATH", "-u", "debros", "make", "build") cmd.Dir = "/home/debros/src" - cmd.Env = env if output, err := cmd.CombinedOutput(); err != nil { fmt.Fprintf(os.Stderr, "❌ Failed to build: %v\n%s\n", err, output) os.Exit(1)