quilt_rails 3.3.0 → 3.3.1
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 +4 -4
- data/Rakefile +2 -0
- data/app/controllers/quilt/performance_report_controller.rb +2 -2
- data/lib/generators/quilt/rails_setup/rails_setup_generator.rb +4 -4
- data/lib/generators/quilt/react_setup/react_setup_generator.rb +1 -1
- data/lib/quilt_rails.rb +2 -1
- data/lib/quilt_rails/configuration.rb +13 -7
- data/lib/quilt_rails/engine.rb +6 -2
- data/lib/quilt_rails/header_csrf_strategy.rb +4 -3
- data/lib/quilt_rails/performance/report.rb +25 -11
- data/lib/quilt_rails/react_renderable.rb +8 -6
- data/lib/quilt_rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16eb5798cc8dd719437110f06bb5cff4dc1bea6c79e1a9a49eedbba0b0ebd303
|
4
|
+
data.tar.gz: d2c9d7ab124b18b6535b57888f3fa5319913554a812e6f074a92eab962cd2f6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a032e43ca617b448cc77f7676a287a19259fed5a41fc4e2ccefa8730c5210f878bdb9bc59183fc0200df1593a42d63147158dedf1683a4db215af739ec18c11
|
7
|
+
data.tar.gz: 3d94f79c24568c45075d658e79428acd08c8fd7f15ccb1efd979767fdff97a1adedd637c4e04b50a31615934642d2d118093ee6f7ce8d32d1fba033a13b7a4af
|
data/Rakefile
CHANGED
@@ -8,9 +8,9 @@ module Quilt
|
|
8
8
|
def create
|
9
9
|
process_report
|
10
10
|
|
11
|
-
render
|
11
|
+
render(json: { result: 'success' }, status: 200)
|
12
12
|
rescue ActionController::ParameterMissing => error
|
13
|
-
render
|
13
|
+
render(json: { error: error.message, status: 422 })
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -12,7 +12,7 @@ module Quilt
|
|
12
12
|
if File.exist?(procfile_path)
|
13
13
|
append_file(procfile_path, File.read(File.expand_path(find_in_source_paths(procfile_path))))
|
14
14
|
else
|
15
|
-
copy_file
|
15
|
+
copy_file(procfile_path)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -20,12 +20,12 @@ module Quilt
|
|
20
20
|
routes_path = "config/routes.rb"
|
21
21
|
|
22
22
|
if File.exist?(routes_path)
|
23
|
-
route
|
23
|
+
route("mount Quilt::Engine, at: '/'")
|
24
24
|
else
|
25
|
-
copy_file
|
25
|
+
copy_file("routes.rb", routes_path)
|
26
26
|
end
|
27
27
|
|
28
|
-
say
|
28
|
+
say("Added Quilt engine mount")
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
data/lib/quilt_rails.rb
CHANGED
@@ -3,11 +3,12 @@ module Quilt
|
|
3
3
|
end
|
4
4
|
|
5
5
|
require "quilt_rails/version"
|
6
|
-
require "quilt_rails/engine"
|
7
6
|
require "quilt_rails/logger"
|
8
7
|
require "quilt_rails/configuration"
|
9
8
|
require "quilt_rails/react_renderable"
|
10
9
|
require "quilt_rails/performance"
|
11
10
|
require "quilt_rails/trusted_ui_server_csrf_strategy"
|
12
11
|
require "quilt_rails/header_csrf_strategy"
|
12
|
+
|
13
|
+
require "quilt_rails/engine"
|
13
14
|
require "quilt_rails/monkey_patches/active_support_reloader" if Rails.env.development?
|
@@ -1,15 +1,21 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
class Configuration
|
5
|
-
attr_accessor :react_server_host, :react_server_protocol
|
3
|
+
require "active_support/ordered_options"
|
6
4
|
|
5
|
+
module Quilt
|
6
|
+
class Configuration < ActiveSupport::OrderedOptions
|
7
7
|
def initialize
|
8
|
-
|
9
|
-
|
8
|
+
super
|
9
|
+
react_server_ip = ENV['REACT_SERVER_IP'] || "localhost"
|
10
|
+
react_server_port = ENV['REACT_SERVER_PORT'] || 8081
|
11
|
+
|
12
|
+
self.react_server_host = "#{react_server_ip}:#{react_server_port}"
|
13
|
+
self.react_server_protocol = ENV['REACT_SERVER_PROTOCOL'] || "http"
|
14
|
+
self.mount = true
|
15
|
+
end
|
10
16
|
|
11
|
-
|
12
|
-
|
17
|
+
def mount?
|
18
|
+
mount
|
13
19
|
end
|
14
20
|
end
|
15
21
|
|
data/lib/quilt_rails/engine.rb
CHANGED
@@ -4,9 +4,13 @@ module Quilt
|
|
4
4
|
class Engine < ::Rails::Engine
|
5
5
|
isolate_namespace Quilt
|
6
6
|
|
7
|
+
config.quilt = Quilt.configuration
|
8
|
+
|
7
9
|
initializer(:mount_quilt, before: :add_builtin_route) do |app|
|
8
|
-
|
9
|
-
|
10
|
+
if config.quilt.mount?
|
11
|
+
app.routes.append do
|
12
|
+
mount(Quilt::Engine, at: '/') unless has_named_route?(:quilt)
|
13
|
+
end
|
10
14
|
end
|
11
15
|
end
|
12
16
|
end
|
@@ -25,9 +25,10 @@ module Quilt
|
|
25
25
|
|
26
26
|
class NoSameSiteHeaderError < StandardError
|
27
27
|
def initialize
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
super(<<~MSG.squish)
|
29
|
+
CSRF verification failed. This request is missing the
|
30
|
+
`x-shopify-react-xhr` header, or it does not have the expected value.
|
31
|
+
MSG
|
31
32
|
end
|
32
33
|
end
|
33
34
|
end
|
@@ -7,25 +7,39 @@ module Quilt
|
|
7
7
|
attr_accessor :navigations
|
8
8
|
attr_accessor :connection
|
9
9
|
|
10
|
-
|
11
|
-
params
|
12
|
-
|
10
|
+
class << self
|
11
|
+
def from_params(params)
|
12
|
+
params.transform_keys! { |key| key.underscore.to_sym }
|
13
|
+
params[:connection] = { effectiveType: 'unknown' } if params[:connection].blank?
|
13
14
|
|
14
|
-
|
15
|
+
connection = Connection.from_params(params[:connection])
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
Report.new(
|
18
|
+
connection: connection,
|
19
|
+
navigations: build_navigations(params[:navigations], connection: connection),
|
20
|
+
events: build_events(params[:events], connection: connection),
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def build_navigations(navigations_params, connection:)
|
27
|
+
navigations_params ||= []
|
28
|
+
navigations_params.map do |navigation|
|
19
29
|
navigation = Navigation.from_params(navigation)
|
20
30
|
navigation.connection = connection
|
21
31
|
navigation
|
22
|
-
end
|
23
|
-
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def build_events(events_params, connection:)
|
36
|
+
events_params ||= []
|
37
|
+
events_params.map do |event|
|
24
38
|
event = Event.from_params(event)
|
25
39
|
event.connection = connection
|
26
40
|
event
|
27
|
-
end
|
28
|
-
|
41
|
+
end
|
42
|
+
end
|
29
43
|
end
|
30
44
|
|
31
45
|
def initialize(events:, navigations:, connection:)
|
@@ -52,17 +52,19 @@ module Quilt
|
|
52
52
|
|
53
53
|
class ReactServerNoResponseError < StandardError
|
54
54
|
def initialize(url)
|
55
|
-
|
56
|
-
|
57
|
-
|
55
|
+
super(<<~MSG.squish)
|
56
|
+
Errno::ECONNREFUSED: Waiting for React server to boot up.
|
57
|
+
If this error persists verify that @shopify/react-server is configured on #{url}"
|
58
|
+
MSG
|
58
59
|
end
|
59
60
|
end
|
60
61
|
|
61
62
|
class DoNotIntegrationTestError < StandardError
|
62
63
|
def initialize
|
63
|
-
|
64
|
-
|
65
|
-
|
64
|
+
super(<<~MSG.squish)
|
65
|
+
Do not try to use Rails integration tests on your quilt_rails app.
|
66
|
+
Instead use Jest and @shopify/react-testing to test your React application directly."
|
67
|
+
MSG
|
66
68
|
end
|
67
69
|
end
|
68
70
|
end
|
data/lib/quilt_rails/version.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.3.
|
4
|
+
version: 3.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mathew Allen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-08-
|
11
|
+
date: 2020-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|