react_webpack_rails 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 63660480d9bc4607d4ed78cf2f51224cabf6ffbb
4
- data.tar.gz: 7a2c1e3d02812e344fee8d76a851de4d51f1df90
3
+ metadata.gz: bc3c752488603fdb973882bb3e20ba9f7f41ede7
4
+ data.tar.gz: fa127620618ef5c6b0ee93ca066684d28ecbc02a
5
5
  SHA512:
6
- metadata.gz: d341a43a62f93cfdcadfbb15e3ea6a871c9e6bd616d906f7518b5b9dc77553fb429fa72f53f358ca5e83bd1e4576c6d78e19b156a5f363eda815ee3abc973d26
7
- data.tar.gz: b6f51b56c5962acb48aeaffb74fdc156cf98c876b48b0f717d49c41eca405e54f8d21cf045febebe6767c520c7e8bf9522f2c3fb497d09207bee93a18785f57f
6
+ metadata.gz: f85dc801dd5df4ea8f60b5f759806e0d935dce4bb9dfbee7133a7d6231d075b3bc98ccd99314598c2a8fe936e966604c56496b8b5446437cadb1cb4ed6890305
7
+ data.tar.gz: cb4e64ca3e72c7033ae05bc527d09ca063e3614953c5610cdbaabb70ec782bb59df1783fe96f148dcdaae798f121a79a0ecf6d1d261b0187d8c8dafbe95861eb
data/CHANGELOG.md CHANGED
@@ -1,3 +1,42 @@
1
+ ## 0.4.0
2
+ * Use React 15.x
3
+ * Added Redux Generator
4
+ * Add css/scss hot reload (css modules support)
5
+ * Fix CamelizeKeys service - accept arrays
6
+
7
+ #### migration 0.3.1 -> 0.4.0
8
+ 1. Install `style-loader` & `css-loader`:
9
+ ```
10
+ $ npm install --save style-loader css-loader
11
+ ```
12
+ 2. update webpack configuration:
13
+ 1. In your `webpack.config.js` in `loaders` section replace:
14
+ ```js
15
+ {
16
+ key: 'scss',
17
+ test: /\.scss$/,
18
+ loader: ExtractTextPlugin.extract('css!sass')
19
+ },
20
+ {
21
+ key: 'css',
22
+ test: /\.css$/,
23
+ loader: ExtractTextPlugin.extract('css!sass')
24
+ }
25
+ ```
26
+ with:
27
+ ```js
28
+ {
29
+ key: 'style',
30
+ test: /\.s?css$/,
31
+ loader: ExtractTextPlugin.extract('css!sass')
32
+ }
33
+ ```
34
+ 2. in your `webpack/hot-dev-config.js` add:
35
+ ```js
36
+ var scssLoader = config.module.loaders.filter(function(loader) { return loader.key == 'style' })[0]
37
+ scssLoader.loader = 'style!css!sass!';
38
+ ```
39
+
1
40
  ## 0.3.1
2
41
  * show depreciation warning only when integrations/react-router is used
3
42
  * throw an error when integration is missing
