Sha256: 86b9d379d02d6af6d22336818680a0a4f36a7cb68b6942fd3eaf61c701dcbf09

Contents?: true

Size: 1.28 KB

Versions: 7

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

module Maglev
  class InstallGenerator < Rails::Generators::Base
    desc 'Install Maglev engine'
    source_root File.expand_path('templates/install', __dir__)
    hook_for :maglev_install

    def compile_editor_assets
      rake 'maglev:vite:install_dependencies'
      rake 'maglev:vite:build_all'
    end

    def migrations
      rake 'maglev:install:migrations'
      rake 'db:migrate'
    end

    def create_initializer
      directory 'config'
      directory 'public'
    end

    def generate_blank_theme
      generate 'maglev:theme'
    end

    def mount_engine
      inject_into_file 'config/routes.rb', before: /^end/ do
        <<-CODE
  mount Maglev::Engine => '/maglev'
  get '(*path)', to: 'maglev/page_preview#index', defaults: { path: 'index' }, constraints: Maglev::PreviewConstraint.new
        CODE
      end
    end

    def instructions
      $stdout.puts <<~INFO
        Done! 🎉

        You can now tweak /config/initializers/maglev.rb.
        You can also modify your theme (in /app/theme and /app/views/theme)
        and generate new sections with rails g maglev:section.

        👉 The next step is to create a site using `rails maglev:create_site`.

        🚨 Don't forget to do it in production as well!
      INFO
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
maglevcms-1.1.7 lib/generators/maglev/install_generator.rb
maglevcms-1.1.6 lib/generators/maglev/install_generator.rb
maglevcms-1.1.5 lib/generators/maglev/install_generator.rb
maglevcms-1.1.4 lib/generators/maglev/install_generator.rb
maglevcms-1.1.3 lib/generators/maglev/install_generator.rb
maglevcms-1.1.2 lib/generators/maglev/install_generator.rb
maglevcms-1.1.1 lib/generators/maglev/install_generator.rb