diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 73dd322f3a..4dc1fde8f5 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -6,6 +6,7 @@ This file documents all notable changes to https://github.com/devonfw/IDEasy[IDE Release with new features and bugfixes: +* https://github.com/devonfw/IDEasy/issues/2189[#2189]: Integrate Ruff * https://github.com/devonfw/IDEasy/issues/2100[#2100]: Fix Python not available for Mac x64 The full list of changes for this release can be found in https://github.com/devonfw/IDEasy/milestone/48?closed=1[milestone 2026.08.001]. diff --git a/cli/src/main/java/com/devonfw/tools/ide/commandlet/CommandletManagerImpl.java b/cli/src/main/java/com/devonfw/tools/ide/commandlet/CommandletManagerImpl.java index 56cd9fa3cf..88c7724e68 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/commandlet/CommandletManagerImpl.java +++ b/cli/src/main/java/com/devonfw/tools/ide/commandlet/CommandletManagerImpl.java @@ -58,6 +58,7 @@ import com.devonfw.tools.ide.tool.pycharm.Pycharm; import com.devonfw.tools.ide.tool.python.Python; import com.devonfw.tools.ide.tool.quarkus.Quarkus; +import com.devonfw.tools.ide.tool.ruff.Ruff; import com.devonfw.tools.ide.tool.rust.Rust; import com.devonfw.tools.ide.tool.soapui.SoapUi; import com.devonfw.tools.ide.tool.sonar.Sonar; @@ -178,6 +179,7 @@ public CommandletManagerImpl(IdeContext context) { add(new Mvnd(context)); add(new Just(context)); add(new SoapUi(context)); + add(new Ruff(context)); } /** diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/ruff/Ruff.java b/cli/src/main/java/com/devonfw/tools/ide/tool/ruff/Ruff.java new file mode 100644 index 0000000000..daa32e9281 --- /dev/null +++ b/cli/src/main/java/com/devonfw/tools/ide/tool/ruff/Ruff.java @@ -0,0 +1,40 @@ +package com.devonfw.tools.ide.tool.ruff; + +import java.util.Set; + +import com.devonfw.tools.ide.common.Tag; +import com.devonfw.tools.ide.context.IdeContext; +import com.devonfw.tools.ide.tool.PackageManagerRequest; +import com.devonfw.tools.ide.tool.uv.UvBasedCommandlet; + +/** + * {@link UvBasedCommandlet} for ruff. + */ +public class Ruff extends UvBasedCommandlet { + + /** + * The constructor. + * + * @param context the {@link IdeContext}. + */ + public Ruff(IdeContext context) { + super(context, "ruff", Set.of(Tag.BUILD)); + } + + @Override + public String getPackageName() { + return "ruff"; + } + + @Override + protected String completeRequestOption(PackageManagerRequest request) { + + if (PackageManagerRequest.TYPE_INSTALL.equals(request.getType())) { + return "--force"; + } + + return super.completeRequestOption(request); + } + + +} diff --git a/cli/src/main/resources/nls/Help.properties b/cli/src/main/resources/nls/Help.properties index 5bbac94170..aacdefef89 100644 --- a/cli/src/main/resources/nls/Help.properties +++ b/cli/src/main/resources/nls/Help.properties @@ -121,6 +121,8 @@ cmd.release.val.args=Additional arguments to pass to the build and deploy comman cmd.repository=Set up pre-configured git repositories using 'ide repository setup ' cmd.repository.detail=Without further arguments this will set up all pre-configured git repositories.\nAlso, you can provide an explicit git repo as `` argument and IDEasy will automatically clone, build and set up your project based on the existing property file.\nRepositories are configured in 'settings/repository/.properties' and can therefore be shared with your project team for automatic or optional setup. cmd.repository.val.repository=The name of the properties file of the pre-configured git repository to set up, omit to set up all active repositories. +cmd.ruff=Tool commandlet for Ruff. +cmd.ruff.detail=Ruff is an extremely fast Python linter and code formatter. Detailed documentation can be found at https://docs.astral.sh/ruff/ cmd.rust=Tool commandlet for Rust (programming language). cmd.rust.detail=Rust is a programming-language focused on safety and performance. Detailed documentation can be found at https://www.rust-lang.org/learn cmd.set-edition=Set the edition of the selected tool. diff --git a/cli/src/main/resources/nls/Help_de.properties b/cli/src/main/resources/nls/Help_de.properties index 78188514ae..83bd160e63 100644 --- a/cli/src/main/resources/nls/Help_de.properties +++ b/cli/src/main/resources/nls/Help_de.properties @@ -121,6 +121,8 @@ cmd.release.val.args=Zusätzliche Argumente, die an den Build- und Deploy-Befehl cmd.repository=Richtet das vorkonfigurierte Git Repository ein mittels 'ide repository setup '. cmd.repository.detail=Dies wird alle vorkonfigurierten Repositories einrichten. Rufen Sie einfach 'ide repository setup ' auf, ersetzen Sie durch den Namen Ihrer Projektkonfigurationsdatei, die sich in 'settings/repository/your_project_name' befindet und IDEasy wird Ihr Projekt basierend auf der vorhandenen Eigenschaftsdatei automatisch klonen, bauen und einrichten.\nWenn Sie den Projektnamen weglassen, werden alle im Repository-Verzeichnis gefundenen Projekte vorkonfiguriert. cmd.repository.val.repository=Der Name der Properties-Datei des vorkonfigurierten Git Repositories zum Einrichten. Falls nicht angegeben, werden alle aktiven Projekte eingerichtet. +cmd.ruff=Werkzeug Kommando für Ruff. +cmd.ruff.detail=Ruff ist ein extrem schneller Python-Linter und Code-Formatter. Detaillierte Dokumentation findet sich unter https://docs.astral.sh/ruff/ cmd.rust=Werkzeug Kommando für Rust (Programmiersprache). cmd.rust.detail=Rust ist eine Programmiersprache mit Fokus auf Sicherheit und Performance. Detaillierte Dokumentation findet sich unter https://www.rust-lang.org/learn cmd.set-edition=Setzt die Edition des selektierten Werkzeugs. diff --git a/cli/src/test/java/com/devonfw/tools/ide/tool/ruff/RuffTest.java b/cli/src/test/java/com/devonfw/tools/ide/tool/ruff/RuffTest.java new file mode 100644 index 0000000000..dff55e1ae1 --- /dev/null +++ b/cli/src/test/java/com/devonfw/tools/ide/tool/ruff/RuffTest.java @@ -0,0 +1,79 @@ +package com.devonfw.tools.ide.tool.ruff; + +import org.junit.jupiter.api.Test; + +import com.devonfw.tools.ide.context.AbstractIdeContextTest; +import com.devonfw.tools.ide.context.IdeTestContext; +import com.devonfw.tools.ide.os.SystemInfoMock; +import com.devonfw.tools.ide.tool.uv.UvBasedCommandlet; +import com.devonfw.tools.ide.version.VersionIdentifier; +import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo; +import com.github.tomakehurst.wiremock.junit5.WireMockTest; + +/** + * Test of {@link Ruff}. + */ +@WireMockTest +public class RuffTest extends AbstractIdeContextTest { + + private static final String PROJECT_UV = "uv"; + + /** + * Tests that {@link Ruff} installs via {@code uv tool}. + * + * @param wireMockRuntimeInfo wireMock server on a random part + */ + @Test + void testRuffInstall(WireMockRuntimeInfo wireMockRuntimeInfo) { + + // arrange + IdeTestContext context = newContext(PROJECT_UV, wireMockRuntimeInfo); + context.setSystemInfo(SystemInfoMock.LINUX_X64); + Ruff commandlet = new Ruff(context); + + // act + commandlet.install(); + + // assert + assertThat(context).logAtInfo().hasMessageContaining("uv tool install --force ruff@"); + assertThat(context).logAtSuccess().hasMessageContaining("Successfully installed ruff"); + } + + /** + * Tests that {@link Ruff} is implemented as a {@link UvBasedCommandlet}. + * + * @param wireMockRuntimeInfo wireMock server on a random port + */ + @Test + void testRuffIsUvBasedCommandlet(WireMockRuntimeInfo wireMockRuntimeInfo) { + + //arrange + IdeTestContext context = newContext(PROJECT_UV, wireMockRuntimeInfo); + context.setSystemInfo(SystemInfoMock.LINUX_X64); + + // act + Ruff commandlet = new Ruff(context); + + // assert + assertThat(commandlet).isInstanceOf(UvBasedCommandlet.class); + } + + /** + * Tests that {@link Ruff#getInstalledVersion()} parses the version from {@code uv tool list} output. + */ + @Test + void testRuffGetInstalledVersion(WireMockRuntimeInfo wireMockRuntimeInfo) { + + // arrange + IdeTestContext context = newContext(PROJECT_UV, wireMockRuntimeInfo); + context.setSystemInfo(SystemInfoMock.LINUX_X64); + Ruff commandlet = new Ruff(context); + commandlet.install(); + + // act + VersionIdentifier installedVersion = commandlet.getInstalledVersion(); + + // assert + assertThat(installedVersion).isEqualTo(VersionIdentifier.of("0.15.22")); + } +} diff --git a/cli/src/test/resources/ide-projects/uv/repository/pypi/ruff.json b/cli/src/test/resources/ide-projects/uv/repository/pypi/ruff.json new file mode 100644 index 0000000000..7b27e138e2 --- /dev/null +++ b/cli/src/test/resources/ide-projects/uv/repository/pypi/ruff.json @@ -0,0 +1,7 @@ +{ + "releases": { + "0.15.20": [], + "0.15.21": [], + "0.15.22": [] + } +} diff --git a/documentation/LICENSE.adoc b/documentation/LICENSE.adoc index 0e0bab23cf..264658a43f 100644 --- a/documentation/LICENSE.adoc +++ b/documentation/LICENSE.adoc @@ -115,6 +115,7 @@ The column `inclusion` indicates the way the component is included: |https://developer.konghq.com/inso-cli |Optional|https://github.com/Kong/insomnia/blob/develop/LICENSE[Apache 2.0] |https://www.rust-lang.org/[Rust] |Optional|https://www.rust-lang.org/policies/licenses[MIT and Apache 2.0] |https://visualstudio.microsoft.com/visual-cpp-build-tools/[MSVC Build Tools] |Optional|https://visualstudio.microsoft.com/license-terms/vs2022-ga-community/[Microsoft Software License Terms] +|https://docs.astral.sh/ruff[ruff] |Optional|https://github.com/astral-sh/ruff/blob/main/LICENSE[MIT License] |=== == Apache Software License - Version 2.0