quilt_rails 1.7.0 → 1.8.0

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: 7327df33398c0cf113388e765ed893ba61d6d90c0eeec85989a52f0974da4d77
4
- data.tar.gz: c99c5ae5c7cfc371e7687741fcd36fed8dfa002d64d9f52eeacb8d27598c5c08
3
+ metadata.gz: 393d55d7b0940edb22882fff283debdc403bd991172f4f4fc80c8f11e9e63ca7
4
+ data.tar.gz: 54eab8702f1f45dcba856e79474ccbde6f575e200b4a4fbb094ffb822d5040cb
5
5
  SHA512:
6
- metadata.gz: '09c0e63254e5c3e18ac56a52eb28470fd5994a8c1887052d26c2b385391f5fe9ba294f3afd43e8942a039bb5a4d12fab2746e38a1f924de8c920f08c67e1176c'
7
- data.tar.gz: d97df6949379a1ec9a6f7ae9636f7008f0a791065a37ba6e5715bf0f489ce7bb7135a44817f6fb5ea4915b1cfea7810fe75f9f54db807b79f5d14c3fbd014315
6
+ metadata.gz: 000d1fee3b1fc1650f9f7ef9eefe5794facbdd3b05907e7d0b5e72214e7486a76a1c07f9eedd02593c3e366f6ffdcd7bf8592d1db744cdfb6d876cc3a48caec7
7
+ data.tar.gz: 9444a83ad67ff6298e10554bf3bf33c3a0db9b22bfd6f19f8cf918c6d31d4ed0f62cc369b3fe44867cf2bab41bf5242c991e0820c63b9c671b0313a9d4a8cb2f
data/README.md CHANGED
@@ -63,8 +63,8 @@ An application can also be setup manually using the following steps.
63
63
  # Add core Node dependencies
64
64
  yarn add @shopify/sewing-kit @shopify/react-server
65
65
 
66
- # Add Polaris and React
67
- yarn add @shopify/polaris react react-dom
66
+ # Add React
67
+ yarn add react react-dom
68
68
 
69
69
  yarn
70
70
  dev up
@@ -121,22 +121,15 @@ Add routes to default to the `ReactController`.
121
121
 
122
122
  `sewing_kit` looks for the top level component of your React app in `app/ui/index`. The component exported from this component (and any imported JS/CSS) will be built into a `main` bundle, and used to render the initial server-rendered markup.
123
123
 
124
- We will add a basic entrypoint using React with Polaris components.
124
+ We will add a basic entrypoint using React with some HTML.
125
125
 
126
126
  ```tsx
127
127
  // app/ui/index.tsx
128
128
 
129
129
  import React from 'react';
130
- import {AppProvider, Page, Card} from '@shopify/polaris';
131
130
 
132
131
  function App() {
133
- return (
134
- <AppProvider>
135
- <Page title="Hello">
136
- <Card sectioned>Hi there</Card>
137
- </Page>
138
- </AppProvider>
139
- );
132
+ return <h1>My application ❤️</h1>;
140
133
  }
141
134
 
142
135
  export default App;
@@ -165,7 +158,7 @@ The basic layout for an app using `quilt_rails` and friends will have a `ui` fol
165
158
  └─- react_controller.rb (see above)
166
159
  ```
167
160
 
168
- ### Rails, Polaris, and React
161
+ ### Rails and React
169
162
 
170
163
  A more complex application will want a more complex layout. The following shows scalable locations for:
171
164
 
@@ -181,7 +174,7 @@ A more complex application will want a more complex layout. The following shows
181
174
  └── ui
182
175
  ├─- index.{js|ts} (exports a React component)
183
176
  ├── styles (optional)
