summaryrefslogtreecommitdiff
path: root/lib/license/finder/ext
diff options
context:
space:
mode:
Diffstat (limited to 'lib/license/finder/ext')
-rw-r--r--lib/license/finder/ext/bower.rb4
-rw-r--r--lib/license/finder/ext/conan.rb4
-rw-r--r--lib/license/finder/ext/go_dep.rb19
-rw-r--r--lib/license/finder/ext/go_modules.rb8
-rw-r--r--lib/license/finder/ext/npm.rb6
-rw-r--r--lib/license/finder/ext/scanner.rb13
-rw-r--r--lib/license/finder/ext/trash.rb19
-rw-r--r--lib/license/finder/ext/yarn.rb6
8 files changed, 70 insertions, 9 deletions
diff --git a/lib/license/finder/ext/bower.rb b/lib/license/finder/ext/bower.rb
index 52e6a16..2725e2f 100644
--- a/lib/license/finder/ext/bower.rb
+++ b/lib/license/finder/ext/bower.rb
@@ -2,8 +2,8 @@
module LicenseFinder
class Bower
- def possible_package_paths
- [project_path.join('bower.json')]
+ def active?
+ project_path.join('bower.json').exist?
end
def prepare
diff --git a/lib/license/finder/ext/conan.rb b/lib/license/finder/ext/conan.rb
index 90e7d9b..26e45aa 100644
--- a/lib/license/finder/ext/conan.rb
+++ b/lib/license/finder/ext/conan.rb
@@ -2,8 +2,8 @@
module LicenseFinder
class Conan
- def possible_package_paths
- [project_path.join('conanfile.txt')]
+ def active?
+ project_path.join('conanfile.txt').exist?
end
def prepare
diff --git a/lib/license/finder/ext/go_dep.rb b/lib/license/finder/ext/go_dep.rb
new file mode 100644
index 0000000..f2867d3
--- /dev/null
+++ b/lib/license/finder/ext/go_dep.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+module LicenseFinder
+ class GoDep
+ def active?
+ return if project_path.to_path.include?('/vendor/')
+
+ project_path.join('Godeps/Godeps.json').exist?
+ end
+
+ def prepare
+ within_project_path do
+ tool_box.install(tool: :golang)
+ shell.execute([:go, :install, '-i', 'github.com/golang/dep/cmd/dep'], capture: false)
+ shell.execute([:asdf, :reshim], capture: false)
+ end
+ end
+ end
+end
diff --git a/lib/license/finder/ext/go_modules.rb b/lib/license/finder/ext/go_modules.rb
index 8927f2c..8a9ea03 100644
--- a/lib/license/finder/ext/go_modules.rb
+++ b/lib/license/finder/ext/go_modules.rb
@@ -5,6 +5,12 @@ module LicenseFinder
FORMAT = "'{{.Main}},{{.Path}},{{.Version}},{{.Dir}}'"
HEADER = [:main_module, :name, :version, :dir].freeze
+ def active?
+ return if project_path.to_path.include?('/vendor/')
+
+ go_sum_path.exist?
+ end
+
def prepare
return if vendored?
@@ -59,7 +65,7 @@ module LicenseFinder
end
def go_sum_path
- @go_sum_path ||= Pathname.glob(project_path.join('go.sum')).find(&:exist?)
+ @go_sum_path ||= project_path.join('go.sum')
end
def vendor_path
diff --git a/lib/license/finder/ext/npm.rb b/lib/license/finder/ext/npm.rb
index 59244c9..59ae24c 100644
--- a/lib/license/finder/ext/npm.rb
+++ b/lib/license/finder/ext/npm.rb
@@ -2,8 +2,10 @@
module LicenseFinder
class NPM
- def possible_package_paths
- [project_path.join('package.json')]
+ def active?
+ return if project_path.to_path.include?('/node_modules/')
+
+ project_path.join('package.json').exist?
end
def prepare
diff --git a/lib/license/finder/ext/scanner.rb b/lib/license/finder/ext/scanner.rb
new file mode 100644
index 0000000..1c5e4ae
--- /dev/null
+++ b/lib/license/finder/ext/scanner.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+module LicenseFinder
+ class Scanner
+ def active_packages
+ active_package_managers
+ .select { |x| x.installed?(@logger) }
+ .map { |x| Thread.new { x.current_packages_with_relations } }
+ .map(&:value)
+ .flatten
+ end
+ end
+end
diff --git a/lib/license/finder/ext/trash.rb b/lib/license/finder/ext/trash.rb
new file mode 100644
index 0000000..76f16b1
--- /dev/null
+++ b/lib/license/finder/ext/trash.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+module LicenseFinder
+ class Trash
+ def active?
+ return if project_path.to_path.include?('/vendor/')
+
+ project_path.join('vendor.conf').exist?
+ end
+
+ def prepare
+ within_project_path do
+ tool_box.install(tool: :golang)
+ shell.execute([:go, :get, '-u', 'github.com/rancher/trash'], capture: false)
+ shell.execute([:asdf, :reshim], capture: false)
+ end
+ end
+ end
+end
diff --git a/lib/license/finder/ext/yarn.rb b/lib/license/finder/ext/yarn.rb
index 7a18e35..eedf435 100644
--- a/lib/license/finder/ext/yarn.rb
+++ b/lib/license/finder/ext/yarn.rb
@@ -5,8 +5,10 @@ module LicenseFinder
INCOMPATIBLE_PACKAGE_REGEX = /(?<name>[\w,\-]+)@(?<version>(\d+\.?)+)/.freeze
PHANTOM_PACKAGE_REGEX = /workspace-aggregator-[a-zA-Z0-9]{8}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{12}/.freeze
- def possible_package_paths
- [project_path.join('yarn.lock')]
+ def active?
+ return if project_path.to_path.include?('/node_modules/')
+
+ project_path.join('yarn.lock').exist?
end
def prepare