#!/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" case $SOLIDUS_BRANCH in v3* | v4.0* | v4.1*) echo "~~> Using a SOLIDUS_BRANCH older than v4.2. Skipping the --admin-preview flag for compatibility." ADMIN_PREVIEW_FLAG=" " ;; *) ADMIN_PREVIEW_FLAG="--admin-preview=false" ;; esac extension_name="super_good-solidus_taxjar" # 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) to the Gemfile" cd ./sandbox cat <> Gemfile gem 'solidus', github: 'solidusio/solidus', branch: '$SOLIDUS_BRANCH' gem 'rails-i18n' gem 'solidus_i18n' gem 'solidus_auth_devise' gem "solidus_frontend" 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 bundle exec rails generate solidus:install \ --auto-accept \ --payment-method=none \ --frontend=none \ ${ADMIN_PREVIEW_FLAG} \ $@ SKIP_SOLIDUS_BOLT=true unbundled bundle exec rails generate solidus_frontend:install --auto-accept unbundled bundle exec rails generate solidus:auth:install --auto-run-migrations unbundled bundle exec rails generate super_good:solidus_taxjar:install --auto-run-migrations echo echo "๐Ÿš€ Sandbox app successfully created for $extension_name!" echo "๐Ÿš€ Using $RAILSDB and Solidus $BRANCH" echo "๐Ÿงช This app is intended for test purposes."