184
- └── settings.scss (global vars and @polaris overrides)
177
+ └── shared.scss (common functions/mixins you want available in every scss file. Requires configuring `plugin.sass`'s `autoInclude` option in `sewing-kit.config.js`)
185
178
 
186
179
  └── tests (optional)
187
180
  │ └── each-test.{js|ts}
@@ -293,53 +286,15 @@ describe('MyComponent', () => {
293
286
  });
294
287
  ```
295
288
 
296
- ### Test setup files
297
-
298
- By default, the jest plugin will look for test setup files under `/app/ui/tests`.
299
-
300
- `setup` can be used to add any custom polyfills needed for the testing environment.
301
-
302
- ```tsx
303
- // app/ui/tests/setup.ts
304
-
305
- import 'isomorphic-fetch';
306
- import 'raf/polyfill';
307
- import {URL, URLSearchParams} from 'url';
308
-
309
- (global as any).URL = URL;
310
- (global as any).URLSearchParams = URLSearchParams;
311
- ```
312
-
313
- `each-test` can be used for any logic that needs to run for each individual test suite. Any setup logic that needs to happen with `jest` globals in scope, such as importing custom matchers, should also be done here.
289
+ #### Customizing the test environment
314
290
 
315
- ```tsx
316
- // app/ui/tests/each-test.ts
291
+ 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.
317
292
 
318
- // we cannot import these in `setup` because `expect` will not be defined
319
- import '@shopify/react-testing/matchers';
320
-
321
- beforeAll(() => {
322
- console.log('I will run before every test suite');
323
- });
324
-
325
- beforeEach(() => {
326
- console.log('I will run before every test case');
327
- });
328
-
329
- afterEach(() => {
330
- console.log('I will run after every test case');
331
- });
332
-
333
- afterAll(() => {
334
- console.log('I will run after every test suite');
335
- });
336
- ```
337
-
338
- For more complete documentation of the jest plugin see [it's documentation](https://github.com/Shopify/sewing-kit/tree/master/docs/plugins/jest.md).
293
+ 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.
339
294
 
340
295
  ### Interacting with the request and response in React code
341
296
 
342
- React-server sets up [@shopify/react-network](https://github.com/Shopify/quilt/blob/master/packages/react-network/src/hooks.ts#L25) automatically, so most interactions with the request or response can be done from inside the React app.
297
+ 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.
343
298
 
344
299
  #### Example: getting headers
345
300
 
@@ -347,7 +302,6 @@ React-server sets up [@shopify/react-network](https://github.com/Shopify/quilt/b
347
302
  // app/ui/index.tsx
348
303
 
349
304
  import React from 'react';
350
- import {AppProvider, Page, Card} from '@shopify/polaris';
351
305
  import {useRequestHeader} from '@shopify/react-network';
352
306
 
353
307
  function App() {
@@ -355,12 +309,10 @@ function App() {
355
309
  const someHeaderICareAbout = useRequestHeader('some-header');
356
310
 
357
311
  return (
358
- <AppProvider>
359
- <Page title="Hello">
360
- {someHeaderICareAbout}
361
- <Card sectioned>Hi there</Card>
362
- </Page>
363
- </AppProvider>
312
+ <>
313
+ <h1>My application ❤️</h1>
314
+ <div>{someHeaderICareAbout}</div>
315
+ </>
364
316
  );
365
317
  }
366
318
 
@@ -373,20 +325,13 @@ export default App;
373
325
  // app/ui/index.tsx
374
326
 
375
327
  import React from 'react';
376
- import {AppProvider, Page, Card} from '@shopify/polaris';
377
328
  import {useRedirect} from '@shopify/react-network';
378
329
 
379
330
  function App() {
380
331
  // redirect to google as soon as we render
381
332
  useRedirect('www.google.com');
382
333
 
383
- return (
384
- <AppProvider>
385
- <Page title="Hello">
386
- <Card sectioned>Hi there</Card>
387
- </Page>
388
- </AppProvider>
389
- );
334
+ return <h1>My application ❤️</h1>;
390
335
  }
391
336
 
392
337
  export default App;
@@ -8,7 +8,24 @@ module Quilt
8
8
 
9
9
  def install_js_dependencies
10
10
  say "Installing @shopify/react-server and @shopify/sewing-kit dependencies"
11
- system("yarn add @shopify/sewing-kit @shopify/react-server") unless Rails.env.test?
11
+ system("yarn add "\
12
+ "@shopify/sewing-kit "\
13
+ "@shopify/react-server "\
14
+ "typescript "\
15
+ "react "\
16
+ "react-dom "\
17
+ "@types/react "\
18
+ "@types/react-dom") unless Rails.env.test?
19
+ end
20
+
21
+ def create_tsconfig
22
+ tsconfig_path = "tsconfig.json"
23
+
24
+ unless File.exist?(tsconfig_path)
25
+ copy_file "tsconfig.json", tsconfig_path
26
+
27
+ log(tsconfig_path, 'wrote')
28
+ end
12
29
  end
13
30
 
14
31
  def create_app_file
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "@shopify/typescript-configs/application.json",
3
+ "compilerOptions": {
4
+ "baseUrl": ".",
5
+ "rootDir": "."
6
+ },
7
+ "include": ["app/ui"]
8
+ }
@@ -1,7 +1,7 @@
1
1
  /* eslint-env node */
2
2
 
3
- module.exports = function sewingKitConfig() {
4
- return {
5
- name: 'your-app-name',
6
- };
7
- };
3
+ import {Env, Plugins} from '@shopify/sewing-kit';
4
+
5
+ export default function sewingKitConfig(_plugins: Plugins, _env: Env) {
6
+ return {};
7
+ }
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Quilt
3
- VERSION = "1.7.0"
3
+ VERSION = "1.8.0"
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: 1.7.0
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mathew Allen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-24 00:00:00.000000000 Z
11
+ date: 2019-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -82,6 +82,7 @@ files:
82
82
  - lib/generators/quilt/install_generator.rb
83
83
  - lib/generators/quilt/templates/App.tsx
84
84
  - lib/generators/quilt/templates/routes.rb
85
+ - lib/generators/quilt/templates/tsconfig.json
85
86
  - lib/generators/sewing_kit/USAGE
86
87
  - lib/generators/sewing_kit/install_generator.rb
87
88
  - lib/generators/sewing_kit/templates/sewing-kit.config.ts