quilt_rails 1.2.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +47 -4
- data/Rakefile +2 -0
- data/app/controllers/quilt/ui_controller.rb +11 -0
- data/config/routes.rb +6 -0
- data/lib/generators/quilt/USAGE +5 -0
- data/lib/generators/quilt/install_generator.rb +36 -0
- data/lib/generators/quilt/templates/App.tsx +7 -0
- data/lib/generators/quilt/templates/routes.rb +5 -0
- data/lib/generators/sewing_kit/USAGE +5 -0
- data/lib/generators/sewing_kit/install_generator.rb +21 -0
- data/lib/generators/sewing_kit/templates/sewing-kit.config.ts +7 -0
- data/lib/quilt_rails/engine.rb +7 -0
- data/lib/quilt_rails/react_renderable.rb +3 -1
- data/lib/quilt_rails/version.rb +1 -1
- data/lib/quilt_rails.rb +1 -1
- metadata +40 -3
- data/lib/quilt_rails/railtie.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5214ca27d069782ed72ddcd0f8efe1570ac2d8ebbf71df664f01d88977b09d80
|
4
|
+
data.tar.gz: c80609914deb36fb2fe95b683b5bdca6bab97f2100609daf95e9938a31a35e4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98813d5e73ad5a700318b8185f08db41863665adb071bef21e9abfea66cbda8810f42ee4c3d7065dbc6fbd32111de9b875964a215258d3fdb6fd71ddd0bfaaab
|
7
|
+
data.tar.gz: 0601b77ac976964817c259c5b4fc9d92356493ebe7f9bf617a5be03b8da9493e8cc04375bba08d6bedff54aec5db5b0fc7c5df0ca22ee9ff6eab6bb09f047e4b
|
data/README.md
CHANGED
@@ -6,13 +6,20 @@ This document focuses on Rails integration. For details of `@shopify/react-serve
|
|
6
6
|
|
7
7
|
## Quick Start
|
8
8
|
|
9
|
-
|
9
|
+
### Add Ruby dependencies
|
10
|
+
|
11
|
+
`bundle add sewing_kit quilt_rails`
|
12
|
+
|
13
|
+
First, create a Rails project using `dev init`. Next, run `rails generate quilt:install`. This will install the Node dependencies, provide a basic React app (in TypeScript) and mounts the Quilt engine inside of your `config/routes.rb` file.
|
14
|
+
|
15
|
+
## Manual Installation
|
16
|
+
|
17
|
+
You can also perform the steps within the rake task manually by following the guide below.
|
10
18
|
|
11
19
|
### Install Dependencies
|
12
20
|
|
13
21
|
```sh
|
14
|
-
# Add
|
15
|
-
bundle add sewing_kit quilt_rails
|
22
|
+
# Add Node dependencies
|
16
23
|
yarn add @shopify/sewing-kit @shopify/react-server
|
17
24
|
|
18
25
|
# Optional - add Polaris and quilt libraries
|
@@ -26,7 +33,33 @@ dev up
|
|
26
33
|
|
27
34
|
sewing_kit looks for JavaScript in `app/ui/index.js`. The code in `index.js` (and any imported JS/CSS) will be built into a `main` bundle.
|
28
35
|
|
29
|
-
### Setup
|
36
|
+
### Rails Setup
|
37
|
+
|
38
|
+
There are 2 ways to consume this package.
|
39
|
+
|
40
|
+
### Option 1: Mount the Engine
|
41
|
+
|
42
|
+
Add the engine to `routes.rb`.
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
# config/routes.rb
|
46
|
+
Rails.application.routes.draw do
|
47
|
+
# ...
|
48
|
+
mount Quilt::Engine, at: '/'
|
49
|
+
end
|
50
|
+
```
|
51
|
+
|
52
|
+
Where `at` is the path where your App will respond with the React App. If you only want a sub-section of routes to respond with the React App, you can pass in the path to that sub-section here. For example:
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
# config/routes.rb
|
56
|
+
Rails.application.routes.draw do
|
57
|
+
# ...
|
58
|
+
mount Quilt::Engine, at: '/path/to/react'
|
59
|
+
end
|
60
|
+
```
|
61
|
+
|
62
|
+
### Option 2: Add your react controller and routes
|
30
63
|
|
31
64
|
Create a `ReactController` to handle react requests.
|
32
65
|
|
@@ -80,3 +113,13 @@ function App() {
|
|
80
113
|
|
81
114
|
export default App;
|
82
115
|
```
|
116
|
+
|
117
|
+
## Rails Generators'
|
118
|
+
|
119
|
+
### `quilt:install`
|
120
|
+
|
121
|
+
Installs the Node dependencies, provide a basic React app (in TypeScript) and mounts the Quilt engine inside of your `config/routes.rb` file.
|
122
|
+
|
123
|
+
### `sewing-kit:install`
|
124
|
+
|
125
|
+
Adds a basic `sewing-kit.config.ts` file.
|
data/Rakefile
CHANGED
data/config/routes.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Quilt
|
4
|
+
class InstallGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('templates', __dir__)
|
6
|
+
|
7
|
+
desc "This generator mounts the Quilt engine and adds a React app."
|
8
|
+
|
9
|
+
def install_js_dependencies
|
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?
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_app_file
|
15
|
+
app_path = "app/ui/index.tsx"
|
16
|
+
|
17
|
+
unless File.exist?(app_path)
|
18
|
+
copy_file "App.tsx", app_path
|
19
|
+
|
20
|
+
log("React App at #{app_path}", 'wrote')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def create_route_file
|
25
|
+
routes_path = "config/routes.rb"
|
26
|
+
|
27
|
+
if File.exist?(routes_path)
|
28
|
+
route "mount Quilt::Engine, at: '/'"
|
29
|
+
else
|
30
|
+
copy_file "routes.rb", routes_path
|
31
|
+
end
|
32
|
+
|
33
|
+
say "Added Quilt engine mount"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SewingKit
|
4
|
+
class InstallGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('templates', __dir__)
|
6
|
+
|
7
|
+
desc "This generator creates a sewing-kit config file."
|
8
|
+
|
9
|
+
def create_config
|
10
|
+
config_path = "config/sewing-kit.config.ts"
|
11
|
+
|
12
|
+
if File.exist?(config_path)
|
13
|
+
say "Sewing kit config already exists"
|
14
|
+
else
|
15
|
+
copy_file "sewing-kit.config.ts", config_path
|
16
|
+
|
17
|
+
say "Sewing kit config"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
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: 1.
|
4
|
+
version: 1.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: 2019-08-
|
11
|
+
date: 2019-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -38,6 +38,34 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.9.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rubocop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.74'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.74'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop-git
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.1.3
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.1.3
|
41
69
|
description: A turn-key solution for integrating server-rendered react into your Rails
|
42
70
|
app using Quilt libraries.
|
43
71
|
email:
|
@@ -48,9 +76,18 @@ extra_rdoc_files: []
|
|
48
76
|
files:
|
49
77
|
- README.md
|
50
78
|
- Rakefile
|
79
|
+
- app/controllers/quilt/ui_controller.rb
|
80
|
+
- config/routes.rb
|
81
|
+
- lib/generators/quilt/USAGE
|
82
|
+
- lib/generators/quilt/install_generator.rb
|
83
|
+
- lib/generators/quilt/templates/App.tsx
|
84
|
+
- lib/generators/quilt/templates/routes.rb
|
85
|
+
- lib/generators/sewing_kit/USAGE
|
86
|
+
- lib/generators/sewing_kit/install_generator.rb
|
87
|
+
- lib/generators/sewing_kit/templates/sewing-kit.config.ts
|
51
88
|
- lib/quilt_rails.rb
|
52
89
|
- lib/quilt_rails/configuration.rb
|
53
|
-
- lib/quilt_rails/
|
90
|
+
- lib/quilt_rails/engine.rb
|
54
91
|
- lib/quilt_rails/react_renderable.rb
|
55
92
|
- lib/quilt_rails/version.rb
|
56
93
|
homepage: https://github.com/Shopify/quilt/tree/master/gems/quilt_rails
|