Skip to content

Commit

Permalink
Merge branch 'main' into implement/windows-installer
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-vcapgemini authored Dec 4, 2024
2 parents e77f25b + e849467 commit e635322
Show file tree
Hide file tree
Showing 68 changed files with 1,865 additions and 1,241 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nightly-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
shell: bash
run: |
cd cli
mvn -B -ntp -Pnative -DskipTests=true compile
mvn -B -ntp -Pnative -DskipTests=true package
- name: Upload native image
uses: actions/upload-artifact@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
current_version="${current_version/ */}"
next_version="${current_version/-SNAPSHOT/}"
cd cli
mvn -B -ntp -Drevision=${next_version} -Pnative -DskipTests=true compile
mvn -B -ntp -Drevision=${next_version} -Pnative -DskipTests=true package
- name: Upload native image
uses: actions/upload-artifact@v4
with:
Expand Down
17 changes: 16 additions & 1 deletion CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,28 @@ This file documents all notable changes to https://github.com/devonfw/IDEasy[IDE

== 2024.12.001

NOTE: ATTENTION: When installing this release as an update, you need to manually remove IDEasy entries from `.bashrc` and if present also `.zshrc`.
Also you should delete all files from your `$IDE_ROOT/_ide` folder before extracting the new version to it.
Then run the `setup` and all should work fine.

Release with new features and bugfixes:

* https://github.com/devonfw/IDEasy/issues/774[#774]: HTTP proxy support not working properly
* https://github.com/devonfw/IDEasy/issues/792[#792]: Honor new variable IDE_OPTIONS in ide command wrapper
* https://github.com/devonfw/IDEasy/issues/589[#589]: Fix NLS Bundles for Linux and MacOS
* https://github.com/devonfw/IDEasy/issues/778[#778]: Add icd command
* https://github.com/devonfw/IDEasy/issues/587[#587]: Checks for git installation before performing git operations
* https://github.com/devonfw/IDEasy/issues/779[#779]: Consider functions instead of alias
* https://github.com/devonfw/IDEasy/issues/810[#810]: setup not adding IDEasy to current shell
* https://github.com/devonfw/IDEasy/issues/782[#782]: Fix IDE_ROOT variable on Linux
* https://github.com/devonfw/IDEasy/issues/637[#637]: Added option to disable updates
* https://github.com/devonfw/IDEasy/issues/764[#764]: IDEasy not working properly in CMD
* https://github.com/devonfw/IDEasy/issues/81[#81]: Implement Toolcommandlet for Kubernetes
* https://github.com/devonfw/IDEasy/issues/737[#737]: Adds cd command to ide shell
* https://github.com/devonfw/IDEasy/issues/758[#758]: Create status commandlet
* https://github.com/devonfw/IDEasy/issues/824[#824]: ide create «settings-url»#«branch» not working
* https://github.com/devonfw/IDEasy/issues/754[#754]: Again messages break processable command output
* https://github.com/devonfw/IDEasy/issues/737[#739]: Improved error handling to show 'You are not inside an IDE installation' only when relevant.

The full list of changes for this release can be found in https://github.com/devonfw/IDEasy/milestone/16?closed=1[milestone 2024.12.001].

Expand All @@ -22,7 +36,8 @@ Release with new features and bugfixes:
* https://github.com/devonfw/IDEasy/issues/632[#632]: Add .editorconfig to settings workspaces
* https://github.com/devonfw/IDEasy/issues/415[#415]: Added a message that will inform the user for what process he will need to enter his sudo-password
* https://github.com/devonfw/IDEasy/issues/708[#708]: Open vscode in workspace path
* https://github.com/devonfw/IDEasy/issues/608[#608]: Enhanced error messages. Now logs missing command output and error messages
* https://github.com/devonfw/IDEasy/issues/608[#608]: Enhanced error messages.
Now logs missing command output and error messages
* https://github.com/devonfw/IDEasy/issues/715[#715]: Show "cygwin is not supported" message for cygwin users
* https://github.com/devonfw/IDEasy/issues/745[#745]: Maven install fails with NPE

