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
@@ -3,9 +3,9 @@ require 'httparty'
|
|
3
3
|
|
4
4
|
module LicenseFinder
|
5
5
|
class Pip < PackageManager
|
6
|
-
def initialize(options={})
|
6
|
+
def initialize(options = {})
|
7
7
|
super
|
8
|
-
@requirements_path = options[:pip_requirements_path] || 'requirements.txt'
|
8
|
+
@requirements_path = options[:pip_requirements_path] || Pathname('requirements.txt')
|
9
9
|
end
|
10
10
|
|
11
11
|
def current_packages
|
@@ -16,36 +16,36 @@ module LicenseFinder
|
|
16
16
|
pypi_def(name, version),
|
17
17
|
logger: logger,
|
18
18
|
children: children,
|
19
|
-
install_path: Pathname(location).join(name)
|
19
|
+
install_path: Pathname(location).join(name)
|
20
20
|
)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
def self.package_management_command
|
25
|
-
|
25
|
+
'pip'
|
26
26
|
end
|
27
27
|
|
28
28
|
private
|
29
29
|
|
30
|
-
def
|
31
|
-
|
32
|
-
|
30
|
+
def possible_package_paths
|
31
|
+
if project_path.nil?
|
32
|
+
[@requirements_path]
|
33
33
|
else
|
34
|
-
@requirements_path
|
34
|
+
[project_path.join(@requirements_path)]
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
def pip_output
|
39
|
-
output = `#{LicenseFinder::BIN_PATH.join(
|
39
|
+
output = `#{LicenseFinder::BIN_PATH.join('license_finder_pip.py')} #{detected_package_path}`
|
40
40
|
JSON(output).map do |package|
|
41
|
-
package.values_at(
|
41
|
+
package.values_at('name', 'version', 'dependencies', 'location')
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
45
|
def pypi_def(name, version)
|
46
46
|
response = HTTParty.get("https://pypi.python.org/pypi/#{name}/#{version}/json")
|
47
47
|
if response.code == 200
|
48
|
-
JSON.parse(response.body).fetch(
|
48
|
+
JSON.parse(response.body).fetch('info', {})
|
49
49
|
else
|
50
50
|
{}
|
51
51
|
end
|
@@ -1,28 +1,28 @@
|
|
1
1
|
module LicenseFinder
|
2
2
|
class PipPackage < Package
|
3
3
|
LICENSE_FORMAT = /^License.*::\s*(.*)$/
|
4
|
-
INVALID_LICENSES = [
|
4
|
+
INVALID_LICENSES = ['', 'UNKNOWN'].to_set
|
5
5
|
|
6
6
|
def self.license_names_from_spec(spec)
|
7
|
-
license = spec[
|
7
|
+
license = spec['license'].to_s.strip
|
8
8
|
|
9
9
|
return [license] unless INVALID_LICENSES.include?(license)
|
10
10
|
|
11
11
|
spec
|
12
|
-
.fetch(
|
12
|
+
.fetch('classifiers', [])
|
13
13
|
.select { |c| c =~ LICENSE_FORMAT }
|
14
14
|
.map { |c| c.gsub(LICENSE_FORMAT, '\1') }
|
15
15
|
end
|
16
16
|
|
17
|
-
def initialize(name, version, spec, options={})
|
17
|
+
def initialize(name, version, spec, options = {})
|
18
18
|
super(
|
19
19
|
name,
|
20
20
|
version,
|
21
21
|
options.merge(
|
22
|
-
authors: spec[
|
23
|
-
summary: spec[
|
24
|
-
description: spec[
|
25
|
-
homepage: spec[
|
22
|
+
authors: spec['author'],
|
23
|
+
summary: spec['summary'],
|
24
|
+
description: spec['description'],
|
25
|
+
homepage: spec['home_page'],
|
26
26
|
spec_licenses: self.class.license_names_from_spec(spec)
|
27
27
|
)
|
28
28
|
)
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module LicenseFinder
|
2
2
|
class Rebar < PackageManager
|
3
|
-
def initialize(options={})
|
3
|
+
def initialize(options = {})
|
4
4
|
super
|
5
|
-
@command = options[:rebar_command] || Rebar
|
6
|
-
@deps_path = Pathname(options[:rebar_deps_dir] ||
|
5
|
+
@command = options[:rebar_command] || Rebar.package_management_command
|
6
|
+
@deps_path = Pathname(options[:rebar_deps_dir] || 'deps')
|
7
7
|
end
|
8
8
|
|
9
9
|
def current_packages
|
@@ -19,24 +19,24 @@ module LicenseFinder
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def self.package_management_command
|
22
|
-
|
22
|
+
'rebar'
|
23
23
|
end
|
24
24
|
|
25
25
|
private
|
26
26
|
|
27
27
|
def rebar_ouput
|
28
28
|
command = "#{@command} list-deps"
|
29
|
-
|
30
|
-
raise "Command '#{command}' failed to execute: #{
|
29
|
+
stdout, stderr, status = Dir.chdir(project_path) { Cmd.run(command) }
|
30
|
+
raise "Command '#{command}' failed to execute: #{stderr}" unless status.success?
|
31
31
|
|
32
|
-
|
32
|
+
stdout
|
33
33
|
.each_line
|
34
|
-
.reject { |line| line.start_with?(
|
35
|
-
.map { |line| line.split(
|
34
|
+
.reject { |line| line.start_with?('=') }
|
35
|
+
.map { |line| line.split(' ') }
|
36
36
|
end
|
37
37
|
|
38
|
-
def
|
39
|
-
project_path.join('rebar.config')
|
38
|
+
def possible_package_paths
|
39
|
+
[project_path.join('rebar.config')]
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module LicenseFinder
|
2
|
+
class Yarn < PackageManager
|
3
|
+
SHELL_COMMAND = 'yarn licenses list --no-progress --json'.freeze
|
4
|
+
|
5
|
+
def possible_package_paths
|
6
|
+
[project_path.join('yarn.lock')]
|
7
|
+
end
|
8
|
+
|
9
|
+
def current_packages
|
10
|
+
stdout, _stderr, status = Cmd.run(Yarn::SHELL_COMMAND)
|
11
|
+
return [] unless status.success?
|
12
|
+
|
13
|
+
packages = []
|
14
|
+
incompatible_packages = []
|
15
|
+
|
16
|
+
json_strings = stdout.split("\n")
|
17
|
+
json_objects = json_strings.map { |json_object| JSON.parse(json_object) }
|
18
|
+
|
19
|
+
if json_objects.last['type'] == 'table'
|
20
|
+
license_json = json_objects.pop['data']
|
21
|
+
packages = packages_from_json(license_json)
|
22
|
+
end
|
23
|
+
|
24
|
+
json_objects.each do |json_object|
|
25
|
+
match = /(?<name>[\w,\-]+)@(?<version>(\d+\.?)+)/ =~ json_object['data'].to_s
|
26
|
+
if match
|
27
|
+
package = Package.new(name, version, spec_licenses: ['unknown'])
|
28
|
+
incompatible_packages.push(package)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
packages + incompatible_packages.uniq
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.takes_priority_over
|
36
|
+
NPM
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.package_management_command
|
40
|
+
'yarn'
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.prepare_command
|
44
|
+
'yarn install'
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def packages_from_json(json_data)
|
50
|
+
body = json_data['body']
|
51
|
+
head = json_data['head']
|
52
|
+
|
53
|
+
packages = body.map do |json_package|
|
54
|
+
Hash[head.zip(json_package)]
|
55
|
+
end
|
56
|
+
|
57
|
+
packages.map do |package_hash|
|
58
|
+
Package.new(package_hash['Name'], package_hash['Version'], spec_licenses: [package_hash['License']], homepage: package_hash['VendorUrl'])
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -2,8 +2,8 @@ require 'license_finder/packages/possible_license_file'
|
|
2
2
|
|
3
3
|
module LicenseFinder
|
4
4
|
class LicenseFiles
|
5
|
-
CANDIDATE_FILE_NAMES = %w
|
6
|
-
CANDIDATE_PATH_WILDCARD = "*{#{CANDIDATE_FILE_NAMES.join(',')}}*"
|
5
|
+
CANDIDATE_FILE_NAMES = %w[LICENSE License Licence COPYING README Readme ReadMe].freeze
|
6
|
+
CANDIDATE_PATH_WILDCARD = "*{#{CANDIDATE_FILE_NAMES.join(',')}}*".freeze
|
7
7
|
|
8
8
|
def self.find(install_path)
|
9
9
|
new(install_path).find
|
@@ -24,10 +24,10 @@ module LicenseFinder
|
|
24
24
|
attr_reader :install_path
|
25
25
|
|
26
26
|
def paths_of_candidate_files
|
27
|
-
candidate_files_and_dirs
|
28
|
-
flat_map { |path| path.directory? ? path.children : path }
|
29
|
-
reject
|
30
|
-
uniq
|
27
|
+
candidate_files_and_dirs
|
28
|
+
.flat_map { |path| path.directory? ? path.children : path }
|
29
|
+
.reject(&:directory?)
|
30
|
+
.uniq
|
31
31
|
end
|
32
32
|
|
33
33
|
def candidate_files_and_dirs
|
@@ -2,33 +2,31 @@ require 'license_finder/packages/activation'
|
|
2
2
|
|
3
3
|
module LicenseFinder
|
4
4
|
Licensing = Struct.new(:package, :decided_licenses, :licenses_from_spec, :license_files) do
|
5
|
-
|
6
5
|
# Implements the algorithm for choosing the right set of licenses from
|
7
6
|
# among the various sources of licenses we know about. In order of
|
8
7
|
# priority, licenses come from decisions, package specs, or package files.
|
9
8
|
def activations
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
else [default_activation]
|
9
|
+
if activations_from_decisions.any? then activations_from_decisions
|
10
|
+
elsif activations_from_spec.any? then activations_from_spec
|
11
|
+
elsif activations_from_files.any? then activations_from_files
|
12
|
+
else [default_activation]
|
15
13
|
end
|
16
14
|
end
|
17
15
|
|
18
16
|
def activations_from_decisions
|
19
17
|
@afd ||= decided_licenses
|
20
|
-
|
18
|
+
.map { |license| Activation::FromDecision.new(package, license) }
|
21
19
|
end
|
22
20
|
|
23
21
|
def activations_from_spec
|
24
22
|
@afs ||= licenses_from_spec
|
25
|
-
|
23
|
+
.map { |license| Activation::FromSpec.new(package, license) }
|
26
24
|
end
|
27
25
|
|
28
26
|
def activations_from_files
|
29
27
|
@aff ||= license_files
|
30
|
-
|
31
|
-
|
28
|
+
.group_by(&:license)
|
29
|
+
.map { |license, files| Activation::FromFiles.new(package, license, files) }
|
32
30
|
end
|
33
31
|
|
34
32
|
def default_activation
|
@@ -5,11 +5,11 @@ module LicenseFinder
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def eql?(other)
|
8
|
-
name == other.name
|
8
|
+
name == other.name
|
9
9
|
end
|
10
10
|
|
11
11
|
def hash
|
12
|
-
name.hash
|
12
|
+
name.hash
|
13
13
|
end
|
14
14
|
|
15
15
|
private
|
@@ -17,10 +17,11 @@ module LicenseFinder
|
|
17
17
|
|
18
18
|
def collect_project_path(all_paths)
|
19
19
|
potential_project_path = all_paths.first
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
is_active_project = active_project?(potential_project_path)
|
21
|
+
return unless is_active_project
|
22
|
+
|
23
|
+
remove_nested(potential_project_path, all_paths)
|
24
|
+
potential_project_path.to_s
|
24
25
|
end
|
25
26
|
|
26
27
|
private
|
@@ -50,7 +51,7 @@ module LicenseFinder
|
|
50
51
|
end
|
51
52
|
|
52
53
|
def nested_path?(path, pathname)
|
53
|
-
|
54
|
+
path.to_s.start_with?(pathname.to_s) && path.to_s != pathname.to_s
|
54
55
|
end
|
55
56
|
end
|
56
57
|
end
|
@@ -2,9 +2,9 @@ require 'csv'
|
|
2
2
|
|
3
3
|
module LicenseFinder
|
4
4
|
class CsvReport < Report
|
5
|
-
COMMA_SEP =
|
6
|
-
AVAILABLE_COLUMNS = %w[name version authors licenses license_links approved summary description homepage install_path package_manager groups]
|
7
|
-
MISSING_DEPENDENCY_TEXT =
|
5
|
+
COMMA_SEP = ','.freeze
|
6
|
+
AVAILABLE_COLUMNS = %w[name version authors licenses license_links approved summary description homepage install_path package_manager groups].freeze
|
7
|
+
MISSING_DEPENDENCY_TEXT = 'This package is not installed. Please install to determine licenses.'.freeze
|
8
8
|
|
9
9
|
def initialize(dependencies, options)
|
10
10
|
super
|
@@ -56,7 +56,7 @@ module LicenseFinder
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def format_approved(dep)
|
59
|
-
dep.approved? ?
|
59
|
+
dep.approved? ? 'Approved' : 'Not approved'
|
60
60
|
end
|
61
61
|
|
62
62
|
def format_summary(dep)
|
@@ -2,7 +2,7 @@ module LicenseFinder
|
|
2
2
|
class DiffReport < CsvReport
|
3
3
|
AVAILABLE_COLUMNS = AVAILABLE_COLUMNS + %w[status current_version previous_version project_paths]
|
4
4
|
|
5
|
-
def initialize(dependencies, options={})
|
5
|
+
def initialize(dependencies, options = {})
|
6
6
|
super(dependencies, options.merge(columns: build_columns(dependencies)))
|
7
7
|
end
|
8
8
|
|
@@ -22,7 +22,7 @@ module LicenseFinder
|
|
22
22
|
|
23
23
|
def build_columns(dependencies)
|
24
24
|
columns = %w[status name version licenses]
|
25
|
-
columns << 'project_paths' if dependencies.all?
|
25
|
+
columns << 'project_paths' if dependencies.all?(&:merged_package?)
|
26
26
|
columns
|
27
27
|
end
|
28
28
|
end
|
@@ -38,7 +38,7 @@ module LicenseFinder
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def link_to(text, link = "##{text}")
|
41
|
-
%
|
41
|
+
%(<a href="#{link}">#{text}</a>)
|
42
42
|
end
|
43
43
|
|
44
44
|
def license_names(dependency)
|
@@ -51,9 +51,7 @@ module LicenseFinder
|
|
51
51
|
|
52
52
|
def version_groups(dependency)
|
53
53
|
result = "v#{dependency.version}"
|
54
|
-
if dependency.groups.any?
|
55
|
-
result << " (#{dependency.groups.join(", ")})"
|
56
|
-
end
|
54
|
+
result << " (#{dependency.groups.join(', ')})" if dependency.groups.any?
|
57
55
|
result
|
58
56
|
end
|
59
57
|
end
|
@@ -3,7 +3,7 @@ module LicenseFinder
|
|
3
3
|
AVAILABLE_COLUMNS = AVAILABLE_COLUMNS + ['subproject_paths']
|
4
4
|
|
5
5
|
def initialize(dependencies, options = {})
|
6
|
-
options[:columns] ||= %w
|
6
|
+
options[:columns] ||= %w[name version licenses subproject_paths]
|
7
7
|
super(dependencies, options)
|
8
8
|
end
|
9
9
|
|
@@ -1,14 +1,12 @@
|
|
1
1
|
module LicenseFinder
|
2
2
|
class TextReport < CsvReport
|
3
|
-
COMMA_SEP =
|
3
|
+
COMMA_SEP = ', '.freeze
|
4
4
|
|
5
|
-
def initialize(dependencies, options={})
|
5
|
+
def initialize(dependencies, options = {})
|
6
6
|
super(dependencies, options)
|
7
7
|
|
8
8
|
default_columns = %w[name version licenses]
|
9
|
-
if @columns.empty?
|
10
|
-
@columns = default_columns
|
11
|
-
end
|
9
|
+
@columns = default_columns if @columns.empty?
|
12
10
|
end
|
13
11
|
end
|
14
12
|
end
|