Skip to content

Commit

Permalink
Merge branch 'main' into feature/396-tool-usage-help
Browse files Browse the repository at this point in the history
  • Loading branch information
hohwille authored Jul 5, 2024
2 parents 871546f + 623ef90 commit 001858c
Show file tree
Hide file tree
Showing 74 changed files with 1,291 additions and 112 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@
*.tar binary
*.bz2 binary
*.gz binary

# special handling for test files
studio64.exe text
24 changes: 24 additions & 0 deletions .github/workflows/nightly-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,27 @@ jobs:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
run: mvn --settings .mvn/settings.xml -DskipTests=true -Darchetype.test.skip=true -Dmaven.install.skip=true -Dgpg.skip=true -Dstyle.color=always -B -ntp -P deploy deploy

check_status:
runs-on: ubuntu-latest
needs: verify_commit
if: ${{ needs.verify_commit.outputs.RUN_BUILD == 'false' }}
steps:
- name: Check last workflow status
id: check_status
run: |
workflow_filename="nightly-build.yml"
last_workflow=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/actions/workflows/$workflow_filename/runs?per_page=1" | jq -r '.workflow_runs[0]')
conclusion=$(echo $last_workflow | jq -r '.conclusion')
echo "conclusion=$conclusion" >> $GITHUB_ENV
- name: Print and handle the status
run: |
echo "The status of the last workflow run is: ${{ env.conclusion }}"
if [ "${{ env.conclusion }}" != "success" ]; then
echo "The last workflow did not succeed. Failing this workflow."
exit 1
else
echo "The last workflow succeeded. This workflow will succeed."
fi
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*.bak
.*
!.gitignore
!.gitkeep
!.ide.software.version
!.devon.software.version
!.ide
Expand All @@ -15,6 +16,7 @@
target/
eclipse-target/
generated/
node_modules

# Package Files #
*.jar
Expand Down
2 changes: 1 addition & 1 deletion .mvn/maven.config
Original file line number Diff line number Diff line change
@@ -1 +1 @@
-Drevision=2024.06.002-alpha-SNAPSHOT
-Drevision=2024.07.001-alpha-SNAPSHOT
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package com.devonfw.tools.ide.commandlet;

import com.devonfw.tools.ide.cli.CliException;
import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.property.StringProperty;
import com.devonfw.tools.ide.tool.ToolCommandlet;
import com.devonfw.tools.ide.tool.gradle.Gradle;
import com.devonfw.tools.ide.tool.mvn.Mvn;
import com.devonfw.tools.ide.tool.npm.Npm;

import java.nio.file.Files;
import java.nio.file.Path;

import static com.devonfw.tools.ide.variable.IdeVariables.GRADLE_BUILD_OPTS;
import static com.devonfw.tools.ide.variable.IdeVariables.MVN_BUILD_OPTS;
import static com.devonfw.tools.ide.variable.IdeVariables.NPM_BUILD_OPTS;

