react_on_rails 1.0.0.pre → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/.dockerignore +2 -0
  3. data/.eslintignore +2 -0
  4. data/.eslintrc +1 -0
  5. data/.gitignore +4 -0
  6. data/.jscsrc +2 -2
  7. data/.rubocop.yml +2 -0
  8. data/.scss-lint.yml +3 -3
  9. data/.travis.yml +31 -18
  10. data/Dockerfile_ci +12 -0
  11. data/Dockerfile_tests +12 -0
  12. data/{LICENSE.txt → LICENSE} +0 -0
  13. data/README.md +170 -290
  14. data/Rakefile +20 -7
  15. data/app/helpers/react_on_rails_helper.rb +5 -5
  16. data/docker-compose.yml +12 -0
  17. data/docs/Contributing.md +26 -2
  18. data/docs/gen-notes/react_syntax.md +3 -0
  19. data/docs/gen-notes/reducers.md +31 -0
  20. data/docs/generator_testing_script.md +50 -0
  21. data/docs/linters.md +8 -0
  22. data/docs/manual_configuration.md +202 -0
  23. data/docs/node_dependencies_and_npm.md +29 -0
  24. data/lib/generators/react_on_rails/base_generator.rb +116 -0
  25. data/lib/generators/react_on_rails/bootstrap_generator.rb +84 -0
  26. data/lib/generators/react_on_rails/generator_helper.rb +48 -0
  27. data/lib/generators/react_on_rails/heroku_deployment_generator.rb +22 -0
  28. data/lib/generators/react_on_rails/install_generator.rb +86 -0
  29. data/lib/generators/react_on_rails/linters_generator.rb +38 -0
  30. data/lib/generators/react_on_rails/react_no_redux_generator.rb +37 -0
  31. data/lib/generators/react_on_rails/react_with_redux_generator.rb +61 -0
  32. data/lib/generators/react_on_rails/templates/base/base/Procfile.dev.tt +4 -0
  33. data/lib/generators/react_on_rails/templates/base/base/REACT_ON_RAILS.md +16 -0
  34. data/lib/generators/react_on_rails/templates/base/base/app/controllers/hello_world_controller.rb +5 -0
  35. data/lib/generators/react_on_rails/templates/base/base/app/views/hello_world/index.html.erb.tt +6 -0
  36. data/lib/generators/react_on_rails/templates/base/base/client/.babelrc +3 -0
  37. data/lib/generators/react_on_rails/templates/base/base/client/REACT_ON_RAILS_CLIENT_README.md +3 -0
  38. data/lib/generators/react_on_rails/templates/base/base/client/app/bundles/HelloWorld/startup/clientGlobals.jsx +4 -0
  39. data/lib/generators/react_on_rails/templates/base/base/client/index.jade +15 -0
  40. data/lib/generators/react_on_rails/templates/base/base/client/npm-shrinkwrap.json +2907 -0
  41. data/lib/generators/react_on_rails/templates/base/base/client/server.js +58 -0
  42. data/lib/generators/react_on_rails/templates/base/base/client/webpack.client.base.config.js +58 -0
  43. data/lib/generators/react_on_rails/templates/base/base/client/webpack.client.hot.config.js +65 -0
  44. data/lib/generators/react_on_rails/templates/base/base/client/webpack.client.rails.config.js +45 -0
  45. data/lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb +30 -0
  46. data/lib/generators/react_on_rails/templates/base/base/lib/tasks/assets.rake +26 -0
  47. data/lib/generators/react_on_rails/templates/base/base/package.json +31 -0
  48. data/lib/generators/react_on_rails/templates/base/server_rendering/client/app/bundles/HelloWorld/startup/serverGlobals.jsx +3 -0
  49. data/lib/generators/react_on_rails/templates/base/server_rendering/client/webpack.server.rails.config.js +37 -0
  50. data/lib/generators/react_on_rails/templates/bootstrap/app/assets/stylesheets/_bootstrap-custom.scss +63 -0
  51. data/lib/generators/react_on_rails/templates/bootstrap/client/assets/stylesheets/_post-bootstrap.scss +10 -0
  52. data/lib/generators/react_on_rails/templates/bootstrap/client/assets/stylesheets/_pre-bootstrap.scss +8 -0
  53. data/lib/generators/react_on_rails/templates/bootstrap/client/assets/stylesheets/_react-on-rails-sass-helper.scss +19 -0
  54. data/lib/generators/react_on_rails/templates/bootstrap/client/bootstrap-sass.config.js +89 -0
  55. data/lib/generators/react_on_rails/templates/client/README.md +97 -0
  56. data/lib/generators/react_on_rails/templates/heroku_deployment/.buildpacks +2 -0
  57. data/lib/generators/react_on_rails/templates/heroku_deployment/Procfile +1 -0
  58. data/lib/generators/react_on_rails/templates/linters/client/.eslintignore +1 -0
  59. data/lib/generators/react_on_rails/templates/linters/client/.eslintrc +17 -0
  60. data/lib/generators/react_on_rails/templates/linters/client/.jscsrc +7 -0
  61. data/lib/generators/react_on_rails/templates/linters/lib/tasks/brakeman.rake +17 -0
  62. data/lib/generators/react_on_rails/templates/linters/lib/tasks/ci.rake +33 -0
  63. data/lib/generators/react_on_rails/templates/linters/lib/tasks/linters.rake +81 -0
  64. data/lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/components/HelloWorldWidget.jsx +39 -0
  65. data/lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/containers/HelloWorld.jsx +33 -0
  66. data/lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/startup/HelloWorldAppClient.jsx +11 -0
  67. data/lib/generators/react_on_rails/templates/no_redux/base/client/package.json.tt +75 -0
  68. data/lib/generators/react_on_rails/templates/no_redux/server_rendering/client/app/bundles/HelloWorld/startup/HelloWorldAppServer.jsx +11 -0
  69. data/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/actions/helloWorldActionCreators.jsx +8 -0
  70. data/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/components/HelloWorldWidget.jsx +48 -0
  71. data/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/constants/helloWorldConstants.jsx +8 -0
  72. data/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/containers/HelloWorld.jsx +43 -0
  73. data/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/reducers/helloWorldReducer.jsx +21 -0
  74. data/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/reducers/index.jsx +14 -0
  75. data/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/startup/HelloWorldAppClient.jsx +20 -0
  76. data/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/store/helloWorldStore.jsx +35 -0
  77. data/lib/generators/react_on_rails/templates/redux/base/client/app/lib/middlewares/loggerMiddleware.js +25 -0
  78. data/lib/generators/react_on_rails/templates/redux/base/client/package.json.tt +82 -0
  79. data/lib/generators/react_on_rails/templates/redux/server_rendering/client/app/bundles/HelloWorld/startup/HelloWorldAppServer.jsx +21 -0
  80. data/lib/react_on_rails.rb +1 -7
  81. data/lib/react_on_rails/configuration.rb +14 -5
  82. data/lib/react_on_rails/engine.rb +7 -0
  83. data/lib/react_on_rails/server_rendering_pool.rb +14 -1
  84. data/lib/react_on_rails/version.rb +1 -1
  85. data/react_on_rails.gemspec +2 -2
  86. data/ruby-lint.yml +1 -0
  87. metadata +75 -11
  88. data/Dockerfile +0 -14
  89. data/docs/README.md +0 -1
