react_on_rails 5.1.1 → 5.2.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 +14 -2
- data/README.md +3 -77
- data/docs/additional-reading/heroku-deployment.md +30 -0
- data/docs/contributor-info/contributing.md +11 -6
- data/docs/contributor-info/releasing.md +1 -1
- data/docs/tutorial.md +3 -1
- data/lib/generators/react_on_rails/base_generator.rb +0 -57
- data/lib/generators/react_on_rails/install_generator.rb +0 -28
- data/lib/generators/react_on_rails/templates/base/base/client/app/bundles/HelloWorld/components/HelloWorldWidget.jsx.tt +8 -22
- data/lib/generators/react_on_rails/templates/base/base/client/package.json.tt +4 -54
- data/lib/generators/react_on_rails/templates/base/base/package.json.tt +5 -25
- data/lib/react_on_rails/version.rb +1 -1
- data/package.json +3 -3
- data/rakelib/examples_config.yml +1 -6
- metadata +2 -26
- data/lib/generators/react_on_rails/bootstrap_generator.rb +0 -86
- data/lib/generators/react_on_rails/heroku_deployment_generator.rb +0 -29
- data/lib/generators/react_on_rails/js_linters_generator.rb +0 -19
- data/lib/generators/react_on_rails/ruby_linters_generator.rb +0 -35
- data/lib/generators/react_on_rails/templates/base/base/Procfile.dev-hot.tt +0 -4
- data/lib/generators/react_on_rails/templates/base/base/client/index.jade +0 -15
- data/lib/generators/react_on_rails/templates/base/base/client/server.js +0 -72
- data/lib/generators/react_on_rails/templates/base/base/client/webpack.client.hot.config.js.tt +0 -70
- data/lib/generators/react_on_rails/templates/base/base/lib/tasks/linters.rake.tt +0 -88
- data/lib/generators/react_on_rails/templates/bootstrap/app/assets/stylesheets/_bootstrap-custom.scss +0 -63
- data/lib/generators/react_on_rails/templates/bootstrap/client/assets/stylesheets/_post-bootstrap.scss +0 -10
- data/lib/generators/react_on_rails/templates/bootstrap/client/assets/stylesheets/_pre-bootstrap.scss +0 -8
- data/lib/generators/react_on_rails/templates/bootstrap/client/assets/stylesheets/_react-on-rails-sass-helper.scss +0 -19
- data/lib/generators/react_on_rails/templates/bootstrap/client/bootstrap-sass.config.js +0 -89
- data/lib/generators/react_on_rails/templates/heroku_deployment/Procfile +0 -1
- data/lib/generators/react_on_rails/templates/heroku_deployment/config/puma.rb +0 -15
- data/lib/generators/react_on_rails/templates/js_linters/client/.eslintignore +0 -1
- data/lib/generators/react_on_rails/templates/js_linters/client/.eslintrc +0 -48
- data/lib/generators/react_on_rails/templates/js_linters/client/.jscsrc +0 -18
- data/lib/generators/react_on_rails/templates/ruby_linters/.rubocop.yml +0 -27
- data/lib/generators/react_on_rails/templates/ruby_linters/.scss-lint.yml +0 -205
- data/lib/generators/react_on_rails/templates/ruby_linters/lib/tasks/brakeman.rake +0 -17
- data/lib/generators/react_on_rails/templates/ruby_linters/lib/tasks/ci.rake +0 -33
- data/lib/generators/react_on_rails/templates/ruby_linters/ruby-lint.yml.tt +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1fb981f3321f2cf6d28a3a3c1550bf60db230df
|
4
|
+
data.tar.gz: fdde71cf3cd95b818f030002e213dcc48885cb86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12dcf6e3bb24210b14cd40ca74643c548d88b592291465bdb427d1eb26b9028ff7eab7e0afa1c95f1f3becd2d175117f83a1d9a0f290337804cf74a7838cc7a0
|
7
|
+
data.tar.gz: 946fe32089268078bb1c7ce4bc1ed6e785572ee2d75f88239d2d586c70e21eab5b7afeb35608dc2a188cf14f06f7d85f4a6136677f9c62c43916e2402ffdd2b1
|
data/CHANGELOG.md
CHANGED
@@ -4,9 +4,20 @@ All notable changes to this project will be documented in this file. Items under
|
|
4
4
|
Contributors: please follow the recommendations outlined at [keepachangelog.com](http://keepachangelog.com/). Please use the existing headings and styling as a guide, and add a link for the version diff at the bottom of the file. Also, please update the `Unreleased` link to compare to the latest release version.
|
5
5
|
## [Unreleased]
|
6
6
|
|
7
|
+
## [5.2.0] - 2016-04-08
|
8
|
+
##### Added
|
9
|
+
- Support for React 15.0 to react_on_rails. See [#379](https://github.com/shakacode/react_on_rails/pull/379) by [brucek](https://github.com/brucek).
|
10
|
+
|
11
|
+
##### Removed
|
12
|
+
- Generator removals to simplify installer. See [#363](https://github.com/shakacode/react_on_rails/pull/363) by [jbhatab](https://github.com/jbhatab).
|
13
|
+
- Removed options for heroku, boostrap, and the linters from generator.
|
14
|
+
- Removed install for the Webpack Dev Server, as we can now do hot reloading with Rails, so the complexity of this feature is not justified. Nevertheless, the setup of React on Rails still supports this setup, just not with the generator.
|
15
|
+
- Documentation added for removed installer options.
|
16
|
+
|
7
17
|
## [5.1.1] - 2016-04-04
|
8
18
|
##### Fixed
|
9
19
|
- [Security] Address failure to sanitize console messages when server rendering and displaying in the browser console. See [#366](https://github.com/shakacode/react_on_rails/pull/366) and [#370](https://github.com/shakacode/react_on_rails/pull/370) by [justin808](https://github.com/justin808)
|
20
|
+
|
10
21
|
##### Added
|
11
22
|
- railsContext includes the port number and a boolean if the code is being run on the server or client.
|
12
23
|
|
@@ -268,8 +279,9 @@ Best done with Object destructing:
|
|
268
279
|
|
269
280
|
##### Fixed
|
270
281
|
- Fix several generator related issues.
|
271
|
-
[Unreleased]: https://github.com/shakacode/react_on_rails/compare/5.
|
272
|
-
[5.
|
282
|
+
[Unreleased]: https://github.com/shakacode/react_on_rails/compare/5.2.0...master
|
283
|
+
[5.2.0]: https://github.com/shakacode/react_on_rails/compare/5.1.1...5.2.0
|
284
|
+
[5.1.1]: https://github.com/shakacode/react_on_rails/compare/5.1.0...5.1.1
|
273
285
|
[5.1.0]: https://github.com/shakacode/react_on_rails/compare/5.0.0...5.1.0
|
274
286
|
[5.0.0]: https://github.com/shakacode/react_on_rails/compare/4.0.3...5.0.0
|
275
287
|
[4.0.3]: https://github.com/shakacode/react_on_rails/compare/4.0.2...4.0.3
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
[![Build Status](https://travis-ci.org/shakacode/react_on_rails.svg?branch=master)](https://travis-ci.org/shakacode/react_on_rails) [![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) [![npm version](https://badge.fury.io/js/react-on-rails.svg)](https://badge.fury.io/js/react-on-rails) [![Code Climate](https://codeclimate.com/github/shakacode/react_on_rails/badges/gpa.svg)](https://codeclimate.com/github/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)
|
2
|
-
|
2
|
+
|
3
3
|
# NEWS
|
4
|
-
* 5.
|
4
|
+
* 2016-04-08: 5.2.0 Released! Support for React 15.0 and upates to the Generator. See the [CHANGELOG.md](./CHANGELOG.md) for details.
|
5
5
|
* [New slides on React on Rails](http://www.slideshare.net/justingordon/react-on-rails-v4032).
|
6
6
|
* 2016-02-28: We added a [Projects page](./PROJECTS.md) and a [Kudos page](./KUDOS.md). Please edit the page your project or [email us](mailto:contact@shakacode.com) and we'll add you. We also love stars as it helps us attract new users and contributors.
|
7
7
|
* *See [NEWS.md](NEWS.md) for the full news history.*
|
@@ -74,23 +74,11 @@ Please see [Getting Started](#getting-started) for how to set up your Rails proj
|
|
74
74
|
- [Globally Exposing Your React Components](#globally-exposing-your-react-components)
|
75
75
|
- [ReactOnRails View Helpers API](#reactonrails-view-helpers-api)
|
76
76
|
- [ReactOnRails JavaScript API](#reactonrails-javascript-api)
|
77
|
-
- [Hot Reloading View Helpers](#hot-reloading-view-helpers)
|
78
77
|
- [React-Router](#react-router)
|
79
78
|
+ [Generator](#generator)
|
80
79
|
- [Understanding the Organization of the Generated Client Code](#understanding-the-organization-of-the-generated-client-code)
|
81
80
|
- [Redux](#redux)
|
82
81
|
- [Multiple React Components on a Page with One Store](#multiple-react-components-on-a-page-with-one-store)
|
83
|
-
- [Using Images and Fonts](#using-images-and-fonts)
|
84
|
-
- [Bootstrap Integration](#bootstrap-integration)
|
85
|
-
+ [Bootstrap via Rails Server](#bootstrap-via-rails-server)
|
86
|
-
+ [Bootstrap via Webpack HMR Dev Server](#bootstrap-via-webpack-hmr-dev-server)
|
87
|
-
+ [Keeping Custom Bootstrap Configurations Synced](#keeping-custom-bootstrap-configurations-synced)
|
88
|
-
+ [Skip Bootstrap Integration](#skip-bootstrap-integration)
|
89
|
-
- [Linters](#linters)
|
90
|
-
+ [JavaScript Linters](#javascript-linters)
|
91
|
-
+ [Ruby Linters](#ruby-linters)
|
92
|
-
+ [Running the Linters](#running-the-linters)
|
93
|
-
+ [Developing with the Webpack Dev Server](#developing-with-the-webpack-dev-server)
|
94
82
|
+ [Adding Additional Routes for the Dev Server](#adding-additional-routes-for-the-dev-server)
|
95
83
|
+ [Migrate From react-rails](#migrate-from-react-rails)
|
96
84
|
+ [Additional Reading](#additional-reading)
|
@@ -105,7 +93,6 @@ Please see [Getting Started](#getting-started) for how to set up your Rails proj
|
|
105
93
|
Like the [react-rails](https://github.com/reactjs/react-rails) gem, React on Rails is capable of server-side rendering with fragment caching and is compatible with [turbolinks](https://github.com/turbolinks/turbolinks). Unlike react-rails, which depends heavily on sprockets and jquery-ujs, React on Rails uses [webpack](http://webpack.github.io/) and does not depend on jQuery. While the initial setup is slightly more involved, it allows for advanced functionality such as:
|
106
94
|
|
107
95
|
+ [Redux](https://github.com/reactjs/redux)
|
108
|
-
+ [Webpack dev server](https://webpack.github.io/docs/webpack-dev-server.html) with [hot module replacement](https://webpack.github.io/docs/hot-module-replacement-with-webpack.html)
|
109
96
|
+ [Webpack optimization functionality](https://github.com/webpack/docs/wiki/optimization)
|
110
97
|
+ [React Router](https://github.com/reactjs/react-router)
|
111
98
|
|
@@ -113,10 +100,7 @@ See the [react-webpack-rails-tutorial](https://github.com/shakacode/react-webpac
|
|
113
100
|
|
114
101
|
## Why Webpack?
|
115
102
|
|
116
|
-
Webpack is used for
|
117
|
-
|
118
|
-
1. Generate several JavaScript "bundles" for inclusion in `application.js`.
|
119
|
-
2. Providing the Webpack Dev Server for quick prototyping of components without needing to refresh your browser to see updates.
|
103
|
+
Webpack is used to generate several JavaScript "bundles" for inclusion in `application.js` or directly in your layout.
|
120
104
|
|
121
105
|
This usage of webpack fits neatly and simply into the existing Rails sprockets system and you can include React components on a Rails view with a simple helper.
|
122
106
|
|
@@ -468,10 +452,6 @@ Usage:
|
|
468
452
|
Options:
|
469
453
|
-R, [--redux], [--no-redux] # Install Redux gems and Redux version of Hello World Example
|
470
454
|
-S, [--server-rendering], [--no-server-rendering] # Add necessary files and configurations for server-side rendering
|
471
|
-
-j, [--skip-js-linters], [--no-skip-js-linters] # Skip installing JavaScript linting files
|
472
|
-
-L, [--ruby-linters], [--no-ruby-linters] # Install ruby linting files, tasks, and configs
|
473
|
-
-H, [--heroku-deployment], [--no-heroku-deployment] # Install files necessary for deploying to Heroku
|
474
|
-
-b, [--skip-bootstrap], [--no-skip-bootstrap] # Skip installing files for bootstrap support
|
475
455
|
|
476
456
|
Runtime options:
|
477
457
|
-f, [--force] # Overwrite files that already exist
|
@@ -506,60 +486,6 @@ The generator has amended the folders created in `client/assets/` to Rails's ass
|
|
506
486
|
|
507
487
|
Alternatively, if you have many existing assets and don't wish to move them, you could consider creating symlinks from client/assets that point to your Rails assets folders inside of `app/assets/`. The assets there will then be visible to both Rails and webpack.
|
508
488
|
|
509
|
-
### Bootstrap Integration
|
510
|
-
React on Rails ships with Twitter Bootstrap already integrated into the build. Note that the generator removes `require_tree` in both the application.js and application.css.scss files. This is to ensure the correct load order for the bootstrap integration, and is usually a good idea in general. You will therefore need to explicitly require your files.
|
511
|
-
|
512
|
-
How the Bootstrap library is loaded depends upon whether one is using the Rails server or the HMR development server.
|
513
|
-
|
514
|
-
#### Bootstrap via Rails Server
|
515
|
-
In the former case, the Rails server loads `bootstrap-sprockets`, provided by the `bootstrap-sass` ruby gem (added automatically to your Gemfile by the generator) via the `app/assets/stylesheets/_bootstrap-custom.scss` partial.
|
516
|
-
|
517
|
-
This allows for using Bootstrap in your regular Rails stylesheets. If you wish to customize any of the Bootstrap variables, you can do so via the `client/assets/stylesheets/_pre-bootstrap.scss` partial.
|
518
|
-
|
519
|
-
#### Bootstrap via Webpack HMR Dev Server
|
520
|
-
When using the webpack dev server, which does not go through Rails, bootstrap is loaded via the [bootstrap-sass-loader](https://github.com/shakacode/bootstrap-sass-loader) which uses the `client/bootstrap-sass-config.js` file.
|
521
|
-
|
522
|
-
#### Keeping Custom Bootstrap Configurations Synced
|
523
|
-
Because the webpack dev server and Rails each load Bootstrap via a different file (explained in the two sections immediately above), any changes to the way components are loaded in one file must also be made to the other file in order to keep styling consistent between the two. For example, if an import is excluded in `_bootstrap-custom.scss`, the same import should be excluded in `bootstrap-sass-config.js` so that styling in the Rails server and the webpack dev server will be the same.
|
524
|
-
|
525
|
-
#### Skip Bootstrap Integration
|
526
|
-
Bootstrap integration is enabled by default, but can be disabled by passing the `--skip-bootstrap` flag (alias `-b`). When you don't need Bootstrap in your existing project, just skip it as needed.
|
527
|
-
|
528
|
-
### Linters
|
529
|
-
The React on Rails generator can add linters and their recommended accompanying configurations to your project. There are two classes of linters: ruby linters and JavaScript linters.
|
530
|
-
|
531
|
-
##### JavaScript Linters
|
532
|
-
JavaScript linters are **enabled by default**, but can be disabled by passing the `--skip-js-linters` flag (alias `j`) , and those that run in Node have been added to `client/package.json` under `devDependencies`.
|
533
|
-
|
534
|
-
##### Ruby Linters
|
535
|
-
Ruby linters are **disabled by default**, but can be enabled by passing the `--ruby-linters` flag when generating. These linters have been added to your Gemfile in addition to the appropriate Rake tasks.
|
536
|
-
|
537
|
-
We really love using all the linters! Give them a try.
|
538
|
-
|
539
|
-
#### Running the Linters
|
540
|
-
To run the linters (runs all linters you have installed, even if you installed both Ruby and Node):
|
541
|
-
|
542
|
-
```bash
|
543
|
-
rake lint
|
544
|
-
```
|
545
|
-
|
546
|
-
Run this command to see all the linters available
|
547
|
-
|
548
|
-
```bash
|
549
|
-
rake -T lint
|
550
|
-
```
|
551
|
-
|
552
|
-
**Here's the list:**
|
553
|
-
```bash
|
554
|
-
rake lint # Runs all linters
|
555
|
-
rake lint:eslint # eslint
|
556
|
-
rake lint:js # JS Linting
|
557
|
-
rake lint:jscs # jscs
|
558
|
-
rake lint:rubocop[fix] # Run Rubocop lint in shell
|
559
|
-
rake lint:ruby # Run ruby-lint as shell
|
560
|
-
rake lint:scss # See docs for task 'scss_lint'
|
561
|
-
```
|
562
|
-
|
563
489
|
## Multiple React Components on a Page with One Store
|
564
490
|
You may wish to have 2 React components share the same the Redux store. For example, if your navbar is a React component, you may want it to use the same store as your component in the main area of the page. You may even want multiple React components in the main area, which allows for greater modularity. In addition, you may want this to work with Turbolinks to minimize reloading the JavaScript. A good example of this would be something like an a notifications counter in a header. As each notifications is read in the body of the page, you would like to update the header. If both the header and body share the same Redux store, then this is trivial. Otherwise, we have to rely on other solutions, such as the header polling the server to see how many unread notifications exist.
|
565
491
|
|
@@ -65,5 +65,35 @@ bin/rake db:migrate
|
|
65
65
|
bin/rake db:setup
|
66
66
|
```
|
67
67
|
|
68
|
+
3. Create a rake file to add webpack compilation to asset precompilation. You may already have this file if you used the React on Rails generator.
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
# lib/tasks/assets.rake
|
72
|
+
# The webpack task must run before assets:environment task.
|
73
|
+
# Otherwise Sprockets cannot find the files that webpack produces.
|
74
|
+
# This is the secret sauce for how a Heroku deployment knows to create the webpack generated JavaScript files.
|
75
|
+
Rake::Task["assets:precompile"]
|
76
|
+
.clear_prerequisites
|
77
|
+
.enhance(["assets:compile_environment"])
|
78
|
+
|
79
|
+
namespace :assets do
|
80
|
+
# In this task, set prerequisites for the assets:precompile task
|
81
|
+
task compile_environment: :webpack do
|
82
|
+
Rake::Task["assets:environment"].invoke
|
83
|
+
end
|
84
|
+
|
85
|
+
desc "Compile assets with webpack"
|
86
|
+
task :webpack do
|
87
|
+
sh "cd client && npm run build:client"
|
88
|
+
# If you are doing server rendering
|
89
|
+
# sh "cd client && npm run build:server"
|
90
|
+
end
|
91
|
+
|
92
|
+
task :clobber do
|
93
|
+
rm_r Dir.glob(Rails.root.join("app/assets/webpack/*"))
|
94
|
+
end
|
95
|
+
end
|
96
|
+
```
|
97
|
+
|
68
98
|
|
69
99
|
|
@@ -1,12 +1,14 @@
|
|
1
1
|
# Tips for Contributors
|
2
|
-
*See [Releasing](
|
2
|
+
*See [Releasing](./releasing.md) for instructions on releasing.*
|
3
3
|
|
4
|
-
|
4
|
+
## To run tests:
|
5
|
+
* After updating code via git, to prepare all examples and run all tests:
|
5
6
|
|
6
7
|
```
|
7
|
-
bundle && npm i && rake examples:prepare_all && rake
|
8
|
+
bundle && npm i && rake examples:prepare_all && rake node_package && rake
|
8
9
|
```
|
9
10
|
|
11
|
+
See Dev Initial Setup, below for, well... initial setup.
|
10
12
|
|
11
13
|
# IDE/IDE SETUP
|
12
14
|
It's critical to configure your IDE/editor to ignore certain directories. Otherwise your IDE might slow to a crawl!
|
@@ -19,6 +21,7 @@ It's critical to configure your IDE/editor to ignore certain directories. Otherw
|
|
19
21
|
* /spec/dummy/app/assets/webpack
|
20
22
|
* /spec/dummy/log
|
21
23
|
* /spec/dummy/node_modules
|
24
|
+
* /spec/dummy/client/node_modules
|
22
25
|
* /spec/dummy/tmp
|
23
26
|
* /spec/react_on_rails/dummy-for-generators
|
24
27
|
|
@@ -81,17 +84,19 @@ This is the error:
|
|
81
84
|
### Prereqs
|
82
85
|
After checking out the repo, making sure you have rvm and nvm setup (setup ruby and node), cd to `spec/dummy` and run `bin/setup` to install ruby dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
83
86
|
|
84
|
-
Additionally, our RSpec tests use the poltergeist web driver. You will need to install the
|
87
|
+
Additionally, our RSpec tests use the poltergeist web driver. You will need to install the phantomjs node module:
|
85
88
|
|
86
89
|
```sh
|
87
|
-
npm install -g
|
90
|
+
npm install -g phantomjs
|
88
91
|
```
|
89
92
|
|
93
|
+
Note this *must* be installed globally for the dummy test project rspec runner to see it properly.
|
94
|
+
|
90
95
|
### NPM link
|
91
96
|
Because the example and dummy apps rely on the react-on-rails node package, they should link directly to your local version to pick up any changes you may have made to that package. To achieve this, switch to the app's root directory and run:
|
92
97
|
|
93
98
|
```sh
|
94
|
-
npm run
|
99
|
+
npm run node_package
|
95
100
|
```
|
96
101
|
|
97
102
|
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:prepare_all` rake task.
|
@@ -3,7 +3,7 @@
|
|
3
3
|
We're now releasing this as a combined ruby gem plus npm package. We will keep the version numbers in sync.
|
4
4
|
|
5
5
|
## Testing the Gem before Release from a Rails App
|
6
|
-
See [Contributing](
|
6
|
+
See [Contributing](./contributing.md)
|
7
7
|
|
8
8
|
## Releasing a new gem version
|
9
9
|
Run `rake -D release` to see instructions on how to release via the rake task.
|
data/docs/tutorial.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
# Tutorial for React on Rails
|
1
|
+
# Tutorial for React on Rails (THIS ONLY WORKS UP TO VERSION 5.1.1)
|
2
|
+
|
3
|
+
*Version 5.2 and greater have removed the non-essential options. See the [changelog](../CHANGELOG.md) for details on what was removed.*
|
2
4
|
|
3
5
|
This tutorial setups up a new Rails app with **React on Rails**, demonstrating Rails + React + Redux + Server Rendering.
|
4
6
|
|
@@ -21,37 +21,11 @@ module ReactOnRails
|
|
21
21
|
default: false,
|
22
22
|
desc: "Configure for server-side rendering of webpack JavaScript",
|
23
23
|
aliases: "-S"
|
24
|
-
# --skip-js-linters
|
25
|
-
class_option :skip_js_linters,
|
26
|
-
type: :boolean,
|
27
|
-
default: false,
|
28
|
-
desc: "Skip installing JavaScript linting files",
|
29
|
-
aliases: "-j"
|
30
|
-
# --ruby-linters
|
31
|
-
class_option :ruby_linters,
|
32
|
-
type: :boolean,
|
33
|
-
default: false,
|
34
|
-
desc: "Install ruby linting files, tasks, and configs",
|
35
|
-
aliases: "-L"
|
36
|
-
|
37
|
-
# --skip-bootstrap
|
38
|
-
class_option :skip_bootstrap,
|
39
|
-
type: :boolean,
|
40
|
-
default: false,
|
41
|
-
desc: "Skip integrating Bootstrap and don't initialize files and regarding configs",
|
42
|
-
aliases: "-b"
|
43
24
|
|
44
25
|
def add_hello_world_route
|
45
26
|
route "get 'hello_world', to: 'hello_world#index'"
|
46
27
|
end
|
47
28
|
|
48
|
-
def create_client_assets_directories
|
49
|
-
empty_directory("client/assets")
|
50
|
-
empty_directory("client/assets/stylesheets")
|
51
|
-
empty_directory_with_keep_file("client/assets/fonts")
|
52
|
-
empty_directory_with_keep_file("client/assets/images")
|
53
|
-
end
|
54
|
-
|
55
29
|
def update_git_ignore
|
56
30
|
data = <<-DATA.strip_heredoc
|
57
31
|
# React on Rails
|
@@ -112,8 +86,6 @@ module ReactOnRails
|
|
112
86
|
base_path = "base/base/"
|
113
87
|
base_files = %w(app/controllers/hello_world_controller.rb
|
114
88
|
client/.babelrc
|
115
|
-
client/index.jade
|
116
|
-
client/server.js
|
117
89
|
client/webpack.client.base.config.js
|
118
90
|
client/webpack.client.rails.config.js
|
119
91
|
REACT_ON_RAILS.md
|
@@ -125,11 +97,9 @@ module ReactOnRails
|
|
125
97
|
base_path = "base/base/"
|
126
98
|
%w(config/initializers/react_on_rails.rb
|
127
99
|
Procfile.dev
|
128
|
-
Procfile.dev-hot
|
129
100
|
app/views/hello_world/index.html.erb
|
130
101
|
package.json
|
131
102
|
client/app/bundles/HelloWorld/components/HelloWorldWidget.jsx
|
132
|
-
client/webpack.client.hot.config.js
|
133
103
|
client/package.json).each { |file| template(base_path + file + ".tt", file) }
|
134
104
|
end
|
135
105
|
|
@@ -153,11 +123,6 @@ module ReactOnRails
|
|
153
123
|
end
|
154
124
|
end
|
155
125
|
|
156
|
-
def template_linter_files_if_appropriate
|
157
|
-
return if !options.ruby_linters? && options.skip_js_linters?
|
158
|
-
template("base/base/lib/tasks/linters.rake.tt", "lib/tasks/linters.rake")
|
159
|
-
end
|
160
|
-
|
161
126
|
def template_assets_rake_file
|
162
127
|
template("base/base/lib/tasks/assets.rake.tt", "lib/tasks/assets.rake")
|
163
128
|
end
|
@@ -167,9 +132,6 @@ module ReactOnRails
|
|
167
132
|
# If you do not want to move existing images and fonts from your Rails app
|
168
133
|
# you could also consider creating symlinks there that point to the original
|
169
134
|
# rails directories. In that case, you would not add these paths here.
|
170
|
-
Rails.application.config.assets.paths << Rails.root.join("client", "assets", "stylesheets")
|
171
|
-
Rails.application.config.assets.paths << Rails.root.join("client", "assets", "images")
|
172
|
-
Rails.application.config.assets.paths << Rails.root.join("client", "assets", "fonts")
|
173
135
|
Rails.application.config.assets.precompile += %w( server-bundle.js )
|
174
136
|
|
175
137
|
# Add folder with webpack generated assets to assets.paths
|
@@ -211,19 +173,6 @@ Rails.application.config.assets.paths << Rails.root.join("app", "assets", "webpa
|
|
211
173
|
ReactOnRails::TestHelper.configure_rspec_to_compile_assets(config)
|
212
174
|
STR
|
213
175
|
|
214
|
-
# rename to application.scss from application.css or application.css.scss
|
215
|
-
def force_application_scss_naming_if_necessary
|
216
|
-
base_path = "app/assets/stylesheets/"
|
217
|
-
application_css = "#{base_path}application.css"
|
218
|
-
application_css_scss = "#{base_path}application.css.scss"
|
219
|
-
|
220
|
-
bad_name = dest_file_exists?(application_css) || dest_file_exists?(application_css_scss)
|
221
|
-
return unless bad_name
|
222
|
-
|
223
|
-
new_name = File.join(destination_root, "#{base_path}application.scss")
|
224
|
-
File.rename(bad_name, new_name)
|
225
|
-
end
|
226
|
-
|
227
176
|
def print_helpful_message
|
228
177
|
message = <<-MSG.strip_heredoc
|
229
178
|
|
@@ -238,12 +187,6 @@ Rails.application.config.assets.paths << Rails.root.join("app", "assets", "webpa
|
|
238
187
|
npm run rails-server
|
239
188
|
|
240
189
|
- Visit http://localhost:3000/hello_world and see your React On Rails app running!
|
241
|
-
|
242
|
-
- Run the npm express-server command to load the node server with hot reloading support.
|
243
|
-
|
244
|
-
npm run express-server
|
245
|
-
|
246
|
-
- Visit http://localhost:4000 and see your React On Rails app running using the Webpack Dev server.
|
247
190
|
MSG
|
248
191
|
GeneratorMessages.add_info(message)
|
249
192
|
end
|
@@ -22,30 +22,6 @@ module ReactOnRails
|
|
22
22
|
default: false,
|
23
23
|
desc: "Add necessary files and configurations for server-side rendering. Default: false",
|
24
24
|
aliases: "-S"
|
25
|
-
# --skip-js-linters
|
26
|
-
class_option :skip_js_linters,
|
27
|
-
type: :boolean,
|
28
|
-
default: false,
|
29
|
-
desc: "Skip installing JavaScript linting files. Default: false",
|
30
|
-
aliases: "-j"
|
31
|
-
# --ruby-linters
|
32
|
-
class_option :ruby_linters,
|
33
|
-
type: :boolean,
|
34
|
-
default: false,
|
35
|
-
desc: "Install ruby linting files, tasks, and configs. Default: false",
|
36
|
-
aliases: "-L"
|
37
|
-
# --ruby-linters
|
38
|
-
class_option :heroku_deployment,
|
39
|
-
type: :boolean,
|
40
|
-
default: false,
|
41
|
-
desc: "Install files necessary for deploying to Heroku. Default: false",
|
42
|
-
aliases: "-H"
|
43
|
-
# --skip-bootstrap
|
44
|
-
class_option :skip_bootstrap,
|
45
|
-
type: :boolean,
|
46
|
-
default: false,
|
47
|
-
desc: "Skip integrating Bootstrap and don't initialize files and regarding configs. Default: false",
|
48
|
-
aliases: "-b"
|
49
25
|
|
50
26
|
# --ignore-warnings
|
51
27
|
class_option :ignore_warnings,
|
@@ -76,10 +52,6 @@ module ReactOnRails
|
|
76
52
|
invoke "react_on_rails:base"
|
77
53
|
invoke "react_on_rails:react_no_redux" unless options.redux?
|
78
54
|
invoke "react_on_rails:react_with_redux" if options.redux?
|
79
|
-
invoke "react_on_rails:js_linters" unless options.skip_js_linters?
|
80
|
-
invoke "react_on_rails:ruby_linters" if options.ruby_linters?
|
81
|
-
invoke "react_on_rails:heroku_deployment" if options.heroku_deployment?
|
82
|
-
invoke "react_on_rails:bootstrap" unless options.skip_bootstrap?
|
83
55
|
end
|
84
56
|
|
85
57
|
# NOTE: other requirements for existing files such as .gitignore or application.
|
@@ -3,9 +3,6 @@
|
|
3
3
|
|
4
4
|
import React, { PropTypes } from 'react';
|
5
5
|
import _ from 'lodash';
|
6
|
-
<%- unless options.skip_bootstrap? -%>
|
7
|
-
import { Input } from 'react-bootstrap';
|
8
|
-
<%- end -%>
|
9
6
|
|
10
7
|
// Simple example of a React "dumb" component
|
11
8
|
export default class HelloWorldWidget extends React.Component {
|
@@ -40,25 +37,14 @@ export default class HelloWorldWidget extends React.Component {
|
|
40
37
|
</h3>
|
41
38
|
<hr />
|
42
39
|
<form className="form-horizontal">
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
/>
|
52
|
-
<%- else -%>
|
53
|
-
<Input
|
54
|
-
type="text"
|
55
|
-
labelClassName="col-sm-2"
|
56
|
-
wrapperClassName="col-sm-10"
|
57
|
-
label="Say hello to:"
|
58
|
-
value={name}
|
59
|
-
onChange={this.handleChange}
|
60
|
-
/>
|
61
|
-
<%- end -%>
|
40
|
+
<label>
|
41
|
+
Say hello to:
|
42
|
+
</label>
|
43
|
+
<input
|
44
|
+
type="text"
|
45
|
+
value={name}
|
46
|
+
onChange={this.handleChange}
|
47
|
+
/>
|
62
48
|
</form>
|
63
49
|
</div>
|
64
50
|
);
|