class Flubber::Deploy
Constants
- FILE_ALL_EXPO_APPS_HAVE
- FOLDERS_TO_UPLOAD
Attributes
selection[R]
Public Class Methods
deploy()
click to toggle source
# File lib/deploy.rb, line 25 def self.deploy new.deploy end
Public Instance Methods
deploy()
click to toggle source
# File lib/deploy.rb, line 29 def deploy unless working_directory_is_an_expo_project? puts "Failed. Run me in an expo project." return end remove_bundle set_flubber_app puts "Using app #{App.name}" generate_bundle upload_bundle remove_bundle log_deploy end
Private Instance Methods
api_token()
click to toggle source
# File lib/deploy.rb, line 157 def api_token @api_token ||= ApiToken.get end
ask_for_which_flubber_app_to_use()
click to toggle source
# File lib/deploy.rb, line 103 def ask_for_which_flubber_app_to_use print_existing_app_options print_new_app_option loop do print "Which app? " @selection = STDIN.gets.chomp.to_i if existing_app_selected? use_existing_app_selection break elsif new_app_selected? create_new_app break end puts "Not an option" end end
create_new_app()
click to toggle source
# File lib/deploy.rb, line 92 def create_new_app print "Name your app: " name = STDIN.gets.chomp app = JSON.parse(Faraday.post( "#{API_URL}/apps", { "name": name }, { "Authorization" => "Bearer #{api_token}" }, ).body) App.set(app) end
existing_app_selected?()
click to toggle source
# File lib/deploy.rb, line 79 def existing_app_selected? selection >= 1 && selection <= flubber_apps.count end
flubber_app_is_set?()
click to toggle source
# File lib/deploy.rb, line 57 def flubber_app_is_set? App.set? end
flubber_apps()
click to toggle source
# File lib/deploy.rb, line 61 def flubber_apps @flubber_apps ||= JSON.parse(Faraday.get( "#{API_URL}/apps", {}, { "Authorization" => "Bearer #{api_token}" }, ).body) end
generate_bundle()
click to toggle source
# File lib/deploy.rb, line 120 def generate_bundle bundling_spinner = TTY::Spinner.new( "[:spinner] Bundling ...", format: :dots, ) bundling_spinner.auto_spin `expo export --public-url #{App.bundles_public_url}` bundling_spinner.stop('Done!') end
log_deploy()
click to toggle source
# File lib/deploy.rb, line 145 def log_deploy Faraday.post( "#{API_URL}/apps/#{App.id}/updates", { "commit_sha": sha }, { "Authorization" => "Bearer #{api_token}" }, ) end
new_app_selected?()
click to toggle source
# File lib/deploy.rb, line 83 def new_app_selected? selection == flubber_apps.count + 1 end
print_existing_app_options()
click to toggle source
# File lib/deploy.rb, line 69 def print_existing_app_options flubber_apps.each_with_index do |app, index| puts "#{index + 1}. #{app["name"]}" end end
print_new_app_option()
click to toggle source
# File lib/deploy.rb, line 75 def print_new_app_option puts "#{flubber_apps.count + 1}. Create A New Flubber App" end
remove_bundle()
click to toggle source
# File lib/deploy.rb, line 161 def remove_bundle `rm -rf dist` end
set_flubber_app()
click to toggle source
# File lib/deploy.rb, line 52 def set_flubber_app return if flubber_app_is_set? ask_for_which_flubber_app_to_use end
sha()
click to toggle source
# File lib/deploy.rb, line 153 def sha @sha ||= Git.open(".").log.first.sha end
upload_bundle()
click to toggle source
# File lib/deploy.rb, line 130 def upload_bundle uploading_spinner = TTY::Spinner.new( "[:spinner] Uploading ...", format: :dots, ) uploading_spinner.auto_spin FOLDERS_TO_UPLOAD.each do |folder| AwsFolderUpload.upload( folder_name: folder[:name], aws_destination: folder[:aws_destination], ) end uploading_spinner.stop('Done!') end
use_existing_app_selection()
click to toggle source
# File lib/deploy.rb, line 87 def use_existing_app_selection flubber_app_index = selection - 1 App.set(flubber_apps[flubber_app_index]) end
working_directory_is_an_expo_project?()
click to toggle source
# File lib/deploy.rb, line 47 def working_directory_is_an_expo_project? @working_directory_is_an_expo_project ||= \ File.exist?(FILE_ALL_EXPO_APPS_HAVE) end