class ReactOnRails::Generators::InstallGenerator
Public Instance Methods
Source
# File lib/generators/react_on_rails/install_generator.rb, line 28 def run_generators if installation_prerequisites_met? || options.ignore_warnings? invoke_generators add_bin_scripts add_post_install_message else error = "react_on_rails generator prerequisites not met!" GeneratorMessages.add_error(error) end ensure print_generator_messages end
Private Instance Methods
Source
# File lib/generators/react_on_rails/install_generator.rb, line 83 def add_bin_scripts directory "#{__dir__}/bin", "bin" # Make these and only these files executable files_to_copy = [] Dir.chdir("#{__dir__}/bin") do files_to_copy.concat(Dir.glob("*")) end files_to_become_executable = files_to_copy.map { |filename| "bin/#{filename}" } File.chmod(0o755, *files_to_become_executable) end
Source
# File lib/generators/react_on_rails/install_generator.rb, line 96 def add_post_install_message GeneratorMessages.add_info(GeneratorMessages.helpful_message_after_installation) end
Source
# File lib/generators/react_on_rails/install_generator.rb, line 63 def installation_prerequisites_met? !(missing_node? || missing_yarn? || ReactOnRails::GitUtils.uncommitted_changes?(GeneratorMessages)) end
NOTE: other requirements for existing files such as .gitignore or application. js(.coffee) are not checked by this method, but instead produce warning messages and allow the build to continue
Source
# File lib/generators/react_on_rails/install_generator.rb, line 49 def invoke_generators invoke "react_on_rails:base" if options.redux? invoke "react_on_rails:react_with_redux" else invoke "react_on_rails:react_no_redux" end invoke "react_on_rails:adapt_for_older_shakapacker" unless using_shakapacker_7_or_above? end
Source
# File lib/generators/react_on_rails/install_generator.rb, line 75 def missing_node? return false unless ReactOnRails::Utils.running_on_windows? ? `where node`.blank? : `which node`.blank? error = "** nodejs is required. Please install it before continuing. https://nodejs.org/en/" GeneratorMessages.add_error(error) true end
Source
# File lib/generators/react_on_rails/install_generator.rb, line 67 def missing_yarn? return false unless ReactOnRails::Utils.running_on_windows? ? `where yarn`.blank? : `which yarn`.blank? error = "yarn is required. Please install it before continuing. https://yarnpkg.com/en/docs/install" GeneratorMessages.add_error(error) true end
Source
# File lib/generators/react_on_rails/install_generator.rb, line 45 def print_generator_messages GeneratorMessages.messages.each { |message| puts message } end
Everything here is not run automatically b/c it’s private
Source
# File lib/generators/react_on_rails/install_generator.rb, line 100 def using_shakapacker_7_or_above? shakapacker_gem = Gem::Specification.find_by_name("shakapacker") shakapacker_gem.version.segments.first >= 7 rescue Gem::MissingSpecError # In case using Webpacker false end