Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Move Spree installer to the `spree` gem, remove auto admin/storefront… (#13480)

Damian Legawiece6e85e6761cf
diff --git a/admin/Gemfile b/admin/Gemfile
index 37f9657eb7..159819f9d1 100644
--- a/admin/Gemfile
+++ b/admin/Gemfile
@@ -1,7 +1,6 @@
eval_gemfile('../common_spree_dependencies.rb')
-gem 'spree_core', path: '../core'
-gem 'spree_api', path: '../api'
+gem 'spree', path: '../'
gem 'spree_emails', path: '../emails'
gem 'sprockets-rails', '>= 3.5.2'
diff --git a/admin/lib/spree/admin.rb b/admin/lib/spree/admin.rb
index a204be7090..7f3aa8ee8c 100644
--- a/admin/lib/spree/admin.rb
+++ b/admin/lib/spree/admin.rb
@@ -1,5 +1,4 @@
-require 'spree_core'
-require 'spree_api'
+require 'spree'
require 'active_link_to'
require 'breadcrumbs_on_rails'
diff --git a/admin/spree_admin.gemspec b/admin/spree_admin.gemspec
index a048bea0f2..41e1106ac7 100644
--- a/admin/spree_admin.gemspec
+++ b/admin/spree_admin.gemspec
@@ -25,8 +25,7 @@ Gem::Specification.new do |s|
s.files = Dir["{app,config,db,lib,vendor}/**/*", "LICENSE.md", "Rakefile", "README.md"].reject { |f| f.match(/^spec/) && !f.match(/^spec\/fixtures/) }
s.require_path = 'lib'
- s.add_dependency 'spree_core', ">= #{s.version}"
- s.add_dependency 'spree_api', ">= #{s.version}"
+ s.add_dependency 'spree', ">= #{s.version}"
s.add_dependency 'active_link_to'
s.add_dependency 'breadcrumbs_on_rails', '~> 4.1'
diff --git a/cli/lib/generators/spree_cli/install/install_generator.rb b/cli/lib/generators/spree_cli/install/install_generator.rb
new file mode 100644
index 0000000000..0bfa417def
--- /dev/null
+++ b/cli/lib/generators/spree_cli/install/install_generator.rb
@@ -0,0 +1,25 @@
+require 'rails/generators'
+
+module SpreeCli
+ module Generators
+ class InstallGenerator < Rails::Generators::Base
+ source_root File.expand_path('templates', __dir__)
+
+ desc 'Installs Spree CLI binstub into your application'
+
+ def create_binstub
+ template 'bin/spree', 'bin/spree'
+ chmod 'bin/spree', 0o755
+ end
+
+ def show_post_install_message
+ say_status :installed, 'bin/spree'
+ say ''
+ say 'You can now run Spree CLI commands using:'
+ say ' bin/spree version'
+ say ' bin/spree extension my_extension'
+ say ''
+ end
+ end
+ end
+end
diff --git a/cli/lib/generators/spree_cli/install/templates/bin/spree b/cli/lib/generators/spree_cli/install/templates/bin/spree
new file mode 100644
index 0000000000..26bcb1a7c4
--- /dev/null
+++ b/cli/lib/generators/spree_cli/install/templates/bin/spree
@@ -0,0 +1,10 @@
+#!/usr/bin/env ruby
+# frozen_string_literal: true
+
+#
+# This file was generated by the `bin/rails g spree_cli:install` command.
+# It loads your application's bundled version of spree_cli.
+#
+
+require 'bundler/setup'
+require 'spree_cli'
diff --git a/cli/lib/spree_cli/templates/extension/lib/%file_name%.rb.tt b/cli/lib/spree_cli/templates/extension/lib/%file_name%.rb.tt
index 0de393260e..eb3047a114 100644
--- a/cli/lib/spree_cli/templates/extension/lib/%file_name%.rb.tt
+++ b/cli/lib/spree_cli/templates/extension/lib/%file_name%.rb.tt
@@ -1,4 +1,4 @@
-require 'spree_core'
+require 'spree'
require 'spree_extension'
require '<%=file_name%>/engine'
require '<%=file_name%>/version'
diff --git a/core/lib/spree/testing_support/common_rake.rb b/core/lib/spree/testing_support/common_rake.rb
index 3002fd9a2c..e7244d5e70 100644
--- a/core/lib/spree/testing_support/common_rake.rb
+++ b/core/lib/spree/testing_support/common_rake.rb
@@ -1,7 +1,3 @@
-unless defined?(Spree::InstallGenerator)
- require 'generators/spree/install/install_generator'
-end
-
require 'generators/spree/dummy/dummy_generator'
require 'generators/spree/dummy_model/dummy_model_generator'
@@ -61,19 +57,34 @@ namespace :common do
system('rm -rf spec') # we need to cleanup factories created by devise to avoid naming conflict
end
- Spree::InstallGenerator.start [
- "--lib_name=#{ENV['LIB_NAME']}",
- '--auto-accept',
- '--force',
- '--migrate=false',
- '--seed=false',
- '--sample=false',
- "--install_storefront=#{args[:install_storefront]}",
- "--install_admin=#{args[:install_admin]}",
- "--user_class=#{args[:user_class]}",
- "--admin_user_class=#{args[:admin_user_class]}",
- "--authentication=#{args[:authentication]}"
- ]
+ # Run core Spree install generator
+ puts 'Running Spree install generator...'
+ system("bundle exec rails g spree:install --force --auto-accept --migrate=false --seed=false --sample=false --user_class=#{args[:user_class]} --admin_user_class=#{args[:admin_user_class]} --authentication=#{args[:authentication]}")
+
+ # Determine if we need to install admin/storefront
+ # Either via explicit flag or because we're testing that gem itself
+ needs_admin = install_admin || ENV['LIB_NAME'] == 'spree/admin'
+ needs_storefront = install_storefront || ENV['LIB_NAME'] == 'spree/storefront'
+
+ # Run admin install generator if requested or testing admin gem
+ if needs_admin
+ # Only run install if explicitly requested (not when testing admin gem itself)
+ if install_admin
+ puts 'Running Spree Admin install generator...'
+ system('bundle exec rails g spree:admin:install --force')
+ end
+ system('bundle exec rails g spree:admin:devise --force') if args[:authentication] == 'devise'
+ end
+
+ # Run storefront install generator if requested or testing storefront gem
+ if needs_storefront
+ # Only run install if explicitly requested (not when testing storefront gem itself)
+ if install_storefront
+ puts 'Running Spree Storefront install generator...'
+ system('bundle exec rails g spree:storefront:install --force --migrate=false')
+ end
+ system('bundle exec rails g spree:storefront:devise --force') if args[:authentication] == 'devise'
+ end
unless ENV['NO_MIGRATE']
puts 'Setting up dummy database...'
diff --git a/docs/developer/advanced/adding_spree_to_rails_app.mdx b/docs/developer/advanced/adding_spree_to_rails_app.mdx
index 31e5444cb5..4c3638c1b4 100644
--- a/docs/developer/advanced/adding_spree_to_rails_app.mdx
+++ b/docs/developer/advanced/adding_spree_to_rails_app.mdx
@@ -11,87 +11,96 @@ description: This guide will show you how to add Spree to an existing Ruby on Ra
If you already have a Ruby on Rails application, you can add Spree to it by following these steps.
-## 1. Installing Spree
+## 1. Add Spree gems
-<AccordionGroup>
- <Accordion icon="gem" title="Add Spree gems">
- Add these lines to your project `Gemfile`:
+Add these lines to your project `Gemfile`:
- ```ruby
- spree_opts = { 'github': 'spree/spree', 'branch': 'main' }
- gem 'spree', spree_opts # core and API
- gem 'spree_admin', spree_opts # Admin panel (optional)
- gem 'spree_storefront', spree_opts # Storefront (optional)
- gem 'spree_emails', spree_opts # transactional emails (optional)
- gem 'spree_sample', spree_opts # dummy data like products, taxons, etc (optional)
- ```
+```ruby
+spree_opts = { 'github': 'spree/spree', 'branch': 'main' }
+gem 'spree', spree_opts # core, API, and CLI
+gem 'spree_admin', spree_opts # Admin panel (optional)
+gem 'spree_storefront', spree_opts # Storefront (optional)
+gem 'spree_emails', spree_opts # transactional emails (optional)
+gem 'spree_sample', spree_opts # dummy data like products, taxons, etc (optional)
+```
- And run the following command to install the gems:
+And run the following command to install the gems:
- ```bash
- bundle install
- ```
- </Accordion>
+```bash
+bundle install
+```
- <Accordion icon="terminal" title="Run the install generator">
- These commands will run generators which will perform operations required for Spree to work properly.
+## 2. Run the install generators
- ```bash
- bin/rails g spree:install --user_class=Spree::User --install_admin=true --install_storefront=true --authentication=devise
- ```
+Spree uses a modular installation approach. First install the core, then add optional components.
- ### Installation options
+### Install core Spree
- * `user_class`: The class that you want to use for your users, eg. `Spree::User` or `User`. This class needs to be present in your application.
- * `authentication`: The authentication gem to use, eg. `devise` or `custom`. Custom will require you to provide your own authentication code.
- * `install_admin`: Whether to install the Admin Panel.
- * `install_storefront`: Whether to install the Storefront.
- * `migrate`: Whether to run migrations.
- * `sample`: Whether to add sample data (products, taxons, etc).
- * `seed`: Whether to run the seed file.
- * `admin_email`: The email of the (first) admin user.
- * `admin_password`: The password of the (first) admin user.
+This installs core models, API, CLI, and authentication:
- </Accordion>
+```bash
+bin/rails g spree:install --user_class=Spree::User --authentication=devise
+```
- <Accordion icon="box" title="Adding sample data">
+**Core installation options:**
- To add sample data to your store, run:
+| Option | Description |
+|--------|-------------|
+| `user_class` | The class for your users, eg. `Spree::User` or `User` |
+| `admin_user_class` | The class for admin users (defaults to `user_class`) |
+| `authentication` | Authentication gem: `devise` or `custom` |
+| `migrate` | Whether to run migrations (default: true) |
+| `seed` | Whether to run the seed file (default: true) |
+| `sample` | Whether to add sample data (default: false) |
+| `admin_email` | Email of the first admin user |
+| `admin_password` | Password of the first admin user |
- ```bash
- bin/rake spree_sample:load
- ```
+### Install Admin Panel (optional)
- This will add a some products, categories, and will setup a checkout flow to your store.
- </Accordion>
-</AccordionGroup>
+```bash
+bin/rails g spree:admin:install
+bin/rails g spree:admin:devise # if using Devise authentication
+```
-## 3. Exploring Your Store
+### Install Storefront (optional)
+
+```bash
+bin/rails g spree:storefront:install
+bin/rails g spree:storefront:devise # if using Devise authentication
+```
+
+## 3. Add sample data (optional)
+
+To add sample data to your store, run:
+
+```bash
+bin/rake spree_sample:load
+```
+
+This will add some products, categories, and will setup a checkout flow to your store.
+
+## 4. Exploring Your Store
Feel free to explore your store. You can do so because Spree comes with a default pre-built Storefront and Admin Panel.
-<AccordionGroup>
- <Accordion icon="key" title="Logging into the Admin Dashboard">
- Use your browser window to navigate to [http://localhost:3000/admin](http://localhost:3000/admin). You can log in with the default credentials:
- - login: `[email protected]`
- - password: `spree123`
+### Logging into the Admin Dashboard
+
+Use your browser window to navigate to [http://localhost:3000/admin](http://localhost:3000/admin). You can log in with the default credentials:
+ - login: `[email protected]`
+ - password: `spree123`
+
+Upon successful authentication, you should see the admin screen:
- Upon successful authentication, you should see the admin screen:
+![](https://vendo-production-res.cloudinary.com/image/upload/v1740668008/docs/admin_dashboard.png)
- ![](https://vendo-production-res.cloudinary.com/image/upload/v1740668008/docs/admin_dashboard.png)
+Feel free to explore some of the Admin Panel features that Spree has to offer and to verify that your installation is working properly.
- Feel free to explore some of the Admin Panel features that Spree has to offer and to verify that your installation is working properly.
- </Accordion>
+### Browsing Storefront
- <Accordion icon="palette" title="Browsing Storefront">
-
- Spree comes with a default pre-built Storefront. You can access it by navigating to [http://localhost:3000](http://localhost:3000).
-
- You can later customize this Storefront or choose another one if you prefer Next.js or Vue.js.
+Spree comes with a default pre-built Storefront. You can access it by navigating to [http://localhost:3000](http://localhost:3000).
- </Accordion>
-</AccordionGroup>
+You can later customize this Storefront or choose another one if you prefer Next.js or Vue.js.
-### All Done!
+## All Done!
Congrats! You've set up your Spree Commerce and it's looking amazing! Need support or want to give some feedback? You can join our [community](https://slack.spreecommerce.org/) or drop us an email at [[email protected]](mailto:[email protected]).
diff --git a/emails/Gemfile b/emails/Gemfile
index 169609b1d3..2e9d1966b8 100644
--- a/emails/Gemfile
+++ b/emails/Gemfile
@@ -1,6 +1,6 @@
eval_gemfile('../common_spree_dependencies.rb')
-gem 'spree_core', path: '../core'
+gem 'spree', path: '../'
gem 'sprockets-rails', '>= 3.5.2'
diff --git a/emails/lib/spree/emails.rb b/emails/lib/spree/emails.rb
index d3a4ab75b6..333b7ead23 100644
--- a/emails/lib/spree/emails.rb
+++ b/emails/lib/spree/emails.rb
@@ -1,4 +1,4 @@
-require 'spree/core'
+require 'spree'
module Spree
module Emails
diff --git a/emails/spree_emails.gemspec b/emails/spree_emails.gemspec
index c3752e4427..f1fe975b3d 100644
--- a/emails/spree_emails.gemspec
+++ b/emails/spree_emails.gemspec
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
s.files = Dir["{app,config,db,lib,vendor}/**/*", "LICENSE.md", "Rakefile", "README.md"].reject { |f| f.match(/^spec/) && !f.match(/^spec\/fixtures/) }
s.require_path = 'lib'
- s.add_dependency 'spree_core', ">= #{s.version}"
+ s.add_dependency 'spree', ">= #{s.version}"
s.add_development_dependency 'email_spec', '~> 2.2'
end
diff --git a/core/lib/generators/spree/install/install_generator.rb b/lib/generators/spree/install/install_generator.rb
similarity index 78%
rename from core/lib/generators/spree/install/install_generator.rb
rename to lib/generators/spree/install/install_generator.rb
index 7560ec4581..206e4d4e5b 100644
--- a/core/lib/generators/spree/install/install_generator.rb
+++ b/lib/generators/spree/install/install_generator.rb
@@ -10,21 +10,16 @@ module Spree
class_option :migrate, type: :boolean, default: true, banner: 'Run Spree migrations'
class_option :seed, type: :boolean, default: true, banner: 'load seed data (migrations must be run)'
class_option :sample, type: :boolean, default: false, banner: 'load sample data (migrations must be run)'
- class_option :install_storefront, type: :boolean, default: false, banner: 'installs default rails storefront'
- class_option :install_admin, type: :boolean, default: false, banner: 'installs default rails admin'
class_option :auto_accept, type: :boolean
class_option :user_class, type: :string
class_option :admin_user_class, type: :string
class_option :admin_email, type: :string
class_option :admin_password, type: :string
- class_option :lib_name, type: :string, default: 'spree'
class_option :enforce_available_locales, type: :boolean, default: nil
class_option :authentication, type: :string, default: 'devise'
def self.source_paths
paths = superclass.source_paths
- paths << File.expand_path('../templates', "../../#{__FILE__}")
- paths << File.expand_path('../templates', "../#{__FILE__}")
paths << File.expand_path('templates', __dir__)
paths.flatten
end
@@ -33,8 +28,6 @@ module Spree
@run_migrations = options[:migrate]
@load_seed_data = options[:seed]
@load_sample_data = options[:sample]
- @install_storefront = options[:install_storefront]
- @install_admin = options[:install_admin]
@authentication = options[:authentication]
unless @run_migrations
@@ -47,7 +40,10 @@ module Spree
template 'config/initializers/spree.rb', 'config/initializers/spree.rb'
end
- # Currently we only support devise, in the future we will also add support for default Rails authentication
+ def install_spree_cli
+ generate 'spree_cli:install'
+ end
+
def install_authentication
if @authentication == 'devise'
generate 'spree:authentication:devise'
@@ -56,28 +52,6 @@ module Spree
end
end
- def install_storefront
- if @install_storefront && Spree::Core::Engine.frontend_available?
- generate "spree:storefront:install#{' --force' if options[:force]}"
-
- # generate devise controllers if authentication is devise
- if @authentication == 'devise'
- generate "spree:storefront:devise#{' --force' if options[:force]}"
- end
- end
- end
-
- def install_admin
- if @install_admin && Spree::Core::Engine.admin_available?
- generate "spree:admin:install#{' --force' if options[:force]}"
-
- # generate devise controllers if authentication is devise
- if @authentication == 'devise'
- generate "spree:admin:devise#{' --force' if options[:force]}"
- end
- end
- end
-
def configure_application
application <<-APP.strip_heredoc.indent!(4)
@@ -111,7 +85,6 @@ module Spree
silence_warnings { rake 'action_text:install:migrations' }
silence_warnings { rake 'spree:install:migrations' }
silence_warnings { rake 'spree_api:install:migrations' }
- silence_warnings { rake 'spree_page_builder:install:migrations' } if @install_storefront && Spree::Core::Engine.frontend_available?
end
end
@@ -126,7 +99,7 @@ module Spree
def populate_seed_data
if @load_seed_data
- say_status :loading, 'seed data'
+ say_status :loading, 'seed data'
rake_options = []
rake_options << 'AUTO_ACCEPT=1' if options[:auto_accept]
rake_options << "ADMIN_EMAIL=#{options[:admin_email]}" if options[:admin_email]
diff --git a/core/lib/generators/spree/install/templates/config/initializers/spree.rb b/lib/generators/spree/install/templates/config/initializers/spree.rb
similarity index 100%
rename from core/lib/generators/spree/install/templates/config/initializers/spree.rb
rename to lib/generators/spree/install/templates/config/initializers/spree.rb
diff --git a/lib/spree.rb b/lib/spree.rb
index 034f861b11..ba39dc2c26 100644
--- a/lib/spree.rb
+++ b/lib/spree.rb
@@ -1,2 +1,3 @@
require 'spree_core'
require 'spree_api'
+require 'spree_cli'
diff --git a/page_builder/Gemfile b/page_builder/Gemfile
index a2b29a61e6..f72c22d69e 100644
--- a/page_builder/Gemfile
+++ b/page_builder/Gemfile
@@ -1,7 +1,6 @@
eval_gemfile('../common_spree_dependencies.rb')
-gem 'spree_core', path: '../core'
-gem 'spree_api', path: '../api'
+gem 'spree', path: '../'
gem 'spree_admin', path: '../admin'
gem 'devise'
diff --git a/page_builder/lib/generators/spree/page_builder/install/install_generator.rb b/page_builder/lib/generators/spree/page_builder/install/install_generator.rb
index 2d352c208c..17b8fd36c9 100644
--- a/page_builder/lib/generators/spree/page_builder/install/install_generator.rb
+++ b/page_builder/lib/generators/spree/page_builder/install/install_generator.rb
@@ -11,8 +11,7 @@ module Spree
end
def run_migrations
- run_migrations = options[:migrate] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]'))
- if run_migrations
+ if options[:migrate]
run 'bin/rails db:migrate'
else
puts 'Skipping rails db:migrate, don\'t forget to run it!'
diff --git a/page_builder/lib/spree/page_builder.rb b/page_builder/lib/spree/page_builder.rb
index e639f66275..bc5847a512 100644
--- a/page_builder/lib/spree/page_builder.rb
+++ b/page_builder/lib/spree/page_builder.rb
@@ -1,4 +1,4 @@
-require 'spree_core'
+require 'spree'
require 'spree_admin'
require 'spree/page_builder/engine'
diff --git a/page_builder/spree_page_builder.gemspec b/page_builder/spree_page_builder.gemspec
index 581d0effd3..f4594f9ecd 100644
--- a/page_builder/spree_page_builder.gemspec
+++ b/page_builder/spree_page_builder.gemspec
@@ -23,6 +23,6 @@ Gem::Specification.new do |s|
s.files = Dir["{app,config,db,lib,vendor}/**/*", "LICENSE.md", "Rakefile", "README.md"].reject { |f| f.match(/^spec/) && !f.match(/^spec\/fixtures/) }
s.require_path = 'lib'
- s.add_dependency 'spree_core', ">= #{s.version}"
+ s.add_dependency 'spree', ">= #{s.version}"
s.add_dependency 'spree_admin', ">= #{s.version}"
end
diff --git a/sample/Gemfile b/sample/Gemfile
index 95dc8177c1..bcb6bab621 100644
--- a/sample/Gemfile
+++ b/sample/Gemfile
@@ -1,5 +1,5 @@
eval_gemfile('../common_spree_dependencies.rb')
-gem 'spree_core', path: '../core'
+gem 'spree', path: '../'
gemspec
diff --git a/sample/lib/spree/sample.rb b/sample/lib/spree/sample.rb
index 7012f5ddde..b5e129cdd6 100644
--- a/sample/lib/spree/sample.rb
+++ b/sample/lib/spree/sample.rb
@@ -1,3 +1,5 @@
+require 'spree'
+
module Spree
module Sample
def self.load_sample(file)
diff --git a/sample/lib/spree_sample.rb b/sample/lib/spree_sample.rb
index 683984f811..7b87bfeb41 100644
--- a/sample/lib/spree_sample.rb
+++ b/sample/lib/spree_sample.rb
@@ -1,4 +1,4 @@
-require 'spree_core'
+require 'spree'
require 'spree/sample'
module SpreeSample
diff --git a/sample/spree_sample.gemspec b/sample/spree_sample.gemspec
index b4c82b0842..f78beec214 100644
--- a/sample/spree_sample.gemspec
+++ b/sample/spree_sample.gemspec
@@ -23,6 +23,6 @@ Gem::Specification.new do |s|
s.require_path = 'lib'
s.requirements << 'none'
- s.add_dependency 'spree_core', ">= #{s.version}"
+ s.add_dependency 'spree', ">= #{s.version}"
s.add_dependency 'ffaker', '~> 2.9'
end
diff --git a/storefront/Gemfile b/storefront/Gemfile
index 30b0ebe5b4..5f08db00f2 100644
--- a/storefront/Gemfile
+++ b/storefront/Gemfile
@@ -1,7 +1,6 @@
eval_gemfile('../common_spree_dependencies.rb')
-gem 'spree_core', path: '../core'
-gem 'spree_api', path: '../api'
+gem 'spree', path: '../'
gem 'spree_admin', path: '../admin'
gem 'spree_emails', path: '../emails'
gem 'spree_page_builder', path: '../page_builder'
diff --git a/storefront/Rakefile b/storefront/Rakefile
index 7d8afd7772..969d9b1744 100644
--- a/storefront/Rakefile
+++ b/storefront/Rakefile
@@ -16,6 +16,7 @@ task :test_app do
user_class: 'Spree::User',
admin_user_class: 'Spree::AdminUser',
authentication: 'devise',
+ install_admin: true,
css: true,
javascript: true
)
diff --git a/storefront/lib/generators/spree/storefront/install/install_generator.rb b/storefront/lib/generators/spree/storefront/install/install_generator.rb
index 923c82d085..41cabe8f17 100644
--- a/storefront/lib/generators/spree/storefront/install/install_generator.rb
+++ b/storefront/lib/generators/spree/storefront/install/install_generator.rb
@@ -6,6 +6,8 @@ module Spree
class InstallGenerator < Rails::Generators::Base
desc 'Installs Spree Storefront'
+ class_option :migrate, type: :boolean, default: true, banner: 'Run migrations'
+
def self.source_paths
[
File.expand_path('templates', __dir__),
@@ -14,6 +16,12 @@ module Spree
]
end
+ def install_page_builder
+ say_status :installing, 'page builder'
+ migrate_option = options[:migrate] == false ? ' --migrate=false' : ''
+ generate "spree:page_builder:install --force#{migrate_option}"
+ end
+
def install
empty_directory Rails.root.join('app/assets/tailwind') if Rails.root && !Rails.root.join('app/assets/tailwind').exist?
template 'application.css', 'app/assets/tailwind/application.css', force: options[:force]
@@ -40,8 +48,8 @@ module Spree
append_to_file 'app/assets/config/manifest.js', "\n//= link_tree ../builds" unless File.read('app/assets/config/manifest.js').include?('//= link_tree ../builds')
end
- # remove static robots.txt as we use robots.txt.erb
- remove_file Rails.root.join('public/robots.txt') if Rails.root && Rails.root.join('public/robots.txt').exist?
+ # remove static robots.txt as storefront serves it dynamically via seo#robots
+ remove_file 'public/robots.txt'
end
end
end
diff --git a/storefront/lib/spree/storefront.rb b/storefront/lib/spree/storefront.rb
index 439567c37d..3e5efc36e5 100644
--- a/storefront/lib/spree/storefront.rb
+++ b/storefront/lib/spree/storefront.rb
@@ -1,4 +1,4 @@
-require 'spree_core'
+require 'spree'
require 'spree_page_builder'
require 'active_link_to'
diff --git a/storefront/spree_storefront.gemspec b/storefront/spree_storefront.gemspec
index 01c7c000f6..a75e224d80 100644
--- a/storefront/spree_storefront.gemspec
+++ b/storefront/spree_storefront.gemspec
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
s.files = Dir["{app,config,db,lib,vendor}/**/*", "LICENSE.md", "Rakefile", "README.md"].reject { |f| f.match(/^spec/) && !f.match(/^spec\/fixtures/) }
s.require_path = 'lib'
- s.add_dependency 'spree_core', ">= #{s.version}"
+ s.add_dependency 'spree', ">= #{s.version}"
s.add_dependency 'spree_page_builder', ">= #{s.version}"
s.add_dependency 'active_link_to'
diff --git a/template.rb b/template.rb
index 9cf2fb5e4a..b0367286f6 100644
--- a/template.rb
+++ b/template.rb
@@ -15,8 +15,10 @@ def add_gems
# Core dependencies
gem 'devise'
- # Spree gems - using main branch for latest
+ # Spree gems - core (includes core, api, cli)
gem 'spree', USE_LOCAL_SPREE ? { path: '../' } : { version: SPREE_VERSION }
+
+ # Optional Spree packages
gem 'spree_emails', USE_LOCAL_SPREE ? { path: '../' } : { version: SPREE_VERSION }
gem 'spree_sample', USE_LOCAL_SPREE ? { path: '../' } : { version: SPREE_VERSION }
gem 'spree_admin', USE_LOCAL_SPREE ? { path: '../' } : { version: SPREE_VERSION }
@@ -65,22 +67,46 @@ def setup_auth
end
def install_spree
- say 'Running Spree installer...', :blue
+ say 'Running Spree installer (core, api, cli)...', :blue
+
+ # Run Spree installer with migrations but without seeds - seeds run after all generators complete
+ if VERBOSE
+ rails_command "generate spree:install --force --auto-accept --seed=false --user_class=Spree::User --admin_user_class=Spree::AdminUser --authentication=devise"
+ else
+ run "bin/rails generate spree:install --force --auto-accept --seed=false --user_class=Spree::User --admin_user_class=Spree::AdminUser --authentication=devise >/dev/null 2>&1"
+ end
+end
+
+def install_spree_admin
+ say 'Installing Spree Admin...', :blue
+
+ if VERBOSE
+ rails_command 'generate spree:admin:install --force'
+ rails_command 'generate spree:admin:devise --force'
+ else
+ run 'bin/rails generate spree:admin:install --force >/dev/null 2>&1'
+ run 'bin/rails generate spree:admin:devise --force >/dev/null 2>&1'
+ end
+end
+
+def install_spree_storefront
+ say 'Installing Spree Storefront...', :blue
- # Run Spree installer with all options
if VERBOSE
- rails_command "generate spree:install --auto-accept --user_class=Spree::User --admin_user_class=Spree::AdminUser --authentication=devise --install_storefront=true --install_admin=true --admin_email=#{ADMIN_EMAIL} --admin_password=#{ADMIN_PASSWORD}"
+ rails_command 'generate spree:storefront:install --force'
+ rails_command 'generate spree:storefront:devise --force'
else
- run "bin/rails generate spree:install --auto-accept --user_class=Spree::User --admin_user_class=Spree::AdminUser --authentication=devise --install_storefront=true --install_admin=true --admin_email=#{ADMIN_EMAIL} --admin_password=#{ADMIN_PASSWORD} >/dev/null 2>&1"
+ run 'bin/rails generate spree:storefront:install --force >/dev/null 2>&1'
+ run 'bin/rails generate spree:storefront:devise --force >/dev/null 2>&1'
end
end
def install_spree_dev_tools
say 'Running Spree Dev Tools installer...', :blue
if VERBOSE
- rails_command "generate spree_dev_tools:install"
+ rails_command "generate spree_dev_tools:install --force"
else
- run "bin/rails generate spree_dev_tools:install >/dev/null 2>&1"
+ run "bin/rails generate spree_dev_tools:install --force >/dev/null 2>&1"
end
end
@@ -110,13 +136,13 @@ def setup_procfile
end
end
-def setup_database
- say 'Setting up database...', :blue
+def seed_database
+ say 'Loading seed data...', :blue
if VERBOSE
- rails_command 'db:migrate'
+ rails_command "db:seed AUTO_ACCEPT=1 ADMIN_EMAIL=#{ADMIN_EMAIL} ADMIN_PASSWORD=#{ADMIN_PASSWORD}"
else
- run 'bin/rails db:migrate >/dev/null 2>&1'
+ run "bin/rails db:seed AUTO_ACCEPT=1 ADMIN_EMAIL=#{ADMIN_EMAIL} ADMIN_PASSWORD=#{ADMIN_PASSWORD} >/dev/null 2>&1"
end
end
@@ -151,6 +177,8 @@ def show_success_message
say 'Useful commands:', :yellow
say ' bin/rails console # Rails console'
say ' bin/rails spree_sample:load # Load more sample data'
+ say ' bin/spree version # Spree CLI version'
+ say ' bin/spree extension my_ext # Generate a new Spree extension'
say
end
@@ -162,9 +190,11 @@ after_bundle do
configure_development_environment
setup_auth
install_spree
+ install_spree_admin
+ install_spree_storefront
install_spree_dev_tools
setup_procfile
- setup_database
+ seed_database
load_sample_data
show_success_message
end