neptuno 1.0.10 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +6 -5
  3. data/Rakefile +6 -6
  4. data/exe/neptuno +1 -1
  5. data/lib/neptuno/cli/activate.rb +19 -19
  6. data/lib/neptuno/cli/base.rb +4 -4
  7. data/lib/neptuno/cli/clone.rb +8 -2
  8. data/lib/neptuno/cli/configure.rb +3 -3
  9. data/lib/neptuno/cli/execute.rb +4 -4
  10. data/lib/neptuno/cli/init.rb +5 -5
  11. data/lib/neptuno/cli/install.rb +15 -17
  12. data/lib/neptuno/cli/list.rb +21 -31
  13. data/lib/neptuno/cli/version.rb +1 -1
  14. data/lib/neptuno/cli.rb +28 -28
  15. data/lib/neptuno/docker/attach.rb +2 -2
  16. data/lib/neptuno/docker/build.rb +5 -5
  17. data/lib/neptuno/docker/down.rb +18 -9
  18. data/lib/neptuno/docker/log.rb +1 -1
  19. data/lib/neptuno/docker/restart.rb +8 -8
  20. data/lib/neptuno/docker/services.rb +2 -2
  21. data/lib/neptuno/docker/up.rb +3 -8
  22. data/lib/neptuno/environment/config.rb +3 -3
  23. data/lib/neptuno/environment/update.rb +1 -1
  24. data/lib/neptuno/git/pull.rb +2 -2
  25. data/lib/neptuno/git/stash.rb +2 -2
  26. data/lib/neptuno/k8s/attach.rb +6 -6
  27. data/lib/neptuno/overmind/connect.rb +20 -71
  28. data/lib/neptuno/overmind/start.rb +22 -56
  29. data/lib/neptuno/overmind/stop.rb +12 -6
  30. data/lib/neptuno/services/add.rb +9 -15
  31. data/lib/neptuno/services/destroy.rb +1 -1
  32. data/lib/neptuno/services/list.rb +3 -2
  33. data/lib/neptuno/services/update.rb +8 -8
  34. data/lib/neptuno/templates/{tmuxinator.yml → .tmuxinator.yml} +2 -4
  35. data/lib/neptuno/templates/docker-compose.yml +18 -7
  36. data/lib/neptuno/templates/neptuno.yml +6 -0
  37. data/lib/neptuno/tty/config.rb +40 -6
  38. data/lib/neptuno/tty/file.rb +6 -6
  39. data/lib/neptuno/version.rb +1 -1
  40. data/lib/neptuno.rb +11 -11
  41. data/neptuno.gemspec +26 -26
  42. metadata +16 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 22b42e801b0beb52e37f1277a186e6ad366b08e8
4
- data.tar.gz: d097479c09527b55dcd8093f19bef7f86c8c9fa2
3
+ metadata.gz: 294ecbcd067c63dc56c264f49ed2338f0c625881
4
+ data.tar.gz: 91bca6f7898526f3e314a589ac6dc698f5b14156
5
5
  SHA512:
6
- metadata.gz: 9bc695ea800c5aec954489b269b90f47742be638026cf45cec37d7ffebeacb0f691cb4b41c821208f5953d254b86e1100ae67b4c04dd8f06027e32d68295d628
7
- data.tar.gz: 6d6e14c8a10c851a883318bda33c36a31194905a2703701e2534587c4938b2f549e725f23e77da1fabdd4213dc44ace86461ee04652d6d94dc1792af4d8502c1
6
+ metadata.gz: 6e6caa3d090c78e0787894086a95c0fa23f6be37fa814570bf70004f4c5dadfbc6500a0a21163cc57264ac806c4ebb6884c8fd9b103c3170a0eefa1845ef5ee1
7
+ data.tar.gz: 5534e7dcc424c14ec5ae852a0122c32c72b1315faeffc6a9e23df32979a52f819d4cfa46d2e281d51689c1c5036ca6171b45b1062b2c81242b8d4f6352dad15f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- neptuno (1.0.10)
4
+ neptuno (1.2.1)
5
5
  dotiw
6
6
  dry-cli
7
7
  hirb
