mimas 0.5.0 → 0.7.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8dc43f51b6e12503251f7aae375c26c7231f0ae96549c675bf82b040604560d6
4
- data.tar.gz: 03fbdf89bcb00a7f976cb25fe21ae3c662ad0c5abb904509bd986e5743f789bc
3
+ metadata.gz: 32d18ae6eabecfaf693befa2c2850b1b5603aa013078280ffc44898e23dd1706
4
+ data.tar.gz: 86f9b0644f120adf2ea0bb9e4e5cacda8ab89d216588c43491bebafb258c05b6
5
5
  SHA512:
6
- metadata.gz: 02ad0133e8c2d58f3b8b1d2b666da86ce006d6f7fd402e3818478e80f41a6cc226957244fd8ac7b16927b2afb722dd3b143404d597d0694dded2da8fd3e92e0a
7
- data.tar.gz: 17a0cfda68a7a0e8f37479435b9efb472043447d09f126d774fd9905d53b94681a87cfcfc55cac7a6a46755d5322c7e97ced66212d11ce22c95b8181d70dfb62
6
+ metadata.gz: 448b7d3a1fb29e51b73068ceac56ed44fad6982e0e1c2eae5d29919601df144e3141d29bde0ec8ba1e2bce037a2cc363053505c8ec4c043edefde766ee75ae7e
7
+ data.tar.gz: 138a243453b2fc62b52fb2625331ee0af5939fd7704ffe2986d030be6af97c5b55e7902166fff7591502a103788adf627644e9d06c79b1d603608971b2e542ff
data/lib/mimas/cli.rb CHANGED
@@ -15,6 +15,11 @@ module Mimas
15
15
  setup.register "deploy_user", Setup::DeployUser
16
16
  setup.register "ruby", Setup::Ruby
17
17
  end
18
+
19
+ register "env" do |setup|
20
+ setup.register "edit", Env::Edit
21
+ setup.register "view", Env::View
22
+ end
18
23
  end
19
24
 
20
25
  Plugins.fetch.each do |plugin|
@@ -4,8 +4,8 @@ module Mimas
4
4
  class Console < BaseCommand
5
5
  desc "Run your app's console"
6
6
 
7
- argument :site, default: :default, desc: "The site to run the console for. Uses the default site if unspecified"
8
7
  argument :server_name, required: true, desc: "The name of the server to run the console on"
8
+ argument :site, default: :default, desc: "The site to run the console for. Uses the default site if unspecified"
9
9
 
10
10
  def call(site:, server_name:, **)
11
11
  site = Config.current.sites[site.to_sym]
@@ -0,0 +1,32 @@
1
+ module Mimas
2
+ module CLI
3
+ module Commands
4
+ class Env::Edit < Env
5
+ desc "Edit the env file for an app"
6
+
7
+ def call(site:, server_name:)
8
+ site = Config.current.sites[site.to_sym]
9
+ server = Config.current.servers[server_name.to_sym]
10
+
11
+ tmp_env_file = Pathname.new(".").join("tmp", ".#{site.name}.mimas.env")
12
+
13
+ system "mkdir -p tmp"
14
+
15
+ ssh(server) do |session|
16
+ session.run "mkdir -p #{server.site_root(site)}"
17
+ session.run "touch #{server.site_root(site).join(".env")}"
18
+
19
+ session.download server.site_root(site).join(".env"), tmp_env_file
20
+
21
+ system "$EDITOR --wait #{tmp_env_file}"
22
+
23
+ session.upload tmp_env_file.to_s, server.site_root(site).join(".env")
24
+ end
25
+
26
+ ensure
27
+ system "rm #{tmp_env_file}"
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,23 @@
1
+ module Mimas
2
+ module CLI
3
+ module Commands
4
+ class Env::View < Env
5
+ desc "View the env file for an app"
6
+
7
+ def call(site:, server_name:)
8
+ site = Config.current.sites[site.to_sym]
9
+ server = Config.current.servers[server_name.to_sym]
10
+
11
+ ssh(server) do |session|
12
+ session.run "mkdir -p #{server.site_root(site)}"
13
+ session.run "touch #{server.site_root(site).join(".env")}"
14
+
15
+ env = session.run "cat #{server.site_root(site).join(".env")}", capture: true
16
+
17
+ say env.bold.white
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,10 @@
1
+ module Mimas
2
+ module CLI
3
+ module Commands
4
+ class Env < BaseCommand
5
+ argument :server_name, required: true, desc: "The name of the server"
6
+ argument :site, default: :default, desc: "The site to modify the env for"
7
+ end
8
+ end
9
+ end
10
+ end
@@ -4,12 +4,12 @@ module Mimas
4
4
  class Push < BaseCommand
5
5
  desc "Push your Ruby app to the server"
6
6
 
7
- argument :site, default: :default, desc: "The site to push. Uses the default site if unspecified"
8
7
  argument :server_name, required: true, desc: "The name of the server to push to"
8
+ argument :site, default: :default, desc: "The site to push. Uses the default site if unspecified"
9
9
 
10
10
  example [
11
11
  "production # Push the default site to the production server",
12
- "app production # Push the `:app` site to the production server"
12
+ "production app # Push the `:app` site to the production server"
13
13
  ]
14
14
 
15
15
  def call(site:, server_name:, **)
@@ -2,7 +2,7 @@ module Mimas
2
2
  module SSH
3
3
  module Interactive
4
4
  def interactive_ssh(host, user:, command:)
5
- system('stty cbreak -echo')
5
+ system('stty raw -echo')
6
6
 
7
7
  Net::SSH.start(host, user) do |session|
8
8
  session.open_channel do |channel|
@@ -51,6 +51,10 @@ module Mimas
51
51
  @ssh.scp.upload! source_file, destination_file
52
52
  end
53
53
 
54
+ def download(source_file, destination_file)
55
+ @ssh.scp.download! source_file, destination_file
56
+ end
57
+
54
58
  def script(name, sudo: false, vars: {})
55
59
  filename = "#{name}.sh"
56
60
  remote_location = "/tmp/#{filename}"
data/lib/mimas/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mimas
2
- VERSION = "0.5.0"
2
+ VERSION = "0.7.0"
3
3
  end
data/lib/mimas.rb CHANGED
@@ -44,6 +44,9 @@ require_relative "mimas/commands/console"
44
44
  require_relative "mimas/commands/init"
45
45
  require_relative "mimas/commands/provision"
46
46
  require_relative "mimas/commands/push"
47
+ require_relative "mimas/commands/env"
48
+ require_relative "mimas/commands/env/edit"
49
+ require_relative "mimas/commands/env/view"
47
50
  require_relative "mimas/commands/ruby"
48
51
  require_relative "mimas/commands/ruby/install"
49
52
  require_relative "mimas/commands/setup"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mimas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ayush Newatia
@@ -106,6 +106,9 @@ files:
106
106
  - lib/mimas/cli.rb
107
107
  - lib/mimas/commands/archive.rb
108
108
  - lib/mimas/commands/console.rb
109
+ - lib/mimas/commands/env.rb
110
+ - lib/mimas/commands/env/edit.rb
111
+ - lib/mimas/commands/env/view.rb
109
112
  - lib/mimas/commands/init.rb
110
113
  - lib/mimas/commands/provision.rb
111
114
  - lib/mimas/commands/push.rb