react_on_rails 9.0.0.beta.12 → 9.0.0.rc.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -3
- data/CONTRIBUTING.md +2 -2
- data/README.md +21 -1
- data/Rakefile +1 -1
- data/docs/additional-reading/rails-engine-integration.md +1 -1
- data/docs/basics/configuration.md +1 -1
- data/docs/contributor-info/generator-testing.md +0 -9
- data/docs/tutorial.md +6 -21
- data/lib/generators/react_on_rails/base_generator.rb +4 -4
- data/lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb +1 -1
- data/lib/react_on_rails/configuration.rb +4 -4
- data/lib/react_on_rails/version.rb +1 -1
- data/lib/tasks/assets.rake +4 -4
- data/package.json +2 -2
- data/rakelib/example_type.rb +3 -58
- data/rakelib/examples.rake +5 -53
- data/rakelib/run_rspec.rake +2 -2
- data/yarn.lock +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4a9c8b1de68556135bbc7fcebff15bbcf1de1b7
|
4
|
+
data.tar.gz: 66c01da5faf9714ed5a590550123ca417f733b37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af5572237cb59ba13e8c6d26ed2b4a1e0f0090dac8e0a2f97dcdd2fd2511a8405188b28ed0fd34e6d12df8f6dfbc456fa0cd5e9f442b5c847963d3aebbc26065
|
7
|
+
data.tar.gz: 348003c600a8269ed0d1fc3deb6e1e57f21304dceb2b2f9179d6d05380e7d0b4d0d5ac4d8f68d3b0b00f5648f9b247b43be687d97130febc4dca705ee35bdbaa
|
data/CHANGELOG.md
CHANGED
@@ -18,7 +18,7 @@ All 9.0.0 beta versions can be viewed in [PR 908](https://github.com/shakacode/r
|
|
18
18
|
1. Added `config.node_modules_location` which defaults to `""` if Webpacker is installed. You may want to set this to 'client'` to `config/initializers/react_on_rails.rb` to keep your node_modules inside of `/client`
|
19
19
|
2. Renamed
|
20
20
|
* config.npm_build_test_command ==> config.build_test_command
|
21
|
-
* config.
|
21
|
+
* config.build_production_command ==> config.build_production_command
|
22
22
|
|
23
23
|
- Update the gemfile. Switch over to using the webpacker gem.
|
24
24
|
|
@@ -444,7 +444,7 @@ No changes.
|
|
444
444
|
- See [shakacode/react-webpack-rails-tutorial/pull/287](https://github.com/shakacode/react-webpack-rails-tutorial/pull/287) for an example of upgrading from v5.
|
445
445
|
|
446
446
|
- To configure the asset compliation you can either
|
447
|
-
1. Specify a `config/react_on_rails` setting for `
|
447
|
+
1. Specify a `config/react_on_rails` setting for `build_production_command` to be nil to turn this feature off.
|
448
448
|
2. Specify the script command you want to run to build your production assets, and remove your assets.rake file.
|
449
449
|
|
450
450
|
- If you are using the ReactOnRails test helper, then you will need to add the 'config.npm_build_test_command' to your config to tell react_on_rails what command to run when you run rspec.
|
@@ -455,7 +455,7 @@ Here is the addition to the generated config file:
|
|
455
455
|
```ruby
|
456
456
|
# This configures the script to run to build the production assets by webpack. Set this to nil
|
457
457
|
# if you don't want react_on_rails building this file for you.
|
458
|
-
config.
|
458
|
+
config.build_production_command = "npm run build:production"
|
459
459
|
|
460
460
|
# If you are using the ReactOnRails::TestHelper.configure_rspec_to_compile_assets(config)
|
461
461
|
# with rspec then this controls what npm command is run
|
data/CONTRIBUTING.md
CHANGED
@@ -46,7 +46,7 @@ When making doc changes, we want the change to work on both the gitbook and the
|
|
46
46
|
|
47
47
|
```sh
|
48
48
|
cd react_on_rails/
|
49
|
-
bundle && yarn && rake examples:
|
49
|
+
bundle && yarn && rake examples:gen_all && rake node_package && rake
|
50
50
|
```
|
51
51
|
|
52
52
|
In order to run tests in browser
|
@@ -145,7 +145,7 @@ yarn run install-react-on-rails
|
|
145
145
|
```
|
146
146
|
_Note: this runs npm under the hood as explained in **Test NPM for react-on-rails** section above_
|
147
147
|
|
148
|
-
From now on, the example and dummy apps will use your local node_package folder as the react-on-rails node package. This will also be done automatically for you via the `rake examples:
|
148
|
+
From now on, the example and dummy apps will use your local node_package folder as the react-on-rails node package. This will also be done automatically for you via the `rake examples:gen_all` rake task.
|
149
149
|
|
150
150
|
*Side note: It's critical to use the alias section of the webpack config to avoid a double inclusion error. This has already been done for you in the example and dummy apps, but for reference:*
|
151
151
|
|
data/README.md
CHANGED
@@ -4,6 +4,26 @@
|
|
4
4
|
|
5
5
|
[rails/webpacker](https://github.com/rails/webpacker) just shipped 3.0. This now enables me to ship version 9.0. See [PR #908](https://github.com/shakacode/react_on_rails/pull/908) for more details.
|
6
6
|
|
7
|
+
# React on Rails v9 beta 12 is based on Webpacker 3.0!
|
8
|
+
|
9
|
+
* See the updated [Tutorial](https://github.com/shakacode/react_on_rails/blob/rails-webpacker/docs/tutorial.md).
|
10
|
+
* I'm grateful for any [PR 908 reviews](https://github.com/shakacode/react_on_rails/pull/908).
|
11
|
+
|
12
|
+
## Steps to a New App with rails/webpacker v3 plus React on Rails v9.beta:
|
13
|
+
1. New Rails app: `rails new my-app --webpack=react`. `cd` into the directory.
|
14
|
+
2. Add beta gem version: `gem 'react_on_rails', '~> 9.0.0.beta.12'`
|
15
|
+
3. Run the generator: `rails generate react_on_rails:install`
|
16
|
+
4. Start the app: `foreman start -f Procfile.dev`
|
17
|
+
5. Visit http://localhost:3000/hello_world
|
18
|
+
|
19
|
+
Turn on HMR (Hot reloading)
|
20
|
+
1. Edit `config/webpacker.yml` and set `hmr: true`
|
21
|
+
2. Start the app: `foreman start -f Procfile.dev-server`
|
22
|
+
3. Visit http://localhost:3000/hello_world
|
23
|
+
4. Edit `app/javascript/bundles/HelloWorld/components/HelloWorld.jsx`, hit save, and see the screen update.
|
24
|
+
|
25
|
+
---------------
|
26
|
+
|
7
27
|
## Thank you from Justin Gordon and [ShakaCode](http://www.shakacode.com)
|
8
28
|
|
9
29
|
Thank you for considering using [React on Rails](https://github.com/shakacode/react_on_rails).
|
@@ -577,7 +597,7 @@ If you are using [jquery-ujs](https://github.com/rails/jquery-ujs) for AJAX call
|
|
577
597
|
## Deployment
|
578
598
|
* Version 6.0 puts the necessary precompile steps automatically in the rake precompile step. You can, however, disable this by setting certain values to nil in the [config/initializers/react_on_rails.rb](https://github.com/shakacode/react_on_rails/tree/master/spec/dummy/config/initializers/react_on_rails.rb).
|
579
599
|
* `config.symlink_non_digested_assets_regex`: Set to nil to turn off the setup of non-js assets.
|
580
|
-
* `
|
600
|
+
* `build_production_command`: Set to nil to turn off the precompilation of the js assets.
|
581
601
|
* See the [Heroku Deployment](./docs/additional-reading/heroku-deployment.md) doc for specifics regarding Heroku. The information here should apply to other deployments.
|
582
602
|
|
583
603
|
## Integration with Node.js for Server Rendering
|
data/Rakefile
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# Rake will automatically load any *.rake files inside of the "rakelib" folder
|
4
4
|
# See rakelib/
|
5
5
|
tasks = %w[run_rspec lint]
|
6
|
-
prepare_for_ci = %w[node_package dummy_apps
|
6
|
+
prepare_for_ci = %w[node_package dummy_apps]
|
7
7
|
|
8
8
|
if ENV["USE_COVERALLS"] == "TRUE"
|
9
9
|
require "coveralls/rake/task"
|
@@ -20,7 +20,7 @@ Rake.application.remove_task('react_on_rails:assets:compile_environment')
|
|
20
20
|
|
21
21
|
task 'react_on_rails:assets:compile_environment' do
|
22
22
|
path = File.join(YourEngineName::Engine.root, 'client')
|
23
|
-
sh "cd #{path} && #{ReactOnRails.configuration.
|
23
|
+
sh "cd #{path} && #{ReactOnRails.configuration.build_production_command}"
|
24
24
|
end
|
25
25
|
```
|
26
26
|
## In the project including your engine
|
@@ -13,7 +13,7 @@ ReactOnRails.configure do |config|
|
|
13
13
|
|
14
14
|
# This configures the script to run to build the production assets by webpack. Set this to nil
|
15
15
|
# if you don't want react_on_rails building this file for you.
|
16
|
-
config.
|
16
|
+
config.build_production_command = "RAILS_ENV=production bin/webpack"
|
17
17
|
|
18
18
|
################################################################################
|
19
19
|
################################################################################
|
@@ -9,12 +9,3 @@ We are currently using Travis for CI. Because of the way Travis works, it is not
|
|
9
9
|
## Configuring what Apps are Generated
|
10
10
|
You can specify additional apps to generate and test by adding to the rakelib/examples_config.yml file. The necessary build and test tasks will automatically be created for you dynamically at runtime.
|
11
11
|
|
12
|
-
## More on the Rake Tasks
|
13
|
-
In order to maximize efficiency, we took several steps to improve the performance of the rake tasks that utilize somewhat advanced rake functionality such as task dependencies, `file` tasks, task synthesizing, and concurrent tasks with `multitask`.
|
14
|
-
|
15
|
-
For example, re-generating the app, running `yarn`, and re-generating the webpack bundles are all only done when they need to be done. Rake will also run certain tasks, including those that generate multiple applications, concurrently.
|
16
|
-
|
17
|
-
For more insight, see:
|
18
|
-
|
19
|
-
- [Avdi Grimm's series of articles on Rake](http://devblog.avdi.org/2014/04/30/learn-advanced-rake-in-7-episodes/)
|
20
|
-
- [Martin Fowler's rake article](http://martinfowler.com/articles/rake.html)
|
data/docs/tutorial.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# React on Rails Basic Tutorial
|
2
2
|
|
3
|
+
* NOTE: Please be sure to use the BETA or RC versions of React on Rails until 9.0 is released.*
|
4
|
+
|
5
|
+
|
3
6
|
This tutorial setups up a new Rails app with **React on Rails**, demonstrating Rails + React + Redux + Server Rendering. It is updated to 9.0.0.
|
4
7
|
|
5
8
|
After finishing this tutorial you will get an application that can do the following (live on Heroku):
|
@@ -55,8 +58,6 @@ bundle exec rails webpacker:install:react
|
|
55
58
|
```
|
56
59
|
|
57
60
|
|
58
|
-
![01](https://cloud.githubusercontent.com/assets/20628911/17464917/3c29e55a-5cf2-11e6-8754-046ba3ee92d9.png)
|
59
|
-
|
60
61
|
|
61
62
|
Add the **React On Rails** gem to your Gemfile:
|
62
63
|
|
@@ -65,10 +66,9 @@ gem 'react_on_rails', '9.0.0' # use latest gem version, prefer exact ver
|
|
65
66
|
```
|
66
67
|
|
67
68
|
|
68
|
-
![02](https://cloud.githubusercontent.com/assets/20628911/17464919/3c2d74c2-5cf2-11e6-8704-a84958832fbb.png)
|
69
|
-
|
70
69
|
Then run `bundle` and commit the git repository (or `rails generate` will not work properly)
|
71
70
|
|
71
|
+
|
72
72
|
```
|
73
73
|
bundle
|
74
74
|
|
@@ -85,21 +85,15 @@ rails generate react_on_rails:install
|
|
85
85
|
bundle && yarn
|
86
86
|
```
|
87
87
|
|
88
|
-
![03](https://cloud.githubusercontent.com/assets/20628911/17464918/3c2c1f00-5cf2-11e6-9525-7b2e15659e01.png)
|
89
|
-
|
90
88
|
and then run server with
|
91
89
|
|
92
90
|
```
|
93
91
|
foreman start -f Procfile.dev
|
94
92
|
```
|
95
93
|
|
96
|
-
![04](https://cloud.githubusercontent.com/assets/20628911/17464921/3c2fdb40-5cf2-11e6-9343-6afa53593a70.png)
|
97
|
-
|
98
94
|
Visit http://localhost:3000/hello_world and see your **React On Rails** app running!
|
99
95
|
Note, foreman defaults to PORT 5000 unless you set the value of PORT in your environment or in the Procfile.
|
100
96
|
|
101
|
-
![05](https://cloud.githubusercontent.com/assets/20628911/17464920/3c2e8ae2-5cf2-11e6-9e30-5ec5f9e2cbc6.png)
|
102
|
-
|
103
97
|
### Custom IP & PORT setup (Cloud9 example)
|
104
98
|
|
105
99
|
In case you are running some custom setup with different IP or PORT you should also edit Procfile.dev. For example to be able to run on free Cloud9 IDE we are putting IP 0.0.0.0 and PORT 8080. The default generated file `Procfile.dev` uses `-p 3000`.
|
@@ -115,8 +109,8 @@ Then visit https://your-shared-addr.c9users.io:8080/hello_world
|
|
115
109
|
|
116
110
|
It's super important to exclude certain directories from RubyMine or else it will slow to a crawl as it tries to parse all the npm files.
|
117
111
|
|
118
|
-
* `public/
|
119
|
-
* `
|
112
|
+
* Generated files, per the settings in your `config/webpacker.yml`, which default to `public/packs` and `public/packs-test`
|
113
|
+
* `node_modules`
|
120
114
|
|
121
115
|
## Deploying to Heroku
|
122
116
|
|
@@ -225,13 +219,4 @@ git commit -m "Latest changes"
|
|
225
219
|
git push heroku master
|
226
220
|
```
|
227
221
|
|
228
|
-
![10](https://cloud.githubusercontent.com/assets/20628911/17465017/1f38fbaa-5cf4-11e6-8d86-a3d91e3878e0.png)
|
229
|
-
|
230
|
-
## Links
|
231
|
-
These are updated for 8.0.0:
|
232
|
-
|
233
|
-
* [PR for using the generator with the Redux option](https://github.com/shakacode/react_on_rails-test-new-redux-generation/pull/17)
|
234
|
-
* [PR showing the changes to deploy to Heroku](https://github.com/shakacode/react_on_rails-test-new-redux-generation/pull/18)
|
235
|
-
* [Live on Heroku](https://hello-react-on-rails-8-0-0.herokuapp.com/)
|
236
|
-
|
237
222
|
Feedback is greatly appreciated! As are stars on github! If you want personalized help, don't hesitate to get in touch with us at [contact@shakacode.com](mailto:contact@shakacode.com).
|
@@ -93,19 +93,19 @@ module ReactOnRails
|
|
93
93
|
|
94
94
|
- Change this line app/views/hello_world/index.html.erb to `prerender: true` to see
|
95
95
|
server rendering (right click on page and select "view source").
|
96
|
-
|
96
|
+
|
97
97
|
<%= react_component("HelloWorldApp", props: @hello_world_props, prerender: true) %>
|
98
98
|
|
99
99
|
- Run the foreman command to start the rails server and run webpack in HMR mode. Be sure
|
100
100
|
to change your development/dev_server/hmr setting to true to see HMR in action.
|
101
101
|
Note, you cannot use the default Procfile.dev-server setup with server rendering.
|
102
|
-
|
102
|
+
|
103
103
|
foreman start -f Procfile.dev-server
|
104
104
|
|
105
105
|
- You may run the commands in the Procfiles in separate shells rather than using foreman.
|
106
106
|
|
107
|
-
- See the documentation on https://github.com/rails/webpacker
|
108
|
-
configuration
|
107
|
+
- See the documentation on https://github.com/rails/webpacker/blob/master/docs/webpack.md
|
108
|
+
for how to customize the default webpack configuration.
|
109
109
|
|
110
110
|
- Visit http://localhost:3000/hello_world and see your React On Rails app running!
|
111
111
|
MSG
|
data/lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
ReactOnRails.configure do |config|
|
6
6
|
# This configures the script to run to build the production assets by webpack. Set this to nil
|
7
7
|
# if you don't want react_on_rails building this file for you.
|
8
|
-
config.
|
8
|
+
config.build_production_command = "RAILS_ENV=production bin/webpack"
|
9
9
|
|
10
10
|
################################################################################
|
11
11
|
################################################################################
|
@@ -107,7 +107,7 @@ module ReactOnRails
|
|
107
107
|
build_test_command: "",
|
108
108
|
i18n_dir: "",
|
109
109
|
i18n_yml_dir: "",
|
110
|
-
|
110
|
+
build_production_command: ""
|
111
111
|
)
|
112
112
|
end
|
113
113
|
|
@@ -118,7 +118,7 @@ module ReactOnRails
|
|
118
118
|
:server_renderer_timeout, :skip_display_none, :raise_on_prerender_error,
|
119
119
|
:generated_assets_dirs, :generated_assets_dir,
|
120
120
|
:webpack_generated_files, :rendering_extension, :build_test_command,
|
121
|
-
:
|
121
|
+
:build_production_command,
|
122
122
|
:i18n_dir, :i18n_yml_dir,
|
123
123
|
:server_render_method, :symlink_non_digested_assets_regex
|
124
124
|
|
@@ -130,7 +130,7 @@ module ReactOnRails
|
|
130
130
|
skip_display_none: nil, generated_assets_dirs: nil,
|
131
131
|
generated_assets_dir: nil, webpack_generated_files: nil,
|
132
132
|
rendering_extension: nil, build_test_command: nil,
|
133
|
-
|
133
|
+
build_production_command: nil,
|
134
134
|
i18n_dir: nil, i18n_yml_dir: nil,
|
135
135
|
server_render_method: "ExecJS", symlink_non_digested_assets_regex: nil)
|
136
136
|
self.node_modules_location = node_modules_location
|
@@ -138,7 +138,7 @@ module ReactOnRails
|
|
138
138
|
self.generated_assets_dirs = generated_assets_dirs
|
139
139
|
self.generated_assets_dir = generated_assets_dir
|
140
140
|
self.build_test_command = build_test_command
|
141
|
-
self.
|
141
|
+
self.build_production_command = build_production_command
|
142
142
|
self.i18n_dir = i18n_dir
|
143
143
|
self.i18n_yml_dir = i18n_yml_dir
|
144
144
|
|
data/lib/tasks/assets.rake
CHANGED
@@ -50,9 +50,9 @@ namespace :react_on_rails do
|
|
50
50
|
namespace :assets do
|
51
51
|
desc <<-DESC.strip_heredoc
|
52
52
|
Compile assets with webpack
|
53
|
-
Uses command defined with ReactOnRails.configuration.
|
53
|
+
Uses command defined with ReactOnRails.configuration.build_production_command
|
54
54
|
|
55
|
-
sh "#{ReactOnRails::Utils.prepend_cd_node_modules_directory('<ReactOnRails.configuration.
|
55
|
+
sh "#{ReactOnRails::Utils.prepend_cd_node_modules_directory('<ReactOnRails.configuration.build_production_command>')}"
|
56
56
|
DESC
|
57
57
|
task webpack: :locale do
|
58
58
|
if Rake::Task.task_defined?("webpacker:compile")
|
@@ -60,9 +60,9 @@ namespace :react_on_rails do
|
|
60
60
|
Rake::Task["webpacker:compile"].clear
|
61
61
|
end
|
62
62
|
|
63
|
-
if ReactOnRails.configuration.
|
63
|
+
if ReactOnRails.configuration.build_production_command.present?
|
64
64
|
sh ReactOnRails::Utils.prepend_cd_node_modules_directory(
|
65
|
-
ReactOnRails.configuration.
|
65
|
+
ReactOnRails.configuration.build_production_command
|
66
66
|
).to_s
|
67
67
|
end
|
68
68
|
end
|
data/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-on-rails",
|
3
|
-
"version": "9.0.0-
|
3
|
+
"version": "9.0.0-rc.0",
|
4
4
|
"description": "react-on-rails JavaScript for react_on_rails Ruby gem",
|
5
5
|
"main": "node_package/lib/ReactOnRails.js",
|
6
6
|
"directories": {
|
@@ -87,7 +87,7 @@
|
|
87
87
|
},
|
88
88
|
"homepage": "https://github.com/shakacode/react_on_rails#readme",
|
89
89
|
"dependencies": {
|
90
|
-
"react-on-rails": "^9.0.0-beta.
|
90
|
+
"react-on-rails": "^9.0.0-beta.12",
|
91
91
|
"react-redux": "^5.0.6"
|
92
92
|
}
|
93
93
|
}
|
data/rakelib/example_type.rb
CHANGED
@@ -38,47 +38,23 @@ module ReactOnRails
|
|
38
38
|
Dir.exist?(dir)
|
39
39
|
end
|
40
40
|
|
41
|
-
def node_modules_location
|
42
|
-
dir
|
43
|
-
end
|
44
|
-
|
45
|
-
def node_modules_dir
|
46
|
-
File.join(node_modules_location, "node_modules")
|
47
|
-
end
|
48
|
-
|
49
|
-
def webpack_bundles_dir
|
50
|
-
File.join(dir, "public", "packs-test")
|
51
|
-
end
|
52
|
-
|
53
|
-
def webpack_bundles
|
54
|
-
bundles = []
|
55
|
-
bundles << File.join(webpack_bundles_dir, "hello-world-bundle.js")
|
56
|
-
end
|
57
|
-
|
58
41
|
def gemfile
|
59
42
|
File.join(dir, "Gemfile")
|
60
43
|
end
|
61
44
|
|
62
|
-
def gemfile_lock
|
63
|
-
"#{gemfile}.lock"
|
64
|
-
end
|
65
|
-
|
66
|
-
def package_json
|
67
|
-
File.join(node_modules_location, "package.json")
|
68
|
-
end
|
69
|
-
|
70
45
|
# Gems we need to add to the Gemfile before bundle installing
|
71
46
|
def required_gems
|
72
47
|
relative_gem_root = Pathname(gem_root).relative_path_from(Pathname(dir))
|
73
48
|
["gem 'react_on_rails', path: '#{relative_gem_root}'"]
|
74
49
|
end
|
75
50
|
|
76
|
-
# Options we pass when running `rails new` from the command-line
|
51
|
+
# Options we pass when running `rails new` from the command-line.
|
52
|
+
# The webpack=react option is key.
|
77
53
|
def rails_options
|
78
54
|
"--skip-bundle --skip-spring --skip-git --skip-test-unit --skip-active-record --webpack=react"
|
79
55
|
end
|
80
56
|
|
81
|
-
%w[gen
|
57
|
+
%w[gen clobber npm_install build_webpack_bundles].each do |task_type|
|
82
58
|
method_name_normal = "#{task_type}_task_name" # ex: `clean_task_name`
|
83
59
|
method_name_short = "#{method_name_normal}_short" # ex: `clean_task_name_short`
|
84
60
|
|
@@ -94,37 +70,6 @@ module ReactOnRails
|
|
94
70
|
"run_rspec:#{rspec_task_name_short}"
|
95
71
|
end
|
96
72
|
|
97
|
-
def source_files
|
98
|
-
FileList.new(all_files_in_dir(generators_source_dir))
|
99
|
-
end
|
100
|
-
|
101
|
-
# Note: we need to explicitly declare a file we know is supposed to be there
|
102
|
-
# to indicate that the example is in need of being rebuilt in the case of its absence.
|
103
|
-
def generated_files
|
104
|
-
FileList.new(all_files_in_dir(dir)) do |fl|
|
105
|
-
fl.include(gemfile) # explicitly declared file (dependency of Gemfile.lock)
|
106
|
-
fl.include(package_json) # explicitly declared file (dependency of NPM Install)
|
107
|
-
fl.exclude(%r{(/node_modules(.+)?)?$}) # leave node_modules folder
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
def generated_client_files
|
112
|
-
generated_files.exclude { |f| !f.start_with?(node_modules_location) }
|
113
|
-
end
|
114
|
-
|
115
|
-
# generated files plus explicitly included files resulting from running
|
116
|
-
# bundle install, yarn, and generating the webpack bundles
|
117
|
-
def prepared_files
|
118
|
-
generated_files
|
119
|
-
.include(webpack_bundles)
|
120
|
-
.include(node_modules_dir)
|
121
|
-
.include(gemfile_lock)
|
122
|
-
end
|
123
|
-
|
124
|
-
def clean_files
|
125
|
-
generated_files
|
126
|
-
end
|
127
|
-
|
128
73
|
# Assumes we are inside a rails app's folder and necessary gems have been installed
|
129
74
|
def generator_shell_commands
|
130
75
|
shell_commands = []
|
data/rakelib/examples.rake
CHANGED
@@ -9,8 +9,6 @@ require "yaml"
|
|
9
9
|
require_relative "example_type"
|
10
10
|
require_relative "task_helpers"
|
11
11
|
include ReactOnRails::TaskHelpers
|
12
|
-
|
13
|
-
# rubocop:disable Metrics/BlockLength
|
14
12
|
namespace :examples do
|
15
13
|
# Loads data from examples_config.yml and instantiates corresponding ExampleType objects
|
16
14
|
examples_config_file = File.expand_path("../examples_config.yml", __FILE__)
|
@@ -19,41 +17,6 @@ namespace :examples do
|
|
19
17
|
|
20
18
|
# Define tasks for each example type
|
21
19
|
ExampleType.all.each do |example_type|
|
22
|
-
# GENERATED FILES
|
23
|
-
example_type.generated_files.each do |f|
|
24
|
-
file f => example_type.source_files do
|
25
|
-
Rake::Task[example_type.gen_task_name].invoke
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
# GEMFILE.LOCK
|
30
|
-
file example_type.gemfile_lock => example_type.gemfile do
|
31
|
-
bundle_install_in(example_type.dir)
|
32
|
-
end
|
33
|
-
|
34
|
-
# WEBPACK BUNDLES
|
35
|
-
example_type.webpack_bundles.each do |f|
|
36
|
-
file f => example_type.generated_client_files do
|
37
|
-
Rake::Task[example_type.build_webpack_bundles_task_name].invoke
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
# BUILD WEBPACK BUNDLES
|
42
|
-
task example_type.build_webpack_bundles_task_name_short => example_type.npm_install_task_name do
|
43
|
-
sh_in_dir(example_type.node_modules_location, example_type.build_webpack_bundles_shell_commands)
|
44
|
-
end
|
45
|
-
|
46
|
-
# # YARN INSTALL
|
47
|
-
task example_type.npm_install_task_name_short => example_type.package_json do
|
48
|
-
sh_in_dir(example_type.node_modules_location, "yarn install --mutex network")
|
49
|
-
end
|
50
|
-
|
51
|
-
# CLEAN
|
52
|
-
desc "Cleans #{example_type.name_pretty}"
|
53
|
-
task example_type.clean_task_name_short do
|
54
|
-
example_type.clean_files.each { |f| rm_rf(f) }
|
55
|
-
end
|
56
|
-
|
57
20
|
# CLOBBER
|
58
21
|
desc "Clobbers (deletes) #{example_type.name_pretty}"
|
59
22
|
task example_type.clobber_task_name_short do
|
@@ -62,39 +25,28 @@ namespace :examples do
|
|
62
25
|
|
63
26
|
# GENERATE
|
64
27
|
desc "Generates #{example_type.name_pretty}"
|
65
|
-
task example_type.gen_task_name_short => example_type.
|
28
|
+
task example_type.gen_task_name_short => example_type.clobber_task_name do
|
66
29
|
mkdir_p(example_type.dir)
|
67
30
|
sh_in_dir(examples_dir, "rails new #{example_type.name} #{example_type.rails_options}")
|
68
31
|
sh_in_dir(example_type.dir, "touch .gitignore")
|
69
32
|
append_to_gemfile(example_type.gemfile, example_type.required_gems)
|
70
33
|
bundle_install_in(example_type.dir)
|
71
34
|
sh_in_dir(example_type.dir, example_type.generator_shell_commands)
|
72
|
-
|
73
|
-
|
74
|
-
# PREPARE
|
75
|
-
desc "Prepares #{example_type.name_pretty} (generates example, `yarn`s, and generates webpack bundles)"
|
76
|
-
multitask example_type.prepare_task_name_short => example_type.prepared_files do
|
77
|
-
Rake::Task["node_package"].invoke
|
35
|
+
sh_in_dir(example_type.dir, "yarn")
|
78
36
|
end
|
79
37
|
end
|
80
38
|
|
81
|
-
desc "Cleans all example apps"
|
82
|
-
multitask clean: ExampleType.all.map(&:clean_task_name)
|
83
|
-
|
84
39
|
desc "Clobbers (deletes) all example apps"
|
85
40
|
task :clobber do
|
86
41
|
rm_rf(examples_dir)
|
87
42
|
end
|
88
43
|
|
89
44
|
desc "Generates all example apps"
|
90
|
-
|
91
|
-
|
92
|
-
desc "Prepares all example apps"
|
93
|
-
multitask prepare_all: ExampleType.all.map(&:prepare_task_name)
|
45
|
+
task gen_all: ExampleType.all.map(&:gen_task_name)
|
94
46
|
end
|
95
47
|
|
96
|
-
desc "
|
97
|
-
|
48
|
+
desc "Generates all example apps. Run `rake -D examples` to see all available options"
|
49
|
+
task examples: ["examples:gen_all"]
|
98
50
|
|
99
51
|
private
|
100
52
|
|
data/rakelib/run_rspec.rake
CHANGED
@@ -54,13 +54,13 @@ namespace :run_rspec do
|
|
54
54
|
# Dynamically define Rake tasks for each example app found in the examples directory
|
55
55
|
ExampleType.all.each do |example_type|
|
56
56
|
desc "Runs RSpec for #{example_type.name_pretty} only"
|
57
|
-
task example_type.rspec_task_name_short => example_type.
|
57
|
+
task example_type.rspec_task_name_short => example_type.gen_task_name do
|
58
58
|
run_tests_in(File.join(examples_dir, example_type.name)) # have to use relative path
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
62
|
desc "Runs Rspec for example apps only"
|
63
|
-
task examples: "examples:
|
63
|
+
task examples: "examples:gen_all" do
|
64
64
|
ExampleType.all.each { |example_type| Rake::Task[example_type.rspec_task_name].invoke }
|
65
65
|
end
|
66
66
|
|
data/yarn.lock
CHANGED
@@ -3357,6 +3357,13 @@ react-on-rails@^9.0.0-beta.11:
|
|
3357
3357
|
version "9.0.0-beta.11"
|
3358
3358
|
resolved "https://registry.yarnpkg.com/react-on-rails/-/react-on-rails-9.0.0-beta.11.tgz#f6951129d7c2a67479281ca900859d5ac0aab978"
|
3359
3359
|
|
3360
|
+
react-on-rails@^9.0.0-beta.12:
|
3361
|
+
version "9.0.0-beta.12"
|
3362
|
+
resolved "https://registry.yarnpkg.com/react-on-rails/-/react-on-rails-9.0.0-beta.12.tgz#6f50d82360a86048952a89594287b86b5621507b"
|
3363
|
+
dependencies:
|
3364
|
+
react-on-rails "^9.0.0-beta.11"
|
3365
|
+
react-redux "^5.0.6"
|
3366
|
+
|
3360
3367
|
react-proxy@^1.1.7:
|
3361
3368
|
version "1.1.8"
|
3362
3369
|
resolved "https://registry.yarnpkg.com/react-proxy/-/react-proxy-1.1.8.tgz#9dbfd9d927528c3aa9f444e4558c37830ab8c26a"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: react_on_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 9.0.0.
|
4
|
+
version: 9.0.0.rc.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Gordon
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rainbow
|