mimas 0.2.3 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a200733060462cb02f5bb316922a18a44f2c02631707ded251f42f25fd4ea0ac
4
- data.tar.gz: ddd5a59c92ae52c85312a92698e3d8f2b7ca85f53c7333bc82376d9bf4b47742
3
+ metadata.gz: ea7a87706ea7f9976b782cb891e446b813c7c866e2a4907f451565e670d194a5
4
+ data.tar.gz: adde800fcc3df657cc512cfd14b9fe1ef314e3d4f19f903c68259c3d7394ef28
5
5
  SHA512:
6
- metadata.gz: 05d4669a9e1122b00de75885ad66734ca6b19da728e5b7b5df02e8a68d46dc2cf3d0bc01155ba88c41949c41534c71d8750608fb688e4c14b340aeca08acfc79
7
- data.tar.gz: 632f575040f53862208831bef4f743ee9960f1a47a56023b15c0b2c49a5767e70a8e14fac0a22c030cd15373f7d168659f6d8f478dc1d2e506ea6b9114c5f08a
6
+ metadata.gz: 984c764fc02feeb671c63f33528258abb8ad271811400d27affe7e220fd4eb6d66652b57a3b829fa1bf972aa23a6a2d5fbb42fe6bc7ec290cf1c1155fc352654
7
+ data.tar.gz: 939fa01df07457e75ecb9b2929757edfa0045cb109ec7f7b33366566397af491aca94df1f4a00125f99bd119ab05fc8cc4b318f3cb6c21e0bdabbc03a1853619
@@ -2,18 +2,12 @@ require 'zlib'
2
2
  require 'rubygems/package'
3
3
 
4
4
  module Mimas
5
- module Archive
6
- def archive(root: Dir.pwd, output:, archive_root: "", glob: nil, files: [])
7
- Archiver
8
- .new(root: root, output: output, archive_root: archive_root, glob: glob, files: files)
9
- .package
10
- end
11
- end
12
-
13
5
  class Archiver
14
- def initialize(root:, output:, archive_root:, glob: nil, files: [])
6
+ DEFAULT_OUTPUT_PATH = Pathname.new(Dir.pwd).join("tmp")
7
+
8
+ def initialize(root:, output_path: DEFAULT_OUTPUT_PATH, output_file:, archive_root: nil, glob: nil, files: [])
15
9
  @root = root || Dir.pwd
16
- @output = output
10
+ @output = Pathname.new(output_path).join(output_file)
17
11
  @archive_root = archive_root || ""
18
12
  @glob = glob
19
13
  @source_files = files
@@ -27,6 +21,8 @@ module Mimas
27
21
 
28
22
  tar.close
29
23
  gz.close
24
+
25
+ return @output.to_s
30
26
  end
31
27
 
32
28
  private
data/lib/mimas/cli.rb CHANGED
@@ -8,6 +8,7 @@ module Mimas
8
8
  register "provision", Provision
9
9
  register "push", Push
10
10
  register "console", Console
11
+ register "archive", Archive
11
12
  register "setup caddy", Setup::Caddy
12
13
  register "setup deploy_user", Setup::DeployUser
13
14
  register "setup ruby", Setup::Ruby
@@ -0,0 +1,19 @@
1
+ module Mimas
2
+ module CLI
3
+ module Commands
4
+ class Archive < BaseCommand
5
+ desc "Create your site's archive which will be uploaded to the server"
6
+
7
+ argument :site, desc: "The name of the site to archive"
8
+
9
+ def call(site: :default)
10
+ site = Config.current.sites[site.to_sym]
11
+
12
+ site.archive
13
+
14
+ say "Your site's archive has been created in #{Archiver::DEFAULT_OUTPUT_PATH}"
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -7,7 +7,7 @@ module Mimas
7
7
  argument :server_name, required: true, desc: "The name of the server to run the console on"
8
8
  argument :site, desc: "The site to run the console for. Uses the default site if unspecified"
9
9
 
10
- def call(server_name, site: :default)
10
+ def call(server_name:, site: :default)
11
11
  server = Config.current.servers[server_name.to_sym]
12
12
  site = Config.current.sites[site.to_sym]
13
13
 
@@ -10,7 +10,7 @@ module Mimas
10
10
  end
11
11
 
12
12
  def archive_path
13
- @archive_path ||= File.join(Dir.pwd, "tmp", archive_name)
13
+ @archive_path
14
14
  end
15
15
 
16
16
  def site_root
@@ -4,7 +4,7 @@ module Mimas
4
4
  def deploy_ruby_app
5
5
  say "Starting deployment for #{site.domain}"
6
6
 
7
- archive(output: archive_path, files: site.files)
7
+ @archive_path = site.archive(filename: archive_name)
8
8
 
