Class: StimulusPlumbers::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
CssEntrypoint
Defined in:
lib/generators/stimulus_plumbers/install/install_generator.rb

Constant Summary collapse

STIMULUS_PLUMBERS_CSS_FILE =
CssEntrypoint::STIMULUS_PLUMBERS_CSS_FILE
CSS_CANDIDATES =
%w[
  app/assets/stylesheets/application.tailwind.css
  app/assets/stylesheets/application.css
  app/javascript/entrypoints/application.css
].freeze

Instance Method Summary collapse

Methods included from CssEntrypoint

#apply_edit, #content_edit, #entry_css_file, #insert_near_anchor, #prepend, #relative_to_destination, #warn_entry_css_not_found

Instance Method Details

#installObject



19
20
21
22
23
24
25
26
# File 'lib/generators/stimulus_plumbers/install/install_generator.rb', line 19

def install
  css_file = entry_css_file(candidates: CSS_CANDIDATES, env_var: STIMULUS_PLUMBERS_CSS_FILE)
  unless css_file
    return warn_entry_css_not_found(candidates: CSS_CANDIDATES, env_var: STIMULUS_PLUMBERS_CSS_FILE, label: "CSS")
  end

  apply_edit(css_file, TokensDirective.directive, stale_pattern: TokensDirective.stale_pattern)
end