Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relax thor version requirement #816

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/license_finder/cli/approvals.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ def add(*names)
assert_some names
modifying { names.each { |name| decisions.approve(name, txn) } }

say "The #{names.join(', ')} dependency has been approved!", :green
say! "The #{names.join(', ')} dependency has been approved!", :green
end

auditable
desc 'remove DEPENDENCY', 'Unapprove a dependency'
def remove(dep)
modifying { decisions.unapprove(dep, txn) }

say "The dependency #{dep} no longer has a manual approval"
say! "The dependency #{dep} no longer has a manual approval"
end
end
end
Expand Down
16 changes: 13 additions & 3 deletions lib/license_finder/cli/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def config
private

def fail(message)
say(message) && exit(1)
say!(message) && exit(1)
end

def license_finder_config
Expand Down Expand Up @@ -81,13 +81,23 @@ def logger_mode
end
end

def say!(*args)
@loud = true
say(*args)
@loud = false
end

def quiet?
@loud ? false : super
end

def say_each(coll)
if coll.any?
coll.each do |item|
say(block_given? ? yield(item) : item)
say!(block_given? ? yield(item) : item)
end
else
say '(none)'
say! '(none)'
end
end

Expand Down
8 changes: 4 additions & 4 deletions lib/license_finder/cli/dependencies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ def add(name, license, version)
decisions.approve(name, txn) if options[:approve]
end
if options[:approve]
say "The #{name} dependency has been added and approved!", :green
say! "The #{name} dependency has been added and approved!", :green
else
say "The #{name} dependency has been added!", :green
say! "The #{name} dependency has been added!", :green
end
end

Expand All @@ -31,12 +31,12 @@ def add(name, license, version)
def remove(name)
modifying { decisions.remove_package(name, txn) }

say "The #{name} dependency has been removed.", :green
say! "The #{name} dependency has been removed.", :green
end

desc 'list', 'List manually added dependencies'
def list
say 'Manually Added Dependencies:', :blue
say! 'Manually Added Dependencies:', :blue
say_each(decisions.packages, &:name)
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/license_finder/cli/ignored_dependencies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class IgnoredDependencies < Base

desc 'list', 'List all the ignored dependencies'
def list
say 'Ignored Dependencies:', :blue
say! 'Ignored Dependencies:', :blue
say_each(decisions.ignored)
end

Expand All @@ -17,15 +17,15 @@ def list
def add(dep)
modifying { decisions.ignore(dep, txn) }

say "Added #{dep} to the ignored dependencies"
say! "Added #{dep} to the ignored dependencies"
end

auditable
desc 'remove DEPENDENCY', 'Remove a dependency from the ignored dependencies'
def remove(dep)
modifying { decisions.heed(dep, txn) }

say "Removed #{dep} from the ignored dependencies"
say! "Removed #{dep} from the ignored dependencies"
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/license_finder/cli/ignored_groups.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class IgnoredGroups < Base

desc 'list', 'List all the ignored groups'
def list
say 'Ignored Groups:', :blue
say! 'Ignored Groups:', :blue
say_each(decisions.ignored_groups)
end

Expand All @@ -17,15 +17,15 @@ def list
def add(group)
modifying { decisions.ignore_group(group, txn) }

say "Added #{group} to the ignored groups"
say! "Added #{group} to the ignored groups"
end

auditable
desc 'remove GROUP', 'Remove a group from the ignored groups'
def remove(group)
modifying { decisions.heed_group(group, txn) }

say "Removed #{group} from the ignored groups"
say! "Removed #{group} from the ignored groups"
end
end
end
Expand Down
10 changes: 5 additions & 5 deletions lib/license_finder/cli/inherited_decisions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class InheritedDecisions < Base

desc 'list', 'List all the inherited decision files'
def list
say 'Inherited Decision Files:', :blue
say! 'Inherited Decision Files:', :blue
say_each(decisions.inherited_decisions)
end

Expand All @@ -17,7 +17,7 @@ def list
def add(*decision_files)
assert_some decision_files
modifying { decision_files.each { |filepath| decisions.inherit_from(filepath) } }
say "Added #{decision_files.join(', ')} to the inherited decisions"
say! "Added #{decision_files.join(', ')} to the inherited decisions"
end

auditable
Expand All @@ -26,15 +26,15 @@ def add_with_auth(*params)
url, auth_type, token_or_env = params
auth_info = { 'url' => url, 'authorization' => "#{auth_type} #{token_or_env}" }
modifying { decisions.add_decision [:inherit_from, auth_info] }
say "Added #{url} to the inherited decisions"
say! "Added #{url} to the inherited decisions"
end

auditable
desc 'remove DECISION_FILE...', 'Remove one or more decision files from the inherited decisions'
def remove(*decision_files)
assert_some decision_files
modifying { decision_files.each { |filepath| decisions.remove_inheritance(filepath) } }
say "Removed #{decision_files.join(', ')} from the inherited decisions"
say! "Removed #{decision_files.join(', ')} from the inherited decisions"
end

auditable
Expand All @@ -43,7 +43,7 @@ def remove_with_auth(*params)
url, auth_type, token_or_env = params
auth_info = { 'url' => url, 'authorization' => "#{auth_type} #{token_or_env}" }
modifying { decisions.remove_inheritance(auth_info) }
say "Removed #{url} from the inherited decisions"
say! "Removed #{url} from the inherited decisions"
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/license_finder/cli/licenses.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ class Licenses < Base
def add(name, license)
modifying { decisions.license(name, license, txn) }

