opal/opal-rails

View on GitHub
bin/sandbox

Summary

Maintainability
Test Coverage
#!/usr/bin/env bash

gem_name="$(ruby -rpathname -e"puts Pathname(ARGV.first).join('../..').expand_path.glob('*.gemspec').first.basename('.gemspec')" -- $0)"

# 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 \
  --skip-bundle \
  --skip-git \
  --skip-keeps \
  --skip-rc \
  --skip-spring \
  --skip-test \
  $@

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

cd ./sandbox
cat <<RUBY >> Gemfile
gem '$gem_name', path: '..'
RUBY

unbundled bundle install --gemfile Gemfile
unbundled bin/rails webpacker:install


cd .. # Back to the project root.
bin/sandbox-setup # Run any custom setup.

echo
echo "🚀 Sandbox app successfully created for $gem_name!"