@@ -17,7 +17,7 @@ PATH
17
17
  GEM
18
18
  remote: https://rubygems.org/
19
19
  specs:
20
- activesupport (7.0.4)
20
+ activesupport (7.0.4.2)
21
21
  concurrent-ruby (~> 1.0, >= 1.0.2)
22
22
  i18n (>= 1.6, < 2)
23
23
  minitest (>= 5.1)
@@ -25,7 +25,7 @@ GEM
25
25
  ansi (1.5.0)
26
26
  ast (2.4.2)
27
27
  builder (3.2.4)
28
- concurrent-ruby (1.1.10)
28
+ concurrent-ruby (1.2.0)
29
29
  diff-lcs (1.5.0)
30
30
  dotiw (5.3.3)
31
31
  activesupport
@@ -90,14 +90,15 @@ GEM
90
90
  tty-spinner (0.9.3)
91
91
  tty-cursor (~> 0.7)
92
92
  tty-which (0.5.0)
93
- tzinfo (2.0.5)
93
+ tzinfo (2.0.6)
94
94
  concurrent-ruby (~> 1.0)
95
95
  unicode-display_width (2.3.0)
96
96
  wisper (2.0.1)
97
- zeitwerk (2.6.6)
97
+ zeitwerk (2.6.7)
98
98
 
99
99
  PLATFORMS
100
100
  x86_64-darwin-21
101
+ x86_64-darwin-22
101
102
  x86_64-linux
102
103
 
103
104
  DEPENDENCIES
data/Rakefile CHANGED
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bundler/gem_tasks'
4
- require 'rake/testtask'
5
- require 'standard/rake'
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+ require "standard/rake"
6
6
 
7
7
  Rake::TestTask.new(:test) do |t|
8
- t.libs << 'test'
9
- t.libs << 'lib'
10
- t.test_files = FileList['test/**/*_test.rb']
8
+ t.libs << "test"
9
+ t.libs << "lib"
10
+ t.test_files = FileList["test/**/*_test.rb"]
11
11
  end
12
12
 
13
13
  task default: %i[test standard:fix]
data/exe/neptuno CHANGED
@@ -2,7 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  # require "bundler/setup"
5
- require 'neptuno'
5
+ require "neptuno"
6
6
 
7
7
  cli = Neptuno::CLI
8
8
  Dry::CLI.new(cli).call
@@ -5,34 +5,34 @@ module Neptuno
5
5
  # Init Neptuno files
6
6
  class Activate < Neptuno::CLI::Base
7
7
  include ::Neptuno::TTY::Config
8
- desc 'Bring services containers up and start their processes'
8
+ desc "Bring services containers up and start their processes"
9
9
 
10
- option :force, type: :boolean, default: false, desc: 'Try to start disrigarding container status'
11
- option :all, type: :boolean, default: false, desc: 'Run on all services'
12
- argument :services, type: :array, required: false, desc: 'Optional list of services'
10
+ option :force, type: :boolean, default: false, desc: "Try to start disrigarding container status"
11
+ option :all, type: :boolean, default: false, desc: "Run on all services"
12
+ argument :services, type: :array, required: false, desc: "Optional list of services"
13
13
 
14
14
  def call(services: [], **options)
15
- multi_spinner = ::TTY::Spinner::Multi.new('[:spinner] Services')
15
+ multi_spinner = ::TTY::Spinner::Multi.new("[:spinner] Services")
16
16
  spinners = {}
17
17
  count = 0
18
- command_services_to('activate to services', all: options.fetch(:all), services_as_args: services) do |services|
19
- system("cd #{neptuno_path} && docker compose up -d #{services.join(' ')}")
18
+ command_services_to("activate to services", all: options.fetch(:all), services_as_args: services) do |services|
19
+ system("cd #{neptuno_path} && docker compose up -d #{services.join(" ")}")
20
20
  running_services = ::Neptuno::CLI::List.new.running_services.first.keys
21
21
  running_services.sort.each do |service|
22
22
  spinners[service] ||= multi_spinner.register("[:spinner] :state #{service}")
