license_finder 2.1.0.rc6 → 2.1.0.rc7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.rdoc +6 -0
- data/Rakefile +3 -24
- data/lib/license_finder/logger.rb +27 -1
- data/lib/license_finder/package_manager.rb +31 -2
- data/lib/license_finder/package_managers/bower.rb +4 -0
- data/lib/license_finder/package_managers/bundler.rb +4 -0
- data/lib/license_finder/package_managers/cocoa_pods.rb +4 -0
- data/lib/license_finder/package_managers/go_dep.rb +4 -0
- data/lib/license_finder/package_managers/go_vendor.rb +9 -1
- data/lib/license_finder/package_managers/go_workspace.rb +6 -3
- data/lib/license_finder/package_managers/gradle.rb +4 -0
- data/lib/license_finder/package_managers/maven.rb +4 -0
- data/lib/license_finder/package_managers/npm.rb +4 -0
- data/lib/license_finder/package_managers/pip.rb +4 -0
- data/lib/license_finder/package_managers/rebar.rb +4 -0
- data/lib/license_finder/version.rb +1 -1
- data/license_finder.gemspec +1 -0
- data/spec/fixtures/all_pms/.envrc +1 -0
- data/spec/fixtures/all_pms/vendor/.gitkeep +0 -0
- data/spec/fixtures/npm-recursive-dependencies/npm-list.json +5158 -0
- data/spec/fixtures/npm-recursive-dependencies/package.json +15 -0
- data/spec/lib/license_finder/package_manager_spec.rb +40 -0
- data/spec/lib/license_finder/package_managers/go_vendor_spec.rb +16 -2
- data/spec/lib/license_finder/package_managers/go_workspace_spec.rb +13 -0
- data/spec/support/shared_examples_for_package_manager.rb +28 -5
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de54a1c1786084407496fd2eb1731686dd81538e
|
4
|
+
data.tar.gz: 762d170826532bff157f863df8e9c6f3afd33f06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32cb267d5a41b650a52c054ff96858ac5fe3810fc1946dcb65f3810c041f9cc71f5edaa2bfd179ae08e86e89ecb31de76fbc50a7b7693c903f41bb5cd1a8ea5b
|
7
|
+
data.tar.gz: db7599addf26235034a50946e1bf5e59010a312fb11f45607cf59e35ac6df65d89b03fd18fbe9651112b09f657a526b4dcbb41dad7306f57ff0f61fa2593e8b8
|
data/CHANGELOG.rdoc
CHANGED
data/Rakefile
CHANGED
@@ -26,31 +26,10 @@ end
|
|
26
26
|
|
27
27
|
desc "Check for non-Ruby development dependencies."
|
28
28
|
task :check_dependencies do
|
29
|
-
|
30
|
-
"mvn" => "Maven",
|
31
|
-
"npm" => "NPM",
|
32
|
-
"pip" => "Pip",
|
33
|
-
"gradle" => "Gradle",
|
34
|
-
"bower" => "Bower",
|
35
|
-
"rebar" => "Rebar",
|
36
|
-
"godep" => "Go"
|
37
|
-
}
|
38
|
-
dependencies["pod"] = "Cocoapods" if LicenseFinder::Platform.darwin?
|
29
|
+
require './lib/license_finder'
|
39
30
|
satisfied = true
|
40
|
-
|
41
|
-
|
42
|
-
if LicenseFinder::Platform.windows?
|
43
|
-
`where #{dependency} 2>NUL`
|
44
|
-
else
|
45
|
-
`which #{dependency} 2>/dev/null`
|
46
|
-
end
|
47
|
-
status = $?
|
48
|
-
if status.success?
|
49
|
-
puts "OK"
|
50
|
-
else
|
51
|
-
puts "missing `#{dependency}`"
|
52
|
-
satisfied = false
|
53
|
-
end
|
31
|
+
LicenseFinder::PackageManager.package_managers.each do |package_manager|
|
32
|
+
satisfied = false unless package_manager.installed?(LicenseFinder::Logger.new(debug:true))
|
54
33
|
end
|
55
34
|
exit 1 unless satisfied
|
56
35
|
end
|
@@ -12,8 +12,22 @@ module LicenseFinder
|
|
12
12
|
end
|
13
13
|
|
14
14
|
class Base
|
15
|
+
def installed package_manager, is_installed
|
16
|
+
if String === is_installed
|
17
|
+
log package_manager, is_installed
|
18
|
+
elsif is_installed
|
19
|
+
log package_manager, Logger.green("is installed")
|
20
|
+
else
|
21
|
+
log package_manager, Logger.red("is not installed")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
15
25
|
def active package_manager, is_active
|
16
|
-
|
26
|
+
if is_active
|
27
|
+
log package_manager, Logger.green("is active")
|
28
|
+
else
|
29
|
+
log package_manager, "is not active"
|
30
|
+
end
|
17
31
|
end
|
18
32
|
|
19
33
|
def package package_manager, package
|
@@ -44,6 +58,18 @@ module LicenseFinder
|
|
44
58
|
end
|
45
59
|
end
|
46
60
|
|
61
|
+
def self.green string
|
62
|
+
colorize 32, string
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.red string
|
66
|
+
colorize 31, string
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.colorize color_code, string
|
70
|
+
"\e[#{color_code}m#{string}\e[0m"
|
71
|
+
end
|
72
|
+
|
47
73
|
class Quiet < Base
|
48
74
|
def log prefix, string
|
49
75
|
end
|
@@ -23,14 +23,33 @@ module LicenseFinder
|
|
23
23
|
active_package_managers.flat_map(&:current_packages_with_relations)
|
24
24
|
end
|
25
25
|
|
26
|
+
def self.installed?(logger=Core.default_logger)
|
27
|
+
if package_management_command.nil?
|
28
|
+
logger.installed self, "no command defined" # TODO comment me out
|
29
|
+
return true
|
30
|
+
end
|
31
|
+
|
32
|
+
if command_exists?(package_management_command)
|
33
|
+
logger.installed self, true
|
34
|
+
return true
|
35
|
+
end
|
36
|
+
|
37
|
+
logger.installed self, false
|
38
|
+
return false
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.package_management_command
|
42
|
+
nil
|
43
|
+
end
|
44
|
+
|
26
45
|
def initialize options={}
|
27
46
|
@logger = options[:logger] || Core.default_logger
|
28
47
|
@project_path = options[:project_path]
|
29
48
|
end
|
30
49
|
|
31
50
|
def active?
|
32
|
-
|
33
|
-
.tap { |is_active| logger.active self.class, is_active }
|
51
|
+
self.class.installed?(logger) &&
|
52
|
+
package_path.exist?.tap { |is_active| logger.active self.class, is_active }
|
34
53
|
end
|
35
54
|
|
36
55
|
def capture(command)
|
@@ -48,6 +67,16 @@ module LicenseFinder
|
|
48
67
|
packages
|
49
68
|
end
|
50
69
|
|
70
|
+
def self.command_exists? command
|
71
|
+
if LicenseFinder::Platform.windows?
|
72
|
+
`where #{command} 2>NUL`
|
73
|
+
else
|
74
|
+
`which #{command} 2>/dev/null`
|
75
|
+
end
|
76
|
+
status = $?
|
77
|
+
return status.success?
|
78
|
+
end
|
79
|
+
|
51
80
|
private
|
52
81
|
|
53
82
|
attr_reader :logger, :project_path
|
@@ -9,7 +9,15 @@ module LicenseFinder
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def active?
|
12
|
-
|
12
|
+
return false unless self.class.installed?(@logger)
|
13
|
+
|
14
|
+
(has_go_files? && package_path.exist?).tap do |is_active|
|
15
|
+
logger.active self.class, is_active
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def has_go_files?
|
20
|
+
!Dir[project_path.join("**/*.go")].empty?
|
13
21
|
end
|
14
22
|
|
15
23
|
def package_path
|
@@ -31,9 +31,12 @@ module LicenseFinder
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def active?
|
34
|
-
|
35
|
-
|
36
|
-
|
34
|
+
return false unless self.class.installed?(logger)
|
35
|
+
|
36
|
+
godep = LicenseFinder::GoDep.new({project_path: Pathname(project_path)})
|
37
|
+
# go workspace is only active if GoDep wasn't. There are some projects
|
38
|
+
# that will use the .envrc and have a Godep folder as well.
|
39
|
+
active = !! (!godep.active? && envrc_path && ENVRC_REGEXP.match(IO.read(envrc_path)))
|
37
40
|
active.tap { |is_active| logger.active self.class, is_active }
|
38
41
|
end
|
39
42
|
|
data/license_finder.gemspec
CHANGED
@@ -42,6 +42,7 @@ Gem::Specification.new do |s|
|
|
42
42
|
s.add_dependency "thor"
|
43
43
|
s.add_dependency "httparty"
|
44
44
|
s.add_dependency "xml-simple"
|
45
|
+
s.add_dependency "colorize"
|
45
46
|
|
46
47
|
s.add_development_dependency "capybara", "~> 2.0.0"
|
47
48
|
s.add_development_dependency "cocoapods", "0.34.0" if LicenseFinder::Platform.darwin?
|
@@ -0,0 +1 @@
|
|
1
|
+
GOPATH=$PWD
|
File without changes
|