#!/usr/bin/env bash set -e test -z "${DEBUG+empty_string}" || set -x test "$DB" = "sqlite" && export DB="sqlite3" if [ -z "$PAYMENT_METHOD" ] then PAYMENT_METHOD="none" fi if [ -z "$SOLIDUS_BRANCH" ] then echo "~~> Use 'export SOLIDUS_BRANCH=[main|v4.0|...]' to control the Solidus branch" SOLIDUS_BRANCH="main" fi echo "~~> Using branch $SOLIDUS_BRANCH of solidus" extension_name="solidus_friendly_promotions" # Stay away from the bundler env of the containing extension. function unbundled { ruby -rbundler -e' Bundler.with_unbundled_env {system *ARGV}' -- \ env BUNDLE_SUPPRESS_INSTALL_USING_MESSAGES=true $@ } echo "~~~> Removing the old sandbox" rm -rf ./sandbox echo "~~~> Creating a pristine Rails app" rails new sandbox \ --database="${DB:-sqlite3}" \ --skip-git \ --skip-keeps \ --skip-rc \ --skip-bootsnap \ --skip-test if [ ! -d "sandbox" ]; then echo 'sandbox rails application failed' exit 1 fi echo "~~~> Adding solidus (with i18n and authentication) and your gem to the Gemfile" cd ./sandbox cat <> Gemfile gem 'solidus', github: 'solidusio/solidus', branch: '$SOLIDUS_BRANCH' gem 'rails-i18n' gem 'solidus_i18n' gem '$extension_name', path: '..' group :test, :development do platforms :mri do gem 'pry-byebug' end end RUBY unbundled bundle install --gemfile Gemfile unbundled bundle exec rake db:drop db:create unbundled bin/rails generate solidus:install \ --auto-accept \ --admin_preview=false \ $@ unbundled bundle exec rails generate solidus:auth:install --auto-run-migrations unbundled bundle exec rails generate ${extension_name}:install --auto-run-migrations echo echo "๐Ÿš€ Sandbox app successfully created for $extension_name!" echo "๐Ÿงช This app is intended for test purposes."