quilt_rails 3.4.0 → 3.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa35ecd25ebbe9bd095f8e161debda741a45237533aef5d36751f9a1858dd5c7
4
- data.tar.gz: 8de82016b228fe4f9ef5f21bd09380637db99d5b160345ce3910e7ca7fdf1e11
3
+ metadata.gz: 0a6933fd12f6ae25d25f4afab855ba022287ac3c2e353d3b1d1aa2764adb6e40
4
+ data.tar.gz: 88e908022a12e1ed55bcd8859bc7be736e9d844832ed7df30f81caf3f822c875
5
5
  SHA512:
6
- metadata.gz: 4e205902095208ed7d79c0e963389220b1c1d1050e46201935428b6949ca6f37f600e412b9cf1eeadf9435e7fd8fade00191edc922cbcb64819bb79acdc9af2f
7
- data.tar.gz: f22a95a82bd538ff24ebaf4e15a1ada939b77e1be3e258c1f5a2ead5f342116517006934d625507f6770da5bce75e52675af5e48cea4c19ee948032c21a7342d
6
+ metadata.gz: b2e02a1233697cb16ef35ec291de7736b3e0721d516bcd566c309c88704e996fc5ce40c3ccb72abc54c6dbf1b2fbe384c41bf333a760e1e889b7ee280331f5ba
7
+ data.tar.gz: 506bfd185f702ad39e7f6d21713524b002bc90e45e0e1aaed0832d6aee2f5d0d998a104c46b9272ab001040fd1ed49be41a788107cc9c0fea9145697dffb10ff
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # quilt_rails
2
2
 
