From 1f4033aa6347ec4b5b663b31920a0e9c7d2dddb7 Mon Sep 17 00:00:00 2001 From: francisco Date: Wed, 7 May 2025 16:02:09 +0100 Subject: [PATCH 1/6] installing eslint in wsl --- config/tools-installer.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/config/tools-installer.go b/config/tools-installer.go index f9994e32..b2d4fa41 100644 --- a/config/tools-installer.go +++ b/config/tools-installer.go @@ -6,6 +6,7 @@ import ( "codacy/cli-v2/utils" "codacy/cli-v2/utils/logger" "fmt" + "log" "os" "os/exec" "path/filepath" @@ -164,6 +165,25 @@ func installRuntimeTool(name string, toolInfo *plugins.ToolInfo, registry string // Execute the installation command using the package manager cmd := exec.Command(packageManagerBinary, strings.Split(installCmd, " ")...) + + // Special handling for ESLint installation in WSL environment + if toolInfo.Name == "eslint" { + // Get node binary directory to add to PATH + nodeBinary, ok := runtimeInfo.Binaries["node"] + if ok { + nodeDir := filepath.Dir(nodeBinary) + // Get current PATH + currentPath := os.Getenv("PATH") + // For WSL, always use Linux path separator + pathSeparator := ":" + newPath := nodeDir + pathSeparator + currentPath + cmd.Env = append(os.Environ(), "PATH="+newPath) + log.Printf("Setting PATH environment for ESLint installation: %s\n", nodeDir) + } + } + + log.Printf("Installing %s v%s...\n", toolInfo.Name, toolInfo.Version) + log.Printf("Running command: %s %s\n", packageManagerBinary, installCmd) output, err := cmd.CombinedOutput() if err != nil { return fmt.Errorf("failed to install tool: %s: %w", string(output), err) From 52fed217b11a99d13ba864c5b6467a179ce94b19 Mon Sep 17 00:00:00 2001 From: francisco Date: Thu, 8 May 2025 11:38:11 +0100 Subject: [PATCH 2/6] fixed codacy-cli.sh to work with aarch64 architecture --- codacy-cli.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/codacy-cli.sh b/codacy-cli.sh index b629b93a..7057e3bf 100755 --- a/codacy-cli.sh +++ b/codacy-cli.sh @@ -17,6 +17,9 @@ case "$arch" in "x86") arch="386" ;; +"aarch64"|"arm64") + arch="arm64" + ;; esac if [ -z "$CODACY_CLI_V2_TMP_FOLDER" ]; then From 1b2be53a8ffb223faa7df93b41c0db3e7a4f20e8 Mon Sep 17 00:00:00 2001 From: "andrzej.janczak" Date: Mon, 12 May 2025 11:18:26 +0200 Subject: [PATCH 3/6] refine ESLint installation handling for Linux (WSL) environment --- config/tools-installer.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/tools-installer.go b/config/tools-installer.go index b2d4fa41..5e6c9cad 100644 --- a/config/tools-installer.go +++ b/config/tools-installer.go @@ -166,15 +166,15 @@ func installRuntimeTool(name string, toolInfo *plugins.ToolInfo, registry string // Execute the installation command using the package manager cmd := exec.Command(packageManagerBinary, strings.Split(installCmd, " ")...) - // Special handling for ESLint installation in WSL environment + // Special handling for ESLint installation in Linux (WSL) environment if toolInfo.Name == "eslint" { // Get node binary directory to add to PATH - nodeBinary, ok := runtimeInfo.Binaries["node"] - if ok { + nodeBinary, exist := runtimeInfo.Binaries["node"] + if exist { nodeDir := filepath.Dir(nodeBinary) // Get current PATH currentPath := os.Getenv("PATH") - // For WSL, always use Linux path separator + // For Linux (WSL), always use Linux path separator pathSeparator := ":" newPath := nodeDir + pathSeparator + currentPath cmd.Env = append(os.Environ(), "PATH="+newPath) From 73c39abbafd423ecf6ae01e0ed719670aac5a9f1 Mon Sep 17 00:00:00 2001 From: "andrzej.janczak" Date: Mon, 12 May 2025 11:24:28 +0200 Subject: [PATCH 4/6] use file logger isntead stdout --- config/tools-installer.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/config/tools-installer.go b/config/tools-installer.go index 5e6c9cad..1a14756f 100644 --- a/config/tools-installer.go +++ b/config/tools-installer.go @@ -178,11 +178,19 @@ func installRuntimeTool(name string, toolInfo *plugins.ToolInfo, registry string pathSeparator := ":" newPath := nodeDir + pathSeparator + currentPath cmd.Env = append(os.Environ(), "PATH="+newPath) - log.Printf("Setting PATH environment for ESLint installation: %s\n", nodeDir) + logger.Debug("Setting PATH environment for ESLint installation", logrus.Fields{ + "nodeDir": nodeDir, + "currentPath": currentPath, + "newPath": newPath, + }) } } - log.Printf("Installing %s v%s...\n", toolInfo.Name, toolInfo.Version) + logger.Debug("Installing tool", logrus.Fields{ + "tool": name, + "version": toolInfo.Version, + }) + log.Printf("Running command: %s %s\n", packageManagerBinary, installCmd) output, err := cmd.CombinedOutput() if err != nil { From 134824602f6231c068898dbc68241c4e776fb225 Mon Sep 17 00:00:00 2001 From: "andrzej.janczak" Date: Mon, 12 May 2025 11:26:04 +0200 Subject: [PATCH 5/6] fix logging --- config/tools-installer.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/config/tools-installer.go b/config/tools-installer.go index 1a14756f..6ea0b0d0 100644 --- a/config/tools-installer.go +++ b/config/tools-installer.go @@ -186,12 +186,10 @@ func installRuntimeTool(name string, toolInfo *plugins.ToolInfo, registry string } } - logger.Debug("Installing tool", logrus.Fields{ - "tool": name, - "version": toolInfo.Version, + log.Printf("Installing %s v%s...\n", toolInfo.Name, toolInfo.Version) + logger.Debug("Running command", logrus.Fields{ + "command": fmt.Sprintf("%s %s", packageManagerBinary, installCmd), }) - - log.Printf("Running command: %s %s\n", packageManagerBinary, installCmd) output, err := cmd.CombinedOutput() if err != nil { return fmt.Errorf("failed to install tool: %s: %w", string(output), err) From 9b7b1f7a5bbd1651ce2b4a976b71866e3a45d580 Mon Sep 17 00:00:00 2001 From: "andrzej.janczak" Date: Mon, 12 May 2025 12:17:45 +0200 Subject: [PATCH 6/6] improve fix only for linux --- config/tools-installer.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/tools-installer.go b/config/tools-installer.go index 6ea0b0d0..75466fd7 100644 --- a/config/tools-installer.go +++ b/config/tools-installer.go @@ -10,6 +10,7 @@ import ( "os" "os/exec" "path/filepath" + "runtime" "strings" "text/template" @@ -167,7 +168,7 @@ func installRuntimeTool(name string, toolInfo *plugins.ToolInfo, registry string cmd := exec.Command(packageManagerBinary, strings.Split(installCmd, " ")...) // Special handling for ESLint installation in Linux (WSL) environment - if toolInfo.Name == "eslint" { + if toolInfo.Name == "eslint" && runtime.GOOS == "linux" { // Get node binary directory to add to PATH nodeBinary, exist := runtimeInfo.Binaries["node"] if exist {