quilt_rails 3.5.5 → 3.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -0
- data/Rakefile +11 -11
- data/config/routes.rb +3 -3
- data/lib/generators/quilt/rails_setup/rails_setup_generator.rb +1 -1
- data/lib/generators/quilt/rails_setup/templates/routes.rb +1 -1
- data/lib/generators/quilt/react_app/react_app_generator.rb +1 -1
- data/lib/generators/quilt/react_setup/react_setup_generator.rb +1 -1
- data/lib/quilt_rails/configuration.rb +3 -3
- data/lib/quilt_rails/engine.rb +1 -1
- data/lib/quilt_rails/monkey_patches/active_support_reloader.rb +2 -1
- data/lib/quilt_rails/performance/event.rb +11 -11
- data/lib/quilt_rails/performance/navigation.rb +1 -0
- data/lib/quilt_rails/performance/report.rb +1 -1
- data/lib/quilt_rails/performance/reportable.rb +1 -1
- data/lib/quilt_rails/performance.rb +10 -10
- data/lib/quilt_rails/react_renderable.rb +5 -7
- data/lib/quilt_rails/trusted_ui_server_csrf_strategy.rb +1 -1
- data/lib/quilt_rails/version.rb +2 -1
- data/lib/quilt_rails.rb +1 -0
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c5d354e60af8454d28307671ebdcc39c08146944e3598e271118e7399299644
|
4
|
+
data.tar.gz: c23c7d51fd5c98b4740b5814046a340dadd9179a1e2f735174e18aa49d908b34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
3
|
+
require "bundler/gem_tasks"
|
4
4
|
|
5
5
|
begin
|
6
|
-
require
|
6
|
+
require "bundler/setup"
|
7
7
|
rescue LoadError
|
8
|
-
puts
|
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(
|
13
|
+
require File.expand_path("../test/dummy/config/application", __FILE__)
|
14
14
|
|
15
|
-
require
|
15
|
+
require "rake/testtask"
|
16
16
|
|
17
17
|
Rake::TestTask.new do |t|
|
18
|
-
t.libs <<
|
19
|
-
t.pattern =
|
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 <<
|
24
|
-
t.name =
|
25
|
-
t.pattern =
|
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:
|
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
|
5
|
-
get
|
6
|
-
root
|
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 ReactSetupGenerator < Rails::Generators::Base
|
5
|
-
source_root File.expand_path(
|
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[
|
10
|
-
react_server_port = ENV[
|
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[
|
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
|
data/lib/quilt_rails/engine.rb
CHANGED
@@ -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:
|
16
|
+
mount(Quilt::Engine, at: "/") unless has_named_route?(:quilt)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -4,17 +4,17 @@ module Quilt
|
|
4
4
|
module Performance
|
5
5
|
class Event
|
6
6
|
TYPE = {
|
7
|
-
time_to_first_byte:
|
8
|
-
time_to_first_paint:
|
9
|
-
time_to_first_contentful_paint:
|
10
|
-
dom_content_loaded:
|
11
|
-
first_input_delay:
|
12
|
-
load:
|
13
|
-
long_task:
|
14
|
-
usable:
|
15
|
-
graphql:
|
16
|
-
script_download:
|
17
|
-
style_download:
|
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
|
@@ -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:
|
13
|
+
params[:connection] = { effectiveType: "unknown" } if params[:connection].blank?
|
14
14
|
|
15
15
|
connection = Connection.from_params(params[:connection])
|
16
16
|
|
@@ -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:
|
16
|
-
time_to_first_contentful_paint:
|
17
|
-
time_to_first_paint:
|
18
|
-
dom_content_loaded:
|
19
|
-
first_input_delay:
|
20
|
-
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:
|
25
|
-
usable:
|
26
|
-
download_size:
|
27
|
-
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
|
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(
|
47
|
-
)
|
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
|
data/lib/quilt_rails/version.rb
CHANGED
data/lib/quilt_rails.rb
CHANGED
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.
|
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-
|
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: '
|
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: '
|
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.
|
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
|