solidus_dev_support 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +7 -0
  2. data/.circleci/config.yml +35 -0
  3. data/.github/PULL_REQUEST_TEMPLATE.md +11 -0
  4. data/.github/stale.yml +17 -0
  5. data/.gitignore +12 -0
  6. data/.rspec +3 -0
  7. data/.rubocop-https---relaxed-ruby-style-rubocop-yml +174 -0
  8. data/.rubocop.yml +2 -0
  9. data/CHANGELOG.md +39 -0
  10. data/Gemfile +8 -0
  11. data/LICENSE.txt +21 -0
  12. data/README.md +154 -0
  13. data/Rakefile +8 -0
  14. data/bin/console +15 -0
  15. data/bin/setup +8 -0
  16. data/exe/solidus +52 -0
  17. data/lib/solidus_dev_support.rb +15 -0
  18. data/lib/solidus_dev_support/extension.rb +50 -0
  19. data/lib/solidus_dev_support/rake_tasks.rb +61 -0
  20. data/lib/solidus_dev_support/rspec/coverage.rb +22 -0
  21. data/lib/solidus_dev_support/rspec/feature_helper.rb +39 -0
  22. data/lib/solidus_dev_support/rspec/rails_helper.rb +60 -0
  23. data/lib/solidus_dev_support/rspec/spec_helper.rb +25 -0
  24. data/lib/solidus_dev_support/rubocop.rb +16 -0
  25. data/lib/solidus_dev_support/rubocop/config.yml +201 -0
  26. data/lib/solidus_dev_support/templates/extension/.circleci/config.yml +35 -0
  27. data/lib/solidus_dev_support/templates/extension/.github/stale.yml +17 -0
  28. data/lib/solidus_dev_support/templates/extension/CONTRIBUTING.md +57 -0
  29. data/lib/solidus_dev_support/templates/extension/Gemfile +25 -0
  30. data/lib/solidus_dev_support/templates/extension/LICENSE +26 -0
  31. data/lib/solidus_dev_support/templates/extension/README.md +48 -0
  32. data/lib/solidus_dev_support/templates/extension/Rakefile +32 -0
  33. data/lib/solidus_dev_support/templates/extension/app/assets/javascripts/spree/backend/%file_name%.js +2 -0
  34. data/lib/solidus_dev_support/templates/extension/app/assets/javascripts/spree/frontend/%file_name%.js +2 -0
  35. data/lib/solidus_dev_support/templates/extension/app/assets/stylesheets/spree/backend/%file_name%.css +4 -0
  36. data/lib/solidus_dev_support/templates/extension/app/assets/stylesheets/spree/frontend/%file_name%.css +4 -0
  37. data/lib/solidus_dev_support/templates/extension/bin/rails.tt +7 -0
  38. data/lib/solidus_dev_support/templates/extension/config/locales/en.yml +5 -0
  39. data/lib/solidus_dev_support/templates/extension/config/routes.rb +5 -0
  40. data/lib/solidus_dev_support/templates/extension/extension.gemspec.erb +23 -0
  41. data/lib/solidus_dev_support/templates/extension/gem_release.yml.tt +5 -0
  42. data/lib/solidus_dev_support/templates/extension/gitignore +15 -0
  43. data/lib/solidus_dev_support/templates/extension/lib/%file_name%.rb.tt +4 -0
  44. data/lib/solidus_dev_support/templates/extension/lib/%file_name%/engine.rb.tt +22 -0
  45. data/lib/solidus_dev_support/templates/extension/lib/%file_name%/factories.rb.tt +4 -0
  46. data/lib/solidus_dev_support/templates/extension/lib/%file_name%/version.rb.tt +5 -0
  47. data/lib/solidus_dev_support/templates/extension/lib/generators/%file_name%/install/install_generator.rb.tt +32 -0
  48. data/lib/solidus_dev_support/templates/extension/rspec +1 -0
  49. data/lib/solidus_dev_support/templates/extension/rubocop.yml +15 -0
  50. data/lib/solidus_dev_support/templates/extension/spec/spec_helper.rb.tt +24 -0
  51. data/lib/solidus_dev_support/testing_support/preferences.rb +45 -0
  52. data/lib/solidus_dev_support/version.rb +5 -0
  53. data/solidus_dev_support.gemspec +50 -0
  54. metadata +384 -0