Expand Down
26 changes: 18 additions & 8 deletions cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,6 @@
<version>1.5.3</version>
<!--optional>true</optional-->
</dependency>
<!-- Needed for WireMock test support -->
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8</artifactId>
<version>2.35.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>me.tongfei</groupId>
<artifactId>progressbar</artifactId>
Expand All @@ -90,6 +83,21 @@
<artifactId>jansi</artifactId>
<version>${jansi.version}</version>
</dependency>
<!-- Test dependencies -->
<!-- Mockito for mocking -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.10.0</version>
<scope>test</scope>
</dependency>
<!-- Needed for WireMock test support -->
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8</artifactId>
<version>2.35.1</version>
<scope>test</scope>
</dependency>
<dependency>
<!-- required for advanced mocking -->
<groupId>net.bytebuddy</groupId>
Expand All @@ -102,11 +110,13 @@
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-core</artifactId>
<version>2.10.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-assertj3</artifactId>
<version>2.9.1</version>
<scope>test</scope>
</dependency>
</dependencies>

Expand Down Expand Up @@ -216,7 +226,7 @@
<goals>
<goal>compile-no-fork</goal>
</goals>
<phase>compile</phase>
<phase>package</phase>
</execution>
<execution>
<id>test-native</id>
Expand Down
6 changes: 4 additions & 2 deletions cli/src/main/java/com/devonfw/tools/ide/cli/CliException.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.devonfw.tools.ide.cli;

import com.devonfw.tools.ide.process.ProcessResult;

/**
* {@link RuntimeException} for to abort CLI process in expected situations. It allows to abort with a defined message for the end user and a defined exit code.
* Unlike other exceptions a {@link CliException} is not treated as technical error. Therefore by default (unless in debug mode) no stacktrace is printed.
Expand Down Expand Up @@ -37,8 +39,7 @@ public CliException(String message, Throwable cause) {
*/
public CliException(String message, int exitCode) {

super(message);
this.exitCode = exitCode;
this(message, exitCode, null);
}

