quilt_rails 3.5.5 → 3.6.0
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 +38 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fff813b5d675694dfec8b04064856c359aa0462cce93078b459253cde856abc7
|
4
|
+
data.tar.gz: 949129ceeba74281875f07c81e677e09121bfb55b9ca8a34b4391470b51c9524
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd0bb599660139c21c7931f65b43fd031cebcb9faf4965983e46aab8a08bd52f7560a14583e4e2ee18a04de9f79997ea01132d7f50ccf699773563beda356805
|
7
|
+
data.tar.gz: bc962fca99d3b892e5178f11b437dd64e8c1462d1a6d62ae52fdc2282fd2ddb924237fbbad028c1dba9c880b8eee6d65086d74907066c0feb4c501f9a30fa7ad
|
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.
|
4
|
+
version: 3.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mathew Allen
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -42,14 +42,14 @@ dependencies:
|
|
42
42
|
name: rails-reverse-proxy
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 0.9.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.9.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
@@ -66,20 +66,34 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 2.8.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rails
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '7.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '7.0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rubocop
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
87
|
- - "~>"
|
74
88
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
89
|
+
version: '1.28'
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
94
|
- - "~>"
|
81
95
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
96
|
+
version: '1.28'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: rubocop-git
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +108,20 @@ dependencies:
|
|
94
108
|
- - "~>"
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: 0.1.3
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop-shopify
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '2.5'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '2.5'
|
97
125
|
description: A turn-key solution for integrating server-rendered React into your Rails
|
98
126
|
app using Quilt libraries.
|
99
127
|
email:
|
@@ -142,7 +170,7 @@ licenses:
|
|
142
170
|
- MIT
|
143
171
|
metadata:
|
144
172
|
allowed_push_host: https://rubygems.org
|
145
|
-
post_install_message:
|
173
|
+
post_install_message:
|
146
174
|
rdoc_options: []
|
147
175
|
require_paths:
|
148
176
|
- lib
|
@@ -157,8 +185,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
185
|
- !ruby/object:Gem::Version
|
158
186
|
version: '0'
|
159
187
|
requirements: []
|
160
|
-
rubygems_version: 3.
|
161
|
-
signing_key:
|
188
|
+
rubygems_version: 3.5.14
|
189
|
+
signing_key:
|
162
190
|
specification_version: 4
|
163
191
|
summary: A turn-key solution for integrating server-rendered React into your Rails
|
164
192
|
app using Quilt libraries.
|