Skip to content

Commit

Permalink
rake outdated task
Browse files Browse the repository at this point in the history
lists outdated puppet modules
  • Loading branch information
rrotter committed May 8, 2024
1 parent 09ad393 commit d75df96
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,35 @@ desc "rm Puppetfile.lock"
task :librarian_clean do |t|
FileUtils.rm_f('Puppetfile.lock')
end

desc "list outdated modules in .fixtures.yml"
task :outdated do |t|
require 'yaml'
require 'net/http'
require 'uri'
require 'json'

fixtures = YAML.load_file('.fixtures.yml')
fixtures['fixtures']['forge_modules'].values.each do |mod|
repo = mod['repo']
slug = repo.tr('/','-')
vers = mod['ref']
uri = URI.parse "https://forgeapi.puppet.com/v3/modules/#{slug}"

response = Net::HTTP.get_response(uri)
raise "failed to fetch #{mod['repo']}" unless response.code == '200'

releases = JSON.parse(response.body)['releases'].map{|x| x['version']}
latest = releases.first
installed_index = releases.find_index(vers)
installed = releases[installed_index]

if installed_index != 0
newer = releases.slice(0,installed_index).join(', ')
puts "#{repo} (#{installed}) < #{newer}"
puts "https://forge.puppet.com/modules/#{repo}"

puts
end
end
end

0 comments on commit d75df96

Please sign in to comment.