diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 4e54f3ed6f..2874744531 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -21,6 +21,7 @@ Release with new features and bugfixes: * https://github.com/devonfw/IDEasy/issues/797[#797]: Use system unzip on macOS to preserve symlinks in ZIP extraction * https://github.com/devonfw/IDEasy/issues/1723[#1723]: Add commandlet for GitHub Copilot CLI * https://github.com/devonfw/IDEasy/issues/1685[#1685]: Add Nest CLI to IDEasy commandlets +* https://github.com/devonfw/IDEasy/issues/1882[#1882]: Add AWS CDK to IDEasy commandlets 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]. 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 69b23e64b8..104f33954d 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 @@ -21,6 +21,7 @@ import com.devonfw.tools.ide.tool.androidstudio.AndroidStudio; import com.devonfw.tools.ide.tool.aws.Aws; import com.devonfw.tools.ide.tool.az.Azure; +import com.devonfw.tools.ide.tool.cdk.Cdk; import com.devonfw.tools.ide.tool.copilot.Copilot; import com.devonfw.tools.ide.tool.corepack.Corepack; import com.devonfw.tools.ide.tool.docker.Docker; @@ -156,6 +157,7 @@ public CommandletManagerImpl(IdeContext context) { add(new Gui(context)); add(new SquirrelSql(context)); add(new Nest(context)); + add(new Cdk(context)); } /** diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/cdk/Cdk.java b/cli/src/main/java/com/devonfw/tools/ide/tool/cdk/Cdk.java new file mode 100644 index 0000000000..2c03d16d69 --- /dev/null +++ b/cli/src/main/java/com/devonfw/tools/ide/tool/cdk/Cdk.java @@ -0,0 +1,30 @@ +package com.devonfw.tools.ide.tool.cdk; + +import java.util.Set; + +import com.devonfw.tools.ide.common.Tag; +import com.devonfw.tools.ide.context.IdeContext; +import com.devonfw.tools.ide.tool.ToolCommandlet; +import com.devonfw.tools.ide.tool.npm.NpmBasedCommandlet; + +/** + * {@link ToolCommandlet} for AWS CDK. + */ +public class Cdk extends NpmBasedCommandlet { + + /** + * The constructor. + * + * @param context the {@link IdeContext}. + */ + public Cdk(IdeContext context) { + + super(context, "cdk", Set.of(Tag.TYPE_SCRIPT, Tag.BUILD)); + } + + @Override + public String getPackageName() { + + return "aws-cdk"; + } +} diff --git a/cli/src/main/resources/nls/Help.properties b/cli/src/main/resources/nls/Help.properties index 9f5dd711bd..34a6b8b72b 100644 --- a/cli/src/main/resources/nls/Help.properties +++ b/cli/src/main/resources/nls/Help.properties @@ -7,6 +7,8 @@ cmd.az.detail=The Azure Command-Line Interface (CLI) is a tool for creating and cmd.build=Runs a build job with given arguments. cmd.build.detail=The `build` commandlet is an abstraction of build systems like https://maven.apache.org/, https://gradle.org/, https://yarnpkg.com/, https://www.npmjs.com/, etc.\nIt will auto-detect your build-system (via existence of files like `pom.xml`, `package.json`, etc.). According to this detection, it will simply delegate to the according commandlet of the specific build system. If that build-system is not yet available it will be downloaded and installed automatically.\nSo `ide build` allows users to build any project without bothering about the build-system. Further specific build options can be configured per project. This makes `ide build` a universal part of every _definition of done_. Before pushing your changes, please always run the following command to verify the build:\n\n 'ide build'\n\nYou may also supply additional arguments as `ide build «args»`. This will simply delegate these arguments to the detected build command (e.g. call `mvn «args»`). cmd.build.val.args=Build arguments to be used when running a build job. +cmd.cdk=Tool commandlet for AWS CDK. +cmd.cdk.detail=The AWS Cloud Development Kit (AWS CDK) is an open-source software development framework for defining cloud infrastructure in code and provisioning it through AWS CloudFormation. Detailed documentation can be found at https://docs.aws.amazon.com/cdk/v2/guide/home.html cmd.complete=Internal commandlet for bash auto-completion. cmd.complete.detail=Run 'ide complete ' to activate the non-interactive autocompletion, replace with the arguments you want to autocomplete.\nE.g. type: 'ide complete in' to get 'install' and 'intellij' suggestions. cmd.copilot=Tool commandlet for GitHub Copilot CLI. diff --git a/cli/src/main/resources/nls/Help_de.properties b/cli/src/main/resources/nls/Help_de.properties index a90b64bc66..ab3062fd2a 100644 --- a/cli/src/main/resources/nls/Help_de.properties +++ b/cli/src/main/resources/nls/Help_de.properties @@ -7,6 +7,8 @@ cmd.az.detail=Das Azure Command-Line Interface (CLI) ist ein Werkzeug zur Erstel cmd.build=Startet einen build Prozess mit übergebenen Argumenten. cmd.build.detail=Der `build`-Befehl ist eine Abstraktion von Build-Systemen wie https://maven.apache.org/, https://gradle.org/, https://yarnpkg.com/, https://www.npmjs.com/ usw.\nEr erkennt automatisch Ihr Build-System (anhand von Dateien wie `pom.xml`, `package.json` usw.). Entsprechend dieser Erkennung delegiert er einfach an den entsprechenden Befehl des spezifischen Build-Systems. Wenn dieses Build-System noch nicht verfügbar ist, wird es automatisch heruntergeladen und installiert.\nSo ermöglicht `ide build` Benutzern, jedes Projekt zu erstellen, ohne sich um das Build-System kümmern zu müssen. Weitere spezifische Build-Optionen können pro Projekt konfiguriert werden. Dies macht `ide build` zu einem universellen Bestandteil jeder _Definition of Done_. Bevor Sie Ihre Änderungen übertragen, führen Sie bitte immer den folgenden Befehl aus, um den Build zu überprüfen:\n\n`ide build`\n\nSie können auch zusätzliche Argumente wie `ide build «args»` angeben. Diese werden einfach an den erkannten Build-Befehl weitergeleitet (z. B. Aufruf von `mvn «args»`). cmd.build.val.args=Argumente die bei dem build Prozess genutzt werden sollen. +cmd.cdk=Werkzeug Kommando für AWS CDK. +cmd.cdk.detail=Das AWS Cloud Development Kit (AWS CDK) ist ein Open-Source-Softwareentwicklungsframework zur Modellierung und Bereitstellung von Cloud-Anwendungen mithilfe von bekannten Programmiersprachen. Detaillierte Dokumentation ist zu finden unter https://docs.aws.amazon.com/cdk/v2/guide/home.html cmd.complete=Internes Werkzeug für bash Autovervollständigung. cmd.complete.detail=Geben Sie 'ide complete ' in die Konsole ein um die einfache Autovervollständigung zu aktivieren, ersetzen Sie mit dem Ausdruck, der automatisch vervollständigt werden soll.\nZ.B. geben Sie einfach 'ide complete in' in die Konsole ein um 'install' und 'intellij' als Vorschläge zu erhalten. cmd.copilot=Werkzeug Kommando für GitHub Copilot CLI. diff --git a/cli/src/test/integration-tests/install-cdk.sh b/cli/src/test/integration-tests/install-cdk.sh new file mode 100644 index 0000000000..5b93697f5e --- /dev/null +++ b/cli/src/test/integration-tests/install-cdk.sh @@ -0,0 +1,13 @@ +echo "Running install cdk integration test" +ide -d install cdk + +cdk_location="" + +if doIsWindows +then + cdk_location="" +else + cdk_location="bin/" +fi + +assertThat "${IDE_ROOT}/${TEST_PROJECT_NAME}/software/node/${cdk_location}cdk" exists diff --git a/cli/src/test/java/com/devonfw/tools/ide/tool/cdk/CdkTest.java b/cli/src/test/java/com/devonfw/tools/ide/tool/cdk/CdkTest.java new file mode 100644 index 0000000000..a6cdcb35d7 --- /dev/null +++ b/cli/src/test/java/com/devonfw/tools/ide/tool/cdk/CdkTest.java @@ -0,0 +1,91 @@ +package com.devonfw.tools.ide.tool.cdk; + +import org.junit.jupiter.api.Test; + +import com.devonfw.tools.ide.context.AbstractIdeContextTest; +import com.devonfw.tools.ide.context.IdeTestContext; +import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo; +import com.github.tomakehurst.wiremock.junit5.WireMockTest; + +/** + * Test of {@link Cdk}. + */ +@WireMockTest +class CdkTest extends AbstractIdeContextTest { + + private static final String PROJECT_CDK = "cdk"; + + /** + * Tests if the {@link Cdk} install works correctly. + * + * @param wireMockRuntimeInfo wireMock server on a random port + */ + @Test + void testCdkInstall(WireMockRuntimeInfo wireMockRuntimeInfo) { + + // arrange + IdeTestContext context = newContext(PROJECT_CDK, wireMockRuntimeInfo); + Cdk commandlet = new Cdk(context); + + // act + commandlet.install(); + + // assert + checkInstallation(context); + + } + + /** + * Tests if the {@link Cdk} install works correctly. + * + * @param wireMockRuntimeInfo wireMock server on a random port + */ + @Test + void testCdkUninstall(WireMockRuntimeInfo wireMockRuntimeInfo) { + + // arrange + IdeTestContext context = newContext(PROJECT_CDK, wireMockRuntimeInfo); + Cdk commandlet = new Cdk(context); + + // act I + commandlet.install(); + + // assert I + checkInstallation(context); + + // act II + commandlet.uninstall(); + + // assert II + assertThat(context).logAtInfo().hasMessageContaining("npm uninstall -g aws-cdk"); + + assertThat(context).logAtSuccess().hasMessage("Successfully uninstalled cdk"); + } + + /** + * Tests if {@link Cdk} run works correctly. + * + * @param wireMockRuntimeInfo wireMock server on a random port + */ + @Test + void testCdkRun(WireMockRuntimeInfo wireMockRuntimeInfo) { + + // arrange + IdeTestContext context = newContext(PROJECT_CDK, wireMockRuntimeInfo); + Cdk commandlet = new Cdk(context); + commandlet.arguments.setValue("--version"); + + // act + commandlet.run(); + + // assert + assertThat(context).logAtInfo().hasMessageContaining("cdk --version"); + } + + private void checkInstallation(IdeTestContext context) { + + assertThat(context).logAtInfo().hasMessageContaining("npm install -gf aws-cdk@2.1120.0"); + + assertThat(context).logAtSuccess().hasMessageContaining("Successfully installed cdk in version 2.1120.0"); + } +} diff --git a/cli/src/test/resources/ide-projects/cdk/_ide/urls/node/node/v18.19.1/urls b/cli/src/test/resources/ide-projects/cdk/_ide/urls/node/node/v18.19.1/urls new file mode 100644 index 0000000000..a07d5a1205 --- /dev/null +++ b/cli/src/test/resources/ide-projects/cdk/_ide/urls/node/node/v18.19.1/urls @@ -0,0 +1 @@ +${testbaseurl}/download/node/node/v18.19.1/node-v18.19.1.tgz diff --git a/cli/src/test/resources/ide-projects/cdk/_ide/urls/npm/npm/dependencies.json b/cli/src/test/resources/ide-projects/cdk/_ide/urls/npm/npm/dependencies.json new file mode 100644 index 0000000000..b84a1b86c9 --- /dev/null +++ b/cli/src/test/resources/ide-projects/cdk/_ide/urls/npm/npm/dependencies.json @@ -0,0 +1,8 @@ +{ + "[9.0, 10.0)": [ + { + "tool": "node", + "versionRange": "[18.0.0,)" + } + ] +} diff --git a/cli/src/test/resources/ide-projects/cdk/project/home/.ide/ide.properties b/cli/src/test/resources/ide-projects/cdk/project/home/.ide/ide.properties new file mode 100644 index 0000000000..e69de29bb2 diff --git a/cli/src/test/resources/ide-projects/cdk/project/settings/ide.properties b/cli/src/test/resources/ide-projects/cdk/project/settings/ide.properties new file mode 100644 index 0000000000..603b70d898 --- /dev/null +++ b/cli/src/test/resources/ide-projects/cdk/project/settings/ide.properties @@ -0,0 +1,3 @@ +NODE_VERSION=v18.19.1 +NPM_VERSION=9.9.2 +CDK_VERSION=2.1120.0 diff --git a/cli/src/test/resources/ide-projects/cdk/project/workspaces/main/.gitkeep b/cli/src/test/resources/ide-projects/cdk/project/workspaces/main/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/cli/src/test/resources/ide-projects/cdk/repository/node/node/default/cdk b/cli/src/test/resources/ide-projects/cdk/repository/node/node/default/cdk new file mode 100755 index 0000000000..00fc09e0aa --- /dev/null +++ b/cli/src/test/resources/ide-projects/cdk/repository/node/node/default/cdk @@ -0,0 +1,2 @@ +#!/bin/bash +echo "cdk $*" diff --git a/cli/src/test/resources/ide-projects/cdk/repository/node/node/default/npm b/cli/src/test/resources/ide-projects/cdk/repository/node/node/default/npm new file mode 100755 index 0000000000..ee633ea32e --- /dev/null +++ b/cli/src/test/resources/ide-projects/cdk/repository/node/node/default/npm @@ -0,0 +1,6 @@ +#!/bin/bash +if [ "$1" == "--version" ]; then + echo "9.9.2" + exit +fi +echo "npm $*" diff --git a/cli/src/test/resources/ide-projects/cdk/repository/node/node/default/npx b/cli/src/test/resources/ide-projects/cdk/repository/node/node/default/npx new file mode 100755 index 0000000000..0723c2041b --- /dev/null +++ b/cli/src/test/resources/ide-projects/cdk/repository/node/node/default/npx @@ -0,0 +1,2 @@ +#!/bin/bash +echo "npx $*" diff --git a/cli/src/test/resources/ide-projects/cdk/repository/npmjs/aws-cdk/cli.json b/cli/src/test/resources/ide-projects/cdk/repository/npmjs/aws-cdk/cli.json new file mode 100644 index 0000000000..2fe0521f3a --- /dev/null +++ b/cli/src/test/resources/ide-projects/cdk/repository/npmjs/aws-cdk/cli.json @@ -0,0 +1,10 @@ +{ + "versions": { + "2.1120.0": { + "version": "2.1120.0", + "dist": { + "tarball": "${testbaseurl}/aws-cdk/-/aws-cdk-2.1120.0.tgz" + } + } + } +} diff --git a/documentation/LICENSE.adoc b/documentation/LICENSE.adoc index c1c5c60664..42e5827070 100644 --- a/documentation/LICENSE.adoc +++ b/documentation/LICENSE.adoc @@ -104,6 +104,7 @@ The column `inclusion` indicates the way the component is included: |https://github.com/openjdk/jfx[OpenJFX] |Optional|https://github.com/openjdk/jfx/blob/master/LICENSE[GPLv2] (with the “Classpath” Exception) |https://squirrel-sql.sourceforge.io/[SQuirreL SQL Client]|Optional|https://github.com/squirrel-sql-client/squirrel-sql-stable-releases/blob/main/LICENSE[LGPL 2.1] |https://docs.nestjs.com/cli/overview[NestJS CLI] |Optional|https://github.com/nestjs/nest-cli/blob/master/LICENSE[MIT License] +|https://docs.aws.amazon.com/cdk/v2/guide/home.html[AWS CDK CLI] |Optional|https://github.com/aws/aws-cdk-cli[Apache 2.0] |=== == Apache Software License - Version 2.0