diff --git a/.gem_release.yml b/.gem_release.yml new file mode 100644 index 000000000..420d0289c --- /dev/null +++ b/.gem_release.yml @@ -0,0 +1,2 @@ +bump: + file: "lib/spree_i18n/version.rb" diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 452ebb342..c496bc7ad 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,7 +1,11 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file + version: 2 updates: -- package-ecosystem: bundler - directory: "/" - schedule: - interval: daily - open-pull-requests-limit: 10 + - package-ecosystem: "bundler" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "weekly" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..c5cc96d14 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,77 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + tests: + name: Tests (${{ matrix.db }}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + db: [postgres, mysql] + include: + - db: postgres + database_url: postgres://postgres:password@localhost:5432/spree_test + - db: mysql + database_url: mysql2://root:password@127.0.0.1:3306/spree_test + services: + postgres: + image: postgres:16 + env: + POSTGRES_PASSWORD: password + POSTGRES_DB: spree_test + ports: ['5432:5432'] + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + mysql: + image: mysql:8.0 + env: + MYSQL_ROOT_PASSWORD: password + MYSQL_DATABASE: spree_test + ports: ['3306:3306'] + options: >- + --health-cmd "mysqladmin ping -h 127.0.0.1" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + env: + DB: ${{ matrix.db }} + DATABASE_URL: ${{ matrix.database_url }} + RAILS_ENV: test + CI: true + steps: + - uses: actions/checkout@v4 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.3' + bundler-cache: true + - name: Install libvips + run: sudo apt-get update && sudo apt-get install -y libvips + - name: Create test app + run: bundle exec rake test_app + - name: Run specs + run: bundle exec rspec --format progress --format RspecJunitFormatter --out tmp/test-results/rspec.xml + + brakeman: + name: Brakeman + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.3' + bundler-cache: true + - name: Run Brakeman + run: bundle exec brakeman --force --exit-on-warn --exit-on-error diff --git a/.gitignore b/.gitignore index 129258e73..8230fcc3c 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ .idea .localeapp/locales .project +.vscode coverage default Gemfile.lock @@ -18,5 +19,6 @@ spec/dummy public/spree .ruby-version .ruby-gemset -gemfiles/*.gemfile.lock *.gem +*/*.gem +.env diff --git a/.rspec b/.rspec index d72f9515c..b8f148f0e 100644 --- a/.rspec +++ b/.rspec @@ -1,3 +1,2 @@ --color -r spec_helper --f documentation diff --git a/.rubocop.yml b/.rubocop.yml index 8d8a6d4a4..c0e407254 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,7 +1,21 @@ ---- -inherit_from: .hound.yml - AllCops: + DisplayCopNames: true + TargetRubyVersion: 3.2 + Include: + - '**/Gemfile' + - '**/Rakefile' Exclude: - - spec/dummy/**/* - - bin/* + - 'spec/dummy/**/*' + - 'lib/generators/**/*' + - 'bin/*' + +Layout/LineLength: + Max: 150 + +# DISABLED + +Style/Documentation: + Enabled: false + +Style/FrozenStringLiteralComment: + Enabled: false diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 15583c588..000000000 --- a/.travis.yml +++ /dev/null @@ -1,44 +0,0 @@ -os: linux -dist: bionic - -addons: - apt: - sources: - - google-chrome - packages: - - google-chrome-stable - -services: - - mysql - - postgresql - -language: ruby - -rvm: - - 2.7 - - 3.0 - -env: - - DB=mysql - - DB=postgres - -gemfile: - - gemfiles/spree_4_2.gemfile - - gemfiles/spree_master.gemfile - -jobs: - allow_failures: - - gemfile: gemfiles/spree_master.gemfile - -before_install: - - mysql -u root -e "GRANT ALL ON *.* TO 'travis'@'%';" - -before_script: - - CHROME_MAIN_VERSION=`google-chrome-stable --version | sed -E 's/(^Google Chrome |\.[0-9]+ )//g'` - - CHROMEDRIVER_VERSION=`curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_MAIN_VERSION"` - - curl "https://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip" -O - - unzip chromedriver_linux64.zip -d ~/bin - -script: - - bundle exec rake test_app - - bundle exec rake spec diff --git a/Appraisals b/Appraisals deleted file mode 100644 index 828b05768..000000000 --- a/Appraisals +++ /dev/null @@ -1,9 +0,0 @@ -appraise 'spree-4-2' do - gem 'spree', '~> 4.2.0.rc3' - gem 'rails-controller-testing' -end - -appraise 'spree-master' do - gem 'spree', github: 'spree/spree', branch: 'master' - gem 'rails-controller-testing' -end \ No newline at end of file diff --git a/Gemfile b/Gemfile index 66b1b4539..b2132c645 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,29 @@ source 'https://rubygems.org' -gem "rails-controller-testing" -gem 'spree', github: 'spree/spree', branch: 'main' +git_source(:github) do |repo_name| + repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?('/') + "https://github.com/#{repo_name}.git" +end + +gem 'rails-controller-testing' + +spree_opts = if ENV['SPREE_PATH'] + { 'path': ENV['SPREE_PATH'] } + else + { 'github': 'spree/spree', 'branch': 'main' } + end +gem 'spree', spree_opts + +gem 'spree_dev_tools', '>= 0.6.0.rc1' + +if ENV['DB'] == 'mysql' + gem 'mysql2' +elsif ENV['DB'] == 'postgres' + gem 'pg' +else + gem 'sqlite3' +end + +gem 'propshaft' gemspec diff --git a/README.md b/README.md index 244f186dd..4a0d2e67e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # Spree Internationalization -[![Build Status](https://travis-ci.org/spree-contrib/spree_i18n.svg?branch=master)](https://travis-ci.org/spree-contrib/spree_i18n) -[![Code Climate](https://codeclimate.com/github/spree-contrib/spree_i18n/badges/gpa.svg)](https://codeclimate.com/github/spree-contrib/spree_i18n) +[![CI](https://github.com/spree/spree_i18n/actions/workflows/ci.yml/badge.svg)](https://github.com/spree/spree_i18n/actions/workflows/ci.yml) This is the Internationalization project for [Spree Commerce][1] @@ -24,59 +23,56 @@ Spree is developed and maintained by 1. Add this extension to your Gemfile with this line: ```ruby - gem 'spree_i18n' + bundle add spree_i18n ``` -2. Install the gem using Bundler: - ```ruby - bundle install - ``` +2. Run the install generator -3. Copy & run migrations ```ruby bundle exec rails g spree_i18n:install ``` -4. Restart your server +3. Restart your server If your server was running, restart it so that it can find the assets properly. -## Upgrading to 5.0 (only Spree 4.2+) +## Developing -### 1. Remove Asset references +1. Create a dummy app -From `vendor/assets/javascripts/spree/backend/all.js` -``` -//= require spree/backend/spree_i18n -``` + ```bash + bundle update + bundle exec rake test_app + ``` -and from `vendor/assets/javascripts/spree/frontend/all.js` -``` -//= require spree/frontend/spree_i18n -``` +2. Add your new code +3. Run tests -and from `vendor/assets/stylesheets/spree/backend/all.css` -``` -*= require spree/backend/spree_i18n -``` + ```bash + bundle exec rspec + ``` -and from `vendor/assets/stylesheets/spree/frontend/all.css` -``` -*= require spree/backend/spree_i18n +## Releasing a new version + +```shell +bundle exec gem bump -p -t +bundle exec gem release ``` ---- +For more options please see [gem-release README](https://github.com/svenfuchs/gem-release) ## Contributing -[See corresponding guidelines][7] +If you'd like to contribute, please take a look at the +[instructions](CONTRIBUTING.md) for installing dependencies and crafting a good +pull request. --- -Copyright (c) 2010-2015 [Spree Commerce Inc.][1] and other [contributors][5]. released under the [New BSD License][6] +Copyright (c) 2010-2026 [Spree Commerce Inc.][1] and other [contributors][5], released under the [New BSD License][6] [1]: https://spreecommerce.org [2]: https://spreecommerce.org/docs/developer/core-concepts/i18n#internationalization -[5]: https://github.com/spree-contrib/spree_i18n/graphs/contributors -[6]: https://github.com/spree-contrib/spree_i18n/blob/master/LICENSE.md -[7]: https://github.com/spree-contrib/spree_i18n/blob/master/CONTRIBUTING.md +[5]: https://github.com/spree/spree_i18n/graphs/contributors +[6]: https://github.com/spree/spree_i18n/blob/main/LICENSE.md +[7]: https://github.com/spree/spree_i18n/blob/main/CONTRIBUTING.md diff --git a/Rakefile b/Rakefile index a7315330f..df64dbb98 100644 --- a/Rakefile +++ b/Rakefile @@ -1,28 +1,23 @@ -require 'rubygems' -require 'bundler/setup' -require 'rake' -require 'rake/testtask' -require 'rake/packagetask' -require 'rubygems/package_task' -require 'rspec/core/rake_task' -require 'spree/testing_support/common_rake' -require 'spree_i18n' - +require 'bundler' Bundler::GemHelper.install_tasks -RSpec::Core::RakeTask.new -task default: :spec +require 'rspec/core/rake_task' +require 'spree/testing_support/extension_rake' -spec = eval(File.read('spree_i18n.gemspec')) +RSpec::Core::RakeTask.new -Gem::PackageTask.new(spec) do |p| - p.gem_spec = spec +task :default do + if Dir['spec/dummy'].empty? + Rake::Task[:test_app].invoke + Dir.chdir('../../') + end + Rake::Task[:spec].invoke end desc 'Generates a dummy app for testing' task :test_app do ENV['LIB_NAME'] = 'spree_i18n' - Rake::Task['common:test_app'].invoke + Rake::Task['extension:test_app'].execute end namespace :spree_i18n do diff --git a/bin/rails b/bin/rails index b52647766..c81cbae12 100755 --- a/bin/rails +++ b/bin/rails @@ -1,4 +1,5 @@ #!/usr/bin/env ruby +# This command will automatically be run when you run "rails" from the root of your extension ENGINE_ROOT = File.expand_path('../..', __FILE__) ENGINE_PATH = File.expand_path('../../lib/spree_i18n/engine', __FILE__) diff --git a/gemfiles/spree_4_2.gemfile b/gemfiles/spree_4_2.gemfile deleted file mode 100644 index 11901f088..000000000 --- a/gemfiles/spree_4_2.gemfile +++ /dev/null @@ -1,8 +0,0 @@ -# This file was generated by Appraisal - -source "https://rubygems.org" - -gem "rails-controller-testing" -gem "spree", "~> 4.2.0.rc3" - -gemspec path: "../" diff --git a/gemfiles/spree_master.gemfile b/gemfiles/spree_master.gemfile deleted file mode 100644 index c3f8398e5..000000000 --- a/gemfiles/spree_master.gemfile +++ /dev/null @@ -1,8 +0,0 @@ -# This file was generated by Appraisal - -source "https://rubygems.org" - -gem "rails-controller-testing" -gem "spree", github: "spree/spree", branch: "master" - -gemspec path: "../" diff --git a/lib/spree_i18n/version.rb b/lib/spree_i18n/version.rb index 0de4145ce..8bc8c3be0 100644 --- a/lib/spree_i18n/version.rb +++ b/lib/spree_i18n/version.rb @@ -1,17 +1,11 @@ module SpreeI18n + VERSION = '5.3.2'.freeze + module_function # Returns the version of the currently loaded SpreeI18n as a # Gem::Version. def version - Gem::Version.new Version::STRING - end - - module Version - MAJOR = 5 - MINOR = 3 - TINY = 2 - - STRING = [MAJOR, MINOR, TINY].compact.join('.') + Gem::Version.new(VERSION) end end diff --git a/spree_i18n.gemspec b/spree_i18n.gemspec index 908afe36c..ce1b817a7 100644 --- a/spree_i18n.gemspec +++ b/spree_i18n.gemspec @@ -1,4 +1,4 @@ -# coding: utf-8 +# encoding: UTF-8 lib = File.expand_path('../lib/', __FILE__) $LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib) @@ -7,25 +7,35 @@ require 'spree_i18n/version' Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = 'spree_i18n' - s.version = SpreeI18n.version - s.summary = 'Provides locale information for use in Spree.' - s.description = s.summary + s.version = SpreeI18n::VERSION + s.summary = 'Provides locale information and translations for Spree Commerce.' + s.description = 'Adds locale files, country/language names and translation tooling for internationalizing Spree Commerce stores.' + s.required_ruby_version = '>= 3.2' - s.author = 'Sean Schofield' - s.email = 'sean.schofield@gmail.com' - s.homepage = 'http://spreecommerce.com' - s.license = 'BSD-3' + s.author = 'Vendo Connect Inc.' + s.email = 'hello@spreecommerce.org' + s.homepage = 'https://github.com/spree/spree_i18n' + s.license = 'BSD-3-Clause' - s.files = `git ls-files`.split("\n") - s.test_files = `git ls-files -- spec/*`.split("\n") + s.metadata = { + 'bug_tracker_uri' => 'https://github.com/spree/spree_i18n/issues', + 'changelog_uri' => "https://github.com/spree/spree_i18n/releases/tag/v#{s.version}", + 'documentation_uri' => 'https://docs.spreecommerce.org/', + 'source_code_uri' => "https://github.com/spree/spree_i18n/tree/v#{s.version}" + } + + s.files = Dir["{app,config,db,lib,vendor}/**/*", "LICENSE.md", "Rakefile", "README.md"].reject { |f| f.match(/^spec/) && !f.match(/^spec\/fixtures/) } s.require_path = 'lib' s.requirements << 'none' - s.add_runtime_dependency 'i18n_data' - s.add_runtime_dependency 'rails-i18n' - s.add_runtime_dependency 'kaminari-i18n' - s.add_runtime_dependency 'spree_core', '>= 4.2.0.rc3' - s.add_runtime_dependency 'spree_extension' + spree_version = '>= 5.4.0.alpha' + s.add_dependency 'spree_core', spree_version + s.add_dependency 'spree_extension' + + s.add_dependency 'i18n_data' + s.add_dependency 'rails-i18n' + s.add_dependency 'kaminari-i18n' s.add_development_dependency 'spree_dev_tools' + s.add_development_dependency 'i18n-tasks' end