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
@@ -1,27 +1,27 @@
|
|
1
1
|
module LicenseFinder
|
2
2
|
class BowerPackage < Package
|
3
|
-
def initialize(bower_module, options={})
|
4
|
-
spec = bower_module.fetch(
|
3
|
+
def initialize(bower_module, options = {})
|
4
|
+
spec = bower_module.fetch('pkgMeta', {})
|
5
5
|
|
6
6
|
if spec.empty?
|
7
|
-
endpoint = bower_module.fetch(
|
8
|
-
name = endpoint[
|
9
|
-
version = endpoint[
|
7
|
+
endpoint = bower_module.fetch('endpoint', {})
|
8
|
+
name = endpoint['name']
|
9
|
+
version = endpoint['target']
|
10
10
|
else
|
11
|
-
name = spec[
|
12
|
-
version = spec[
|
11
|
+
name = spec['name']
|
12
|
+
version = spec['version']
|
13
13
|
end
|
14
14
|
|
15
15
|
super(
|
16
16
|
name,
|
17
17
|
version,
|
18
18
|
options.merge(
|
19
|
-
summary: spec[
|
20
|
-
description: spec[
|
21
|
-
homepage: spec[
|
19
|
+
summary: spec['description'],
|
20
|
+
description: spec['readme'],
|
21
|
+
homepage: spec['homepage'],
|
22
22
|
spec_licenses: Package.license_names_from_standard_spec(spec),
|
23
|
-
install_path: bower_module[
|
24
|
-
missing: bower_module[
|
23
|
+
install_path: bower_module['canonicalDir'],
|
24
|
+
missing: bower_module['missing']
|
25
25
|
)
|
26
26
|
)
|
27
27
|
end
|
@@ -1,24 +1,24 @@
|
|
1
|
-
require
|
1
|
+
require 'bundler'
|
2
2
|
|
3
3
|
module LicenseFinder
|
4
4
|
class Bundler < PackageManager
|
5
|
-
def initialize
|
5
|
+
def initialize(options = {})
|
6
6
|
super
|
7
7
|
@ignored_groups = options[:ignored_groups]
|
8
|
-
@definition
|
8
|
+
@definition = options[:definition] # dependency injection for tests
|
9
9
|
end
|
10
10
|
|
11
11
|
def current_packages
|
12
12
|
logger.log self.class, "including groups #{included_groups.inspect}"
|
13
13
|
details.map do |gem_detail, bundle_detail|
|
14
14
|
BundlerPackage.new(gem_detail, bundle_detail, logger: logger).tap do |package|
|
15
|
-
|
15
|
+
log_package_dependencies package
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
def self.package_management_command
|
21
|
-
|
21
|
+
'bundle'
|
22
22
|
end
|
23
23
|
|
24
24
|
private
|
@@ -27,12 +27,12 @@ module LicenseFinder
|
|
27
27
|
|
28
28
|
def definition
|
29
29
|
# DI
|
30
|
-
@definition ||= ::Bundler::Definition.build(
|
30
|
+
@definition ||= ::Bundler::Definition.build(detected_package_path, lockfile_path, nil)
|
31
31
|
end
|
32
32
|
|
33
33
|
def details
|
34
34
|
gem_details.map do |gem_detail|
|
35
|
-
bundle_detail = bundler_details.detect { |
|
35
|
+
bundle_detail = bundler_details.detect { |bundler_detail| bundler_detail.name == gem_detail.name }
|
36
36
|
[gem_detail, bundle_detail]
|
37
37
|
end
|
38
38
|
end
|
@@ -49,12 +49,24 @@ module LicenseFinder
|
|
49
49
|
definition.groups - ignored_groups.map(&:to_sym)
|
50
50
|
end
|
51
51
|
|
52
|
-
def
|
53
|
-
project_path.join(
|
52
|
+
def possible_package_paths
|
53
|
+
[project_path.join('Gemfile')]
|
54
54
|
end
|
55
55
|
|
56
56
|
def lockfile_path
|
57
57
|
project_path.join('Gemfile.lock')
|
58
58
|
end
|
59
|
+
|
60
|
+
def log_package_dependencies(package)
|
61
|
+
dependencies = package.children
|
62
|
+
if dependencies.empty?
|
63
|
+
logger.log self.class, format("package '%s' has no dependencies", package.name)
|
64
|
+
else
|
65
|
+
logger.log self.class, format("package '%s' has dependencies:", package.name)
|
66
|
+
dependencies.each do |dep|
|
67
|
+
logger.log self.class, format('- %s', dep)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
59
71
|
end
|
60
72
|
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module LicenseFinder
|
4
|
+
class Carthage < PackageManager
|
5
|
+
class CarthageError < RuntimeError; end
|
6
|
+
|
7
|
+
def current_packages
|
8
|
+
cartfile.each_line.map do |line|
|
9
|
+
name, version = name_version_from_line line
|
10
|
+
|
11
|
+
CarthagePackage.new(
|
12
|
+
name,
|
13
|
+
version,
|
14
|
+
license_text(name),
|
15
|
+
logger: logger,
|
16
|
+
install_path: project_checkout(name)
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.package_management_command
|
22
|
+
LicenseFinder::Platform.darwin? ? 'carthage' : nil
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def cartfile
|
28
|
+
if File.exist?(resolved_path)
|
29
|
+
@cartfile ||= IO.read(resolved_path)
|
30
|
+
else
|
31
|
+
raise CarthageError, 'No Cartfile.resolved found.
|
32
|
+
Please install your dependencies first.'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def possible_package_paths
|
37
|
+
[public_dependency_path]
|
38
|
+
end
|
39
|
+
|
40
|
+
def public_dependency_path
|
41
|
+
project_path.join('Cartfile')
|
42
|
+
end
|
43
|
+
|
44
|
+
def resolved_path
|
45
|
+
project_path.join('Cartfile.resolved')
|
46
|
+
end
|
47
|
+
|
48
|
+
def project_checkout(name)
|
49
|
+
project_path.join('Carthage', 'Checkouts', name)
|
50
|
+
end
|
51
|
+
|
52
|
+
def license_text(name)
|
53
|
+
license_path = license_pattern(name).find { |f| File.exist?(f) }
|
54
|
+
license_path.nil? ? nil : IO.read(license_path)
|
55
|
+
end
|
56
|
+
|
57
|
+
def license_pattern(name)
|
58
|
+
checkout_path = project_checkout(name)
|
59
|
+
Dir.glob(checkout_path.join('LICENSE*'), File::FNM_CASEFOLD)
|
60
|
+
end
|
61
|
+
|
62
|
+
def name_version_from_line(cartfile_line)
|
63
|
+
cartfile_line.split(' ')[1, 2].map { |f| f.split('/').last.delete('"').gsub('.git', '') }
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module LicenseFinder
|
2
|
+
class CarthagePackage < Package
|
3
|
+
def initialize(name, version, license_text, options = {})
|
4
|
+
super(name, version, options)
|
5
|
+
@license = License.find_by_text(license_text.to_s)
|
6
|
+
end
|
7
|
+
|
8
|
+
def licenses_from_spec
|
9
|
+
[@license].compact
|
10
|
+
end
|
11
|
+
|
12
|
+
def package_manager
|
13
|
+
'Carthage'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
require
|
1
|
+
require 'json'
|
2
2
|
|
3
3
|
module LicenseFinder
|
4
4
|
class CocoaPods < PackageManager
|
5
5
|
def current_packages
|
6
6
|
podfile = YAML.load_file(lockfile_path)
|
7
7
|
|
8
|
-
podfile[
|
8
|
+
podfile['PODS'].map do |pod|
|
9
9
|
pod = pod.keys.first if pod.is_a?(Hash)
|
10
10
|
|
11
11
|
name, version = pod.scan(/(.*)\s\((.*)\)/).flatten
|
@@ -20,34 +20,34 @@ module LicenseFinder
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def self.package_management_command
|
23
|
-
LicenseFinder::Platform.darwin? ?
|
23
|
+
LicenseFinder::Platform.darwin? ? 'pod' : nil
|
24
24
|
end
|
25
25
|
|
26
26
|
private
|
27
27
|
|
28
|
-
def
|
29
|
-
project_path.join(
|
28
|
+
def possible_package_paths
|
29
|
+
[project_path.join('Podfile')]
|
30
30
|
end
|
31
31
|
|
32
32
|
def lockfile_path
|
33
|
-
project_path.join(
|
33
|
+
project_path.join('Podfile.lock')
|
34
34
|
end
|
35
35
|
|
36
36
|
def license_texts
|
37
37
|
# package name => license text
|
38
|
-
@license_texts ||= read_plist(acknowledgements_path)[
|
39
|
-
|
38
|
+
@license_texts ||= read_plist(acknowledgements_path)['PreferenceSpecifiers']
|
39
|
+
.each_with_object({}) { |hash, memo| memo[hash['Title']] = hash['FooterText'] }
|
40
40
|
end
|
41
41
|
|
42
42
|
def acknowledgements_path
|
43
|
-
search_paths = [
|
44
|
-
|
45
|
-
|
43
|
+
search_paths = ['Pods/Pods-acknowledgements.plist',
|
44
|
+
'Pods/Target Support Files/Pods/Pods-acknowledgements.plist',
|
45
|
+
'Pods/Target Support Files/Pods-*/Pods-*-acknowledgements.plist']
|
46
46
|
|
47
|
-
Dir[*search_paths.map {|path| File.join(project_path, path) }].first
|
47
|
+
Dir[*search_paths.map { |path| File.join(project_path, path) }].first
|
48
48
|
end
|
49
49
|
|
50
|
-
def read_plist
|
50
|
+
def read_plist(pathname)
|
51
51
|
JSON.parse(`plutil -convert json -o - '#{pathname}'`)
|
52
52
|
end
|
53
53
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative 'conan_info_parser'
|
2
|
+
|
3
|
+
module LicenseFinder
|
4
|
+
class Conan < PackageManager
|
5
|
+
def possible_package_paths
|
6
|
+
[project_path.join('conanfile.txt')]
|
7
|
+
end
|
8
|
+
|
9
|
+
def current_packages
|
10
|
+
install_command = 'conan install'
|
11
|
+
info_command = 'conan info'
|
12
|
+
Dir.chdir(project_path) { Cmd.run(install_command) }
|
13
|
+
info_output, _stderr, _status = Dir.chdir(project_path) { Cmd.run(info_command) }
|
14
|
+
|
15
|
+
info_parser = ConanInfoParser.new
|
16
|
+
|
17
|
+
deps = info_parser.parse(info_output)
|
18
|
+
deps.map do |dep|
|
19
|
+
name, version = dep['name'].split('@').first.split('/')
|
20
|
+
url = dep['URL']
|
21
|
+
license_file_path = Dir.glob("#{project_path}/licenses/#{name}/**/LICENSE*").first
|
22
|
+
ConanPackage.new(name, version, File.open(license_file_path).read, url) unless name == 'PROJECT'
|
23
|
+
end.compact
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module LicenseFinder
|
2
|
+
class ConanInfoParser
|
3
|
+
def parse(info)
|
4
|
+
@lines = info.lines.map(&:chomp)
|
5
|
+
@state = :project_level # state of the state machine
|
6
|
+
@projects = [] # list of projects
|
7
|
+
@current_project = nil # current project being populated in the SM
|
8
|
+
@current_vals = [] # current val list being populate in the SM
|
9
|
+
@current_key = nil # current key to be associated with the current val
|
10
|
+
while (line = @lines.shift)
|
11
|
+
next if line == ''
|
12
|
+
case @state
|
13
|
+
when :project_level
|
14
|
+
@current_project = {}
|
15
|
+
@current_project['name'] = line.strip
|
16
|
+
@state = :key_val
|
17
|
+
when :key_val
|
18
|
+
parse_key_val(line)
|
19
|
+
when :val_list
|
20
|
+
parse_val_list(line)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
wrap_up
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def parse_key_val(line)
|
29
|
+
key, val = key_val(line)
|
30
|
+
if val
|
31
|
+
@current_project[key] = val
|
32
|
+
elsif line.start_with?(' ')
|
33
|
+
@current_key = key
|
34
|
+
@current_vals = []
|
35
|
+
@state = :val_list
|
36
|
+
else
|
37
|
+
change_to_new_project_state line
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def parse_val_list(line)
|
42
|
+
if val_list_level(line)
|
43
|
+
@current_vals << line.strip
|
44
|
+
else
|
45
|
+
@current_project[@current_key] = @current_vals
|
46
|
+
if line.start_with?(' ')
|
47
|
+
@state = :key_val
|
48
|
+
@lines.unshift(line)
|
49
|
+
else
|
50
|
+
change_to_new_project_state line
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def wrap_up
|
56
|
+
if @current_vals.count && @current_key then @current_project[@current_key] = @current_vals end
|
57
|
+
@projects << @current_project
|
58
|
+
end
|
59
|
+
|
60
|
+
def val_list_level(line)
|
61
|
+
line.start_with?(' ')
|
62
|
+
end
|
63
|
+
|
64
|
+
def change_to_new_project_state(line)
|
65
|
+
@state = :project_level
|
66
|
+
@projects << @current_project
|
67
|
+
@lines.unshift(line)
|
68
|
+
end
|
69
|
+
|
70
|
+
def key_val(info)
|
71
|
+
info.split(':', 2).map(&:strip!)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module LicenseFinder
|
2
|
+
class ConanPackage < Package
|
3
|
+
def initialize(name, version, license_text, url, options = {})
|
4
|
+
super(name, version, options)
|
5
|
+
@license = License.find_by_text(license_text.to_s)
|
6
|
+
@homepage = url
|
7
|
+
end
|
8
|
+
|
9
|
+
def licenses_from_spec
|
10
|
+
[@license].compact
|
11
|
+
end
|
12
|
+
|
13
|
+
def package_manager
|
14
|
+
'Conan'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'toml'
|
2
|
+
|
3
|
+
module LicenseFinder
|
4
|
+
class Dep < PackageManager
|
5
|
+
def possible_package_paths
|
6
|
+
[project_path.join('Gopkg.lock')]
|
7
|
+
end
|
8
|
+
|
9
|
+
def current_packages
|
10
|
+
toml = TOML.load_file(detected_package_path)
|
11
|
+
projects = toml['projects']
|
12
|
+
projects.map do |project|
|
13
|
+
GoPackage.from_dependency({
|
14
|
+
'ImportPath' => project['name'],
|
15
|
+
'InstallPath' => project_path.join('vendor', project['name']),
|
16
|
+
'Rev' => project['revision']
|
17
|
+
}, nil, true)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.takes_priority_over
|
22
|
+
Go15VendorExperiment
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.prepare_command
|
26
|
+
'dep ensure'
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.package_management_command
|
30
|
+
'dep'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module LicenseFinder
|
2
|
+
class Glide < PackageManager
|
3
|
+
def possible_package_paths
|
4
|
+
[project_path.join('src', 'glide.lock'), project_path.join('glide.lock')]
|
5
|
+
end
|
6
|
+
|
7
|
+
def current_packages
|
8
|
+
YAML.load_file(detected_package_path).fetch('imports').map do |package_hash|
|
9
|
+
import_path = package_hash.fetch('name')
|
10
|
+
GoPackage.from_dependency({
|
11
|
+
'ImportPath' => import_path,
|
12
|
+
'InstallPath' => project_path.join('src', 'vendor', import_path),
|
13
|
+
'Rev' => package_hash.fetch('version')
|
14
|
+
}, nil, true)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.takes_priority_over
|
19
|
+
Go15VendorExperiment
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.package_management_command
|
23
|
+
'glide'
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.prepare_command
|
27
|
+
'glide install'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|