react_on_rails 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -2
- data/README.md +11 -3
- data/docs/additional_reading/manual_installation.md +3 -4
- data/docs/additional_reading/react_router.md +11 -1
- data/lib/generators/USAGE +99 -0
- data/lib/generators/react_on_rails/base_generator.rb +8 -2
- data/lib/generators/react_on_rails/bootstrap_generator.rb +4 -2
- data/lib/generators/react_on_rails/dev_tests_generator.rb +1 -1
- data/lib/generators/react_on_rails/generator_errors.rb +15 -0
- data/lib/generators/react_on_rails/generator_helper.rb +8 -0
- data/lib/generators/react_on_rails/heroku_deployment_generator.rb +1 -1
- data/lib/generators/react_on_rails/install_generator.rb +26 -12
- data/lib/generators/react_on_rails/js_linters_generator.rb +1 -1
- data/lib/generators/react_on_rails/react_no_redux_generator.rb +1 -1
- data/lib/generators/react_on_rails/react_with_redux_generator.rb +1 -1
- data/lib/generators/react_on_rails/ruby_linters_generator.rb +1 -1
- data/lib/generators/react_on_rails/templates/base/base/client/package.json.tt +3 -2
- data/lib/generators/react_on_rails/templates/base/base/client/webpack.client.base.config.js.tt +0 -1
- data/lib/generators/react_on_rails/templates/base/base/client/webpack.client.rails.config.js +3 -1
- data/lib/react_on_rails/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 062f2c7e4196debbd1f64da115d09fce0f6c8658
|
4
|
+
data.tar.gz: 4894e6147beb9739bd4dea998c78268d72b02990
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f5230308a176eeb4e21345de213aa8e6fbaa243590bdd02fa5d53f28e9dfb5614ffd887d4802d659dd94435756133463d67f12cb474d117f86f33420a3904ba
|
7
|
+
data.tar.gz: 4fb8e4b8ab396b9e8eb519a51cf1b5829bf6878417502707a21c42f15fcce3e1b00397aef9cef99ba4aef995342f959b8b7fb01ad6177b4037fbce4f1d0a93f3
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file. Items under `Unreleased` is upcoming features that will be out in next version.
|
3
3
|
|
4
|
-
##
|
4
|
+
## v1.2.0
|
5
5
|
### Added
|
6
6
|
- Support `--skip-bootstrap` or `-b` option for generator.
|
7
7
|
- Create examples tasks to test generated example apps.
|
@@ -31,4 +31,4 @@ All notable changes to this project will be documented in this file. Items under
|
|
31
31
|
- Nothing.
|
32
32
|
|
33
33
|
[Unreleased]: https://github.com/shakacode/react_on_rails/compare/v1.0.0...HEAD
|
34
|
-
[1.1.1]: https://github.com/shakacode/react_on_rails/compare/v1.0.0...v1.1.1
|
34
|
+
[1.1.1]: https://github.com/shakacode/react_on_rails/compare/v1.0.0...v1.1.1
|
data/README.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
[![Build Status](https://travis-ci.org/shakacode/react_on_rails.svg?branch=master)](https://travis-ci.org/shakacode/react_on_rails) [![Coverage Status](https://coveralls.io/repos/shakacode/react_on_rails/badge.svg?branch=master&service=github)](https://coveralls.io/github/shakacode/react_on_rails?branch=master) [![Dependency Status](https://gemnasium.com/shakacode/react_on_rails.svg)](https://gemnasium.com/shakacode/react_on_rails) [![Gem Version](https://badge.fury.io/rb/react_on_rails.svg)](https://badge.fury.io/rb/react_on_rails)
|
2
2
|
|
3
|
+
# NEWS
|
4
|
+
2.0 is about to ship! Please grab the latest and let us know if you see any issues!
|
5
|
+
|
6
|
+
* https://rubygems.org/gems/react_on_rails
|
7
|
+
* https://www.npmjs.com/package/react-on-rails
|
8
|
+
* Branch: https://github.com/shakacode/react_on_rails/tree/npm-react-on-rails-js
|
9
|
+
* PR: https://github.com/shakacode/react_on_rails/pull/148
|
10
|
+
|
3
11
|
# React on Rails
|
4
12
|
React on Rails integrates Facebook's [React](https://github.com/facebook/react) front-end framework with Rails. Currently, both React v0.14 and v0.13 are supported, with server rendering. [Redux](https://github.com/rackt/redux) and [React-Router](https://github.com/rackt/react-redux) are supported as well. See the Rails on Maui [blog post](http://www.railsonmaui.com/blog/2014/10/03/integrating-webpack-and-the-es6-transpiler-into-an-existing-rails-project/) that started it all!
|
5
13
|
|
@@ -200,8 +208,8 @@ This is how you actually render the React components you exposed to `window` ins
|
|
200
208
|
This is a helper method that takes any JavaScript expression and returns the output from evaluating it. If you have more than one line that needs to be executed, wrap it in an IIFE. JS exceptions will be caught and console messages handled properly.
|
201
209
|
|
202
210
|
## Generator
|
203
|
-
The `react_on_rails:install` generator combined with the example pull requests of generator runs will get you up and running efficiently. There's a fair bit of setup with integrating Webpack with Rails.
|
204
|
-
|
211
|
+
The `react_on_rails:install` generator combined with the example pull requests of generator runs will get you up and running efficiently. There's a fair bit of setup with integrating Webpack with Rails. Defaults for options are such that the default is for the flag to be off. For example, the default for `-R` is that `redux` is off, and the default of `-b` means that `skip-bootstrap` is off.
|
212
|
+
|
205
213
|
Run `rails generate react_on_rails:install --help` for descriptions of all available options:
|
206
214
|
|
207
215
|
```
|
@@ -226,7 +234,7 @@ Description:
|
|
226
234
|
Create react on rails files for install generator.
|
227
235
|
```
|
228
236
|
|
229
|
-
For a clear example of what each generator option will do, see our generator results repo: [Generator Results](https://github.com/shakacode/react_on_rails-generator-results/
|
237
|
+
For a clear example of what each generator option will do, see our generator results repo: [Generator Results](https://github.com/shakacode/react_on_rails-generator-results/blob/master/README.md). Each pull request shows a git "diff" that highlights the changes that the generator has made.
|
230
238
|
|
231
239
|
### Understanding the Organization of the Generated Client Code
|
232
240
|
The generated client code follows our organization scheme. Each unique set of functionality, is given its own folder inside of `client/app/bundles`. This encourages for modularity of DOMAINS.
|
@@ -46,7 +46,7 @@ See the next section for a sample webpack.server.rails.config.js.
|
|
46
46
|
entry: ['./app/startup/serverGlobals'],
|
47
47
|
```
|
48
48
|
3. Ensure the name of your ouput file (shown [here](https://github.com/shakacode/react-webpack-rails-tutorial/blob/537c985dc82faee333d80509343ca32a3965f9dd/client/webpack.server.rails.config.js#L9)) of your server bundle corresponds to the configuration of the gem. The default path is `app/assets/javascripts/generated`. See below for customization of configuration variables.
|
49
|
-
4. Expose `React` in your webpack config, like [this](https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/client/webpack.server.rails.config.js#
|
49
|
+
4. Expose `React` in your webpack config, like [this](https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/client/webpack.server.rails.build.config.js#L54-L55)
|
50
50
|
|
51
51
|
```javascript
|
52
52
|
{ test: require.resolve('react'), loader: 'expose?React' },
|
@@ -54,9 +54,8 @@ See the next section for a sample webpack.server.rails.config.js.
|
|
54
54
|
// For React 0.14
|
55
55
|
{ test: require.resolve('react-dom/server'), loader: 'expose?ReactDOMServer' }, // not in client one, only server
|
56
56
|
```
|
57
|
-
|
58
|
-
|
59
|
-
Be sure to check out the latest example version of [client/webpack.server.rails.config.js](https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/client/webpack.server.rails.config.js).
|
57
|
+
### Sample webpack.server.rails.build.config.js (ONLY for server rendering)
|
58
|
+
Be sure to check out the latest example version of [client/webpack.server.rails.build.config.js](https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/client/webpack.server.rails.build.config.js).
|
60
59
|
|
61
60
|
```javascript
|
62
61
|
// Common webpack configuration for server bundle
|
@@ -1,8 +1,10 @@
|
|
1
1
|
# Using React Router
|
2
|
-
React on Rails supports the use of React Router. Client-side code doesn't need any special configuration for the React on Rails gem. Implement React Router how you normally would.
|
2
|
+
React on Rails supports the use of React Router. Client-side code doesn't need any special configuration for the React on Rails gem. Implement React Router how you normally would.
|
3
3
|
|
4
4
|
However, when attempting to use server-rendering, it is necessary to take steps that prevent rendering when there is a router error or redirect. In these cases, the client code should return an object containing the `error` and a `redirectLocation` instead of the React component. The `react_component` helper method in your Rails view will automatically detect that there was an error/redirect and handle it accordingly.
|
5
5
|
|
6
|
+
If you are working with the HelloWorldApp created by the react_on_rails generator, then the code below corresponds to the module in `client/app/bundles/HelloWorld/startup/HelloWorldAppServer.jsx`.
|
7
|
+
|
6
8
|
```js
|
7
9
|
const RouterApp = (props, location) => {
|
8
10
|
const store = createStore(props);
|
@@ -33,3 +35,11 @@ const RouterApp = (props, location) => {
|
|
33
35
|
);
|
34
36
|
};
|
35
37
|
```
|
38
|
+
|
39
|
+
For a fleshed out integration of react_on_rails with react-router, check out [React Webpack Rails Tutorial Code](https://github.com/shakacode/react-webpack-rails-tutorial), specifically the files:
|
40
|
+
|
41
|
+
* [react-webpack-rails-tutorial/client/app/bundles/comments/routes/routes.jsx](https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/client/app/bundles/comments/routes/routes.jsx)
|
42
|
+
|
43
|
+
* [react-webpack-rails-tutorial/client/app/bundles/comments/startup/ClientRouterApp.jsx](https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/client/app/bundles/comments/startup/ClientRouterApp.jsx)
|
44
|
+
|
45
|
+
* [react-webpack-rails-tutorial/client/app/bundles/comments/startup/ServerRouterApp.jsx](https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/client/app/bundles/comments/startup/ServerRouterApp.jsx)
|
@@ -0,0 +1,99 @@
|
|
1
|
+
Description:
|
2
|
+
|
3
|
+
The react_on_rails:install generator combined with the example pull requests of
|
4
|
+
generator runs will get you up and running efficiently. There's a fair bit of
|
5
|
+
setup involved when ~with~ integrating Webpack with Rails. Defaults for options
|
6
|
+
are such that the default is for the flag to be off. For example, the default for
|
7
|
+
`-R` is that redux is off, and the default of -b means that skip-bootstrap is off.
|
8
|
+
|
9
|
+
* Redux
|
10
|
+
|
11
|
+
Passing the --redux generator option causes the generated Hello World example
|
12
|
+
to integrate the Redux state container framework. The necessary node modules
|
13
|
+
will be automatically included for you.
|
14
|
+
|
15
|
+
The generator uses the organizational `paradigm of "bundles"`. These are like
|
16
|
+
application domains and are used for grouping your code into webpack bundles
|
17
|
+
in case you decide to create different bundles for deployment. This is also
|
18
|
+
useful for separating out logical parts of your application. We recommend that
|
19
|
+
that each bundle will have it's own Redux store. If you have code that you
|
20
|
+
want to reuse across bundles, such as middleware or common utilities, place them
|
21
|
+
under `/client/app/lib`. You can then import them in your client code:
|
22
|
+
`import MyModule from 'lib/MyModule'`; since we have configured webpack to
|
23
|
+
automatically resolve the word lib to point to this folder.
|
24
|
+
|
25
|
+
* Using Images and Fonts
|
26
|
+
|
27
|
+
The generator has amended the folders created in `client/assets/` to Rails's
|
28
|
+
asset path. We recommend that if you have any existing assets that you want
|
29
|
+
to use with your client code, you should move them to these folders and use
|
30
|
+
webpack as normal. This allows webpack's development server to have access
|
31
|
+
to your assets, as it will not be able to see any assets in the default Rails
|
32
|
+
directories which are above the `/client` directory.
|
33
|
+
|
34
|
+
Alternatively, if you have many existing assets and don't wish to move them,
|
35
|
+
you could consider creating symlinks from `client/assets` that point to your
|
36
|
+
Rails assets folders inside of `app/assets/`. The assets there will then be
|
37
|
+
visible to both Rails and webpack.
|
38
|
+
|
39
|
+
* Bootstrap Integration
|
40
|
+
|
41
|
+
React on Rails ships with Twitter Bootstrap already integrated into the build.
|
42
|
+
Note that the generator removes require_tree in both the application.js and
|
43
|
+
application.css.scss files. This is to ensure the correct load order for the
|
44
|
+
bootstrap integration, and is usually a good idea in general. You will therefore
|
45
|
+
need to explicitly require your files.
|
46
|
+
|
47
|
+
How the Bootstrap library is loaded depends upon whether one is using the Rails
|
48
|
+
server or the HMR development server.
|
49
|
+
|
50
|
+
1. Bootstrap via Rails Server
|
51
|
+
|
52
|
+
The Rails server loads bootstrap-sprockets, provided
|
53
|
+
by the bootstrap-sass ruby gem (added automatically to your Gemfile by
|
54
|
+
the generator), via the `app/assets/stylesheets/_bootstrap-custom.scss`
|
55
|
+
partial.
|
56
|
+
|
57
|
+
This allows for using Bootstrap in your regular Rails stylesheets. If you
|
58
|
+
wish to customize any of the Bootstrap variables, you can do so via the
|
59
|
+
`client/assets/stylesheets/_pre-bootstrap.scss` partial.
|
60
|
+
|
61
|
+
2. Bootstrap via Webpack Dev Server
|
62
|
+
|
63
|
+
The webpack dev server does not go through Rails but instead loads bootstrap
|
64
|
+
via the `bootstrap-sass-loader` webpack loader. You can configure the loader
|
65
|
+
via the `client/bootstrap-sass-config.js` file.
|
66
|
+
|
67
|
+
3. Keeping Custom Bootstrap Configurations Synced
|
68
|
+
|
69
|
+
Because the webpack dev server and Rails each load Bootstrap via a different
|
70
|
+
file (explained in the two sections immediately above), any changes to
|
71
|
+
the way components are loaded in one file must also be made to the other
|
72
|
+
file in order to keep styling consistent between the two. For example,
|
73
|
+
if an import is excluded in _bootstrap-custom.scss, the same import should
|
74
|
+
be excluded in `bootstrap-sass-config.js` so that styling in the Rails
|
75
|
+
server and the webpack dev server will be the same.
|
76
|
+
|
77
|
+
4. Skip Bootstrap Integration
|
78
|
+
|
79
|
+
Bootstrap integration is enabled by default, but can be disabled by passing
|
80
|
+
the --skip-bootstrap flag (alias -b). When you don't need Bootstrap in your
|
81
|
+
existing project, just skip it as needed.
|
82
|
+
|
83
|
+
* JavaScript Linters
|
84
|
+
|
85
|
+
JavaScript linters are enabled by default, but can be disabled by passing the
|
86
|
+
--skip-js-linters flag (alias j), and those that run in Node have been add to
|
87
|
+
`client/package.json` under devDependencies.
|
88
|
+
|
89
|
+
* Ruby Linters
|
90
|
+
|
91
|
+
Ruby linters are disabled by default, but can be enabled by passing the
|
92
|
+
`--ruby-linters` flag when generating. These linters have been added to your
|
93
|
+
Gemfile in addition to the the appropriate Rake tasks.
|
94
|
+
|
95
|
+
We really love using all the linters! Give them a try.
|
96
|
+
|
97
|
+
More Details:
|
98
|
+
|
99
|
+
`https://github.com/shakacode/react_on_rails#generator`
|
@@ -1,12 +1,14 @@
|
|
1
1
|
require "rails/generators"
|
2
2
|
require File.expand_path("../generator_helper", __FILE__)
|
3
|
+
require File.expand_path("../generator_errors", __FILE__)
|
3
4
|
|
4
5
|
include GeneratorHelper
|
6
|
+
include GeneratorErrors
|
5
7
|
|
6
8
|
module ReactOnRails
|
7
9
|
module Generators
|
8
10
|
class BaseGenerator < Rails::Generators::Base # rubocop:disable Metrics/ClassLength
|
9
|
-
|
11
|
+
Rails::Generators.hide_namespace(namespace)
|
10
12
|
source_root(File.expand_path("../templates", __FILE__))
|
11
13
|
|
12
14
|
# --redux
|
@@ -62,7 +64,11 @@ module ReactOnRails
|
|
62
64
|
/app/assets/javascripts/generated/*
|
63
65
|
DATA
|
64
66
|
|
65
|
-
dest_file_exists?(".gitignore")
|
67
|
+
if dest_file_exists?(".gitignore")
|
68
|
+
append_to_file(".gitignore", data)
|
69
|
+
else
|
70
|
+
GeneratorErrors.add_error(return_setup_file_error(".gitignore", data))
|
71
|
+
end
|
66
72
|
end
|
67
73
|
|
68
74
|
def update_application_js
|
@@ -1,11 +1,13 @@
|
|
1
1
|
require "rails/generators"
|
2
2
|
require File.expand_path("../generator_helper", __FILE__)
|
3
|
+
require File.expand_path("../generator_errors", __FILE__)
|
3
4
|
include GeneratorHelper
|
5
|
+
include GeneratorErrors
|
4
6
|
|
5
7
|
module ReactOnRails
|
6
8
|
module Generators
|
7
9
|
class BootstrapGenerator < Rails::Generators::Base
|
8
|
-
|
10
|
+
Rails::Generators.hide_namespace(namespace)
|
9
11
|
source_root(File.expand_path("../templates", __FILE__))
|
10
12
|
|
11
13
|
def copy_bootstrap_files
|
@@ -54,7 +56,7 @@ module ReactOnRails
|
|
54
56
|
if File.exist?(application_scss)
|
55
57
|
append_to_file(application_scss, data)
|
56
58
|
else
|
57
|
-
|
59
|
+
GeneratorErrors.add_error(return_setup_file_error(application_scss, data))
|
58
60
|
end
|
59
61
|
end
|
60
62
|
|
@@ -5,7 +5,7 @@ include GeneratorHelper
|
|
5
5
|
module ReactOnRails
|
6
6
|
module Generators
|
7
7
|
class DevTestsGenerator < Rails::Generators::Base
|
8
|
-
|
8
|
+
Rails::Generators.hide_namespace(namespace)
|
9
9
|
source_root(File.expand_path("../templates/dev_tests", __FILE__))
|
10
10
|
|
11
11
|
def copy_rspec_files
|
@@ -17,6 +17,14 @@ module GeneratorHelper
|
|
17
17
|
puts "\n#{data}\n"
|
18
18
|
end
|
19
19
|
|
20
|
+
def return_setup_file_error(file, data)
|
21
|
+
error = ""
|
22
|
+
error << "** #{file} was not found.\n"
|
23
|
+
error << "Please add the following content to your #{file} file:\n"
|
24
|
+
error << "\n#{data}\n"
|
25
|
+
error
|
26
|
+
end
|
27
|
+
|
20
28
|
def empty_directory_with_keep_file(destination, config = {})
|
21
29
|
empty_directory(destination, config)
|
22
30
|
keep_file(destination)
|
@@ -5,7 +5,7 @@ include GeneratorHelper
|
|
5
5
|
module ReactOnRails
|
6
6
|
module Generators
|
7
7
|
class HerokuDeploymentGenerator < Rails::Generators::Base
|
8
|
-
|
8
|
+
Rails::Generators.hide_namespace(namespace)
|
9
9
|
source_root(File.expand_path("../templates", __FILE__))
|
10
10
|
|
11
11
|
def copy_heroku_deployment_files
|
@@ -1,54 +1,68 @@
|
|
1
1
|
require "rails/generators"
|
2
|
+
require File.expand_path("../generator_helper", __FILE__)
|
3
|
+
require File.expand_path("../generator_errors", __FILE__)
|
4
|
+
include GeneratorHelper
|
5
|
+
include GeneratorErrors
|
2
6
|
|
3
7
|
module ReactOnRails
|
4
8
|
module Generators
|
5
9
|
class InstallGenerator < Rails::Generators::Base
|
10
|
+
# fetch USAGE file for details generator description
|
11
|
+
source_root(File.expand_path("../", __FILE__))
|
12
|
+
|
6
13
|
# --redux
|
7
14
|
class_option :redux,
|
8
15
|
type: :boolean,
|
9
16
|
default: false,
|
10
|
-
desc: "Install Redux gems and Redux version of Hello World Example",
|
17
|
+
desc: "Install Redux gems and Redux version of Hello World Example. Default: false",
|
11
18
|
aliases: "-R"
|
12
19
|
# --server-rendering
|
13
20
|
class_option :server_rendering,
|
14
21
|
type: :boolean,
|
15
22
|
default: false,
|
16
|
-
desc: "Add necessary files and configurations for server-side rendering",
|
23
|
+
desc: "Add necessary files and configurations for server-side rendering. Default: false",
|
17
24
|
aliases: "-S"
|
18
25
|
# --skip-js-linters
|
19
26
|
class_option :skip_js_linters,
|
20
27
|
type: :boolean,
|
21
28
|
default: false,
|
22
|
-
desc: "Skip installing JavaScript linting files",
|
29
|
+
desc: "Skip installing JavaScript linting files. Default: false",
|
23
30
|
aliases: "-j"
|
24
31
|
# --ruby-linters
|
25
32
|
class_option :ruby_linters,
|
26
33
|
type: :boolean,
|
27
34
|
default: false,
|
28
|
-
desc: "Install ruby linting files, tasks, and configs",
|
35
|
+
desc: "Install ruby linting files, tasks, and configs. Default: false",
|
29
36
|
aliases: "-L"
|
30
37
|
# --ruby-linters
|
31
38
|
class_option :heroku_deployment,
|
32
39
|
type: :boolean,
|
33
40
|
default: false,
|
34
|
-
desc: "Install files necessary for deploying to Heroku",
|
41
|
+
desc: "Install files necessary for deploying to Heroku. Default: false",
|
35
42
|
aliases: "-H"
|
36
|
-
|
37
43
|
# --skip-bootstrap
|
38
44
|
class_option :skip_bootstrap,
|
39
45
|
type: :boolean,
|
40
46
|
default: false,
|
41
|
-
desc: "Skip integrating Bootstrap and don't initialize files and regarding configs",
|
47
|
+
desc: "Skip integrating Bootstrap and don't initialize files and regarding configs. Default: false",
|
42
48
|
aliases: "-b"
|
43
49
|
|
44
50
|
def run_generators # rubocop:disable Metrics/CyclomaticComplexity
|
45
|
-
|
51
|
+
unless installation_prerequisites_met?
|
52
|
+
print_errors
|
53
|
+
return
|
54
|
+
end
|
46
55
|
warn_if_nvm_is_not_installed
|
47
56
|
invoke_generators
|
57
|
+
print_errors
|
48
58
|
end
|
49
59
|
|
50
60
|
private
|
51
61
|
|
62
|
+
def print_errors
|
63
|
+
GeneratorErrors.errors.each { |errors| puts errors }
|
64
|
+
end
|
65
|
+
|
52
66
|
def invoke_generators # rubocop:disable Metrics/CyclomaticComplexity
|
53
67
|
invoke "react_on_rails:base"
|
54
68
|
invoke "react_on_rails:react_no_redux" unless options.redux?
|
@@ -70,14 +84,14 @@ module ReactOnRails
|
|
70
84
|
return false unless `which npm`.blank?
|
71
85
|
error = "** npm is required. Please install it before continuing."
|
72
86
|
error << "https://www.npmjs.com/"
|
73
|
-
|
87
|
+
GeneratorErrors.add_error(error)
|
74
88
|
end
|
75
89
|
|
76
90
|
def missing_node?
|
77
91
|
return false unless `which node`.blank?
|
78
92
|
error = "** nodejs is required. Please install it before continuing."
|
79
93
|
error << "https://nodejs.org/en/"
|
80
|
-
|
94
|
+
GeneratorErrors.add_error(error)
|
81
95
|
end
|
82
96
|
|
83
97
|
def uncommitted_changes?
|
@@ -85,12 +99,12 @@ module ReactOnRails
|
|
85
99
|
status = `git status`
|
86
100
|
return false if status.include?("nothing to commit, working directory clean")
|
87
101
|
error = "** You have uncommitted code. Please commit or stash your changes before continuing"
|
88
|
-
|
102
|
+
GeneratorErrors.add_error(error)
|
89
103
|
end
|
90
104
|
|
91
105
|
def warn_if_nvm_is_not_installed
|
92
106
|
return true unless `which nvm`.blank?
|
93
|
-
|
107
|
+
GeneratorErrors.add_error("** nvm is advised. Please consider installing it. https://github.com/creationix/nvm")
|
94
108
|
end
|
95
109
|
end
|
96
110
|
end
|
@@ -3,7 +3,7 @@ require "rails/generators"
|
|
3
3
|
module ReactOnRails
|
4
4
|
module Generators
|
5
5
|
class JsLintersGenerator < Rails::Generators::Base
|
6
|
-
|
6
|
+
Rails::Generators.hide_namespace(namespace)
|
7
7
|
source_root File.expand_path("../templates", __FILE__)
|
8
8
|
|
9
9
|
# NOTE: linter modules are included via template in base/base/client/package.json.tt
|
@@ -3,7 +3,7 @@ require "rails/generators"
|
|
3
3
|
module ReactOnRails
|
4
4
|
module Generators
|
5
5
|
class RubyLintersGenerator < Rails::Generators::Base
|
6
|
-
|
6
|
+
Rails::Generators.hide_namespace(namespace)
|
7
7
|
source_root File.expand_path("../templates", __FILE__)
|
8
8
|
|
9
9
|
def add_ruby_linter_gems_to_gemfile
|
@@ -50,9 +50,9 @@
|
|
50
50
|
"jquery-ujs": "^1.1.0-1",
|
51
51
|
"loader-utils": "^0.2.11",
|
52
52
|
<%- if options.redux? -%>
|
53
|
-
"lodash": "^3.10.1",
|
54
53
|
"mirror-creator": "0.0.1",
|
55
54
|
<%- end -%>
|
55
|
+
"lodash": "^3.10.1",
|
56
56
|
"react": "^0.14.0",
|
57
57
|
<%- unless options.skip_bootstrap? -%>
|
58
58
|
"react-bootstrap": "^0.28.1",
|
@@ -64,7 +64,8 @@
|
|
64
64
|
"redux-promise": "^0.5.0",
|
65
65
|
"redux-thunk": "^1.0.0",
|
66
66
|
<%- end -%>
|
67
|
-
"webpack": "^1.12.8"
|
67
|
+
"webpack": "^1.12.8",
|
68
|
+
"lodash":"^3.10.1"
|
68
69
|
},
|
69
70
|
"devDependencies": {
|
70
71
|
<%- unless options.skip_js_linters? -%>
|
data/lib/generators/react_on_rails/templates/base/base/client/webpack.client.rails.config.js
CHANGED
@@ -19,8 +19,10 @@ config.entry.vendor.unshift(
|
|
19
19
|
'es5-shim/es5-sham'
|
20
20
|
);
|
21
21
|
|
22
|
-
//
|
22
|
+
// jquery-ujs MUST GO AFTER jquery, so must use 'push'
|
23
|
+
config.entry.app.push('jquery-ujs');
|
23
24
|
|
25
|
+
// See webpack.common.config for adding modules common to both the webpack dev server and rails
|
24
26
|
config.module.loaders.push(
|
25
27
|
{test: /\.jsx?$/, loader: 'babel-loader', exclude: /node_modules/},
|
26
28
|
{test: require.resolve('react'), loader: 'imports?shim=es5-shim/es5-shim&sham=es5-shim/es5-sham'}
|
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: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Gordon
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -167,9 +167,11 @@ files:
|
|
167
167
|
- docs/sample_generated_js/README.md
|
168
168
|
- docs/sample_generated_js/client-generated.js
|
169
169
|
- docs/sample_generated_js/server-generated.js
|
170
|
+
- lib/generators/USAGE
|
170
171
|
- lib/generators/react_on_rails/base_generator.rb
|
171
172
|
- lib/generators/react_on_rails/bootstrap_generator.rb
|
172
173
|
- lib/generators/react_on_rails/dev_tests_generator.rb
|
174
|
+
- lib/generators/react_on_rails/generator_errors.rb
|
173
175
|
- lib/generators/react_on_rails/generator_helper.rb
|
174
176
|
- lib/generators/react_on_rails/heroku_deployment_generator.rb
|
175
177
|
- lib/generators/react_on_rails/install_generator.rb
|
@@ -268,7 +270,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
268
270
|
version: '0'
|
269
271
|
requirements: []
|
270
272
|
rubyforge_project:
|
271
|
-
rubygems_version: 2.
|
273
|
+
rubygems_version: 2.5.1
|
272
274
|
signing_key:
|
273
275
|
specification_version: 4
|
274
276
|
summary: Rails with react server rendering with webpack.
|