class MobileWorkflowCli::AppBuilder

Public Instance Methods

ability_generator() click to toggle source
# File lib/mobile_workflow_cli/app_builder.rb, line 20
def ability_generator
  copy_file 'ability.rb', 'app/models/ability.rb'
end
active_storage() click to toggle source
# File lib/mobile_workflow_cli/app_builder.rb, line 24
def active_storage
  rails_command 'active_storage:install'
  copy_file 'storage.s3.yml', 'config/storage.yml'
  gsub_file 'config/environments/production.rb', 'config.active_storage.service = :local', 'config.active_storage.service = :amazon'  
end
dokku(dokku_host) click to toggle source
# File lib/mobile_workflow_cli/app_builder.rb, line 63
def dokku(dokku_host)
  @dokku_host = dokku_host
  dokku_backend.create
  dokku_backend.configure_activestorage if options[:s3_storage]
  dokku_backend.deploy
  dokku_backend.sync_dotenv
end
gemfile() click to toggle source
# File lib/mobile_workflow_cli/app_builder.rb, line 7
def gemfile
  template 'Gemfile.erb', 'Gemfile'
end
heroku() click to toggle source
# File lib/mobile_workflow_cli/app_builder.rb, line 56
def heroku
  heroku_backend.create
  heroku_backend.configure_activestorage if options[:s3_storage]
  heroku_backend.deploy
  heroku_backend.sync_dotenv
end
mobile_workflow_generator(open_api_spec_path) click to toggle source
# File lib/mobile_workflow_cli/app_builder.rb, line 30
def mobile_workflow_generator(open_api_spec_path)
  copy_file open_api_spec_path, 'config/open_api_spec.json'
  gen_opts = ""
  gen_opts += "--doorkeeper_oauth" if options[:doorkeeper_oauth]
  generate "mobile_workflow:install #{gen_opts}"
  
  # Copy user migrations if needed
  rails_command 'mobile_workflow:install:migrations' if options[:doorkeeper_oauth]
end
procfiles() click to toggle source
# File lib/mobile_workflow_cli/app_builder.rb, line 11
def procfiles
  copy_file 'Procfile', 'Procfile'
  copy_file 'Procfile.dev', 'Procfile.dev'
end
readme() click to toggle source
# File lib/mobile_workflow_cli/app_builder.rb, line 3
def readme
  template 'README.md.erb', 'README.md'
end
rspec_generator() click to toggle source
# File lib/mobile_workflow_cli/app_builder.rb, line 16
def rspec_generator
  generate 'rspec:install'
end
s3_backend(region) click to toggle source
# File lib/mobile_workflow_cli/app_builder.rb, line 40
def s3_backend(region)
  @region = region
  aws_backend.create
  aws_backend.write_env
  
  if options[:heroku]
    heroku_backend.sync_dotenv
    sleep 10 # Wait for the server to restart
    aws_backend.create_topic_subscription(heroku_backend.notifications_endpoint)
  elsif options[:dokku]
    dokku_backend.sync_dotenv 
    aws_backend.create_topic_subscription(dokku_backend.notifications_endpoint)      
  end
  
end

Private Instance Methods

aws_backend() click to toggle source
# File lib/mobile_workflow_cli/app_builder.rb, line 72
def aws_backend
  @aws_backend ||= AwsBackend.new(app_name: app_name, region: @region)
end
dokku_backend() click to toggle source
# File lib/mobile_workflow_cli/app_builder.rb, line 76
def dokku_backend
  @dokku_backend ||= DokkuBackend.new(app_name: app_name, dokku_host: @dokku_host)
end
heroku_backend() click to toggle source
# File lib/mobile_workflow_cli/app_builder.rb, line 80
def heroku_backend
  @heroku_backend ||= HerokuBackend.new(app_name: app_name)
end