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
data/lib/license_finder/cli.rb
CHANGED
@@ -4,10 +4,8 @@ module LicenseFinder
|
|
4
4
|
end
|
5
5
|
|
6
6
|
require 'license_finder/cli/patched_thor'
|
7
|
-
|
8
7
|
require 'license_finder/cli/base'
|
9
8
|
require 'license_finder/cli/makes_decisions'
|
10
|
-
|
11
9
|
require 'license_finder/cli/whitelist'
|
12
10
|
require 'license_finder/cli/blacklist'
|
13
11
|
require 'license_finder/cli/dependencies'
|
@@ -16,5 +14,4 @@ require 'license_finder/cli/approvals'
|
|
16
14
|
require 'license_finder/cli/ignored_groups'
|
17
15
|
require 'license_finder/cli/ignored_dependencies'
|
18
16
|
require 'license_finder/cli/project_name'
|
19
|
-
|
20
17
|
require 'license_finder/cli/main'
|
@@ -5,16 +5,16 @@ module LicenseFinder
|
|
5
5
|
include MakesDecisions
|
6
6
|
|
7
7
|
auditable
|
8
|
-
desc
|
8
|
+
desc 'add DEPENDENCY...', 'Approve one or more dependencies by name'
|
9
9
|
def add(*names)
|
10
10
|
assert_some names
|
11
11
|
modifying { names.each { |name| decisions.approve(name, txn) } }
|
12
12
|
|
13
|
-
say "The #{names.join(
|
13
|
+
say "The #{names.join(', ')} dependency has been approved!", :green
|
14
14
|
end
|
15
15
|
|
16
16
|
auditable
|
17
|
-
desc
|
17
|
+
desc 'remove DEPENDENCY', 'Unapprove a dependency'
|
18
18
|
def remove(dep)
|
19
19
|
modifying { decisions.unapprove(dep, txn) }
|
20
20
|
|
@@ -3,8 +3,10 @@ require 'thor'
|
|
3
3
|
module LicenseFinder
|
4
4
|
module CLI
|
5
5
|
class Base < Thor
|
6
|
-
class_option :project_path,
|
7
|
-
|
6
|
+
class_option :project_path,
|
7
|
+
desc: 'Path to the project. Defaults to current working directory.'
|
8
|
+
class_option :decisions_file,
|
9
|
+
desc: 'Where decisions are saved. Defaults to doc/dependency_decisions.yml.'
|
8
10
|
|
9
11
|
no_commands do
|
10
12
|
def decisions
|
@@ -21,7 +23,7 @@ module LicenseFinder
|
|
21
23
|
end
|
22
24
|
|
23
25
|
def fail(message)
|
24
|
-
say
|
26
|
+
say(message) && exit(1)
|
25
27
|
end
|
26
28
|
|
27
29
|
def license_finder_config
|
@@ -36,7 +38,10 @@ module LicenseFinder
|
|
36
38
|
:pip_requirements_path,
|
37
39
|
:rebar_command,
|
38
40
|
:rebar_deps_dir,
|
39
|
-
:
|
41
|
+
:mix_command,
|
42
|
+
:mix_deps_dir,
|
43
|
+
:save,
|
44
|
+
:prepare
|
40
45
|
).merge(
|
41
46
|
logger: logger_config
|
42
47
|
)
|
@@ -57,15 +62,13 @@ module LicenseFinder
|
|
57
62
|
end
|
58
63
|
|
59
64
|
def assert_some(things)
|
60
|
-
unless things.any?
|
61
|
-
raise ArgumentError, "wrong number of arguments (0 for 1+)", caller
|
62
|
-
end
|
65
|
+
raise ArgumentError, 'wrong number of arguments (0 for 1+)', caller unless things.any?
|
63
66
|
end
|
64
67
|
|
65
68
|
def extract_options(*keys)
|
66
69
|
result = {}
|
67
70
|
keys.each do |key|
|
68
|
-
result[key.to_sym] = options[key.to_s] if options.
|
71
|
+
result[key.to_sym] = options[key.to_s] if options.key? key.to_s
|
69
72
|
end
|
70
73
|
result
|
71
74
|
end
|
@@ -4,26 +4,26 @@ module LicenseFinder
|
|
4
4
|
extend Subcommand
|
5
5
|
include MakesDecisions
|
6
6
|
|
7
|
-
desc
|
7
|
+
desc 'list', 'List all the blacklisted licenses'
|
8
8
|
def list
|
9
|
-
say
|
10
|
-
say_each(decisions.blacklisted
|
9
|
+
say 'Blacklisted Licenses:', :blue
|
10
|
+
say_each(decisions.blacklisted, &:name)
|
11
11
|
end
|
12
12
|
|
13
13
|
auditable
|
14
|
-
desc
|
14
|
+
desc 'add LICENSE...', 'Add one or more licenses to the blacklist'
|
15
15
|
def add(*licenses)
|
16
16
|
assert_some licenses
|
17
17
|
modifying { licenses.each { |l| decisions.blacklist(l, txn) } }
|
18
|
-
say "Added #{licenses.join(
|
18
|
+
say "Added #{licenses.join(', ')} to the license blacklist"
|
19
19
|
end
|
20
20
|
|
21
21
|
auditable
|
22
|
-
desc
|
22
|
+
desc 'remove LICENSE...', 'Remove one or more licenses from the blacklist'
|
23
23
|
def remove(*licenses)
|
24
24
|
assert_some licenses
|
25
25
|
modifying { licenses.each { |l| decisions.unblacklist(l, txn) } }
|
26
|
-
say "Removed #{licenses.join(
|
26
|
+
say "Removed #{licenses.join(', ')} from the license blacklist"
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -4,16 +4,16 @@ module LicenseFinder
|
|
4
4
|
extend Subcommand
|
5
5
|
include MakesDecisions
|
6
6
|
|
7
|
-
method_option :approve, type: :boolean, desc:
|
7
|
+
method_option :approve, type: :boolean, desc: 'Approve the added dependency'
|
8
8
|
auditable
|
9
|
-
desc
|
9
|
+
desc 'add DEPENDENCY LICENSE [VERSION] [--approve]', 'Add a dependency that is not managed by a package manager, optionally approving it at the same time'
|
10
10
|
def add(name, license, version = nil)
|
11
|
-
modifying
|
11
|
+
modifying do
|
12
12
|
decisions
|
13
13
|
.add_package(name, version, txn)
|
14
14
|
.license(name, license, txn)
|
15
15
|
decisions.approve(name, txn) if options[:approve]
|
16
|
-
|
16
|
+
end
|
17
17
|
if options[:approve]
|
18
18
|
say "The #{name} dependency has been added and approved!", :green
|
19
19
|
else
|
@@ -22,17 +22,17 @@ module LicenseFinder
|
|
22
22
|
end
|
23
23
|
|
24
24
|
auditable
|
25
|
-
desc
|
25
|
+
desc 'remove DEPENDENCY', 'Remove a dependency that is not managed by a package manager'
|
26
26
|
def remove(name)
|
27
27
|
modifying { decisions.remove_package(name, txn) }
|
28
28
|
|
29
29
|
say "The #{name} dependency has been removed.", :green
|
30
30
|
end
|
31
31
|
|
32
|
-
desc
|
32
|
+
desc 'list', 'List manually added dependencies'
|
33
33
|
def list
|
34
|
-
say
|
35
|
-
say_each(decisions.packages
|
34
|
+
say 'Manually Added Dependencies:', :blue
|
35
|
+
say_each(decisions.packages, &:name)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -4,14 +4,14 @@ module LicenseFinder
|
|
4
4
|
extend Subcommand
|
5
5
|
include MakesDecisions
|
6
6
|
|
7
|
-
desc
|
7
|
+
desc 'list', 'List all the ignored dependencies'
|
8
8
|
def list
|
9
|
-
say
|
9
|
+
say 'Ignored Dependencies:', :blue
|
10
10
|
say_each(decisions.ignored)
|
11
11
|
end
|
12
12
|
|
13
13
|
auditable
|
14
|
-
desc
|
14
|
+
desc 'add DEPENDENCY', 'Add a dependency to be ignored'
|
15
15
|
def add(dep)
|
16
16
|
modifying { decisions.ignore(dep, txn) }
|
17
17
|
|
@@ -19,7 +19,7 @@ module LicenseFinder
|
|
19
19
|
end
|
20
20
|
|
21
21
|
auditable
|
22
|
-
desc
|
22
|
+
desc 'remove DEPENDENCY', 'Remove a dependency from the ignored dependencies'
|
23
23
|
def remove(dep)
|
24
24
|
modifying { decisions.heed(dep, txn) }
|
25
25
|
|
@@ -4,14 +4,14 @@ module LicenseFinder
|
|
4
4
|
extend Subcommand
|
5
5
|
include MakesDecisions
|
6
6
|
|
7
|
-
desc
|
7
|
+
desc 'list', 'List all the ignored groups'
|
8
8
|
def list
|
9
|
-
say
|
9
|
+
say 'Ignored Groups:', :blue
|
10
10
|
say_each(decisions.ignored_groups)
|
11
11
|
end
|
12
12
|
|
13
13
|
auditable
|
14
|
-
desc
|
14
|
+
desc 'add GROUP', 'Add a group to be ignored'
|
15
15
|
def add(group)
|
16
16
|
modifying { decisions.ignore_group(group, txn) }
|
17
17
|
|
@@ -19,7 +19,7 @@ module LicenseFinder
|
|
19
19
|
end
|
20
20
|
|
21
21
|
auditable
|
22
|
-
desc
|
22
|
+
desc 'remove GROUP', 'Remove a group from the ignored groups'
|
23
23
|
def remove(group)
|
24
24
|
modifying { decisions.heed_group(group, txn) }
|
25
25
|
|
@@ -5,7 +5,7 @@ module LicenseFinder
|
|
5
5
|
include MakesDecisions
|
6
6
|
|
7
7
|
auditable
|
8
|
-
desc
|
8
|
+
desc 'add DEPENDENCY LICENSE', "Set a dependency's licenses, overwriting any license_finder has found"
|
9
9
|
def add(name, license)
|
10
10
|
modifying { decisions.license(name, license, txn) }
|
11
11
|
|
@@ -13,7 +13,7 @@ module LicenseFinder
|
|
13
13
|
end
|
14
14
|
|
15
15
|
auditable
|
16
|
-
desc
|
16
|
+
desc 'remove DEPENDENCY LICENSE', 'Remove a manually set license'
|
17
17
|
def remove(dep, lic)
|
18
18
|
modifying { decisions.unlicense(dep, lic, txn) }
|
19
19
|
|
@@ -15,27 +15,44 @@ module LicenseFinder
|
|
15
15
|
'html' => HtmlReport,
|
16
16
|
'markdown' => MarkdownReport,
|
17
17
|
'csv' => CsvReport
|
18
|
-
}
|
18
|
+
}.freeze
|
19
19
|
|
20
|
-
class_option :format, desc:
|
20
|
+
class_option :format, desc: 'The desired output format.', default: 'text', enum: FORMATS.keys
|
21
21
|
class_option :columns, type: :array, desc: "For text or CSV reports, which columns to print. Pick from: #{CsvReport::AVAILABLE_COLUMNS}", default: %w[name version licenses]
|
22
|
-
class_option :save, desc: "Save report to a file. Default: 'license_report.csv' in project root.", lazy_default:
|
23
|
-
class_option :go_full_version, desc:
|
24
|
-
class_option :gradle_include_groups, desc:
|
25
|
-
class_option :gradle_command,
|
26
|
-
|
27
|
-
|
28
|
-
class_option :
|
22
|
+
class_option :save, desc: "Save report to a file. Default: 'license_report.csv' in project root.", lazy_default: 'license_report'
|
23
|
+
class_option :go_full_version, desc: 'Whether dependency version should include full version. Only meaningful if used with a Go project. Defaults to false.'
|
24
|
+
class_option :gradle_include_groups, desc: 'Whether dependency name should include group id. Only meaningful if used with a Java/gradle project. Defaults to false.'
|
25
|
+
class_option :gradle_command,
|
26
|
+
desc: "Command to use when fetching gradle packages. Only meaningful if used with a Java/gradle project.
|
27
|
+
Defaults to 'gradlew' / 'gradlew.bat' if the wrapper is present, otherwise to 'gradle'."
|
28
|
+
class_option :maven_include_groups, desc: 'Whether dependency name should include group id. Only meaningful if used with a Java/maven project. Defaults to false.'
|
29
|
+
class_option :maven_options, desc: 'Maven options to append to command. Defaults to empty.'
|
30
|
+
class_option :pip_requirements_path, desc: 'Path to python requirements file. Defaults to requirements.txt.'
|
29
31
|
class_option :rebar_command, desc: "Command to use when fetching rebar packages. Only meaningful if used with a Erlang/rebar project. Defaults to 'rebar'."
|
30
32
|
class_option :rebar_deps_dir, desc: "Path to rebar dependencies directory. Only meaningful if used with a Erlang/rebar project. Defaults to 'deps'."
|
31
|
-
class_option :
|
32
|
-
class_option :
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
class_option :mix_command, desc: "Command to use when fetching packages through Mix. Only meaningful if used with a Mix project (i.e., Elixir or Erlang). Defaults to 'mix'."
|
34
|
+
class_option :mix_deps_dir, desc: "Path to Mix dependencies directory. Only meaningful if used with a Mix project (i.e., Elixir or Erlang). Defaults to 'deps'."
|
35
|
+
|
36
|
+
# Method options which are shared between report and action_item
|
37
|
+
def self.shared_options
|
38
|
+
method_option :debug,
|
39
|
+
aliases: '-d',
|
40
|
+
type: :boolean,
|
41
|
+
desc: 'Emit detailed info about what LicenseFinder is doing'
|
42
|
+
|
43
|
+
method_option :prepare,
|
44
|
+
aliases: '-p',
|
45
|
+
type: :boolean,
|
46
|
+
desc: 'Prepares the project first for license_finder',
|
47
|
+
default: false,
|
48
|
+
required: false
|
49
|
+
end
|
37
50
|
|
51
|
+
desc 'action_items', 'List unapproved dependencies (the default action for `license_finder`)'
|
52
|
+
method_option :quiet, aliases: '-q', type: :boolean, desc: 'Silences progress report', required: false
|
53
|
+
shared_options
|
38
54
|
def action_items
|
55
|
+
run_prepare_phase if prepare?
|
39
56
|
any_packages = license_finder.any_packages?
|
40
57
|
unapproved = license_finder.unapproved
|
41
58
|
blacklisted = license_finder.blacklisted
|
@@ -44,21 +61,21 @@ module LicenseFinder
|
|
44
61
|
say "\n"
|
45
62
|
|
46
63
|
unless any_packages
|
47
|
-
say
|
64
|
+
say 'No dependencies recognized!', :red
|
48
65
|
exit 0
|
49
66
|
end
|
50
67
|
|
51
68
|
if unapproved.empty?
|
52
|
-
say
|
69
|
+
say 'All dependencies are approved for use', :green
|
53
70
|
else
|
54
71
|
unless blacklisted.empty?
|
55
|
-
say
|
72
|
+
say 'Blacklisted dependencies:', :red
|
56
73
|
say report_of(blacklisted)
|
57
74
|
end
|
58
75
|
|
59
76
|
other_unapproved = unapproved - blacklisted
|
60
77
|
unless other_unapproved.empty?
|
61
|
-
say
|
78
|
+
say 'Dependencies that need approval:', :yellow
|
62
79
|
say report_of(other_unapproved)
|
63
80
|
end
|
64
81
|
|
@@ -68,31 +85,34 @@ module LicenseFinder
|
|
68
85
|
|
69
86
|
default_task :action_items
|
70
87
|
|
71
|
-
desc
|
88
|
+
desc 'report', "Print a report of the project's dependencies to stdout"
|
89
|
+
shared_options
|
90
|
+
method_option :recursive, aliases: '-r', type: :boolean, default: false,
|
91
|
+
desc: 'Recursively runs License Finder on all sub-projects'
|
72
92
|
|
93
|
+
method_option :subprojects, aliases: '-s', type: :array,
|
94
|
+
desc: "Generate a single report for multiple sub-projects. Ex: --subprojects='path/to/project1', 'path/to/project2'"
|
73
95
|
def report
|
74
96
|
logger_config[:quiet] = true
|
75
|
-
|
76
|
-
subproject_paths = options[:
|
77
|
-
subproject_paths = ProjectFinder.new(license_finder.config.project_path).find_projects if recursive?
|
97
|
+
subproject_paths = options[:subprojects]
|
98
|
+
subproject_paths = ProjectFinder.new(license_finder.config.project_path).find_projects if options[:recursive]
|
78
99
|
|
79
100
|
if subproject_paths && !subproject_paths.empty?
|
80
101
|
finder = LicenseAggregator.new(license_finder_config, subproject_paths)
|
81
102
|
report = MergedReport.new(finder.dependencies, options)
|
82
103
|
else
|
104
|
+
run_prepare_phase if prepare?
|
83
105
|
report = report_of(license_finder.acknowledged)
|
84
106
|
end
|
85
107
|
save? ? save_report(report, options[:save]) : say(report)
|
86
108
|
end
|
87
109
|
|
88
|
-
desc
|
89
|
-
|
110
|
+
desc 'version', 'Print the version of LicenseFinder'
|
90
111
|
def version
|
91
112
|
puts LicenseFinder::VERSION
|
92
113
|
end
|
93
114
|
|
94
|
-
desc
|
95
|
-
|
115
|
+
desc 'diff OLDFILE NEWFILE', 'Command to view the differences between two generated reports (csv).'
|
96
116
|
def diff(file1, file2)
|
97
117
|
f1 = IO.read(file1)
|
98
118
|
f2 = IO.read(file2)
|
@@ -100,14 +120,14 @@ module LicenseFinder
|
|
100
120
|
save? ? save_report(report, options[:save]) : say(report)
|
101
121
|
end
|
102
122
|
|
103
|
-
subcommand
|
104
|
-
subcommand
|
105
|
-
subcommand
|
106
|
-
subcommand
|
107
|
-
subcommand
|
108
|
-
subcommand
|
109
|
-
subcommand
|
110
|
-
subcommand
|
123
|
+
subcommand 'dependencies', Dependencies, 'Add or remove dependencies that your package managers are not aware of'
|
124
|
+
subcommand 'licenses', Licenses, "Set a dependency's licenses, if the licenses found by license_finder are missing or wrong"
|
125
|
+
subcommand 'approvals', Approvals, 'Manually approve dependencies, even if their licenses are not whitelisted'
|
126
|
+
subcommand 'ignored_groups', IgnoredGroups, 'Exclude test and development dependencies from action items and reports'
|
127
|
+
subcommand 'ignored_dependencies', IgnoredDependencies, 'Exclude individual dependencies from action items and reports'
|
128
|
+
subcommand 'whitelist', Whitelist, 'Automatically approve any dependency that has a whitelisted license'
|
129
|
+
subcommand 'blacklist', Blacklist, 'Forbid approval of any dependency whose licenses are all blacklisted'
|
130
|
+
subcommand 'project_name', ProjectName, 'Set the project name, for display in reports'
|
111
131
|
|
112
132
|
private
|
113
133
|
|
@@ -126,12 +146,12 @@ module LicenseFinder
|
|
126
146
|
!!options[:save]
|
127
147
|
end
|
128
148
|
|
129
|
-
def
|
130
|
-
|
149
|
+
def prepare?
|
150
|
+
options[:prepare]
|
131
151
|
end
|
132
152
|
|
133
|
-
def
|
134
|
-
|
153
|
+
def run_prepare_phase
|
154
|
+
license_finder.prepare_projects
|
135
155
|
end
|
136
156
|
end
|
137
157
|
end
|
@@ -7,8 +7,8 @@ module LicenseFinder
|
|
7
7
|
|
8
8
|
module ClassMethods
|
9
9
|
def auditable
|
10
|
-
method_option :who, desc:
|
11
|
-
method_option :why, desc:
|
10
|
+
method_option :who, desc: 'The person making this decision'
|
11
|
+
method_option :why, desc: 'The reason for making this decision'
|
12
12
|
method_option :version, desc: 'The version that will be approved'
|
13
13
|
end
|
14
14
|
end
|
@@ -3,7 +3,7 @@ module LicenseFinder
|
|
3
3
|
module Rootcommand
|
4
4
|
# Helper to auto-generate the documentation for a group of commands
|
5
5
|
def subcommand(namespace, klass, namespace_description)
|
6
|
-
description = "#{namespace} [#{(klass.tasks.keys - [
|
6
|
+
description = "#{namespace} [#{(klass.tasks.keys - ['help']).join('|')}]"
|
7
7
|
desc description, "#{namespace_description} - see `license_finder #{namespace} help` for more information"
|
8
8
|
super namespace, klass
|
9
9
|
end
|
@@ -13,20 +13,19 @@ module LicenseFinder
|
|
13
13
|
module Subcommand
|
14
14
|
# Hack to override the help message produced by Thor.
|
15
15
|
# https://github.com/wycats/thor/issues/261#issuecomment-16880836
|
16
|
-
def banner(command,
|
16
|
+
def banner(command, _namespace = nil, _subcommand = nil)
|
17
17
|
"#{basename} #{underscore_name(name)} #{command.usage}"
|
18
18
|
end
|
19
19
|
|
20
20
|
protected
|
21
21
|
|
22
22
|
def underscore_name(name)
|
23
|
-
underscored = name.split(
|
24
|
-
underscored.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
|
25
|
-
underscored.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
|
26
|
-
underscored.tr!(
|
23
|
+
underscored = name.split('::').last
|
24
|
+
underscored.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
25
|
+
underscored.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
|
26
|
+
underscored.tr!('-', '_')
|
27
27
|
underscored.downcase
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
32
|
-
|