Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix installation method as a gem executable #162

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,39 @@ class SolidusStarterFrontendGenerator < Rails::Generators::Base

def install
# Copy directories
directory 'app', 'app'
directory 'lib/views', 'lib/views'
directory 'app', 'app', exclude_pattern: /auth_views/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why we need this part: exclude_pattern: /auth_views/. There is no auth_views folder in the app directory, isn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because of this file:

https://github.com/nebulab/solidus_starter_frontend/blob/waiting-for-dev/fix_executable_installation/app/controllers/concerns/solidus_starter_frontend/auth_views.rb

We don't need it, thanks to your suggestion to add the views directly into the application. However, it crashes because of Engine not being within the namespace if we copy it.

directory 'lib/views/auth', 'app/views'

# Copy files
copy_file 'lib/solidus_starter_frontend_configuration.rb', 'lib/solidus_starter_frontend_configuration.rb'
copy_file 'lib/solidus_starter_frontend/config.rb', 'lib/solidus_starter_frontend/config.rb'
copy_file 'lib/solidus_starter_frontend/solidus_support_extensions.rb', 'lib/solidus_starter_frontend/solidus_support_extensions.rb'

# Initializer
initializer 'solidus_starter_frontend.rb' do
"require 'solidus_starter_frontend/solidus_support_extensions'"
end

# Routes
copy_file 'config/routes.rb', 'tmp/routes.rb'
prepend_file 'config/routes.rb', File.read('tmp/routes.rb')

# Enable Solidus frontend
application do
<<~RUBY
config.x.solidus.frontend_available = true
config.to_prepare do
if defined?(Spree::Auth::Engine)
[
Spree::UserConfirmationsController,
Spree::UserPasswordsController,
Spree::UserRegistrationsController,
Spree::UserSessionsController,
Spree::UsersController
].each do |auth_controller|
auth_controller.include SolidusStarterFrontend::Taxonomies
end
end
end
RUBY
end

# Gems
gem 'canonical-rails'
gem 'solidus_support'
gem 'truncate_html'

# Text updates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module SolidusStarterFrontend
module Views
class OverrideGenerator < ::Rails::Generators::Base
def self.views_folder
Engine.root.join('app', 'views', 'spree')
Rails.root.join('app', 'views', 'spree')
end

VIEWS = Dir.glob(views_folder.join('**', '*'))
Expand Down
1 change: 0 additions & 1 deletion lib/solidus_starter_frontend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
require 'solidus_core'
require 'solidus_support'

require 'solidus_starter_frontend/solidus_support_extensions'
require 'solidus_starter_frontend/version'
require 'solidus_starter_frontend/config'
require 'solidus_starter_frontend/engine'
4 changes: 4 additions & 0 deletions lib/solidus_starter_frontend/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ class Engine < Rails::Engine

engine_name 'solidus_starter_frontend'

initializer 'solidus_starter_frontend', before: 'solidus_support_frontend_paths' do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to add solidus_support_frontend_paths here?

Copy link
Contributor Author

@waiting-for-dev waiting-for-dev Jun 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, for now, it's added on my fork https://github.com/waiting-for-dev/solidus_support/blob/bcda06b7ff436018b5a3eb2588ca55a7128a7d5a/lib/solidus_support/engine_extensions.rb#L85. For now, you need to manually add it to the Gemfile if you want to test this branch.

Rails.configuration.x.solidus.frontend_available = true
end

# use rspec for tests
config.generators do |g|
g.test_framework :rspec
Expand Down
9 changes: 0 additions & 9 deletions lib/solidus_starter_frontend/solidus_support_extensions.rb

This file was deleted.