diff --git a/.circleci/config.yml b/.circleci/config.yml index 12bb10e..e7e2f71 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -16,12 +16,18 @@ jobs: executor: solidusio_extensions/mysql steps: - solidusio_extensions/run-tests + lint-code: + executor: solidusio_extensions/sqlite-memory + steps: + - solidusio_extensions/lint-code workflows: "Run specs on supported Solidus versions": jobs: - run-specs-with-postgres - run-specs-with-mysql + - lint-code + "Weekly run specs against master": triggers: - schedule: diff --git a/.github/stale.yml b/.github/stale.yml index d9f6563..03407b3 100644 --- a/.github/stale.yml +++ b/.github/stale.yml @@ -1,17 +1,17 @@ # Number of days of inactivity before an issue becomes stale daysUntilStale: 60 # Number of days of inactivity before a stale issue is closed -daysUntilClose: 7 +daysUntilClose: false # Issues with these labels will never be considered stale exemptLabels: - pinned - security # Label to use when marking an issue as stale -staleLabel: wontfix +staleLabel: stale # Comment to post when marking an issue as stale. Set to `false` to disable markComment: > This issue has been automatically marked as stale because it has not had - recent activity. It will be closed if no further activity occurs. Thank you + recent activity. It might be closed if no further activity occurs. Thank you for your contributions. # Comment to post when closing a stale issue. Set to `false` to disable -closeComment: false \ No newline at end of file +closeComment: false diff --git a/.github_changelog_generator b/.github_changelog_generator new file mode 100644 index 0000000..eac0962 --- /dev/null +++ b/.github_changelog_generator @@ -0,0 +1,2 @@ +issues=false +exclude-labels=infrastructure diff --git a/.rubocop.yml b/.rubocop.yml index 6207a64..b075a8f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,2 +1,5 @@ require: - solidus_dev_support/rubocop + +AllCops: + NewCops: disable diff --git a/README.md b/README.md index 6b4d579..b1637fe 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ -# SolidusFeeds +# Solidus Feeds +[![CircleCI](https://circleci.com/gh/nebulab/solidus_feeds.svg?style=shield)](https://circleci.com/gh/nebulab/solidus_feeds) +[![codecov](https://codecov.io/gh/nebulab/solidus_feeds/branch/master/graph/badge.svg)](https://codecov.io/gh/nebulab/solidus_feeds) + + A framework for producing and publishing feeds on Solidus. ## Installation @@ -13,12 +17,13 @@ gem 'solidus_feeds' Bundle your dependencies and run the installation generator: ```shell -bundle -bundle exec rails g solidus_feeds:install +bin/rails generate solidus_feeds:install ``` ## Usage + + ⚠️ *This is work in progress, once done the following is expected to be the final interface* ⚠️ Define and publish your own feeds @@ -96,7 +101,6 @@ app if it does not exist, then it will run specs. The dummy app can be regenerat `bin/rake extension:test_app`. ```shell -bundle bin/rake ``` @@ -121,7 +125,7 @@ the sandbox app is `./sandbox` and `bin/rails` will forward any Rails commands t Here's an example: -```shell +``` $ bin/rails server => Booting Puma => Rails 6.0.2.1 application starting in development @@ -129,14 +133,21 @@ $ bin/rails server Use Ctrl-C to stop ``` -### Releasing new versions +### Updating the changelog -Your new extension version can be released using `gem-release` like this: +Before and after releases the changelog should be updated to reflect the up-to-date status of +the project: ```shell -bundle exec gem bump -v VERSION --tag --push --remote upstream && gem release +bin/rake changelog +git add CHANGELOG.md +git commit -m "Update the changelog" ``` +### Releasing new versions + +Please refer to the dedicated [page](https://github.com/solidusio/solidus/wiki/How-to-release-extensions) on Solidus wiki. + ## License Copyright (c) 2020 [name of extension author], released under the New BSD License. diff --git a/bin/rails-sandbox b/bin/rails-sandbox index c89b2ae..ad2df04 100755 --- a/bin/rails-sandbox +++ b/bin/rails-sandbox @@ -5,7 +5,7 @@ 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 + system "#{__dir__}/sandbox" or begin warn 'Automatic creation of the sandbox app failed' exit 1 end diff --git a/bin/sandbox b/bin/sandbox index c3fab47..e377f14 100755 --- a/bin/sandbox +++ b/bin/sandbox @@ -72,9 +72,11 @@ unbundled bundle exec rails generate spree:install \ --user_class=Spree::User \ --enforce_available_locales=true \ --with-authentication=false \ + --payment-method=none \ $@ unbundled bundle exec rails generate solidus:auth:install +unbundled bundle exec rails generate ${extension_name}:install echo echo "🚀 Sandbox app successfully created for $extension_name!" diff --git a/lib/generators/solidus_feeds/install/install_generator.rb b/lib/generators/solidus_feeds/install/install_generator.rb index 9fcbba2..3904140 100644 --- a/lib/generators/solidus_feeds/install/install_generator.rb +++ b/lib/generators/solidus_feeds/install/install_generator.rb @@ -4,15 +4,20 @@ module SolidusFeeds module Generators class InstallGenerator < Rails::Generators::Base class_option :auto_run_migrations, type: :boolean, default: false + source_root File.expand_path('templates', __dir__) + + def copy_initializer + template 'initializer.rb', 'config/initializers/solidus_feeds.rb' + end def add_javascripts - append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require spree/frontend/solidus_feeds\n" # rubocop:disable Metrics/LineLength - append_file 'vendor/assets/javascripts/spree/backend/all.js', "//= require spree/backend/solidus_feeds\n" # rubocop:disable Metrics/LineLength + append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require spree/frontend/solidus_feeds\n" + append_file 'vendor/assets/javascripts/spree/backend/all.js', "//= require spree/backend/solidus_feeds\n" end def add_stylesheets - inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/frontend/solidus_feeds\n", before: %r{\*/}, verbose: true # rubocop:disable Metrics/LineLength - inject_into_file 'vendor/assets/stylesheets/spree/backend/all.css', " *= require spree/backend/solidus_feeds\n", before: %r{\*/}, verbose: true # rubocop:disable Metrics/LineLength + inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/frontend/solidus_feeds\n", before: %r{\*/}, verbose: true # rubocop:disable Layout/LineLength + inject_into_file 'vendor/assets/stylesheets/spree/backend/all.css', " *= require spree/backend/solidus_feeds\n", before: %r{\*/}, verbose: true # rubocop:disable Layout/LineLength end def add_migrations @@ -20,7 +25,7 @@ def add_migrations end def run_migrations - run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]')) # rubocop:disable Metrics/LineLength + run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]')) # rubocop:disable Layout/LineLength if run_migrations run 'bin/rails db:migrate' else diff --git a/lib/generators/solidus_feeds/install/templates/initializer.rb b/lib/generators/solidus_feeds/install/templates/initializer.rb new file mode 100644 index 0000000..f3cf1b4 --- /dev/null +++ b/lib/generators/solidus_feeds/install/templates/initializer.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +SolidusFeeds.configure do |config| + # TODO: Remember to change this with the actual preferences you have implemented! + # config.sample_preference = 'sample_value' +end diff --git a/lib/solidus_feeds.rb b/lib/solidus_feeds.rb index c470541..303c920 100644 --- a/lib/solidus_feeds.rb +++ b/lib/solidus_feeds.rb @@ -3,6 +3,7 @@ require 'solidus_core' require 'solidus_support' +require 'solidus_feeds/configuration' require 'solidus_feeds/version' require 'solidus_feeds/feed' require 'solidus_feeds/feeds' diff --git a/lib/solidus_feeds/configuration.rb b/lib/solidus_feeds/configuration.rb new file mode 100644 index 0000000..b7e9ceb --- /dev/null +++ b/lib/solidus_feeds/configuration.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +module SolidusFeeds + class Configuration + # Define here the settings for this extensions, e.g.: + # + # attr_accessor :my_setting + end + + class << self + def configuration + @configuration ||= Configuration.new + end + + alias config configuration + + def configure + yield configuration + end + end +end diff --git a/lib/solidus_feeds/testing_support/factories.rb b/lib/solidus_feeds/testing_support/factories.rb new file mode 100644 index 0000000..745a01e --- /dev/null +++ b/lib/solidus_feeds/testing_support/factories.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +FactoryBot.define do +end diff --git a/solidus_feeds.gemspec b/solidus_feeds.gemspec index 528ff46..0c3ed44 100644 --- a/solidus_feeds.gemspec +++ b/solidus_feeds.gemspec @@ -31,5 +31,5 @@ Gem::Specification.new do |spec| spec.add_dependency 'solidus_core', ['>= 2.0.0', '< 3'] spec.add_dependency 'solidus_support', '~> 0.5' - spec.add_development_dependency 'solidus_dev_support' + spec.add_development_dependency 'solidus_dev_support', '~> 2.1' end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f94a791..d8b10bb 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -6,22 +6,26 @@ # Run Coverage report require 'solidus_dev_support/rspec/coverage' -require File.expand_path('dummy/config/environment.rb', __dir__).tap { |file| - # Create the dummy app if it's still missing. - system 'bin/rake extension:test_app' unless File.exist? file -} +# Create the dummy app if it's still missing. +dummy_env = "#{__dir__}/dummy/config/environment.rb" +system 'bin/rake extension:test_app' unless File.exist? dummy_env +require dummy_env # Requires factories and other useful helpers defined in spree_core. require 'solidus_dev_support/rspec/feature_helper' # Requires supporting ruby files with custom matchers and macros, etc, # in spec/support/ and its subdirectories. -Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f } +Dir["#{__dir__}/support/**/*.rb"].sort.each { |f| require f } -# Requires factories defined in lib/solidus_feeds/factories.rb -require 'solidus_feeds/factories' +# Requires factories defined in lib/solidus_feeds/testing_support/factories.rb +require 'solidus_feeds/testing_support/factories' RSpec.configure do |config| config.infer_spec_type_from_file_location! config.use_transactional_fixtures = false + + if Spree.solidus_gem_version < Gem::Version.new('2.11') + config.extend Spree::TestingSupport::AuthorizationHelpers::Request, type: :system + end end