9
9
  ssh(server) do |session|
10
10
  validate_server_ruby_version(session)
@@ -4,7 +4,7 @@ module Mimas
4
4
  def deploy_static_site
5
5
  say "Starting deployment for #{site.domain}"
6
6
 
7
- archive(root: site.root_dir, output: archive_path, archive_root: "root", glob: site.glob)
7
+ @archive_path = site.archive(filename: archive_name)
8
8
 
9
9
  ssh(server) do |session|
10
10
  refreshing_caddy(session) do
@@ -1,6 +1,6 @@
1
1
  module Mimas
2
2
  class Deployment
3
- include Terminal::Printer, Template, Archive, SSH
3
+ include Terminal::Printer, Template, SSH
4
4
 
5
5
  include Paths, Files
6
6
  include StaticSite, RubyApp, Caddy
@@ -0,0 +1,13 @@
1
+ module Mimas
2
+ class Site
3
+ module Archive
4
+ def archive(filename: "#{name}.tar.gz")
5
+ if self.ruby_app?
6
+ Archiver.new(output_file: filename, files: files).package
7
+ else
8
+ Archiver.new(root: root_dir, output_file: filename, archive_root: "root", glob: glob, files: files).package
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
data/lib/mimas/site.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  module Mimas
2
2
  class Site
3
+ include Archive
4
+
3
5
  attr_reader :name
4
6
  def initialize(name, args)
5
7
  @name = name
@@ -21,21 +23,34 @@ module Mimas
21
23
  services.any?
22
24
  end
23
25
 
26
+ # Placeholder, will be overwritten by the config file if defined
27
+ def glob
28
+ nil
29
+ end
30
+
31
+ # Placeholder, will be overwritten by the config file if defined
32
+ def files
33
+ nil
34
+ end
35
+
24
36
  def validate!
25
37
  raise Config::InvalidConfiguration.new("`site` requires a `domain`") \
26
38
  unless self.respond_to?(:domain)
27
39
 
28
40
  if ruby_app?
29
41
  raise Config::InvalidConfiguration.new("`site` requires a `files` directive") \
30
- unless self.respond_to?(:files)
42
+ unless self.files != nil
31
43
 
32
44
  services.values.each do |service|
33
45
  raise Config::InvalidConfiguration.new("#{service[:name]} service requires a `command` directive") \
34
46
  unless service[:command]
35
47
  end
36
48
  else
37
- raise Config::InvalidConfiguration.new("`site` requires a `root_dir` and `glob` directive") \
38
- unless self.respond_to?(:root_dir) && self.respond_to?(:glob)
49
+ raise Config::InvalidConfiguration.new("`site` requires a `root_dir` directive") \
50
+ unless self.respond_to?(:root_dir)
51
+
52
+ raise Config::InvalidConfiguration.new("`site` requires a `files` or `glob` directive") \
53
+ unless self.glob != nil || self.files != nil
39
54
  end
40
55
 
41
56
  true
data/lib/mimas/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mimas
2
- VERSION = "0.2.3"
2
+ VERSION = "0.3.0"
3
3
  end
data/lib/mimas.rb CHANGED
@@ -16,6 +16,7 @@ require_relative "mimas/hooks"
16
16
 
17
17
  require_relative "mimas/config"
18
18
 
19
+ require_relative "mimas/site/archive"
19
20
  require_relative "mimas/site"
20
21
 
21
22
  require_relative "mimas/server/prerequisites"
@@ -35,6 +36,7 @@ require_relative "mimas/deployment"
35
36
  require_relative "mimas/plugins"
36
37
 
37
38
  require_relative "mimas/base_command"
39
+ require_relative "mimas/commands/archive"
38
40
  require_relative "mimas/commands/console"
39
41
  require_relative "mimas/commands/init"
40
42
  require_relative "mimas/commands/install"
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.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ayush Newatia
@@ -104,6 +104,7 @@ files:
104
104
  - lib/mimas/archiver.rb
105
105
  - lib/mimas/base_command.rb
106
106
  - lib/mimas/cli.rb
107
+ - lib/mimas/commands/archive.rb
107
108
  - lib/mimas/commands/console.rb
108
109
  - lib/mimas/commands/init.rb
109
110
  - lib/mimas/commands/install.rb
@@ -135,6 +136,7 @@ files:
135
136
  - lib/mimas/server/prerequisites.rb
136
137
  - lib/mimas/server/ruby.rb
137
138
  - lib/mimas/site.rb
139
+ - lib/mimas/site/archive.rb
138
140
  - lib/mimas/ssh.rb
139
141
  - lib/mimas/template.rb
140
142
  - lib/mimas/templates/Caddyfile.ruby.erb