picobox 0.2.6 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/README.md +1 -0
  4. data/lib/picobox.rb +6 -1
  5. data/lib/picobox/box.rb +4 -4
  6. data/lib/picobox/boxes/{unpacker.rb → installer.rb} +2 -2
  7. data/lib/picobox/commands/add_box.rb +2 -4
  8. data/lib/picobox/commands/add_service.rb +1 -3
  9. data/lib/picobox/commands/initialize_project.rb +9 -14
  10. data/lib/picobox/commands/install_config.rb +17 -0
  11. data/lib/picobox/commands/list_boxes.rb +1 -1
  12. data/lib/picobox/commands/remove_service.rb +1 -3
  13. data/lib/picobox/commands/remove_setup_shell.rb +2 -13
  14. data/lib/picobox/commands/restart.rb +3 -4
  15. data/lib/picobox/commands/setup_shell.rb +1 -5
  16. data/lib/picobox/commands/ssh_instance.rb +2 -5
  17. data/lib/picobox/commands/start.rb +1 -4
  18. data/lib/picobox/commands/start_uninstall.rb +2 -7
  19. data/lib/picobox/commands/stop.rb +1 -4
  20. data/lib/picobox/commands/update_packages.rb +30 -0
  21. data/lib/picobox/constants.rb +11 -8
  22. data/lib/picobox/handlers/stdout_handler.rb +16 -3
  23. data/lib/picobox/os/abstract.rb +4 -0
  24. data/lib/picobox/os/distro.rb +11 -5
  25. data/lib/picobox/project.rb +3 -0
  26. data/lib/picobox/service.rb +4 -0
  27. data/lib/picobox/shell/ini_file.rb +38 -0
  28. data/lib/picobox/shell/startup_script.rb +4 -2
  29. data/lib/picobox/system.rb +5 -0
  30. data/lib/picobox/utils/output.rb +2 -1
  31. data/lib/picobox/utils/packages.rb +37 -0
  32. data/picobox.gemspec +2 -1
  33. metadata +21 -23
  34. data/lib/picobox/boxes/packages/elixir/Dockerfile +0 -52
  35. data/lib/picobox/boxes/packages/elixir/docker-compose.yml +0 -26
  36. data/lib/picobox/boxes/packages/elixir/info +0 -18
  37. data/lib/picobox/boxes/packages/elixir/start +0 -3
  38. data/lib/picobox/boxes/packages/python/Dockerfile +0 -29
  39. data/lib/picobox/boxes/packages/python/docker-compose.yml +0 -14
  40. data/lib/picobox/boxes/packages/python/start +0 -3
  41. data/lib/picobox/boxes/packages/rails/Dockerfile +0 -74
  42. data/lib/picobox/boxes/packages/rails/docker-compose.yml +0 -47
  43. data/lib/picobox/boxes/packages/rails/start +0 -9
  44. data/lib/picobox/boxes/packages/ruby/Dockerfile +0 -46
  45. data/lib/picobox/boxes/packages/ruby/docker-compose.yml +0 -20
  46. data/lib/picobox/boxes/packages/ruby/start +0 -3
  47. data/lib/picobox/services/packages/elasticsearch/config.yml +0 -14
  48. data/lib/picobox/services/packages/memcached/config.yml +0 -9
  49. data/lib/picobox/services/packages/mongodb/config.yml +0 -13
  50. data/lib/picobox/services/packages/mysql/config.yml +0 -17
  51. data/lib/picobox/services/packages/postgres/config.yml +0 -16
  52. data/lib/picobox/services/packages/redis/config.yml +0 -7
  53. data/lib/picobox/templates/shell_extensions.bash +0 -135
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 39a5b830c2733f29c9d8dbf58508f95fde56aa94
4
- data.tar.gz: a2a57a7a8af2c4cdc2bef8e7eaf37c4369ed5574
3
+ metadata.gz: 402514d6b3f2e61a23162e553a374ebf16b2b858
4
+ data.tar.gz: 64e4e09effbadcb2ee9abd0fb7be6e05b0a60035
5
5
  SHA512:
6
- metadata.gz: 97e2e58e6d8288484f8a0e68deedfcf1a154a71d13fddc91c45c0c5708b4351c4872bf025c2261bc786773dec8bcc6d41d0ccd78e25e405a516f775f684fac91
7
- data.tar.gz: 3e3543cb2354086dd24d4715b7b3a2e23483eb5afbed0c764b0cf58a289e29b635d9035bb56c2a93a15dcca02d891967a3f490276ed6827381db224098d5a549
6
+ metadata.gz: 31eb5aa3df0845d2f88c2e3d0e3a6d3e0f0ec4fcb8492e612659f8e5c3b2787cae10bdad6508252b1b67f4d3d87703dee3086d602276bde7150e9f704ce525e9
7
+ data.tar.gz: 2c5bbb347a212554698af4fa6d6d39c4e9f7765f058cca52c7ee2c7357583f60b99184fb4615aa9fdf026703b4c2aaf55a365bba68410941d70ccf48c1f290c3
data/.gitignore CHANGED
@@ -11,6 +11,7 @@
11
11
  .picobox
12
12
  .byebug_history
13
13
  .DS_Store
14
+ /packages
14
15
 
15
16
  # rspec failure tracking
16
17
  .rspec_status
data/README.md CHANGED
@@ -131,6 +131,7 @@ $ bundle exec byebug -R localhost:8989
131
131
  - [ ] Some services should install thier own volumes
132
132
  - [ ] Box update function
133
133
  - [ ] Remove TTY::File, TTY::Prompt dependency (needs native extensions)
134
+
134
135
  **http://blog.cloud66.com/using-ssh-private-keys-securely-in-docker-build/
135
136
 
136
137
  ## Contributing
data/lib/picobox.rb CHANGED
@@ -12,6 +12,7 @@ require 'ostruct'
12
12
  require 'yaml'
13
13
  require 'inifile'
14
14
  require 'pathname'
15
+ require 'json'
15
16
 
16
17
  require 'picobox/utils/progress_bar'
17
18
  require 'picobox/utils/spinner'
@@ -21,6 +22,7 @@ require 'picobox/utils/domain_event_publisher'
21
22
  require 'picobox/utils/visitor_by_os'
22
23
  require 'picobox/utils/output'
23
24
  require 'picobox/utils/shell'
25
+ require 'picobox/utils/packages'
24
26
 
25
27
  require 'picobox/docker_compose/config'
26
28
 
@@ -49,9 +51,11 @@ require 'picobox/commands/restart'
49
51
  require 'picobox/commands/ssh_instance'
50
52
  require 'picobox/commands/reload_shell'
51
53
  require 'picobox/commands/get_root_permission'
54
+ require 'picobox/commands/update_packages'
55
+ require 'picobox/commands/install_config'
52
56
 
53
57
  require 'picobox/boxes/manifest'
54
- require 'picobox/boxes/unpacker'
58
+ require 'picobox/boxes/installer'
55
59
 
56
60
  require 'picobox/services/manifest'
57
61
  require 'picobox/services/installer'
@@ -67,6 +71,7 @@ require 'picobox/shell/startup_script'
67
71
  require 'picobox/shell/dot_profile'
68
72
  require 'picobox/shell/dot_zshrc'
69
73
  require 'picobox/shell/dot_bashrc'
74
+ require 'picobox/shell/ini_file'
70
75
 
71
76
  require 'picobox/constants'
72
77
  require 'picobox/cli'
data/lib/picobox/box.rb CHANGED
@@ -11,10 +11,6 @@ module Picobox
11
11
 
12
12
  def install(type = nil)
13
13
  return if type.nil?
14
- # TODO place to inject unpacker for different types
15
- # of unpacking (ie net), could first search locally
16
- # then on the net
17
- # accept(Commands::AddBox.new(type, FileUnpacker, NetUnpacker))
18
14
  accept(Commands::AddBox.new(type))
19
15
  rescue Errors::BoxNotImplemented
20
16
  display_box_not_available type
@@ -28,7 +24,11 @@ module Picobox
28
24
  end
29
25
 
30
26
  def list()
27
+ accept(Commands::UpdatePackages.new)
31
28
  accept(Commands::ListBoxes.new)
29
+ rescue Errors::PicoboxNotInstalled
30
+ display_picobox_not_installed
31
+ exit 1
32
32
  rescue StandardError => e
