From b13890885afc663284c6e726dc5d371976c0e7ae Mon Sep 17 00:00:00 2001 From: Elia Schito Date: Thu, 4 May 2023 16:23:50 +0200 Subject: [PATCH] Add solidus_admin to newly generated stores --- admin/config/routes.rb | 1 + .../solidus_admin/install/install_generator.rb | 11 +++++++++++ bin/sandbox | 1 + .../generators/solidus/install/install_generator.rb | 5 +++++ 4 files changed, 18 insertions(+) create mode 100644 admin/lib/generators/solidus_admin/install/install_generator.rb diff --git a/admin/config/routes.rb b/admin/config/routes.rb index 5457c61cb8d..dd703b1dca2 100644 --- a/admin/config/routes.rb +++ b/admin/config/routes.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true SolidusAdmin::Engine.routes.draw do + get '/', to: ->(env) { [200, {}, ['Hello from the new admin!']] } end diff --git a/admin/lib/generators/solidus_admin/install/install_generator.rb b/admin/lib/generators/solidus_admin/install/install_generator.rb new file mode 100644 index 00000000000..0ccbe7cde99 --- /dev/null +++ b/admin/lib/generators/solidus_admin/install/install_generator.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module SolidusAdmin + module Generators + class InstallGenerator < Rails::Generators::Base + def install_solidus_core_support + route "mount SolidusAdmin::Engine, at: '/solidus_admin'" + end + end + end +end diff --git a/bin/sandbox b/bin/sandbox index ebff817bc09..9b11abd9ece 100755 --- a/bin/sandbox +++ b/bin/sandbox @@ -59,6 +59,7 @@ cd ./sandbox cat <> Gemfile gem 'solidus', path: '..' +gem 'solidus_admin', path: '../admin' gem 'rails-i18n' gem 'solidus_i18n' diff --git a/core/lib/generators/solidus/install/install_generator.rb b/core/lib/generators/solidus/install/install_generator.rb index b1e8938cb79..101c2d76756 100644 --- a/core/lib/generators/solidus/install/install_generator.rb +++ b/core/lib/generators/solidus/install/install_generator.rb @@ -133,6 +133,11 @@ def create_database rake 'db:create' end + def install_solidus_admin + bundle_command 'add solidus_admin' unless has_gem?('solidus_admin') + generate 'solidus_admin:install' + end + def install_routes if Pathname(app_path).join('config', 'routes.rb').read.include? CORE_MOUNT_ROUTE say_status :route_exist, CORE_MOUNT_ROUTE, :blue