solidus_dev_support 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a3823487a717fb97e853499a6e68ad405e443ae3f0b16bdfc4c11ab97dd31670
4
- data.tar.gz: fa21213f5c4726ecaed62f37cff358774c1b09d1f9ad850e16f94e6d2b937722
3
+ metadata.gz: 389395ffb560031a111e0baaba5c71d9b7f2a8ccc6ca750ea2577fb214250410
4
+ data.tar.gz: a0c401f0b752a9f87dadbb44eb862f4cf43cde5e3337218f974a37333da64436
5
5
  SHA512:
6
- metadata.gz: a80b12e5e9a84e3b0ff6476c3f887277b3acc53ce9c79910679b22d791639ce7d74a1f6ca8a7c2d6550ee64ac1866420c08c1c892ac965a2a89fee053d62c504
7
- data.tar.gz: 493cfb3d42a71d111c90ccdad26095010d660f78f5748e25f86518918689b2e0524425caa710e3d9e144b881e022650ae4a3ff13781e6923d994bf499ab9f895
6
+ metadata.gz: 8f85910f752ebe285a4dedc588ec00e16c934649b04a754298c907ef1c041b0dee5e86e7cd4702ca6e8bb82947e6533e13ec5043fba086fc3c71dcb4aab01db4
7
+ data.tar.gz: 5fb1ae79621a936f5abd625205f1980998a7f6769851f9402d3497c2b73d5e2601aa08e0533b1e7f4fd443eecebf039796cf41ddcc3f46a9e8544ed6f39d57b0
@@ -7,21 +7,43 @@ orbs:
7
7
  # or goes EOL.
8
8
  solidusio_extensions: solidusio/extensions@volatile
9
9
 
10
- jobs:
11
- run-specs-with-postgres:
12
- executor: solidusio_extensions/postgres
13
- steps:
14
- - solidusio_extensions/run-tests
15
- run-specs-with-mysql:
16
- executor: solidusio_extensions/mysql
10
+ executors:
11
+ # We don't rely directly on the DB, but we still want to ensure generated
12
+ # extensions are able to connect and spin up Solidus. Using an in-memory
13
+ # SQLite makes it blazingly fast.
14
+ sqlite-memory:
15
+ docker:
16
+ - image: circleci/ruby:2.5.6-node-browsers
17
+ environment:
18
+ RAILS_ENV: test
19
+ DB: sqlite
20
+ DATABASE_URL: sqlite3::memory:?pool=1
21
+ DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL: true
22
+
23
+ commands:
24
+ setup:
17
25
  steps:
18
- - solidusio_extensions/run-tests
26
+ - checkout
27
+ - run: "gem install bundler -v '>=2' --conservative"
28
+
29
+ jobs:
30
+ solidus-master:
31
+ executor: sqlite-memory
32
+ steps: ['setup', 'solidusio_extensions/run-tests-solidus-master']
33
+ solidus-current:
34
+ executor: sqlite-memory
35
+ steps: ['setup', 'solidusio_extensions/run-tests-solidus-current']
36
+ solidus-older:
37
+ executor: sqlite-memory
38
+ steps: ['setup', 'solidusio_extensions/run-tests-solidus-older']
19
39
 
20
40
  workflows:
21
41
  "Run specs on supported Solidus versions":
22
42
  jobs:
23
- - run-specs-with-postgres
24
- - run-specs-with-mysql
43
+ - solidus-master
44
+ - solidus-current
45
+ - solidus-older
46
+
25
47
  "Weekly run specs against master":
26
48
  triggers:
27
49
  - schedule:
@@ -31,5 +53,6 @@ workflows:
31
53
  only:
32
54
  - master
33
55
  jobs:
34
- - run-specs-with-postgres
35
- - run-specs-with-mysql
56
+ - solidus-master
57
+ - solidus-current
58
+ - solidus-older
data/.gitignore CHANGED
@@ -6,9 +6,8 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ /vendor/bundle/
9
10
  Gemfile.lock
10
11
 
11
12
  # rspec failure tracking
12
13
  .rspec_status
13
-
14
- /spec/tmp/
@@ -9,18 +9,48 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
9
9
 
10
10
  ### Added
11
11
 
