class BuntoAuth::Commands
Constants
- FILES
- VARS
Public Class Methods
changed?()
click to toggle source
# File lib/bunto_auth/commands.rb, line 14 def self.changed? !execute_command("git", "status", destination, "--porcelain").empty? rescue false end
configure_heroku(options)
click to toggle source
# File lib/bunto_auth/commands.rb, line 66 def self.configure_heroku(options) VARS.each do |var| execute_command "heroku", "config:set", "GITHUB_#{var.upcase}=#{options[var]}" if options[var] end end
copy_templates()
click to toggle source
# File lib/bunto_auth/commands.rb, line 26 def self.copy_templates FILES.each do |file| if File.exist? "#{destination}/#{file}" puts "* #{destination}/#{file} already exists... skipping." else puts "* creating #{destination}/#{file}" FileUtils.cp "#{source}/#{file}", "#{destination}/#{file}" end end end
destination()
click to toggle source
# File lib/bunto_auth/commands.rb, line 10 def self.destination @destination ||= Dir.pwd end
env_var_set?(var)
click to toggle source
# File lib/bunto_auth/commands.rb, line 45 def self.env_var_set?(var) !ENV[var].to_s.blank? end
execute_command(*args)
click to toggle source
# File lib/bunto_auth/commands.rb, line 20 def self.execute_command(*args) output, status = Open3.capture2e(*args) raise "Command `#{args.join(" ")}` failed: #{output}" unless status.exitstatus.zero? output end
heroku_remote_set?()
click to toggle source
# File lib/bunto_auth/commands.rb, line 61 def self.heroku_remote_set? remotes = execute_command "git", "remote", "-v" !!(remotes =~ %r!^heroku\s!) end
init_repo()
click to toggle source
# File lib/bunto_auth/commands.rb, line 49 def self.init_repo execute_command "git", "init", destination FILES.each do |file| next if file == ".env" execute_command("git", "add", "--", "#{destination}/#{file}") end end
initial_commit()
click to toggle source
# File lib/bunto_auth/commands.rb, line 57 def self.initial_commit execute_command "git", "commit", "-m", "'[Bunto Auth] Initial setup'" end
source()
click to toggle source
# File lib/bunto_auth/commands.rb, line 6 def self.source @source ||= File.expand_path("../../templates", File.dirname(__FILE__)) end
team_id(org, team)
click to toggle source
# File lib/bunto_auth/commands.rb, line 37 def self.team_id(org, team) client = Octokit::Client.new :access_token => ENV["GITHUB_TOKEN"] client.auto_paginate = true teams = client.organization_teams org found = teams.find { |t| t[:slug] == team } found[:id] if found end