3
- A turn-key solution for integrating Quilt client-side libraries into your Rails app, with support for server-side-rendering using [`@shopify/react-server`](https://www.npmjs.com/package/@shopify/react-server), integration with [`@shopify/sewing-kit`](https://github.com/Shopify/sewing-kit) for building, testing and linting, and front-end performance tracking through [`@shopify/performance`](https://www.npmjs.com/package/@shopify/performance).
3
+ A turn-key solution for integrating [Quilt](https://github.com/Shopify/quilt) client-side libraries into your Rails app, with support for server-side-rendering using [`@shopify/react-server`](https://www.npmjs.com/package/@shopify/react-server), integration with [`@shopify/sewing-kit`](https://github.com/Shopify/sewing-kit) for building, testing and linting, and front-end performance tracking through [`@shopify/performance`](https://www.npmjs.com/package/@shopify/performance).
4
4
 
5
5
  ## Table of Contents
6
6
 
@@ -67,9 +67,9 @@ Follow [this guide](./docs/manual-installation.md) on how to do manual setup wit
67
67
 
68
68
  For fast tests with consistent results, test front-end components using the tools provided by sewing-kit instead of Rails integration tests.
69
69
 
70
- Use [`sewing-kit test`](https://github.com/Shopify/sewing-kit/blob/master/docs/commands/test.md#L3) to run all `.test.{js|ts}x` files in the `app/ui` directory. [Jest](https://jestjs.io/) is used as a test runner, with customization available via [its sewing-kit plugin](https://github.com/Shopify/sewing-kit/blob/master/docs/plugins/jest.md).
70
+ Use [`sewing-kit test`](https://github.com/Shopify/sewing-kit/blob/main/docs/commands/test.md#L3) to run all `.test.{js|ts}x` files in the `app/ui` directory. [Jest](https://jestjs.io/) is used as a test runner, with customization available via [its sewing-kit plugin](https://github.com/Shopify/sewing-kit/blob/main/docs/plugins/jest.md).
71
71
 
72
- For testing React applications we provide and support [`@shopify/react-testing`](https://github.com/Shopify/quilt/tree/master/packages/react-testing).
72
+ For testing React applications we provide and support [`@shopify/react-testing`](https://github.com/Shopify/quilt/tree/main/packages/react-testing).
73
73
 
74
74
  ##### Example
75
75
 
@@ -102,11 +102,11 @@ describe('MyComponent', () => {
102
102
 
103
103
  Often you will want to hook up custom polyfills, global mocks, or other logic that needs to run either before the initialization of the test environment, or once for each test suite.
104
104
 
105
- By default, sewing-kit will look for such test setup files under `/app/ui/tests`. Check out the [documentation](https://github.com/Shopify/sewing-kit/blob/master/docs/plugins/jest.md#smart-defaults) for more details.
105
+ By default, sewing-kit will look for such test setup files under `/app/ui/tests`. Check out the [documentation](https://github.com/Shopify/sewing-kit/blob/main/docs/plugins/jest.md#smart-defaults) for more details.
106
106
 
107
107
  ##### Interacting with the request and response in React code
108
108
 
109
- React-server sets up [@shopify/react-network](https://github.com/Shopify/quilt/blob/master/packages/react-network) automatically, so most interactions with the request or response can be done from inside the React app.
109
+ React-server sets up [@shopify/react-network](https://github.com/Shopify/quilt/blob/main/packages/react-network) automatically, so most interactions with the request or response can be done from inside the React app.
110
110
 
111
111
  ##### Example: getting headers
112
112
 
@@ -131,7 +131,7 @@ function App() {
131
131
  export default App;
132
132
  ```
133
133
 
134
- **Note:** This solution works out of the box for initial server-side renders. If you wish to have consistent access to request headers on subsequent client-side renders, take a look at [`NetworkUniversalProvider`](https://github.com/Shopify/quilt/tree/master/packages/react-network#networkuniversalprovider).
134
+ **Note:** This solution works out of the box for initial server-side renders. If you wish to have consistent access to request headers on subsequent client-side renders, take a look at [`NetworkUniversalProvider`](https://github.com/Shopify/quilt/tree/main/packages/react-network#networkuniversalprovider).
135
135
 
136
136
  ##### Example: sending custom headers from Rails controller
137
137
 
@@ -147,7 +147,7 @@ class ReactController < ApplicationController
147
147
  end
148
148
  ```
149
149
 
150
- 🗒️ if you don't have a controller. Follow the [instruction](./docs/manual-installation#add-a-react-controller-and-routes) to setup `quilt_rails` in a controller instead of using the engine.
150
+ 🗒️ if you don't have a controller. Follow the [instruction](./docs/manual-installation.md#option-2-add-a-react-controller-and-routes) to setup `quilt_rails` in a controller instead of using the engine.
151
151
 
152
152
  Headers can be accessed during server-side-rendering with the `useRequestHeader` hook from `@shopify/react-network`.
153
153
 
@@ -183,7 +183,7 @@ class ReactController < ApplicationController
183
183
  end
184
184
  ```
185
185
 
186
- 🗒️ if you don't have a controller. Follow the [instruction](./docs/manual-installation#add-a-react-controller-and-routes) to setup `quilt_rails` in a controller instead of using the engine.
186
+ 🗒️ if you don't have a controller. Follow the [instruction](./docs/manual-installation.md#option-2-add-a-react-controller-and-routes) to setup `quilt_rails` in a controller instead of using the engine.
187
187
 
188
188
  If using `react-server` without a customized server & client file, this will be automatically passed into your application as the `data` prop. If `react-server` is not being used or a customized server / client file was provided, check out [`react-server/webpack-plugin`](../../packages/react-server/src/webpack-plugin/webpack-plugin.ts) on how to pass the data to React.
189
189
 
@@ -222,9 +222,9 @@ export default App;
222
222
 
223
223
  #### Isomorphic state
224
224
 
225
- With SSR enabled React apps, state must be serialized on the server and deserialized on the client to keep it consistent. When using `@shopify/react-server`, the best tool for this job is [`@shopify/react-html`](https://github.com/Shopify/quilt/tree/master/packages/react-html)'s [`useSerialized`](https://github.com/Shopify/quilt/tree/master/packages/react-html#in-your-application-code) hook.
225
+ With SSR enabled React apps, state must be serialized on the server and deserialized on the client to keep it consistent. When using `@shopify/react-server`, the best tool for this job is [`@shopify/react-html`](https://github.com/Shopify/quilt/tree/main/packages/react-html)'s [`useSerialized`](https://github.com/Shopify/quilt/tree/main/packages/react-html#in-your-application-code) hook.
226
226
 
227
- `useSerialized` can be used to implement [universal-providers](https://github.com/Shopify/quilt/tree/master/packages/react-universal-provider#what-is-a-universal-provider-), allowing application code to manage what is persisted between the server and client without adding any custom code to client or server entrypoints. We offer some for common use cases such as [GraphQL](https://github.com/Shopify/quilt/tree/master/packages/react-graphql-universal-provider), and [I18n](https://github.com/Shopify/quilt/tree/master/packages/react-i18n-universal-provider).
227
+ `useSerialized` can be used to implement [universal-providers](https://github.com/Shopify/quilt/tree/main/packages/react-universal-provider#what-is-a-universal-provider-), allowing application code to manage what is persisted between the server and client without adding any custom code to client or server entrypoints. We offer some for common use cases such as [GraphQL](https://github.com/Shopify/quilt/tree/main/packages/react-graphql-universal-provider), and [I18n](https://github.com/Shopify/quilt/tree/main/packages/react-i18n-universal-provider).
228
228
 
229
229
  #### Customizing the Node server
230
230
 
@@ -289,7 +289,7 @@ end
289
289
 
290
290
  #### Exception monitoring with Bugsnag
291
291
 
292
- For an opinionated universal Bugsnag+React setup we provide and support [`@shopify/react-bugsnag`](https://github.com/Shopify/quilt/tree/master/packages/react-bugsnag).
292
+ For an opinionated universal Bugsnag+React setup we provide and support [`@shopify/react-bugsnag`](https://github.com/Shopify/quilt/tree/main/packages/react-bugsnag).
293
293
 
294
294
  ##### Example
295
295
 
@@ -5,12 +5,17 @@ module Quilt
5
5
  include Quilt::ReactRenderable
6
6
  layout(false)
7
7
 
8
- rescue_from(Quilt::ReactRenderable::ReactServerNoResponseError) do
9
- render(:react_render_error, status: :internal_server_error)
10
- end
11
-
12
8
  def index
13
9
  render_react
10
+ rescue Quilt::ReactRenderable::ReactServerNoResponseError
11
+ sleep(1)
12
+ retry if execution_count < 10
13
+ raise
14
+ end
15
+
16
+ def execution_count
17
+ @times ||= 0
18
+ @times = @times.next
14
19
  end
15
20
  end
16
21
  end
@@ -11,6 +11,7 @@ module Quilt
11
11
 
12
12
  self.react_server_host = "#{react_server_ip}:#{react_server_port}"
13
13
  self.react_server_protocol = ENV['REACT_SERVER_PROTOCOL'] || "http"
14
+ self.logger = ::Logger.new($stdout)
14
15
  self.mount = true
15
16
  end
16
17
 
@@ -19,11 +20,13 @@ module Quilt
19
20
  end
20
21
  end
21
22
 
22
- def self.configuration
23
- @configuration ||= Configuration.new
24
- end
23
+ class << self
24
+ def configuration
25
+ @configuration ||= Configuration.new
26
+ end
25
27
 
26
- def self.configure
27
- yield(configuration)
28
+ def configure
29
+ yield(configuration)
30
+ end
28
31
  end
29
32
  end
@@ -6,6 +6,10 @@ module Quilt
6
6
 
7
7
  config.quilt = Quilt.configuration
8
8
 
9
+ initializer(:initialize_quilt_logger, after: :initialize_logger) do
10
+ config.quilt.logger = ::Rails.logger
11
+ end
12
+
9
13
  initializer(:mount_quilt, before: :add_builtin_route) do |app|
10
14
  if config.quilt.mount?
11
15
  app.routes.append do
@@ -3,11 +3,14 @@
3
3
  module Quilt
4
4
  module Logger
5
5
  def self.log(string)
6
- if Rails.logger.nil?
7
- puts string
8
- else
9
- Rails.logger.info(string)
10
- end
6
+ ActiveSupport::Deprecation.warn(<<~MSG.squish)
7
+ Quilt::Logger.log is deprecated. Please use Quilt.logger instead.
8
+ MSG
9
+ Quilt.configuration.logger.info(string)
11
10
  end
12
11
  end
12
+
13
+ class << self
14
+ delegate(:logger, to: :configuration)
15
+ end
13
16
  end
@@ -30,10 +30,10 @@ module Quilt
30
30
 
31
31
  def proxy(headers, data)
32
32
  url = "#{Quilt.configuration.react_server_protocol}://#{Quilt.configuration.react_server_host}"
33
- Quilt::Logger.log("[ReactRenderable] proxying to React server at #{url}")
33
+ Quilt.logger.info("[ReactRenderable] proxying to React server at #{url}")
34
34
 
35
35
  unless headers.blank?
36
- Quilt::Logger.log("[ReactRenderable] applying custom headers #{headers.inspect}")
36
+ Quilt.logger.info("[ReactRenderable] applying custom headers #{headers.inspect}")
37
37
  end
38
38
 
39
39
  begin
@@ -42,7 +42,7 @@ module Quilt
42
42
  headers: headers.merge('X-Request-ID': request.request_id, 'X-Quilt-Data': data.to_json)
43
43
  ) do |callbacks|
44
44
  callbacks.on_response do |status_code, _response|
45
- Quilt::Logger.log("[ReactRenderable] #{url} returned #{status_code}")
45
+ Quilt.logger.info("[ReactRenderable] #{url} returned #{status_code}")
46
46
  end
47
47
  end
48
48
  rescue Errno::ECONNREFUSED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Quilt
3
- VERSION = "3.4.0"
3
+ VERSION = "3.4.1"
4
4
  end
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.0
4
+ version: 3.4.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-26 00:00:00.000000000 Z
11
+ date: 2021-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 3.2.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 3.2.0
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rails-reverse-proxy
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -92,7 +106,6 @@ files:
92
106
  - Rakefile
93
107
  - app/controllers/quilt/performance_report_controller.rb
94
108
  - app/controllers/quilt/ui_controller.rb
95
- - app/views/quilt/ui/react_render_error.html
96
109
  - config/routes.rb
97
110
  - lib/generators/quilt/USAGE
98
111
  - lib/generators/quilt/install_generator.rb
@@ -124,7 +137,7 @@ files:
124
137
  - lib/quilt_rails/react_renderable.rb
125
138
  - lib/quilt_rails/trusted_ui_server_csrf_strategy.rb
126
139
  - lib/quilt_rails/version.rb
127
- homepage: https://github.com/Shopify/quilt/tree/master/gems/quilt_rails
140
+ homepage: https://github.com/Shopify/quilt/tree/main/gems/quilt_rails
128
141
  licenses:
129
142
  - MIT
130
143
  metadata:
@@ -1,21 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>React Render Error</title>
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <meta http-equiv="refresh" content="3;URL='/'" />
7
- <link rel="stylesheet" href="https://unpkg.com/@shopify/polaris@5.1.0/dist/styles.css" />
8
- </head>
9
- <body>
10
- <div>
11
- <div>
12
- <h1>Waiting for React Sever to boot up.</h1>
13
- <p>This page will refresh automatically.</p>
14
- </div>
15
- <p>
16
- If this error persists, ensure <code>@shopify/react-server</code>
17
- is running on <code>http://localhost:8081</code>.
18
- </p>
19
- </div>
20
- </body>
21
- </html>