Skip to content

Commit

Permalink
Discourage SolidusStarterFrontend from being run as an engine
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmendoza committed Jul 13, 2021
1 parent 08ad480 commit cfc6371
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

require 'solidus_dev_support/rake_tasks'

ENV['SOLIDUS_STARTER_FRONTEND_ALLOW_AS_ENGINE'] = 'true'
SolidusDevSupport::RakeTasks.install

task default: 'extension:specs'
19 changes: 19 additions & 0 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,19 @@ Note that `solidus_starter_frontend` has conditional references to
`solidus_auth_devise`, so it's important to place `solidus_starter_frontend`
before `solidus_auth_devise`.

#### 3) Enable `SOLIDUS_STARTER_FRONTEND_ALLOW_AS_ENGINE` environment variable

We're strongly encouraging people to use `solidus_starter_frontend` as a
generator. Thus, if you want to run it as an engine, you'll need to set an
environment variable explicitly stating so.

One way to do this is to set the environment variable within an initializer:

```sh
# config/initializers/solidus_starter_frontend.rb
ENV['SOLIDUS_STARTER_FRONTEND_ALLOW_AS_ENGINE'] = 'true'
```

#### 3) Install Solidus

```sh
Expand All @@ -109,6 +122,12 @@ bundle exec rails generate solidus:auth:install --auto-run-migrations
You will need to run `bundle exec rails g solidus_starter_frontend:install` to add the
frontend assets to the existing vendored Solidus manifest files.

#### 5) Run the server

```sh
rails server
```

### Updating the changelog
Before and after releases the changelog should be updated to reflect the
up-to-date status of the project:
Expand Down
2 changes: 2 additions & 0 deletions lib/solidus_starter_frontend/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class Engine < Rails::Engine
end

config.to_prepare do
raise 'Error: SolidusStarterFrontend is not allowed to run as an engine' unless ENV['SOLIDUS_STARTER_FRONTEND_ALLOW_AS_ENGINE']

if defined?(Spree::Auth::Engine)
[
Spree::UserConfirmationsController,
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# Configure Rails Environment
ENV['RAILS_ENV'] = 'test'
ENV['SOLIDUS_STARTER_FRONTEND_ALLOW_AS_ENGINE'] = 'true'

# Run Coverage report
require 'solidus_dev_support/rspec/coverage'
Expand Down

0 comments on commit cfc6371

Please sign in to comment.