2020-10-15 19:21:50 +00:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
|
|
|
|
require "fileutils"
|
|
|
|
|
|
|
|
DIR = File.dirname __dir__
|
|
|
|
|
|
|
|
def execute cmd
|
|
|
|
puts cmd
|
|
|
|
abort unless system cmd
|
|
|
|
end
|
|
|
|
|
2021-01-09 19:16:24 +00:00
|
|
|
# In an autosynth (multi-library) run, a previous library synth may have
|
|
|
|
# created a new library. If so, autosynth doesn't clean up those newly created
|
|
|
|
# files (i.e. it runs git reset --hard but not git clean). Do that ourselves,
|
|
|
|
# so any previously created files don't pollute this and subsequent synth runs.
|
|
|
|
execute "git clean -df"
|
|
|
|
|
2021-01-01 20:29:10 +00:00
|
|
|
Dir.chdir "google-apis-generator"
|
2020-12-22 23:10:52 +00:00
|
|
|
|
2020-10-15 19:21:50 +00:00
|
|
|
execute "bundle install"
|
|
|
|
|
|
|
|
if ARGV.empty?
|
2020-12-31 22:55:59 +00:00
|
|
|
execute "echo a | bundle exec bin/generate-api gen #{DIR}/generated --from-discovery --no-preferred-only --names=#{DIR}/api_names.yaml --names-out=#{DIR}/api_names_out.yaml --spot-check"
|
2020-10-19 02:03:57 +00:00
|
|
|
elsif ARGV == ["--clean"] || ARGV == ["clean"]
|
2020-12-31 22:55:59 +00:00
|
|
|
execute "bundle exec bin/generate-api gen #{DIR}/generated --clean"
|
2020-10-15 19:21:50 +00:00
|
|
|
elsif ARGV.size == 2
|
|
|
|
api, version = ARGV
|
2020-12-31 22:55:59 +00:00
|
|
|
execute "echo a | bundle exec bin/generate-api gen #{DIR}/generated --api=#{api}.#{version} --names=#{DIR}/api_names.yaml --names-out=#{DIR}/api_names_out.yaml --spot-check"
|
2020-10-15 19:21:50 +00:00
|
|
|
else
|
|
|
|
abort "Bad arguments: #{ARGV}"
|
|
|
|
end
|