Skip to content

Commit de36a2d

Browse files
authored
Merge pull request #188 from solidusio/elia/solidus-starter-frontend-support
Misc: auth-devise, extracted frontend gem, sqlite
2 parents e5fec9c + b794ef0 commit de36a2d

6 files changed

Lines changed: 60 additions & 31 deletions

File tree

.circleci/config.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,25 @@ commands:
1212
steps:
1313
- checkout
1414
- run:
15-
command: "gem install bundler -v '>=2' --conservative"
16-
no_output_timeout: 20m
15+
name: "Update bundler"
16+
command: |
17+
gem update --system
18+
gem --version
19+
gem install bundler -v '>=2.3.21' --conservative
20+
bundle --version
1721
1822
jobs:
1923
solidus-master:
20-
executor: solidusio_extensions/sqlite-memory
24+
executor: solidusio_extensions/sqlite
2125
steps: ['setup', 'solidusio_extensions/run-tests-solidus-master']
2226
solidus-current:
23-
executor: solidusio_extensions/sqlite-memory
27+
executor: solidusio_extensions/sqlite
2428
steps: ['setup', 'solidusio_extensions/run-tests-solidus-current']
2529
solidus-older:
26-
executor: solidusio_extensions/sqlite-memory
30+
executor: solidusio_extensions/sqlite
2731
steps: ['setup', 'solidusio_extensions/run-tests-solidus-older']
2832
lint-code:
29-
executor: solidusio_extensions/sqlite-memory
33+
executor: solidusio_extensions/sqlite
3034
steps: ['setup', 'solidusio_extensions/lint-code']
3135

3236
workflows:

lib/solidus_dev_support/templates/extension/Gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
66
branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
77
gem 'solidus', github: 'solidusio/solidus', branch: branch
88

9+
# The solidus_frontend gem has been pulled out since v3.2
10+
gem 'solidus_frontend', github: 'solidusio/solidus_frontend' if branch == 'master'
11+
gem 'solidus_frontend' if branch >= 'v3.2' # rubocop:disable Bundler/DuplicatedGem
12+
913
# Needed to help Bundler figure out how to resolve dependencies,
1014
# otherwise it takes forever to resolve them.
1115
# See https://github.com/bundler/bundler/issues/6677

lib/solidus_dev_support/templates/extension/bin/sandbox.tt

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#!/usr/bin/env bash
22

33
set -e
4+
if [ ! -z $DEBUG ]
5+
then
6+
set -x
7+
fi
48

59
case "$DB" in
610
postgres|postgresql)
@@ -9,21 +13,36 @@ postgres|postgresql)
913
mysql)
1014
RAILSDB="mysql"
1115
;;
12-
sqlite|'')
16+
sqlite3|sqlite)
17+
RAILSDB="sqlite3"
18+
;;
19+
'')
20+
echo "~~> Use 'export DB=[postgres|mysql|sqlite]' to control the DB adapter"
1321
RAILSDB="sqlite3"
1422
;;
1523
*)
16-
echo "Invalid DB specified: $DB"
24+
echo "Invalid value specified for the Solidus sandbox: DB=\"$DB\"."
25+
echo "Please use 'postgres', 'mysql', or 'sqlite' instead."
1726
exit 1
1827
;;
1928
esac
29+
echo "~~> Using $RAILSDB as the database engine"
2030

21-
if [ ! -z $SOLIDUS_BRANCH ]
31+
if [ -n $SOLIDUS_BRANCH ]
2232
then
2333
BRANCH=$SOLIDUS_BRANCH
2434
else
35+
echo "~~> Use 'export SOLIDUS_BRANCH=[master|v3.2|...]' to control the Solidus branch"
2536
BRANCH="master"
2637
fi
38+
echo "~~> Using branch $BRANCH of solidus"
39+
40+
if [ -z $SOLIDUS_FRONTEND ]
41+
then
42+
echo "~~> Use 'export SOLIDUS_FRONTEND=[solidus_frontend|solidus_starter_frontend]' to control the Solidus frontend"
43+
SOLIDUS_FRONTEND="solidus_frontend"
44+
fi
45+
echo "~~> Using branch $SOLIDUS_FRONTEND as the solidus frontend"
2746

2847
extension_name="<%= file_name %>"
2948

