2020-06-12 20:03:43 +00:00
|
|
|
# License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later
|
|
|
|
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE
|
2020-06-04 16:19:29 +00:00
|
|
|
|
|
|
|
# Create notice files for dependencies
|
|
|
|
namespace :notice do
|
2020-06-11 21:19:42 +00:00
|
|
|
desc "generate NOTICE-ruby and NOTICE-js"
|
|
|
|
task :update => ['ruby:update', 'js:update']
|
2020-06-04 16:19:29 +00:00
|
|
|
namespace :ruby do
|
|
|
|
require 'bundler'
|
|
|
|
require 'httparty'
|
|
|
|
def get_notice_ruby
|
|
|
|
parser = Bundler::LockfileParser.new(File.read(Rails.root.join("Gemfile.lock")))
|
|
|
|
result = parser.specs.map do |spec|
|
|
|
|
"gem/rubygems/-/#{spec.name}/#{spec.version.to_s}"
|
|
|
|
end
|
|
|
|
|
|
|
|
@options = {
|
|
|
|
:headers => {
|
|
|
|
'Content-Type' => 'application/json',
|
|
|
|
'Accept' => 'application/json'
|
|
|
|
},
|
|
|
|
:timeout => 120
|
|
|
|
}
|
|
|
|
result = HTTParty.post("https://api.clearlydefined.io/notices", @options.merge(body:JSON::generate({coordinates: result})))
|
2020-06-05 17:56:20 +00:00
|
|
|
JSON::parse(result.body)['content']
|
2020-06-04 16:19:29 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "generating NOTICE-ruby from ClearlyDefined.io"
|
|
|
|
task :update do
|
|
|
|
result = get_notice_ruby
|
2020-06-05 17:56:20 +00:00
|
|
|
File.write('NOTICE-ruby', result)
|
2020-06-04 16:19:29 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "checking whether NOTICE-ruby matches the one on ClearlyDefined.io"
|
|
|
|
task :verify do
|
|
|
|
result = get_notice_ruby
|
2020-06-05 17:56:20 +00:00
|
|
|
raise "NOTICE-ruby is not up to date. Run bin/rails notice:ruby:update to update the file." if result != File.read('NOTICE-ruby')
|
2020-06-04 16:19:29 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
namespace :js do
|
2020-07-30 20:51:26 +00:00
|
|
|
notice_cmd = "npx @houdiniproject/noticeme@^1.0.0-pre5 -f NOTICE-js -i included.json"
|
2020-06-04 16:19:29 +00:00
|
|
|
|
|
|
|
desc "generating NOTICE-js from ClearlyDefined.io"
|
|
|
|
task :update do
|
2020-07-30 20:51:26 +00:00
|
|
|
raise "NOTICE-js could not be updated" unless system(notice_cmd + " -u")
|
2020-06-04 16:19:29 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "checking whether NOTICE-js matches the one on ClearlyDefined.io"
|
|
|
|
task :verify do
|
2020-07-30 20:51:26 +00:00
|
|
|
raise "NOTICE-js is not up to date. Run bin/rails notice:js:update to update the file" unless system(notice_cmd)
|
2020-06-04 16:19:29 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|