Sha256: df1536e4009ca46ba7f7378d4ffc3e19508cbccbe7e36efa7ac5943b937f8cbd

Contents?: true

Size: 1.41 KB

Versions: 53

Compression:

Stored size: 1.41 KB

Contents

require 'rails/generators'

module ForestLiana
  class InstallGenerator < Rails::Generators::Base
    desc 'Forest Rails Liana installation generator'

    argument :env_secret, type: :string, required: true, desc: 'required', banner: 'env_secret'

    def install
      route "mount ForestLiana::Engine => '/forest'"

      initializer 'forest_liana.rb' do
        "ForestLiana.env_secret = Rails.application.secrets.forest_env_secret" +
        "\nForestLiana.auth_secret = Rails.application.secrets.forest_auth_secret"
      end

      auth_secret = SecureRandom.urlsafe_base64

      puts "\nForest generated a random authentication secret to secure the " +
        "data access of your local project.\nYou can change it at any time in " +
        "your config/secrets.yml file.\n\n"

      inject_into_file 'config/secrets.yml', after: "development:" do
        "\n  forest_env_secret: #{env_secret}" +
        "\n  forest_auth_secret: #{auth_secret}"
      end

      inject_into_file 'config/secrets.yml', after: "staging:", force: true do
        "\n  forest_env_secret: <%= ENV[\"FOREST_ENV_SECRET\"] %>" +
        "\n  forest_auth_secret: <%= ENV[\"FOREST_AUTH_SECRET\"] %>"
      end

      inject_into_file 'config/secrets.yml', after: "production:", force: true do
        "\n  forest_env_secret: <%= ENV[\"FOREST_ENV_SECRET\"] %>" +
        "\n  forest_auth_secret: <%= ENV[\"FOREST_AUTH_SECRET\"] %>"
      end
    end
  end
end

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
forest_liana-1.7.9 lib/generators/forest_liana/install_generator.rb
forest_liana-1.7.8 lib/generators/forest_liana/install_generator.rb
forest_liana-1.7.7 lib/generators/forest_liana/install_generator.rb
forest_liana-1.7.6 lib/generators/forest_liana/install_generator.rb
forest_liana-1.7.5 lib/generators/forest_liana/install_generator.rb
forest_liana-1.7.4 lib/generators/forest_liana/install_generator.rb
forest_liana-1.7.3 lib/generators/forest_liana/install_generator.rb
forest_liana-1.7.2 lib/generators/forest_liana/install_generator.rb
forest_liana-1.7.1 lib/generators/forest_liana/install_generator.rb
forest_liana-1.7.0 lib/generators/forest_liana/install_generator.rb
forest_liana-1.6.17 lib/generators/forest_liana/install_generator.rb
forest_liana-1.6.16 lib/generators/forest_liana/install_generator.rb
forest_liana-1.6.15 lib/generators/forest_liana/install_generator.rb
forest_liana-1.6.14 lib/generators/forest_liana/install_generator.rb
forest_liana-1.6.13 lib/generators/forest_liana/install_generator.rb
forest_liana-1.6.12 lib/generators/forest_liana/install_generator.rb
forest_liana-1.6.11 lib/generators/forest_liana/install_generator.rb
forest_liana-1.6.10 lib/generators/forest_liana/install_generator.rb
forest_liana-1.6.7 lib/generators/forest_liana/install_generator.rb
forest_liana-1.6.6 lib/generators/forest_liana/install_generator.rb