Skip to content

Commit

Permalink
v1.4.9
Browse files Browse the repository at this point in the history
  • Loading branch information
robplan committed Nov 22, 2024
1 parent c9bc91c commit c2ac257
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
neptuno (1.4.1)
neptuno (1.4.8)
dotiw
dry-cli
hirb
Expand Down
27 changes: 14 additions & 13 deletions lib/neptuno/cli/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,34 @@ class Install < Dry::CLI::Command
include TTY::Config
include TTY::Which

desc "Installs git, docker, tmux, tmuxinator and overmind"
desc 'Installs git, docker, tmux, tmuxinator and overmind'

CONFIG = nil

def call(**)
install "git"
install "docker"
install "tmux"
install "overmind"
install "tmuxinator"
install 'git'
install 'docker'
install 'tmux'
install 'overmind'
install 'tmuxinator'

return unless system("apt-get -v")
return unless system('apt-get -v')

system("sudo apt-get update")
system('sudo apt-get update')
end

def install(package)
if ::TTY::Which.exist?(package)
puts "#{package} is already installed"
else
puts "Installing #{package}"
if system("brew -v")
if system('brew -v')
system("brew install #{package}")
elsif package == "overmind"
system("go install github.com/DarthSim/overmind/v2@latest")
elsif package == "tmuxinator"
system("gem install tmuxinator")
elsif package == 'overmind'
system('go install github.com/DarthSim/overmind/v2@latest')
elsif package == 'tmuxinator'
system('ASDF_RUBY_VERSION=system gem update bundler')
system('ASDF_RUBY_VERSION=system gem install tmuxinator')
else
system("sudo apt-get install #{package} -y")
end
Expand Down
5 changes: 5 additions & 0 deletions lib/neptuno/docker/build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ class Build < Neptuno::CLI::Base
def call(services: [], **options)
command_services_to('build', all: options.fetch(:all), services_as_args: services) do |services|
make_service_files(services)
populated = system("cd #{neptuno_path}/services/#{service} 2>/dev/null && git add .")
unless populated
puts 'Initializing git submodule'
system("cd #{neptuno_path}/services/#{service} 2>/dev/null && git submodule update --init --recursive #{neptuno_path}/services/#{service}")
end
opts = options.fetch(:options, nil) || get_gpr
services.each do |service|
puts '********************'
Expand Down
2 changes: 1 addition & 1 deletion lib/neptuno/docker/down.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def call(services: [], **options)
puts "Neptuno killed Tmux session for: #{service}" if `echo $TMUX`.strip.empty?
end
else
system("cd #{neptuno_path} && tmux kill-session -t neptuno")
# system("cd #{neptuno_path} && tmux kill-session -t neptuno")
services_to_stop.each do
system("cd #{neptuno_path}/procfiles/#{service} && rm .overmind.sock > /dev/null 2>&1")
end
Expand Down
2 changes: 2 additions & 0 deletions lib/neptuno/docker/restart.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class Restart < Neptuno::CLI::Base
desc 'Docker: Rebuild and restart docker containers for current project'

option :all, type: :boolean, default: false, desc: 'Run on all services'
option :volumes, type: :boolean, default: false, desc: 'Remove named volumes'
argument :services, type: :array, required: false, desc: 'Optional list of services'
option :options, required: false, desc: 'Optional string of options passed to build'

Expand All @@ -15,6 +16,7 @@ def call(services: [], **options)
make_service_files(services)
opts = options.fetch(:options, nil) || get_gpr
system("cd #{neptuno_path} && docker compose stop -t 0 #{services.join(' ')}")
system("cd #{neptuno_path} && docker compose down -v #{services.join(' ')}") if options.fetch(:volumes)
system("cd #{neptuno_path} && docker compose rm -f #{services.join(' ')}")
system("cd #{neptuno_path} && docker compose build #{opts} #{services.join(' ')}")
system("cd #{neptuno_path} && docker compose up -d #{services.join(' ')}")
Expand Down
9 changes: 9 additions & 0 deletions lib/neptuno/docker/up.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ class Up < Neptuno::CLI::Base
def call(services: [], **options)
command_services_to('come up', all: options.fetch(:all), services_as_args: services) do |services, _project|
make_service_files(services)

services.each do |service|
populated = system("cd #{neptuno_path}/services/#{service} 2>/dev/null && git add .")
unless populated
puts 'Initializing git submodule'
system("cd #{neptuno_path}/services/#{service} 2>/dev/null && git submodule update --init --recursive #{neptuno_path}/services/#{service}")
end
end

system("cd #{neptuno_path} && docker compose up -d --wait #{services.join(' ')}")
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/neptuno/environment/update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Neptuno
module Environment
# Build docker container for Neptuno project
class Update < Neptuno::CLI::Base
desc "Environment: Update all environment files"
desc 'Environment: Update all environment files'

def call
env_path = "#{neptuno_path}/environments/"
Expand Down
4 changes: 2 additions & 2 deletions lib/neptuno/overmind/connect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ def call(services: [], **options)
else
puts `neptuno start --no-up #{services.join(' ')}` if options.fetch(:start)
if outside_tmux
system("cd #{neptuno_path} && tmuxinator start neptuno #{services.join(' ')}")
system("cd #{neptuno_path} && sleep 1 && tmuxinator start neptuno #{services.join(' ')}")
else
puts "Connecting to #{original_services.first}"
system("cd #{neptuno_path}/procfiles/#{original_services.first} && overmind connect shell")
system("cd #{neptuno_path}/procfiles/#{original_services.first} && sleep 2 && overmind connect shell")
end
end
end
Expand Down
8 changes: 6 additions & 2 deletions lib/neptuno/services/update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ def call(services: [], **options)
services.each do |service|
puts "---Updating #{service}---"
current_branch = `git branch --show-current`
puts current_branch
system("cd #{neptuno_path}/services/#{service} 2>/dev/null && git add . && git stash save -u -q neptuno_stash")
puts "Current branch #{current_branch}\r\n"
populated = system("cd #{neptuno_path}/services/#{service} 2>/dev/null && git add . && git stash save -u -q neptuno_stash")
unless populated
puts 'Initializing git submodule'
system("cd #{neptuno_path}/services/#{service} 2>/dev/null && git submodule update --init --recursive #{neptuno_path}/services/#{service}")
end
`cd #{neptuno_path}/services/#{service} 2>/dev/null && git checkout main 2>/dev/null`
`cd #{neptuno_path}/services/#{service} 2>/dev/null && git checkout master 2>/dev/null`
system("cd #{neptuno_path}/services/#{service} 2>/dev/null && git pull")
Expand Down
2 changes: 1 addition & 1 deletion lib/neptuno/tty/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def neptuno_path
def make_service_files(services)
services.each do |service|
`cd #{neptuno_path} && mkdir -p environments/#{service} procfiles/#{service} dockerfiles/#{service}`
`cd #{neptuno_path} && touch environments/#{service}/local_env`
`cd #{neptuno_path} && touch environments/#{service}/default`
`cd #{neptuno_path} && touch dockerfiles/#{service}/Dockerfile`
`cd #{neptuno_path} && touch dockerfiles/#{service}/entrypoint.sh`
end
Expand Down
2 changes: 1 addition & 1 deletion lib/neptuno/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Neptuno
VERSION = '1.4.2'
VERSION = '1.4.9'
end

0 comments on commit c2ac257

Please sign in to comment.