Skip to content
Merged
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
35 changes: 16 additions & 19 deletions lib/solidus_dev_support/templates/extension/bin/sandbox.tt
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,45 @@ test -z "${DEBUG+empty_string}" || set -x

test "$DB" = "sqlite" && export DB="sqlite3"

if [ -z "$SOLIDUS_BRANCH" ]
if [ -z "$PAYMENT_METHOD" ]
then
echo "~~> Use 'export SOLIDUS_BRANCH=[main|v3.2|...]' to control the Solidus branch"
SOLIDUS_BRANCH="main"
PAYMENT_METHOD="none"
fi
echo "~~> Using branch $SOLIDUS_BRANCH of solidus"

if [ -z "$SOLIDUS_FRONTEND" ]
if [ -z "$SOLIDUS_BRANCH" ]
then
echo "~~> Use 'export SOLIDUS_FRONTEND=[solidus_frontend|solidus_starter_frontend]' to control the Solidus frontend"
SOLIDUS_FRONTEND="solidus_frontend"
echo "~~> Use 'export SOLIDUS_BRANCH=[main|v4.0|...]' to control the Solidus branch"
SOLIDUS_BRANCH="main"
fi
echo "~~> Using branch $SOLIDUS_FRONTEND as the solidus frontend"
echo "~~> Using branch $SOLIDUS_BRANCH of solidus"

extension_name="<%= file_name %>"

# Stay away from the bundler env of the containing extension.
function unbundled {
ruby -rbundler -e'b = proc {system *ARGV}; Bundler.respond_to?(:with_unbundled_env) ? Bundler.with_unbundled_env(&b) : Bundler.with_clean_env(&b)' -- $@
ruby -rbundler -e'
Bundler.with_unbundled_env {system *ARGV}' -- \
env BUNDLE_SUPPRESS_INSTALL_USING_MESSAGES=true $@
}

echo "~~~> Removing the old sandbox"
rm -rf ./sandbox
unbundled bundle exec rails new sandbox \

echo "~~~> Creating a pristine Rails app"
rails new sandbox \
--database="${DB:-sqlite3}" \
--skip-bundle \
--skip-git \
--skip-keeps \
--skip-rc \
--skip-spring \
--skip-test \
--skip-javascript
--skip-bootsnap \
--skip-test

if [ ! -d "sandbox" ]; then
echo 'sandbox rails application failed'
exit 1
fi

echo "~~~> Adding solidus (with i18n) to the Gemfile"
cd ./sandbox
cat <<RUBY >> Gemfile
gem 'solidus', github: 'solidusio/solidus', branch: '$SOLIDUS_BRANCH'
Expand All @@ -63,11 +65,6 @@ unbundled bundle exec rake db:drop db:create

unbundled bundle exec rails generate solidus:install \
--auto-accept \
--user_class=Spree::User \
--enforce_available_locales=true \
--with-authentication=<%= file_name != 'solidus_auth_devise' %> \
--payment-method=none \
--frontend=${SOLIDUS_FRONTEND} \
$@

unbundled bundle exec rails generate solidus:auth:install --auto-run-migrations
Expand Down