/**
* Build tool {@link Commandlet} for automatically detecting build configuration files and running the respective tool.
*/
public class BuildCommandlet extends Commandlet {

/**
* The arguments to build with.
*/
public StringProperty arguments;

/**
* The constructor.
*
* @param context the {@link IdeContext}.
*/
public BuildCommandlet(IdeContext context) {

super(context);
addKeyword(getName());
this.arguments = add(new StringProperty("", false, true, "args"));
}

@Override
public String getName() {

return "build";
}

@Override
public void run() {

Path buildPath = this.context.getCwd();
String[] defaultToolOptions = new String[0];

if (buildPath == null) {
throw new CliException("Missing current working directory!");
}

ToolCommandlet commandlet = null;
if (Files.exists(buildPath.resolve("pom.xml"))) {
commandlet = this.context.getCommandletManager().getCommandlet(Mvn.class);
defaultToolOptions = getDefaultToolOptions(MVN_BUILD_OPTS.getName());
} else if (Files.exists(buildPath.resolve("build.gradle"))) {
commandlet = this.context.getCommandletManager().getCommandlet(Gradle.class);
defaultToolOptions = getDefaultToolOptions(GRADLE_BUILD_OPTS.getName());
} else if (Files.exists(buildPath.resolve("package.json"))) {
if (Files.exists(buildPath.resolve("yarn.lock"))) {
// TODO: add yarn here
} else {
commandlet = this.context.getCommandletManager().getCommandlet(Npm.class);

defaultToolOptions = getDefaultToolOptions(NPM_BUILD_OPTS.getName());
}
} else {
throw new CliException("Could not find build descriptor - no pom.xml, build.gradle, or package.json found!");
}

if (this.arguments.asArray().length != 0) {
defaultToolOptions = this.arguments.asArray();
}

if (commandlet != null) {
commandlet.runTool(null, defaultToolOptions);
}

}

private String[] getDefaultToolOptions(String buildOptionName) {

String[] defaultToolOptions;
defaultToolOptions = this.context.getVariables().get(buildOptionName).split(" ");
return defaultToolOptions;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.devonfw.tools.ide.tool.jmc.Jmc;
import com.devonfw.tools.ide.tool.kotlinc.Kotlinc;
import com.devonfw.tools.ide.tool.kotlinc.KotlincNative;
import com.devonfw.tools.ide.tool.lazydocker.LazyDocker;
import com.devonfw.tools.ide.tool.mvn.Mvn;
import com.devonfw.tools.ide.tool.node.Node;
import com.devonfw.tools.ide.tool.npm.Npm;
Expand All @@ -28,6 +29,7 @@
import com.devonfw.tools.ide.tool.quarkus.Quarkus;
import com.devonfw.tools.ide.tool.sonar.Sonar;
import com.devonfw.tools.ide.tool.terraform.Terraform;
import com.devonfw.tools.ide.tool.tomcat.Tomcat;
import com.devonfw.tools.ide.tool.vscode.Vscode;

import java.util.Collection;
Expand Down Expand Up @@ -77,6 +79,7 @@ public CommandletManagerImpl(IdeContext context) {
add(new UninstallCommandlet(context));
add(new UpdateCommandlet(context));
add(new CreateCommandlet(context));
add(new BuildCommandlet(context));
add(new Gh(context));
add(new Helm(context));
add(new Java(context));
Expand All @@ -91,6 +94,7 @@ public CommandletManagerImpl(IdeContext context) {
add(new Quarkus(context));
add(new Kotlinc(context));
add(new KotlincNative(context));
add(new Tomcat(context));
add(new Vscode(context));
add(new Azure(context));
add(new Aws(context));
Expand All @@ -103,6 +107,7 @@ public CommandletManagerImpl(IdeContext context) {
add(new Sonar(context));
add(new GraalVm(context));
add(new PgAdmin(context));
add(new LazyDocker(context));
}

private void add(Commandlet commandlet) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.devonfw.tools.ide.completion;

import java.util.Arrays;
import java.util.List;

import com.devonfw.tools.ide.commandlet.Commandlet;
import com.devonfw.tools.ide.property.Property;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
* Collects the {@link CompletionCandidate}s for auto-completion.
*/
Expand Down Expand Up @@ -50,25 +51,15 @@ default int addAllMatches(String text, String[] sortedCandidates, Property<?> pr
}
return sortedCandidates.length;
}
int count = 0;
int index = Arrays.binarySearch(sortedCandidates, text);
if (index >= 0) {
add(sortedCandidates[index], "", property, commandlet);
index++;
count++;
} else {
index = -index - 1;
}
while ((index >= 0) && (index < sortedCandidates.length)) {
if (sortedCandidates[index].startsWith(text)) {
add(sortedCandidates[index], "", property, commandlet);
count++;
} else {
break;
}
index++;

List<String> prefixWords = Arrays.asList(sortedCandidates).stream().filter(word -> word.startsWith(text))
.collect(Collectors.toList());

for (String match : prefixWords) {
add(match, "", property, commandlet);
}
return count;

return prefixWords.size();
}

/**
Expand Down
Loading

0 comments on commit 001858c

Please sign in to comment.