Skip to content
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.

Commit

Permalink
ruby: add local gem vendor folder to avoid perm issues
Browse files Browse the repository at this point in the history
maven: fix the maven test case
tests: fix all cases

Signed-off-by: mcoops <[email protected]>
  • Loading branch information
mcoops committed Aug 25, 2021
1 parent 65ca764 commit 9c11369
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 56 deletions.
147 changes: 94 additions & 53 deletions deplist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,73 +38,122 @@ func BuildWant() []Dependency {
"internal/testlog",
"os",
"fmt",
"path",
"io/fs",
"internal/unsafeheader",
"github.com/openshift/api/config/v1",
"golang.org/x/text/unicode",
"github.com/mcoops/deplist",
}

npmSet1 := []string{
"angular",
"d3",
"d3-array",
"d3-axis",
"loose-envify",
"iconv-lite",
"d3-brush",
"d3-polygon",
"d3-zoom",
"d3-path",
"d3-chord",
"d3-color",
"d3-contour",
"d3-delaunay",
"delaunator",
"d3-dispatch",
"d3-drag",
"d3-dsv",
"commander",
"iconv-lite",
}

npmSet2 := []string{
"safer-buffer",
"rw",
"d3-ease",
"d3-fetch",
"d3-force",
"d3-format",
"d3-geo",
"object-assign",
"rw",
"d3-scale-chromatic",
"d3-brush",
"d3-hierarchy",
"d3-interpolate",
"d3-path",
"d3-polygon",
"d3-quadtree",
"d3-random",
"commander",
"d3-time",
"d3-time-format",
"d3-dsv",
"d3-scale",
"is-plain-object",
"d3-quadtree",
"tiny-warning",
"d3-hierarchy",
"d3-dsv",
"d3-timer",
"d3-scale-chromatic",
"d3-selection",
"d3-shape",
"d3-time",
"d3-time-format",
"d3-array",
"d3-axis",
"d3-timer",
"d3-transition",
"d3-zoom",
"d3-ease",
"d3-color",
"prismjs",
"clipboard",
"good-listener",
"delegate",
"select",
"tiny-emitter",
"react",
"loose-envify",
"d3-force",
"iconv-lite",
"angular",
"d3-delaunay",
"rxjs",
"d3-zoom",
"d3-scale",
"d3-interpolate",
"d3-path",
"d3-array",
"d3-time",
"js-tokens",
"object-assign",
"prop-types",
"d3-format",
"safer-buffer",
"d3-contour",
"d3-geo",
"safer-buffer",
"react-is",
"rxjs",
"d3-format",
"d3-interpolate",
"d3-dispatch",
"d3-force",
"d3-color",
"d3-transition",
"prop-types",
"tiny-emitter",
"d3-polygon",
"d3-chord",
"d3-fetch",
"d3-dispatch",
"d3-contour",
"tslib",
"good-listener",
"d3",
"d3-axis",
"d3-ease",
"delegate",
"d3-drag",
"delaunator",
"commander",
"d3-color",
"delaunator",
"d3-timer",
"d3-drag",
"d3-geo",
"slate",
"@types/esrever",
"d3-interpolate",
"d3-random",
"select",
"esrever",
"d3-transition",
"clipboard",
"d3-dispatch",
"d3-format",
"d3-path",
"d3-array",
"d3-random",
"d3-fetch",
"d3-quadtree",
"d3-shape",
"d3-delaunay",
"d3-time",
"d3-shape",
"immer",
"is-plain-object",
"tiny-warning",
"@types/esrever",
"d3-time-format",
"d3-selection",
"d3-quadtree",
"d3-selection",
"react",
"tether",
"d3-interpolate",
"d3-dsv",
"d3-array",
}

rubySet := []string{
Expand Down Expand Up @@ -209,15 +258,7 @@ func BuildWant() []Dependency {
}
deps = append(deps, d)
}
deps = append(deps, Dependency{DepType: 2, Path: "com.amazonaws:aws-lambda-java-core"}) // java

for _, n := range npmSet2 {
d := Dependency{
DepType: 3,
Path: n,
}
deps = append(deps, d)
}
deps = append(deps, Dependency{DepType: 2, Path: "com.amazonaws:aws-lambda-java-core:jar", Version: "1.0.0"}) // java

for _, n := range rubySet {
d := Dependency{
Expand Down
15 changes: 14 additions & 1 deletion internal/scan/ruby.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package scan

import (
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"strings"
Expand All @@ -11,17 +13,28 @@ func GetRubyDeps(path string) (map[string]string, error) {

dirPath := filepath.Dir(path)

// override the gem path otherwise might hit perm issues and it's annoying
gem_path, err := ioutil.TempDir("", "gem_vendor")
if err != nil {
return nil, err
}

// cleanup after ourselves
defer os.RemoveAll(gem_path)

//Make sure that the Gemfile we are loading is supported by the version of bundle currently installed.
cmd := exec.Command("bundle", "update", "--bundler")
cmd.Dir = dirPath
_, err := cmd.Output()
cmd.Env = append(cmd.Env, "GEM_HOME="+gem_path)
_, err = cmd.Output()
if err != nil {
return nil, err
}

cmd = exec.Command("bundle", "list")

cmd.Dir = dirPath
cmd.Env = append(cmd.Env, "GEM_HOME="+gem_path)

data, err := cmd.Output()

Expand Down
23 changes: 21 additions & 2 deletions test/testRepo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<maven-dependency-plugin.version>3.0.2</maven-dependency-plugin.version>
</properties>

<dependencies>
Expand All @@ -35,6 +34,26 @@
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>${maven-dependency-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>${maven-enforcer-plugin.version}</version>
<configuration>
<rules>
<requireMavenVersion>
<version>[3.0.2,)</version>
</requireMavenVersion>
<requireJavaVersion>
<version>[1.8,)</version>
</requireJavaVersion>
</rules>
</configuration>
</plugin>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
Expand Down

0 comments on commit 9c11369

Please sign in to comment.