@@ -3,10 +3,4 @@ require "rails"
3
3
  require "react_on_rails/version"
4
4
  require "react_on_rails/configuration"
5
5
  require "react_on_rails/server_rendering_pool"
6
- module ReactOnRails
7
- class Engine < ::Rails::Engine
8
- config.to_prepare do
9
- ReactOnRails::ServerRenderingPool.reset_pool
10
- end
11
- end
12
- end
6
+ require "react_on_rails/engine"
@@ -11,17 +11,21 @@ module ReactOnRails
11
11
  logging_on_server: true,
12
12
  generator_function: false,
13
13
  trace: Rails.env.development?,
14
+ development_mode: Rails.env.development?,
14
15
  server_renderer_pool_size: 1,
15
16
  server_renderer_timeout: 20)
16
17
  end
17
18
 
18
19
  class Configuration
19
- attr_accessor :server_bundle_js_file, :prerender, :replay_console, :generator_function, :trace,
20
- :logging_on_server, :server_renderer_pool_size, :server_renderer_timeout
20
+ attr_accessor :server_bundle_js_file, :prerender, :replay_console,
21
+ :generator_function, :trace, :development_mode,
22
+ :logging_on_server, :server_renderer_pool_size,
23
+ :server_renderer_timeout
21
24
 
