license_finder 0.7.3 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -3
- data/.travis.yml +1 -8
- data/bin/license_finder +31 -1
- data/db/migrate/201303290935_create_dependencies.rb +14 -0
- data/db/migrate/201303291155_create_licenses.rb +13 -0
- data/db/migrate/201303291402_create_approvals.rb +13 -0
- data/db/migrate/201303291456_create_ancestries.rb +9 -0
- data/db/migrate/201303291519_create_bundler_groups.rb +13 -0
- data/db/migrate/201303291720_move_manual_from_approvals_to_licenses.rb +11 -0
- data/db/migrate/201303291753_allow_null_license_names.rb +7 -0
- data/db/migrate/201304011027_allow_null_dependency_version.rb +7 -0
- data/db/migrate/201304020947_change_table_name_licenses_to_license_aliases.rb +5 -0
- data/features/approve_dependencies.feature +0 -45
- data/features/html_report.feature +1 -11
- data/features/license_finder.feature +13 -27
- data/features/license_finder_rake_task.feature +2 -1
- data/features/set_license.feature +2 -4
- data/features/step_definitions/license_finder_steps.rb +25 -0
- data/features/step_definitions/steps.rb +40 -26
- data/features/text_report.feature +2 -2
- data/files/license_finder.yml +1 -1
- data/lib/license_finder.rb +14 -6
- data/lib/license_finder/bundle.rb +4 -17
- data/lib/license_finder/bundle_syncer.rb +2 -3
- data/lib/license_finder/bundled_gem.rb +4 -47
- data/lib/license_finder/cli.rb +9 -16
- data/lib/license_finder/configuration.rb +55 -3
- data/lib/license_finder/dependency_report.rb +1 -1
- data/lib/license_finder/gem_saver.rb +69 -0
- data/lib/license_finder/html_report.rb +2 -2
- data/lib/license_finder/license.rb +60 -58
- data/lib/license_finder/license_files.rb +36 -0
- data/lib/license_finder/license_url.rb +8 -6
- data/lib/license_finder/platform.rb +32 -0
- data/lib/license_finder/possible_license_file.rb +1 -1
- data/lib/license_finder/tables.rb +7 -0
- data/lib/license_finder/tables/approval.rb +4 -0
- data/lib/license_finder/tables/bundler_group.rb +4 -0
- data/lib/license_finder/tables/dependency.rb +31 -0
- data/lib/license_finder/tables/license_alias.rb +22 -0
- data/lib/license_finder/yml_to_sql.rb +127 -0
- data/lib/tasks/license_finder.rake +3 -0
- data/lib/templates/html_report.erb +50 -32
- data/lib/templates/text_report.erb +3 -2
- data/license_finder.gemspec +14 -5
- data/readme.md +10 -50
- data/spec/lib/license_finder/bundle_spec.rb +22 -19
- data/spec/lib/license_finder/bundle_syncer_spec.rb +4 -10
- data/spec/lib/license_finder/bundled_gem_spec.rb +40 -108
- data/spec/lib/license_finder/cli_spec.rb +3 -3
- data/spec/lib/license_finder/configuration_spec.rb +53 -21
- data/spec/lib/license_finder/gem_saver_spec.rb +155 -0
- data/spec/lib/license_finder/html_report_spec.rb +32 -15
- data/spec/lib/license_finder/license_files_spec.rb +50 -0
- data/spec/lib/license_finder/tables/dependency_spec.rb +102 -0
- data/spec/lib/license_finder/tables/license_alias_spec.rb +54 -0
- data/spec/lib/license_finder/text_report_spec.rb +6 -4
- data/spec/lib/license_finder/yml_to_sql_spec.rb +99 -0
- data/spec/lib/license_finder_spec.rb +5 -5
- data/spec/spec_helper.rb +17 -1
- metadata +79 -32
- data/lib/license_finder/dependency.rb +0 -50
- data/lib/license_finder/persistence.rb +0 -1
- data/lib/license_finder/persistence/yaml.rb +0 -7
- data/lib/license_finder/persistence/yaml/configuration.rb +0 -34
- data/lib/license_finder/persistence/yaml/dependency.rb +0 -127
- data/lib/license_finder/source_syncer.rb +0 -40
- data/lib/templates/dependency.html.erb +0 -54
- data/spec/lib/license_finder/dependency_spec.rb +0 -188
- data/spec/lib/license_finder/persistence/yaml/dependency_spec.rb +0 -5
- data/spec/lib/license_finder/source_syncer_spec.rb +0 -37
- data/spec/support/shared_examples/persistence/configuration.rb +0 -28
- data/spec/support/shared_examples/persistence/dependency.rb +0 -138
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,22 +1,15 @@
|
|
1
1
|
rvm:
|
2
|
+
- 2.0.0
|
2
3
|
- 1.9.3
|
3
4
|
- 1.9.2
|
4
|
-
- jruby-18mode
|
5
5
|
- jruby-19mode
|
6
|
-
- rbx-18mode
|
7
6
|
- rbx-19mode
|
8
7
|
- ruby-head
|
9
8
|
- jruby-head
|
10
|
-
- 1.8.7
|
11
|
-
- ree
|
12
9
|
|
13
10
|
matrix:
|
14
11
|
allow_failures:
|
15
|
-
- rvm: jruby-18mode
|
16
12
|
- rvm: jruby-19mode
|
17
|
-
- rvm: rbx-18mode
|
18
13
|
- rvm: rbx-19mode
|
19
14
|
- rvm: ruby-head
|
20
15
|
- rvm: jruby-head
|
21
|
-
- rvm: 1.8.7
|
22
|
-
- rvm: ree
|
data/bin/license_finder
CHANGED
@@ -3,7 +3,31 @@
|
|
3
3
|
require 'license_finder'
|
4
4
|
require 'optparse'
|
5
5
|
|
6
|
+
module SpinnerStrategy
|
7
|
+
module Spin
|
8
|
+
def self.run
|
9
|
+
thread = Thread.new() {
|
10
|
+
wheel = '\|/-'
|
11
|
+
i = 0
|
12
|
+
while not LicenseFinder::CLI.class_variable_get("@@run_complete") do
|
13
|
+
print "\r ---------- #{wheel[i]} ----------"
|
14
|
+
i = (i + 1) % 4
|
15
|
+
end
|
16
|
+
}
|
17
|
+
yield
|
18
|
+
thread.join
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
module Noop
|
23
|
+
def self.run
|
24
|
+
yield
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
6
29
|
options = {}
|
30
|
+
spinner = SpinnerStrategy::Spin
|
7
31
|
|
8
32
|
OptionParser.new do |opts|
|
9
33
|
opts.banner = "Usage: license_finder [options] [dependency]"
|
@@ -15,10 +39,16 @@ OptionParser.new do |opts|
|
|
15
39
|
opts.on("-l", "--license [LICENSE]", "Update a gem's license.") do |license|
|
16
40
|
options[:license] = license
|
17
41
|
end
|
42
|
+
|
43
|
+
opts.on("-q", "--quiet") do
|
44
|
+
spinner = SpinnerStrategy::Noop
|
45
|
+
end
|
18
46
|
end.parse!
|
19
47
|
|
20
48
|
unless options.empty?
|
21
49
|
options[:dependency] = ARGV.last
|
22
50
|
end
|
23
51
|
|
24
|
-
|
52
|
+
spinner.run {
|
53
|
+
LicenseFinder::CLI.execute! options
|
54
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# sequel -m db/migrate -E sqlite://doc/dependencies.db
|
2
|
+
|
3
|
+
Sequel.migration do
|
4
|
+
change do
|
5
|
+
create_table(:dependencies) do
|
6
|
+
primary_key :id
|
7
|
+
String :name, null: false
|
8
|
+
String :version, null: false
|
9
|
+
String :summary
|
10
|
+
String :description
|
11
|
+
String :homepage
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -12,48 +12,3 @@ Feature: Approving non-whitelisted Dependencies
|
|
12
12
|
When I run "license_finder"
|
13
13
|
Then I should not see "gpl_gem" in its output
|
14
14
|
Then I should see the "gpl_gem" in the html flagged as "approved"
|
15
|
-
|
16
|
-
Scenario: Manually approving a non-whitelisted dependency
|
17
|
-
Given I have an app with license finder
|
18
|
-
And my app depends on a gem "gpl_gem" licensed with "GPL"
|
19
|
-
And I whitelist the "MIT" license
|
20
|
-
|
21
|
-
When I run "license_finder"
|
22
|
-
Then I should see the following settings for "gpl_gem":
|
23
|
-
"""
|
24
|
-
version: "0.0.0"
|
25
|
-
license: "GPL"
|
26
|
-
approved: false
|
27
|
-
"""
|
28
|
-
|
29
|
-
When I update the settings for "gpl_gem" with the following content:
|
30
|
-
"""
|
31
|
-
approved: true
|
32
|
-
"""
|
33
|
-
When I run "license_finder"
|
34
|
-
Then I should not see "gpl_gem" in its output
|
35
|
-
|
36
|
-
Scenario: Manually adding a non-bundled dependency
|
37
|
-
Given I have an app with license finder
|
38
|
-
When I run "license_finder"
|
39
|
-
And I add the following content to "dependencies.yml":
|
40
|
-
"""
|
41
|
-
- name: "my_javascript_library"
|
42
|
-
version: "0.0.0"
|
43
|
-
license: "GPL"
|
44
|
-
approved: false
|
45
|
-
"""
|
46
|
-
Then I should see the following settings for "my_javascript_library":
|
47
|
-
"""
|
48
|
-
version: "0.0.0"
|
49
|
-
license: "GPL"
|
50
|
-
approved: false
|
51
|
-
"""
|
52
|
-
When I run "license_finder"
|
53
|
-
Then I should see "my_javascript_library" in its output
|
54
|
-
When I update the settings for "my_javascript_library" with the following content:
|
55
|
-
"""
|
56
|
-
approved: true
|
57
|
-
"""
|
58
|
-
When I run "license_finder"
|
59
|
-
Then I should not see "my_javascript_library" in its output
|
@@ -31,18 +31,8 @@ Feature: HTML Report
|
|
31
31
|
And I whitelist the following licenses: "MIT, other"
|
32
32
|
When I run "license_finder"
|
33
33
|
# rake, bundler, license_finder, my_app, gpl_licensed_gem, mit_licensed_gem
|
34
|
-
Then I should see "
|
34
|
+
Then I should see "8 total" in the html
|
35
35
|
# gpl_licensed_gem
|
36
36
|
And I should see "1 unapproved" in the html
|
37
37
|
# gpl_licensed_gem
|
38
38
|
And I should see "1 GPL" in the html
|
39
|
-
|
40
|
-
Scenario: Implicit dependencies list their parent dependencies
|
41
|
-
Given I have a rails app with license finder
|
42
|
-
When I run "license_finder"
|
43
|
-
Then I should see the "activerecord" in the html with the following details:
|
44
|
-
| parent |
|
45
|
-
| rails |
|
46
|
-
And I should see "rails" in the html with the following details:
|
47
|
-
| children |
|
48
|
-
| activerecord |
|
@@ -6,7 +6,7 @@ Feature: License Finder command line executable
|
|
6
6
|
Scenario: Running without a configuration file
|
7
7
|
Given I have an app with license finder
|
8
8
|
And my app does not have a "config" directory
|
9
|
-
When I run "license_finder"
|
9
|
+
When I run "license_finder -q"
|
10
10
|
Then I should see a "config" directory
|
11
11
|
And I should see the file "config/license_finder.yml" with the following content:
|
12
12
|
"""
|
@@ -17,45 +17,31 @@ Feature: License Finder command line executable
|
|
17
17
|
ignore_groups:
|
18
18
|
#- test
|
19
19
|
#- development
|
20
|
-
dependencies_file_dir: './'
|
21
|
-
"""
|
20
|
+
dependencies_file_dir: './doc/'
|
22
21
|
|
23
|
-
|
24
|
-
Given I have an app with license finder
|
25
|
-
And my app depends on a gem "mit_licensed_gem" licensed with "MIT"
|
26
|
-
And I have a truncated dependencies.yml file
|
27
|
-
When I run "license_finder"
|
28
|
-
Then it should exit with status code 1
|
29
|
-
And I should see "mit_licensed_gem" in its output
|
22
|
+
"""
|
30
23
|
|
31
24
|
Scenario: Auditing an application with non-whitelisted licenses
|
32
25
|
Given I have an app with license finder
|
33
26
|
And my app depends on a gem "mit_licensed_gem" licensed with "MIT"
|
34
|
-
When I run "license_finder"
|
27
|
+
When I run "license_finder -q"
|
35
28
|
Then it should exit with status code 1
|
36
29
|
And I should see "mit_licensed_gem" in its output
|
37
30
|
|
38
31
|
Scenario: Auditing an application with whitelisted licenses
|
39
32
|
Given I have an app with license finder
|
40
33
|
And my app depends on a gem "mit_licensed_gem" licensed with "MIT"
|
41
|
-
When I run "license_finder"
|
34
|
+
When I run "license_finder -q"
|
42
35
|
Then I should see "mit_licensed_gem" in its output
|
43
36
|
When I whitelist the following licenses: "MIT, other"
|
44
|
-
And I run "license_finder"
|
37
|
+
And I run "license_finder -q"
|
45
38
|
Then I should see "All gems are approved for use" in its output
|
46
39
|
And it should exit with status code 0
|
47
40
|
|
48
|
-
Scenario:
|
49
|
-
Given I have
|
50
|
-
And
|
51
|
-
And I
|
52
|
-
|
53
|
-
When I run
|
54
|
-
Then
|
55
|
-
|
56
|
-
Scenario: Remove readme file paths from legacy dependencies.yml
|
57
|
-
Given I have an app with license finder
|
58
|
-
And my app depends on a gem "random_licensed_gem" licensed with "random_license"
|
59
|
-
And I have a legacy dependencies.yml file with readme_files entry for gem "random_licensed_gem"
|
60
|
-
When I run "license_finder"
|
61
|
-
Then I should not see an entry "readme_files" for gem "random_licensed_gem" in my dependencies.yml
|
41
|
+
Scenario: Keep manually set license dependencies
|
42
|
+
Given I have a project that depends on mime-types
|
43
|
+
And I manually set the license type to Ruby
|
44
|
+
And I run license_finder again
|
45
|
+
Then the mime-types license is set to Ruby
|
46
|
+
When I run license_finder again
|
47
|
+
Then the mime-types license is set to Ruby
|
@@ -8,7 +8,5 @@ Feature: Set a dependency's license through a command line interface
|
|
8
8
|
And my app depends on a gem "other_license_gem" licensed with "other"
|
9
9
|
When I run "license_finder"
|
10
10
|
When I run "license_finder -l MIT other_license_gem"
|
11
|
-
|
12
|
-
|
13
|
-
license: "MIT"
|
14
|
-
"""
|
11
|
+
And I run license_finder again
|
12
|
+
Then I should see other_license_gem set to MIT license
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'license_finder'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'pathname'
|
4
|
+
require 'bundler'
|
5
|
+
require 'capybara'
|
6
|
+
|
7
|
+
Given /^I have a project that depends on mime\-types$/ do
|
8
|
+
@user = ::DSL::User.new
|
9
|
+
@user.create_rails_app
|
10
|
+
@user.add_gem_dependency('mime-types')
|
11
|
+
@user.bundle_app
|
12
|
+
@user.execute_command "license_finder"
|
13
|
+
end
|
14
|
+
|
15
|
+
Given /^I manually set the license type to Ruby$/ do
|
16
|
+
@output = @user.execute_command "license_finder -l Ruby mime-types"
|
17
|
+
end
|
18
|
+
|
19
|
+
When /^I run license_finder again$/ do
|
20
|
+
@output = @user.execute_command "license_finder -q"
|
21
|
+
end
|
22
|
+
|
23
|
+
Then /^the mime\-types license is set to Ruby$/ do
|
24
|
+
@output.should =~ /mime-types.*Ruby/
|
25
|
+
end
|
@@ -2,7 +2,6 @@ require 'fileutils'
|
|
2
2
|
require 'pathname'
|
3
3
|
require 'bundler'
|
4
4
|
require 'capybara'
|
5
|
-
require 'pry'
|
6
5
|
|
7
6
|
Given /^I have a rails app(?:lication)? with license finder$/ do
|
8
7
|
@user = ::DSL::User.new
|
@@ -44,8 +43,8 @@ Given /^I whitelist the following licenses: "([^"]*)"$/ do |licenses|
|
|
44
43
|
end
|
45
44
|
|
46
45
|
Given /^I have a legacy dependencies\.yml file with "(.*?)" approved with its "(.*?)" license$/ do |gem_name, license_name|
|
47
|
-
|
48
|
-
<<-YAML
|
46
|
+
@user.modifying_dependencies_file do |f|
|
47
|
+
f.write <<-YAML
|
49
48
|
- name: #{gem_name}
|
50
49
|
version: 1.5.0
|
51
50
|
license: #{license_name}
|
@@ -58,8 +57,8 @@ Given /^I have a legacy dependencies\.yml file with "(.*?)" approved with its "(
|
|
58
57
|
end
|
59
58
|
|
60
59
|
And /^I have a legacy dependencies\.yml file with readme_files entry for gem "(.*?)"$/ do |gem_name|
|
61
|
-
|
62
|
-
<<-YAML
|
60
|
+
@user.modifying_dependencies_file do |f|
|
61
|
+
f.write <<-YAML
|
63
62
|
- name: #{gem_name}
|
64
63
|
version: 1.5.0
|
65
64
|
license: some_license
|
@@ -73,6 +72,21 @@ And /^I have a legacy dependencies\.yml file with readme_files entry for gem "(.
|
|
73
72
|
end
|
74
73
|
end
|
75
74
|
|
75
|
+
Given /^I have a legacy dependencies\.yml file with a blank readme_files entry for gem "(.*?)"$/ do |gem_name|
|
76
|
+
@user.modifying_dependencies_file do |f|
|
77
|
+
f.write(<<-YAML)
|
78
|
+
- name: #{gem_name}
|
79
|
+
version: 1.5.0
|
80
|
+
license: some_license
|
81
|
+
approved: true
|
82
|
+
notes: ''
|
83
|
+
license_files:
|
84
|
+
- path: /some/path/to/files/that/are/rad
|
85
|
+
readme_files:
|
86
|
+
YAML
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
76
90
|
When /^I run "(.*?)"$/ do |command|
|
77
91
|
@output = @user.execute_command command
|
78
92
|
end
|
@@ -102,12 +116,6 @@ When /^the text "([^"]*)" should link to "([^"]*)"$/ do |text, link|
|
|
102
116
|
html.all(:xpath, "//a[@href='#{link}']").first.text.should == text
|
103
117
|
end
|
104
118
|
|
105
|
-
When /^I have a truncated dependencies.yml file$/ do
|
106
|
-
File.open(@user.dependencies_file_path, 'w+') do |f|
|
107
|
-
f.puts ""
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
119
|
When /^"([^"]*)" is an alternative name for the "MIT" license$/ do |alternative_name|
|
112
120
|
# this step is simply for readability
|
113
121
|
end
|
@@ -116,6 +124,10 @@ When /^I whitelist the "([^"]*)" bundler group$/ do |group|
|
|
116
124
|
@user.configure_license_finder_bundler_whitelist(group)
|
117
125
|
end
|
118
126
|
|
127
|
+
Then(/^I should see other_license_gem set to MIT license$/) do
|
128
|
+
@output.should =~ /other_license_gem.*MIT/
|
129
|
+
end
|
130
|
+
|
119
131
|
Then /^I should see a "([^"]+)" directory$/ do |name|
|
120
132
|
File.should be_exists(@user.app_path(name))
|
121
133
|
end
|
@@ -141,13 +153,6 @@ Then /^I should see exactly one entry for "(.*?)" in "(.*?)"$/ do |gem_name, fil
|
|
141
153
|
file_contents.scan(/#{gem_name}/).size.should == 1
|
142
154
|
end
|
143
155
|
|
144
|
-
Then /^I should see the following settings for "([^"]*)":$/ do |name, yaml|
|
145
|
-
expected_settings = YAML.load(yaml)
|
146
|
-
all_settings = YAML.load(File.read(@user.dependencies_file_path))
|
147
|
-
actual_settings = all_settings.detect { |gem| gem['name'] == name }
|
148
|
-
actual_settings.should include expected_settings
|
149
|
-
end
|
150
|
-
|
151
156
|
Then /^I should not see an entry "(.*?)" for gem "(.*?)" in my dependencies\.yml$/ do |entry_key, gem_name|
|
152
157
|
settings = YAML.load(File.read(@user.dependencies_file_path))
|
153
158
|
gem_settings = settings.detect { |gem| gem['name'] == gem_name }
|
@@ -303,15 +308,24 @@ module DSL
|
|
303
308
|
File.join(app_path, 'config')
|
304
309
|
end
|
305
310
|
|
311
|
+
def doc_path
|
312
|
+
File.join(app_path, 'doc')
|
313
|
+
end
|
314
|
+
|
306
315
|
def dependencies_file_path
|
307
|
-
File.join(
|
316
|
+
File.join(doc_path, 'dependencies.yml')
|
308
317
|
end
|
309
318
|
|
310
319
|
def dependencies_html_path
|
311
|
-
File.join(
|
320
|
+
File.join(doc_path, 'dependencies.html')
|
312
321
|
end
|
313
322
|
|
314
|
-
|
323
|
+
def add_gem_dependency(name, options = {})
|
324
|
+
line = "gem #{name.inspect}"
|
325
|
+
line << ", " + options.inspect unless options.empty?
|
326
|
+
|
327
|
+
add_to_gemfile(line)
|
328
|
+
end
|
315
329
|
|
316
330
|
def bundle_app
|
317
331
|
Bundler.with_clean_env do
|
@@ -319,13 +333,13 @@ module DSL
|
|
319
333
|
end
|
320
334
|
end
|
321
335
|
|
322
|
-
def
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
add_to_gemfile(line)
|
336
|
+
def modifying_dependencies_file
|
337
|
+
FileUtils.mkdir_p(File.dirname(dependencies_file_path))
|
338
|
+
File.open(dependencies_file_path, 'w+') { |f| yield f }
|
327
339
|
end
|
328
340
|
|
341
|
+
private
|
342
|
+
|
329
343
|
def add_to_gemfile(line)
|
330
344
|
`echo #{line.inspect} >> #{File.join(app_path, "Gemfile")}`
|
331
345
|
end
|