@@ -50,7 +69,6 @@ fi
5069
cd ./sandbox
5170
cat <<RUBY >> Gemfile
5271
gem 'solidus', github: 'solidusio/solidus', branch: '$BRANCH'
53-
gem 'solidus_auth_devise', '>= 2.1.0'
5472
gem 'rails-i18n'
5573
gem 'solidus_i18n'
5674
@@ -71,16 +89,14 @@ unbundled bundle exec rails generate solidus:install \
7189
--auto-accept \
7290
--user_class=Spree::User \
7391
--enforce_available_locales=true \
74-
--with-authentication=false \
92+
--with-authentication=<%= file_name != 'solidus_auth_devise' %> \
7593
--payment-method=none \
94+
--frontend=${SOLIDUS_FRONTEND} \
7695
$@
7796

78-
unbundled bundle exec rails generate solidus:auth:install
79-
unbundled bundle exec rails generate ${extension_name}:install
97+
unbundled bundle exec rails generate solidus:auth:install --auto-run-migrations
98+
unbundled bundle exec rails generate ${extension_name}:install --auto-run-migrations
8099

81100
echo
82101
echo "🚀 Sandbox app successfully created for $extension_name!"
83-
echo "🚀 Using $RAILSDB and Solidus $BRANCH"
84-
echo "🚀 Use 'export DB=[postgres|mysql|sqlite]' to control the DB adapter"
85-
echo "🚀 Use 'export SOLIDUS_BRANCH=<BRANCH-NAME>' to control the Solidus version"
86-
echo "🚀 This app is intended for test purposes."
102+
echo "🧪 This app is intended for test purposes."

lib/solidus_dev_support/templates/extension/extension.gemspec.tt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
1717
spec.metadata['source_code_uri'] = '<%= gemspec.metadata["source_code_uri"] %>'
1818
spec.metadata['changelog_uri'] = '<%= gemspec.metadata["changelog_uri"] %>'
1919

20-
spec.required_ruby_version = Gem::Requirement.new('~> 2.5')
20+
spec.required_ruby_version = Gem::Requirement.new('>= 2.5', '< 4')
2121

2222
# Specify which files should be added to the gem when it is released.
2323
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.

solidus_dev_support.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Gem::Specification.new do |spec|
3333
spec.add_dependency 'capybara-screenshot', '~> 1.0'
3434
spec.add_dependency 'codecov', '~> 0.2'
3535
spec.add_dependency 'database_cleaner', '~> 1.7'
36-
spec.add_dependency 'factory_bot', '~> 4.8'
36+
spec.add_dependency 'factory_bot', '>= 4.8'
3737
spec.add_dependency 'factory_bot_rails'
3838
spec.add_dependency 'ffaker', '~> 2.13'
3939
spec.add_dependency 'gem-release', '~> 2.1'

spec/features/create_extension_spec.rb

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -155,18 +155,22 @@ def check_sandbox
155155

156156
def sh(*args)
157157
command = args.size == 1 ? args.first : args.shelljoin
158-
output, status = with_unbundled_env { Open3.capture2e(command) }
158+
output, status = with_unbundled_env do
159+
Open3.capture2e({ 'CI' => nil }, command)
160+
end
159161

160-
if status.success?
161-
output.to_s
162-
else
163-
if $DEBUG
164-
warn '~' * 80
165-
warn "$ #{command}"
166-
warn output.to_s
167-
end
162+
if $DEBUG || ENV['DEBUG']
163+
warn '~' * 80
164+
warn "$ #{command}"
165+
warn output.to_s
166+
warn "$ #{command} ~~~~> EXIT STATUS: #{status.exitstatus}"
167+
end
168+
169+
unless status.success?
168170
raise(command_failed_error, "command failed: #{command}\n#{output}")
169171
end
172+
173+
output.to_s
170174
end
171175

172176
def with_unbundled_env(&block)
@@ -182,11 +186,12 @@ def bundle_install
182186
# variables doesn't help because commands are run with a clean env.
183187
bundle_path = "#{gem_root}/vendor/bundle"
184188

185-
command = 'bundle install'
186-
command += " --path=#{bundle_path.shellescape}" if File.exist?(bundle_path)
189+
if File.exist?(bundle_path)
190+
sh "bundle config set --local path #{bundle_path.shellescape}"
191+
end
187192

188193
output = nil
189-
cd(install_path) { output = sh command }
194+
cd(install_path) { output = sh 'bundle install' }
190195
output
191196
end
192197
end

0 commit comments

Comments
 (0)