Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repositories {
}
maven { url 'https://jitpack.io' }
maven {
url 'https://maven.pkg.github.com/RHEcosystemAppEng/crda-java-api'
url 'https://maven.pkg.github.com/RHEcosystemAppEng/exhort-java-api'
credentials {
username = project.findProperty("gpr.username") ?: System.getenv("GITHUB_USERNAME")
password = project.findProperty("gpr.token") ?: System.getenv("GITHUB_TOKEN")
Expand Down Expand Up @@ -60,7 +60,7 @@ dependencies {
}
implementation 'org.kohsuke:github-api:1.314'
implementation 'org.apache.commons:commons-compress:1.21'
implementation 'com.redhat.crda:crda-java-api:0.0.1-SNAPSHOT'
implementation 'com.redhat.exhort:exhort-java-api:0.0.1-SNAPSHOT'
testImplementation('junit:junit:4.13.1')
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.jboss.tools.intellij.crda;
package org.jboss.tools.intellij.exhort;

import com.intellij.openapi.components.Service;
import com.redhat.crda.Api;
import com.redhat.crda.impl.CrdaApi;
import com.redhat.crda.tools.Ecosystem;
import com.redhat.exhort.Api;
import com.redhat.exhort.impl.ExhortApi;
import com.redhat.exhort.tools.Ecosystem;
import org.jboss.tools.intellij.analytics.TelemetryService;

import java.io.IOException;
Expand All @@ -22,14 +22,14 @@ public String toString() {
}
}

private final Api crdaApi;
private final Api exhortApi;

public ApiService() {
this(new CrdaApi());
this(new ExhortApi());
}

ApiService(Api crdaApi) {
this.crdaApi = crdaApi;
ApiService(Api exhortApi) {
this.exhortApi = exhortApi;
}

public Path getStackAnalysis(
Expand All @@ -44,8 +44,8 @@ public Path getStackAnalysis(
telemetryMsg.property(TelemetryKeys.MANIFEST.toString(), manifestName);

try {
var htmlContent = crdaApi.stackAnalysisHtml(manifestPath);
var tmpFile = Files.createTempFile("crda_", ".html");
var htmlContent = exhortApi.stackAnalysisHtml(manifestPath);
var tmpFile = Files.createTempFile("exhort_", ".html");
Files.write(tmpFile, htmlContent.get());

telemetryMsg.send();
Expand Down
23 changes: 19 additions & 4 deletions src/main/java/org/jboss/tools/intellij/stackanalysis/SaAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;

import org.jboss.tools.intellij.crda.ApiService;
import com.redhat.crda.tools.Ecosystem;
import org.jboss.tools.intellij.exhort.ApiService;
import org.jboss.tools.intellij.analytics.Platform;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -52,9 +51,9 @@ public void actionPerformed(@NotNull AnActionEvent event) {

// Get SA report for given manifest file.
String reportLink;
if ("pom.xml".equals(manifestFile.getName())) {
if ("pom.xml".equals(manifestFile.getName()) || "package.json".equals(manifestFile.getName()) ) {
reportLink = apiService.getStackAnalysis(
"maven",
determinePackageManagerName(manifestFile.getName()),
manifestFile.getName(),
manifestFile.getPath()
).toUri().toString();
Expand All @@ -81,6 +80,22 @@ public void actionPerformed(@NotNull AnActionEvent event) {
}
}

private String determinePackageManagerName(String name) {
String packageManager;
switch(name)
{
case "pom.xml":
packageManager = "maven";
break;
case "package.json":
packageManager = "npm";
break;
default:
throw new IllegalArgumentException("package manager not implemented");
}
return packageManager;
}


/**
* <p>Updates the state of the action, Action is show if this method returns true.</p>
Expand Down