12
+ - Enforced Rails version depending on the Solidus version in generated Gemfile
13
+ - Made Git ignore `spec/examples.txt` in generated extensions
14
+ - Added the ability to run `solidus extension .` to update an extension
15
+
16
+ ### Changed
17
+
18
+ - The `solidus` executable is now solely managed by Thor and is open to extension by other gems
19
+
20
+ ### Fixed
21
+
22
+ - Fixed generated extensions using an old Rakefile
23
+ - Fixed some RuboCop offenses in the generated files
24
+ - Fixed the `bin/setup` script calling a non-existing Rake binary
25
+
26
+ ### Removed
27
+
28
+ - Removed RuboCop from the default Rake task
29
+ - Removed the `-v` option from the `solidus` executable
30
+ - Removed the factory_bot gem from the Gemfile
31
+
32
+ ## [0.3.0] - 2019-01-10
33
+
34
+ ### Added
35
+
12
36
  - Adopted Ruby 2.4+ as the minimum Ruby version in generated extensions
13
37
  - Added `bin/console`, `bin/rails` and `bin/setup` to generated extensions
14
38
  - Added some Bundler gemspec defaults to generated extensions
39
+ - Configured the default Rake task to run generate the test app before running RSpec
15
40
 
16
41
  ### Changed
17
42
 
18
43
  - Updated solidus_support to 0.4.0 for Zeitwerk and Rails 6 compatibility
44
+ - Updated the `solidus` executable to only rely on Thor and be open to extension by other gems
19
45
 
20
46
  ### Removed
21
47
 
22
48
  - Removed solidus_support as a dependency
23
49
 
50
+ ### Fixed
51
+
52
+ - Fixed `extension:test_app` not going back to the root after execution
53
+
24
54
  ## [0.2.0] - 2019-12-16
25
55
 
26
56
  ### Added
@@ -50,7 +80,8 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
50
80
 
51
81
  Initial release.
52
82
 
53
- [Unreleased]: https://github.com/solidusio-contrib/solidus_dev_support/compare/v0.2.0...HEAD
83
+ [Unreleased]: https://github.com/solidusio-contrib/solidus_dev_support/compare/v0.3.0...HEAD
84
+ [0.3.0]: https://github.com/solidusio-contrib/solidus_dev_support/compare/v0.2.0...v0.3.0
54
85
  [0.2.0]: https://github.com/solidusio-contrib/solidus_dev_support/compare/v0.1.1...v0.2.0
55
86
  [0.1.1]: https://github.com/solidusio-contrib/solidus_dev_support/compare/v0.1.0...v0.1.1
56
87
  [0.1.0]: https://github.com/solidusio-contrib/solidus_dev_support/releases/tag/v0.1.0
data/Gemfile CHANGED
@@ -6,3 +6,18 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
6
 
7
7
  # Specify your gem's dependencies in solidus_dev_support.gemspec
8
8
  gemspec
9
+
10
+ branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
11
+ gem 'solidus', github: 'solidusio/solidus', branch: branch
12
+
13
+ # A workaround for https://github.com/bundler/bundler/issues/6677
14
+ gem 'rails', '>0.a'
15
+
16
+ # These gems will be used by the temporary extensions generated by tests
17
+ group :test do
18
+ gem 'solidus_auth_devise'
19
+ gem 'factory_bot', '> 4.10.0'
20
+ gem 'mysql2'
21
+ gem 'pg'
22
+ gem 'sqlite3'
23
+ end
data/README.md CHANGED
@@ -146,7 +146,7 @@ To install extension-related Rake tasks, add this to your `Rakefile`:
146
146
  require 'solidus_dev_support/rake_tasks'
147
147
  SolidusDevSupport::RakeTasks.install
148
148
 
