Class: ActiveCanvas::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- ActiveCanvas::Generators::InstallGenerator
- Defined in:
- lib/generators/active_canvas/install/install_generator.rb
Instance Method Summary collapse
- #choose_css_framework ⇒ Object
- #configure_ai_features ⇒ Object
- #create_initializer ⇒ Object
- #install_migrations ⇒ Object
- #mount_engine ⇒ Object
- #show_completion ⇒ Object
- #sync_ai_models ⇒ Object
- #welcome ⇒ Object
Instance Method Details
#choose_css_framework ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/generators/active_canvas/install/install_generator.rb', line 38 def choose_css_framework say "Step 2: CSS Framework", :yellow say "-" * 40 say "Choose which framework to use in the editor and public pages:" say "" say " 1. tailwind - Tailwind CSS (recommended)" say " 2. bootstrap - Bootstrap 5" say " 3. none - No framework" say "" framework = ask("Enter choice [tailwind]:") framework = "tailwind" if framework.blank? framework = framework.downcase.strip @css_framework = case framework when "tailwind", "1" then :tailwind when "bootstrap", "2" then :bootstrap5 when "none", "3" then :none else :tailwind end if @css_framework == :tailwind setup_tailwind elsif @css_framework == :bootstrap5 setup_bootstrap else say "→ No framework selected. You can change this in Admin > Settings.", :yellow end say "" end |
#configure_ai_features ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/generators/active_canvas/install/install_generator.rb', line 69 def configure_ai_features say "Step 3: AI Features", :yellow say "-" * 40 say "ActiveCanvas includes AI-powered features:" say " • Text/HTML generation from prompts" say " • Image generation (DALL-E)" say " • Screenshot to code conversion" say "" say "Supported providers:", :cyan say " • OpenAI (GPT-4, DALL-E) - recommended" say " • Anthropic (Claude)" say " • OpenRouter (access to many models)" say "" @setup_ai = yes_no?("Configure AI API keys now?", default: true) if @setup_ai configure_ai_keys else say "→ Add API keys later in Admin > Settings > AI", :yellow end say "" end |
#create_initializer ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/generators/active_canvas/install/install_generator.rb', line 93 def create_initializer say "Step 4: Configuration", :yellow say "-" * 40 @mount_path = ask("Mount path [/canvas]:") @mount_path = "/canvas" if @mount_path.blank? @mount_path = "/#{@mount_path}" unless @mount_path.start_with?("/") template "initializer.rb", "config/initializers/active_canvas.rb" say "✓ Created config/initializers/active_canvas.rb", :green say "" end |
#install_migrations ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/generators/active_canvas/install/install_generator.rb', line 18 def install_migrations say "Step 1: Database Migrations", :yellow say "-" * 40 if yes_no?("Copy ActiveCanvas migrations to your app?", default: true) rake "active_canvas:install:migrations" say "✓ Migrations copied", :green if yes_no?("Run migrations now?", default: true) rake "db:migrate" say "✓ Migrations completed", :green else say "→ Remember to run: bin/rails db:migrate", :yellow end else say "→ Skipped. Run later: bin/rails active_canvas:install:migrations", :yellow end say "" end |
#mount_engine ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/generators/active_canvas/install/install_generator.rb', line 106 def mount_engine say "Step 5: Routes", :yellow say "-" * 40 routes_file = "config/routes.rb" if File.read(routes_file).include?("ActiveCanvas::Engine") say "✓ ActiveCanvas::Engine already mounted", :green else route "mount ActiveCanvas::Engine => '#{@mount_path}'" say "✓ Mounted ActiveCanvas at #{@mount_path}", :green end say "" end |
#show_completion ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/generators/active_canvas/install/install_generator.rb', line 130 def show_completion say "=" * 60, :green say " Setup Complete!", :green say "=" * 60, :green say "" say "Next steps:", :yellow say "" say " 1. Start your Rails server:" say " $ bin/rails server", :cyan say "" say " 2. Visit the admin panel:" say " http://localhost:3000#{@mount_path}/admin", :cyan say "" say " 3. Configure authentication in:" say " config/initializers/active_canvas.rb", :cyan say "" if @css_framework && @css_framework != :none say " 4. Your CSS framework (#{@css_framework}) is configured." say " It will be loaded automatically in the editor.", :cyan say "" end unless @setup_ai say " 5. Add AI API keys in Admin > Settings > AI", :cyan say " Or via environment variables / Rails credentials", :cyan say "" end say "Documentation: https://github.com/giovapanasiti/active_canvas" say "" end |
#sync_ai_models ⇒ Object
120 121 122 123 124 125 126 127 128 |
# File 'lib/generators/active_canvas/install/install_generator.rb', line 120 def sync_ai_models if @setup_ai && yes_no?("Sync AI models now? (requires API keys in ENV)", default: false) say "" say "Syncing AI models...", :cyan rake "active_canvas:sync_models" say "✓ AI models synced", :green end say "" end |
#welcome ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/generators/active_canvas/install/install_generator.rb', line 8 def welcome say "" say "=" * 60, :cyan say " Welcome to ActiveCanvas Setup Wizard", :cyan say "=" * 60, :cyan say "" say "This wizard will help you set up ActiveCanvas in your Rails app." say "" end |