summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorJared Norman <jared@super.gd>2020-06-24 11:53:40 -0700
committerJared Norman <jared@super.gd>2020-06-24 11:53:40 -0700
commitd4116e138a0e7c7d524e1342f7d12353e60d23c7 (patch)
tree3bd7f672da4cc9c2a72ee73122ecfa1cf3e41d9b /bin
parent96a435b27fd7a4e7e26299aeacf95746d594da15 (diff)
Add scripts provided by solidus_dev_support
Diffstat (limited to 'bin')
-rwxr-xr-xbin/rails7
-rwxr-xr-xbin/rails-engine13
-rwxr-xr-xbin/rails-sandbox16
-rwxr-xr-xbin/rake7
-rwxr-xr-xbin/sandbox84
5 files changed, 127 insertions, 0 deletions
diff --git a/bin/rails b/bin/rails
new file mode 100755
index 0000000..6dbbbc3
--- /dev/null
+++ b/bin/rails
@@ -0,0 +1,7 @@
+#!/usr/bin/env ruby
+
+if %w[g generate].include? ARGV.first
+ exec "#{__dir__}/rails-engine", *ARGV
+else
+ exec "#{__dir__}/rails-sandbox", *ARGV
+end
diff --git a/bin/rails-engine b/bin/rails-engine
new file mode 100755
index 0000000..3684b30
--- /dev/null
+++ b/bin/rails-engine
@@ -0,0 +1,13 @@
+#!/usr/bin/env ruby
+# This command will automatically be run when you run "rails" with Rails gems
+# installed from the root of your application.
+
+ENGINE_ROOT = File.expand_path('..', __dir__)
+ENGINE_PATH = File.expand_path('../lib/solidus_taxjar/engine', __dir__)
+
+# Set up gems listed in the Gemfile.
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
+require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
+
+require 'rails/all'
+require 'rails/engine/commands'
diff --git a/bin/rails-sandbox b/bin/rails-sandbox
new file mode 100755
index 0000000..c89b2ae
--- /dev/null
+++ b/bin/rails-sandbox
@@ -0,0 +1,16 @@
+#!/usr/bin/env ruby
+
+app_root = 'sandbox'
+
+unless File.exist? "#{app_root}/bin/rails"
+ warn 'Creating the sandbox app...'
+ Dir.chdir "#{__dir__}/.." do
+ system "#{__dir__}/sandbox" or begin # rubocop:disable Style/AndOr
+ warn 'Automatic creation of the sandbox app failed'
+ exit 1
+ end
+ end
+end
+
+Dir.chdir app_root
+exec 'bin/rails', *ARGV
diff --git a/bin/rake b/bin/rake
new file mode 100755
index 0000000..1e6eacd
--- /dev/null
+++ b/bin/rake
@@ -0,0 +1,7 @@
+#!/usr/bin/env ruby
+# frozen_string_literal: true
+
+require "rubygems"
+require "bundler/setup"
+
+load Gem.bin_path("rake", "rake")
diff --git a/bin/sandbox b/bin/sandbox
new file mode 100755
index 0000000..ca0fa22
--- /dev/null
+++ b/bin/sandbox
@@ -0,0 +1,84 @@
+#!/usr/bin/env bash
+
+set -e
+
+case "$DB" in
+postgres|postgresql)
+ RAILSDB="postgresql"
+ ;;
+mysql)
+ RAILSDB="mysql"
+ ;;
+sqlite|'')
+ RAILSDB="sqlite3"
+ ;;
+*)
+ echo "Invalid DB specified: $DB"
+ exit 1
+ ;;
+esac
+
+if [ ! -z $SOLIDUS_BRANCH ]
+then
+ BRANCH=$SOLIDUS_BRANCH
+else
+ BRANCH="master"
+fi
+
+extension_name="solidus_taxjar"
+
+# 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)' -- $@
+}
+
+rm -rf ./sandbox
+unbundled bundle exec rails new sandbox --database="$RAILSDB" \
+ --skip-bundle \
+ --skip-git \
+ --skip-keeps \
+ --skip-rc \
+ --skip-spring \
+ --skip-test \
+ --skip-javascript
+
+if [ ! -d "sandbox" ]; then
+ echo 'sandbox rails application failed'
+ exit 1
+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'
+
+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 spree:install \
+ --auto-accept \
+ --user_class=Spree::User \
+ --enforce_available_locales=true \
+ --with-authentication=false \
+ $@
+
+unbundled bundle exec rails generate solidus:auth:install
+
+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."