23
- spinners[service].update(state: '- ')
23
+ spinners[service].update(state: "- ")
24
24
  spinners[service].auto_spin
25
25
  end
26
26
  loop do
27
27
  ps = `cd #{neptuno_path} && docker compose ps`.split("\n").compact.select { |x| x.match(/^\s*#{project}/) }
28
28
 
29
29
  running_services.sort.each do |service|
30
- service_ps = ps.find {|s| s =~ /#{project}[-_]#{service}[-_]\d\s/ }
30
+ service_ps = ps.find { |s| s =~ /#{project}[-_]#{service}[-_]\d\s/ }
31
31
 
32
- status = :dead if service_ps.to_s.include?('exited')
33
- status = :starting if service_ps.to_s.include?('starting')
34
- status = :unhealthy if service_ps.to_s.include?('(unhealthy')
35
- status = :healthy if service_ps.to_s.include?('(healthy')
32
+ status = :dead if service_ps.to_s.include?("exited")
33
+ status = :starting if service_ps.to_s.include?("starting")
34
+ status = :unhealthy if service_ps.to_s.include?("(unhealthy")
35
+ status = :healthy if service_ps.to_s.include?("(healthy")
36
36
  status = :force if options.fetch(:force)
37
37
 
38
38
  case status
@@ -40,19 +40,19 @@ module Neptuno
40
40
  spinners[service].success
41
41
  `cd #{neptuno_path}/procfiles/#{service} && overmind start -D -N > /dev/null 2>&1`
42
42
  when :dead
43
- spinners[service].update(state: 'dead ')
43
+ spinners[service].update(state: "dead ")
44
44
  spinners[service].error
45
45
  when :starting
46
- spinners[service].update(state: 'starting ')
46
+ spinners[service].update(state: "starting ")
47
47
  when :unhealthy
48
- spinners[service].update(state: 'unhealthy ')
48
+ spinners[service].update(state: "unhealthy ")
49
49
  spinners[service].error if spinners[service].instance_variable_get(:@state) == :spinning && count > 50
50
50
  when :healthy
51
- spinners[service].update(state: 'ready ')
51
+ spinners[service].update(state: "ready ")
52
52
  spinners[service].success
53
53
  `cd #{neptuno_path}/procfiles/#{service} && overmind start -D -N > /dev/null 2>&1`
54
54
  else
55
- spinners[service].update(state: 'down ')
55
+ spinners[service].update(state: "down ")
56
56
  spinners[service].error
57
57
  end
58
58
  end
@@ -61,7 +61,7 @@ module Neptuno
61
61
  count += 1
62
62
  sleep(5)
63
63
  end
64
- spinner = ::TTY::Spinner.new('Neptuno: Starting[:spinner]', format: :dots)
64
+ spinner = ::TTY::Spinner.new("Neptuno: Starting[:spinner]", format: :dots)
65
65
  spinner.auto_spin
66
66
 
67
67
  spinner.stop
@@ -12,13 +12,13 @@ module Neptuno
12
12
  ABORT_MESSAGE = "fatal: not a Neptuno repository (or any of the parent directories)"
13
13
 
14
14
  def initialize
15
- abort ABORT_MESSAGE if neptuno_path == ""
15
+ abort ABORT_MESSAGE if neptuno_path == ""
16
16
  config.append_path(neptuno_path)
17
17
  config.read
18
18
  end
19
19
 
20
20
  def command_service_to(request, service_as_args: "")
21
- chosen_service ||= service_as_args&.empty? ? nil : service_as_args
21
+ chosen_service ||= service_as_args.to_a.empty? ? nil : service_as_args
22
22
  chosen_service ||= service if in_service?
23
23
  chosen_service ||= prompt.select("Command service to #{request}:", services)
24
24
  yield chosen_service, project
@@ -26,9 +26,9 @@ module Neptuno
26
26
 
27
27
  def command_services_to(request, all: nil, services_as_args: [])
28
28
  chosen_services = services if all
29
- chosen_services ||= services_as_args&.empty? ? nil : services_as_args
29
+ chosen_services ||= services_as_args.to_a.empty? ? nil : services_as_args
30
30
  chosen_services ||= [service] if in_service?
31
- chosen_services ||= configured_services.empty? ? nil : configured_services
31
+ chosen_services ||= configured_services.to_a.empty? ? nil : configured_services
32
32
  chosen_services ||= prompt.multi_select("Command services to #{request}:", services)
33
33
  yield chosen_services, project
34
34
  end
@@ -5,13 +5,19 @@ module Neptuno
5
5
  # Init Neptuno files
6
6
 
7
7
  class Clone < Dry::CLI::Command
8
- desc 'Clone a neptuno compliant project'
8
+ desc "Clone a neptuno compliant project"
9
+ option :provision, type: :boolean, default: false, desc: "Build docker images, start containers and run procs"
10
+
9
11
  def call(**options)
10
12
  git_url = options[:args].first
11
13
  args_path = options[:args].second
12
- path = args_path || git_url.split('/').last.split('.').first
14
+ path = args_path || git_url.split("/").last.split(".").first
13
15
  `git clone --recurse-submodules #{git_url} #{path}`
16
+
14
17
  sleep(1)
18
+
19
+ return unless options.fetch(:provision)
20
+
15
21
  `cd #{path} && neptuno services update -am`
16
22
  puts "Building Docker images"
17
23
  `cd #{path} && neptuno build -a`
@@ -4,11 +4,11 @@ module Neptuno
4
4
  module CLI
5
5
  # Configure Neptuno defaults
6
6
  class Configure < Neptuno::CLI::Base
7
- desc 'Configure which services to start by default'
7
+ desc "Configure which services to start by default"
8
8
 
9
9
  def call(**)
10
- configured_services = config.fetch('configured_services')
11
- configured_services = prompt.multi_select('Active services: ', config.fetch('services')) do |menu|
10
+ configured_services = config.fetch("configured_services")
11
+ configured_services = prompt.multi_select("Active services: ", config.fetch("services")) do |menu|
12
12
  menu.default(*configured_services)
13
13
  end
14
14
  config.set(:configured_services, value: configured_services)
@@ -7,17 +7,17 @@ module Neptuno
7
7
  include TTY::File
8
8
  include TTY::Config
9
9
 
10
- desc 'Execute service script'
10
+ desc "Execute service script"
11
11
 
12
12
  def call(**options)
13
- command_service_to('execute', service_as_args: options[:args]&.first) do |service, _project|
14
- commands = Dir.glob("#{neptuno_path}/scripts/#{service}/*").map { |x| x.split('/') }.map(&:last)
13
+ command_service_to("execute", service_as_args: options[:args]&.first) do |service, _project|
14
+ commands = Dir.glob("#{neptuno_path}/scripts/#{service}/*").map { |x| x.split("/") }.map(&:last)
15
15
  command = options[:args].last if commands.include?(options[:args]&.last)
16
16
  puts "#{neptuno_path}/scripts/#{service}/*"
17
17
  puts service
18
18
  puts commands.to_s
19
19
  puts Dir.glob("#{neptuno_path}/scripts/#{service}/*").to_s
20
- command ||= prompt.select('execute', commands || [])
20
+ command ||= prompt.select("execute", commands || [])
21
21
  `cd #{neptuno_path}/scripts/#{service} && ./#{command}`
22
22
  end
23
23
  end
@@ -8,19 +8,19 @@ module Neptuno
8
8
  include TTY::Config
9
9
  include TTY::Which
10
10
 
11
- desc 'Initializes a Neptuno project folder structure'
11
+ desc "Initializes a Neptuno project folder structure"
12
12
 
13
- WORK_TREE = { '.' => [{ 'services' => [], 'dockerfiles' => [], 'procfiles' => [], 'environments' => [] }] }.freeze
13
+ WORK_TREE = {"." => [{"services" => [], "dockerfiles" => [], "procfiles" => [], "environments" => []}]}.freeze
14
14
 
15
15
  CONFIG = nil
16
16
 
17
17
  def call(**)
18
- abort 'Neptuno projects can not be nested.' if neptuno_path != ''
18
+ abort "Neptuno projects can not be nested." if neptuno_path != ""
19
19
  ::TTY::File.create_dir(WORK_TREE, Dir.pwd)
20
- config.set(:configured_services, value: '')
20
+ config.set(:configured_services, value: "")
21
21
  config.set(:services, value: [])
22
22
  config.write(create: true, force: true)
23
- `cp #{File.expand_path("../../templates", __FILE__)}/* ./`
23
+ `cp -r #{File.expand_path("../../templates", __dir__)}/* ./`
24
24
  end
25
25
  end
26
26
  end
@@ -10,20 +10,20 @@ module Neptuno
10
10
  include TTY::Config
11
11
  include TTY::Which
12
12
 
13
- desc 'Installs git, docker, tmux, tmuxinator and overmind'
13
+ desc "Installs git, docker, tmux, tmuxinator and overmind"
14
14
 
15
15
  CONFIG = nil
16
16
 
17
17
  def call(**)
18
- install 'git'
19
- install 'docker'
20
- install 'tmux'
21
- install 'overmind'
22
- install 'tmuxinator'
18
+ install "git"
19
+ install "docker"
20
+ install "tmux"
21
+ install "overmind"
22
+ install "tmuxinator"
23
23
 
24
- if(system("apt-get -v"))
25
- system("sudo apt-get update")
26
- end
24
+ return unless system("apt-get -v")
25
+
26
+ system("sudo apt-get update")
27
27
  end
28
28
 
29
29
  def install(package)
@@ -31,16 +31,14 @@ module Neptuno
31
31
  puts "#{package} is already installed"
32
32
  else
33
33
  puts "Installing #{package}"
34
- if(system("brew -v"))
34
+ if system("brew -v")
35
35
  system("brew install #{package}")
36
+ elsif package == "overmind"
37
+ system("go install github.com/DarthSim/overmind/v2@latest")
38
+ elsif package == "tmuxinator"
39
+ system("gem install tmuxinator")
36
40
  else
37
- if(package == 'overmind')
38
- system("go install github.com/DarthSim/overmind/v2@latest")
39
- elsif(package == 'tmuxinator')
40
- system("gem install tmuxinator")
41
- else
42
- system("sudo apt-get install #{package} -y")
43
- end
41
+ system("sudo apt-get install #{package} -y")
44
42
  end
45
43
  end
46
44
  end
@@ -9,29 +9,24 @@ module Neptuno
9
9
  include TTY::Config
10
10
  include DOTIW::Methods
11
11
 
12
- desc 'List containers and their processes'
13
- option :relative, aliases: ['r'], type: :boolean, default: true,
14
- desc: "Use relative time in 'last commit date' field"
12
+ desc "List containers and their processes"
13
+ option :relative, aliases: ["r"], type: :boolean, default: true,
14
+ desc: "Use relative time in 'last commit date' field"
15
15
 
16
16
  STATE_ORDER = %w[on dead off].freeze
17
17
 
18
- def running_services
19
- proc_files = Dir.glob('procfiles/**/Procfile', base: neptuno_path)
20
- neptuno_procs = proc_files.map do |f|
21
- [f.split("\/")[1], File.read("#{neptuno_path}/#{f}").split("\n").map do |s|
22
- s.split(':').first
23
- end]
24
- end.to_h
18
+ def services_and_procs
19
+ proc_files = Dir.glob("procfiles/**/Procfile", base: neptuno_path)
20
+ sap = proc_files.map do |f|
21
+ [f.split("/")[1], File.read("#{neptuno_path}/#{f}").split("\n").map do |s|
22
+ next if /^\w*#/.match?(s)
25
23
 
26
- begin
27
- docker_containers = `docker compose ps`.lines[1..]
28
- raise if $?.exitstatus != 0
29
- rescue RuntimeError
30
- exit
31
- end
32
- docker_procs = docker_containers.map { |service| service.split(/\s\s+/).slice(2, 2) }.to_h
24
+ s.split(":").first
25
+ end.compact]
26
+ end.to_h
33
27
 
34
- [neptuno_procs, docker_procs]
28
+ services.each { |s| sap[s] ||= [] }
29
+ sap
35
30
  end
36
31
 
37
32
  def service_current_branches
@@ -49,30 +44,25 @@ module Neptuno
49
44
  end
50
45
 
51
46
  def get_display_date(date, relative)
52
- if date
53
- return date unless relative
47
+ return unless date
48
+ return date unless relative
54
49
 
55
- distance_of_time_in_words(Time.now, Time.parse(date), false, highest_measures: 1).concat(' ago')
56
- end
50
+ distance_of_time_in_words(Time.now, Time.parse(date), false, highest_measures: 1).concat(" ago")
57
51
  end
58
52
 
59
53
  def call(**options)
60
- neptuno_procs, docker_procs = running_services
54
+ jss = json_services_status.to_h
61
55
  branches = service_current_branches
62
56
  dates = last_commit_date
63
57
 
64
- x = docker_compose_services - neptuno_procs.select{|k,v| v.length > 0}.keys
65
- x.each{|y| neptuno_procs[y] = ""}
66
-
67
- procs = neptuno_procs.map do |name, *processes|
58
+ procs = services_and_procs.map do |name, *processes|
68
59
  display_date = get_display_date(dates[name], options.fetch(:relative))
69
- state = docker_procs[name]&.match?(/running/) ? 'on' : nil
70
- state ||= docker_procs[name]&.match?(/exited/) ? 'dead' : 'off'
71
- { state: state, name: name, branch: branches[name], last_commit: display_date, processes: processes }
60
+ state = jss.to_h[name] || "Off"
61
+ {state: state, name: name, branch: branches[name], last_commit: display_date, processes: processes}
72
62
  end
73
63
 
74
64
  puts Hirb::Helpers::AutoTable.render(procs.sort do |a, b|
75
- [STATE_ORDER.index(b[:state]), a[:name]] <=> [STATE_ORDER.index(a[:state]), b[:name]]
65
+ a[:state].split(" ").first <=> b[:state].split(" ").first
76
66
  end.reverse, fields: %i[state name branch last_commit processes])
77
67
  end
78
68
  end
@@ -4,7 +4,7 @@ module Neptuno
4
4
  module CLI
5
5
  # Print Neptuno CLI version
6
6
  class Version < Dry::CLI::Command
7
- desc 'Print version'
7
+ desc "Print version"
8
8
 
9
9
  def call(**)
10
10
  puts ::Neptuno::VERSION
data/lib/neptuno/cli.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry/cli'
3
+ require "dry/cli"
4
4
 
5
5
  # Public: Command line interface that allows to install the library, and run
6
6
  # simple commands.
@@ -8,32 +8,32 @@ module Neptuno
8
8
  module CLI
9
9
  extend Dry::CLI::Registry
10
10
 
11
- register 'version', Version, aliases: ['v', '-v', '--version', 'info']
12
- register 'init', Init
13
- register 'clone', Clone
14
- register 'ls', List, aliases: ['ps']
15
- register 'activate', Activate, aliases: ['a']
16
- register 'config', Configure, aliases: %w[configure conf cc]
17
- register 'execute', Execute, aliases: ['e']
18
- register 'build', ::Neptuno::Docker::Build, aliases: ['b']
19
- register 'up', Docker::Up, aliases: ['u']
20
- register 'down', Docker::Down, aliases: ['d']
21
- register 'restart', Docker::Restart, aliases: ['r']
22
- register 'attach', Docker::Attach, aliases: ['at']
23
- register 'k8s', K8s::Attach, aliases: ['k']
24
- register 'log', Docker::Log, aliases: ['l']
25
- register 'start', Overmind::Start, aliases: ['s']
26
- register 'stop', Overmind::Stop, aliases: ['x']
27
- register 'update', Services::Update, aliases: ['su']
28
- register 'connect', Overmind::Connect, aliases: ['c']
29
- register 'services list', Services::List, aliases: ['ls']
30
- register 'services add', Services::Add
31
- register 'services destroy', Services::Destroy, aliases: ['rm']
32
- register 'services update', Services::Update, aliases: ['su']
33
- register 'git stash', ::Neptuno::Git::Stash
34
- register 'git pull', ::Neptuno::Git::Pull
35
- register 'install', ::Neptuno::CLI::Install
36
- register 'environment update', Environment::Update
37
- register 'environment config', Environment::Config
11
+ register "version", Version, aliases: ["v", "-v", "--version", "info"]
12
+ register "init", Init
13
+ register "clone", Clone
14
+ register "ls", List, aliases: ["ps"]
15
+ register "activate", Activate, aliases: ["a"]
16
+ register "config", Configure, aliases: %w[configure conf cc]
17
+ register "execute", Execute, aliases: ["e"]
18
+ register "build", ::Neptuno::Docker::Build, aliases: ["b"]
19
+ register "up", Docker::Up, aliases: ["u"]
20
+ register "down", Docker::Down, aliases: ["d"]
21
+ register "restart", Docker::Restart, aliases: ["r"]
22
+ register "attach", Docker::Attach, aliases: ["at"]
23
+ register "k8s", K8s::Attach, aliases: ["k"]
24
+ register "log", Docker::Log, aliases: ["l"]
25
+ register "start", Overmind::Start, aliases: ["s"]
26
+ register "stop", Overmind::Stop, aliases: ["x"]
27
+ register "update", Services::Update, aliases: ["su"]
28
+ register "connect", Overmind::Connect, aliases: ["c"]
29
+ register "services list", Services::List, aliases: ["ls"]
30
+ register "services add", Services::Add
31
+ register "services destroy", Services::Destroy, aliases: ["rm"]
32
+ register "services update", Services::Update, aliases: ["su"]
33
+ register "git stash", ::Neptuno::Git::Stash
34
+ register "git pull", ::Neptuno::Git::Pull
35
+ register "install", ::Neptuno::CLI::Install
36
+ register "environment update", Environment::Update
37
+ register "environment config", Environment::Config
38
38
  end
39
39
  end
@@ -6,10 +6,10 @@ module Neptuno
6
6
  include ::Neptuno::TTY::Config
7
7
  desc "Docker: Attach to a container's command"
8
8
 
9
- option :up, type: :boolean, default: false, desc: 'Try to start containers before connecting'
9
+ option :up, type: :boolean, default: false, desc: "Try to start containers before connecting"
10
10
 
11
11
  def call(**options)
12
- command_service_to('attach', service_as_args: options[:args].first) do |service, project|
12
+ command_service_to("attach", service_as_args: options[:args].first) do |service, project|
13
13
  system("cd #{neptuno_path} && docker compose up -d #{service}") if options.fetch(:up)
14
14
  success = system("cd #{neptuno_path} && docker attach #{project}_#{service}_1")
15
15
  unless success
@@ -4,15 +4,15 @@ module Neptuno
4
4
  module Docker
5
5
  # Build docker container for Neptuno project
6
6
  class Build < Neptuno::CLI::Base
7
- desc 'Docker: Build docker containers for project'
7
+ desc "Docker: Build docker containers for project"
8
8
 
9
- option :all, type: :boolean, default: false, desc: 'Run on all services'
10
- argument :services, type: :array, required: false, desc: 'Optional list of services'
9
+ option :all, type: :boolean, default: false, desc: "Run on all services"
10
+ argument :services, type: :array, required: false, desc: "Optional list of services"
11
11
 
12
12
  def call(services: [], **options)
13
- command_services_to('build', all: options.fetch(:all), services_as_args: services) do |services|
13
+ command_services_to("build", all: options.fetch(:all), services_as_args: services) do |services|
14
14
  make_service_files(services)
15
- system("cd #{neptuno_path} && docker compose build #{services.join(' ')}")
15
+ system("cd #{neptuno_path} && docker compose build #{services.join(" ")}")
16
16
  end
17
17
  end
18
18
  end
@@ -4,19 +4,28 @@ module Neptuno
4
4
  module Docker
5
5
  # Stop docker containers for Neptuno project
6
6
  class Down < Neptuno::CLI::Base
7
- desc 'Docker: Stop docker containers for current project'
7
+ desc "Docker: Stop docker containers for current project"
8
8
 
9
- option :tmux, type: :boolean, default: false, desc: 'Kill tmux session'
10
- option :all, type: :boolean, default: false, desc: 'Run on all services'
11
- argument :services, type: :array, required: false, desc: 'Optional list of services'
9
+ option :all, type: :boolean, default: false, desc: "Run on all services"
10
+ argument :services, type: :array, required: false, desc: "Optional list of services"
12
11
 
13
12
  def call(services: [], **options)
14
- command_services_to('go down', all: options.fetch(:all), services_as_args: services) do |services|
13
+ command_services_to("go down", all: options.fetch(:all), services_as_args: services) do |services|
15
14
  make_service_files(services)
16
- system("cd #{neptuno_path} && docker compose stop -t 0 #{services.join(' ')}")
17
- system("cd #{neptuno_path} && docker compose rm -f #{services.join(' ')}")
18
- system("cd #{neptuno_path} && tmux kill-session -t neptuno") if options.fetch(:tmux)
19
- system("cd #{neptuno_path}/procfiles/#{service} && rm .overmind.sock > /dev/null 2>&1")
15
+ services_to_stop = services.intersection(services_with_procs).intersection(running_services)
16
+ system("cd #{neptuno_path} && docker compose stop -t 0 #{services.join(" ")}")
17
+ system("cd #{neptuno_path} && docker compose rm -f #{services.join(" ")}")
18
+ if config.fetch("procfile_manager") == "tmux"
19
+ services_to_stop.each do |service|
20
+ system("tmux kill-session -t #{service} 2>/dev/null ")
21
+ puts "Neptuno killed Tmux session for: #{service}" if `echo $TMUX`.strip.empty?
22
+ end
23
+ else
24
+ system("cd #{neptuno_path} && tmux kill-session -t neptuno")
25
+ services_to_stop.each do
26
+ system("cd #{neptuno_path}/procfiles/#{service} && rm .overmind.sock > /dev/null 2>&1")
27
+ end
28
+ end
20
29
  end
21
30
  end
22
31
  end
@@ -7,7 +7,7 @@ module Neptuno
7
7
  desc "Docker: Show a container's log"
8
8
 
9
9
  def call(**options)
10
- command_service_to('log', service_as_args: options[:args].first) do |service, project|
10
+ command_service_to("log", service_as_args: options[:args].first) do |service, project|
11
11
  success = system("cd #{neptuno_path} && docker logs -f #{project}_#{service}_1")
12
12
  unless success
13
13
  puts "Trying #{project}-#{services.first}-1"
@@ -4,18 +4,18 @@ module Neptuno
4
4
  module Docker
5
5
  # Restart docker containers for Neptuno project
6
6
  class Restart < Neptuno::CLI::Base
7
- desc 'Docker: Rebuild and restart docker containers for current project'
7
+ desc "Docker: Rebuild and restart docker containers for current project"
8
8
 
9
- option :all, type: :boolean, default: false, desc: 'Run on all services'
10
- argument :services, type: :array, required: false, desc: 'Optional list of services'
9
+ option :all, type: :boolean, default: false, desc: "Run on all services"
10
+ argument :services, type: :array, required: false, desc: "Optional list of services"
11
11
 
12
12
  def call(services: [], **options)
13
- command_services_to('restart', all: options.fetch(:all), services_as_args: services) do |services|
13
+ command_services_to("restart", all: options.fetch(:all), services_as_args: services) do |services|
14
14
  make_service_files(services)
15
- system("cd #{neptuno_path} && docker compose stop -t 0 #{services.join(' ')}")
16
- system("cd #{neptuno_path} && docker compose rm -f #{services.join(' ')}")
17
- system("cd #{neptuno_path} && docker compose build #{services.join(' ')}")
18
- system("cd #{neptuno_path} && docker compose up -d #{services.join(' ')}")
15
+ system("cd #{neptuno_path} && docker compose stop -t 0 #{services.join(" ")}")
16
+ system("cd #{neptuno_path} && docker compose rm -f #{services.join(" ")}")
17
+ system("cd #{neptuno_path} && docker compose build #{services.join(" ")}")
18
+ system("cd #{neptuno_path} && docker compose up -d #{services.join(" ")}")
19
19
  end
20
20
  end
21
21
  end