# frozen_string_literal: true require "rails/generators" require "rails/generators/rails/app/app_generator" module TractorBeam class AppGenerator < Rails::Generators::AppGenerator hide! class_option :database, type: :string, aliases: "-d", default: "postgresql", desc: "Configure for selected database (options: #{DATABASES.join('/')})" class_option :version, type: :boolean, aliases: "-v", group: :tractor_beam, desc: "Show TractorBeam version number and quit" class_option :help, type: :boolean, aliases: "-h", group: :tractor_beam, desc: "Show this help message and quit" class_option :path, type: :string, default: nil, desc: "Path to the gem" class_option :skip_test, type: :boolean, default: true, desc: "Skip Test Unit" class_option :skip_system_test, type: :boolean, default: true, desc: "Skip system test files" class_option :skip_turbolinks, type: :boolean, default: true, desc: "Skip turbolinks gem" class_option :skip_sprockets, type: :boolean, aliases: "-S", default: true, desc: "Skip Sprockets files" class_option :skip_coffee, type: :boolean, default: true, desc: "Don't use CoffeeScript" class_option :webpack, type: :string, default: "webpack", desc: "Preconfigure for app-like JavaScript with Webpack (options: #{WEBPACKS.join('/')})" # def finish_template # invoke :beam_customizations # # super # end def beam_customizations build :set_ruby_version invoke :setup_development_environment invoke :setup_production_environment invoke :run_bundle invoke :run_webpack invoke :setup_defaul_rails_features_on_webpack invoke :setup_component_based_frontend invoke :setup_linters invoke :generate_spring_binstubs invoke :git_first_commit invoke :outro end def setup_component_based_frontend say "Setting modern frontend architecture" build :remove_legacy_assets_folder build :setup_root_frontend_folder build :create_application_layout build :setup_browserlist_rc build :customize_webpacker_yml build :prepend_view_path_to_application_controller end def setup_linters say "Setting up linters" build :setup_js_linter build :setup_style_linter build :add_scripts_to_package_json end def setup_development_environment say "Setting up development environment" build :configure_generators build :component_generator build :procfile_dev build :provide_setup_script end def setup_production_environment say "Setting up production environment" build :procfile end def setup_defaul_rails_features_on_webpack build :setup_rails_ujs build :setup_actioncable build :setup_turbolinks end def git_first_commit say "Commiting skeleton app to git" run("git add . && git commit -m 'first commit'") end def outro outro_text = <<-OUTRO ======================== = Abduction complete!! = ======================== OUTRO say outro_text, :blue end def self.banner "tractor_beam #{arguments.map(&:usage).join(' ')} [options]" end protected def get_builder_class TractorBeam::AppBuilder end end end