quilt_rails 3.5.5 → 3.5.6

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: 592c0b080cb38e2f3441388b089c9de398f1ac6d9a8374fcc0e07497d3105311
4
- data.tar.gz: f24e29204dbd946dd4c97182f7e61888e769790097295443f8c8f1bcb8ba46e0
3
+ metadata.gz: 2c5d354e60af8454d28307671ebdcc39c08146944e3598e271118e7399299644
4
+ data.tar.gz: c23c7d51fd5c98b4740b5814046a340dadd9179a1e2f735174e18aa49d908b34
5
5
  SHA512:
6
- metadata.gz: fae414a9e0d56917e5bbe809e21eda522215a182bb144f8849c1cdf27eb6c7b1514e400e8b51e30ee6de798ac296e29e083b964dd94068f0e6908b8c7f938d01
7
- data.tar.gz: 9de5aa59ffee287534e46e13c430d4400e78e70953fd363cd60fb7d9b8069e2b4c8ca33f5ccfdb811b98859a5058c60cc6d1f8f19a48a025d3d97a90f351c365
6
+ metadata.gz: ead07a6242b9eff56f5cc10c98596578a2d40ebeab79f8bf21c178ca36cf3e7891f6db39ab8cc22aaecf5185ef3a0e978ad90daba74ad7a8692a0678721ae4c6
7
+ data.tar.gz: faf34218855d37fce55e366747e8d5239123f187c4f23ba316781e78f6735d324627c5589ad6c2781d900cc79ed59902095f2dd725721984f30f55e95bf9179f
data/README.md CHANGED
@@ -20,6 +20,8 @@ A turn-key solution for integrating [Quilt](https://github.com/Shopify/quilt) cl
20
20
  - [Fixing rejected CSRF tokens for new user sessions](#fixing-rejected-csrf-tokens-for-new-user-sessions)
21
21
  - [Performance tracking a React app](#performance-tracking-a-react-app)
22
22
  - [API](#api)
23
+ - [Shopify embedded app](#shopify-embedded-app)
24
+ - [FAQ](#faq)
23
25
 
24
26
  ## Server-side-rendering
25
27
 
@@ -315,6 +317,20 @@ Follow details guide [here](./docs/performance-tracking.md).
315
317
 
316
318
  Find all features this gem offer in this [API doc](./docs/api.md).
317
319
 
320
+ ## Shopify embedded app
321
+
322
+ [See here for Dev Docs for Apps](https://shopify.dev/apps). Make sure to add the line: `include ShopifyApp::EmbeddedApp` if you are using Quilt for server-side rendering of React for an embedded application:
323
+
324
+ ```ruby
325
+ class ReactController < ApplicationController
326
+ include ShopifyApp::EmbeddedApp
327
+ include Quilt::ReactRenderable
328
+ def index
329
+ render_react
330
+ end
331
+ end
332
+ ```
333
+
318
334
  ## FAQ
319
335
 
320
336
  Find your [here](./docs/FAQ.md).
data/Rakefile CHANGED
@@ -1,28 +1,28 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bundler/gem_tasks'
3
+ require "bundler/gem_tasks"
4
4
 
5
5
  begin
6
- require 'bundler/setup'
6
+ require "bundler/setup"
7
7
  rescue LoadError
8
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
8
+ puts "You must `gem install bundler` and `bundle install` to run rake tasks"
9
9
  end
10
10
 
11
11
  Bundler::GemHelper.install_tasks
12
12
 
13
- require File.expand_path('../test/dummy/config/application', __FILE__)
13
+ require File.expand_path("../test/dummy/config/application", __FILE__)
14
14
 
15
- require 'rake/testtask'
15
+ require "rake/testtask"
16
16
 
17
17
  Rake::TestTask.new do |t|
18
- t.libs << 'test'
19
- t.pattern = 'test/**/*_test.rb'
18
+ t.libs << "test"
19
+ t.pattern = "test/**/*_test.rb"
20
20
  end
21
21
 
22
22
  Rake::TestTask.new do |t|
23
- t.libs << 'test'
24
- t.name = 'test:unit'
25
- t.pattern = 'test/quilt_rails/**/*_test.rb'
23
+ t.libs << "test"
24
+ t.name = "test:unit"
25
+ t.pattern = "test/quilt_rails/**/*_test.rb"
26
26
  end
27
27
 
28
- task(default: %i(test))
28
+ task(default: [:test])
data/config/routes.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  Quilt::Engine.routes.draw do
4
- post '/performance_report', to: 'performance_report#create'
5
- get '/*path', to: 'ui#index'
6
- root 'ui#index'
4
+ post "/performance_report", to: "performance_report#create"
5
+ get "/*path", to: "ui#index"
6
+ root "ui#index"
7
7
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Quilt
4
4
  class RailsSetupGenerator < Rails::Generators::Base
5
- source_root File.expand_path('templates', __dir__)
5
+ source_root File.expand_path("templates", __dir__)
6
6
 
7
7
  desc "This generator mounts the Quilt engine and add Procfile."
8
8
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  Rails.application.routes.draw do
4
- mount Quilt::Engine, at: '/'
4
+ mount Quilt::Engine, at: "/"
5
5
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Quilt
4
4
  class ReactAppGenerator < Rails::Generators::Base
5
- source_root File.expand_path('templates', __dir__)
5
+ source_root File.expand_path("templates", __dir__)
6
6
 
7
7
  desc "This generator adds a React app."
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Quilt
4
4
  class ReactSetupGenerator < Rails::Generators::Base
5
- source_root File.expand_path('templates', __dir__)
5
+ source_root File.expand_path("templates", __dir__)
6
6
  class_option :skip_yarn, type: :boolean, default: false
7
7
 
8
8
  desc "This generator adds a React app."
@@ -6,11 +6,11 @@ module Quilt
6
6
  class Configuration < ActiveSupport::OrderedOptions
7
7
  def initialize
8
8
  super
9
- react_server_ip = ENV['REACT_SERVER_IP'] || "localhost"
10
- react_server_port = ENV['REACT_SERVER_PORT'] || 8081
9
+ react_server_ip = ENV["REACT_SERVER_IP"] || "localhost"
10
+ react_server_port = ENV["REACT_SERVER_PORT"] || 8081
11
11
 
12
12
  self.react_server_host = "#{react_server_ip}:#{react_server_port}"
13
- self.react_server_protocol = ENV['REACT_SERVER_PROTOCOL'] || "http"
13
+ self.react_server_protocol = ENV["REACT_SERVER_PROTOCOL"] || "http"
14
14
  self.logger = ::Logger.new($stdout)
15
15
  self.mount = true
16
16
  self.allow_integration_test = false
@@ -13,7 +13,7 @@ module Quilt
13
13
  initializer(:mount_quilt, before: :add_builtin_route) do |app|
14
14
  if config.quilt.mount?
15
15
  app.routes.append do
16
- mount(Quilt::Engine, at: '/') unless has_named_route?(:quilt)
16
+ mount(Quilt::Engine, at: "/") unless has_named_route?(:quilt)
17
17
  end
18
18
  end
19
19
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
- require 'rails'
2
+
3
+ require "rails"
3
4
 
4
5
  # The default ActiveSupport::Reloader memoizes `@should_reload` for the
5
6
  # lifetime of each request. This is a problem for quilt_rails apps because:
@@ -4,17 +4,17 @@ module Quilt
4
4
  module Performance
5
5
  class Event
6
6
  TYPE = {
7
- time_to_first_byte: 'ttfb',
8
- time_to_first_paint: 'ttfp',
9
- time_to_first_contentful_paint: 'ttfcp',
10
- dom_content_loaded: 'dcl',
11
- first_input_delay: 'fid',
12
- load: 'load',
13
- long_task: 'longtask',
14
- usable: 'usable',
15
- graphql: 'graphql',
16
- script_download: 'script',
17
- style_download: 'style',
7
+ time_to_first_byte: "ttfb",
8
+ time_to_first_paint: "ttfp",
9
+ time_to_first_contentful_paint: "ttfcp",
10
+ dom_content_loaded: "dcl",
11
+ first_input_delay: "fid",
12
+ load: "load",
13
+ long_task: "longtask",
14
+ usable: "usable",
15
+ graphql: "graphql",
16
+ script_download: "script",
17
+ style_download: "style",
18
18
  }
19
19
 
20
20
  attr_accessor :type
@@ -74,6 +74,7 @@ module Quilt
74
74
  events_with_size.reduce(nil) do |total, current|
75
75
  current_size = current.metadata.size
76
76
  return current_size + total unless total.nil?
77
+
77
78
  current_size
78
79
  end
79
80
  end
@@ -10,7 +10,7 @@ module Quilt
10
10
  class << self
11
11
  def from_params(params)
12
12
  params.transform_keys! { |key| key.underscore.to_sym }
13
- params[:connection] = { effectiveType: 'unknown' } if params[:connection].blank?
13
+ params[:connection] = { effectiveType: "unknown" } if params[:connection].blank?
14
14
 
15
15
  connection = Connection.from_params(params[:connection])
16
16
 
@@ -10,7 +10,7 @@ module Quilt
10
10
  private
11
11
 
12
12
  def normalized_params
13
- return params unless request.content_type == 'text/plain'
13
+ return params unless request.content_type == "text/plain"
14
14
 
15
15
  ActionController::Parameters.new(JSON.parse(request.body.read))
16
16
  end
@@ -12,19 +12,19 @@ require "quilt_rails/performance/reportable"
12
12
  module Quilt
13
13
  module Performance
14
14
  LIFECYCLE = {
15
- time_to_first_byte: 'time_to_first_byte',
16
- time_to_first_contentful_paint: 'time_to_first_contentful_paint',
17
- time_to_first_paint: 'time_to_first_paint',
18
- dom_content_loaded: 'dom_content_loaded',
19
- first_input_delay: 'first_input_delay',
20
- load: 'dom_load',
15
+ time_to_first_byte: "time_to_first_byte",
16
+ time_to_first_contentful_paint: "time_to_first_contentful_paint",
17
+ time_to_first_paint: "time_to_first_paint",
18
+ dom_content_loaded: "dom_content_loaded",
19
+ first_input_delay: "first_input_delay",
20
+ load: "dom_load",
21
21
  }
22
22
 
23
23
  NAVIGATION = {
24
- complete: 'navigation_complete',
25
- usable: 'navigation_usable',
26
- download_size: 'navigation_download_size',
27
- cache_effectiveness: 'navigation_cache_effectiveness',
24
+ complete: "navigation_complete",
25
+ usable: "navigation_usable",
26
+ download_size: "navigation_download_size",
27
+ cache_effectiveness: "navigation_cache_effectiveness",
28
28
  }
29
29
  end
30
30
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rails-reverse-proxy'
3
+ require "rails-reverse-proxy"
4
4
 
5
5
  module Quilt
6
6
  module ReactRenderable
@@ -22,7 +22,9 @@ module Quilt
22
22
 
23
23
  def call_proxy(headers, data)
24
24
  if defined? ShopifySecurityBase
25
+ # rubocop:disable Naming/InclusiveLanguage
25
26
  allowlist = ShopifySecurityBase::HTTPHostRestriction.respond_to?(:allowlist) ? :allowlist : :whitelist
27
+ # rubocop:enable Naming/InclusiveLanguage
26
28
  ShopifySecurityBase::HTTPHostRestriction.send(allowlist, [Quilt.configuration.react_server_host]) do
27
29
  proxy(headers, data)
28
30
  end
@@ -43,12 +45,8 @@ module Quilt
43
45
  data_json = JSON.generate(data.as_json, ascii_only: true)
44
46
  reverse_proxy(
45
47
  url,
46
- headers: headers.merge('X-Request-ID': request.request_id, 'X-Quilt-Data': data_json)
47
- ) do |callbacks|
48
- callbacks.on_response do |status_code, _response|
49
- Quilt.logger.info("[ReactRenderable] #{url} returned #{status_code}")
50
- end
51
- end
48
+ headers: headers.merge("X-Request-ID": request.request_id, "X-Quilt-Data": data_json)
49
+ )
52
50
  rescue Errno::ECONNREFUSED
53
51
  raise ReactServerNoResponseError, url
54
52
  end
@@ -15,7 +15,7 @@ module Quilt
15
15
  private
16
16
 
17
17
  def node_server_side_render?
18
- @controller.request.headers['x-shopify-server-side-rendered'] == '1'
18
+ @controller.request.headers["x-shopify-server-side-rendered"] == "1"
19
19
  end
20
20
 
21
21
  def fallback_handler
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Quilt
3
- VERSION = "3.5.5"
4
+ VERSION = "3.5.6"
4
5
  end
data/lib/quilt_rails.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Quilt
3
4
  end
4
5
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quilt_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.5
4
+ version: 3.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mathew Allen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-10 00:00:00.000000000 Z
11
+ date: 2022-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0.74'
75
+ version: '1.28'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0.74'
82
+ version: '1.28'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rubocop-git
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: 0.1.3
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop-shopify
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '2.5'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '2.5'
97
111
  description: A turn-key solution for integrating server-rendered React into your Rails
98
112
  app using Quilt libraries.
99
113
  email:
@@ -157,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
171
  - !ruby/object:Gem::Version
158
172
  version: '0'
159
173
  requirements: []
160
- rubygems_version: 3.2.20
174
+ rubygems_version: 3.3.3
161
175
  signing_key:
162
176
  specification_version: 4
163
177
  summary: A turn-key solution for integrating server-rendered React into your Rails