Skip to content

Commit

Permalink
Merge pull request #2385 from tvdeyen/more-installer-options
Browse files Browse the repository at this point in the history
More installer options
  • Loading branch information
tvdeyen authored Nov 18, 2022
2 parents 5c210af + d27a558 commit f99cef5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
4 changes: 1 addition & 3 deletions lib/alchemy/install/tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ def inject_routes(auto_accept = false)
inject_into_file "./config/routes.rb", "\n mount Alchemy::Engine => '#{mountpoint}'\n", { after: sentinel, verbose: true }
end

def set_primary_language(auto_accept = false)
code = "en"
def set_primary_language(code: "en", name: "English", auto_accept: false)
unless auto_accept
code = ask("- What is the language code of your site's primary language?", default: code)
end
name = "English"
unless auto_accept
name = ask("- What is the name of your site's primary language?", default: name)
end
Expand Down
30 changes: 27 additions & 3 deletions lib/generators/alchemy/install/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,34 @@ class InstallGenerator < ::Rails::Generators::Base
class_option :skip_db_create,
type: :boolean,
default: false,
desc: "Skip creting the database during install."
desc: "Skip creating the database during install."

class_option :skip_mount,
type: :boolean,
default: false,
desc: "Skip mounting into routes.rb during install."

class_option :default_language_code,
type: :string,
default: "en",
desc: "The default language code of your site."

class_option :default_language_name,
type: :string,
default: "English",
desc: "The default language name of your site."

source_root File.expand_path("files", __dir__)

def setup
header
say "Welcome to AlchemyCMS!"
say "Let's begin with some questions.\n\n"
end

def mount
return if options[:skip_mount]

install_tasks.inject_routes(options[:auto_accept])
end

Expand Down Expand Up @@ -108,13 +128,17 @@ def copy_alchemy_entry_point

def set_primary_language
header
install_tasks.set_primary_language(options[:auto_accept])
install_tasks.set_primary_language(
code: options[:default_language_code],
name: options[:default_language_name],
auto_accept: options[:auto_accept]
)
end

def setup_database
rake("db:create", abort_on_failure: true) unless options[:skip_db_create]
# We can't invoke this rake task, because Rails will use wrong engine names otherwise
rake("railties:install:migrations", abort_on_failure: true)
rake("alchemy:install:migrations", abort_on_failure: true)
rake("db:migrate", abort_on_failure: true)
install_tasks.inject_seeder
rake("db:seed", abort_on_failure: true)
Expand Down

0 comments on commit f99cef5

Please sign in to comment.