mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
clients: fix API builder (#290)
This commit is contained in:
@@ -12,19 +12,18 @@ If this is your first time building the clients, you'll need to do the following
|
|||||||
gem install http
|
gem install http
|
||||||
```
|
```
|
||||||
|
|
||||||
2) Create a secret gist on Github and get an API token too.
|
2) Create a secret gist on Github and get an API token too.
|
||||||
|
|
||||||
### Every Time
|
### Every Time
|
||||||
|
|
||||||
Everytime the API spec is updated, be sure to bump the version number in `swagger.yml`, then run:
|
Everytime the API spec is updated, be sure to bump the version number in `swagger.yml`, then run:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# The GITHUB_TOKEN, GITHUB_USERNAME and GIST_ID requirement is temporary, just used to automate the gist. Once this is public, we don't need the gist anymore.
|
ruby build.rb
|
||||||
GITHUB_TOKEN=X GITHUB_USERNAME=treeder GIST_ID=Y ruby build.rb
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Boom. That's it.
|
Boom. That's it.
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
Sometimes this will fail due to github caching or something and versions will be off. Just bump version and retry.
|
Sometimes this will fail due to github caching or something and versions will be off. Just bump version and retry.
|
||||||
|
|||||||
@@ -6,20 +6,7 @@ require 'openssl'
|
|||||||
|
|
||||||
require_relative '../tests/utils.rb'
|
require_relative '../tests/utils.rb'
|
||||||
|
|
||||||
gist_id = ENV['GIST_ID']
|
swaggerUrl = "https://raw.githubusercontent.com/iron-io/functions/master/docs/swagger.yml"
|
||||||
gist_url = "https://api.github.com/gists/#{gist_id}"
|
|
||||||
puts gist_url
|
|
||||||
HTTP.auth("Token #{ENV['GITHUB_TOKEN']}")
|
|
||||||
.patch(gist_url, :json => {
|
|
||||||
"files"=> {
|
|
||||||
"swagger.yml" => {
|
|
||||||
"content" => File.read('../docs/swagger.yml')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
swaggerUrl = "https://gist.githubusercontent.com/#{ENV['GITHUB_USERNAME']}/#{gist_id}/raw/"
|
|
||||||
# swaggerRaw = open(swaggerUrl){|f| f.read}
|
|
||||||
spec = YAML.load(open(swaggerUrl))
|
spec = YAML.load(open(swaggerUrl))
|
||||||
version = spec['info']['version']
|
version = spec['info']['version']
|
||||||
puts "VERSION: #{version}"
|
puts "VERSION: #{version}"
|
||||||
@@ -58,7 +45,7 @@ languages.each do |l|
|
|||||||
deploy = []
|
deploy = []
|
||||||
case l
|
case l
|
||||||
when 'go'
|
when 'go'
|
||||||
clone(lshort)
|
clone(lshort)
|
||||||
glob_pattern = ['functions', "**", "*.go"]
|
glob_pattern = ['functions', "**", "*.go"]
|
||||||
copy_dir = "."
|
copy_dir = "."
|
||||||
options['packageName'] = 'functions'
|
options['packageName'] = 'functions'
|
||||||
@@ -82,7 +69,7 @@ languages.each do |l|
|
|||||||
# copy_dir = "javascript-client/."
|
# copy_dir = "javascript-client/."
|
||||||
clone(lshort)
|
clone(lshort)
|
||||||
options['projectName'] = "iron_functions"
|
options['projectName'] = "iron_functions"
|
||||||
deploy << "npm publish"
|
deploy << "npm publish"
|
||||||
else
|
else
|
||||||
puts "Skipping #{l}"
|
puts "Skipping #{l}"
|
||||||
next
|
next
|
||||||
@@ -117,7 +104,7 @@ languages.each do |l|
|
|||||||
destdir = "tmp/functions_#{lshort}"
|
destdir = "tmp/functions_#{lshort}"
|
||||||
puts "Trying cp", "tmp/#{lv}/#{l}-client/#{copy_dir}", destdir
|
puts "Trying cp", "tmp/#{lv}/#{l}-client/#{copy_dir}", destdir
|
||||||
FileUtils.cp_r("tmp/#{lv}/#{l}-client/#{copy_dir}", destdir)
|
FileUtils.cp_r("tmp/#{lv}/#{l}-client/#{copy_dir}", destdir)
|
||||||
# Write a version file, this ensures there's always a change.
|
# Write a version file, this ensures there's always a change.
|
||||||
File.open("#{destdir}/VERSION", 'w') { |file| file.write(version) }
|
File.open("#{destdir}/VERSION", 'w') { |file| file.write(version) }
|
||||||
|
|
||||||
# Commit and push
|
# Commit and push
|
||||||
@@ -135,7 +122,7 @@ languages.each do |l|
|
|||||||
if ex.last_line.include?("nothing to commit") || ex.last_line.include?("already exists") || ex.last_line.include?("no changes added to commit")
|
if ex.last_line.include?("nothing to commit") || ex.last_line.include?("already exists") || ex.last_line.include?("no changes added to commit")
|
||||||
# ignore this
|
# ignore this
|
||||||
puts "Ignoring error"
|
puts "Ignoring error"
|
||||||
else
|
else
|
||||||
raise ex
|
raise ex
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user