33
33
  display_info(e, :red)
34
34
  exit 1
@@ -1,11 +1,11 @@
1
1
  module Picobox
2
2
  module Boxes
3
- class Unpacker
3
+ class Installer
4
4
  def initialize(os)
5
5
  @os = os
6
6
  end
7
7
 
8
- def unpack(type)
8
+ def install(type)
9
9
  @manifest = Manifest.new(os, type)
10
10
  @manifest.check! # raises an exception if we can't find the type in the manifest
11
11
 
@@ -8,9 +8,9 @@ module Picobox
8
8
  def visit_darwin subject
9
9
  publish_event :add_box_start, type
10
10
 
11
- raise Errors::ProjectNotInitialized unless project_initialized?
11
+ raise Errors::ProjectNotInitialized unless os.project_initialized?
12
12
 
13
- Boxes::Unpacker.new(os).unpack(type)
13
+ Boxes::Installer.new(os).install(type)
14
14
  end
15
15
 
16
16
 
@@ -20,8 +20,6 @@ module Picobox
20
20
 
21
21
  private
22
22
  attr_reader :type
23
-
24
- def project_initialized?() Utils::Project.new(os).project_initialized? end
25
23
  end
26
24
  end
27
25
  end
@@ -8,7 +8,7 @@ module Picobox
8
8
  def visit_darwin subject
9
9
  publish_event :add_service_start, service
10
10
 
11
- raise Errors::ProjectNotInitialized unless project_initialized?
11
+ raise Errors::ProjectNotInitialized unless os.project_initialized?
12
12
 
13
13
  Services::Installer.new(os).install(service)
14
14
 
@@ -22,8 +22,6 @@ module Picobox
22
22
 
23
23
  private
24
24
  attr_reader :service
25
-
26
- def project_initialized?() Utils::Project.new(os).project_initialized? end
27
25
  end
28
26
  end
29
27
  end
@@ -2,10 +2,17 @@ module Picobox
2
2
  module Commands
3
3
  class InitializeProject < Picobox::Utils::VisitorByOs
4
4
  def visit_darwin subject
5
+ raise Errors::PicoboxNotInstalled unless os.picobox_installed?
6
+
5
7
  publish_event :project_initialize_start
6
8
 
7
- create_project_config_dir
8
- create_project_ini
9
+ # create project config_dir
10
+ TTY::File.create_dir project_config_dir
11
+
12
+ # create project ini
13
+ TTY::File.create_file "#{project_config_dir}/#{Picobox::PROJECT_INI}" do |content|
14
+ "[project]\nenabled=true\n"
15
+ end
9
16
 
10
17
  publish_event :project_initialize_complete
11
18
  end
@@ -17,18 +24,6 @@ module Picobox
17
24
 
18
25
 
19
26
  private
20
- def create_project_config_dir
21
- # for now just empty dir, but eventualy add flags with ini files 'ie enabled, etc'
22
- # https://github.com/albfan/bash-ini-parser
23
- TTY::File.create_dir project_config_dir
24
- end
25
-
26
- def create_project_ini
27
- TTY::File.create_file "#{project_config_dir}/#{Picobox::PROJECT_INI}" do |content|
28
- "[project]\nroot=#{os.current_dir}\n"
29
- end
30
- end
31
-
32
27
  def project_config_dir
33
28
  "#{os.current_dir}/#{Picobox::CONFIG_DIR}"
34
29
  end
@@ -0,0 +1,17 @@
1
+ module Picobox
2
+ module Commands
3
+ class InstallConfig < Picobox::Utils::VisitorByOs
4
+ def visit_darwin subject
5
+ publish_event :config_setup_start
6
+
7
+ TTY::File.create_dir os.config_dir
8
+ Shell::IniFile.get(os).install
9
+ end
10
+
11
+
12
+ def visit_linux subject
13
+ visit_darwin subject
14
+ end
15
+ end
16
+ end
17
+ end
@@ -6,7 +6,7 @@ module Picobox
6
6
 
7
7
  publish_event :list_boxes, boxes
8
8
  end
9
-
9
+
10
10
 
11
11
  def visit_linux subject
12
12
  visit_darwin subject
