Class: Iron::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Iron::Generators::InstallGenerator
- Defined in:
- lib/generators/iron/install/install_generator.rb
Constant Summary collapse
- MOUNT_PATH =
"/admin".freeze
- MOUNT_LINE =
%(mount Iron::Engine => "#{MOUNT_PATH}").freeze
- SEEDS_MARKER =
"# == Iron CMS admin ==".freeze
Instance Method Summary collapse
- #create_schema_skeleton ⇒ Object
- #create_seeds ⇒ Object
- #display_instructions ⇒ Object
- #install_action_text ⇒ Object
- #install_active_storage ⇒ Object
- #install_agent_skill ⇒ Object
- #install_iron_migrations ⇒ Object
- #install_pages ⇒ Object
- #mount_engine ⇒ Object
- #provision_admin ⇒ Object
- #wire_release_step ⇒ Object
Instance Method Details
#create_schema_skeleton ⇒ Object
39 40 41 |
# File 'lib/generators/iron/install/install_generator.rb', line 39 def create_schema_skeleton copy_file "schema.json", "db/cms/schema.json" end |
#create_seeds ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/generators/iron/install/install_generator.rb', line 43 def create_seeds return if seeds_marker_present? if File.exist?(seeds_path) append_to_file "db/seeds.rb", seeds_block else copy_file "seeds.rb", "db/seeds.rb" end end |
#display_instructions ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/generators/iron/install/install_generator.rb', line 72 def display_instructions say "\n=== Iron CMS Installed ===\n", :green say "Created:" say " - config/routes.rb mounts Iron::Engine at #{MOUNT_PATH}" say " - db/cms/schema.json (minimal CMS schema skeleton — edit, then bin/rails iron:schema:apply)" say " - db/seeds.rb provisions the first administrator (run by db:seed)" say " - lib/tasks/iron_release.rake applies the CMS schema during db:prepare" say " - .claude/skills/iron-cms/SKILL.md (the Iron CMS workflow for coding agents)" say " - app/controllers/pages_controller.rb renders published content" say "\nSet IRON_SEED_EMAIL and IRON_SEED_PASSWORD outside local environments, or seeding fails fast." say "\nNext steps:" say "1. Run bin/dev and open http://localhost:3000#{MOUNT_PATH} to sign in." say "2. Deploy with bin/kamal deploy — db:prepare migrates and applies the CMS schema." end |
#install_action_text ⇒ Object
26 27 28 29 30 31 |
# File 'lib/generators/iron/install/install_generator.rb', line 26 def install_action_text return if skip_db_steps? return if migration_present?("create_action_text_tables.action_text.rb") rails_command "action_text:install:migrations", inline: true end |
#install_active_storage ⇒ Object
19 20 21 22 23 24 |
# File 'lib/generators/iron/install/install_generator.rb', line 19 def install_active_storage return if skip_db_steps? return if migration_present?("create_active_storage_tables.active_storage.rb") rails_command "active_storage:install", inline: true end |
#install_agent_skill ⇒ Object
57 58 59 |
# File 'lib/generators/iron/install/install_generator.rb', line 57 def install_agent_skill invoke "iron:agents", [], quiet: true end |
#install_iron_migrations ⇒ Object
33 34 35 36 37 |
# File 'lib/generators/iron/install/install_generator.rb', line 33 def install_iron_migrations return if skip_db_steps? rails_command "iron:install:migrations", inline: true end |
#install_pages ⇒ Object
61 62 63 |
# File 'lib/generators/iron/install/install_generator.rb', line 61 def install_pages invoke "iron:pages", [], quiet: true unless routes_include?("iron_pages") end |
#mount_engine ⇒ Object
15 16 17 |
# File 'lib/generators/iron/install/install_generator.rb', line 15 def mount_engine route MOUNT_LINE unless routes_include?(MOUNT_LINE) end |
#provision_admin ⇒ Object
65 66 67 68 69 70 |
# File 'lib/generators/iron/install/install_generator.rb', line 65 def provision_admin return if skip_db_steps? rails_command "db:prepare", abort_on_failure: true rails_command "db:seed", abort_on_failure: true end |
#wire_release_step ⇒ Object
53 54 55 |
# File 'lib/generators/iron/install/install_generator.rb', line 53 def wire_release_step copy_file "iron_release.rake", "lib/tasks/iron_release.rake" end |