mimas 0.2.3 → 0.3.1
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 +4 -4
- data/lib/mimas/archiver.rb +7 -11
- data/lib/mimas/cli.rb +12 -8
- data/lib/mimas/commands/archive.rb +19 -0
- data/lib/mimas/commands/console.rb +3 -3
- data/lib/mimas/commands/push.rb +2 -2
- data/lib/mimas/deployment/paths.rb +1 -1
- data/lib/mimas/deployment/ruby_app.rb +1 -1
- data/lib/mimas/deployment/static_site.rb +1 -1
- data/lib/mimas/deployment.rb +2 -2
- data/lib/mimas/server/console.rb +1 -1
- data/lib/mimas/server.rb +2 -0
- data/lib/mimas/site/archive.rb +13 -0
- data/lib/mimas/site.rb +18 -3
- data/lib/mimas/version.rb +1 -1
- data/lib/mimas.rb +3 -0
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 63e189942a8ac6122487ac902f2a3ccf5e353442b2159cd336a0b0b4828d4fb3
|
|
4
|
+
data.tar.gz: 07250c8fe15deef0ebacd566feeb500efc91a6cf1d77631f63e1ae4c084e7ba0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ffc9f5c7c236c550f205376277f591b68af6a4328d1f4e510d2e21f3500aec6aa09a0066ca25f57953b867126dda52594ec7afb5492a5d8353047d722fe24fd4
|
|
7
|
+
data.tar.gz: e4cbbfe1fd2bdbd973a00116507f0d7b3b47871c7d20acddd9baa9d09827c51c6c85ba3fc8e37d7f5f737a5ff4a1137f2c2f64d751fe24f41e0e494c3a757c32
|
data/lib/mimas/archiver.rb
CHANGED
|
@@ -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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
DEFAULT_OUTPUT_PATH = Pathname.new(Dir.pwd).join("tmp")
|
|
7
|
+
|
|
8
|
+
def initialize(root: Dir.pwd, output_path: DEFAULT_OUTPUT_PATH, output_file:, archive_root: nil, glob: nil, files: [])
|
|
9
|
+
@root = root
|
|
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
|
@@ -3,14 +3,18 @@ module Mimas
|
|
|
3
3
|
module Commands
|
|
4
4
|
extend Dry::CLI::Registry
|
|
5
5
|
|
|
6
|
-
register "init",
|
|
7
|
-
register "install ruby",
|
|
8
|
-
register "provision",
|
|
9
|
-
register "push",
|
|
10
|
-
register "console",
|
|
11
|
-
register "
|
|
12
|
-
|
|
13
|
-
register "setup
|
|
6
|
+
register "init", Init
|
|
7
|
+
register "install ruby", Install
|
|
8
|
+
register "provision", Provision
|
|
9
|
+
register "push", Push, aliases: ["deploy"]
|
|
10
|
+
register "console", Console
|
|
11
|
+
register "archive", Archive
|
|
12
|
+
|
|
13
|
+
register "setup" do |setup|
|
|
14
|
+
setup.register "caddy", Setup::Caddy
|
|
15
|
+
setup.register "deploy_user", Setup::DeployUser
|
|
16
|
+
setup.register "ruby", Setup::Ruby
|
|
17
|
+
end
|
|
14
18
|
end
|
|
15
19
|
|
|
16
20
|
Plugins.fetch.each do |plugin|
|
|
@@ -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, in a `tmp` folder. Use this to inspect what will be uploaded."
|
|
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
|
|
@@ -4,10 +4,10 @@ module Mimas
|
|
|
4
4
|
class Console < BaseCommand
|
|
5
5
|
desc "Run your app's console"
|
|
6
6
|
|
|
7
|
-
argument :server_name, required: true,
|
|
8
|
-
argument :site,
|
|
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
|
-
def call(server_name
|
|
10
|
+
def call(server_name:, site:, **)
|
|
11
11
|
server = Config.current.servers[server_name.to_sym]
|
|
12
12
|
site = Config.current.sites[site.to_sym]
|
|
13
13
|
|
data/lib/mimas/commands/push.rb
CHANGED
|
@@ -5,14 +5,14 @@ module Mimas
|
|
|
5
5
|
desc "Push your Ruby app to the server"
|
|
6
6
|
|
|
7
7
|
argument :server_name, required: true, desc: "The name of the server to push to"
|
|
8
|
-
argument :site,
|
|
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
12
|
"production app # Push the `:app` site to the production server"
|
|
13
13
|
]
|
|
14
14
|
|
|
15
|
-
def call(server_name:, site
|
|
15
|
+
def call(server_name:, site:, **)
|
|
16
16
|
server = Config.current.servers[server_name.to_sym]
|
|
17
17
|
site = Config.current.sites[site.to_sym]
|
|
18
18
|
|
|
@@ -4,7 +4,7 @@ module Mimas
|
|
|
4
4
|
def deploy_static_site
|
|
5
5
|
say "Starting deployment for #{site.domain}"
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
@archive_path = site.archive(filename: archive_name)
|
|
8
8
|
|
|
9
9
|
ssh(server) do |session|
|
|
10
10
|
refreshing_caddy(session) do
|
data/lib/mimas/deployment.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module Mimas
|
|
2
2
|
class Deployment
|
|
3
|
-
include Terminal::Printer, Template,
|
|
3
|
+
include Terminal::Printer, Template, SSH
|
|
4
4
|
|
|
5
5
|
include Paths, Files
|
|
6
6
|
include StaticSite, RubyApp, Caddy
|
|
@@ -21,7 +21,7 @@ module Mimas
|
|
|
21
21
|
deploy_ruby_app
|
|
22
22
|
end
|
|
23
23
|
ensure
|
|
24
|
-
File.delete(archive_path)
|
|
24
|
+
File.delete(archive_path) if archive_path
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
end
|
data/lib/mimas/server/console.rb
CHANGED
|
@@ -8,7 +8,7 @@ module Mimas
|
|
|
8
8
|
Net::SSH.start(host, user) do |session|
|
|
9
9
|
session.open_channel do |channel|
|
|
10
10
|
channel.request_pty do
|
|
11
|
-
channel.exec("cd #{current_path(site)} && /bin/bash -lc #{console_command}") do
|
|
11
|
+
channel.exec("cd #{current_path(site)} && /bin/bash -lc '#{console_command}'") do
|
|
12
12
|
channel.on_data do |_, data|
|
|
13
13
|
$stdout.print(data) if data
|
|
14
14
|
end
|
data/lib/mimas/server.rb
CHANGED
|
@@ -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.
|
|
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`
|
|
38
|
-
unless self.respond_to?(:root_dir)
|
|
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
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"
|
|
@@ -23,6 +24,7 @@ require_relative "mimas/server/harden"
|
|
|
23
24
|
require_relative "mimas/server/deploy_user"
|
|
24
25
|
require_relative "mimas/server/caddy"
|
|
25
26
|
require_relative "mimas/server/ruby"
|
|
27
|
+
require_relative "mimas/server/console"
|
|
26
28
|
require_relative "mimas/server"
|
|
27
29
|
|
|
28
30
|
require_relative "mimas/deployment/caddy"
|
|
@@ -35,6 +37,7 @@ require_relative "mimas/deployment"
|
|
|
35
37
|
require_relative "mimas/plugins"
|
|
36
38
|
|
|
37
39
|
require_relative "mimas/base_command"
|
|
40
|
+
require_relative "mimas/commands/archive"
|
|
38
41
|
require_relative "mimas/commands/console"
|
|
39
42
|
require_relative "mimas/commands/init"
|
|
40
43
|
require_relative "mimas/commands/install"
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mimas
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ayush Newatia
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-07-
|
|
10
|
+
date: 2026-07-31 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: dry-cli
|
|
@@ -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
|