@@ -8,7 +8,7 @@ module Picobox
8
8
  def visit_darwin subject
9
9
  publish_event :remove_service_start, type
10
10
 
11
- raise Errors::ProjectNotInitialized unless project_initialized?
11
+ raise Errors::ProjectNotInitialized unless os.project_initialized?
12
12
 
13
13
  Services::Installer.new(os).uninstall(type)
14
14
 
@@ -22,8 +22,6 @@ module Picobox
22
22
 
23
23
  private
24
24
  attr_reader :type
25
-
26
- def project_initialized?() Utils::Project.new(os).project_initialized? end
27
25
  end
28
26
  end
29
27
  end
@@ -4,8 +4,8 @@ module Picobox
4
4
  def visit_darwin subject
5
5
  publish_event :remove_shell_setup_start
6
6
 
7
- delete_config_directory
8
- uninstall_shell_extensions
7
+ TTY::File.remove_file os.config_dir, force: true
8
+ Shell::StartupScript.get(os).uninstall_extensions
9
9
 
10
10
  publish_event :remove_shell_setup_complete
11
11
  end
@@ -14,17 +14,6 @@ module Picobox
14
14
  def visit_linux subject
15
15
  visit_darwin subject
16
16
  end
17
-
18
-
19
- private
20
- def delete_config_directory
21
- TTY::File.remove_file os.config_dir, force: true
22
- end
23
-
24
- def uninstall_shell_extensions
25
- script = Shell::StartupScript.get(os)
26
- script.uninstall_extensions
27
- end
28
17
  end
29
18
  end
30
19
  end
@@ -2,7 +2,9 @@ module Picobox
2
2
  module Commands
3
3
  class Restart < Picobox::Utils::VisitorByOs
4
4
  def visit_darwin subject
5
- if project_running?
5
+ raise Errors::ProjectNotInitialized unless os.project_initialized?
6
+
7
+ if os.project_running?
6
8
  System.new(Os::CurrentOs.get).stop
7
9
  System.new(Os::CurrentOs.get).start
8
10
  else
@@ -14,9 +16,6 @@ module Picobox
14
16
  def visit_linux subject
15
17
  visit_darwin subject
16
18
  end
17
-
18
- private
19
- def project_running?() Utils::Project.new(os).running? end
20
19
  end
21
20
  end
22
21
  end
@@ -4,11 +4,7 @@ module Picobox
4
4
  def visit_darwin subject
5
5
  publish_event :shell_setup_start
6
6
 
7
- start_up_script = Shell::StartupScript.get(os)
8
-
9
- TTY::File.create_dir os.config_dir
10
-
11
- start_up_script.install_extensions
7
+ Shell::StartupScript.get(os).install_extensions
12
8
 
13
9
  publish_event :shell_setup_complete
14
10
  end
@@ -8,8 +8,8 @@ module Picobox
8
8
  def visit_darwin subject
9
9
  publish_event :opening_shell, service
10
10
 
11
- raise Errors::ProjectNotInitialized unless project_initialized?
12
- raise Errors::SystemDownError unless project_running?
11
+ raise Errors::ProjectNotInitialized unless os.project_initialized?
12
+ raise Errors::SystemDownError unless os.project_running?
13
13
 
14
14
  system "bash", "-c", "docker-compose exec #{service} bash"
15
15
  end
@@ -22,9 +22,6 @@ module Picobox
22
22
 
23
23
  private
24
24
  attr_reader :service
25
-
26
- def project_initialized?() Utils::Project.new(os).project_initialized? end
27
- def project_running?() Utils::Project.new(os).running? end
28
25
  end
29
26
  end
30
27
  end
@@ -4,7 +4,7 @@ module Picobox
4
4
  def visit_darwin subject
5
5
  publish_event :starting
6
6
 
7
- raise Errors::ProjectNotInitialized unless project_initialized?
7
+ raise Errors::ProjectNotInitialized unless os.project_initialized?
8
8
 
9
9
  system("docker-compose up -d #{Picobox.output}")
10
10
  publish_event :started
@@ -14,9 +14,6 @@ module Picobox
14
14
  def visit_linux subject
15
15
  visit_darwin subject
16
16
  end