149
- task default: 'extension:specs'
149
+ task default: %w[extension:test_app extension:specs]
150
150
  ```
151
151
 
152
152
  (If your extension used the legacy extension Rakefile, then you should completely replace its
@@ -154,8 +154,10 @@ contents with the block above.)
154
154
 
155
155
  This will provide the following tasks:
156
156
 
157
- - `extension:specs` (default), which runs the specs for your extension
158
157
  - `extension:test_app`, which generates a dummy app for your extension
158
+ - `extension:specs` (default), which runs the specs for your extension
159
+
160
+ It also allows you to run `rake` to, respectively, generate a test app and run all tests.
159
161
 
160
162
  ## Development
161
163
 
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rake' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rake", "rake")
@@ -1,53 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require 'optparse'
4
+ require 'solidus_dev_support/solidus_command'
5
5
 
6
- require 'solidus_dev_support/version'
7
-
8
- Options = Struct.new(:name)
9
-
10
- class Parser
11
- class << self
12
- def parse(args)
13
- options.parse!(args)
14
- end
15
-
16
- def options
17
- OptionParser.new do |opts|
18
- opts.banner = 'Usage: solidus [[extension extension_name] | [-h] [-v]]'
19
-
20
- opts.on('-h', '--help', 'Prints this help') do
21
- puts opts
22
- end
23
-
24
- opts.on(
25
- '-v',
26
- '--version',
27
- "Prints the current version: #{SolidusDevSupport::VERSION}"
28
- ) do
29
- puts SolidusDevSupport::VERSION
30
- end
31
- end
32
- end
33
- end
34
- end
35
-
36
- # Print help if no options are supplied
37
- ARGV << '--help' unless ARGV.first
38
-
39
- if ARGV.first == 'extension' || ARGV.first == 'e'
40
- ARGV.shift
41
-
42
- unless ARGV.first
43
- puts 'An extension must have a name!'
44
- puts `solidus -h`
45
- exit 1
46
- end
47
-
48
- require 'solidus_dev_support'
49
- require 'solidus_dev_support/extension'
50
- SolidusDevSupport::Extension.start
51
- else
52
- Parser.parse(ARGV)
53
- end
6
+ SolidusDevSupport::SolidusCommand.start
@@ -1,54 +1,56 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'thor'
4
- require 'thor/group'
5
4
  require 'pathname'
6
5
 
7
6
  module SolidusDevSupport
8
- class Extension < Thor::Group
7
+ class Extension < Thor
9
8
  include Thor::Actions
9
+ PREFIX = 'solidus_'
10
10
 
11
- desc 'builds a solidus extension'
12
- argument :file_name, type: :string, desc: 'rails app_path', default: '.'
11
+ default_command :generate
13
12
 
14
- source_root File.expand_path('templates/extension', __dir__)
13
+ desc 'generate PATH', 'Generates a new Solidus extension'
14
+ def generate(raw_path = '.')
15
+ self.path = raw_path
15
16
 
16
- def generate
17
- use_prefix 'solidus_'
17
+ empty_directory path
18
18
 
19
- empty_directory file_name
20
-
21
- directory 'app', "#{file_name}/app"
22
- directory 'lib', "#{file_name}/lib"
23
- directory 'bin', "#{file_name}/bin"
24
- directory '.circleci', "#{file_name}/.circleci"
25
- directory '.github', "#{file_name}/.github"
19
+ directory 'app', "#{path}/app"
20
+ directory 'lib', "#{path}/lib"
21
+ directory 'bin', "#{path}/bin"
22
+ directory '.circleci', "#{path}/.circleci"
23
+ directory '.github', "#{path}/.github"
26
24
 
27
25
  Dir["#{file_name}/bin/*"].each do |executable|
28
26
  make_executable executable
29
27
  end
30
28
 
31
- template 'extension.gemspec.erb', "#{file_name}/#{file_name}.gemspec"
32
- template 'Gemfile', "#{file_name}/Gemfile"
33
- template 'gitignore', "#{file_name}/.gitignore"
34
- template 'gem_release.yml.tt', "#{file_name}/.gem_release.yml"
35
- template 'LICENSE', "#{file_name}/LICENSE"
36
- template 'Rakefile', "#{file_name}/Rakefile"
37
- template 'README.md', "#{file_name}/README.md"
38
- template 'config/routes.rb', "#{file_name}/config/routes.rb"
39
- template 'config/locales/en.yml', "#{file_name}/config/locales/en.yml"
40
- template 'rspec', "#{file_name}/.rspec"
41
- template 'spec/spec_helper.rb.tt', "#{file_name}/spec/spec_helper.rb"
42
- template 'rubocop.yml', "#{file_name}/.rubocop.yml"
29
+ template 'extension.gemspec.erb', "#{path}/#{file_name}.gemspec"
30
+ template 'Gemfile', "#{path}/Gemfile"
31
+ template 'gitignore', "#{path}/.gitignore"
32
+ template 'gem_release.yml.tt', "#{path}/.gem_release.yml"
33
+ template 'LICENSE', "#{path}/LICENSE"
34
+ template 'Rakefile', "#{path}/Rakefile"
35
+ template 'README.md', "#{path}/README.md"
36
+ template 'config/routes.rb', "#{path}/config/routes.rb"
37
+ template 'config/locales/en.yml', "#{path}/config/locales/en.yml"
38
+ template 'rspec', "#{path}/.rspec"
39
+ template 'spec/spec_helper.rb.tt', "#{path}/spec/spec_helper.rb"
40
+ template 'rubocop.yml', "#{path}/.rubocop.yml"
43
41
  end
44
42
 
45
43
  no_tasks do
46
- def class_name
47
- Thor::Util.camel_case file_name
48
- end
44
+ def path=(path)
45
+ path = File.expand_path(path)
46
+
47
+ @file_name = Thor::Util.snake_case(File.basename(path))
48
+ @file_name = PREFIX + @file_name unless @file_name.start_with?(PREFIX)
49
+
50
+ @class_name = Thor::Util.camel_case @file_name
49
51
 
50
- def use_prefix(prefix)
51
- @file_name = prefix + Thor::Util.snake_case(file_name) unless file_name =~ /^#{prefix}/
52
+ @root = File.dirname(path)
53
+ @path = File.join(@root, @file_name)
52
54
  end
53
55
 
54
56
  def make_executable(path)
@@ -56,6 +58,12 @@ module SolidusDevSupport
56
58
  executable = (path.stat.mode | 0o111)
57
59
  path.chmod(executable)
58
60
  end
61
+
62
+ attr_reader :root, :path, :file_name, :class_name
63
+ end
64
+
65
+ def self.source_root
66
+ "#{__dir__}/templates/extension"
59
67
  end
60
68
  end
61
69
  end
@@ -26,33 +26,32 @@ module SolidusDevSupport
26
26
 
27
27
  def install_test_app_task
28
28
  require 'rake/clean'
29
- ::CLOBBER.include test_app_path
29
+ require 'spree/testing_support/extension_rake'
30
30
 
31
31
  ENV['DUMMY_PATH'] = test_app_path.to_s
32
32
  ENV['LIB_NAME'] = gemspec.name
33
- require 'spree/testing_support/extension_rake'
34
33
 
35
- namespace :extension do
36
- directory ENV['DUMMY_PATH'] do
37
- Rake::Task['extension:test_app']
34
+ ::CLOBBER.include test_app_path
38
35
 
39
- # We need to go back to the gem root since extension:test_app changes
40
- # the working directory to be the dummy app.
36
+ namespace :extension do
37
+ task :test_app do
38
+ Rake::Task['extension:test_app'].invoke
41
39
  cd root
42
40
  end
43
41
  end
44
42
  end
45
43
 
46
44
  def install_rspec_task
45
+ require 'rspec/core/rake_task'
46
+
47
47
  namespace :extension do
48
- require 'rspec/core/rake_task'
49
48
  ::RSpec::Core::RakeTask.new(:specs, [] => FileList[ENV['DUMMY_PATH']]) do |t|
50
49
  # Ref: https://circleci.com/docs/2.0/configuration-reference#store_test_results
51
50
  # Ref: https://github.com/solidusio/circleci-orbs-extensions#test-results-rspec
52
51
  if ENV['TEST_RESULTS_PATH']
53
52
  t.rspec_opts =
54
53
  "--format progress " \
55
- "--format RspecJunitFormatter --out #{ENV['TEST_RESULTS_PATH']}"
54
+ "--format RspecJunitFormatter --out #{ENV['TEST_RESULTS_PATH']}"
56
55
  end
57
56
  end
58
57
  end
@@ -16,7 +16,9 @@ SimpleCov.start('rails') do
16
16
  add_filter %r{^/lib/.*/version.rb}
17
17
  end
18
18
 
19
- if ENV['CI']
19
+ if ENV['CODECOV_TOKEN']
20
20
  require 'codecov'
21
21
  SimpleCov.formatter = SimpleCov::Formatter::Codecov
22
+ else
23
+ warn "Provide a CODECOV_TOKEN environment variable to enable Codecov uploads"
22
24
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'thor'
4
+ require 'solidus_dev_support/extension'
5
+
6
+ module SolidusDevSupport
7
+ class SolidusCommand < Thor
8
+ namespace ''
9
+
10
+ desc 'extension', 'Manage solidus extensions'
11
+ subcommand 'extension', Extension
12
+
13
+ desc 'e', 'Manage solidus extensions (shortcut for "extension")'
14
+ subcommand 'e', Extension
15
+
16
+ def self.exit_on_failure?
17
+ true
18
+ end
19
+ end
20
+ end
21
+
@@ -6,11 +6,14 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
6
6
  branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
7
7
  gem 'solidus', github: 'solidusio/solidus', branch: branch
8
8
 
9
+ # Needed to help Bundler figure out how to resolve dependencies,
10
+ # otherwise it takes forever to resolve them.
11
+ # See https://github.com/bundler/bundler/issues/6677
12
+ gem 'rails', '>0.a'
13
+
9
14
  # Provides basic authentication functionality for testing parts of your engine
10
15
  gem 'solidus_auth_devise'
11
16
 
12
- gem 'factory_bot', '> 4.10.0'
13
-
14
17
  case ENV['DB']
15
18
  when 'mysql'
16
19
  gem 'mysql2'
@@ -1,32 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bundler'
3
+ require 'solidus_dev_support/rake_tasks'
4
+ SolidusDevSupport::RakeTasks.install
4
5
 
5
- Bundler::GemHelper.install_tasks
6
-
7
- begin
8
- require 'spree/testing_support/extension_rake'
9
- require 'rubocop/rake_task'
10
- require 'rspec/core/rake_task'
11
-
12
- RSpec::Core::RakeTask.new(:spec)
13
-
14
- RuboCop::RakeTask.new
15
-
16
- task default: %i(first_run rubocop spec)
17
- rescue LoadError # rubocop:disable Lint/HandleExceptions
18
- # no rspec available
19
- end
20
-
21
- task :first_run do
22
- if Dir['spec/dummy'].empty?
23
- Rake::Task[:test_app].invoke
24
- Dir.chdir('../../')
25
- end
26
- end
27
-
28
- desc 'Generates a dummy app for testing'
29
- task :test_app do
30
- ENV['LIB_NAME'] = '<%=file_name%>'
31
- Rake::Task['extension:test_app'].invoke
32
- end
6
+ task default: %w[extension:test_app extension:specs]
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ # frozen_string_literal: true
4
+
3
5
  require "bundler/setup"
4
6
  require "<%= file_name %>"
5
7
 
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ # frozen_string_literal: true
4
+
3
5
  app_root = 'spec/dummy'
4
6
 
5
7
  unless File.exist? "#{app_root}/bin/rails"
@@ -9,5 +11,5 @@ unless File.exist? "#{app_root}/bin/rails"
9
11
  end
10
12
  end
11
13
 
12
- Dir.chdir 'spec/dummy'
14
+ Dir.chdir app_root
13
15
  exec 'bin/rails', *ARGV
@@ -5,6 +5,4 @@ set -vx
5
5
 
6
6
  gem install bundler --conservative
7
7
  bundle update
8
- bin/rake clobber
9
- bin/rake spec/dummy
10
- bin/rails railties:install:migrations db:migrate db:seed
8
+ bundle exec rake extension:test_app
@@ -13,3 +13,4 @@ nbproject
13
13
  pkg
14
14
  *.swp
15
15
  spec/dummy
16
+ spec/examples.txt
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusDevSupport
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_dev_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alessandro Desantis
@@ -303,6 +303,7 @@ files:
303
303
  - README.md
304
304
  - Rakefile
305
305
  - bin/console
306
+ - bin/rake
306
307
  - bin/setup
307
308
  - bin/solidus
308
309
  - exe/solidus
@@ -315,6 +316,7 @@ files:
315
316
  - lib/solidus_dev_support/rspec/spec_helper.rb
316
317
  - lib/solidus_dev_support/rubocop.rb
317
318
  - lib/solidus_dev_support/rubocop/config.yml
319
+ - lib/solidus_dev_support/solidus_command.rb
318
320
  - lib/solidus_dev_support/templates/extension/.circleci/config.yml
319
321
  - lib/solidus_dev_support/templates/extension/.github/stale.yml
320
322
  - lib/solidus_dev_support/templates/extension/CONTRIBUTING.md