22
25
  def initialize(server_bundle_js_file: nil, prerender: nil, replay_console: nil,
23
- generator_function: nil, trace: nil, logging_on_server: nil,
24
- server_renderer_pool_size: nil, server_renderer_timeout: nil)
26
+ generator_function: nil, trace: nil, development_mode: nil,
27
+ logging_on_server: nil, server_renderer_pool_size: nil,
28
+ server_renderer_timeout: nil)
25
29
  if File.exist?(server_bundle_js_file)
26
30
  self.server_bundle_js_file = server_bundle_js_file
27
31
  else
@@ -32,10 +36,15 @@ module ReactOnRails
32
36
  self.replay_console = replay_console
33
37
  self.logging_on_server = logging_on_server
34
38
  self.generator_function = generator_function
39
+ if development_mode.nil?
40
+ self.development_mode = Rails.env.development?
41
+ else
42
+ self.development_mode = development_mode
43
+ end
35
44
  self.trace = trace.nil? ? Rails.env.development? : trace
36
45
 
37
46
  # Server rendering:
38
- self.server_renderer_pool_size = server_renderer_pool_size # increase if you're on JRuby
47
+ self.server_renderer_pool_size = self.development_mode ? 1 : server_renderer_pool_size
39
48
  self.server_renderer_timeout = server_renderer_timeout # seconds
40
49
  end
41
50
  end
@@ -0,0 +1,7 @@
1
+ module ReactOnRails
2
+ class Engine < ::Rails::Engine
3
+ config.to_prepare do
4
+ ReactOnRails::ServerRenderingPool.reset_pool
5
+ end
6
+ end
7
+ end
@@ -11,6 +11,15 @@ module ReactOnRails
11
11
  @js_context_pool = ConnectionPool.new(options) { create_js_context }
12
12
  end
13
13
 
14
+ def self.reset_pool_if_server_bundle_was_modified
15
+ return unless ReactOnRails.configuration.development_mode
16
+ file_mtime = File.mtime(ReactOnRails.configuration.server_bundle_js_file)
17
+ first_time = @server_bundle_timestamp.nil?
18
+ return if first_time || @server_bundle_timestamp == file_mtime
19
+ ReactOnRails::ServerRenderingPool.reset_pool
20
+ @server_bundle_timestamp = file_mtime
21
+ end
22
+
14
23
  class PrerenderError < RuntimeError
15
24
  def initialize(component_name, props, js_message)