@@ -0,0 +1,35 @@
1
+ version: 2.1
2
+
3
+ orbs:
4
+ # Always take the latest version of the orb, this allows us to
5
+ # run specs against Solidus supported versions only without the need
6
+ # to change this configuration every time a Solidus version is released
7
+ # or goes EOL.
8
+ solidusio_extensions: solidusio/extensions@volatile
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
17
+ steps:
18
+ - solidusio_extensions/run-tests
19
+
20
+ workflows:
21
+ "Run specs on supported Solidus versions":
22
+ jobs:
23
+ - run-specs-with-postgres
24
+ - run-specs-with-mysql
25
+ "Weekly run specs against master":
26
+ triggers:
27
+ - schedule:
28
+ cron: "0 0 * * 4" # every Thursday
29
+ filters:
30
+ branches:
31
+ only:
32
+ - master
33
+ jobs:
34
+ - run-specs-with-postgres
35
+ - run-specs-with-mysql
@@ -0,0 +1,17 @@
1
+ # Number of days of inactivity before an issue becomes stale
2
+ daysUntilStale: 60
3
+ # Number of days of inactivity before a stale issue is closed
4
+ daysUntilClose: 7
5
+ # Issues with these labels will never be considered stale
6
+ exemptLabels:
7
+ - pinned
8
+ - security
9
+ # Label to use when marking an issue as stale
10
+ staleLabel: wontfix
11
+ # Comment to post when marking an issue as stale. Set to `false` to disable
12
+ markComment: >
13
+ This issue has been automatically marked as stale because it has not had
14
+ recent activity. It will be closed if no further activity occurs. Thank you
15
+ for your contributions.
16
+ # Comment to post when closing a stale issue. Set to `false` to disable
17
+ closeComment: false
@@ -0,0 +1,57 @@
1
+ # How to contribute
2
+
3
+ Third-party patches are essential to any great open source project. We want
4
+ to keep it as easy as possible to contribute changes that get things working
5
+ in your environment. There are a few guidelines that we need contributors to
6
+ follow so that we can have a chance of keeping on top of things.
7
+
8
+ ## Getting Started
9
+
10
+ * Make sure you have a [GitHub account](https://github.com/signup/free)
11
+ * Submit a ticket for your issue, assuming one does not already exist.
12
+ * Clearly describe the issue including steps to reproduce when it is a bug.
13
+ * Make sure you fill in the earliest version that you know has the issue.
14
+ * Fork the repository on GitHub
15
+
16
+ ## Making Changes
17
+
18
+ * Create a topic branch from where you want to base your work.
19
+ * This is usually the master branch.
20
+ * Only target release branches if you are certain your fix must be on that
21
+ branch.
22
+ * To quickly create a topic branch based on master; `git branch
23
+ fix/master/my_contribution master` then checkout the new branch with `git
24
+ checkout fix/master/my_contribution`. Please avoid working directly on the
25
+ `master` branch.
26
+ * Make commits of logical units.
27
+ * Check for unnecessary whitespace with `git diff --check` before committing.
28
+ * Make sure your commit messages are in the proper format.
29
+
30
+ ````
31
+ (#99999) Make the example in CONTRIBUTING imperative and concrete
32
+
33
+ Without this patch applied the example commit message in the CONTRIBUTING
34
+ document is not a concrete example. This is a problem because the
35
+ contributor is left to imagine what the commit message should look like
36
+ based on a description rather than an example. This patch fixes the
37
+ problem by making the example concrete and imperative.
38
+
39
+ The first line is a real life imperative statement with a ticket number
40
+ from our issue tracker. The body describes the behavior without the patch,
41
+ why this is a problem, and how the patch fixes the problem when applied.
42
+ ````
43
+
44
+ * Make sure you have added the necessary tests for your changes.
45
+ * Run _all_ the tests to assure nothing else was accidentally broken.
46
+
47
+ ## Submitting Changes
48
+
49
+ * Push your changes to a topic branch in your fork of the repository.
50
+ * Submit a pull request to the extensions repository.
51
+ * Update any Github issues to mark that you have submitted code and are ready for it to be reviewed.
52
+ * Include a link to the pull request in the ticket
53
+
54
+ # Additional Resources
55
+
56
+ * [General GitHub documentation](http://help.github.com/)
57
+ * [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
5
+
6
+ branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
7
+ gem 'solidus', github: 'solidusio/solidus', branch: branch
8
+
9
+ # Provides basic authentication functionality for testing parts of your engine
10
+ gem 'solidus_auth_devise'
11
+
12
+ gem 'factory_bot', '> 4.10.0'
13
+
14
+ case ENV['DB']
15
+ when 'mysql'
16
+ gem 'mysql2'
17
+ when 'postgresql'
18
+ gem 'pg'
19
+ else
20
+ gem 'sqlite3'
21
+ end
22
+
23
+ gem 'solidus_dev_support', github: 'solidusio-contrib/solidus_dev_support'
24
+
25
+ gemspec
@@ -0,0 +1,26 @@
1
+ Copyright (c) <%= Time.now.year %> [name of plugin creator]
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ * Neither the name Spree nor the names of its contributors may be used to
13
+ endorse or promote products derived from this software without specific
14
+ prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,48 @@
1
+ <%= class_name %>
2
+ <%= "=" * class_name.size %>
3
+
4
+ Introduction goes here.
5
+
6
+ Installation
7
+ ------------
8
+
9
+ Add <%= file_name %> to your Gemfile:
10
+
11
+ ```ruby
12
+ gem '<%= file_name %>'
13
+ ```
14
+
15
+ Bundle your dependencies and run the installation generator:
16
+
17
+ ```shell
18
+ bundle
19
+ bundle exec rails g <%= file_name %>:install
20
+ ```
21
+
22
+ Testing
23
+ -------
24
+
25
+ First bundle your dependencies, then run `rake`. `rake` will default to building the dummy app if it does not exist, then it will run specs, and [Rubocop](https://github.com/bbatsov/rubocop) static code analysis. The dummy app can be regenerated by using `rake test_app`.
26
+
27
+ ```shell
28
+ bundle
29
+ bundle exec rake
30
+ ```
31
+
32
+ When testing your application's integration with this extension you may use its factories.
33
+ Simply add this require statement to your spec_helper:
34
+
35
+ ```ruby
36
+ require '<%= file_name %>/factories'
37
+ ```
38
+
39
+ Releasing
40
+ ---------
41
+
42
+ Your new extension version can be released using `gem-release` like this:
43
+
44
+ ```shell
45
+ bundle exec gem bump -v VERSION --tag --push --remote upstream && gem release
46
+ ```
47
+
48
+ Copyright (c) <%= Time.now.year %> [name of extension creator], released under the New BSD License
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler'
4
+
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 # rubocop:disable Rails/RakeEnvironment
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 # rubocop:disable Rails/RakeEnvironment
30
+ ENV['LIB_NAME'] = '<%=file_name%>'
31
+ Rake::Task['extension:test_app'].invoke
32
+ end
@@ -0,0 +1,2 @@
1
+ // Placeholder manifest file.
2
+ // the installer will append this file to the app vendored assets here: vendor/assets/javascripts/spree/backend/all.js'
@@ -0,0 +1,2 @@
1
+ // Placeholder manifest file.
2
+ // the installer will append this file to the app vendored assets here: vendor/assets/javascripts/spree/frontend/all.js'
@@ -0,0 +1,4 @@
1
+ /*
2
+ Placeholder manifest file.
3
+ the installer will append this file to the app vendored assets here: 'vendor/assets/stylesheets/spree/backend/all.css'
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Placeholder manifest file.
3
+ the installer will append this file to the app vendored assets here: 'vendor/assets/stylesheets/spree/frontend/all.css'
4
+ */
@@ -0,0 +1,7 @@
1
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
2
+
3
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
4
+ ENGINE_PATH = File.expand_path('../../lib/<%= file_name -%>/engine', __FILE__)
5
+
6
+ require 'rails/all'
7
+ require 'rails/engine/commands'
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: Hello world
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ Spree::Core::Engine.routes.draw do
4
+ # Add your extension routes here
5
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ $:.push File.expand_path('lib', __dir__)
4
+ require '<%= file_name %>/version'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = '<%= file_name %>'
8
+ s.version = <%= class_name %>::VERSION
9
+ s.summary = 'TODO'
10
+ s.description = 'TODO'
11
+ s.license = 'BSD-3-Clause'
12
+
13
+ # s.author = 'You'
14
+ # s.email = 'you@example.com'
15
+ # s.homepage = 'http://www.example.com'
16
+
17
+ s.files = Dir["{app,config,db,lib}/**/*", 'LICENSE', 'Rakefile', 'README.md']
18
+ s.test_files = Dir['spec/**/*']
19
+
20
+ s.add_dependency 'solidus_core' # Set Solidus version
21
+
22
+ s.add_development_dependency 'solidus_dev_support'
23
+ end
@@ -0,0 +1,5 @@
1
+ bump:
2
+ recurse: false
3
+ file: 'lib/<%=file_name%>/version.rb'
4
+ message: Bump <%=class_name%> to %{version}
5
+ branch: true
@@ -0,0 +1,15 @@
1
+ *.gem
2
+ \#*
3
+ *~
4
+ .#*
5
+ .DS_Store
6
+ .idea
7
+ .project
8
+ .sass-cache
9
+ coverage
10
+ Gemfile.lock
11
+ tmp
12
+ nbproject
13
+ pkg
14
+ *.swp
15
+ spec/dummy
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'solidus_core'
4
+ require '<%=file_name%>/engine'
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module <%= class_name %>
4
+ class Engine < Rails::Engine
5
+ require 'spree/core'
6
+ isolate_namespace Spree
7
+ engine_name '<%= file_name %>'
8
+
9
+ # use rspec for tests
10
+ config.generators do |g|
11
+ g.test_framework :rspec
12
+ end
13
+
14
+ def self.activate
15
+ Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
16
+ Rails.configuration.cache_classes ? require(c) : load(c)
17
+ end
18
+ end
19
+
20
+ config.to_prepare(&method(:activate).to_proc)
21
+ end
22
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ FactoryBot.define do
4
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module <%= class_name %>
4
+ VERSION = '0.0.1'
5
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module <%= class_name %>
4
+ module Generators
5
+ class InstallGenerator < Rails::Generators::Base
6
+ class_option :auto_run_migrations, type: :boolean, default: false
7
+
8
+ def add_javascripts
9
+ append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require spree/frontend/<%= file_name %>\n"
10
+ append_file 'vendor/assets/javascripts/spree/backend/all.js', "//= require spree/backend/<%= file_name %>\n"
11
+ end
12
+
13
+ def add_stylesheets
14
+ inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/frontend/<%= file_name %>\n", before: %r{\*/}, verbose: true
15
+ inject_into_file 'vendor/assets/stylesheets/spree/backend/all.css', " *= require spree/backend/<%= file_name %>\n", before: %r{\*/}, verbose: true
16
+ end
17
+
18
+ def add_migrations
19
+ run 'bundle exec rake railties:install:migrations FROM=<%= file_name %>'
20
+ end
21
+
22
+ def run_migrations
23
+ run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]'))
24
+ if run_migrations
25
+ run 'bundle exec rake db:migrate'
26
+ else
27
+ puts 'Skipping rake db:migrate, don\'t forget to run it!' # rubocop:disable Rails/Output
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,15 @@
1
+ require:
2
+ - solidus_dev_support/rubocop
3
+
4
+ inherit_gem:
5
+ solidus_dev_support: .rubocop.yml
6
+
7
+ AllCops:
8
+ TargetRubyVersion: 2.5
9
+ Exclude:
10
+ - spec/dummy/**/*
11
+ - vendor/**/*
12
+
13
+ Rails/SkipsModelValidations:
14
+ Exclude:
15
+ - db/migrate/**/*
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Configure Rails Environment
4
+ ENV['RAILS_ENV'] = 'test'
5
+
6
+ # Run Coverage report
7
+ require 'solidus_dev_support/rspec/coverage'
8
+
9
+ require File.expand_path('dummy/config/environment.rb', __dir__)
10
+
11
+ # Requires factories and other useful helpers defined in spree_core.
12
+ require 'solidus_dev_support/rspec/feature_helper'
13
+
14
+ # Requires supporting ruby files with custom matchers and macros, etc,
15
+ # in spec/support/ and its subdirectories.
16
+ Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
17
+
18
+ # Requires factories defined in lib/<%= file_name %>/factories.rb
19
+ require '<%= file_name %>/factories'
20
+
21
+ RSpec.configure do |config|
22
+ config.infer_spec_type_from_file_location!
23
+ config.use_transactional_fixtures = false
24
+ end