bin/init
#!/usr/bin/env ruby
require_relative 'helpers'
app_root do
use_docker = ask(
question: 'Would you like to use Docker Compose for Postgres?',
valid_answers: ['y', 'N']
)
header 'Configuring git'
target_upstream = "https://github.com/avo-hq/avo.git"
current_upstream = `git config --get remote.upstream.url`.chomp
if current_upstream.nil? || current_upstream.empty?
puts "Adding new remote 'upstream' to #{target_upstream}"
run! "git remote add upstream #{target_upstream}"
elsif current_upstream != target_upstream
puts "Updating existing remote 'upstream' to #{target_upstream}"
run! "git remote set-url upstream #{target_upstream}"
else
puts "Remote 'upstream' already points to #{target_upstream}, no change"
end
header 'Installing gems'
run! 'bundle install'
header 'Installing Yarn packages'
run! 'yarn'
run! '(cd spec/dummy; yarn)'
run! '(cp spec/dummy/.env.test.sample spec/dummy/.env.test)'
if use_docker == 'y'
header 'Creating the Docker volume'
run! 'docker volume create --name=avo-db-data'
header 'Creating and running the Docker image'
run! 'docker-compose up -d'
end
header 'Preparing the database'
run! 'bin/rails db:setup'
header 'Building assets'
run! 'yarn build:js'
run! 'yarn build:custom-js'
run! 'yarn build:css'
if use_docker == 'y'
header 'Stopping the Docker image'
run! 'docker-compose stop'
end
end