Skip to content

Commit

Permalink
update solidus_dev_support setup
Browse files Browse the repository at this point in the history
  • Loading branch information
ccarruitero committed Nov 9, 2022
1 parent 23a21ed commit 06a011b
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 21 deletions.
6 changes: 6 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
version: 2.1

orbs:
# Required for feature specs.
browser-tools: circleci/[email protected]

# Always take the latest version of the orb, this allows us to
# run specs against Solidus supported versions only without the need
# to change this configuration every time a Solidus version is released
Expand All @@ -11,14 +14,17 @@ jobs:
run-specs-with-postgres:
executor: solidusio_extensions/postgres
steps:
- browser-tools/install-browser-tools
- solidusio_extensions/run-tests
run-specs-with-mysql:
executor: solidusio_extensions/mysql
steps:
- browser-tools/install-browser-tools
- solidusio_extensions/run-tests
lint-code:
executor: solidusio_extensions/sqlite-memory
steps:
- browser-tools/install-browser-tools
- solidusio_extensions/lint-code

workflows:
Expand Down
19 changes: 11 additions & 8 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
solidus_git, solidus_frontend_git = if (branch == 'master') || (branch >= 'v3.2')
%w[solidusio/solidus solidusio/solidus_frontend]
else
%w[solidusio/solidus] * 2
end
gem 'solidus', github: solidus_git, branch: branch
gem 'solidus_frontend', github: solidus_frontend_git, branch: branch
gem 'solidus', github: 'solidusio/solidus', branch: branch

# The solidus_frontend gem has been pulled out since v3.2
gem 'solidus_frontend', github: 'solidusio/solidus_frontend' if branch == 'master'
gem 'solidus_frontend' if branch >= 'v3.2' # rubocop:disable Bundler/DuplicatedGem

# Needed to help Bundler figure out how to resolve dependencies,
# otherwise it takes forever to resolve them.
Expand All @@ -20,7 +18,7 @@ gem 'rails', '>0.a'
# Provides basic authentication functionality for testing parts of your engine
gem 'solidus_auth_devise'

case ENV['DB']
case ENV.fetch('DB', nil)
when 'mysql'
gem 'mysql2'
when 'postgresql'
Expand All @@ -35,6 +33,11 @@ gem 'dato', require: 'dato'
gem 'prismic.io', require: 'prismic'
gem 'solidus_static_content', github: 'solidusio-contrib/solidus_static_content'

# While we still support Ruby < 3 we need to workaround a limitation in
# the 'async' gem that relies on the latest ruby, since RubyGems doesn't
# resolve gems based on the required ruby version.
gem 'async', '< 3' if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3')

gemspec

# Use a local Gemfile to include development dependencies that might not be
Expand Down
42 changes: 29 additions & 13 deletions bin/sandbox
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/usr/bin/env bash

set -e
if [ ! -z $DEBUG ]
then
set -x
fi

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

if [ ! -z $SOLIDUS_BRANCH ]
if [ -n $SOLIDUS_BRANCH ]
then
BRANCH=$SOLIDUS_BRANCH
else
echo "~~> Use 'export SOLIDUS_BRANCH=[master|v3.2|...]' to control the Solidus branch"
BRANCH="master"
fi
echo "~~> Using branch $BRANCH of solidus"

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

extension_name="solidus_content"

Expand All @@ -50,7 +69,6 @@ fi
cd ./sandbox
cat <<RUBY >> Gemfile
gem 'solidus', github: 'solidusio/solidus', branch: '$BRANCH'
gem 'solidus_auth_devise', '>= 2.1.0'
gem 'rails-i18n'
gem 'solidus_i18n'
Expand All @@ -67,20 +85,18 @@ unbundled bundle install --gemfile Gemfile

unbundled bundle exec rake db:drop db:create

unbundled bundle exec rails generate spree:install \
unbundled bundle exec rails generate solidus:install \
--auto-accept \
--user_class=Spree::User \
--enforce_available_locales=true \
--with-authentication=false \
--payment-method=none
--with-authentication=true \
--payment-method=none \
--frontend=${SOLIDUS_FRONTEND} \
$@

unbundled bundle exec rails generate solidus:auth:install
unbundled bundle exec rails generate ${extension_name}:install
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 "πŸš€ 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."
echo "πŸ§ͺ This app is intended for test purposes."

0 comments on commit 06a011b

Please sign in to comment.