Class: Senren::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Senren::Generators::InstallGenerator
- Defined in:
- lib/generators/senren/install/install_generator.rb
Instance Method Summary collapse
-
#configure_stimulus_loading ⇒ Object
Switches Stimulus to on-demand loading instead of documenting it.
- #copy_base_files ⇒ Object
- #create_assets_dir ⇒ Object
- #create_components_dir ⇒ Object
- #create_senren_dir ⇒ Object
- #create_stimulus_dir ⇒ Object
- #mirror_registry ⇒ Object
- #print_next_steps ⇒ Object
- #write_agent_files ⇒ Object
- #write_skill_file ⇒ Object
Instance Method Details
#configure_stimulus_loading ⇒ Object
Switches Stimulus to on-demand loading instead of documenting it.
Rails' default is eagerLoadControllersFrom("controllers", application),
which imports every controller in the importmap on every page. Because
pin_all_from "app/javascript/controllers" is recursive it also covers
app/javascript/controllers/senren, so a static page paid for every
interactive component the app had installed.
This was a README instruction the developer had to follow by hand, and a "PASS" in bin/performance that only grepped that README. An instruction nobody runs is not a feature.
It uses the official stimulus-loading helper rather than a Senren-specific loader, and therefore changes loading for the app's own controllers too. That is the trade the README already asked for; the generator only acts when the file still carries the untouched Rails default, and says so.
57 58 59 60 |
# File 'lib/generators/senren/install/install_generator.rb', line 57 def configure_stimulus_loading enable_lazy_controller_loading disable_controller_preloading end |
#copy_base_files ⇒ Object
30 31 32 33 34 35 |
# File 'lib/generators/senren/install/install_generator.rb', line 30 def copy_base_files template 'base_component.rb.tt', 'app/components/senren/base_component.rb' template 'senren.css.tt', 'app/assets/stylesheets/senren.css' template 'conventions.md.tt', '.senren/conventions.md' template 'installed_components.yml.tt', '.senren/installed_components.yml' end |
#create_assets_dir ⇒ Object
26 27 28 |
# File 'lib/generators/senren/install/install_generator.rb', line 26 def create_assets_dir empty_directory 'app/assets/stylesheets' end |
#create_components_dir ⇒ Object
18 19 20 |
# File 'lib/generators/senren/install/install_generator.rb', line 18 def create_components_dir empty_directory 'app/components/senren' end |
#create_senren_dir ⇒ Object
14 15 16 |
# File 'lib/generators/senren/install/install_generator.rb', line 14 def create_senren_dir empty_directory '.senren' end |
#create_stimulus_dir ⇒ Object
22 23 24 |
# File 'lib/generators/senren/install/install_generator.rb', line 22 def create_stimulus_dir empty_directory 'app/javascript/controllers/senren' end |
#mirror_registry ⇒ Object
37 38 39 |
# File 'lib/generators/senren/install/install_generator.rb', line 37 def mirror_registry copy_file Senren::Rails.registry_path, '.senren/registry.yml' end |
#print_next_steps ⇒ Object
72 73 74 75 76 |
# File 'lib/generators/senren/install/install_generator.rb', line 72 def print_next_steps say "\nSenren installed." say 'Next: bin/rails senren:add button card badge alert dialog' say 'Then: bin/rails senren:agents:sync' end |
#write_agent_files ⇒ Object
67 68 69 70 |
# File 'lib/generators/senren/install/install_generator.rb', line 67 def write_agent_files say_status :senren, 'syncing Codex/Cursor/Claude/Copilot instruction files' Senren::Rails::AgentRulesWriter.new(paths: host_paths).sync! end |
#write_skill_file ⇒ Object
62 63 64 65 |
# File 'lib/generators/senren/install/install_generator.rb', line 62 def write_skill_file say_status :senren, 'writing .senren/skill.md' Senren::Rails::SkillWriter.new(paths: host_paths).sync! end |