data/README.md CHANGED
@@ -10,7 +10,7 @@ See [0.3-stable](https://github.com/netguru/react_webpack_rails/tree/0.3-stable)
10
10
  ## Features
11
11
  * [Install Generator](https://github.com/netguru/react_webpack_rails/blob/master/docs/install_generator.md) for quick [Webpack](http://webpack.github.io/) setup.
12
12
  * Integrated [react-hot-loader](https://github.com/gaearon/react-hot-loader)
13
- * ES6/7 support with [bablejs](https://babeljs.io/).
13
+ * ES6/7 support with [babeljs](https://babeljs.io/).
14
14
  * Node.js based [server-side JavaScript execution](https://github.com/netguru/react_webpack_rails/blob/master/docs/server_side_rendering.md).
15
15
  * [React](https://facebook.github.io/react/) integration with server prerender option.
16
16
  * [React-router](https://github.com/rackt/react-router) integration.
@@ -36,19 +36,7 @@ Then run installation:
36
36
 
37
37
  $ rails g react_webpack_rails:install
38
38
 
39
- *read more about [install generator](https://github.com/netguru/react_webpack_rails/blob/master/docs/install_generator.md) here*
40
-
41
-
42
- Establish the node packages (may take a few moments)
43
-
44
- $ npm install # you may see warnings to consider updating the provided package.json file with license and repository
45
-
46
- And require integration and bundle files in `application.js`
47
-
48
- ```js
49
- //= require react_integration
50
- //= require react_bundle
51
- ```
39
+ *read more about [`install generator`](https://github.com/netguru/react_webpack_rails/blob/master/docs/install_generator.md)*
52
40
 
53
41
  ### Babel
54
42
 
data/docs/README.md CHANGED
@@ -1,14 +1,21 @@
1
1
  # Docs
2
+
2
3
  1. [Api](https://github.com/netguru/react_webpack_rails/blob/master/docs/api.md)
4
+
3
5
  1.1 [React](https://github.com/netguru/react_webpack_rails/blob/master/docs/api.md#React)
4
6
  * [js: registerComponent](https://github.com/netguru/react_webpack_rails/blob/master/docs/api.md#registercomponent)
5
7
  * [js: createComponent](https://github.com/netguru/react_webpack_rails/blob/master/docs/api.md#getcomponent)
6
8
  * [js: renderComponent](https://github.com/netguru/react_webpack_rails/blob/master/docs/api.md#rendercomponent)
7
9
  * [js: unmountComponent](https://github.com/netguru/react_webpack_rails/blob/master/docs/api.md#unmountcomponent)
8
10
  * [ruby: react_component](https://github.com/netguru/react_webpack_rails/blob/master/docs/api.md#react_component)
11
+
9
12
  1.2 [ReactRouter](https://github.com/netguru/react_webpack_rails/blob/master/docs/api.md#ReactRouter)
10
13
  * [js: getRouter](https://github.com/netguru/react_webpack_rails/blob/master/docs/api.md#getrouter)
11
14
  * [js: renderRouter](https://github.com/netguru/react_webpack_rails/blob/master/docs/api.md#renderrouter)
12
15
  * [ruby: react_router](https://github.com/netguru/react_webpack_rails/blob/master/docs/api.md#react_router)
16
+
13
17
  2. [Server-Side Rendering](https://github.com/netguru/react_webpack_rails/blob/master/docs/server_side_rendering.md)
14
- 3. [Install Generator]((https://github.com/netguru/react_webpack_rails/blob/master/docs/install_generator.md))
18
+
19
+ 3. [Install Generator](https://github.com/netguru/react_webpack_rails/blob/master/docs/install_generator.md)
20
+
21
+ 4. [Deployment](https://github.com/netguru/react_webpack_rails/blob/master/docs/deployment.md)
@@ -46,10 +46,11 @@ And modify:
46
46
  - `app/views/layouts/application.html.erb` by adding hot_reload partial.
47
47
 
48
48
  ### Options
49
- * *--no-example* - skip example generator
50
- * *--no-hot-reload* - skip hot_reload generator
51
- * *--no-server-side* - skip server_side generator
52
- * *--no-karma-setup* - skip karma_setup generator
53
- * *--react-router* - run react_rotuer generator [DEPRECIATED since v0.3.0 - use [rwr-react_router](https://github.com/netguru/rwr-react_router) instead]
49
+ * `--no-example` - skip example generator
50
+ * `--no-hot-reload` - skip hot_reload generator
51
+ * `--no-server-side` - skip server_side generator
52
+ * `--no-karma-setup` - skip karma_setup generator
53
+ * `--react-router` - run react_rotuer generator [DEPRECIATED since v0.3.0 - use [rwr-react_router](https://github.com/netguru/rwr-react_router) instead]
54
+ * `--redux` - install and setup [`rwr-redux`](https://github.com/netguru/rwr-redux) gem
54
55
 
55
56
  *Detailed description of generators coming soon...*
data/js/src/version.js CHANGED
@@ -1 +1 @@
1
- export default '0.3.1';
1
+ export default '0.4.0';
@@ -25,6 +25,15 @@ module ReactWebpackRails
25
25
  copy_file 'partial/_react_hot_assets.html.erb', 'app/views/layouts/_react_hot_assets.html.erb'
26
26
  settings = template_language_settings("render 'layouts/react_hot_assets'")
27
27
 
28
+ missing_layout_info = <<-NO_MANIFEST.strip_heredoc
29
+ Application Layout not found.
30
+
31
+ Application Layout (normally app/views/layouts/appliaction.html.erb) could not be found.
32
+ Please add in you main layout: "render 'layouts/react_hot_assets'"
33
+ NO_MANIFEST
34
+
35
+ return say_status(:not_found, missing_layout_info, :red) if settings == :no_application_layout
36
+
28
37
  inject_into_file settings[:layout_file], settings[:parsed_command], after: "#{settings[:body_tag]}\n"
29
38
  end
30
39
 
@@ -32,6 +41,7 @@ module ReactWebpackRails
32
41
 
33
42
  def template_language_settings(command)
34
43
  layout_file = Dir.glob('app/views/layouts/application.*').first
44
+ return :no_application_layout if layout_file.nil?
35
45
 
36
46
  case File.extname(layout_file)
37
47
  when '.slim'
@@ -0,0 +1,56 @@
1
+ module ReactWebpackRails
2
+ module Install
3
+ require 'generators/react_webpack_rails/merge_helpers'
4
+
5
+ class ReduxGenerator < Rails::Generators::Base
6
+ include MergeHelpers
7
+ desc 'Add redux setup'
8
+ source_root File.expand_path('../../templates', __FILE__)
9
+
10
+ REACT_INDEX_FILE = 'app/react/index.js'
11
+
12
+ class_option :tmp_package,
13
+ type: :boolean,
14
+ default: false,
15
+ desc: 'Force update tmp/package.json instead package.json'
16
+
17
+ def package
18
+ merge_options = options.tmp_package ? { package_file: 'tmp/package.json', force: true } : {}
19
+ merge_into_package 'packages/redux.json', merge_options
20
+ end
21
+
22
+ def add_import
23
+ inject_into_file REACT_INDEX_FILE, after: "import RWR from 'react-webpack-rails';\n" do
24
+ <<-'JS'.strip_heredoc
25
+ import RWRRedux from 'rwr-redux';
26
+
27
+ JS
28
+ end
29
+ end
30
+
31
+ def gsub_rwr_import
32
+ old_line = "import RWR from 'react-webpack-rails';"
33
+ new_line = "import RWR, { integrationsManager } from 'react-webpack-rails';"
34
+ gsub_file REACT_INDEX_FILE, old_line, new_line
35
+ end
36
+
37
+ def add_integration_managers
38
+ inject_into_file REACT_INDEX_FILE, after: "RWR.run();\n" do
39
+ <<-'JS'.strip_heredoc
40
+
41
+ integrationsManager.register('redux-store', RWRRedux.storeIntegrationWrapper);
42
+ integrationsManager.register('redux-container', RWRRedux.containerIntegrationWrapper);
43
+ JS
44
+ end
45
+ end
46
+
47
+ def add_rwr_redux
48
+ append_file 'Gemfile' do
49
+ <<-'RB'.strip_heredoc
50
+ gem 'rwr-redux'
51
+ RB
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -23,6 +23,10 @@ module ReactWebpackRails
23
23
  type: :boolean,
24
24
  default: false,
25
25
  desc: 'Run react_router generator'
26
+ class_option :redux,
27
+ type: :boolean,
28
+ default: false,
29
+ desc: 'Run redux generator'
26
30
 
27
31
  def generate_core
28
32
  generate 'react_webpack_rails:install:core --tmp-package'
@@ -56,6 +60,11 @@ module ReactWebpackRails
56
60
  generate 'react_webpack_rails:install:react_router --tmp_package'
57
61
  end
58
62
 
63
+ def generate_redux
64
+ return unless options.redux
65
+ generate 'react_webpack_rails:install:redux --tmp_package'
66
+ end
67
+
59
68
  def copy_package
60
69
  create_file 'package.json', File.read(Rails.root.join('tmp/package.json'))
61
70
  end
@@ -64,6 +73,15 @@ module ReactWebpackRails
64
73
  remove_file('tmp/package.json')
65
74
  end
66
75
 
76
+ def install_gems
77
+ return unless options.redux
78
+ run 'bundle install'
79
+ end
80
+
81
+ def install_packages
82
+ run 'npm install'
83
+ end
84
+
67
85
  private
68
86
 
69
87
  def deprecation_warning
@@ -12,12 +12,15 @@
12
12
  "babel-preset-es2015": "^6.3.13",
13
13
  "babel-preset-react": "^6.3.13",
14
14
  "babel-preset-stage-1": "^6.3.13",
15
+ "css-loader": "^0.23.1",
15
16
  "extract-text-webpack-plugin": "^0.8.2",
16
17
  "node-sass": "^3.3.3",
17
- "react": "^0.14.0",
18
- "react-dom": "^0.14.0",
18
+ "react": "^15.0.1",
19
+ "react-addons-test-utils": "^15.0.1",
20
+ "react-dom": "^15.0.1",
19
21
  "react-webpack-rails": "^0.3.0",
20
22
  "sass-loader": "^3.0.0",
23
+ "style-loader": "^0.13.1",
21
24
  "webpack": "^1.12.1"
22
25
  },
23
26
  "scripts": {
@@ -0,0 +1,7 @@
1
+ {
2
+ "dependencies": {
3
+ "react-redux": "^4.4.4",
4
+ "redux": "^3.4.0",
5
+ "rwr-redux": "^0.2.0"
6
+ }
7
+ }
@@ -1,5 +1,5 @@
1
- import React from 'react/addons';
2
- const TestUtils = React.addons.TestUtils;
1
+ import React from 'react';
2
+ import TestUtils from 'react-addons-test-utils';
3
3
  import expect from 'expect';
4
4
  import HelloWorld from './hello-world';
5
5
 
@@ -3,6 +3,9 @@ var config = require('./dev.config');
3
3
  var jsxLoader = config.module.loaders.filter(function(loader) { return loader.key == 'jsx' })[0]
4
4
  jsxLoader.loaders.unshift('react-hot');
5
5
 
6
+ var scssLoader = config.module.loaders.filter(function(loader) { return loader.key == 'style' })[0]
7
+ scssLoader.loader = 'style!css!sass!';
8
+
6
9
  config.output.publicPath = 'http://localhost:8080/assets/'
7
10
 
8
11
  config.entry.main.push(
@@ -17,13 +17,8 @@ module.exports = {
17
17
  loaders: ['babel']
18
18
  },
19
19
  {
20
- key: 'scss',
21
- test: /\.scss$/,
22
- loader: ExtractTextPlugin.extract('css!sass')
23
- },
24
- {
25
- key: 'css',
26
- test: /\.css$/,
20
+ key: 'style',
21
+ test: /\.s?css$/,
27
22
  loader: ExtractTextPlugin.extract('css!sass')
28
23
  }
29
24
  ]
@@ -1,11 +1,24 @@
1
1
  module ReactWebpackRails
2
2
  module Services
3
3
  class CamelizeKeys
4
- def self.call(props)
5
- return props unless props.is_a?(Hash)
6
- props.inject({}) do |h, (k, v)|
7
- h[k.to_s.camelize(:lower)] = v.is_a?(Hash) ? self.call(v) : v
8
- h
4
+ def call(data)
5
+ case data.class.name
6
+ when 'Array' then data.map { |element| call(element) }
7
+ when 'Hash' then camelize_hash(data)
8
+ else data
9
+ end
10
+ end
11
+
12
+ def self.call(data)
13
+ new.call(data)
14
+ end
15
+
16
+ private
17
+
18
+ def camelize_hash(data)
19
+ data.inject({}) do |hash, (key, value)|
20
+ hash[key.to_s.camelize(:lower)] = call(value)
21
+ hash
9
22
  end
10
23
  end
11
24
  end
@@ -1,3 +1,3 @@
1
1
  module ReactWebpackRails
2
- VERSION = '0.3.1'
2
+ VERSION = '0.4.0'
3
3
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-webpack-rails",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "Js part of react_webpack_rails - webpack based React & Rails integration.",
5
5
  "main": "js/lib/index.js",
6
6
  "files": [
@@ -28,11 +28,13 @@
28
28
  },
29
29
  "homepage": "https://github.com/netguru/react_webpack_rails#readme",
30
30
  "peerDependencies": {
31
- "react": "^0.14.0",
32
- "react-dom": "^0.14.0"
31
+ "react": "^15.0.0",
32
+ "react-dom": "^15.0.0"
33
33
  },
34
34
  "dependencies": {
35
- "babel-polyfill": "^6.3.0"
35
+ "babel-polyfill": "^6.3.0",
36
+ "react": "^15.0.1",
37
+ "react-dom": "^15.0.1"
36
38
  },
37
39
  "devDependencies": {
38
40
  "babel-cli": "^6.4.0",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: react_webpack_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rafał Gawlik
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2016-03-29 00:00:00.000000000 Z
12
+ date: 2016-04-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -112,6 +112,7 @@ files:
112
112
  - lib/generators/react_webpack_rails/install/hot_reload_generator.rb
113
113
  - lib/generators/react_webpack_rails/install/karma_setup_generator.rb
114
114
  - lib/generators/react_webpack_rails/install/react_router_generator.rb
115
+ - lib/generators/react_webpack_rails/install/redux_generator.rb
115
116
  - lib/generators/react_webpack_rails/install/server_side_generator.rb
116
117
  - lib/generators/react_webpack_rails/install_generator.rb
117
118
  - lib/generators/react_webpack_rails/merge_helpers.rb
@@ -127,6 +128,7 @@ files:
127
128
  - lib/generators/react_webpack_rails/templates/packages/hot-reload.json
128
129
  - lib/generators/react_webpack_rails/templates/packages/js-specs.json
129
130
  - lib/generators/react_webpack_rails/templates/packages/react-router.json
131
+ - lib/generators/react_webpack_rails/templates/packages/redux.json
130
132
  - lib/generators/react_webpack_rails/templates/packages/server-side.json
131
133
  - lib/generators/react_webpack_rails/templates/partial/_react_hot_assets.html.erb
132
134
  - lib/generators/react_webpack_rails/templates/react/components/hello-world-test.jsx
@@ -172,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
174
  version: '0'
173
175
  requirements: []
174
176
  rubyforge_project:
175
- rubygems_version: 2.4.8
177
+ rubygems_version: 2.4.5.1
176
178
  signing_key:
177
179
  specification_version: 4
178
180
  summary: React and Rails integration done with webpack