From bbff144004b6e162d9a27720b975a4953182da70 Mon Sep 17 00:00:00 2001 From: Grey Baker Date: Mon, 11 Sep 2017 22:03:14 +0100 Subject: Bump rails from 5.1.3 to 5.1.4 (#4875) Bumps [rails](https://github.com/rails/rails) from 5.1.3 to 5.1.4. - [Commits](https://github.com/rails/rails/compare/v5.1.3...v5.1.4) --- Gemfile.lock | 74 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 37 insertions(+), 37 deletions(-) (limited to 'Gemfile.lock') diff --git a/Gemfile.lock b/Gemfile.lock index ddb97dd94..b5a0df3ea 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,25 +1,25 @@ GEM remote: https://rubygems.org/ specs: - actioncable (5.1.3) - actionpack (= 5.1.3) + actioncable (5.1.4) + actionpack (= 5.1.4) nio4r (~> 2.0) websocket-driver (~> 0.6.1) - actionmailer (5.1.3) - actionpack (= 5.1.3) - actionview (= 5.1.3) - activejob (= 5.1.3) + actionmailer (5.1.4) + actionpack (= 5.1.4) + actionview (= 5.1.4) + activejob (= 5.1.4) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.1.3) - actionview (= 5.1.3) - activesupport (= 5.1.3) + actionpack (5.1.4) + actionview (= 5.1.4) + activesupport (= 5.1.4) rack (~> 2.0) - rack-test (~> 0.6.3) + rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.1.3) - activesupport (= 5.1.3) + actionview (5.1.4) + activesupport (= 5.1.4) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) @@ -30,16 +30,16 @@ GEM case_transform (>= 0.2) jsonapi-renderer (>= 0.1.1.beta1, < 0.2) active_record_query_trace (1.5.4) - activejob (5.1.3) - activesupport (= 5.1.3) + activejob (5.1.4) + activesupport (= 5.1.4) globalid (>= 0.3.6) - activemodel (5.1.3) - activesupport (= 5.1.3) - activerecord (5.1.3) - activemodel (= 5.1.3) - activesupport (= 5.1.3) + activemodel (5.1.4) + activesupport (= 5.1.4) + activerecord (5.1.4) + activemodel (= 5.1.4) + activesupport (= 5.1.4) arel (~> 8.0) - activesupport (5.1.3) + activesupport (5.1.4) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (~> 0.7) minitest (~> 5.1) @@ -334,20 +334,20 @@ GEM rack-cors (0.4.1) rack-protection (2.0.0) rack - rack-test (0.6.3) - rack (>= 1.0) + rack-test (0.7.0) + rack (>= 1.0, < 3) rack-timeout (0.4.2) - rails (5.1.3) - actioncable (= 5.1.3) - actionmailer (= 5.1.3) - actionpack (= 5.1.3) - actionview (= 5.1.3) - activejob (= 5.1.3) - activemodel (= 5.1.3) - activerecord (= 5.1.3) - activesupport (= 5.1.3) + rails (5.1.4) + actioncable (= 5.1.4) + actionmailer (= 5.1.4) + actionpack (= 5.1.4) + actionview (= 5.1.4) + activejob (= 5.1.4) + activemodel (= 5.1.4) + activerecord (= 5.1.4) + activesupport (= 5.1.4) bundler (>= 1.3.0) - railties (= 5.1.3) + railties (= 5.1.4) sprockets-rails (>= 2.0.0) rails-controller-testing (1.0.2) actionpack (~> 5.x, >= 5.0.1) @@ -363,9 +363,9 @@ GEM railties (~> 5.0) rails-settings-cached (0.6.6) rails (>= 4.2.0) - railties (5.1.3) - actionpack (= 5.1.3) - activesupport (= 5.1.3) + railties (5.1.4) + actionpack (= 5.1.4) + activesupport (= 5.1.4) method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) @@ -472,7 +472,7 @@ GEM sprockets (3.7.1) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (3.2.0) + sprockets-rails (3.2.1) actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) @@ -588,7 +588,7 @@ DEPENDENCIES rack-attack (~> 5.0) rack-cors (~> 0.4) rack-timeout (~> 0.4) - rails (~> 5.1.0) + rails (~> 5.1.4) rails-controller-testing (~> 1.0) rails-i18n (~> 5.0) rails-settings-cached (~> 0.6) -- cgit From a6a206ef850da46a1fbdf262fe4527a44f2ceb0f Mon Sep 17 00:00:00 2001 From: Grey Baker Date: Mon, 11 Sep 2017 22:43:19 +0100 Subject: Bump puma from 3.9.1 to 3.10.0 (#4879) Bumps [puma](https://github.com/puma/puma) from 3.9.1 to 3.10.0. - [Release notes](https://github.com/puma/puma/releases/tag/v3.10.0) - [Changelog](https://github.com/puma/puma/blob/master/History.md) - [Commits](https://github.com/puma/puma/compare/v3.9.1...v3.10.0) --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'Gemfile.lock') diff --git a/Gemfile b/Gemfile index a4799a1bf..051f09f78 100644 --- a/Gemfile +++ b/Gemfile @@ -5,7 +5,7 @@ ruby '>= 2.3.0', '< 2.5.0' gem 'pkg-config', '~> 1.2' -gem 'puma', '~> 3.8' +gem 'puma', '~> 3.10' gem 'rails', '~> 5.1.4' gem 'uglifier', '~> 3.2' diff --git a/Gemfile.lock b/Gemfile.lock index b5a0df3ea..31893dc3f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -323,7 +323,7 @@ GEM pry-rails (0.3.6) pry (>= 0.10.4) public_suffix (3.0.0) - puma (3.9.1) + puma (3.10.0) pundit (1.1.0) activesupport (>= 3.0.0) rabl (0.13.1) @@ -582,7 +582,7 @@ DEPENDENCIES pghero (~> 1.7) pkg-config (~> 1.2) pry-rails (~> 0.3) - puma (~> 3.8) + puma (~> 3.10) pundit (~> 1.1) rabl (~> 0.13) rack-attack (~> 5.0) -- cgit From 48d77ea1ebd6096a6ad5e265d99fa20e7a965276 Mon Sep 17 00:00:00 2001 From: Akihiko Odaki Date: Sat, 16 Sep 2017 21:59:41 +0900 Subject: Fix filterable_languages method of SettingsHelper (#4966) --- Gemfile | 2 +- Gemfile.lock | 4 ++-- app/helpers/settings_helper.rb | 2 +- app/lib/language_detector.rb | 39 ++++++++++++++----------------- app/services/post_status_service.rb | 6 +---- spec/lib/language_detector_spec.rb | 34 +++++++++++++-------------- spec/services/post_status_service_spec.rb | 9 +++---- 7 files changed, 43 insertions(+), 53 deletions(-) (limited to 'Gemfile.lock') diff --git a/Gemfile b/Gemfile index 051f09f78..4f4861913 100644 --- a/Gemfile +++ b/Gemfile @@ -25,7 +25,7 @@ gem 'bootsnap' gem 'browser' gem 'charlock_holmes', '~> 0.7.5' gem 'iso-639' -gem 'cld3', '~> 3.1' +gem 'cld3', '~> 3.2.0' gem 'devise', '~> 4.2' gem 'devise-two-factor', '~> 3.0' gem 'doorkeeper', '~> 4.2' diff --git a/Gemfile.lock b/Gemfile.lock index 31893dc3f..f080f15e5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -110,7 +110,7 @@ GEM activesupport charlock_holmes (0.7.5) chunky_png (1.3.8) - cld3 (3.1.3) + cld3 (3.2.0) ffi (>= 1.1.0, < 1.10.0) climate_control (0.2.0) cocaine (0.5.8) @@ -541,7 +541,7 @@ DEPENDENCIES capistrano-yarn (~> 2.0) capybara (~> 2.14) charlock_holmes (~> 0.7.5) - cld3 (~> 3.1) + cld3 (~> 3.2.0) climate_control (~> 0.2) devise (~> 4.2) devise-two-factor (~> 3.0) diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb index 369a45680..14776b354 100644 --- a/app/helpers/settings_helper.rb +++ b/app/helpers/settings_helper.rb @@ -41,7 +41,7 @@ module SettingsHelper end def filterable_languages - I18n.available_locales.map { |locale| locale.to_s.split('-').first.to_sym }.uniq + LanguageDetector.instance.language_names.select(&HUMAN_LOCALES.method(:key?)) end def hash_to_object(hash) diff --git a/app/lib/language_detector.rb b/app/lib/language_detector.rb index 1d9932b52..a42460e10 100644 --- a/app/lib/language_detector.rb +++ b/app/lib/language_detector.rb @@ -1,26 +1,31 @@ # frozen_string_literal: true class LanguageDetector - attr_reader :text, :account + include Singleton - def initialize(text, account = nil) - @text = text - @account = account + def initialize @identifier = CLD3::NNetLanguageIdentifier.new(1, 2048) end - def to_iso_s - detected_language_code || default_locale + def detect(text, account) + detect_language_code(text) || default_locale(account) end - def prepared_text - simplified_text.strip + def language_names + @language_names = + CLD3::TaskContextParams::LANGUAGE_NAMES.map { |name| iso6391(name.to_s).to_sym } + .uniq end private - def detected_language_code - iso6391(result.language).to_sym if detected_language_reliable? + def prepare_text(text) + simplify_text(text).strip + end + + def detect_language_code(text) + result = @identifier.find_language(prepare_text(text)) + iso6391(result.language.to_s).to_sym if result.reliable? end def iso6391(bcp47) @@ -32,15 +37,7 @@ class LanguageDetector ISO_639.find(iso639).alpha2 end - def result - @result ||= @identifier.find_language(prepared_text) - end - - def detected_language_reliable? - result.reliable? - end - - def simplified_text + def simplify_text(text) text.dup.tap do |new_text| new_text.gsub!(FetchLinkCardService::URL_PATTERN, '') new_text.gsub!(Account::MENTION_RE, '') @@ -49,7 +46,7 @@ class LanguageDetector end end - def default_locale - account&.user_locale&.to_sym || nil + def default_locale(account) + account.user_locale&.to_sym end end diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb index 97c55c4b2..e37cd94df 100644 --- a/app/services/post_status_service.rb +++ b/app/services/post_status_service.rb @@ -28,7 +28,7 @@ class PostStatusService < BaseService sensitive: options[:sensitive], spoiler_text: options[:spoiler_text] || '', visibility: options[:visibility] || account.user&.setting_default_privacy, - language: detect_language_for(text, account), + language: LanguageDetector.instance.detect(text, account), application: options[:application]) attach_media(status, media) @@ -69,10 +69,6 @@ class PostStatusService < BaseService media.update(status_id: status.id) end - def detect_language_for(text, account) - LanguageDetector.new(text, account).to_iso_s - end - def process_mentions_service @process_mentions_service ||= ProcessMentionsService.new end diff --git a/spec/lib/language_detector_spec.rb b/spec/lib/language_detector_spec.rb index ec39cb6a0..d17026511 100644 --- a/spec/lib/language_detector_spec.rb +++ b/spec/lib/language_detector_spec.rb @@ -3,10 +3,10 @@ require 'rails_helper' describe LanguageDetector do - describe 'prepared_text' do + describe 'prepare_text' do it 'returns unmodified string without special cases' do string = 'just a regular string' - result = described_class.new(string).prepared_text + result = described_class.instance.send(:prepare_text, string) expect(result).to eq string end @@ -14,33 +14,35 @@ describe LanguageDetector do it 'collapses spacing in strings' do string = 'The formatting in this is very odd' - result = described_class.new(string).prepared_text + result = described_class.instance.send(:prepare_text, string) expect(result).to eq 'The formatting in this is very odd' end it 'strips usernames from strings before detection' do string = '@username Yeah, very surreal...! also @friend' - result = described_class.new(string).prepared_text + result = described_class.instance.send(:prepare_text, string) expect(result).to eq 'Yeah, very surreal...! also' end it 'strips URLs from strings before detection' do string = 'Our website is https://example.com and also http://localhost.dev' - result = described_class.new(string).prepared_text + result = described_class.instance.send(:prepare_text, string) expect(result).to eq 'Our website is and also' end it 'strips #hashtags from strings before detection' do string = 'Hey look at all the #animals and #fish' - result = described_class.new(string).prepared_text + result = described_class.instance.send(:prepare_text, string) expect(result).to eq 'Hey look at all the and' end end - describe 'to_iso_s' do + describe 'detect' do + let(:account_without_user_locale) { Fabricate(:user, locale: nil).account } + it 'detects english language for basic strings' do strings = [ "Hello and welcome to mastodon how are you today?", @@ -48,7 +50,7 @@ describe LanguageDetector do "a lot of people just want to feel righteous all the time and that's all that matters", ] strings.each do |string| - result = described_class.new(string).to_iso_s + result = described_class.instance.detect(string, account_without_user_locale) expect(result).to eq(:en), string end @@ -56,14 +58,14 @@ describe LanguageDetector do it 'detects spanish language' do string = 'Obtener un Hola y bienvenidos a Mastodon' - result = described_class.new(string).to_iso_s + result = described_class.instance.detect(string, account_without_user_locale) expect(result).to eq :es end describe 'when language can\'t be detected' do it 'uses nil when sent an empty document' do - result = described_class.new('').to_iso_s + result = described_class.instance.detect('', account_without_user_locale) expect(result).to eq nil end @@ -73,7 +75,7 @@ describe LanguageDetector do cld_result = CLD3::NNetLanguageIdentifier.new(0, 2048).find_language(string) expect(cld_result).not_to eq :en - result = described_class.new(string).to_iso_s + result = described_class.instance.detect(string, account_without_user_locale) expect(result).to eq nil end @@ -82,14 +84,13 @@ describe LanguageDetector do describe 'with an account' do it 'uses the account locale when present' do account = double(user_locale: 'fr') - result = described_class.new('', account).to_iso_s + result = described_class.instance.detect('', account) expect(result).to eq :fr end it 'uses nil when account is present but has no locale' do - account = double(user_locale: nil) - result = described_class.new('', account).to_iso_s + result = described_class.instance.detect('', account_without_user_locale) expect(result).to eq nil end @@ -97,8 +98,7 @@ describe LanguageDetector do describe 'with an `en` default locale' do it 'uses nil for undetectable string' do - string = '' - result = described_class.new(string).to_iso_s + result = described_class.instance.detect('', account_without_user_locale) expect(result).to eq nil end @@ -114,7 +114,7 @@ describe LanguageDetector do it 'uses nil for undetectable string' do string = '' - result = described_class.new(string).to_iso_s + result = described_class.instance.detect(string, account_without_user_locale) expect(result).to eq nil end diff --git a/spec/services/post_status_service_spec.rb b/spec/services/post_status_service_spec.rb index 4182c4e1f..91902ff69 100644 --- a/spec/services/post_status_service_spec.rb +++ b/spec/services/post_status_service_spec.rb @@ -65,15 +65,12 @@ RSpec.describe PostStatusService do end it 'creates a status with a language set' do - detector = double(to_iso_s: :en) - allow(LanguageDetector).to receive(:new).and_return(detector) - account = Fabricate(:account) - text = 'test status text' + text = 'This is an English text.' - subject.call(account, text) + status = subject.call(account, text) - expect(LanguageDetector).to have_received(:new).with(text, account) + expect(status.language).to eq 'en' end it 'processes mentions' do -- cgit From 66be6475b643009bb13c1de7b6225d659f9e5112 Mon Sep 17 00:00:00 2001 From: Daigo 3 Dango Date: Sun, 17 Sep 2017 16:55:57 -1000 Subject: Bump ruby version to 2.4.2 (#4958) * Bump ruby version to 2.4.2 https://www.ruby-lang.org/en/news/2017/09/14/ruby-2-4-2-released/ Gemfile.lock is also updated. TODO - [ ] Update Dockerfile with Alpine release of ruby-2.4.2 * Revert jwt version It seems that jwt 2.0.0 fails in some environment. ref. https://github.com/zaru/webpush/issues/42 * Bump Ruby version on docker image --- .ruby-version | 2 +- .travis.yml | 2 +- Dockerfile | 2 +- Gemfile.lock | 92 ++++++++++++++++++++++++++++++----------------------------- 4 files changed, 50 insertions(+), 48 deletions(-) (limited to 'Gemfile.lock') diff --git a/.ruby-version b/.ruby-version index 005119baa..8e8299dcc 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.4.1 +2.4.2 diff --git a/.travis.yml b/.travis.yml index d5b51fcb0..71a117810 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,7 +37,7 @@ addons: rvm: - 2.3.4 - - 2.4.1 + - 2.4.2 services: - redis-server diff --git a/Dockerfile b/Dockerfile index 15138065b..3ad2ad7ef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:2.4.1-alpine3.6 +FROM ruby:2.4.2-alpine3.6 LABEL maintainer="https://github.com/tootsuite/mastodon" \ description="A GNU Social-compatible microblogging server" diff --git a/Gemfile.lock b/Gemfile.lock index f080f15e5..97db3aa9a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -57,33 +57,33 @@ GEM encryptor (~> 3.0.0) av (0.9.0) cocaine (~> 0.5.3) - aws-sdk (2.10.21) - aws-sdk-resources (= 2.10.21) - aws-sdk-core (2.10.21) + aws-sdk (2.10.46) + aws-sdk-resources (= 2.10.46) + aws-sdk-core (2.10.46) aws-sigv4 (~> 1.0) jmespath (~> 1.0) - aws-sdk-resources (2.10.21) - aws-sdk-core (= 2.10.21) - aws-sigv4 (1.0.1) + aws-sdk-resources (2.10.46) + aws-sdk-core (= 2.10.46) + aws-sigv4 (1.0.2) bcrypt (3.1.11) - better_errors (2.1.1) + better_errors (2.3.0) coderay (>= 1.0.0) - erubis (>= 2.6.6) + erubi (>= 1.0.0) rack (>= 0.9.0) binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) - bootsnap (1.1.2) + bootsnap (1.1.3) msgpack (~> 1.0) brakeman (3.7.2) - browser (2.4.0) + browser (2.5.1) builder (3.2.3) - bullet (5.5.1) + bullet (5.6.1) activesupport (>= 3.0.0) uniform_notifier (~> 1.10.0) bundler-audit (0.6.0) bundler (~> 1.2) thor (~> 0.18) - capistrano (3.8.2) + capistrano (3.9.1) airbrussh (>= 1.0.0) i18n rake (>= 10.0.0) @@ -99,9 +99,9 @@ GEM sshkit (~> 1.3) capistrano-yarn (2.0.2) capistrano (~> 3.0) - capybara (2.14.4) + capybara (2.15.1) addressable - mime-types (>= 1.16) + mini_mime (>= 0.1.3) nokogiri (>= 1.3.3) rack (>= 1.0.0) rack-test (>= 0.5.4) @@ -115,7 +115,7 @@ GEM climate_control (0.2.0) cocaine (0.5.8) climate_control (>= 0.0.3, < 1.0) - coderay (1.1.1) + coderay (1.1.2) colorize (0.8.1) concurrent-ruby (1.0.5) connection_pool (2.2.1) @@ -151,13 +151,12 @@ GEM thread_safe encryptor (3.0.0) erubi (1.6.1) - erubis (2.7.0) et-orbi (1.0.5) tzinfo - excon (0.58.0) + excon (0.59.0) execjs (2.7.0) - fabrication (2.16.2) - faker (1.7.3) + fabrication (2.16.3) + faker (1.8.4) i18n (~> 0.5) fast_blank (1.0.0) ffi (1.9.18) @@ -194,7 +193,7 @@ GEM railties (>= 4.0.1) hamster (3.0.0) concurrent-ruby (~> 1.0) - hashdiff (0.3.5) + hashdiff (0.3.6) highline (1.7.8) hiredis (0.6.1) hkdf (0.3.0) @@ -213,11 +212,11 @@ GEM colorize rack i18n (0.8.6) - i18n-tasks (0.9.16) + i18n-tasks (0.9.18) activesupport (>= 4.0.2) ast (>= 2.1.0) easy_translate (>= 0.5.0) - erubis + erubi highline (>= 1.7.3) i18n parser (>= 2.2.3.0) @@ -231,7 +230,7 @@ GEM json-ld (2.1.5) multi_json (~> 1.12) rdf (~> 2.2) - json-ld-preloaded (2.2.1) + json-ld-preloaded (2.2.2) json-ld (~> 2.1, >= 2.1.5) multi_json (~> 1.11) rdf (~> 2.2) @@ -258,10 +257,11 @@ GEM letter_opener (~> 1.0) railties (>= 3.2) link_header (0.0.8) - lograge (0.5.1) + lograge (0.6.0) actionpack (>= 4, < 5.2) activesupport (>= 4, < 5.2) railties (>= 4, < 5.2) + request_store (~> 1.0) loofah (2.0.3) nokogiri (>= 1.5.9) mail (2.6.6) @@ -276,27 +276,28 @@ GEM mime-types-data (~> 3.2015) mime-types-data (3.2016.0521) mimemagic (0.3.2) + mini_mime (0.1.4) mini_portile2 (2.2.0) minitest (5.10.3) msgpack (1.1.0) - multi_json (1.12.1) + multi_json (1.12.2) net-scp (1.2.1) net-ssh (>= 2.6.5) - net-ssh (4.1.0) + net-ssh (4.2.0) nio4r (2.1.0) nokogiri (1.8.0) mini_portile2 (~> 2.2.0) nokogumbo (1.4.13) nokogiri - oj (3.3.4) - openssl (2.0.4) + oj (3.3.5) + openssl (2.0.5) orm_adapter (0.5.0) ostatus2 (2.0.1) addressable (~> 2.4) http (~> 2.0) nokogiri (~> 1.6) openssl (~> 2.0) - ox (2.5.0) + ox (2.6.0) paperclip (5.1.0) activemodel (>= 4.2.0) activesupport (>= 4.2.0) @@ -306,15 +307,15 @@ GEM paperclip-av-transcoder (0.6.4) av (~> 0.9.0) paperclip (>= 2.5.2) - parallel (1.11.2) - parallel_tests (2.14.2) + parallel (1.12.0) + parallel_tests (2.15.0) parallel parser (2.4.0.0) ast (~> 2.2) pg (0.21.0) pghero (1.7.0) activerecord - pkg-config (1.2.4) + pkg-config (1.2.7) powerpack (0.1.1) pry (0.10.4) coderay (~> 1.1.0) @@ -371,8 +372,8 @@ GEM thor (>= 0.18.1, < 2.0) rainbow (2.2.2) rake - rake (12.0.0) - rdf (2.2.8) + rake (12.1.0) + rdf (2.2.9) hamster (~> 3.0) link_header (~> 0.0, >= 0.0.8) rdf-normalize (0.3.2) @@ -396,6 +397,7 @@ GEM redis-store (>= 1.2, < 2) redis-store (1.3.0) redis (>= 2.2) + request_store (1.3.2) responders (2.4.0) actionpack (>= 4.2.0, < 5.3) railties (>= 4.2.0, < 5.3) @@ -410,7 +412,7 @@ GEM rspec-mocks (3.6.0) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.6.0) - rspec-rails (3.6.0) + rspec-rails (3.6.1) actionpack (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) @@ -422,15 +424,15 @@ GEM rspec-core (~> 3.0, >= 3.0.0) sidekiq (>= 2.4.0) rspec-support (3.6.0) - rubocop (0.49.1) + rubocop (0.50.0) parallel (~> 1.10) parser (>= 2.3.3.1, < 3.0) powerpack (~> 0.1) - rainbow (>= 1.99.1, < 3.0) + rainbow (>= 2.2.2, < 3.0) ruby-progressbar (~> 1.7) unicode-display_width (~> 1.0, >= 1.0.1) ruby-oembed (0.12.0) - ruby-progressbar (1.8.1) + ruby-progressbar (1.8.3) rufus-scheduler (3.4.2) et-orbi (~> 1.0) safe_yaml (1.0.4) @@ -438,7 +440,7 @@ GEM crass (~> 1.0.2) nokogiri (>= 1.4.4) nokogumbo (~> 1.4.1) - sass (3.4.24) + sass (3.4.25) scss_lint (0.54.0) rake (>= 0.9, < 13) sass (~> 3.4.20) @@ -450,12 +452,12 @@ GEM sidekiq-bulk (0.1.1) activesupport sidekiq - sidekiq-scheduler (2.1.8) + sidekiq-scheduler (2.1.9) redis (~> 3) rufus-scheduler (~> 3.2) sidekiq (>= 3) tilt (>= 1.4.0) - sidekiq-unique-jobs (5.0.9) + sidekiq-unique-jobs (5.0.10) sidekiq (>= 4.0, <= 6.0) thor (~> 0) simple-navigation (4.0.5) @@ -463,11 +465,11 @@ GEM simple_form (3.5.0) actionpack (> 4, < 5.2) activemodel (> 4, < 5.2) - simplecov (0.14.1) + simplecov (0.15.1) docile (~> 1.1.0) json (>= 1.8, < 3) simplecov-html (~> 0.10.0) - simplecov-html (0.10.1) + simplecov-html (0.10.2) slop (3.6.0) sprockets (3.7.1) concurrent-ruby (~> 1.0) @@ -476,7 +478,7 @@ GEM actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - sshkit (1.13.1) + sshkit (1.14.0) net-scp (>= 1.1.2) net-ssh (>= 2.8.0) statsd-instrument (2.1.4) @@ -620,7 +622,7 @@ DEPENDENCIES webpush RUBY VERSION - ruby 2.4.1p111 + ruby 2.4.2p198 BUNDLED WITH 1.15.4 -- cgit From b982d549f440cfebadd5dc8d300a506df213bfee Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Mon, 25 Sep 2017 02:11:14 +0200 Subject: Add strong_migrations gem to warn when creating unsafe migrations (#5078) --- Gemfile | 1 + Gemfile.lock | 3 +++ config/initializers/strong_migrations.rb | 3 +++ 3 files changed, 7 insertions(+) create mode 100644 config/initializers/strong_migrations.rb (limited to 'Gemfile.lock') diff --git a/Gemfile b/Gemfile index 4f4861913..6c31e8932 100644 --- a/Gemfile +++ b/Gemfile @@ -105,6 +105,7 @@ group :development do gem 'brakeman', '~> 3.6', require: false gem 'bundler-audit', '~> 0.5', require: false gem 'scss_lint', '~> 0.53', require: false + gem 'strong_migrations' gem 'capistrano', '~> 3.8' gem 'capistrano-rails', '~> 1.2' diff --git a/Gemfile.lock b/Gemfile.lock index 97db3aa9a..b29d32400 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -482,6 +482,8 @@ GEM net-scp (>= 1.1.2) net-ssh (>= 2.8.0) statsd-instrument (2.1.4) + strong_migrations (0.1.9) + activerecord (>= 3.2.0) temple (0.8.0) terminal-table (1.8.0) unicode-display_width (~> 1.1, >= 1.1.1) @@ -614,6 +616,7 @@ DEPENDENCIES simplecov (~> 0.14) sprockets-rails (~> 3.2) statsd-instrument (~> 2.1) + strong_migrations twitter-text (~> 1.14) tzinfo-data (~> 1.2017) uglifier (~> 3.2) diff --git a/config/initializers/strong_migrations.rb b/config/initializers/strong_migrations.rb new file mode 100644 index 000000000..3d7beac9f --- /dev/null +++ b/config/initializers/strong_migrations.rb @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +StrongMigrations.start_after = 20170924022025 if Rails.env.development? -- cgit From 6e83b5e719cf58a554681859c0b74df626bb66a1 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 27 Sep 2017 03:13:09 +0200 Subject: Update brakeman to 3.0 and bundler-audit to 0.6 (#5117) --- Gemfile | 4 ++-- Gemfile.lock | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'Gemfile.lock') diff --git a/Gemfile b/Gemfile index 6c31e8932..248171680 100644 --- a/Gemfile +++ b/Gemfile @@ -102,8 +102,8 @@ group :development do gem 'letter_opener', '~> 1.4' gem 'letter_opener_web', '~> 1.3' gem 'rubocop', require: false - gem 'brakeman', '~> 3.6', require: false - gem 'bundler-audit', '~> 0.5', require: false + gem 'brakeman', '~> 4.0', require: false + gem 'bundler-audit', '~> 0.6', require: false gem 'scss_lint', '~> 0.53', require: false gem 'strong_migrations' diff --git a/Gemfile.lock b/Gemfile.lock index b29d32400..89ee34cb6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -74,7 +74,7 @@ GEM debug_inspector (>= 0.0.1) bootsnap (1.1.3) msgpack (~> 1.0) - brakeman (3.7.2) + brakeman (4.0.1) browser (2.5.1) builder (3.2.3) bullet (5.6.1) @@ -535,10 +535,10 @@ DEPENDENCIES better_errors (~> 2.1) binding_of_caller (~> 0.7) bootsnap - brakeman (~> 3.6) + brakeman (~> 4.0) browser bullet (~> 5.5) - bundler-audit (~> 0.5) + bundler-audit (~> 0.6) capistrano (~> 3.8) capistrano-rails (~> 1.2) capistrano-rbenv (~> 2.1) -- cgit From 901fc48aaec8c6c5f1ae3c210c701abce3c03c7c Mon Sep 17 00:00:00 2001 From: Yamagishi Kazutoshi Date: Wed, 27 Sep 2017 21:41:54 +0900 Subject: Upgrade Webpacker to version 3.0.1 (#5122) --- Gemfile | 2 +- Gemfile.lock | 8 +++++--- Procfile.dev | 2 +- bin/webpack | 7 +++---- bin/webpack-dev-server | 47 ++++++++++++++++++++++++++++++++++++----------- config/webpacker.yml | 22 ++++++++++++++++++++-- lib/tasks/assets.rake | 2 +- 7 files changed, 67 insertions(+), 23 deletions(-) (limited to 'Gemfile.lock') diff --git a/Gemfile b/Gemfile index 248171680..09b3b8eff 100644 --- a/Gemfile +++ b/Gemfile @@ -67,7 +67,7 @@ gem 'sprockets-rails', '~> 3.2', require: 'sprockets/railtie' gem 'statsd-instrument', '~> 2.1' gem 'twitter-text', '~> 1.14' gem 'tzinfo-data', '~> 1.2017' -gem 'webpacker', '~> 2.0' +gem 'webpacker', '~> 3.0' gem 'webpush' gem 'json-ld-preloaded', '~> 2.2.1' diff --git a/Gemfile.lock b/Gemfile.lock index 89ee34cb6..73419fd28 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -335,6 +335,8 @@ GEM rack-cors (0.4.1) rack-protection (2.0.0) rack + rack-proxy (0.6.2) + rack rack-test (0.7.0) rack (>= 1.0, < 3) rack-timeout (0.4.2) @@ -510,9 +512,9 @@ GEM addressable (>= 2.3.6) crack (>= 0.3.2) hashdiff - webpacker (2.0) + webpacker (3.0.1) activesupport (>= 4.2) - multi_json (~> 1.2) + rack-proxy (>= 0.6.1) railties (>= 4.2) webpush (0.3.2) hkdf (~> 0.2) @@ -621,7 +623,7 @@ DEPENDENCIES tzinfo-data (~> 1.2017) uglifier (~> 3.2) webmock (~> 3.0) - webpacker (~> 2.0) + webpacker (~> 3.0) webpush RUBY VERSION diff --git a/Procfile.dev b/Procfile.dev index 9084b4263..e75a491c7 100644 --- a/Procfile.dev +++ b/Procfile.dev @@ -1,4 +1,4 @@ web: PORT=3000 bundle exec puma -C config/puma.rb sidekiq: PORT=3000 bundle exec sidekiq stream: PORT=4000 yarn run start -webpack: ./bin/webpack-dev-server --host 0.0.0.0 +webpack: ./bin/webpack-dev-server --listen-host 0.0.0.0 diff --git a/bin/webpack b/bin/webpack index 867550eb8..528233a78 100755 --- a/bin/webpack +++ b/bin/webpack @@ -2,7 +2,6 @@ $stdout.sync = true require "shellwords" -require "yaml" ENV["RAILS_ENV"] ||= "development" RAILS_ENV = ENV["RAILS_ENV"] @@ -20,9 +19,9 @@ unless File.exist?(WEBPACK_CONFIG) exit! end -newenv = { "NODE_PATH" => NODE_MODULES_PATH.shellescape } -cmdline = ["yarn", "run", "webpack", "--", "--config", WEBPACK_CONFIG] + ARGV +env = { "NODE_PATH" => NODE_MODULES_PATH.shellescape } +cmd = [ "#{NODE_MODULES_PATH}/.bin/webpack", "--config", WEBPACK_CONFIG ] + ARGV Dir.chdir(APP_PATH) do - exec newenv, *cmdline + exec env, *cmd end diff --git a/bin/webpack-dev-server b/bin/webpack-dev-server index 0beec3175..c9672f663 100755 --- a/bin/webpack-dev-server +++ b/bin/webpack-dev-server @@ -3,6 +3,7 @@ $stdout.sync = true require "shellwords" require "yaml" +require "socket" ENV["RAILS_ENV"] ||= "development" RAILS_ENV = ENV["RAILS_ENV"] @@ -13,7 +14,9 @@ NODE_ENV = ENV["NODE_ENV"] APP_PATH = File.expand_path("../", __dir__) CONFIG_FILE = File.join(APP_PATH, "config/webpacker.yml") NODE_MODULES_PATH = File.join(APP_PATH, "node_modules") -WEBPACK_CONFIG = File.join(APP_PATH, "config/webpack/development.js") +WEBPACK_CONFIG = File.join(APP_PATH, "config/webpack/#{NODE_ENV}.js") + +DEFAULT_LISTEN_HOST_ADDR = NODE_ENV == 'development' ? 'localhost' : '0.0.0.0' def args(key) index = ARGV.index(key) @@ -21,23 +24,45 @@ def args(key) end begin - dev_server = YAML.load_file(CONFIG_FILE)["development"]["dev_server"] + dev_server = YAML.load_file(CONFIG_FILE)[RAILS_ENV]["dev_server"] - DEV_SERVER_HOST = "http#{"s" if args('--https') || dev_server["https"]}://#{dev_server["host"]}:#{args('--port') || dev_server["port"]}" + HOSTNAME = args('--host') || dev_server["host"] + PORT = args('--port') || dev_server["port"] + HTTPS = ARGV.include?('--https') || dev_server["https"] + DEV_SERVER_ADDR = "http#{"s" if HTTPS}://#{HOSTNAME}:#{PORT}" + LISTEN_HOST_ADDR = args('--listen-host') || DEFAULT_LISTEN_HOST_ADDR rescue Errno::ENOENT, NoMethodError - puts "Webpack dev_server configuration not found in #{CONFIG_FILE}." - puts "Please run bundle exec rails webpacker:install to install webpacker" + $stdout.puts "Webpack dev_server configuration not found in #{CONFIG_FILE}." + $stdout.puts "Please run bundle exec rails webpacker:install to install webpacker" + exit! +end + +begin + server = TCPServer.new(LISTEN_HOST_ADDR, PORT) + server.close + +rescue Errno::EADDRINUSE + $stdout.puts "Another program is running on port #{PORT}. Set a new port in #{CONFIG_FILE} for dev_server" exit! end -newenv = { - "NODE_PATH" => NODE_MODULES_PATH.shellescape, - "ASSET_HOST" => DEV_SERVER_HOST.shellescape -}.freeze +# Delete supplied host, port and listen-host CLI arguments +["--host", "--port", "--listen-host"].each do |arg| + ARGV.delete(args(arg)) + ARGV.delete(arg) +end + +env = { "NODE_PATH" => NODE_MODULES_PATH.shellescape } -cmdline = ["yarn", "run", "webpack-dev-server", "--", "--progress", "--color", "--config", WEBPACK_CONFIG] + ARGV +cmd = [ + "#{NODE_MODULES_PATH}/.bin/webpack-dev-server", "--progress", "--color", + "--config", WEBPACK_CONFIG, + "--host", LISTEN_HOST_ADDR, + "--public", "#{HOSTNAME}:#{PORT}", + "--port", PORT.to_s +] + ARGV Dir.chdir(APP_PATH) do - exec newenv, *cmdline + exec env, *cmd end diff --git a/config/webpacker.yml b/config/webpacker.yml index aa429a1dd..8d8470651 100644 --- a/config/webpacker.yml +++ b/config/webpacker.yml @@ -4,6 +4,15 @@ default: &default source_path: app/javascript source_entry_path: packs public_output_path: packs + cache_path: tmp/cache/webpacker + + # Additional paths webpack should lookup modules + # ['app/assets', 'engine/foo/app/assets'] + resolved_paths: [] + + # Reload manifest.json on all requests so we reload latest compiled packs + cache_manifest: false + extensions: - .js - .sass @@ -17,16 +26,25 @@ default: &default development: <<: *default + compile: true dev_server: - host: 127.0.0.1 - port: 8080 + host: localhost + port: 3035 + hmr: false https: false test: <<: *default + # Compile test packs to a separate directory public_output_path: packs-test production: <<: *default + + # Production depends on precompilation of packs prior to booting for performance. + compile: false + + # Cache manifest.json for performance + cache_manifest: true diff --git a/lib/tasks/assets.rake b/lib/tasks/assets.rake index 92d5aea80..44896afc7 100644 --- a/lib/tasks/assets.rake +++ b/lib/tasks/assets.rake @@ -16,7 +16,7 @@ end if Rake::Task.task_defined?('assets:precompile') Rake::Task['assets:precompile'].enhance do - Webpacker::Manifest.load + Webpacker.manifest.refresh Rake::Task['assets:generate_static_pages'].invoke end end -- cgit