license_finder 1.2 → 2.0.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -1
- data/CHANGELOG.rdoc +27 -0
- data/CONTRIBUTING.md +38 -0
- data/README.md +139 -159
- data/Rakefile +17 -13
- data/features/features/cli_spec.rb +43 -0
- data/features/features/configure/add_dependencies_spec.rb +37 -0
- data/features/features/configure/approve_dependencies_spec.rb +30 -0
- data/features/features/configure/assign_licenses_spec.rb +20 -0
- data/features/features/configure/ignore_dependencies_spec.rb +35 -0
- data/features/features/configure/ignore_groups_spec.rb +31 -0
- data/features/features/configure/name_project_spec.rb +32 -0
- data/features/features/configure/whitelist_licenses_spec.rb +40 -0
- data/features/features/package_managers/bower_spec.rb +14 -0
- data/features/features/package_managers/cocoapods_spec.rb +14 -0
- data/features/features/package_managers/gradle_spec.rb +14 -0
- data/features/features/package_managers/maven_spec.rb +14 -0
- data/features/features/package_managers/npm_spec.rb +14 -0
- data/features/features/package_managers/pip_spec.rb +14 -0
- data/features/features/report/csv_spec.rb +17 -0
- data/features/features/report/html_spec.rb +50 -0
- data/{spec → features}/fixtures/Podfile +0 -0
- data/{spec → features}/fixtures/build.gradle +0 -0
- data/{spec → features}/fixtures/pom.xml +0 -0
- data/features/support/testing_dsl.rb +295 -0
- data/lib/license_finder.rb +16 -50
- data/lib/license_finder/cli.rb +13 -253
- data/lib/license_finder/cli/approvals.rb +26 -0
- data/lib/license_finder/cli/base.rb +20 -0
- data/lib/license_finder/cli/dependencies.rb +39 -0
- data/lib/license_finder/cli/ignored_dependencies.rb +30 -0
- data/lib/license_finder/cli/ignored_groups.rb +30 -0
- data/lib/license_finder/cli/licenses.rb +24 -0
- data/lib/license_finder/cli/main.rb +82 -0
- data/lib/license_finder/cli/makes_decisions.rb +48 -0
- data/lib/license_finder/cli/patched_thor.rb +34 -0
- data/lib/license_finder/cli/project_name.rb +31 -0
- data/lib/license_finder/cli/whitelist.rb +32 -0
- data/lib/license_finder/configuration.rb +14 -145
- data/lib/license_finder/decision_applier.rb +46 -0
- data/lib/license_finder/decisions.rb +174 -0
- data/lib/license_finder/license.rb +13 -32
- data/lib/license_finder/license/definitions.rb +15 -13
- data/lib/license_finder/license/template.rb +1 -1
- data/lib/{data/licenses → license_finder/license/templates}/Apache2.txt +0 -0
- data/lib/{data/licenses → license_finder/license/templates}/BSD.txt +0 -0
- data/lib/{data/licenses → license_finder/license/templates}/GPLv2.txt +0 -0
- data/lib/{data/licenses → license_finder/license/templates}/ISC.txt +0 -0
- data/lib/{data/licenses → license_finder/license/templates}/LGPL.txt +0 -0
- data/lib/{data/licenses → license_finder/license/templates}/MIT.txt +0 -0
- data/lib/{data/licenses → license_finder/license/templates}/NewBSD.txt +0 -0
- data/lib/{data/licenses → license_finder/license/templates}/Python.txt +0 -0
- data/lib/{data/licenses → license_finder/license/templates}/Ruby.txt +0 -0
- data/lib/{data/licenses → license_finder/license/templates}/SimplifiedBSD.txt +0 -0
- data/lib/license_finder/package.rb +77 -7
- data/lib/license_finder/package_manager.rb +43 -0
- data/lib/license_finder/package_managers/bower.rb +1 -1
- data/lib/license_finder/package_managers/bower_package.rb +23 -44
- data/lib/license_finder/package_managers/bundler.rb +4 -7
- data/lib/license_finder/package_managers/bundler_package.rb +14 -31
- data/lib/license_finder/package_managers/cocoa_pods.rb +1 -1
- data/lib/license_finder/package_managers/cocoa_pods_package.rb +2 -10
- data/lib/license_finder/package_managers/gradle.rb +6 -2
- data/lib/license_finder/package_managers/gradle_package.rb +6 -30
- data/lib/license_finder/package_managers/manual_package.rb +25 -0
- data/lib/license_finder/package_managers/maven_package.rb +8 -37
- data/lib/license_finder/package_managers/npm.rb +16 -4
- data/lib/license_finder/package_managers/npm_package.rb +12 -43
- data/lib/license_finder/package_managers/pip_package.rb +17 -37
- data/lib/license_finder/platform.rb +0 -16
- data/lib/license_finder/possible_license_file.rb +9 -14
- data/lib/license_finder/possible_license_files.rb +1 -5
- data/lib/license_finder/report.rb +26 -0
- data/lib/license_finder/reports/csv_report.rb +58 -0
- data/lib/license_finder/reports/erb_report.rb +61 -0
- data/lib/license_finder/reports/html_report.rb +10 -1
- data/lib/license_finder/reports/markdown_report.rb +7 -1
- data/lib/license_finder/reports/templates/bootstrap.css +9 -0
- data/lib/license_finder/reports/templates/html_report.erb +105 -0
- data/lib/{templates → license_finder/reports/templates}/markdown_report.erb +7 -7
- data/lib/license_finder/reports/text_report.rb +5 -3
- data/lib/license_finder/version.rb +3 -0
- data/license_finder.gemspec +2 -6
- data/release/instructions.md +8 -0
- data/spec/feature_helper.rb +11 -0
- data/spec/fixtures/config/license_finder.yml +3 -0
- data/spec/fixtures/{nested_readme/vendor/README → license_directory/LICENSE/Apache.txt} +0 -0
- data/spec/lib/license_finder/cli/approvals_spec.rb +63 -0
- data/spec/lib/license_finder/cli/dependencies_spec.rb +59 -0
- data/spec/lib/license_finder/cli/ignored_dependencies_spec.rb +47 -0
- data/spec/lib/license_finder/cli/ignored_groups_spec.rb +40 -0
- data/spec/lib/license_finder/cli/licenses_spec.rb +60 -0
- data/spec/lib/license_finder/cli/main_spec.rb +110 -0
- data/spec/lib/license_finder/cli/project_name_spec.rb +40 -0
- data/spec/lib/license_finder/cli/whitelist_spec.rb +58 -0
- data/spec/lib/license_finder/configuration_spec.rb +46 -191
- data/spec/lib/license_finder/decision_applier_spec.rb +65 -0
- data/spec/lib/license_finder/decisions_spec.rb +347 -0
- data/spec/lib/license_finder/license/definitions_spec.rb +1 -7
- data/spec/lib/license_finder/license_spec.rb +2 -30
- data/spec/lib/license_finder/package_manager_spec.rb +22 -0
- data/spec/lib/license_finder/package_managers/bower_package_spec.rb +33 -66
- data/spec/lib/license_finder/package_managers/bundler_package_spec.rb +7 -71
- data/spec/lib/license_finder/package_managers/cocoa_pods_package_spec.rb +8 -11
- data/spec/lib/license_finder/package_managers/gradle_package_spec.rb +28 -32
- data/spec/lib/license_finder/package_managers/gradle_spec.rb +18 -23
- data/spec/lib/license_finder/package_managers/maven_package_spec.rb +20 -43
- data/spec/lib/license_finder/package_managers/npm_package_spec.rb +22 -73
- data/spec/lib/license_finder/package_managers/npm_spec.rb +18 -21
- data/spec/lib/license_finder/package_managers/pip_package_spec.rb +24 -63
- data/spec/lib/license_finder/package_spec.rb +121 -0
- data/spec/lib/license_finder/possible_license_file_spec.rb +2 -3
- data/spec/lib/license_finder/possible_license_files_spec.rb +18 -22
- data/spec/lib/license_finder/reports/csv_report_spec.rb +26 -0
- data/spec/lib/license_finder/reports/html_report_spec.rb +39 -22
- data/spec/lib/license_finder/reports/markdown_report_spec.rb +8 -16
- data/spec/lib/license_finder/reports/text_report_spec.rb +21 -12
- data/spec/spec_helper.rb +1 -4
- data/spec/support/shared_examples_for_package.rb +0 -11
- data/spec/support/shared_examples_for_package_manager.rb +1 -0
- data/spec/support/stdout_helpers.rb +4 -11
- metadata +73 -158
- data/db/migrate/201303290935_create_dependencies.rb +0 -14
- data/db/migrate/201303291155_create_licenses.rb +0 -13
- data/db/migrate/201303291402_create_approvals.rb +0 -13
- data/db/migrate/201303291456_create_ancestries.rb +0 -9
- data/db/migrate/201303291519_create_bundler_groups.rb +0 -13
- data/db/migrate/201303291720_move_manual_from_approvals_to_licenses.rb +0 -11
- data/db/migrate/201303291753_allow_null_license_names.rb +0 -7
- data/db/migrate/201304011027_allow_null_dependency_version.rb +0 -7
- data/db/migrate/201304020947_change_table_name_licenses_to_license_aliases.rb +0 -5
- data/db/migrate/201304181524_add_manual_to_dependencies.rb +0 -7
- data/db/migrate/201307250917_add_license_manual_to_dependencies.rb +0 -7
- data/db/migrate/201307251004_data_fix_manual_licenses.rb +0 -15
- data/db/migrate/201307251107_reassociate_license.rb +0 -23
- data/db/migrate/201307251340_remove_manual_from_license_aliases.rb +0 -7
- data/db/migrate/201311192002_add_manually_approved_to_dependencies.rb +0 -7
- data/db/migrate/201311192003_reassociate_manual_approval.rb +0 -13
- data/db/migrate/201311192010_drop_approvals.rb +0 -5
- data/db/migrate/201401302113_re_reassociate_license.rb +0 -23
- data/db/migrate/201403181732_rename_manual_fields.rb +0 -10
- data/db/migrate/201403190028_add_manual_approvals.rb +0 -22
- data/db/migrate/201403191419_add_timestamps_to_manual_approvals.rb +0 -15
- data/db/migrate/201403191645_remove_license_aliases.rb +0 -23
- data/db/migrate/201410031451_rename_dependency_license_name.rb +0 -6
- data/features/cli.feature +0 -37
- data/features/cocoapods_dependencies.feature +0 -10
- data/features/configure_bundler_groups.feature +0 -23
- data/features/configure_ignore_dependencies.feature +0 -16
- data/features/configure_project_name.feature +0 -10
- data/features/configure_whitelist.feature +0 -27
- data/features/gradle_dependencies.feature +0 -9
- data/features/manually_added.feature +0 -19
- data/features/manually_approved.feature +0 -10
- data/features/manually_assigned_license.feature +0 -16
- data/features/maven_dependencies.feature +0 -9
- data/features/multiple_licenses.feature +0 -9
- data/features/node_dependencies.feature +0 -9
- data/features/python_dependencies.feature +0 -9
- data/features/report_csv.feature +0 -15
- data/features/report_html.feature +0 -24
- data/features/step_definitions/cli_steps.rb +0 -51
- data/features/step_definitions/cocoapod_steps.rb +0 -8
- data/features/step_definitions/configure_bundler_groups_steps.rb +0 -30
- data/features/step_definitions/configure_ignore_dependencies.rb +0 -35
- data/features/step_definitions/configure_project_name_steps.rb +0 -3
- data/features/step_definitions/configure_whitelist_steps.rb +0 -45
- data/features/step_definitions/gradle_steps.rb +0 -8
- data/features/step_definitions/manually_added_steps.rb +0 -28
- data/features/step_definitions/manually_approved_steps.rb +0 -24
- data/features/step_definitions/manually_assigned_license_steps.rb +0 -34
- data/features/step_definitions/maven_steps.rb +0 -8
- data/features/step_definitions/multiple_licenses_steps.rb +0 -14
- data/features/step_definitions/node_steps.rb +0 -8
- data/features/step_definitions/python_steps.rb +0 -8
- data/features/step_definitions/report_csv_steps.rb +0 -20
- data/features/step_definitions/report_html_steps.rb +0 -60
- data/features/step_definitions/shared_steps.rb +0 -307
- data/lib/data/license_finder.example.yml +0 -12
- data/lib/license_finder/dependency_manager.rb +0 -92
- data/lib/license_finder/package_saver.rb +0 -44
- data/lib/license_finder/reports/dependency_report.rb +0 -34
- data/lib/license_finder/reports/detailed_text_report.rb +0 -19
- data/lib/license_finder/reports/formatted_report.rb +0 -40
- data/lib/license_finder/reports/reporter.rb +0 -27
- data/lib/license_finder/tables.rb +0 -9
- data/lib/license_finder/tables/bundler_group.rb +0 -7
- data/lib/license_finder/tables/dependency.rb +0 -113
- data/lib/license_finder/tables/manual_approval.rb +0 -13
- data/lib/license_finder/yml_to_sql.rb +0 -117
- data/lib/templates/html_report.erb +0 -117
- data/lib/templates/text_report.erb +0 -3
- data/release/gem_version.rb +0 -3
- data/release/manual_instructions.md +0 -29
- data/release/publish.sh +0 -32
- data/spec/fixtures/APACHE-2-LICENSE +0 -202
- data/spec/fixtures/GPLv2 +0 -339
- data/spec/fixtures/ISC-LICENSE +0 -10
- data/spec/fixtures/MIT-LICENSE +0 -22
- data/spec/fixtures/MIT-LICENSE-with-varied-disclaimer +0 -22
- data/spec/fixtures/README-with-MIT-LICENSE +0 -222
- data/spec/fixtures/license_directory/LICENSE/BSD-2-Clause.txt +0 -25
- data/spec/fixtures/license_directory/LICENSE/GPL-2.0.txt +0 -339
- data/spec/fixtures/license_directory/LICENSE/LICENSE +0 -191
- data/spec/fixtures/license_directory/LICENSE/MIT.txt +0 -21
- data/spec/fixtures/license_directory/LICENSE/RUBY.txt +0 -60
- data/spec/fixtures/mit_licensed_gem/LICENSE +0 -22
- data/spec/fixtures/other_licensed_gem/LICENSE +0 -3
- data/spec/fixtures/readme/Project ReadMe b/data/spec/fixtures/readme/Project → ReadMe +0 -0
- data/spec/fixtures/readme/README +0 -0
- data/spec/fixtures/readme/Readme.markdown +0 -0
- data/spec/lib/license_finder/cli_spec.rb +0 -298
- data/spec/lib/license_finder/dependency_manager_spec.rb +0 -198
- data/spec/lib/license_finder/package_saver_spec.rb +0 -82
- data/spec/lib/license_finder/reports/detailed_text_report_spec.rb +0 -33
- data/spec/lib/license_finder/reports/reporter_spec.rb +0 -33
- data/spec/lib/license_finder/tables/dependency_spec.rb +0 -196
- data/spec/lib/license_finder/yml_to_sql_spec.rb +0 -123
- data/spec/lib/license_finder_spec.rb +0 -16
@@ -1,5 +1,29 @@
|
|
1
1
|
module LicenseFinder
|
2
|
+
# Super-class for the different package managers
|
3
|
+
# (Bundler, NPM, Pip, etc.)
|
4
|
+
#
|
5
|
+
# For guidance on adding a new package manager use the shared behavior
|
6
|
+
#
|
7
|
+
# it_behaves_like "a PackageManager"
|
8
|
+
#
|
9
|
+
# Additional guidelines are:
|
10
|
+
#
|
11
|
+
# - implement #current_packages, to return a list of `Package`s this package manager is tracking
|
12
|
+
# - implement #package_path, a `Pathname` which, if the file exists, indicates the package manager is in use on this project
|
13
|
+
#
|
2
14
|
class PackageManager
|
15
|
+
def self.package_managers
|
16
|
+
[Bundler, NPM, Pip, Bower, Maven, Gradle, CocoaPods]
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.current_packages(options)
|
20
|
+
package_managers.
|
21
|
+
map { |pm| pm.new(options) }.
|
22
|
+
select(&:active?).
|
23
|
+
map(&:current_packages_with_relations).
|
24
|
+
flatten
|
25
|
+
end
|
26
|
+
|
3
27
|
attr_reader :logger
|
4
28
|
|
5
29
|
def initialize options={}
|
@@ -11,6 +35,17 @@ module LicenseFinder
|
|
11
35
|
injected_package_path.exist?.tap { |is_active| logger.active self.class, is_active }
|
12
36
|
end
|
13
37
|
|
38
|
+
def current_packages_with_relations
|
39
|
+
packages = current_packages
|
40
|
+
packages.each do |parent|
|
41
|
+
parent.children.each do |child_name|
|
42
|
+
child = packages.detect { |child| child.name == child_name }
|
43
|
+
child.parents << parent.name if child
|
44
|
+
end
|
45
|
+
end
|
46
|
+
packages
|
47
|
+
end
|
48
|
+
|
14
49
|
private
|
15
50
|
|
16
51
|
def injected_package_path
|
@@ -18,3 +53,11 @@ module LicenseFinder
|
|
18
53
|
end
|
19
54
|
end
|
20
55
|
end
|
56
|
+
|
57
|
+
require 'license_finder/package_managers/bower'
|
58
|
+
require 'license_finder/package_managers/bundler'
|
59
|
+
require 'license_finder/package_managers/npm'
|
60
|
+
require 'license_finder/package_managers/pip'
|
61
|
+
require 'license_finder/package_managers/maven'
|
62
|
+
require 'license_finder/package_managers/cocoa_pods'
|
63
|
+
require 'license_finder/package_managers/gradle'
|
@@ -1,50 +1,29 @@
|
|
1
1
|
module LicenseFinder
|
2
2
|
class BowerPackage < Package
|
3
3
|
def initialize(bower_module, options={})
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
def children
|
30
|
-
[] # no way to determine child deps from bower (maybe?)
|
31
|
-
end
|
32
|
-
|
33
|
-
def groups
|
34
|
-
[] # no concept of dev/test groups in bower (maybe?)
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
attr_reader :bower_module
|
40
|
-
attr_reader :module_metadata
|
41
|
-
|
42
|
-
def install_path
|
43
|
-
bower_module["canonicalDir"]
|
44
|
-
end
|
45
|
-
|
46
|
-
def license_names_from_spec
|
47
|
-
Package.license_names_from_standard_spec(module_metadata)
|
4
|
+
spec = bower_module.fetch("pkgMeta", Hash.new)
|
5
|
+
|
6
|
+
if spec.empty?
|
7
|
+
endpoint = bower_module.fetch("endpoint", Hash.new)
|
8
|
+
name = endpoint["name"]
|
9
|
+
version = endpoint["target"]
|
10
|
+
else
|
11
|
+
name = spec["name"]
|
12
|
+
version = spec["version"]
|
13
|
+
end
|
14
|
+
|
15
|
+
super(
|
16
|
+
name,
|
17
|
+
version,
|
18
|
+
options.merge(
|
19
|
+
summary: spec["description"],
|
20
|
+
description: spec["readme"],
|
21
|
+
homepage: spec["homepage"],
|
22
|
+
spec_licenses: Package.license_names_from_standard_spec(spec),
|
23
|
+
install_path: bower_module["canonicalDir"],
|
24
|
+
missing: bower_module["missing"]
|
25
|
+
)
|
26
|
+
)
|
48
27
|
end
|
49
28
|
end
|
50
29
|
end
|
@@ -4,8 +4,8 @@ module LicenseFinder
|
|
4
4
|
class Bundler < PackageManager
|
5
5
|
def initialize options={}
|
6
6
|
super
|
7
|
-
@ignore_groups = options[:ignore_groups]
|
8
|
-
@definition = options[:definition]
|
7
|
+
@ignore_groups = options[:ignore_groups]
|
8
|
+
@definition = options[:definition] # dependency injection for tests
|
9
9
|
end
|
10
10
|
|
11
11
|
def current_packages
|
@@ -20,16 +20,13 @@ module LicenseFinder
|
|
20
20
|
|
21
21
|
private
|
22
22
|
|
23
|
+
attr_reader :ignore_groups
|
24
|
+
|
23
25
|
def definition
|
24
26
|
# DI
|
25
27
|
@definition ||= ::Bundler::Definition.build(package_path, lockfile_path, nil)
|
26
28
|
end
|
27
29
|
|
28
|
-
def ignore_groups
|
29
|
-
# DI
|
30
|
-
@ignore_groups ||= LicenseFinder.config.ignore_groups
|
31
|
-
end
|
32
|
-
|
33
30
|
def package_path
|
34
31
|
Pathname.new("Gemfile")
|
35
32
|
end
|
@@ -1,36 +1,19 @@
|
|
1
1
|
module LicenseFinder
|
2
2
|
class BundlerPackage < Package
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
def version
|
19
|
-
gem_def.version.to_s
|
20
|
-
end
|
21
|
-
|
22
|
-
def children
|
23
|
-
gem_def.dependencies.map(&:name)
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def install_path
|
29
|
-
gem_def.full_gem_path
|
30
|
-
end
|
31
|
-
|
32
|
-
def license_names_from_spec
|
33
|
-
gem_def.licenses
|
3
|
+
def initialize(spec, bundler_def, options={})
|
4
|
+
super(
|
5
|
+
spec.name,
|
6
|
+
spec.version.to_s,
|
7
|
+
options.merge(
|
8
|
+
summary: spec.summary,
|
9
|
+
description: spec.description,
|
10
|
+
homepage: spec.homepage,
|
11
|
+
children: spec.dependencies.map(&:name),
|
12
|
+
groups: Array(bundler_def && bundler_def.groups),
|
13
|
+
spec_licenses: spec.licenses,
|
14
|
+
install_path: spec.full_gem_path
|
15
|
+
)
|
16
|
+
)
|
34
17
|
end
|
35
18
|
end
|
36
19
|
end
|
@@ -33,7 +33,7 @@ module LicenseFinder
|
|
33
33
|
'Pods/Target Support Files/Pods' # cocoapods >= 0.34
|
34
34
|
]
|
35
35
|
|
36
|
-
directories.map { |dir| Pathname.new(
|
36
|
+
directories.map { |dir| Pathname.new(dir).join(filename) }.find(&:exist?)
|
37
37
|
end
|
38
38
|
|
39
39
|
def read_plist pathname
|
@@ -1,18 +1,10 @@
|
|
1
1
|
module LicenseFinder
|
2
2
|
class CocoaPodsPackage < Package
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
def initialize(name, version, license_text, options={})
|
7
|
-
super options
|
8
|
-
@name = name
|
9
|
-
@version = version
|
3
|
+
def initialize(name, version, license_text)
|
4
|
+
super(name, version)
|
10
5
|
@license_text = license_text
|
11
6
|
end
|
12
7
|
|
13
|
-
def groups; []; end
|
14
|
-
def children; []; end
|
15
|
-
|
16
8
|
def licenses
|
17
9
|
[License.find_by_text(@license_text.to_s) || default_license].to_set
|
18
10
|
end
|
@@ -2,8 +2,13 @@ require "xmlsimple"
|
|
2
2
|
|
3
3
|
module LicenseFinder
|
4
4
|
class Gradle < PackageManager
|
5
|
+
def initialize(options={})
|
6
|
+
super
|
7
|
+
@command = options[:gradle_command] || "gradle"
|
8
|
+
end
|
9
|
+
|
5
10
|
def current_packages
|
6
|
-
`#{
|
11
|
+
`#{@command} downloadLicenses`
|
7
12
|
|
8
13
|
xml = license_report.read
|
9
14
|
|
@@ -11,7 +16,6 @@ module LicenseFinder
|
|
11
16
|
'GroupTags' => { 'dependencies' => 'dependency' }
|
12
17
|
}
|
13
18
|
XmlSimple.xml_in(xml, options).fetch('dependency', []).map do |dep|
|
14
|
-
dep["license"].reject! { |l| l["name"] == "No license found" }
|
15
19
|
GradlePackage.new(dep, logger: logger)
|
16
20
|
end
|
17
21
|
end
|
@@ -1,36 +1,12 @@
|
|
1
1
|
module LicenseFinder
|
2
2
|
class GradlePackage < Package
|
3
|
-
|
3
|
+
def initialize(spec, options={})
|
4
|
+
_, name, version = spec["name"].split(":")
|
5
|
+
licenses = Array(spec["license"])
|
6
|
+
.map { |l| l["name"] }
|
7
|
+
.reject { |name| name == "No license found" }
|
4
8
|
|
5
|
-
|
6
|
-
super options
|
7
|
-
@gradle_dependency = gradle_dependency
|
8
|
-
@name = @gradle_dependency["name"].split(":")[1]
|
9
|
-
@version = @gradle_dependency["name"].split(":")[2]
|
10
|
-
end
|
11
|
-
|
12
|
-
def description
|
13
|
-
""
|
14
|
-
end
|
15
|
-
|
16
|
-
def summary
|
17
|
-
""
|
18
|
-
end
|
19
|
-
|
20
|
-
def homepage
|
21
|
-
""
|
22
|
-
end
|
23
|
-
|
24
|
-
def groups
|
25
|
-
[]
|
26
|
-
end
|
27
|
-
|
28
|
-
def children
|
29
|
-
[]
|
30
|
-
end
|
31
|
-
|
32
|
-
def license_names_from_spec
|
33
|
-
@gradle_dependency["license"].map { |l| l["name"] }
|
9
|
+
super(name, version, options.merge(spec_licenses: licenses))
|
34
10
|
end
|
35
11
|
end
|
36
12
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module LicenseFinder
|
2
|
+
class ManualPackage < Package
|
3
|
+
def ==(other)
|
4
|
+
eql? other
|
5
|
+
end
|
6
|
+
|
7
|
+
def eql?(other)
|
8
|
+
name == other.name # && version.to_s == other.version.to_s # ignore version
|
9
|
+
end
|
10
|
+
|
11
|
+
def hash
|
12
|
+
name.hash # ^ version.to_s.hash # ignore version
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def licenses_from_spec
|
18
|
+
Set.new
|
19
|
+
end
|
20
|
+
|
21
|
+
def licenses_from_files
|
22
|
+
Set.new
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -1,42 +1,13 @@
|
|
1
1
|
module LicenseFinder
|
2
2
|
class MavenPackage < Package
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
mvn_dependency["artifactId"]
|
12
|
-
end
|
13
|
-
|
14
|
-
def version
|
15
|
-
mvn_dependency["version"]
|
16
|
-
end
|
17
|
-
|
18
|
-
def description
|
19
|
-
""
|
20
|
-
end
|
21
|
-
|
22
|
-
def summary
|
23
|
-
""
|
24
|
-
end
|
25
|
-
|
26
|
-
def homepage
|
27
|
-
""
|
28
|
-
end
|
29
|
-
|
30
|
-
def groups
|
31
|
-
[]
|
32
|
-
end
|
33
|
-
|
34
|
-
def children
|
35
|
-
[]
|
36
|
-
end
|
37
|
-
|
38
|
-
def license_names_from_spec
|
39
|
-
mvn_dependency["licenses"].map { |l| l["name"] }
|
3
|
+
def initialize(spec, options={})
|
4
|
+
super(
|
5
|
+
spec["artifactId"],
|
6
|
+
spec["version"],
|
7
|
+
options.merge(
|
8
|
+
spec_licenses: Array(spec["licenses"]).map { |l| l["name"] }
|
9
|
+
)
|
10
|
+
)
|
40
11
|
end
|
41
12
|
end
|
42
13
|
end
|
@@ -2,15 +2,15 @@ require 'json'
|
|
2
2
|
|
3
3
|
module LicenseFinder
|
4
4
|
class NPM < PackageManager
|
5
|
-
DEPENDENCY_GROUPS = ["dependencies", "devDependencies"
|
5
|
+
DEPENDENCY_GROUPS = ["dependencies", "devDependencies"]
|
6
6
|
|
7
7
|
def current_packages
|
8
8
|
json = npm_json
|
9
9
|
dependencies = DEPENDENCY_GROUPS.map { |g| (json[g] || {}).values }.flatten(1).reject{ |d| d.is_a?(String) }
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
pkgs = {} # name => spec
|
12
|
+
dependencies.each { |d| recursive_dependencies(d, pkgs) }
|
13
|
+
pkgs.values.map { |d| NpmPackage.new(d, logger: logger) }
|
14
14
|
end
|
15
15
|
|
16
16
|
private
|
@@ -38,5 +38,17 @@ module LicenseFinder
|
|
38
38
|
def package_path
|
39
39
|
Pathname.new('package.json')
|
40
40
|
end
|
41
|
+
|
42
|
+
# node_module can be empty hash if it is included elsewhere
|
43
|
+
def recursive_dependencies(node_module, memo)
|
44
|
+
key = node_module['name']
|
45
|
+
memo[key] ||= {}
|
46
|
+
memo[key].merge!(node_module)
|
47
|
+
node_module.fetch('dependencies', {}).each do |dep_key, data|
|
48
|
+
data['name'] ||= dep_key
|
49
|
+
recursive_dependencies(data, memo)
|
50
|
+
end
|
51
|
+
memo
|
52
|
+
end
|
41
53
|
end
|
42
54
|
end
|
@@ -1,48 +1,17 @@
|
|
1
1
|
module LicenseFinder
|
2
2
|
class NpmPackage < Package
|
3
|
-
def initialize(
|
4
|
-
super
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
def summary
|
17
|
-
node_module["description"]
|
18
|
-
end
|
19
|
-
|
20
|
-
def description
|
21
|
-
node_module["readme"]
|
22
|
-
end
|
23
|
-
|
24
|
-
def homepage
|
25
|
-
node_module["homepage"]
|
26
|
-
end
|
27
|
-
|
28
|
-
def children
|
29
|
-
[] # no way to determine child deps from npm (maybe?)
|
30
|
-
end
|
31
|
-
|
32
|
-
def groups
|
33
|
-
[] # no concept of dev/test groups in npm (maybe?)
|
34
|
-
end
|
35
|
-
|
36
|
-
private
|
37
|
-
|
38
|
-
attr_reader :node_module
|
39
|
-
|
40
|
-
def install_path
|
41
|
-
node_module["path"]
|
42
|
-
end
|
43
|
-
|
44
|
-
def license_names_from_spec
|
45
|
-
Package.license_names_from_standard_spec(node_module)
|
3
|
+
def initialize(spec, options={})
|
4
|
+
super(
|
5
|
+
spec["name"],
|
6
|
+
spec["version"],
|
7
|
+
options.merge(
|
8
|
+
description: spec["description"],
|
9
|
+
homepage: spec["homepage"],
|
10
|
+
spec_licenses: Package.license_names_from_standard_spec(spec),
|
11
|
+
install_path: spec["path"],
|
12
|
+
children: spec.fetch("dependencies", {}).map { |_, d| d["name"] }
|
13
|
+
)
|
14
|
+
)
|
46
15
|
end
|
47
16
|
end
|
48
17
|
end
|