#!/usr/bin/env ruby

# This tests installing runtime dependencies for all providers, as part of # a second stage in .travis.yml.

$: << ‘lib’

require ‘dpl’

def opts_for(provider)

opts = provider.opts.select(&:required?)
opts = opts + [provider.opts[provider.required.map(&:first).first]].compact
opts.map { |opt| opt_for(opt) }.join(' ')

end

def opt_for(opt)

"--#{opt.name} #{opt.enum? ? opt.enum.first : 'str'}"

end

def run(cmd)

puts
puts cmd
fail unless system cmd

end

skip = %i(help heroku pages provider) keys = Dpl::Provider.registry.keys.sort - skip providers = keys.map { |key| Dpl::Provider }

providers.each do |provider|

run "bin/dpl #{provider.registry_key} --stage install #{opts_for(provider)}"
# run 'gem list'

end