16
25
  message = ["Encountered error \"#{js_message}\" when prerendering #{component_name} with #{props}",
@@ -81,7 +90,11 @@ module ReactOnRails
81
90
  ExecJS.compile(base_js_code)
82
91
  else
83
92
  if server_js_file.present?
84
- Rails.logger.warn("You specified server rendering JS file: #{server_js_file}, but it cannot be read.")
93
+ msg = "You specified server rendering JS file: #{server_js_file}, but it cannot be "\
94
+ "read. You may set the server_bundle_js_file in your configuration to be \"\" to "\
95
+ "avoid this warning"
96
+ Rails.logger.warn msg
97
+ puts msg
85
98
  end
86
99
  ExecJS.compile("")
87
100
  end
@@ -1,3 +1,3 @@
1
1
  module ReactOnRails
2
- VERSION = "1.0.0.pre"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -19,13 +19,13 @@ Gem::Specification.new do |s|
19
19
  s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  s.require_paths = ["lib"]
21
21
 
22
- s.add_dependency "rails", ">= 4.0"
22
+ s.add_dependency "rails", ">= 3.2"
23
23
  s.add_dependency "execjs", "~> 2.5"
24
24
  s.add_dependency "connection_pool"
25
25
 
26
26
  s.add_development_dependency "bundler", "~> 1.10"
27
27
  s.add_development_dependency "rake", "~> 10.0"
28
28
  s.add_development_dependency "rspec"
29
- s.add_development_dependency "rubocop"
30
29
  s.add_development_dependency "coveralls"
30
+ s.add_development_dependency "generator_spec"
31
31
  end
data/ruby-lint.yml CHANGED
@@ -10,6 +10,7 @@ directories:
10
10
  ignore_paths:
11
11
  - client
12
12
  - node_modules
13
+ - coverage
13
14
 
14
15
  analysis_classes:
15
16
  # - argument_amount
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.0.0.pre
4
+ version: 1.0.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: 2015-10-13 00:00:00.000000000 Z
11
+ date: 2015-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.0'
19
+ version: '3.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '4.0'
26
+ version: '3.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: execjs
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -95,7 +95,7 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: rubocop
98
+ name: coveralls
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ">="
@@ -109,7 +109,7 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: coveralls
112
+ name: generator_spec
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
@@ -131,6 +131,7 @@ extra_rdoc_files: []
131
131
  files:
132
132
  - ".babelrc"
133
133
  - ".coveralls.yml"
134
+ - ".dockerignore"
134
135
  - ".eslintignore"
135
136
  - ".eslintrc"
136
137
  - ".gitignore"
@@ -140,20 +141,83 @@ files:
140
141
  - ".scss-lint.yml"
141
142
  - ".travis.yml"
142
143
  - CODE_OF_CONDUCT.md
143
- - Dockerfile
144
+ - Dockerfile_ci
145
+ - Dockerfile_tests
144
146
  - Gemfile
145
- - LICENSE.txt
147
+ - LICENSE
146
148
  - README.md
147
149
  - Rakefile
148
150
  - app/assets/javascripts/react_on_rails.js
149
151
  - app/helpers/react_on_rails_helper.rb
150
152
  - docker-compose.yml
151
153
  - docs/Contributing.md
152
- - docs/README.md
154
+ - docs/gen-notes/react_syntax.md
155
+ - docs/gen-notes/reducers.md
156
+ - docs/generator_testing_script.md
157
+ - docs/linters.md
158
+ - docs/manual_configuration.md
159
+ - docs/node_dependencies_and_npm.md
153
160
  - docs/sample_generated_js/client-generated.js
154
161
  - docs/sample_generated_js/server-generated.js
162
+ - lib/generators/react_on_rails/base_generator.rb
163
+ - lib/generators/react_on_rails/bootstrap_generator.rb
164
+ - lib/generators/react_on_rails/generator_helper.rb
165
+ - lib/generators/react_on_rails/heroku_deployment_generator.rb
166
+ - lib/generators/react_on_rails/install_generator.rb
167
+ - lib/generators/react_on_rails/linters_generator.rb
168
+ - lib/generators/react_on_rails/react_no_redux_generator.rb
169
+ - lib/generators/react_on_rails/react_with_redux_generator.rb
170
+ - lib/generators/react_on_rails/templates/base/base/Procfile.dev.tt
171
+ - lib/generators/react_on_rails/templates/base/base/REACT_ON_RAILS.md
172
+ - lib/generators/react_on_rails/templates/base/base/app/controllers/hello_world_controller.rb
173
+ - lib/generators/react_on_rails/templates/base/base/app/views/hello_world/index.html.erb.tt
174
+ - lib/generators/react_on_rails/templates/base/base/client/.babelrc
175
+ - lib/generators/react_on_rails/templates/base/base/client/REACT_ON_RAILS_CLIENT_README.md
176
+ - lib/generators/react_on_rails/templates/base/base/client/app/bundles/HelloWorld/startup/clientGlobals.jsx
177
+ - lib/generators/react_on_rails/templates/base/base/client/index.jade
178
+ - lib/generators/react_on_rails/templates/base/base/client/npm-shrinkwrap.json
179
+ - lib/generators/react_on_rails/templates/base/base/client/server.js
180
+ - lib/generators/react_on_rails/templates/base/base/client/webpack.client.base.config.js
181
+ - lib/generators/react_on_rails/templates/base/base/client/webpack.client.hot.config.js
182
+ - lib/generators/react_on_rails/templates/base/base/client/webpack.client.rails.config.js
183
+ - lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb
184
+ - lib/generators/react_on_rails/templates/base/base/lib/tasks/assets.rake
185
+ - lib/generators/react_on_rails/templates/base/base/package.json
186
+ - lib/generators/react_on_rails/templates/base/server_rendering/client/app/bundles/HelloWorld/startup/serverGlobals.jsx
187
+ - lib/generators/react_on_rails/templates/base/server_rendering/client/webpack.server.rails.config.js
188
+ - lib/generators/react_on_rails/templates/bootstrap/app/assets/stylesheets/_bootstrap-custom.scss
189
+ - lib/generators/react_on_rails/templates/bootstrap/client/assets/stylesheets/_post-bootstrap.scss
190
+ - lib/generators/react_on_rails/templates/bootstrap/client/assets/stylesheets/_pre-bootstrap.scss
191
+ - lib/generators/react_on_rails/templates/bootstrap/client/assets/stylesheets/_react-on-rails-sass-helper.scss
192
+ - lib/generators/react_on_rails/templates/bootstrap/client/bootstrap-sass.config.js
193
+ - lib/generators/react_on_rails/templates/client/README.md
194
+ - lib/generators/react_on_rails/templates/heroku_deployment/.buildpacks
195
+ - lib/generators/react_on_rails/templates/heroku_deployment/Procfile
196
+ - lib/generators/react_on_rails/templates/linters/client/.eslintignore
197
+ - lib/generators/react_on_rails/templates/linters/client/.eslintrc
198
+ - lib/generators/react_on_rails/templates/linters/client/.jscsrc
199
+ - lib/generators/react_on_rails/templates/linters/lib/tasks/brakeman.rake
200
+ - lib/generators/react_on_rails/templates/linters/lib/tasks/ci.rake
201
+ - lib/generators/react_on_rails/templates/linters/lib/tasks/linters.rake
202
+ - lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/components/HelloWorldWidget.jsx
203
+ - lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/containers/HelloWorld.jsx
204
+ - lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/startup/HelloWorldAppClient.jsx
205
+ - lib/generators/react_on_rails/templates/no_redux/base/client/package.json.tt
206
+ - lib/generators/react_on_rails/templates/no_redux/server_rendering/client/app/bundles/HelloWorld/startup/HelloWorldAppServer.jsx
207
+ - lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/actions/helloWorldActionCreators.jsx
208
+ - lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/components/HelloWorldWidget.jsx
209
+ - lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/constants/helloWorldConstants.jsx
210
+ - lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/containers/HelloWorld.jsx
211
+ - lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/reducers/helloWorldReducer.jsx
212
+ - lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/reducers/index.jsx
213
+ - lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/startup/HelloWorldAppClient.jsx
214
+ - lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/store/helloWorldStore.jsx
215
+ - lib/generators/react_on_rails/templates/redux/base/client/app/lib/middlewares/loggerMiddleware.js
216
+ - lib/generators/react_on_rails/templates/redux/base/client/package.json.tt
217
+ - lib/generators/react_on_rails/templates/redux/server_rendering/client/app/bundles/HelloWorld/startup/HelloWorldAppServer.jsx
155
218
  - lib/react_on_rails.rb
156
219
  - lib/react_on_rails/configuration.rb
220
+ - lib/react_on_rails/engine.rb
157
221
  - lib/react_on_rails/server_rendering_pool.rb
158
222
  - lib/react_on_rails/version.rb
159
223
  - react_on_rails.gemspec
@@ -173,9 +237,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
173
237
  version: '0'
174
238
  required_rubygems_version: !ruby/object:Gem::Requirement
175
239
  requirements:
176
- - - ">"
240
+ - - ">="
177
241
  - !ruby/object:Gem::Version
178
- version: 1.3.1
242
+ version: '0'
179
243
  requirements: []
180
244
  rubyforge_project:
181
245
  rubygems_version: 2.4.8
data/Dockerfile DELETED
@@ -1,14 +0,0 @@
1
- FROM ruby:2.2.3
2
- MAINTAINER Dylan Grafmyre <dylan@shakacode.com>
3
-
4
- RUN mkdir -p /app
5
- WORKDIR /app/
6
- # Setup container for linting with ruby and npm
7
- RUN gem install rubocop ruby-lint scss_lint
8
- RUN curl --silent --location https://deb.nodesource.com/setup_0.12 | bash -
9
- RUN apt-get install -y nodejs
10
- RUN npm install -g eslint \
11
- eslint-config-airbnb \
12
- eslint-plugin-react \
13
- babel-eslint \
14
- jscs
data/docs/README.md DELETED
@@ -1 +0,0 @@
1
- ## PENDING: ADD DOCS HERE