17
-
18
- private
19
- def project_initialized?() Utils::Project.new(os).project_initialized? end
20
17
  end
21
18
  end
22
19
  end
@@ -2,20 +2,15 @@ module Picobox
2
2
  module Commands
3
3
  class StartUninstall < Picobox::Utils::VisitorByOs
4
4
  def visit_darwin subject
5
- raise Errors::PicoboxNotInstalled unless picobox_installed?
5
+ raise Errors::PicoboxNotInstalled unless os.picobox_installed?
6
6
 
7
7
  publish_event :uninstall_started
8
8
  end
9
9
 
10
-
10
+
11
11
  def visit_linux subject
12
12
  visit_darwin subject
13
13
  end
14
-
15
- private
16
- def picobox_installed?
17
- File.exist? os.config_dir
18
- end
19
14
  end
20
15
  end
21
16
  end
@@ -4,7 +4,7 @@ module Picobox
4
4
  def visit_darwin subject
5
5
  publish_event :stopping
6
6
 
7
- raise Errors::ProjectNotInitialized unless project_initialized?
7
+ raise Errors::ProjectNotInitialized unless os.project_initialized?
8
8
 
9
9
  system("docker-compose down #{Picobox.output}")
10
10
 
@@ -15,9 +15,6 @@ module Picobox
15
15
  def visit_linux subject
16
16
  visit_darwin subject
17
17
  end
18
-
19
- private
20
- def project_initialized?() Utils::Project.new(os).project_initialized? end
21
18
  end
22
19
  end
23
20
  end
@@ -0,0 +1,30 @@
1
+ module Picobox
2
+ module Commands
3
+ class UpdatePackages < Picobox::Utils::VisitorByOs
4
+ def visit_darwin subject
5
+ raise Errors::PicoboxNotInstalled unless os.picobox_installed?
6
+
7
+ packages = Utils::Packages.new(os)
8
+
9
+ if packages.update?
10
+ publish_event :update_packages_start
11
+
12
+ filename = packages.download
13
+
14
+ system("rm -rf #{Picobox.packages_dir}")
15
+ system("mkdir #{Picobox.packages_dir}")
16
+ system("tar xvf #{filename} -C #{Picobox.packages_dir} --strip-components=1 #{Picobox.output}")
17
+
18
+ Shell::IniFile.get(os)[:packages] = { version: packages.version, last_update: Time.now.to_i }
19
+
20
+ publish_event :update_packages_stop
21
+ end
22
+ end
23
+
24
+
25
+ def visit_linux subject
26
+ visit_darwin subject
27
+ end
28
+ end
29
+ end
30
+ end
@@ -1,17 +1,20 @@
1
1
  module Picobox
2
2
  # names for files / directories
3
- VERSION = '0.2.6'
4
- HOMEPAGE = 'https://github.com/surzycki/picobox'
5
- CONFIG_DIR = '.picobox'
6
- PROJECT_INI = 'project.ini'
7
- SHELL_EXTENSIONS = 'shell_extensions'
3
+ VERSION = '0.3.0'
4
+ HOMEPAGE = 'https://github.com/surzycki/picobox'
5
+ PACKAGES_INFO_URL = 'https://api.github.com/repos/picobox/packages/releases/latest'
6
+ CONFIG_DIR = '.picobox'
7
+ PROJECT_INI = 'project.ini'
8
+ PICOBOX_INI = 'picobox.ini'
9
+ SHELL_EXTENSIONS = 'extensions.bash'
8
10
 
9
11
 
10
12
  module_function
11
13
  def root() File.expand_path('../../..', __FILE__) end
12
- def template_dir() "#{Picobox.root}/lib/picobox/templates" end
13
- def box_packages_dir() "#{Picobox.root}/lib/picobox/boxes/packages" end
14
- def service_packages_dir() "#{Picobox.root}/lib/picobox/services/packages" end
14
+ def packages_dir() "#{Picobox.root}/packages" end
15
+ def box_packages_dir() "#{packages_dir}/boxes" end
16
+ def service_packages_dir() "#{packages_dir}/services" end
17
+ def extensions_dir() "#{packages_dir}/shell" end
15
18
 
16
19
  def output() @output end
17
20
  def verbose?() @verbose end