Skip to content

Commit

Permalink
Copy sandbox script from SolidusPaypalCommercePlatform
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmendoza committed Feb 15, 2023
1 parent 8754ff8 commit ae77f76
Showing 1 changed file with 20 additions and 62 deletions.
82 changes: 20 additions & 62 deletions bin/sandbox
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#!/usr/bin/env bash

set -e
if [ -n "$DEBUG" ]
then
set -x
fi

case "$DB" in
postgres|postgresql)
Expand All @@ -13,91 +9,53 @@ postgres|postgresql)
mysql)
RAILSDB="mysql"
;;
sqlite3|sqlite)
RAILSDB="sqlite3"
;;
'')
echo "~~> Use 'export DB=[postgres|mysql|sqlite]' to control the DB adapter"
sqlite|'')
RAILSDB="sqlite3"
;;
*)
echo "Invalid value specified for the Solidus sandbox: DB=\"$DB\"."
echo "Please use 'postgres', 'mysql', or 'sqlite' instead."
echo "Invalid DB specified: $DB"
exit 1
;;
esac
echo "~~> Using $RAILSDB as the database engine"

if [ -z "$SOLIDUS_BRANCH" ]
then
echo "~~> Use 'export SOLIDUS_BRANCH=[master|v3.2|...]' to control the Solidus branch"
SOLIDUS_BRANCH="master"
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"
BRANCH=$SOLIDUS_BRANCH
else
BRANCH="master"
fi
echo "~~> Using branch $SOLIDUS_FRONTEND as the solidus frontend"

extension_name="solidus_braintree"

# 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'b = proc {system *ARGV}; Bundler.respond_to?(:with_unbundled_env) ? Bundler.with_unbundled_env(&b) : Bundler.with_clean_env(&b)' -- "$@"
}

rm -rf ./sandbox
unbundled bundle exec rails new sandbox --database="$RAILSDB" \
--skip-bundle \
rails new sandbox \
--database="$RAILSDB" \
--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

cd ./sandbox
cat <<RUBY >> Gemfile
gem 'solidus', github: 'solidusio/solidus', branch: '$SOLIDUS_BRANCH'
gem 'rails-i18n'
gem 'solidus_i18n'
# This Braintree extension contains a user decorator, so the user class must be loaded first.
gem "solidus_auth_devise", "~> 2.5"
gem '$extension_name', path: '..'
group :test, :development do
platforms :mri do
gem 'pry-byebug'
end
end
RUBY

unbundled bundle install --gemfile Gemfile

unbundled bundle add solidus --github solidusio/solidus --branch "${BRANCH:-master}" --version '> 0.a'
unbundled bundle exec rake db:drop db:create

# Still request "devise". Solidus will skip installing it again but will include its seeds.
unbundled bundle exec rails generate solidus:install \
--auto-accept \
--user_class=Spree::User \
--enforce_available_locales=true \
--authentication="devise" \
--payment-method=none \
--frontend=${SOLIDUS_FRONTEND} \
$@

unbundled bundle exec rails generate solidus:auth:install --auto-run-migrations
unbundled bundle exec rails generate ${extension_name}:install --auto-run-migrations
unbundled bundle exec rails generate solidus:install --payment-method=none --auto-accept "$@"
unbundled bundle add ${extension_name} --path '../'
unbundled bundle exec rails generate ${extension_name}:install --frontend=starter --migrate=true

echo
echo "πŸš€ Sandbox app successfully created for $extension_name!"
echo "πŸ§ͺ This app is intended for test purposes."
echo "πŸš€ Sandbox app successfully created for ${extension_name}!"
echo "πŸš€ Using $RAILSDB and Solidus $BRANCH"
echo "πŸš€ Use 'export DB=[postgres|mysql|sqlite]' to control the DB adapter"
echo "πŸš€ Use 'export SOLIDUS_BRANCH=<BRANCH-NAME>' to control the Solidus version"
echo "πŸš€ This app is intended for test purposes."

0 comments on commit ae77f76

Please sign in to comment.