license_finder 0.8.1-java → 0.8.2-java
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/CHANGELOG.rdoc +15 -1
- data/bin/license_finder +1 -61
- data/db/migrate/201304181524_add_manual_to_dependencies.rb +7 -0
- data/features/ignore_bundle_groups.feature +15 -2
- data/features/non_bundler_dependencies.feature +19 -0
- data/features/step_definitions/approve_dependencies_steps.rb +1 -1
- data/features/step_definitions/cli_steps.rb +1 -1
- data/features/step_definitions/html_report_steps.rb +1 -6
- data/features/step_definitions/ignore_bundle_groups_steps.rb +18 -2
- data/features/step_definitions/non_bundler_steps.rb +33 -0
- data/features/step_definitions/set_license_steps.rb +1 -1
- data/features/step_definitions/shared_steps.rb +5 -8
- data/lib/license_finder.rb +24 -25
- data/lib/license_finder/bundle.rb +2 -2
- data/lib/license_finder/bundled_gem.rb +3 -3
- data/lib/license_finder/{gem_saver.rb → bundled_gem_saver.rb} +3 -5
- data/lib/license_finder/bundler_group_manager.rb +22 -0
- data/lib/license_finder/cli.rb +137 -31
- data/lib/license_finder/configuration.rb +28 -12
- data/lib/license_finder/dependency_manager.rb +49 -0
- data/lib/license_finder/license.rb +3 -3
- data/lib/license_finder/{license_files.rb → possible_license_files.rb} +2 -2
- data/lib/license_finder/{dependency_report.rb → reports/dependency_report.rb} +1 -1
- data/lib/license_finder/{html_report.rb → reports/html_report.rb} +0 -0
- data/lib/license_finder/{reporter.rb → reports/reporter.rb} +0 -0
- data/lib/license_finder/{text_report.rb → reports/text_report.rb} +0 -0
- data/lib/license_finder/tables.rb +1 -1
- data/lib/license_finder/tables/dependency.rb +24 -5
- data/lib/license_finder/yml_to_sql.rb +5 -0
- data/lib/tasks/license_finder.rake +1 -1
- data/license_finder.gemspec +5 -3
- data/readme.md +103 -26
- data/release.md +7 -2
- data/spec/lib/license_finder/bundle_spec.rb +4 -11
- data/spec/lib/license_finder/{gem_saver_spec.rb → bundled_gem_saver_spec.rb} +7 -4
- data/spec/lib/license_finder/bundled_gem_spec.rb +1 -1
- data/spec/lib/license_finder/bundler_group_manager_spec.rb +60 -0
- data/spec/lib/license_finder/cli_spec.rb +119 -19
- data/spec/lib/license_finder/configuration_spec.rb +31 -8
- data/spec/lib/license_finder/dependency_manager_spec.rb +107 -0
- data/spec/lib/license_finder/html_report_spec.rb +3 -3
- data/spec/lib/license_finder/{license_files_spec.rb → possible_license_files_spec.rb} +7 -7
- data/spec/lib/license_finder/tables/dependency_spec.rb +31 -44
- data/spec/lib/license_finder/yml_to_sql_spec.rb +24 -2
- data/spec/spec_helper.rb +0 -1
- data/spec/support/silence_stdout.rb +13 -0
- metadata +85 -76
- data/lib/license_finder/bundle_syncer.rb +0 -11
- data/spec/lib/license_finder/bundle_syncer_spec.rb +0 -16
data/.gitignore
CHANGED
data/CHANGELOG.rdoc
CHANGED
@@ -1,8 +1,22 @@
|
|
1
|
+
=== 0.8.2 / 2012-07-09
|
2
|
+
|
3
|
+
* Features
|
4
|
+
|
5
|
+
* Switch to thor for CLI, to support future additions to CLI
|
6
|
+
* Restore ability to manage (add/remove) dependencies that Bundler can't find
|
7
|
+
* Can maintain ignored bundler groups from command line
|
8
|
+
|
9
|
+
* Bugfixes
|
10
|
+
|
11
|
+
* Fix bug preventing manual approval of child dependencies (Issue #23)
|
12
|
+
* Fix issue with database URI when the absolute path to the database file
|
13
|
+
contains spaces.
|
14
|
+
* Upgrading from 0.7.2 no longer removes non-gem dependencies (Issue #20)
|
15
|
+
|
1
16
|
=== 0.8.1 / 2013-04-14
|
2
17
|
|
3
18
|
* Features
|
4
19
|
|
5
|
-
* Add spinner to show that the binary is actually doing something.
|
6
20
|
* JRuby version of the gem.
|
7
21
|
* Official ruby 2.0 support.
|
8
22
|
* CLI interface for moving dependencies.* files to `doc/`.
|
data/bin/license_finder
CHANGED
@@ -1,65 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'license_finder'
|
4
|
-
require 'optparse'
|
5
4
|
|
6
|
-
|
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
|
-
|
29
|
-
options = {}
|
30
|
-
spinner = SpinnerStrategy::Spin
|
31
|
-
skip = false
|
32
|
-
|
33
|
-
OptionParser.new do |opts|
|
34
|
-
opts.banner = "Usage: license_finder [options] [dependency]"
|
35
|
-
|
36
|
-
opts.on("-a", "--approve", "Approve a gem by name.") do |gem_name|
|
37
|
-
options[:approve] = true
|
38
|
-
end
|
39
|
-
|
40
|
-
opts.on("-l", "--license [LICENSE]", "Update a gem's license.") do |license|
|
41
|
-
options[:license] = license
|
42
|
-
end
|
43
|
-
|
44
|
-
opts.on("-q", "--quiet") do
|
45
|
-
spinner = SpinnerStrategy::Noop
|
46
|
-
end
|
47
|
-
|
48
|
-
opts.on("-m", "--move") do
|
49
|
-
skip = true
|
50
|
-
`sed '$d' < config/license_finder.yml > tmp34567.txt`
|
51
|
-
`mv tmp34567.txt config/license_finder.yml`
|
52
|
-
`echo "dependencies_file_dir: './doc/'" >> config/license_finder.yml`
|
53
|
-
`mkdir doc`
|
54
|
-
`mv dependencies.* doc/`
|
55
|
-
puts "Congratulations, you have cleaned up your root directory!'"
|
56
|
-
end
|
57
|
-
end.parse!
|
58
|
-
|
59
|
-
unless options.empty?
|
60
|
-
options[:dependency] = ARGV.last
|
61
|
-
end
|
62
|
-
|
63
|
-
spinner.run {
|
64
|
-
LicenseFinder::CLI.execute!(options)
|
65
|
-
} unless skip
|
5
|
+
LicenseFinder::CLI::Main.start
|
@@ -3,8 +3,21 @@ Feature: Ignore Bundle Groups
|
|
3
3
|
I want to ignore certain bundler groups
|
4
4
|
So that any gems I use in development, or for testing, are automatically approved for use
|
5
5
|
|
6
|
-
Scenario:
|
6
|
+
Scenario: Ignored bundler groups are not evaluated for licenses
|
7
7
|
Given I have an app with license finder that depends on a GPL licensed gem in the test bundler group
|
8
|
-
And I
|
8
|
+
And I add the test group to the ignored bundler groups
|
9
9
|
When I run license_finder
|
10
10
|
Then I should not see the GPL licensed gem in the output
|
11
|
+
|
12
|
+
Scenario: Bundler groups can be added to the ignore list from command line
|
13
|
+
Given I have an app with license finder
|
14
|
+
And I add the test group to the ignored bundler groups
|
15
|
+
When I get the ignored groups from the command line
|
16
|
+
Then I should see the test group in the output
|
17
|
+
|
18
|
+
Scenario: Bundler groups can be removed from the ignore list from command line
|
19
|
+
Given I have an app with license finder
|
20
|
+
And I add the test group to the ignored bundler groups
|
21
|
+
And I remove the test group from the ignored bundler groups
|
22
|
+
When I get the ignored groups from the command line
|
23
|
+
Then I should not see the test group in the output
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Feature: Tracking non-Bundler Dependencies
|
2
|
+
So that I can track JS and other dependencies not tracked by Bundler
|
3
|
+
As an application developer using license finder
|
4
|
+
I want to be able to manually manage non-Bundler dependencies
|
5
|
+
|
6
|
+
Scenario: Adding a non-Bundler dependency
|
7
|
+
Given I have an app with license finder
|
8
|
+
When I add my JS dependency
|
9
|
+
Then I should see the JS dependency in the console output
|
10
|
+
|
11
|
+
Scenario: Auto approving a non-Bundler dependency I add
|
12
|
+
Given I have an app with license finder
|
13
|
+
When I add my JS dependency with an approval flag
|
14
|
+
Then I should not see the JS dependency in the console output since it is approved
|
15
|
+
|
16
|
+
Scenario: Removing a non-Bundler dependency
|
17
|
+
Given I have an app with license finder and a JS dependency
|
18
|
+
When I remove my JS dependency
|
19
|
+
Then I should not see the JS dependency in the console output
|
@@ -7,7 +7,7 @@ end
|
|
7
7
|
When(/^I approve that gem$/) do
|
8
8
|
@output = @user.execute_command "license_finder"
|
9
9
|
@output.should include "gpl_gem"
|
10
|
-
@output = @user.execute_command "license_finder
|
10
|
+
@output = @user.execute_command "license_finder approve gpl_gem"
|
11
11
|
@output = @user.execute_command "license_finder -q"
|
12
12
|
end
|
13
13
|
|
@@ -18,7 +18,7 @@ Given(/^I have a project that depends on mime\-types with a manual license type$
|
|
18
18
|
@user.add_gem_dependency('mime-types')
|
19
19
|
@user.bundle_app
|
20
20
|
@user.execute_command "license_finder -q"
|
21
|
-
@output = @user.execute_command "license_finder
|
21
|
+
@output = @user.execute_command "license_finder license Ruby mime-types"
|
22
22
|
@output.should =~ /mime-types.*Ruby/
|
23
23
|
end
|
24
24
|
|
@@ -1,8 +1,3 @@
|
|
1
|
-
Given(/^I have an app with license finder$/) do
|
2
|
-
@user = ::DSL::User.new
|
3
|
-
@user.create_nonrails_app
|
4
|
-
end
|
5
|
-
|
6
1
|
Given(/^my app depends on a gem with specific details$/) do
|
7
2
|
@gem_name = "mit_licensed_gem"
|
8
3
|
@table = {
|
@@ -54,7 +49,7 @@ end
|
|
54
49
|
Then(/^I should see only see GPL liceneses as unapproved in the html$/) do
|
55
50
|
html = File.read(@user.dependencies_html_path)
|
56
51
|
page = Capybara.string(html)
|
57
|
-
page.should have_content '
|
52
|
+
page.should have_content '9 total'
|
58
53
|
page.should have_content '1 unapproved'
|
59
54
|
page.should have_content '1 GPL'
|
60
55
|
end
|
@@ -4,10 +4,26 @@ Given(/^I have an app with license finder that depends on a GPL licensed gem in
|
|
4
4
|
@user.add_dependency_to_app 'gpl_gem', :license => 'GPL', :bundler_groups => 'test'
|
5
5
|
end
|
6
6
|
|
7
|
-
And(/^I
|
8
|
-
@user.
|
7
|
+
And(/^I add the test group to the ignored bundler groups$/) do
|
8
|
+
@user.execute_command('license_finder ignored_bundler_group add test')
|
9
|
+
end
|
10
|
+
|
11
|
+
And(/^I remove the test group from the ignored bundler groups$/) do
|
12
|
+
@user.execute_command('license_finder ignored_bundler_group remove test')
|
9
13
|
end
|
10
14
|
|
11
15
|
Then(/^I should not see the GPL licensed gem in the output$/) do
|
12
16
|
@output.should_not include 'gpl_gem'
|
13
17
|
end
|
18
|
+
|
19
|
+
When(/^I get the ignored groups from the command line$/) do
|
20
|
+
@output = @user.execute_command('license_finder ignored_bundler_group list')
|
21
|
+
end
|
22
|
+
|
23
|
+
Then(/^I should see the test group in the output$/) do
|
24
|
+
@output.should include 'test'
|
25
|
+
end
|
26
|
+
|
27
|
+
Then(/^I should not see the test group in the output$/) do
|
28
|
+
@output.should_not include 'test'
|
29
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
Given(/^I have an app with license finder and a JS dependency$/) do
|
2
|
+
@user = ::DSL::User.new
|
3
|
+
@user.create_nonrails_app
|
4
|
+
@output = @user.execute_command 'license_finder dependencies add MIT my_js_dep 1.2.3'
|
5
|
+
end
|
6
|
+
|
7
|
+
When(/^I add my JS dependency$/) do
|
8
|
+
@output = @user.execute_command 'license_finder dependencies add MIT my_js_dep 1.2.3'
|
9
|
+
end
|
10
|
+
|
11
|
+
When(/^I add my JS dependency with an approval flag$/) do
|
12
|
+
@output = @user.execute_command 'license_finder dependencies add -a MIT my_js_dep 1.2.3'
|
13
|
+
@output.should == "The my_js_dep dependency has been added and approved!\n"
|
14
|
+
end
|
15
|
+
|
16
|
+
When(/^I remove my JS dependency$/) do
|
17
|
+
@user.execute_command 'license_finder dependencies remove my_js_dep'
|
18
|
+
end
|
19
|
+
|
20
|
+
Then(/^I should see the JS dependency in the console output$/) do
|
21
|
+
@output = @user.execute_command 'license_finder -q'
|
22
|
+
@output.should include 'my_js_dep, 1.2.3, MIT'
|
23
|
+
end
|
24
|
+
|
25
|
+
Then(/^I should not see the JS dependency in the console output$/) do
|
26
|
+
@output = @user.execute_command 'license_finder -q'
|
27
|
+
@output.should_not include 'my_js_dep, 1.2.3, MIT'
|
28
|
+
end
|
29
|
+
|
30
|
+
Then(/^I should not see the JS dependency in the console output since it is approved$/) do
|
31
|
+
@output = @user.execute_command 'license_finder -q'
|
32
|
+
@output.should_not include 'my_js_dep, 1.2.3, MIT'
|
33
|
+
end
|
@@ -7,7 +7,7 @@ end
|
|
7
7
|
|
8
8
|
When(/^I set that gems license to MIT from the command line$/) do
|
9
9
|
@output = @user.execute_command 'license_finder -q'
|
10
|
-
@output = @user.execute_command 'license_finder
|
10
|
+
@output = @user.execute_command 'license_finder license MIT other_gem'
|
11
11
|
@output = @user.execute_command 'license_finder -q'
|
12
12
|
end
|
13
13
|
|
@@ -5,6 +5,11 @@ require 'capybara'
|
|
5
5
|
|
6
6
|
########## COMMON STEPS ##########
|
7
7
|
|
8
|
+
Given(/^I have an app with license finder$/) do
|
9
|
+
@user = ::DSL::User.new
|
10
|
+
@user.create_nonrails_app
|
11
|
+
end
|
12
|
+
|
8
13
|
When(/^I run license_finder$/) do
|
9
14
|
@output = @user.execute_command "license_finder -q"
|
10
15
|
end
|
@@ -103,14 +108,6 @@ module DSL
|
|
103
108
|
end
|
104
109
|
end
|
105
110
|
|
106
|
-
def configure_license_finder_bundler_whitelist(whitelisted_groups=[])
|
107
|
-
whitelisted_groups = Array whitelisted_groups
|
108
|
-
FileUtils.mkdir_p(config_path)
|
109
|
-
File.open(File.join(config_path, "license_finder.yml"), "w") do |f|
|
110
|
-
f.write({'ignore_groups' => whitelisted_groups}.to_yaml)
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
111
|
def execute_command(command)
|
115
112
|
Bundler.with_clean_env do
|
116
113
|
@output = `cd #{app_path} && bundle exec #{command}`
|
data/lib/license_finder.rb
CHANGED
@@ -5,32 +5,31 @@ require 'erb'
|
|
5
5
|
module LicenseFinder
|
6
6
|
ROOT_PATH = Pathname.new(__FILE__).dirname
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
autoload :
|
15
|
-
autoload :
|
16
|
-
autoload :
|
17
|
-
autoload :
|
18
|
-
autoload :
|
19
|
-
autoload :
|
20
|
-
autoload :PossibleLicenseFile,
|
21
|
-
autoload :
|
22
|
-
autoload :
|
23
|
-
|
24
|
-
autoload :
|
25
|
-
autoload :BundleSyncer, 'license_finder/bundle_syncer'
|
26
|
-
autoload :YmlToSql, 'license_finder/yml_to_sql'
|
27
|
-
autoload :Dependency, 'license_finder/tables/dependency'
|
28
|
-
autoload :Approval, 'license_finder/tables/approval'
|
29
|
-
autoload :LicenseAlias, 'license_finder/tables/license_alias'
|
8
|
+
Error = Class.new(StandardError)
|
9
|
+
|
10
|
+
autoload :Bundle, 'license_finder/bundle'
|
11
|
+
autoload :BundledGem, 'license_finder/bundled_gem'
|
12
|
+
autoload :BundledGemSaver, 'license_finder/bundled_gem_saver'
|
13
|
+
autoload :BundlerGroupManager, 'license_finder/bundler_group_manager'
|
14
|
+
autoload :CLI, 'license_finder/cli'
|
15
|
+
autoload :Configuration, 'license_finder/configuration'
|
16
|
+
autoload :DependencyManager, 'license_finder/dependency_manager'
|
17
|
+
autoload :License, 'license_finder/license'
|
18
|
+
autoload :LicenseUrl, 'license_finder/license_url'
|
19
|
+
autoload :Platform, 'license_finder/platform'
|
20
|
+
autoload :PossibleLicenseFile, 'license_finder/possible_license_file'
|
21
|
+
autoload :PossibleLicenseFiles, 'license_finder/possible_license_files'
|
22
|
+
autoload :YmlToSql, 'license_finder/yml_to_sql'
|
23
|
+
|
24
|
+
autoload :Approval, 'license_finder/tables/approval'
|
30
25
|
autoload :BundlerGroup, 'license_finder/tables/bundler_group'
|
31
|
-
autoload :
|
32
|
-
autoload :
|
33
|
-
|
26
|
+
autoload :Dependency, 'license_finder/tables/dependency'
|
27
|
+
autoload :LicenseAlias, 'license_finder/tables/license_alias'
|
28
|
+
|
29
|
+
autoload :DependencyReport, 'license_finder/reports/dependency_report'
|
30
|
+
autoload :HtmlReport, 'license_finder/reports/html_report'
|
31
|
+
autoload :Reporter, 'license_finder/reports/reporter'
|
32
|
+
autoload :TextReport, 'license_finder/reports/text_report'
|
34
33
|
|
35
34
|
def self.config
|
36
35
|
@config ||= Configuration.ensure_default
|
@@ -2,8 +2,8 @@ module LicenseFinder
|
|
2
2
|
class Bundle
|
3
3
|
attr_writer :ignore_groups
|
4
4
|
|
5
|
-
def self.
|
6
|
-
new(bundler_definition).gems
|
5
|
+
def self.current_gems(bundler_definition=nil)
|
6
|
+
new(bundler_definition).gems
|
7
7
|
end
|
8
8
|
|
9
9
|
def initialize(bundler_definition=nil)
|
@@ -34,15 +34,15 @@ module LicenseFinder
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def license_files
|
37
|
-
|
37
|
+
PossibleLicenseFiles.new(@spec.full_gem_path).find
|
38
38
|
end
|
39
39
|
|
40
40
|
def sort_order
|
41
41
|
dependency_name.downcase
|
42
42
|
end
|
43
43
|
|
44
|
-
def
|
45
|
-
|
44
|
+
def save_as_dependency
|
45
|
+
BundledGemSaver.find_or_initialize_by_name(@spec.name, self).save
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
@@ -1,13 +1,11 @@
|
|
1
1
|
module LicenseFinder
|
2
|
-
class
|
2
|
+
class BundledGemSaver
|
3
3
|
extend Forwardable
|
4
4
|
def_delegators :spec, :name, :version, :summary, :description, :homepage
|
5
5
|
def_delegators :bundled_gem, :bundler_dependency, :determine_license, :children
|
6
6
|
|
7
7
|
def self.find_or_initialize_by_name(name, bundled_gem)
|
8
|
-
dependency = Dependency.
|
9
|
-
d.approval = Approval.create
|
10
|
-
end
|
8
|
+
dependency = Dependency.named(name)
|
11
9
|
new(dependency, bundled_gem)
|
12
10
|
end
|
13
11
|
|
@@ -55,7 +53,7 @@ module LicenseFinder
|
|
55
53
|
def refresh_children
|
56
54
|
dependency.remove_all_children
|
57
55
|
children.each do |child|
|
58
|
-
dependency.add_child Dependency.
|
56
|
+
dependency.add_child Dependency.named(child)
|
59
57
|
end
|
60
58
|
end
|
61
59
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module LicenseFinder
|
2
|
+
module BundlerGroupManager
|
3
|
+
def self.add_ignored_group(group)
|
4
|
+
config = LicenseFinder.config
|
5
|
+
ignored_groups = config.ignore_groups.map(&:to_s)
|
6
|
+
return if ignored_groups.include?(group)
|
7
|
+
|
8
|
+
config.ignore_groups << group.to_sym
|
9
|
+
config.save_to_yaml
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.remove_ignored_group(group)
|
13
|
+
config = LicenseFinder.config
|
14
|
+
ignored_groups = config.ignore_groups.map(&:to_s)
|
15
|
+
return unless ignored_groups.include?(group)
|
16
|
+
|
17
|
+
config.ignore_groups.delete(group.to_sym)
|
18
|
+
config.save_to_yaml
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
data/lib/license_finder/cli.rb
CHANGED
@@ -1,49 +1,155 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
1
3
|
module LicenseFinder
|
2
4
|
module CLI
|
3
|
-
|
5
|
+
class Base < Thor
|
6
|
+
def self.subcommand(namespace, klass, namespace_description)
|
7
|
+
description = "#{namespace} [#{(klass.tasks.keys - ["help"]).join("|")}]"
|
8
|
+
desc description, "#{namespace_description} - see `license_finder #{namespace} help` for more information"
|
9
|
+
super namespace, klass
|
10
|
+
end
|
4
11
|
|
5
|
-
|
12
|
+
private
|
6
13
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
14
|
+
def die_on_error
|
15
|
+
yield
|
16
|
+
rescue LicenseFinder::Error => e
|
17
|
+
say e.message, :red
|
18
|
+
exit 1
|
19
|
+
end
|
20
|
+
end
|
11
21
|
|
12
|
-
|
22
|
+
class Dependencies < Base
|
23
|
+
option :approve, type: :boolean, aliases: :a
|
24
|
+
desc "add LICENSE DEPENDENCY_NAME [VERSION] [--approve]", "Add a dependency that is not managed by Bundler"
|
25
|
+
def add(license, name, version = nil)
|
26
|
+
die_on_error {
|
27
|
+
DependencyManager.create_non_bundler(license, name, version)
|
28
|
+
DependencyManager.approve!(name) if options[:approve]
|
29
|
+
}
|
30
|
+
if options[:approve]
|
31
|
+
say "The #{name} dependency has been added and approved!", :green
|
32
|
+
else
|
33
|
+
say "The #{name} dependency has been added!", :green
|
34
|
+
end
|
35
|
+
end
|
13
36
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
37
|
+
desc "remove DEPENDENCY_NAME", "Remove a dependency that is not managed by Bundler"
|
38
|
+
def remove(name)
|
39
|
+
die_on_error {
|
40
|
+
DependencyManager.destroy_non_bundler(name)
|
41
|
+
}
|
42
|
+
|
43
|
+
say "The #{name} dependency has been removed.", :green
|
21
44
|
end
|
22
45
|
end
|
23
46
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
dependency = Dependency.first(name: options[:dependency])
|
47
|
+
class IgnoredBundlerGroups < Base
|
48
|
+
desc "list", "List all the ignored bundler groups"
|
49
|
+
def list
|
50
|
+
ignored = LicenseFinder.config.ignore_groups
|
29
51
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
dependency.approve!
|
34
|
-
puts "The #{dependency.name} has been approved!\n\n"
|
35
|
-
elsif options[:license]
|
36
|
-
dependency.set_license_manually options[:license]
|
37
|
-
puts "The #{dependency.name} has been marked as using #{options[:license]} license!\n\n"
|
52
|
+
say "Ignored Bundler Groups:", :red
|
53
|
+
ignored.each do |group|
|
54
|
+
say group
|
38
55
|
end
|
56
|
+
end
|
57
|
+
|
58
|
+
desc "add", "Add a bundler group to be ignored"
|
59
|
+
def add(group)
|
60
|
+
die_on_error {
|
61
|
+
BundlerGroupManager.add_ignored_group(group)
|
62
|
+
}
|
63
|
+
say "Added #{group} to the ignored bundler groups"
|
64
|
+
end
|
39
65
|
|
40
|
-
|
66
|
+
desc "remove", "Remove a bundler group from the ignored bundler groups"
|
67
|
+
def remove(group)
|
68
|
+
die_on_error {
|
69
|
+
BundlerGroupManager.remove_ignored_group(group)
|
70
|
+
}
|
71
|
+
say "Removed #{group} from the ignored bundler groups"
|
41
72
|
end
|
42
73
|
end
|
43
74
|
|
44
|
-
|
45
|
-
|
46
|
-
|
75
|
+
class Main < Base
|
76
|
+
option :quiet, type: :boolean, aliases: :q
|
77
|
+
desc "rescan", "Find new dependencies."
|
78
|
+
def rescan
|
79
|
+
die_on_error {
|
80
|
+
spinner {
|
81
|
+
DependencyManager.sync_with_bundler
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
action_items
|
86
|
+
end
|
87
|
+
default_task :rescan
|
88
|
+
|
89
|
+
desc "approve DEPENDENCY_NAME", "Approve a dependency by name."
|
90
|
+
def approve(name)
|
91
|
+
die_on_error {
|
92
|
+
DependencyManager.approve!(name)
|
93
|
+
}
|
94
|
+
|
95
|
+
say "The #{name} dependency has been approved!", :green
|
96
|
+
end
|
97
|
+
|
98
|
+
desc "license LICENSE DEPENDENCY_NAME", "Update a dependency's license."
|
99
|
+
def license(license, name)
|
100
|
+
die_on_error {
|
101
|
+
DependencyManager.license!(name, license)
|
102
|
+
}
|
103
|
+
|
104
|
+
say "The #{name} dependency has been marked as using #{license} license!", :green
|
105
|
+
end
|
106
|
+
|
107
|
+
desc "move", "Move dependency.* files from root directory to doc/."
|
108
|
+
def move
|
109
|
+
Configuration.move!
|
110
|
+
say "Congratulations, you have cleaned up your root directory!'", :green
|
111
|
+
end
|
112
|
+
|
113
|
+
desc "action_items", "List unapproved dependencies"
|
114
|
+
def action_items
|
115
|
+
unapproved = Dependency.unapproved
|
116
|
+
|
117
|
+
if unapproved.empty?
|
118
|
+
say "All gems are approved for use", :green
|
119
|
+
else
|
120
|
+
say "Dependencies that need approval:", :red
|
121
|
+
say TextReport.new(unapproved)
|
122
|
+
exit 1
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
subcommand "dependencies", Dependencies, "manage non-Bundler dependencies"
|
127
|
+
subcommand "ignored_bundler_groups", IgnoredBundlerGroups, "manage ignored bundler groups"
|
128
|
+
|
129
|
+
private
|
130
|
+
|
131
|
+
def spinner
|
132
|
+
if options[:quiet]
|
133
|
+
yield
|
134
|
+
else
|
135
|
+
begin
|
136
|
+
thread = Thread.new {
|
137
|
+
wheel = '\|/-'
|
138
|
+
i = 0
|
139
|
+
while true do
|
140
|
+
print "\r ---------- #{wheel[i]} ----------"
|
141
|
+
i = (i + 1) % 4
|
142
|
+
end
|
143
|
+
}
|
144
|
+
yield
|
145
|
+
ensure
|
146
|
+
if thread
|
147
|
+
thread.kill
|
148
|
+
puts "\r" + " "*24
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
47
153
|
end
|
48
154
|
end
|
49
155
|
end
|