mimas-rails 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1ef176e12527799f2ae157cddc6b687f4c48c29ddcf6bb96ee39039b22441d39
4
+ data.tar.gz: c249ea3f2a721d5ec1031dec74343b4a4511677e120017ed7659cefa26af8f06
5
+ SHA512:
6
+ metadata.gz: d8aa6df9635fd1a9d1eddc8b1c4c59e9fda8d745fc529e66d449d87212481a518f1fbda6d1fa1335134b90780fb567c0dfef8c4f9b07c72424175947ac500681
7
+ data.tar.gz: f231a8cbcebe31fe06a2b5b246d895d964e97b88c9f56af7c4b17b17584c574bde5fda89692b4d2acce5121b1eab04e9153b4b55c459cf5721a67eed191aaa7f
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026-present Ayush Newatia
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,44 @@
1
+ module Mimas
2
+ module Plugins
3
+ module Rails
4
+ module Commands
5
+ class Init < Mimas::CLI::Commands::BaseCommand
6
+ desc "Create the Mimas config file"
7
+
8
+ def call
9
+ say "Initialising Mimas. We need some information about your site."
10
+ say ""
11
+
12
+ say "Your site's domain will be the containing folder on the server."
13
+ domain = ask "What is your site's domain name?"
14
+ ip = ask "What is your production server's IP address?"
15
+
16
+ Dir.mkdir("deploy") unless Dir.exist? "deploy"
17
+
18
+ destination_dir = File.join(Dir.pwd, Mimas::Config::DEFAULT_DIRECTORY)
19
+
20
+ app_server = Bundler.load.requested_specs.map(&:name).filter { ["falcon", "puma"].include?(it) }.first
21
+
22
+ configrb = template("config.rb", ip: ip, domain: domain, app_server: app_server)
23
+ File.write(File.join(destination_dir, "mimas.rb"), configrb)
24
+
25
+ copy_file(destination_dir, "Caddyfile.erb")
26
+
27
+ if app_server == "falcon"
28
+ falconrb = template("falcon.rb", domain: domain)
29
+ File.write(File.join(destination_dir, "falcon.rb"), falconrb)
30
+ end
31
+
32
+ copy_file(destination_dir, "puma.rb") if app_server == "puma"
33
+
34
+ Dir.mkdir("tmp") unless Dir.exist?("tmp")
35
+
36
+ say ""
37
+ say "Successfully created 'deploy/mimas.rb' and 'deploy/Caddyfile.erb'. Customise your deployment by editing these files."
38
+ say "Please ensure your DNS is correctly configured."
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,7 @@
1
+ module Mimas
2
+ module Plugins
3
+ module Rails
4
+ VERSION = "0.1.0"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,35 @@
1
+ module Mimas
2
+ module Plugins
3
+ module Rails
4
+ extend self
5
+
6
+ def register_commands(cli)
7
+ cli.register "init", Commands::Init
8
+ end
9
+
10
+ def hooks
11
+ hooks = Mimas::Hooks.new
12
+
13
+ hooks.before_push do |site|
14
+ site.env.each_line do
15
+ key, value = it.split("=").map(&:strip)
16
+ ENV[key] = value
17
+ end
18
+
19
+ `bin/rails assets:clobber`
20
+ `bin/rails assets:precompile`
21
+ end
22
+
23
+ hooks.after_push do
24
+ `bin/rails assets:clobber`
25
+ end
26
+
27
+ hooks
28
+ end
29
+
30
+ def templates_dir
31
+ Pathname.new(__dir__).join("templates")
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,21 @@
1
+ <%= domain %> {
2
+ reverse_proxy {
3
+ to unix/<%= unix_socket %>
4
+
5
+ lb_try_duration 5s
6
+ }
7
+
8
+ file_server /assets/* {
9
+ root <%= site_root %>/current/public/assets
10
+ }
11
+
12
+ @stamped-assets path /assets/*
13
+ header @stamped-assets {
14
+ cache-control "public, max-age=31536000, immutable"
15
+ }
16
+
17
+ log {
18
+ format console
19
+ output file <%= site_root %>/logs/caddy.log
20
+ }
21
+ }
@@ -0,0 +1,41 @@
1
+ site do
2
+ domain "<%= domain %>"
3
+ files do
4
+ `git ls-files -z`.split("\x0")
5
+ .reject do
6
+ it.match(%r!^(bin|mimas.rb|Caddyfile|log|test|tmp|.gitignore|.gitattributes)!)
7
+ end
8
+ .push(*Dir.glob("./public/*"))
9
+ .push(*Dir.glob("./public/assets/**/*", File::FNM_DOTMATCH))
10
+ end
11
+
12
+ healthcheck_path "/up"
13
+
14
+ # Access the console by running `mimas console SERVER_NAME`
15
+ console "bundle exec rails console"
16
+
17
+ env do
18
+ <<~STRING
19
+ RAILS_ENV=production
20
+ STRING
21
+ end
22
+
23
+ deploy do
24
+ <<~STRING
25
+ bundle install
26
+ bundle binstub railties
27
+ bundle exec rake db:migrate
28
+ STRING
29
+ end
30
+
31
+ services do
32
+ web do
33
+ command "bundle exec puma -C deploy/puma.rb"
34
+ end
35
+ end
36
+ end
37
+
38
+ server :production do
39
+ host "<%= ip %>"
40
+ user "deploy"
41
+ end
@@ -0,0 +1,6 @@
1
+ require "mimas"
2
+ require_relative "mimas/plugins/rails"
3
+
4
+ require_relative "mimas/plugins/rails/commands/init"
5
+
6
+ Mimas::Plugins.register(Mimas::Plugins::Rails)
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mimas-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ayush Newatia
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: mimas
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '0.8'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '0.8'
26
+ email: ayush@hey.com
27
+ executables: []
28
+ extensions: []
29
+ extra_rdoc_files: []
30
+ files:
31
+ - LICENSE.txt
32
+ - lib/mimas-rails.rb
33
+ - lib/mimas/plugins/rails.rb
34
+ - lib/mimas/plugins/rails/commands/init.rb
35
+ - lib/mimas/plugins/rails/version.rb
36
+ - lib/mimas/plugins/templates/Caddyfile.erb
37
+ - lib/mimas/plugins/templates/config.rb.erb
38
+ homepage: https://codeberg.org/ayushn21/mimas-rails
39
+ licenses:
40
+ - MIT
41
+ metadata:
42
+ mimas_plugin: 'true'
43
+ rdoc_options: []
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 3.4.0
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ requirements: []
57
+ rubygems_version: 4.0.16
58
+ specification_version: 4
59
+ summary: Simplify Rails deployment using Mimas
60
+ test_files: []