From 8f52bbc60d836b877e04f736f95be87f51a7c61d Mon Sep 17 00:00:00 2001 From: AdemZarrouki Date: Thu, 7 May 2026 12:13:02 +0200 Subject: [PATCH 1/4] #1886: update NpmBasedCommandlet to correctly detect installed tool version --- .../tools/ide/tool/npm/NpmBasedCommandlet.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/npm/NpmBasedCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/tool/npm/NpmBasedCommandlet.java index 93eeb39768..b96d3049d5 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/tool/npm/NpmBasedCommandlet.java +++ b/cli/src/main/java/com/devonfw/tools/ide/tool/npm/NpmBasedCommandlet.java @@ -1,6 +1,7 @@ package com.devonfw.tools.ide.tool.npm; import java.nio.file.Files; +import java.nio.file.Path; import java.util.List; import java.util.Set; @@ -50,6 +51,17 @@ public ToolRepository getToolRepository() { return this.context.getNpmRepository(); } + /** + * Override to ignore the toolPath parameter and use npm package manager to detect the actual installed version of the tool. + * + * @param toolPath the installation {@link Path} where to find the version file. + * @return the installed version or null if not installed. + */ + @Override + protected VersionIdentifier getInstalledVersion(Path toolPath) { + return computeInstalledVersion(); + } + @Override protected VersionIdentifier computeInstalledVersion() { return runPackageManagerGetInstalledVersion(getPackageName()); From 8446e0ac847152b6f7042ea5d712fca1d336e85b Mon Sep 17 00:00:00 2001 From: AdemZarrouki Date: Thu, 7 May 2026 12:22:43 +0200 Subject: [PATCH 2/4] #1886: update CHANGELOG --- CHANGELOG.adoc | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 7c2e2ca190..9621e50d79 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -22,6 +22,7 @@ Release with new features and bugfixes: * https://github.com/devonfw/IDEasy/issues/1723[#1723]: Add commandlet for GitHub Copilot CLI * https://github.com/devonfw/IDEasy/issues/1688[#1688]: Remove unnecessary message in the CLI when installing a new tool * https://github.com/devonfw/IDEasy/issues/1685[#1685]: Add Nest CLI to IDEasy commandlets +* https://github.com/devonfw/IDEasy/issues/1886[#1886]: Fix NpmBasedCommandlet shows wrong tool version after install The full list of changes for this release can be found in https://github.com/devonfw/IDEasy/milestone/44?closed=1[milestone 2026.05.001]. From f048669be3dd00cc8d3aac74c8707d4f340d7ccc Mon Sep 17 00:00:00 2001 From: AdemZarrouki Date: Thu, 21 May 2026 10:15:58 +0200 Subject: [PATCH 3/4] #1886: move the getInstalledVersion to PackageManagerBasedLocalToolCommandlet --- .../PackageManagerBasedLocalToolCommandlet.java | 15 +++++++++++++-- .../tools/ide/tool/npm/NpmBasedCommandlet.java | 11 ----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/PackageManagerBasedLocalToolCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/tool/PackageManagerBasedLocalToolCommandlet.java index 126e538d7a..3d4a77d1d0 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/tool/PackageManagerBasedLocalToolCommandlet.java +++ b/cli/src/main/java/com/devonfw/tools/ide/tool/PackageManagerBasedLocalToolCommandlet.java @@ -180,6 +180,17 @@ public VersionIdentifier getInstalledVersion() { return this.installedVersion.get(); } + /** + * Override to ignore the {@code toolPath} parameter and use the package-manager based detection of the actually installed version. + * + * @param toolPath the installation {@link Path} where to find the version file. + * @return the installed version or null if not installed. + */ + @Override + protected VersionIdentifier getInstalledVersion(Path toolPath) { + return getInstalledVersion(); + } + @Override protected final void performToolInstallation(ToolInstallRequest request, Path installationPath) { @@ -190,8 +201,8 @@ protected final void performToolInstallation(ToolInstallRequest request, Path in } /** - * @return {@code false} if the underlying {@link #getPackageManagerClass() package manager} should also be installed, {@code false} to skip that additional installation (e.g. to prevent infinite loop in case of cyclic - * dependencies between package manager based tools such as node and npm). + * @return {@code false} if the underlying {@link #getPackageManagerClass() package manager} should also be installed, {@code false} to skip that additional + * installation (e.g. to prevent infinite loop in case of cyclic dependencies between package manager based tools such as node and npm). */ protected boolean isSkipInstallation() { return false; diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/npm/NpmBasedCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/tool/npm/NpmBasedCommandlet.java index b96d3049d5..c2a456668c 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/tool/npm/NpmBasedCommandlet.java +++ b/cli/src/main/java/com/devonfw/tools/ide/tool/npm/NpmBasedCommandlet.java @@ -1,7 +1,6 @@ package com.devonfw.tools.ide.tool.npm; import java.nio.file.Files; -import java.nio.file.Path; import java.util.List; import java.util.Set; @@ -51,16 +50,6 @@ public ToolRepository getToolRepository() { return this.context.getNpmRepository(); } - /** - * Override to ignore the toolPath parameter and use npm package manager to detect the actual installed version of the tool. - * - * @param toolPath the installation {@link Path} where to find the version file. - * @return the installed version or null if not installed. - */ - @Override - protected VersionIdentifier getInstalledVersion(Path toolPath) { - return computeInstalledVersion(); - } @Override protected VersionIdentifier computeInstalledVersion() { From 3dd30314f9e66c7f30935bb411c96ab607659e7c Mon Sep 17 00:00:00 2001 From: AdemZarrouki Date: Thu, 21 May 2026 10:26:58 +0200 Subject: [PATCH 4/4] #1886: remove extra line --- .../java/com/devonfw/tools/ide/tool/npm/NpmBasedCommandlet.java | 1 - 1 file changed, 1 deletion(-) diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/npm/NpmBasedCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/tool/npm/NpmBasedCommandlet.java index c2a456668c..93eeb39768 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/tool/npm/NpmBasedCommandlet.java +++ b/cli/src/main/java/com/devonfw/tools/ide/tool/npm/NpmBasedCommandlet.java @@ -50,7 +50,6 @@ public ToolRepository getToolRepository() { return this.context.getNpmRepository(); } - @Override protected VersionIdentifier computeInstalledVersion() { return runPackageManagerGetInstalledVersion(getPackageName());