Skip to content

Instantly share code, notes, and snippets.

@cjavilla-stripe
Created July 28, 2020 18:25
Show Gist options
  • Save cjavilla-stripe/2c02ab1b30bd867926baa42a0a7b4d81 to your computer and use it in GitHub Desktop.
Save cjavilla-stripe/2c02ab1b30bd867926baa42a0a7b4d81 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
require 'octokit'
require 'dotenv'
require 'restclient'
require 'json'
Dotenv.load('.env_shortcut')
GITHUB = "https://raw.githubusercontent.com/%s/master/.cli.json"
# Set access_token instead of login and password if you use personal access token
client = Octokit::Client.new(access_token: ENV['GK'])
results = []
results << [
'name',
'has_cli',
'integration_name',
"ruby",
"node",
"php",
"php-slim",
"java",
"python",
"go",
"dotnet",
"typescript",
"clients"
].join(",")
# Fetch the current user
repo = client.org_repos('stripe-samples', per_page: 100).each do |repo|
begin
response = RestClient.get(GITHUB % repo.full_name)
cli_data = JSON.parse(response)
has_cli = true
rescue RestClient::NotFound => e
has_cli = false
rescue => e
p e
end
if !has_cli
results << [
repo.name,
has_cli,
].join(",")
else
cli_data["integrations"].each do |integration|
results << [
repo.name,
has_cli,
integration["name"],
integration["servers"].include?("ruby"),
integration["servers"].include?("node"),
integration["servers"].include?("php"),
integration["servers"].include?("php-slim"),
integration["servers"].include?("java"),
integration["servers"].include?("python"),
integration["servers"].include?("go"),
integration["servers"].include?("dotnet"),
integration["servers"].include?("node-typescript") || integration["servers"].include?("typescript"),
integration["clients"].join("|"),
].join(",")
if !(integration["servers"] - ["ruby", "node", "php", "php-slim", "python", "go", "dotnet", "java", "node-typescript", "typescript"]).empty?
p integration["servers"]
end
end
end
end
puts results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment