license_finder 3.0.4 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +56 -0
- data/CHANGELOG.md +29 -2
- data/CONTRIBUTING.md +5 -1
- data/Dockerfile +33 -10
- data/Gemfile +2 -2
- data/README.md +27 -5
- data/Rakefile +15 -21
- data/ci/pipelines/pipeline.yml.erb +40 -6
- data/ci/pipelines/release.yml +11 -5
- data/ci/scripts/containerize-tests.sh +16 -0
- data/ci/scripts/run-rubocop.sh +8 -0
- data/ci/scripts/run-tests.sh +22 -0
- data/ci/scripts/test.ps1 +81 -0
- data/ci/tasks/build-windows.yml +6 -0
- data/ci/tasks/build.yml +2 -2
- data/ci/tasks/rubocop.yml +13 -0
- data/features/features/cli/cli_spec.rb +8 -8
- data/features/features/configure/add_dependencies_spec.rb +7 -7
- data/features/features/configure/approve_dependencies_spec.rb +15 -15
- data/features/features/configure/assign_licenses_spec.rb +4 -4
- data/features/features/configure/blacklist_licenses_spec.rb +3 -3
- data/features/features/configure/ignore_dependencies_spec.rb +3 -3
- data/features/features/configure/ignore_groups_spec.rb +4 -4
- data/features/features/configure/name_project_spec.rb +4 -4
- data/features/features/configure/set_project_path_spec.rb +2 -2
- data/features/features/configure/whitelist_licenses_spec.rb +4 -4
- data/features/features/package_managers/bower_spec.rb +3 -3
- data/features/features/package_managers/carthage_spec.rb +14 -0
- data/features/features/package_managers/cocoapods_spec.rb +3 -3
- data/features/features/package_managers/conan_spec.rb +11 -0
- data/features/features/package_managers/dep_spec.rb +15 -0
- data/features/features/package_managers/glide_spec.rb +14 -0
- data/features/features/package_managers/govendor_spec.rb +15 -0
- data/features/features/package_managers/gradle_spec.rb +1 -1
- data/features/features/package_managers/gvt_spec.rb +14 -0
- data/features/features/package_managers/maven_spec.rb +2 -3
- data/features/features/package_managers/mix_spec.rb +16 -0
- data/features/features/package_managers/npm_spec.rb +3 -3
- data/features/features/package_managers/nuget_spec.rb +4 -4
- data/features/features/package_managers/pip_spec.rb +2 -2
- data/features/features/package_managers/rebar_spec.rb +3 -3
- data/features/features/package_managers/yarn_spec.rb +14 -0
- data/features/features/report/composite_spec.rb +1 -1
- data/features/features/report/csv_spec.rb +3 -3
- data/features/features/report/diff_spec.rb +20 -10
- data/features/features/report/html_spec.rb +10 -10
- data/features/features/report/subproject_spec.rb +15 -4
- data/features/fixtures/Cartfile +1 -0
- data/features/fixtures/Podfile +1 -1
- data/features/fixtures/alternate-build-file-gradle/build-alt.gradle +5 -15
- data/features/fixtures/build.gradle +5 -15
- data/features/fixtures/conanfile.txt +11 -0
- data/features/fixtures/file-based-libs-gradle/build.gradle +5 -7
- data/features/fixtures/gopath_dep/src/foo-dep/Gopkg.lock +9 -0
- data/features/fixtures/gopath_dep/src/foo-dep/Gopkg.toml +7 -0
- data/features/fixtures/gopath_dep/src/foo-dep/bar/bar.go +10 -0
- data/features/fixtures/gopath_dep/src/foo-dep/foo.go +7 -0
- data/features/fixtures/gopath_glide/src/glide.lock +9 -0
- data/features/fixtures/gopath_glide/src/glide.yaml +6 -0
- data/features/fixtures/gopath_govendor/src/vendor/vendor.json +19 -0
- data/features/fixtures/gopath_gvt/src/vendor/manifest +22 -0
- data/features/fixtures/gradle-wrapper/build.gradle +5 -15
- data/features/fixtures/gradle-wrapper/gradlew +6 -1
- data/features/fixtures/gradle-wrapper/gradlew.bat +9 -1
- data/features/fixtures/mix.exs +22 -0
- data/features/fixtures/multi-module-gradle/build.gradle +7 -15
- data/features/fixtures/single-module-gradle/build.gradle +5 -15
- data/features/support/testing_dsl.rb +155 -43
- data/lib/license_finder.rb +4 -3
- data/lib/license_finder/cli.rb +0 -3
- data/lib/license_finder/cli/approvals.rb +3 -3
- data/lib/license_finder/cli/base.rb +11 -8
- data/lib/license_finder/cli/blacklist.rb +7 -7
- data/lib/license_finder/cli/dependencies.rb +8 -8
- data/lib/license_finder/cli/ignored_dependencies.rb +4 -4
- data/lib/license_finder/cli/ignored_groups.rb +4 -4
- data/lib/license_finder/cli/licenses.rb +2 -2
- data/lib/license_finder/cli/main.rb +59 -39
- data/lib/license_finder/cli/makes_decisions.rb +2 -2
- data/lib/license_finder/cli/patched_thor.rb +6 -7
- data/lib/license_finder/cli/project_name.rb +5 -6
- data/lib/license_finder/cli/whitelist.rb +7 -7
- data/lib/license_finder/configuration.rb +15 -4
- data/lib/license_finder/core.rb +20 -4
- data/lib/license_finder/decision_applier.rb +0 -1
- data/lib/license_finder/decisions.rb +12 -14
- data/lib/license_finder/diff.rb +33 -31
- data/lib/license_finder/license.rb +13 -9
- data/lib/license_finder/license/definitions.rb +55 -55
- data/lib/license_finder/license/none_matcher.rb +1 -1
- data/lib/license_finder/license/template.rb +1 -1
- data/lib/license_finder/license/text.rb +0 -1
- data/lib/license_finder/license_aggregator.rb +1 -0
- data/lib/license_finder/logger.rb +18 -61
- data/lib/license_finder/package.rb +25 -11
- data/lib/license_finder/package_delta.rb +3 -6
- data/lib/license_finder/package_manager.rb +77 -34
- data/lib/license_finder/package_managers/bower.rb +8 -8
- data/lib/license_finder/package_managers/bower_package.rb +12 -12
- data/lib/license_finder/package_managers/bundler.rb +21 -9
- data/lib/license_finder/package_managers/bundler_package.rb +1 -1
- data/lib/license_finder/package_managers/carthage.rb +66 -0
- data/lib/license_finder/package_managers/carthage_package.rb +16 -0
- data/lib/license_finder/package_managers/cocoa_pods.rb +13 -13
- data/lib/license_finder/package_managers/cocoa_pods_package.rb +1 -1
- data/lib/license_finder/package_managers/conan.rb +26 -0
- data/lib/license_finder/package_managers/conan_info_parser.rb +74 -0
- data/lib/license_finder/package_managers/conan_package.rb +17 -0
- data/lib/license_finder/package_managers/dep.rb +33 -0
- data/lib/license_finder/package_managers/glide.rb +30 -0
- data/lib/license_finder/package_managers/{go_vendor.rb → go_15vendorexperiment.rb} +19 -24
- data/lib/license_finder/package_managers/go_dep.rb +15 -12
- data/lib/license_finder/package_managers/go_package.rb +15 -13
- data/lib/license_finder/package_managers/go_workspace.rb +39 -34
- data/lib/license_finder/package_managers/govendor.rb +32 -0
- data/lib/license_finder/package_managers/gradle.rb +16 -16
- data/lib/license_finder/package_managers/gradle_package.rb +8 -8
- data/lib/license_finder/package_managers/gvt.rb +61 -0
- data/lib/license_finder/package_managers/maven.rb +17 -18
- data/lib/license_finder/package_managers/maven_package.rb +4 -6
- data/lib/license_finder/package_managers/merged_package.rb +25 -2
- data/lib/license_finder/package_managers/mix.rb +51 -0
- data/lib/license_finder/package_managers/mix_package.rb +7 -0
- data/lib/license_finder/package_managers/npm.rb +8 -32
- data/lib/license_finder/package_managers/npm_package.rb +51 -48
- data/lib/license_finder/package_managers/nuget.rb +30 -40
- data/lib/license_finder/package_managers/pip.rb +11 -11
- data/lib/license_finder/package_managers/pip_package.rb +8 -8
- data/lib/license_finder/package_managers/rebar.rb +11 -11
- data/lib/license_finder/package_managers/yarn.rb +62 -0
- data/lib/license_finder/packages/activation.rb +2 -2
- data/lib/license_finder/packages/license_files.rb +6 -6
- data/lib/license_finder/packages/licensing.rb +8 -10
- data/lib/license_finder/packages/manual_package.rb +2 -2
- data/lib/license_finder/project_finder.rb +6 -5
- data/lib/license_finder/report.rb +1 -0
- data/lib/license_finder/reports/csv_report.rb +4 -4
- data/lib/license_finder/reports/diff_report.rb +2 -2
- data/lib/license_finder/reports/erb_report.rb +2 -4
- data/lib/license_finder/reports/html_report.rb +2 -2
- data/lib/license_finder/reports/markdown_report.rb +1 -1
- data/lib/license_finder/reports/merged_report.rb +1 -1
- data/lib/license_finder/reports/text_report.rb +3 -5
- data/lib/license_finder/shared_helpers/cmd.rb +11 -0
- data/lib/license_finder/version.rb +1 -1
- data/license_finder-2.1.2.gem +0 -0
- data/license_finder.gemspec +38 -38
- metadata +84 -118
- data/ci/scripts/test.sh +0 -26
- data/ci/tasks/create-source-archives.yml +0 -23
- data/spec/dummy_app/Gemfile +0 -6
- data/spec/fixtures/all_pms/.envrc +0 -1
- data/spec/fixtures/all_pms/.nuget/.keep +0 -0
- data/spec/fixtures/all_pms/Gemfile +0 -0
- data/spec/fixtures/all_pms/Godeps/Godeps.json +0 -0
- data/spec/fixtures/all_pms/Podfile +0 -0
- data/spec/fixtures/all_pms/bower.json +0 -0
- data/spec/fixtures/all_pms/build.gradle +0 -0
- data/spec/fixtures/all_pms/package.json +0 -0
- data/spec/fixtures/all_pms/pom.xml +0 -0
- data/spec/fixtures/all_pms/rebar.config +0 -0
- data/spec/fixtures/all_pms/requirements.txt +0 -0
- data/spec/fixtures/all_pms/vendor/.gitkeep +0 -0
- data/spec/fixtures/composite/Gemfile +0 -0
- data/spec/fixtures/composite/nested_project/.envrc +0 -8
- data/spec/fixtures/composite/nested_project/src/github.com/pivotal/foo/Godeps/Godeps.json +0 -16
- data/spec/fixtures/composite/nested_project/src/github.com/pivotal/foo/Godeps/Readme +0 -5
- data/spec/fixtures/composite/nested_project/src/github.com/pivotal/foo/foo.go +0 -6
- data/spec/fixtures/composite/not_a_project/DONTREADME.md +0 -0
- data/spec/fixtures/composite/project1/Gemfile +0 -0
- data/spec/fixtures/composite/project2/package.json +0 -0
- data/spec/fixtures/config/license_finder.yml +0 -5
- data/spec/fixtures/license_directory/COPYING +0 -1
- data/spec/fixtures/license_directory/LICENSE/MIT.txt +0 -1
- data/spec/fixtures/license_directory/LICENSE/lib/unrelated.txt +0 -2
- data/spec/fixtures/license_names/COPYING.txt +0 -1
- data/spec/fixtures/license_names/LICENSE +0 -1
- data/spec/fixtures/license_names/Licence.rdoc +0 -1
- data/spec/fixtures/license_names/Mit-License +0 -1
- data/spec/fixtures/license_names/README.rdoc +0 -1
- data/spec/fixtures/nested_gem/vendor/LICENSE +0 -1
- data/spec/fixtures/npm-circular-dependencies/npm-list.json +0 -5339
- data/spec/fixtures/npm-circular-dependencies/package.json +0 -5
- data/spec/fixtures/npm-circular-licenses/npm-list.json +0 -7597
- data/spec/fixtures/npm-circular-licenses/package.json +0 -23
- data/spec/fixtures/npm-licenses-string/npm-list.json +0 -7597
- data/spec/fixtures/npm-licenses-string/package.json +0 -23
- data/spec/fixtures/npm-recursive-dependencies/npm-list.json +0 -5158
- data/spec/fixtures/npm-recursive-dependencies/package.json +0 -15
- data/spec/fixtures/npm-stack-too-deep/npm-list.json +0 -13464
- data/spec/fixtures/npm-stack-too-deep/package.json +0 -5
- data/spec/fixtures/utf8_gem/README +0 -210
- data/spec/lib/license_finder/cli/approvals_spec.rb +0 -71
- data/spec/lib/license_finder/cli/blacklist_spec.rb +0 -58
- data/spec/lib/license_finder/cli/dependencies_spec.rb +0 -73
- data/spec/lib/license_finder/cli/ignored_dependencies_spec.rb +0 -47
- data/spec/lib/license_finder/cli/ignored_groups_spec.rb +0 -40
- data/spec/lib/license_finder/cli/licenses_spec.rb +0 -60
- data/spec/lib/license_finder/cli/main_spec.rb +0 -243
- data/spec/lib/license_finder/cli/project_name_spec.rb +0 -40
- data/spec/lib/license_finder/cli/whitelist_spec.rb +0 -58
- data/spec/lib/license_finder/configuration_spec.rb +0 -115
- data/spec/lib/license_finder/core_spec.rb +0 -54
- data/spec/lib/license_finder/decision_applier_spec.rb +0 -219
- data/spec/lib/license_finder/decisions_spec.rb +0 -408
- data/spec/lib/license_finder/diff_spec.rb +0 -129
- data/spec/lib/license_finder/license/definitions_spec.rb +0 -177
- data/spec/lib/license_finder/license_aggregator_spec.rb +0 -61
- data/spec/lib/license_finder/license_spec.rb +0 -106
- data/spec/lib/license_finder/package_delta_spec.rb +0 -18
- data/spec/lib/license_finder/package_manager_spec.rb +0 -62
- data/spec/lib/license_finder/package_managers/bower_package_spec.rb +0 -71
- data/spec/lib/license_finder/package_managers/bower_spec.rb +0 -39
- data/spec/lib/license_finder/package_managers/bundler_package_spec.rb +0 -35
- data/spec/lib/license_finder/package_managers/bundler_spec.rb +0 -56
- data/spec/lib/license_finder/package_managers/cocoa_pods_package_spec.rb +0 -48
- data/spec/lib/license_finder/package_managers/cocoa_pods_spec.rb +0 -59
- data/spec/lib/license_finder/package_managers/go_dep_spec.rb +0 -126
- data/spec/lib/license_finder/package_managers/go_package_spec.rb +0 -33
- data/spec/lib/license_finder/package_managers/go_vendor_spec.rb +0 -144
- data/spec/lib/license_finder/package_managers/go_workspace_spec.rb +0 -286
- data/spec/lib/license_finder/package_managers/gradle_package_spec.rb +0 -80
- data/spec/lib/license_finder/package_managers/gradle_spec.rb +0 -180
- data/spec/lib/license_finder/package_managers/maven_package_spec.rb +0 -63
- data/spec/lib/license_finder/package_managers/maven_spec.rb +0 -128
- data/spec/lib/license_finder/package_managers/merged_package_spec.rb +0 -60
- data/spec/lib/license_finder/package_managers/npm_package_spec.rb +0 -57
- data/spec/lib/license_finder/package_managers/npm_spec.rb +0 -253
- data/spec/lib/license_finder/package_managers/nuget_package_spec.rb +0 -9
- data/spec/lib/license_finder/package_managers/nuget_spec.rb +0 -157
- data/spec/lib/license_finder/package_managers/pip_package_spec.rb +0 -87
- data/spec/lib/license_finder/package_managers/pip_spec.rb +0 -47
- data/spec/lib/license_finder/package_managers/rebar_package_spec.rb +0 -24
- data/spec/lib/license_finder/package_managers/rebar_spec.rb +0 -50
- data/spec/lib/license_finder/package_spec.rb +0 -179
- data/spec/lib/license_finder/packages/activation_spec.rb +0 -41
- data/spec/lib/license_finder/packages/license_files_spec.rb +0 -46
- data/spec/lib/license_finder/packages/licensing_spec.rb +0 -1
- data/spec/lib/license_finder/packages/possible_license_file_spec.rb +0 -38
- data/spec/lib/license_finder/project_finder_spec.rb +0 -33
- data/spec/lib/license_finder/reports/csv_report_spec.rb +0 -70
- data/spec/lib/license_finder/reports/diff_report_spec.rb +0 -56
- data/spec/lib/license_finder/reports/html_report_spec.rb +0 -101
- data/spec/lib/license_finder/reports/markdown_report_spec.rb +0 -45
- data/spec/lib/license_finder/reports/merged_report_spec.rb +0 -21
- data/spec/lib/license_finder/reports/text_report_spec.rb +0 -43
- data/spec/spec_helper.rb +0 -27
- data/spec/support/shared_examples_for_package_manager.rb +0 -52
- data/spec/support/stdout_helpers.rb +0 -31
- data/spec/support/test_fixtures.rb +0 -7
@@ -18,6 +18,7 @@ module LicenseFinder
|
|
18
18
|
def aggregate_packages
|
19
19
|
@subprojects.flat_map do |project_path|
|
20
20
|
finder = LicenseFinder::Core.new(@license_finder_config.merge(project_path: project_path))
|
21
|
+
finder.prepare_projects if @license_finder_config[:prepare]
|
21
22
|
finder.acknowledged.map { |dep| MergedPackage.new(dep, [project_path]) }
|
22
23
|
end
|
23
24
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module LicenseFinder
|
2
2
|
module Logger
|
3
|
-
def self.new
|
3
|
+
def self.new(options = {})
|
4
4
|
klass = if options[:quiet]
|
5
5
|
Quiet
|
6
6
|
elsif options[:debug]
|
@@ -11,79 +11,36 @@ module LicenseFinder
|
|
11
11
|
klass.new
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def active package_manager, is_active
|
26
|
-
if is_active
|
27
|
-
log package_manager, Logger.green("is active")
|
28
|
-
else
|
29
|
-
log package_manager, "is not active"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def package package_manager, package
|
34
|
-
dependencies = package.children
|
35
|
-
if dependencies.empty?
|
36
|
-
log package_manager, sprintf("package '%s' has no dependencies", package.name)
|
37
|
-
else
|
38
|
-
log package_manager, sprintf("package '%s' has dependencies:", package.name)
|
39
|
-
dependencies.each do |dep|
|
40
|
-
log package_manager, sprintf("- %s", dep)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def activation activation
|
46
|
-
preamble = sprintf("package %s:", activation.package.name)
|
47
|
-
if activation.sources.empty?
|
48
|
-
log activation.package.class, sprintf("%s no licenses found", preamble)
|
49
|
-
else
|
50
|
-
activation.sources.each do |source|
|
51
|
-
log activation.package.class, sprintf("%s found license '%s' %s", preamble, activation.license.name, source)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def log prefix, string
|
57
|
-
raise NotImplementedError, "#log must be implemented"
|
14
|
+
def self.colorize(string, color)
|
15
|
+
case color
|
16
|
+
when :red
|
17
|
+
"\e[31m#{string}\e[0m"
|
18
|
+
when :green
|
19
|
+
"\e[32m#{string}\e[0m"
|
20
|
+
else
|
21
|
+
string
|
58
22
|
end
|
59
23
|
end
|
60
24
|
|
61
|
-
|
62
|
-
|
63
|
-
|
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"
|
25
|
+
class Base
|
26
|
+
def log(_prefix, _string, _options = {})
|
27
|
+
raise NotImplementedError, '#log must be implemented'
|
28
|
+
end
|
71
29
|
end
|
72
30
|
|
73
31
|
class Quiet < Base
|
74
|
-
def log
|
75
|
-
end
|
32
|
+
def log(prefix, string, options = {}); end
|
76
33
|
end
|
77
34
|
|
78
35
|
class Progress < Base
|
79
|
-
def log
|
80
|
-
print(
|
36
|
+
def log(_prefix, _string, _options = {})
|
37
|
+
print('.') && $stdout.flush
|
81
38
|
end
|
82
39
|
end
|
83
40
|
|
84
41
|
class Verbose < Base
|
85
|
-
def log
|
86
|
-
printf("%s: %s\n", prefix, string)
|
42
|
+
def log(prefix, string, options = {})
|
43
|
+
printf("%s: %s\n", prefix, Logger.colorize(string, options[:color]))
|
87
44
|
end
|
88
45
|
end
|
89
46
|
|
@@ -18,27 +18,27 @@ module LicenseFinder
|
|
18
18
|
attr_reader :logger
|
19
19
|
|
20
20
|
def self.license_names_from_standard_spec(spec)
|
21
|
-
licenses = spec[
|
21
|
+
licenses = spec['licenses'] || [spec['license']].compact
|
22
22
|
licenses = [licenses] unless licenses.is_a?(Array)
|
23
23
|
licenses.map do |license|
|
24
24
|
if license.is_a? Hash
|
25
|
-
license[
|
25
|
+
license['type']
|
26
26
|
else
|
27
27
|
license
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
def initialize(name, version = nil, options={})
|
32
|
+
def initialize(name, version = nil, options = {})
|
33
33
|
@logger = options[:logger] || Core.default_logger
|
34
34
|
|
35
35
|
## DESCRIPTION
|
36
36
|
@name = name
|
37
37
|
@version = version
|
38
|
-
@authors = options[:authors] ||
|
39
|
-
@summary = options[:summary] ||
|
40
|
-
@description = options[:description] ||
|
41
|
-
@homepage = options[:homepage] ||
|
38
|
+
@authors = options[:authors] || ''
|
39
|
+
@summary = options[:summary] || ''
|
40
|
+
@description = options[:description] || ''
|
41
|
+
@homepage = options[:homepage] || ''
|
42
42
|
@children = options[:children] || []
|
43
43
|
@parents = Set.new # will be figured out later by package manager
|
44
44
|
@groups = options[:groups] || []
|
@@ -100,7 +100,7 @@ module LicenseFinder
|
|
100
100
|
|
101
101
|
def <=>(other)
|
102
102
|
eq_name = name <=> other.name
|
103
|
-
return eq_name unless eq_name
|
103
|
+
return eq_name unless eq_name.zero?
|
104
104
|
version <=> other.version
|
105
105
|
end
|
106
106
|
|
@@ -109,7 +109,7 @@ module LicenseFinder
|
|
109
109
|
end
|
110
110
|
|
111
111
|
def hash
|
112
|
-
[name,version].hash
|
112
|
+
[name, version].hash
|
113
113
|
end
|
114
114
|
|
115
115
|
## LICENSING
|
@@ -123,7 +123,7 @@ module LicenseFinder
|
|
123
123
|
|
124
124
|
def activations
|
125
125
|
licensing.activations.tap do |activations|
|
126
|
-
activations.each { |activation|
|
126
|
+
activations.each { |activation| log_activation activation }
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
@@ -146,12 +146,23 @@ module LicenseFinder
|
|
146
146
|
end
|
147
147
|
|
148
148
|
def package_manager
|
149
|
-
|
149
|
+
'unknown'
|
150
150
|
end
|
151
151
|
|
152
152
|
def missing?
|
153
153
|
@missing
|
154
154
|
end
|
155
|
+
|
156
|
+
def log_activation(activation)
|
157
|
+
preamble = format('package %s:', activation.package.name)
|
158
|
+
if activation.sources.empty?
|
159
|
+
logger.log activation.package.class, format('%s no licenses found', preamble)
|
160
|
+
else
|
161
|
+
activation.sources.each do |source|
|
162
|
+
logger.log activation.package.class, format("%s found license '%s' %s", preamble, activation.license.name, source)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
155
166
|
end
|
156
167
|
end
|
157
168
|
|
@@ -164,6 +175,9 @@ require 'license_finder/package_managers/npm_package'
|
|
164
175
|
require 'license_finder/package_managers/maven_package'
|
165
176
|
require 'license_finder/package_managers/gradle_package'
|
166
177
|
require 'license_finder/package_managers/cocoa_pods_package'
|
178
|
+
require 'license_finder/package_managers/carthage_package'
|
167
179
|
require 'license_finder/package_managers/rebar_package'
|
180
|
+
require 'license_finder/package_managers/mix_package'
|
168
181
|
require 'license_finder/package_managers/merged_package'
|
169
182
|
require 'license_finder/package_managers/nuget_package'
|
183
|
+
require 'license_finder/package_managers/conan_package'
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module LicenseFinder
|
2
2
|
class PackageDelta
|
3
|
-
STATUSES = [
|
3
|
+
STATUSES = %i[added removed unchanged].freeze
|
4
4
|
|
5
5
|
def initialize(status, current_package, previous_package)
|
6
6
|
@status = status
|
@@ -16,14 +16,11 @@ module LicenseFinder
|
|
16
16
|
pick_package.version
|
17
17
|
end
|
18
18
|
|
19
|
-
|
20
19
|
def subproject_paths
|
21
20
|
pick_package.subproject_paths
|
22
21
|
end
|
23
22
|
|
24
|
-
|
25
|
-
@status
|
26
|
-
end
|
23
|
+
attr_reader :status
|
27
24
|
|
28
25
|
def licenses
|
29
26
|
pick_package.licenses
|
@@ -33,7 +30,7 @@ module LicenseFinder
|
|
33
30
|
pick_package.class == MergedPackage
|
34
31
|
end
|
35
32
|
|
36
|
-
def method_missing(
|
33
|
+
def method_missing(_method_name)
|
37
34
|
nil
|
38
35
|
end
|
39
36
|
|
@@ -9,72 +9,107 @@ module LicenseFinder
|
|
9
9
|
# Additional guidelines are:
|
10
10
|
#
|
11
11
|
# - implement #current_packages, to return a list of `Package`s this package manager is tracking
|
12
|
-
# - implement #
|
13
|
-
#
|
12
|
+
# - implement #possible_package_paths, an array of `Pathname`s which are the possible locations which contain a configuration file/folder indicating the package manager is in use.
|
13
|
+
# - implement(Optional) #package_management_command, string for invoking the package manager
|
14
|
+
# - implement(Optional) #prepare_command, string for fetching dependencies for package manager (runs when the --prepare flag is passed to license_finder)
|
15
|
+
|
14
16
|
class PackageManager
|
15
|
-
|
16
|
-
[GoDep, GoWorkspace, GoVendor, Bundler, NPM, Pip, Bower, Maven, Gradle, CocoaPods, Rebar, Nuget]
|
17
|
-
end
|
17
|
+
include LicenseFinder::SharedHelpers
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
19
|
+
class << self
|
20
|
+
def package_managers
|
21
|
+
[GoDep, GoWorkspace, Go15VendorExperiment, Glide, Gvt, Govendor, Dep, Bundler, NPM, Pip,
|
22
|
+
Yarn, Bower, Maven, Gradle, CocoaPods, Rebar, Nuget, Carthage, Mix, Conan]
|
23
|
+
end
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
logger.installed self, "no command defined" # TODO comment me out
|
29
|
-
return true
|
25
|
+
def active_packages(options)
|
26
|
+
active_package_managers(options).flat_map(&:current_packages_with_relations)
|
30
27
|
end
|
31
28
|
|
32
|
-
|
33
|
-
|
34
|
-
|
29
|
+
def active_package_managers(options = { project_path: Pathname.new('') })
|
30
|
+
active_pm_classes = package_managers.select { |pm_class| pm_class.new(options).active? }
|
31
|
+
active_pm_classes -= active_pm_classes.map(&:takes_priority_over)
|
32
|
+
active_pm_classes.map { |pm_class| pm_class.new(options) }
|
35
33
|
end
|
36
34
|
|
37
|
-
|
38
|
-
|
39
|
-
|
35
|
+
def takes_priority_over
|
36
|
+
nil
|
37
|
+
end
|
38
|
+
|
39
|
+
def installed?(logger = Core.default_logger)
|
40
|
+
if package_management_command.nil?
|
41
|
+
logger.log self, 'no command defined' # TODO: comment me out
|
42
|
+
true
|
43
|
+
elsif command_exists?(package_management_command)
|
44
|
+
logger.log self, 'is installed', color: :green
|
45
|
+
true
|
46
|
+
else
|
47
|
+
logger.log self, 'is not installed', color: :red
|
48
|
+
false
|
49
|
+
end
|
50
|
+
end
|
40
51
|
|
41
|
-
|
42
|
-
|
52
|
+
# see class description
|
53
|
+
def package_management_command
|
54
|
+
nil
|
55
|
+
end
|
56
|
+
|
57
|
+
# see class description
|
58
|
+
def prepare_command
|
59
|
+
nil
|
60
|
+
end
|
43
61
|
end
|
44
62
|
|
45
|
-
def initialize
|
63
|
+
def initialize(options = {})
|
46
64
|
@logger = options[:logger] || Core.default_logger
|
47
65
|
@project_path = options[:project_path]
|
48
66
|
end
|
49
67
|
|
50
68
|
def active?
|
69
|
+
path = detected_package_path
|
51
70
|
self.class.installed?(logger) &&
|
52
|
-
|
71
|
+
!path.nil? &&
|
72
|
+
path.exist?.tap do |is_active|
|
73
|
+
if is_active
|
74
|
+
logger.log self.class, 'is active', color: :green
|
75
|
+
else
|
76
|
+
logger.log self.class, 'is not active'
|
77
|
+
end
|
78
|
+
end
|
53
79
|
end
|
54
80
|
|
55
|
-
def
|
56
|
-
|
81
|
+
def detected_package_path
|
82
|
+
possible_package_paths.find(&:exist?)
|
83
|
+
end
|
84
|
+
|
85
|
+
def prepare
|
86
|
+
if self.class.prepare_command
|
87
|
+
_stdout, _stderr, status = Cmd.run(self.class.prepare_command)
|
88
|
+
raise "Prepare command '#{self.class.prepare_command}' failed" unless status.success?
|
89
|
+
else
|
90
|
+
logger.log self.class, 'no prepare step provided', color: :red
|
91
|
+
end
|
57
92
|
end
|
58
93
|
|
59
94
|
def current_packages_with_relations
|
60
95
|
packages = current_packages
|
61
96
|
packages.each do |parent|
|
62
97
|
parent.children.each do |child_name|
|
63
|
-
child = packages.detect { |
|
98
|
+
child = packages.detect { |child_package| child_package.name == child_name }
|
64
99
|
child.parents << parent.name if child
|
65
100
|
end
|
66
101
|
end
|
67
102
|
packages
|
68
103
|
end
|
69
104
|
|
70
|
-
def self.command_exists?
|
105
|
+
def self.command_exists?(command)
|
71
106
|
if LicenseFinder::Platform.windows?
|
72
|
-
|
107
|
+
_stdout, _stderr, status = Cmd.run("where #{command} 2>NUL")
|
73
108
|
else
|
74
|
-
|
109
|
+
_stdout, _stderr, status = Cmd.run("which #{command} 2>/dev/null")
|
75
110
|
end
|
76
|
-
|
77
|
-
|
111
|
+
|
112
|
+
status.success?
|
78
113
|
end
|
79
114
|
|
80
115
|
private
|
@@ -85,15 +120,23 @@ end
|
|
85
120
|
|
86
121
|
require 'license_finder/package_managers/bower'
|
87
122
|
require 'license_finder/package_managers/go_workspace'
|
88
|
-
require 'license_finder/package_managers/
|
123
|
+
require 'license_finder/package_managers/go_15vendorexperiment'
|
89
124
|
require 'license_finder/package_managers/go_dep'
|
125
|
+
require 'license_finder/package_managers/gvt'
|
126
|
+
require 'license_finder/package_managers/glide'
|
127
|
+
require 'license_finder/package_managers/govendor'
|
90
128
|
require 'license_finder/package_managers/bundler'
|
91
129
|
require 'license_finder/package_managers/npm'
|
130
|
+
require 'license_finder/package_managers/yarn'
|
92
131
|
require 'license_finder/package_managers/pip'
|
93
132
|
require 'license_finder/package_managers/maven'
|
133
|
+
require 'license_finder/package_managers/mix'
|
94
134
|
require 'license_finder/package_managers/cocoa_pods'
|
135
|
+
require 'license_finder/package_managers/carthage'
|
95
136
|
require 'license_finder/package_managers/gradle'
|
96
137
|
require 'license_finder/package_managers/rebar'
|
97
138
|
require 'license_finder/package_managers/nuget'
|
139
|
+
require 'license_finder/package_managers/dep'
|
140
|
+
require 'license_finder/package_managers/conan'
|
98
141
|
|
99
142
|
require 'license_finder/package'
|
@@ -9,23 +9,23 @@ module LicenseFinder
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.package_management_command
|
12
|
-
|
12
|
+
'bower'
|
13
13
|
end
|
14
14
|
|
15
15
|
private
|
16
16
|
|
17
17
|
def bower_output
|
18
|
-
command = "#{Bower
|
19
|
-
|
20
|
-
raise "Command '#{command}' failed to execute: #{
|
18
|
+
command = "#{Bower.package_management_command} list --json -l action --allow-root"
|
19
|
+
stdout, stderr, status = Dir.chdir(project_path) { Cmd.run(command) }
|
20
|
+
raise "Command '#{command}' failed to execute: #{stderr}" unless status.success?
|
21
21
|
|
22
|
-
JSON(
|
23
|
-
.fetch(
|
22
|
+
JSON(stdout)
|
23
|
+
.fetch('dependencies', {})
|
24
24
|
.values
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
28
|
-
project_path.join('bower.json')
|
27
|
+
def possible_package_paths
|
28
|
+
[project_path.join('bower.json')]
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|