say "The #{name} dependency has been marked as using #{license} license!", :green
say! "The #{name} dependency has been marked as using #{license} license!", :green
end

auditable
desc 'remove DEPENDENCY LICENSE', 'Remove a manually set license'
def remove(dep, lic)
modifying { decisions.unlicense(dep, lic, txn) }

say "The dependency #{dep} no longer has a manual license"
say! "The dependency #{dep} no longer has a manual license"
end
end
end
Expand Down
20 changes: 10 additions & 10 deletions lib/license_finder/cli/main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def project_roots

filtered_project_roots << project_path if aggregate_paths.include?(project_path) && !filtered_project_roots.include?(project_path)

say(filtered_project_roots)
say!(filtered_project_roots)
end

desc 'action_items', 'List unapproved dependencies (the default action for `license_finder`)'
Expand All @@ -115,25 +115,25 @@ def action_items
restricted = finder.restricted

# Ensure to start output on a new line even with dot progress indicators.
say "\n"
say! "\n"

unless any_packages
say 'No dependencies recognized!', :red
say! 'No dependencies recognized!', :red
exit 0
end

if unapproved.empty?
say 'All dependencies are approved for use', :green
say! 'All dependencies are approved for use', :green
else
unless restricted.empty?
say 'Restricted dependencies:', :red
say report_of(restricted)
say! 'Restricted dependencies:', :red
say! report_of(restricted)
end

other_unapproved = unapproved - restricted
unless other_unapproved.empty?
say 'Dependencies that need approval:', :yellow
say report_of(other_unapproved)
say! 'Dependencies that need approval:', :yellow
say! report_of(other_unapproved)
end

exit 1
Expand All @@ -151,7 +151,7 @@ def action_items
def report
finder = LicenseAggregator.new(config, aggregate_paths)
report = report_of(finder.dependencies)
save? ? save_report(report, config.save_file) : say(report)
save? ? save_report(report, config.save_file) : say!(report)
end

desc 'version', 'Print the version of LicenseFinder'
Expand All @@ -166,7 +166,7 @@ def diff(file1, file2)
f1 = IO.read(file1)
f2 = IO.read(file2)
report = DiffReport.new(Diff.compare(f1, f2))
save? ? save_report(report, config.save_file) : say(report)
save? ? save_report(report, config.save_file) : say!(report)
end

subcommand 'dependencies', Dependencies, 'Add or remove dependencies that your package managers are not aware of'
Expand Down
6 changes: 3 additions & 3 deletions lib/license_finder/cli/permitted_licenses.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class PermittedLicenses < Base

desc 'list', 'List all the permitted licenses'
def list
say 'Permitted Licenses:', :blue
say! 'Permitted Licenses:', :blue
say_each(decisions.permitted, &:name)
end

Expand All @@ -17,15 +17,15 @@ def list
def add(*licenses)
assert_some licenses
modifying { licenses.each { |l| decisions.permit(l, txn) } }
say "Added #{licenses.join(', ')} to the permitted licenses"
say! "Added #{licenses.join(', ')} to the permitted licenses"
end

auditable
desc 'remove LICENSE...', 'Remove one or more licenses from the permitted licenses'
def remove(*licenses)
assert_some licenses
modifying { licenses.each { |l| decisions.unpermit(l, txn) } }
say "Removed #{licenses.join(', ')} from the license permitted licenses"
say! "Removed #{licenses.join(', ')} from the license permitted licenses"
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions lib/license_finder/cli/project_name.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@ class ProjectName < Base

desc 'show', 'Show the project name'
def show
say 'Project Name:', :blue
say decisions.project_name
say! 'Project Name:', :blue
say! decisions.project_name
end

auditable
desc 'add NAME', 'Set the project name'
def add(name)
modifying { decisions.name_project(name, txn) }

say "Set the project name to #{name}", :green
say! "Set the project name to #{name}", :green
end

auditable
desc 'remove', 'Remove the project name'
def remove
modifying { decisions.unname_project(txn) }

say 'Removed the project name'
say! 'Removed the project name'
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/license_finder/cli/restricted_licenses.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class RestrictedLicenses < Base

desc 'list', 'List all the restricted licenses'
def list
say 'Restricted Licenses:', :blue
say! 'Restricted Licenses:', :blue
say_each(decisions.restricted, &:name)
end

Expand All @@ -17,15 +17,15 @@ def list
def add(*licenses)
assert_some licenses
modifying { licenses.each { |l| decisions.restrict(l, txn) } }
say "Added #{licenses.join(', ')} to the restricted licenses"
say! "Added #{licenses.join(', ')} to the restricted licenses"
end

auditable
desc 'remove LICENSE...', 'Remove one or more licenses from the restricted licenses'
def remove(*licenses)
assert_some licenses
modifying { licenses.each { |l| decisions.unrestrict(l, txn) } }
say "Removed #{licenses.join(', ')} from the restricted licenses"
say! "Removed #{licenses.join(', ')} from the restricted licenses"
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion license_finder.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Gem::Specification.new do |s|

s.add_dependency 'bundler'
s.add_dependency 'rubyzip', '>=1', '<3'
s.add_dependency 'thor', '~> 1.0.1'
s.add_dependency 'thor', '~> 1.0'
s.add_dependency 'tomlrb', '>= 1.3', '< 2.1'
s.add_dependency 'with_env', '1.1.0'
s.add_dependency 'xml-simple', '~> 1.1.5'
Expand Down