/**
Expand All @@ -51,6 +52,7 @@ public CliException(String message, int exitCode) {
public CliException(String message, int exitCode, Throwable cause) {

super(message, cause);
assert (exitCode != ProcessResult.SUCCESS);
this.exitCode = exitCode;
}

Expand Down
17 changes: 17 additions & 0 deletions cli/src/main/java/com/devonfw/tools/ide/cli/CliExitException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.devonfw.tools.ide.cli;

import com.devonfw.tools.ide.process.ProcessResult;

/**
* {@link CliException} Empty exception that is thrown when a required variable is not set.
*/
public class CliExitException extends CliException {

/**
* The constructor.
*/
public CliExitException() {

super("", ProcessResult.EXIT);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.devonfw.tools.ide.cli;

import java.net.URL;
import java.nio.file.Path;

import com.devonfw.tools.ide.process.ProcessResult;
Expand Down Expand Up @@ -67,7 +66,7 @@ public static CliOfflineException ofPurpose(String purpose) {
* @param repository the path, where the repository should be cloned to.
* @return A {@link CliOfflineException} with an informative message.
*/
public static CliOfflineException ofClone(URL url, Path repository) {
public static CliOfflineException ofClone(String url, Path repository) {
return new CliOfflineException("Could not clone " + url + " to " + repository + " because you are offline.");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ public final class CliProcessException extends CliException {

/**
* The constructor.
*
* @param processResult the {@link #getProcessResult() process result}.
*/
public CliProcessException(ProcessResult processResult) {

this("Command " + processResult.getExecutable() + " failed with exit code " + processResult.getExitCode() + " - full commandline was "
+ processResult.getCommand(), processResult);
}

/**
* The constructor.
*
* @param processResult the {@link #getProcessResult() process result}.
*/
public CliProcessException(String message, ProcessResult processResult) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
import java.util.Set;

import com.devonfw.tools.ide.context.AbstractIdeContext;
import com.devonfw.tools.ide.context.GitContext;
import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.git.GitContext;
import com.devonfw.tools.ide.git.GitUrl;
import com.devonfw.tools.ide.property.FlagProperty;
import com.devonfw.tools.ide.property.StringProperty;
import com.devonfw.tools.ide.repo.CustomTool;
Expand Down Expand Up @@ -129,7 +130,7 @@ private void updateSettings() {
} else if ("-".equals(repository)) {
repository = IdeContext.DEFAULT_SETTINGS_REPO_URL;
}
gitContext.pullOrClone(repository, settingsPath);
gitContext.pullOrClone(GitUrl.of(repository), settingsPath);
}
step.success("Successfully updated settings repository.");
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.Map;
import java.util.stream.Collectors;

import com.devonfw.tools.ide.cli.CliExitException;
import com.devonfw.tools.ide.context.AbstractIdeContext;
import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.environment.EnvironmentVariablesType;
Expand Down Expand Up @@ -42,7 +43,7 @@ public String getName() {
@Override
public boolean isIdeHomeRequired() {

return true;
return false;
}

@Override
Expand All @@ -53,7 +54,9 @@ public boolean isProcessableOutput() {

@Override
public void run() {

if (context.getIdeHome() == null) {
throw new CliExitException();
}
boolean winCmd = false;
WindowsPathSyntax pathSyntax = null;
IdeSubLogger logger = this.context.level(IdeLogLevel.PROCESSABLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private void doImportRepository(Path repositoryFile, boolean forceMode) {

String repository = repositoryConfig.path();
String gitUrl = repositoryConfig.gitUrl();
if (repository == null || "".equals(repository) || gitUrl == null || "".equals(gitUrl)) {
if (repository == null || repository.isEmpty() || gitUrl == null || gitUrl.isEmpty()) {
this.context.warning("Invalid repository configuration {} - both 'path' and 'git-url' have to be defined.", repositoryFile.getFileName().toString());
return;
}
Expand All @@ -95,7 +95,7 @@ private void doImportRepository(Path repositoryFile, boolean forceMode) {
this.context.getFileAccess().mkdirs(workspacePath);

Path repositoryPath = workspacePath.resolve(repository);
this.context.getGitContext().pullOrClone(gitUrl, repositoryPath, repositoryConfig.gitBranch());
this.context.getGitContext().pullOrClone(repositoryConfig.asGitUrl(), repositoryPath);

String buildCmd = repositoryConfig.buildCmd();
this.context.debug("Building repository with ide command: {}", buildCmd);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import java.util.Properties;
import java.util.Set;

import com.devonfw.tools.ide.git.GitUrl;

/**
* Represents the configuration of a repository to be used by the {@link RepositoryCommandlet}.
*
Expand All @@ -32,6 +34,18 @@ public record RepositoryConfig(
Set<String> imports,
boolean active) {

/**
* @return the {@link GitUrl} from {@link #gitUrl()} and {@link #gitBranch()}.
*/
public GitUrl asGitUrl() {

return new GitUrl(this.gitUrl, this.gitBranch);
}

/**
* @param filePath the {@link Path} to the {@link Properties} to load.
* @return the parsed {@link RepositoryConfig}.
*/
public static RepositoryConfig loadProperties(Path filePath) {

Properties properties = new Properties();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.devonfw.tools.ide.commandlet;

import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Iterator;

import org.fusesource.jansi.AnsiConsole;
Expand Down Expand Up @@ -79,13 +81,13 @@ public void run() {

// TODO: implement TailTipWidgets, see: https://github.com/devonfw/IDEasy/issues/169

String prompt = "ide> ";
String rightPrompt = null;
String line;

AnsiConsole.systemInstall();
while (true) {
try {
String prompt = context.getCwd() + "$ ide ";
line = reader.readLine(prompt, rightPrompt, (MaskingCallback) null, null);
line = line.trim();
if (line.equals("exit")) {
Expand Down Expand Up @@ -129,9 +131,37 @@ private int runCommand(String args) {
String[] arguments = args.split(" ", 0);
CliArguments cliArgs = new CliArguments(arguments);
cliArgs.next();

if ("cd".equals(arguments[0])) {
return changeDirectory(cliArgs);
}

return ((AbstractIdeContext) this.context).run(cliArgs);
}

private int changeDirectory(CliArguments cliArgs) {
if (!cliArgs.hasNext()) {
Path homeDir = this.context.getUserHome();
context.setCwd(homeDir, context.getWorkspaceName(), context.getIdeHome());
return 0;
}

String targetDir = String.valueOf(cliArgs.next());
Path path = Paths.get(targetDir);

// If the given path is relative, resolve it relative to the current directory
if (!path.isAbsolute()) {
path = context.getCwd().resolve(targetDir).normalize();
}

if (context.getFileAccess().isExpectedFolder(path)) {
context.setCwd(path, context.getWorkspaceName(), context.getIdeHome());
return 0;
} else {
return 1;
}
}

/**
* @param argument the current {@link CliArgument} (position) to match.
* @param commandlet the potential {@link Commandlet} to match.
Expand Down
Loading

0 comments on commit e635322

Please sign in to comment.