mimas 0.6.0 → 0.8.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: 6dc4a3414f0933e28ec8423cfe5a196ab7d71e7f29bf49ebe90c769a0ad639e5
4
- data.tar.gz: 828a20632f35dc23aec49355b97f542b71453be576bc2054becf95d6b489b316
3
+ metadata.gz: d7b1e0a122cca5f1960259943841f29cb12c967bf694de92338265a8ba3b7d77
4
+ data.tar.gz: 83880507d160303bf177657773ebbc5f664fb39a763b28a30c7442020cdbacc2
5
5
  SHA512:
6
- metadata.gz: f4d3bd8d2c05458282bac661ef17eca0bb75b945c4c09c95bf8aedaac7b7ea9109caf775dc1d6406db6238538504def83fccf616496423d6e464d3a6f6c9e1e3
7
- data.tar.gz: b37b16ff9c64cfb233dc2a5d1b6274908f4be362b96c8eb9c4bc99536dbe32e173296825116775e158950543d33b95e8cfa3163a8330b838906566a7d48e6086
6
+ metadata.gz: e6bb11010c26816b7ea3af61871b06061782adf92b5222dbb61c8816c35ea23c0d9afe432a329afccf87686c8599c3baad3d66d0aa5309389bb8987da7390a6d
7
+ data.tar.gz: b1b77669d6fb2e3809bd5f696c723ccb407a2db9e5d98b6b78f311cfc9b7986f37d44d377897172ef2e8ab9e48a8bb51732572e1aa26c24e3d92b23fdb8d37c9
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:, **)
@@ -33,11 +33,11 @@ module Mimas
33
33
  end
34
34
  end
35
35
 
36
- @hooks[:before_push].each { it.call }
36
+ Hooks.run(@hooks[:before_push], args: [site])
37
37
 
38
38
  Deployment.new(site: site, server: server).deploy
39
39
 
40
- @hooks[:after_push].each { it.call }
40
+ Hooks.run(@hooks[:after_push], args: [site])
41
41
  end
42
42
  end
43
43
  end
data/lib/mimas/config.rb CHANGED
@@ -105,6 +105,10 @@ module Mimas
105
105
  end
106
106
 
107
107
  class Site < Options
108
+ def files(&block)
109
+ @options[:files] = block
110
+ end
111
+
108
112
  def services(&block)
109
113
  @options[:services] = Services.parse(&block)
110
114
  end
@@ -33,7 +33,7 @@ module Mimas
33
33
 
34
34
  say "Running deploy script"
35
35
  session.upload StringIO.new(site.deploy), deploy_script_path
36
- session.run "cd #{remote_destination} && ~/.cargo/bin/rv run sh #{deploy_script}"
36
+ session.run "cd #{remote_destination} && /usr/bin/env bash -lc 'set -a; source #{site_root.join(".env")}; source #{mimas_path.join("mimas.env")}; rv run sh #{deploy_script}; set +a;'"
37
37
  session.run "rm #{deploy_script_path}"
38
38
 
39
39
  say "Setting current symlink"
@@ -66,7 +66,6 @@ module Mimas
66
66
  exit 1
67
67
  end
68
68
 
69
-
70
69
  cleanup_successful_deployment(session, remote_current_version: remote_current_version)
71
70
  say "\n"
72
71
  say "Deployment complete! #{version} is now live.".bold.white
data/lib/mimas/hooks.rb CHANGED
@@ -16,6 +16,16 @@ module Mimas
16
16
  end
17
17
  end
18
18
 
19
+ def self.run(hooks, args: [])
20
+ hooks.each do |hook|
21
+ if hook.arity == args.count
22
+ hook.call(*args)
23
+ else
24
+ hook.call
25
+ end
26
+ end
27
+ end
28
+
19
29
  POINTS.each do |point|
20
30
  define_method(point) do |&block|
21
31
  @hooks[point] << block
@@ -3,7 +3,7 @@ module Mimas
3
3
  module Archive
4
4
  def archive(filename: "#{name}.tar.gz")
5
5
  if self.ruby_app?
6
- Archiver.new(output_file: filename, files: files).package
6
+ Archiver.new(output_file: filename, files: files.call).package
7
7
  else
8
8
  Archiver.new(root: root_dir, output_file: filename, archive_root: "root", glob: glob, files: files).package
9
9
  end
@@ -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.6.0"
2
+ VERSION = "0.8.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.6.0
4
+ version: 0.8.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
@@ -170,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
173
  - !ruby/object:Gem::Version
171
174
  version: '0'
172
175
  requirements: []
173
- rubygems_version: 4.0.18
176
+ rubygems_version: 4.0.16
174
177
  specification_version: 4
175
178
  summary: Deploy Ruby apps to a single server using an omakase setup
176
179
  test_files: []