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.

Adds ability to generate Headless Sandbox application

Damian Legawiec85823a999e50
diff --git a/guides/src/content/developer/tutorials/developing_spree.md b/guides/src/content/developer/tutorials/developing_spree.md
index c22caf50bf..7e805ac1cf 100644
--- a/guides/src/content/developer/tutorials/developing_spree.md
+++ b/guides/src/content/developer/tutorials/developing_spree.md
@@ -41,6 +41,30 @@ Create a sandbox Rails application for testing purposes which automatically perf
bundle exec rake sandbox
```
+For headless sandbox please run:
+
+```shell
+SPREE_HEADLESS=true bundle exec rake sandbox
+```
+
+By default Sandbox uses SQLite database. But you can switch to PostgreSQL:
+
+```shell
+DB=postgres bundle exec rake sandbox
+```
+
+or MySQL:
+
+```shell
+DB=mysql bundle exec rake sandbox
+```
+
+You can also combine those options:
+
+```shell
+SPREE_HEADLESS=true DB=postgres bundle exec rake sandbox
+```
+
Start the server
```shell
diff --git a/lib/sandbox.sh b/lib/sandbox.sh
index dabd8363b6..a4f6915fbb 100755
--- a/lib/sandbox.sh
+++ b/lib/sandbox.sh
@@ -50,11 +50,32 @@ else
SPREE_GATEWAY_GEM="gem 'spree_gateway', github: 'spree/spree_gateway', branch: 'master'"
fi
+if [ "$SPREE_HEADLESS" != "" ]; then
cat <<RUBY >> Gemfile
-gem 'spree', path: '..'
+gem 'spree_core', path: '..'
+gem 'spree_api', path: '..'
+gem 'spree_backend', path: '..'
+gem 'spree_sample', path: '..'
+gem 'spree_cmd', path: '..'
+
$SPREE_AUTH_DEVISE_GEM
$SPREE_GATEWAY_GEM
+gem 'spree_i18n', github: 'spree-contrib/spree_i18n', branch: 'master'
+
+group :test, :development do
+ gem 'bullet'
+ gem 'pry-byebug'
+ gem 'awesome_print'
+end
+
+gem 'rack-cache'
+RUBY
+else
+cat <<RUBY >> Gemfile
+gem 'spree', path: '..'
+$SPREE_AUTH_DEVISE_GEM
+$SPREE_GATEWAY_GEM
gem 'spree_i18n', github: 'spree-contrib/spree_i18n', branch: 'master'
gem 'spree_static_content', github: 'spree-contrib/spree_static_content', branch: 'master'
gem 'spree_related_products', github: 'spree-contrib/spree_related_products', branch: 'master'
@@ -69,13 +90,14 @@ end
# ExecJS runtime
gem 'mini_racer'
-gem 'rack-cache'
-
# temporary fix for sassc segfaults on ruby 3.0.0 on Mac OS Big Sur
# this change fixes the issue:
# https://github.com/sass/sassc-ruby/commit/04407faf6fbd400f1c9f72f752395e1dfa5865f7
gem 'sassc', github: 'sass/sassc-ruby', branch: 'master'
+
+gem 'rack-cache'
RUBY
+fi
cat <<RUBY >> config/environments/development.rb
Rails.application.config.hosts << /.*\.lvh\.me/
@@ -88,6 +110,9 @@ bundle exec rails g spree:install --auto-accept --user_class=Spree::User --enfor
bundle exec rails g spree:mailers_preview
bundle exec rails g spree:auth:install
bundle exec rails g spree_gateway:install
-bundle exec rails g spree_related_products:install
-bundle exec rails g spree_static_content:install
-bundle exec rails g spree_multi_domain:install
+
+if [ "$SPREE_HEADLESS" == "" ]; then
+ bundle exec rails g spree_related_products:install
+ bundle exec rails g spree_static_content:install
+ bundle exec rails g spree_multi_domain:install
+fi