Class: Mimas::CLI::Commands::Init
- Inherits:
-
BaseCommand
- Object
- Dry::CLI::Command
- BaseCommand
- Mimas::CLI::Commands::Init
- Defined in:
- lib/mimas/commands/init.rb
Constant Summary
Constants included from Template
Instance Method Summary collapse
Methods inherited from BaseCommand
Methods included from Terminal::Printer
Methods included from SSH
Methods included from Template
#copy_file, lookup_paths, #read_file, #template
Constructor Details
This class inherits a constructor from Mimas::CLI::Commands::BaseCommand
Instance Method Details
#call ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/mimas/commands/init.rb', line 7 def call say "Initialising Mimas. We need some information about your site." say "" say "Your site's domain will be the containing folder on the server." domain = ask "What is your site's domain name?" ip = ask "What is your production server's IP address?" site_type = ask "Are you creating a \n 1. Ruby app \n 2. Static site \n (1 | 2)" site_type = site_types[site_type] app_server = nil if site_type == :ruby app_server = ask "Which Ruby application server are you using?" app_server&.downcase! unless ["falcon", "puma"].include?(app_server) say "Mimas natively supports Falcon and Puma. To use other server, ensure you configure it to bind to a unix socket defined in `ENV['MIMAS_UNIX_SOCKET']`".white.bold end end Dir.mkdir("deploy") unless Dir.exist? "deploy" destination_dir = File.join(Dir.pwd, Mimas::Config::DEFAULT_DIRECTORY) configrb = template("config.rb", ip: ip, domain: domain, site_type: site_type, app_server: app_server) File.write(File.join(destination_dir, "mimas.rb"), configrb) if site_type == :ruby copy_file(destination_dir, "Caddyfile.ruby.erb", rename: "Caddyfile.erb") if app_server == "falcon" falconrb = template("falcon.rb", domain: domain) File.write(File.join(destination_dir, "falcon.rb"), falconrb) end copy_file(destination_dir, "puma.rb") if app_server == "puma" else copy_file(destination_dir, "Caddyfile.static.erb", rename: "Caddyfile.erb") end Dir.mkdir("tmp") unless Dir.exist?("tmp") say "" say "Successfully created 'deploy/mimas.rb' and 'deploy/Caddyfile.erb'. Customise your deployment by editing these files." say "Please ensure your DNS is correctly configured." end |
#site_types ⇒ Object
54 55 56 57 58 59 |
# File 'lib/mimas/commands/init.rb', line 54 def site_types { "1" => :ruby, "2" => :static } end |