Skip to content
Merged
Show file tree
Hide file tree
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
23 changes: 5 additions & 18 deletions bin/dummy-app
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,16 @@
set -e

extension_name="solidus_stripe"
app_name="dummy-app"

bin/rails-new "$app_name"

# Stay away from the bundler env of the containing extension.
function unbundled {
ruby -rbundler -e'Bundler.with_unbundled_env{system({"BUNDLE_SUPPRESS_INSTALL_USING_MESSAGES"=>"1"},*ARGV)}' -- "$@"
echo "~~> Running: $@"
ruby -rbundler -e'Bundler.with_unbundled_env {system *ARGV}' -- env BUNDLE_SUPPRESS_INSTALL_USING_MESSAGES=true "$@"
}

# "sqlite" is set by the ORB extension instead of "sqlite3",
# all other options are already in the format expected by `rails new`.
test "$DB" = "sqlite" && export DB="sqlite3"

rm -rf ./dummy-app
rails_version=`bundle exec ruby -e'require "rails"; puts Rails.version'`
rails _${rails_version}_ new dummy-app \
--database=${DB:-sqlite3} \
--skip-git \
--skip-rc

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

cd ./dummy-app

# Coverage
Expand All @@ -39,4 +27,3 @@ unbundled bundle exec rake db:drop db:create
unbundled bundle exec rails generate solidus:install --auto-accept --payment-method=none --no-seed --no-sample "$@"
unbundled bundle add $extension_name --path ..
unbundled bundle exec rails generate $extension_name:install --migrate --load-seeds=false --specs=all

55 changes: 55 additions & 0 deletions bin/rails-new
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env bash

set -e

app_name="$1"

root_path="$PWD"
app_path="${root_path}/${app_name}"
ruby_version=`ruby -e'puts RUBY_VERSION'`
rails_version=`bundle exec ruby -rrails/version -e'puts Rails.version'`
solidus_version=`bundle exec ruby -rspree/core/version -e'puts Spree::VERSION'`
cache_path="tmp/cache/rails-new/${app_name}-${rails_version}-${solidus_version}-${ruby_version}.zip"

# Stay away from the bundler env of the containing extension.
function unbundled {
echo "~~> Running: $@"
ruby -rbundler -e'Bundler.with_unbundled_env {system *ARGV}' -- env BUNDLE_SUPPRESS_INSTALL_USING_MESSAGES=true "$@"
}

# "sqlite" is set by the ORB extension instead of "sqlite3",
# all other options are already in the format expected by `rails new`.
test "$DB" = "sqlite" && export DB="sqlite3"

rm -rf "$app_path"
mkdir -p tmp/cache/rails-new

if [ -f "${cache_path}" ]; then
echo "~~> Using cached rails ${app_name}"
unzip -q "${cache_path}" -d ./
cd "${app_path}"
unbundled bundle install
cd "${root_path}"
else
echo "~~> Creating rails ${app_name}"
rails _${rails_version}_ new ${app_name} \
--database=${DB:-sqlite3} \
--skip-git \
--skip-rc

cd "$app_path"
unbundled bundle add listen --group development
unbundled bundle add solidus --github solidusio/solidus --branch "${BRANCH:-master}" --version '> 0.a'
unbundled bundle exec rake db:drop db:create
unbundled bundle exec rails generate solidus:install --auto-accept --payment-method=none
cd "${root_path}"

echo "~~> Creating rails ${app_name} cache"
rm -rf ${app_name}/tmp/solidus_starter_frontend*
zip -q -r "${cache_path}" ${app_name}
fi

if [ ! -d "${app_name}" ]; then
echo '~~> Creation of the ${app_name} rails application failed'
exit 1
fi
28 changes: 6 additions & 22 deletions bin/sandbox
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,17 @@
set -e

extension_name="solidus_stripe"
app_name="sandbox"

bin/rails-new "$app_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)' -- "$@"
echo "~~> Running: $@"
ruby -rbundler -e'Bundler.with_unbundled_env {system *ARGV}' -- env BUNDLE_SUPPRESS_INSTALL_USING_MESSAGES=true "$@"
}

# "sqlite" is set by the ORB extension instead of "sqlite3",
# all other options are already in the format expected by `rails new`.
test "$DB" = "sqlite" && export DB="sqlite3"

rm -rf ./sandbox
rails_version=`bundle exec ruby -e'require "rails"; puts Rails.version'`
rails _${rails_version}_ new sandbox \
--database=${DB:-sqlite3} \
--skip-git \
--skip-rc

if [ ! -d "sandbox" ]; then
echo '~~> Creation of the sandbox rails application failed'
exit 1
fi

cd ./sandbox
unbundled bundle add listen --group development
unbundled bundle add solidus --github solidusio/solidus --branch "${BRANCH:-master}" --version '> 0.a'
unbundled bundle exec rake db:drop db:create
unbundled bundle exec rails generate solidus:install --auto-accept --payment-method=none "$@"
cd "./$app_name"
unbundled bundle add $extension_name --path ..
unbundled bundle exec rails generate $extension_name:install --migrate --specs=all

Expand Down