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,307 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
require 'pathname'
|
3
|
-
require 'bundler'
|
4
|
-
require 'capybara'
|
5
|
-
require 'open3'
|
6
|
-
|
7
|
-
########## COMMON STEPS ##########
|
8
|
-
|
9
|
-
Given(/^I have an app$/) do
|
10
|
-
@user = ::DSL::User.new
|
11
|
-
@user.create_ruby_app
|
12
|
-
end
|
13
|
-
|
14
|
-
When(/^I run license_finder$/) do
|
15
|
-
@user.execute_command "license_finder --quiet"
|
16
|
-
end
|
17
|
-
|
18
|
-
When(/^I whitelist everything I can think of$/) do
|
19
|
-
@user.configure_license_finder_whitelist ["MIT","other","New BSD","Apache 2.0","Ruby"]
|
20
|
-
@user.execute_command "license_finder --quiet"
|
21
|
-
end
|
22
|
-
|
23
|
-
Then(/^I should see the project name (\w+) in the html$/) do |project_name|
|
24
|
-
@user.in_html do |page|
|
25
|
-
title = page.find("h1")
|
26
|
-
|
27
|
-
expect(title).to have_content project_name
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
|
32
|
-
module DSL
|
33
|
-
class User
|
34
|
-
def create_python_app
|
35
|
-
reset_projects!
|
36
|
-
|
37
|
-
app_path.mkpath
|
38
|
-
shell_out("cd #{app_path} && touch requirements.txt")
|
39
|
-
|
40
|
-
add_pip_dependency('argparse==1.2.1')
|
41
|
-
|
42
|
-
pip_install
|
43
|
-
end
|
44
|
-
|
45
|
-
def create_node_app
|
46
|
-
reset_projects!
|
47
|
-
|
48
|
-
app_path.mkpath
|
49
|
-
shell_out("cd #{app_path} && touch package.json")
|
50
|
-
|
51
|
-
add_npm_dependency('http-server', '0.6.1')
|
52
|
-
|
53
|
-
npm_install
|
54
|
-
end
|
55
|
-
|
56
|
-
def create_maven_app
|
57
|
-
reset_projects!
|
58
|
-
|
59
|
-
app_path.mkpath
|
60
|
-
|
61
|
-
add_maven_dependency
|
62
|
-
|
63
|
-
mvn_install
|
64
|
-
end
|
65
|
-
|
66
|
-
def create_gradle_app
|
67
|
-
reset_projects!
|
68
|
-
|
69
|
-
app_path.mkpath
|
70
|
-
|
71
|
-
add_gradle_dependency
|
72
|
-
end
|
73
|
-
|
74
|
-
def create_ruby_app
|
75
|
-
reset_projects!
|
76
|
-
|
77
|
-
shell_out("cd #{projects_path} && bundle gem #{app_name}")
|
78
|
-
|
79
|
-
add_gem_dependency('license_finder', path: root_path.to_s)
|
80
|
-
|
81
|
-
bundle_install
|
82
|
-
end
|
83
|
-
|
84
|
-
def create_cocoapods_app
|
85
|
-
reset_projects!
|
86
|
-
|
87
|
-
app_path.mkpath
|
88
|
-
|
89
|
-
add_pod_dependency
|
90
|
-
|
91
|
-
pod_install
|
92
|
-
end
|
93
|
-
|
94
|
-
def create_and_depend_on_gem(gem_name, options)
|
95
|
-
create_gem(gem_name, options)
|
96
|
-
depend_on_local_gem(gem_name)
|
97
|
-
end
|
98
|
-
|
99
|
-
def create_gem(gem_name, options)
|
100
|
-
gem_dir = projects_path.join(gem_name)
|
101
|
-
|
102
|
-
gem_dir.mkpath
|
103
|
-
gem_dir.join("#{gem_name}.gemspec").open('w') do |file|
|
104
|
-
file.write gemspec_string(gem_name, options)
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
def depend_on_local_gem(gem_name, options={})
|
109
|
-
gem_dir = projects_path.join(gem_name)
|
110
|
-
options[:path] = gem_dir.to_s
|
111
|
-
|
112
|
-
add_gem_dependency(gem_name, options)
|
113
|
-
|
114
|
-
bundle_install
|
115
|
-
end
|
116
|
-
|
117
|
-
def configure_license_finder_whitelist(whitelisted_licenses=[])
|
118
|
-
config_path.mkpath
|
119
|
-
config_file.open("w") do |f|
|
120
|
-
f.write({'whitelist' => whitelisted_licenses}.to_yaml)
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
def execute_command(command)
|
125
|
-
::Bundler.with_clean_env do
|
126
|
-
@output = shell_out("cd #{app_path} && bundle exec #{command}", true)
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
def seeing?(content)
|
131
|
-
@output.include? content
|
132
|
-
end
|
133
|
-
|
134
|
-
def seeing_line?(content)
|
135
|
-
seeing_something_like? /^#{Regexp.escape content}$/
|
136
|
-
end
|
137
|
-
|
138
|
-
def seeing_something_like?(regex)
|
139
|
-
@output =~ regex
|
140
|
-
end
|
141
|
-
|
142
|
-
def app_path(sub_directory = nil)
|
143
|
-
path = base_path = projects_path.join(app_name).cleanpath
|
144
|
-
|
145
|
-
if sub_directory
|
146
|
-
path = base_path.join(sub_directory).cleanpath
|
147
|
-
|
148
|
-
raise "#{sub_directory} is outside of the app" unless path.to_s =~ %r{^#{base_path}/}
|
149
|
-
end
|
150
|
-
|
151
|
-
path
|
152
|
-
end
|
153
|
-
|
154
|
-
def config_path
|
155
|
-
app_path('config')
|
156
|
-
end
|
157
|
-
|
158
|
-
def config_file
|
159
|
-
config_path.join("license_finder.yml")
|
160
|
-
end
|
161
|
-
|
162
|
-
def in_html
|
163
|
-
yield Capybara.string(app_path('doc/dependencies.html').read)
|
164
|
-
end
|
165
|
-
|
166
|
-
def in_gem_html(gem_name)
|
167
|
-
in_html do |page|
|
168
|
-
yield page.find("##{gem_name}")
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
private
|
173
|
-
|
174
|
-
def gemspec_string(gem_name, options)
|
175
|
-
if options.has_key?(:license) && options.has_key?(:licenses)
|
176
|
-
raise "Can't specify both `license` and `licenses`"
|
177
|
-
end
|
178
|
-
|
179
|
-
license_key = ([:license, :licenses] & options.keys).first
|
180
|
-
license_value = options.fetch(license_key)
|
181
|
-
summary = options.fetch(:summary, "")
|
182
|
-
description = options.fetch(:description, "")
|
183
|
-
version = options[:version] || "0.0.0"
|
184
|
-
homepage = options[:homepage]
|
185
|
-
|
186
|
-
<<-GEMSPEC
|
187
|
-
Gem::Specification.new do |s|
|
188
|
-
s.name = "#{gem_name}"
|
189
|
-
s.version = "#{version}"
|
190
|
-
s.author = "Cucumber"
|
191
|
-
s.summary = "#{summary}"
|
192
|
-
s.#{license_key} = #{license_value.inspect}
|
193
|
-
s.description = "#{description}"
|
194
|
-
s.homepage = "#{homepage}"
|
195
|
-
end
|
196
|
-
GEMSPEC
|
197
|
-
end
|
198
|
-
|
199
|
-
def add_gem_dependency(name, options = {})
|
200
|
-
line = "gem #{name.inspect}"
|
201
|
-
line << ", " + options.inspect unless options.empty?
|
202
|
-
|
203
|
-
add_to_gemfile(line)
|
204
|
-
end
|
205
|
-
|
206
|
-
def add_pip_dependency(dependency)
|
207
|
-
add_to_requirements(dependency)
|
208
|
-
end
|
209
|
-
|
210
|
-
def add_npm_dependency(dependency, version)
|
211
|
-
line = "{\"dependencies\" : {\"#{dependency}\": \"#{version}\"}}"
|
212
|
-
|
213
|
-
add_to_package(line)
|
214
|
-
end
|
215
|
-
|
216
|
-
def add_maven_dependency
|
217
|
-
path = fixtures_path.join("pom.xml")
|
218
|
-
shell_out("cp #{path} #{app_path}")
|
219
|
-
end
|
220
|
-
|
221
|
-
def add_gradle_dependency
|
222
|
-
path = fixtures_path.join("build.gradle")
|
223
|
-
shell_out("cd #{app_path} && cp #{path} .")
|
224
|
-
end
|
225
|
-
|
226
|
-
def add_pod_dependency
|
227
|
-
path = fixtures_path.join("Podfile")
|
228
|
-
shell_out("cp #{path} #{app_path}")
|
229
|
-
end
|
230
|
-
|
231
|
-
def bundle_install
|
232
|
-
::Bundler.with_clean_env do
|
233
|
-
shell_out("cd #{app_path} && bundle check || bundle install")
|
234
|
-
end
|
235
|
-
end
|
236
|
-
|
237
|
-
def pip_install
|
238
|
-
shell_out("cd #{app_path} && pip install -r requirements.txt")
|
239
|
-
end
|
240
|
-
|
241
|
-
def npm_install
|
242
|
-
shell_out("cd #{app_path} && npm install 2>/dev/null")
|
243
|
-
end
|
244
|
-
|
245
|
-
def mvn_install
|
246
|
-
shell_out("cd #{app_path} && mvn install")
|
247
|
-
end
|
248
|
-
|
249
|
-
def pod_install
|
250
|
-
shell_out("cd #{app_path} && pod install --no-integrate")
|
251
|
-
end
|
252
|
-
|
253
|
-
def add_to_gemfile(line)
|
254
|
-
shell_out("echo #{line.inspect} >> #{app_path.join("Gemfile")}")
|
255
|
-
end
|
256
|
-
|
257
|
-
def add_to_requirements(line)
|
258
|
-
shell_out("echo #{line.inspect} >> #{app_path.join("requirements.txt")}")
|
259
|
-
end
|
260
|
-
|
261
|
-
def add_to_package(line)
|
262
|
-
shell_out("echo #{line.inspect} >> #{app_path.join("package.json")}")
|
263
|
-
end
|
264
|
-
|
265
|
-
def app_name
|
266
|
-
"my_app"
|
267
|
-
end
|
268
|
-
|
269
|
-
def sandbox_path
|
270
|
-
root_path.join("tmp")
|
271
|
-
end
|
272
|
-
|
273
|
-
def projects_path
|
274
|
-
sandbox_path.join("projects")
|
275
|
-
end
|
276
|
-
|
277
|
-
def fixtures_path
|
278
|
-
root_path.join("spec", "fixtures")
|
279
|
-
end
|
280
|
-
|
281
|
-
def reset_projects!
|
282
|
-
shell_out("rm -rf #{projects_path}")
|
283
|
-
projects_path.mkpath
|
284
|
-
end
|
285
|
-
|
286
|
-
def root_path
|
287
|
-
Pathname.new(__FILE__).dirname.join("..", "..").realpath
|
288
|
-
end
|
289
|
-
|
290
|
-
def shell_out(command, allow_failures = false)
|
291
|
-
output = `#{command} 2>&1`
|
292
|
-
status = $?
|
293
|
-
unless status.success? || allow_failures
|
294
|
-
message_format = <<EOM
|
295
|
-
Command failed: `%s`
|
296
|
-
output: %s
|
297
|
-
exit: %d
|
298
|
-
EOM
|
299
|
-
message = sprintf message_format, command, output.chomp, status.exitstatus
|
300
|
-
raise RuntimeError.new(message)
|
301
|
-
end
|
302
|
-
|
303
|
-
$last_command_exit_status = status
|
304
|
-
output
|
305
|
-
end
|
306
|
-
end
|
307
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
---
|
2
|
-
whitelist:
|
3
|
-
#- MIT
|
4
|
-
#- Apache 2.0
|
5
|
-
ignore_groups:
|
6
|
-
#- test
|
7
|
-
#- development
|
8
|
-
ignore_dependencies:
|
9
|
-
#- bundler
|
10
|
-
dependencies_file_dir: './doc/'
|
11
|
-
project_name: # project name
|
12
|
-
gradle_command: # only meaningful if used with a Java/gradle project. Defaults to "gradle".
|
@@ -1,92 +0,0 @@
|
|
1
|
-
require 'digest'
|
2
|
-
|
3
|
-
module LicenseFinder
|
4
|
-
class DependencyManager
|
5
|
-
attr_reader :logger
|
6
|
-
|
7
|
-
def initialize options={}
|
8
|
-
@logger = options[:logger] || LicenseFinder::Logger::Default.new
|
9
|
-
end
|
10
|
-
|
11
|
-
def sync_with_package_managers options={}
|
12
|
-
modifying {
|
13
|
-
current_dependencies = PackageSaver.save_all(current_packages)
|
14
|
-
|
15
|
-
Dependency.added_automatically.obsolete(current_dependencies).each(&:destroy)
|
16
|
-
}
|
17
|
-
end
|
18
|
-
|
19
|
-
def manually_add(license, name, version)
|
20
|
-
raise Error.new("#{name} dependency already exists") unless Dependency.where(name: name).empty?
|
21
|
-
|
22
|
-
modifying {
|
23
|
-
dependency = Dependency.new(added_manually: true, name: name, version: version)
|
24
|
-
dependency.licenses = [License.find_by_name(license)].to_set
|
25
|
-
dependency.save
|
26
|
-
}
|
27
|
-
end
|
28
|
-
|
29
|
-
def manually_remove(name)
|
30
|
-
modifying { find_by_name(name, Dependency.added_manually).destroy }
|
31
|
-
end
|
32
|
-
|
33
|
-
def license!(name, license_name)
|
34
|
-
license = License.find_by_name(license_name)
|
35
|
-
modifying { find_by_name(name).set_license_manually!(license) }
|
36
|
-
end
|
37
|
-
|
38
|
-
def approve!(name, approver = nil, notes = nil)
|
39
|
-
modifying { find_by_name(name).approve!(approver, notes) }
|
40
|
-
end
|
41
|
-
|
42
|
-
def modifying
|
43
|
-
checksum_before = checksum
|
44
|
-
result = DB.transaction { yield }
|
45
|
-
checksum_after = checksum
|
46
|
-
|
47
|
-
database_changed = checksum_before != checksum_after
|
48
|
-
|
49
|
-
if database_changed || reports_do_not_exist || reports_are_stale
|
50
|
-
Reporter.write_reports
|
51
|
-
end
|
52
|
-
|
53
|
-
result
|
54
|
-
end
|
55
|
-
|
56
|
-
private # not really private, but it looks like it is!
|
57
|
-
|
58
|
-
def reports_do_not_exist
|
59
|
-
!(LicenseFinder.config.artifacts.html_file.exist?)
|
60
|
-
end
|
61
|
-
|
62
|
-
def reports_are_stale
|
63
|
-
LicenseFinder.config.last_modified > LicenseFinder.config.artifacts.last_refreshed
|
64
|
-
end
|
65
|
-
|
66
|
-
def current_packages
|
67
|
-
package_managers.
|
68
|
-
map { |pm| pm.new(logger: logger) }.
|
69
|
-
select(&:active?).
|
70
|
-
map(&:current_packages).
|
71
|
-
flatten
|
72
|
-
end
|
73
|
-
|
74
|
-
def package_managers
|
75
|
-
[Bundler, NPM, Pip, Bower, Maven, Gradle, CocoaPods]
|
76
|
-
end
|
77
|
-
|
78
|
-
def find_by_name(name, scope = Dependency)
|
79
|
-
dep = scope.first(name: name)
|
80
|
-
raise Error.new("could not find dependency named #{name}") unless dep
|
81
|
-
dep
|
82
|
-
end
|
83
|
-
|
84
|
-
def checksum
|
85
|
-
database_file = LicenseFinder.config.artifacts.database_file
|
86
|
-
if database_file.exist?
|
87
|
-
Digest::SHA2.file(database_file).hexdigest
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'forwardable'
|
2
|
-
|
3
|
-
module LicenseFinder
|
4
|
-
class PackageSaver
|
5
|
-
extend Forwardable
|
6
|
-
def_delegators :package, :licenses, :children, :groups, :summary, :description, :version, :homepage
|
7
|
-
|
8
|
-
attr_reader :dependency, :package
|
9
|
-
|
10
|
-
def self.save_all(packages)
|
11
|
-
packages.map do |package|
|
12
|
-
find_or_create_by_name(package).save
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def initialize(dependency, package)
|
17
|
-
@dependency = dependency
|
18
|
-
@package = package
|
19
|
-
end
|
20
|
-
|
21
|
-
def save
|
22
|
-
dependency.version = version.to_s
|
23
|
-
dependency.summary = summary
|
24
|
-
dependency.description = description
|
25
|
-
dependency.homepage = homepage
|
26
|
-
dependency.bundler_group_names = groups.map(&:to_s)
|
27
|
-
dependency.children_names = children
|
28
|
-
dependency.set_licenses licenses
|
29
|
-
|
30
|
-
# Only save *changed* dependencies. This ensures re-running
|
31
|
-
# `license_finder` won't always update the DB, and therefore won't always
|
32
|
-
# update the HTML/markdown reports with a new timestamp.
|
33
|
-
dependency.save_changes
|
34
|
-
dependency
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
def self.find_or_create_by_name(package)
|
40
|
-
dependency = Dependency.named(package.name)
|
41
|
-
new(dependency, package)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|