From 956151edc7ac5635c10be2f1ede583403d650b55 Mon Sep 17 00:00:00 2001 From: Josias Schneider Date: Sun, 6 Dec 2015 20:25:53 -0200 Subject: [PATCH 1/2] Update react_on_rails to 1.1.1 Create `/bundles/Comments` folder structure Update webpack config files to reflect the change --- Gemfile.lock | 12 +++++++----- .../Comments}/actions/commentsActionCreators.js | 0 .../{ => bundles/Comments}/components/Comment.jsx | 0 .../{ => bundles/Comments}/components/CommentBox.jsx | 0 .../Comments}/components/CommentForm.jsx | 0 .../Comments}/components/CommentList.jsx | 0 .../Comments}/components/CommentScreen.jsx | 0 .../Comments}/components/NonRouterCommentScreen.jsx | 0 .../Comments}/components/RouterCommentScreen.jsx | 0 .../Comments}/components/SimpleCommentScreen.jsx | 0 .../Comments}/components/TestReactRouter.jsx | 0 .../Comments}/components/TestReactRouterRedirect.jsx | 0 .../Comments}/constants/commentsConstants.js | 0 client/app/{ => bundles/Comments}/layout/Layout.jsx | 0 .../Comments}/reducers/commentsReducer.js | 0 client/app/{ => bundles/Comments}/reducers/index.js | 0 client/app/{ => bundles/Comments}/routes/routes.jsx | 0 .../app/{ => bundles/Comments}/startup/ClientApp.jsx | 0 .../Comments}/startup/ClientRouterApp.jsx | 0 .../app/{ => bundles/Comments}/startup/ServerApp.jsx | 0 .../Comments}/startup/ServerRouterApp.jsx | 0 .../{ => bundles/Comments}/startup/clientGlobals.jsx | 0 .../{ => bundles/Comments}/startup/serverGlobals.jsx | 0 .../{ => bundles/Comments}/stores/commentsStore.js | 2 +- .../{ => bundles/Comments}/utils/commentsManager.js | 0 .../{ => bundles/Comments}/utils/metaTagsManager.js | 0 client/app/{ => lib}/middlewares/loggerMiddleware.js | 0 client/webpack.client.base.config.js | 8 +++++++- client/webpack.client.hot.config.js | 5 +---- client/webpack.client.rails.config.js | 1 - client/webpack.server.rails.config.js | 6 +++++- 31 files changed, 21 insertions(+), 13 deletions(-) rename client/app/{ => bundles/Comments}/actions/commentsActionCreators.js (100%) rename client/app/{ => bundles/Comments}/components/Comment.jsx (100%) rename client/app/{ => bundles/Comments}/components/CommentBox.jsx (100%) rename client/app/{ => bundles/Comments}/components/CommentForm.jsx (100%) rename client/app/{ => bundles/Comments}/components/CommentList.jsx (100%) rename client/app/{ => bundles/Comments}/components/CommentScreen.jsx (100%) rename client/app/{ => bundles/Comments}/components/NonRouterCommentScreen.jsx (100%) rename client/app/{ => bundles/Comments}/components/RouterCommentScreen.jsx (100%) rename client/app/{ => bundles/Comments}/components/SimpleCommentScreen.jsx (100%) rename client/app/{ => bundles/Comments}/components/TestReactRouter.jsx (100%) rename client/app/{ => bundles/Comments}/components/TestReactRouterRedirect.jsx (100%) rename client/app/{ => bundles/Comments}/constants/commentsConstants.js (100%) rename client/app/{ => bundles/Comments}/layout/Layout.jsx (100%) rename client/app/{ => bundles/Comments}/reducers/commentsReducer.js (100%) rename client/app/{ => bundles/Comments}/reducers/index.js (100%) rename client/app/{ => bundles/Comments}/routes/routes.jsx (100%) rename client/app/{ => bundles/Comments}/startup/ClientApp.jsx (100%) rename client/app/{ => bundles/Comments}/startup/ClientRouterApp.jsx (100%) rename client/app/{ => bundles/Comments}/startup/ServerApp.jsx (100%) rename client/app/{ => bundles/Comments}/startup/ServerRouterApp.jsx (100%) rename client/app/{ => bundles/Comments}/startup/clientGlobals.jsx (100%) rename client/app/{ => bundles/Comments}/startup/serverGlobals.jsx (100%) rename client/app/{ => bundles/Comments}/stores/commentsStore.js (92%) rename client/app/{ => bundles/Comments}/utils/commentsManager.js (100%) rename client/app/{ => bundles/Comments}/utils/metaTagsManager.js (100%) rename client/app/{ => lib}/middlewares/loggerMiddleware.js (100%) diff --git a/Gemfile.lock b/Gemfile.lock index f81f6640..99870124 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -91,6 +91,7 @@ GEM coffee-script-source execjs coffee-script-source (1.10.0) + concurrent-ruby (1.0.0) connection_pool (2.2.0) coveralls (0.8.9) json (~> 1.8) @@ -139,12 +140,12 @@ GEM mime-types (>= 1.16, < 3) method_source (0.8.2) mime-types (2.99) - mini_portile (0.6.2) + mini_portile2 (2.0.0) minitest (5.8.3) multi_json (1.11.2) netrc (0.11.0) - nokogiri (1.6.6.4) - mini_portile (~> 0.6.0) + nokogiri (1.6.7) + mini_portile2 (~> 2.0.0.rc2) parser (2.2.3.0) ast (>= 1.1, < 3.0) pg (0.18.4) @@ -203,7 +204,7 @@ GEM rainbow (2.0.0) rake (10.4.2) rdoc (4.2.0) - react_on_rails (1.1.0) + react_on_rails (1.1.1) connection_pool execjs (~> 2.5) rails (>= 3.2) @@ -278,7 +279,8 @@ GEM spring (1.4.4) spring-commands-rspec (1.0.4) spring (>= 0.9.1) - sprockets (3.4.1) + sprockets (3.5.1) + concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-rails (2.3.3) actionpack (>= 3.0) diff --git a/client/app/actions/commentsActionCreators.js b/client/app/bundles/Comments/actions/commentsActionCreators.js similarity index 100% rename from client/app/actions/commentsActionCreators.js rename to client/app/bundles/Comments/actions/commentsActionCreators.js diff --git a/client/app/components/Comment.jsx b/client/app/bundles/Comments/components/Comment.jsx similarity index 100% rename from client/app/components/Comment.jsx rename to client/app/bundles/Comments/components/Comment.jsx diff --git a/client/app/components/CommentBox.jsx b/client/app/bundles/Comments/components/CommentBox.jsx similarity index 100% rename from client/app/components/CommentBox.jsx rename to client/app/bundles/Comments/components/CommentBox.jsx diff --git a/client/app/components/CommentForm.jsx b/client/app/bundles/Comments/components/CommentForm.jsx similarity index 100% rename from client/app/components/CommentForm.jsx rename to client/app/bundles/Comments/components/CommentForm.jsx diff --git a/client/app/components/CommentList.jsx b/client/app/bundles/Comments/components/CommentList.jsx similarity index 100% rename from client/app/components/CommentList.jsx rename to client/app/bundles/Comments/components/CommentList.jsx diff --git a/client/app/components/CommentScreen.jsx b/client/app/bundles/Comments/components/CommentScreen.jsx similarity index 100% rename from client/app/components/CommentScreen.jsx rename to client/app/bundles/Comments/components/CommentScreen.jsx diff --git a/client/app/components/NonRouterCommentScreen.jsx b/client/app/bundles/Comments/components/NonRouterCommentScreen.jsx similarity index 100% rename from client/app/components/NonRouterCommentScreen.jsx rename to client/app/bundles/Comments/components/NonRouterCommentScreen.jsx diff --git a/client/app/components/RouterCommentScreen.jsx b/client/app/bundles/Comments/components/RouterCommentScreen.jsx similarity index 100% rename from client/app/components/RouterCommentScreen.jsx rename to client/app/bundles/Comments/components/RouterCommentScreen.jsx diff --git a/client/app/components/SimpleCommentScreen.jsx b/client/app/bundles/Comments/components/SimpleCommentScreen.jsx similarity index 100% rename from client/app/components/SimpleCommentScreen.jsx rename to client/app/bundles/Comments/components/SimpleCommentScreen.jsx diff --git a/client/app/components/TestReactRouter.jsx b/client/app/bundles/Comments/components/TestReactRouter.jsx similarity index 100% rename from client/app/components/TestReactRouter.jsx rename to client/app/bundles/Comments/components/TestReactRouter.jsx diff --git a/client/app/components/TestReactRouterRedirect.jsx b/client/app/bundles/Comments/components/TestReactRouterRedirect.jsx similarity index 100% rename from client/app/components/TestReactRouterRedirect.jsx rename to client/app/bundles/Comments/components/TestReactRouterRedirect.jsx diff --git a/client/app/constants/commentsConstants.js b/client/app/bundles/Comments/constants/commentsConstants.js similarity index 100% rename from client/app/constants/commentsConstants.js rename to client/app/bundles/Comments/constants/commentsConstants.js diff --git a/client/app/layout/Layout.jsx b/client/app/bundles/Comments/layout/Layout.jsx similarity index 100% rename from client/app/layout/Layout.jsx rename to client/app/bundles/Comments/layout/Layout.jsx diff --git a/client/app/reducers/commentsReducer.js b/client/app/bundles/Comments/reducers/commentsReducer.js similarity index 100% rename from client/app/reducers/commentsReducer.js rename to client/app/bundles/Comments/reducers/commentsReducer.js diff --git a/client/app/reducers/index.js b/client/app/bundles/Comments/reducers/index.js similarity index 100% rename from client/app/reducers/index.js rename to client/app/bundles/Comments/reducers/index.js diff --git a/client/app/routes/routes.jsx b/client/app/bundles/Comments/routes/routes.jsx similarity index 100% rename from client/app/routes/routes.jsx rename to client/app/bundles/Comments/routes/routes.jsx diff --git a/client/app/startup/ClientApp.jsx b/client/app/bundles/Comments/startup/ClientApp.jsx similarity index 100% rename from client/app/startup/ClientApp.jsx rename to client/app/bundles/Comments/startup/ClientApp.jsx diff --git a/client/app/startup/ClientRouterApp.jsx b/client/app/bundles/Comments/startup/ClientRouterApp.jsx similarity index 100% rename from client/app/startup/ClientRouterApp.jsx rename to client/app/bundles/Comments/startup/ClientRouterApp.jsx diff --git a/client/app/startup/ServerApp.jsx b/client/app/bundles/Comments/startup/ServerApp.jsx similarity index 100% rename from client/app/startup/ServerApp.jsx rename to client/app/bundles/Comments/startup/ServerApp.jsx diff --git a/client/app/startup/ServerRouterApp.jsx b/client/app/bundles/Comments/startup/ServerRouterApp.jsx similarity index 100% rename from client/app/startup/ServerRouterApp.jsx rename to client/app/bundles/Comments/startup/ServerRouterApp.jsx diff --git a/client/app/startup/clientGlobals.jsx b/client/app/bundles/Comments/startup/clientGlobals.jsx similarity index 100% rename from client/app/startup/clientGlobals.jsx rename to client/app/bundles/Comments/startup/clientGlobals.jsx diff --git a/client/app/startup/serverGlobals.jsx b/client/app/bundles/Comments/startup/serverGlobals.jsx similarity index 100% rename from client/app/startup/serverGlobals.jsx rename to client/app/bundles/Comments/startup/serverGlobals.jsx diff --git a/client/app/stores/commentsStore.js b/client/app/bundles/Comments/stores/commentsStore.js similarity index 92% rename from client/app/stores/commentsStore.js rename to client/app/bundles/Comments/stores/commentsStore.js index dd221d3f..d6865a4a 100644 --- a/client/app/stores/commentsStore.js +++ b/client/app/bundles/Comments/stores/commentsStore.js @@ -3,7 +3,7 @@ import { compose, createStore, applyMiddleware, combineReducers } from 'redux'; import thunkMiddleware from 'redux-thunk'; -import loggerMiddleware from '../middlewares/loggerMiddleware'; +import loggerMiddleware from 'lib/middlewares/loggerMiddleware'; import reducers from '../reducers'; import { initalStates } from '../reducers'; diff --git a/client/app/utils/commentsManager.js b/client/app/bundles/Comments/utils/commentsManager.js similarity index 100% rename from client/app/utils/commentsManager.js rename to client/app/bundles/Comments/utils/commentsManager.js diff --git a/client/app/utils/metaTagsManager.js b/client/app/bundles/Comments/utils/metaTagsManager.js similarity index 100% rename from client/app/utils/metaTagsManager.js rename to client/app/bundles/Comments/utils/metaTagsManager.js diff --git a/client/app/middlewares/loggerMiddleware.js b/client/app/lib/middlewares/loggerMiddleware.js similarity index 100% rename from client/app/middlewares/loggerMiddleware.js rename to client/app/lib/middlewares/loggerMiddleware.js diff --git a/client/webpack.client.base.config.js b/client/webpack.client.base.config.js index 38f278fd..578b135c 100644 --- a/client/webpack.client.base.config.js +++ b/client/webpack.client.base.config.js @@ -1,6 +1,7 @@ // Common client-side webpack configuration used by webpack.hot.config and webpack.rails.config. const webpack = require('webpack'); +const path = require('path'); const devBuild = process.env.NODE_ENV !== 'production'; const nodeEnv = devBuild ? 'development' : 'production'; @@ -21,10 +22,15 @@ module.exports = { ], // This will contain the app entry points defined by webpack.hot.config and webpack.rails.config - app: [], + app: [ + './app/bundles/Comments/startup/clientGlobals', + ], }, resolve: { extensions: ['', '.webpack.js', '.web.js', '.js', '.jsx', '.scss', '.css', 'config.js'], + alias: { + lib: path.join(process.cwd(), 'app', 'lib'), + }, }, plugins: [ new webpack.DefinePlugin({ diff --git a/client/webpack.client.hot.config.js b/client/webpack.client.hot.config.js index 06c27f41..82329186 100644 --- a/client/webpack.client.hot.config.js +++ b/client/webpack.client.hot.config.js @@ -16,10 +16,7 @@ config.entry.app.push( // Test out Css & Sass './assets/stylesheets/test-stylesheet.css', - './assets/stylesheets/test-sass-stylesheet.scss', - - // App entry point - './app/startup/clientGlobals' + './assets/stylesheets/test-sass-stylesheet.scss' ); config.output = { diff --git a/client/webpack.client.rails.config.js b/client/webpack.client.rails.config.js index c07d59cf..d55f5906 100644 --- a/client/webpack.client.rails.config.js +++ b/client/webpack.client.rails.config.js @@ -19,7 +19,6 @@ config.entry.vendor.unshift( 'es5-shim/es5-shim', 'es5-shim/es5-sham' ); -config.entry.app.push('./app/startup/clientGlobals'); // See webpack.common.config for adding modules common to both the webpack dev server and rails diff --git a/client/webpack.server.rails.config.js b/client/webpack.server.rails.config.js index df111d3c..382e2a32 100644 --- a/client/webpack.server.rails.config.js +++ b/client/webpack.server.rails.config.js @@ -1,6 +1,7 @@ // Common webpack configuration for server bundle const webpack = require('webpack'); +const path = require('path'); const devBuild = process.env.NODE_ENV !== 'production'; const nodeEnv = devBuild ? 'development' : 'production'; @@ -9,13 +10,16 @@ module.exports = { // the project dir context: __dirname, - entry: ['./app/startup/serverGlobals', 'react-dom/server', 'react'], + entry: ['./app/bundles/Comments/startup/serverGlobals', 'react-dom/server', 'react'], output: { filename: 'server-bundle.js', path: '../app/assets/javascripts/generated', }, resolve: { extensions: ['', '.webpack.js', '.web.js', '.js', '.jsx', 'config.js'], + alias: { + lib: path.join(process.cwd(), 'app', 'lib'), + }, }, plugins: [ new webpack.DefinePlugin({ From d17119abc6c6763dee9ff24f719ed7ab5834441b Mon Sep 17 00:00:00 2001 From: Josias Schneider Date: Sun, 6 Dec 2015 20:34:52 -0200 Subject: [PATCH 2/2] Rename stores folder to store Rename stores folder to store Fix components path in specs Fix `getDOMNode` warning on `CommentForm.jsx` --- client/app/bundles/Comments/components/CommentForm.jsx | 4 ++-- client/app/bundles/Comments/startup/ClientApp.jsx | 2 +- client/app/bundles/Comments/startup/ClientRouterApp.jsx | 2 +- client/app/bundles/Comments/startup/ServerApp.jsx | 2 +- client/app/bundles/Comments/startup/ServerRouterApp.jsx | 2 +- .../app/bundles/Comments/{stores => store}/commentsStore.js | 0 client/test/components/CommentList_spec.jsx | 4 ++-- client/test/components/Comment_spec.jsx | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) rename client/app/bundles/Comments/{stores => store}/commentsStore.js (100%) diff --git a/client/app/bundles/Comments/components/CommentForm.jsx b/client/app/bundles/Comments/components/CommentForm.jsx index c1b31bc1..fccdf60c 100644 --- a/client/app/bundles/Comments/components/CommentForm.jsx +++ b/client/app/bundles/Comments/components/CommentForm.jsx @@ -46,8 +46,8 @@ class CommentForm extends React.Component { comment = { // This is different because the input is a native HTML element // rather than a React element. - author: this.refs.inlineAuthor.getDOMNode().value, - text: this.refs.inlineText.getDOMNode().value, + author: this.refs.inlineAuthor.value, + text: this.refs.inlineText.value, }; } diff --git a/client/app/bundles/Comments/startup/ClientApp.jsx b/client/app/bundles/Comments/startup/ClientApp.jsx index 1578db30..822b0dc6 100644 --- a/client/app/bundles/Comments/startup/ClientApp.jsx +++ b/client/app/bundles/Comments/startup/ClientApp.jsx @@ -1,7 +1,7 @@ import React from 'react'; import { Provider } from 'react-redux'; -import createStore from '../stores/commentsStore'; +import createStore from '../store/commentsStore'; import NonRouterCommentScreen from '../components/NonRouterCommentScreen'; const App = props => { diff --git a/client/app/bundles/Comments/startup/ClientRouterApp.jsx b/client/app/bundles/Comments/startup/ClientRouterApp.jsx index 61dc7fe8..f31baf22 100644 --- a/client/app/bundles/Comments/startup/ClientRouterApp.jsx +++ b/client/app/bundles/Comments/startup/ClientRouterApp.jsx @@ -3,7 +3,7 @@ import { Provider } from 'react-redux'; import Router from 'react-router'; import createHistory from 'history/lib/createBrowserHistory'; -import createStore from '../stores/commentsStore'; +import createStore from '../store/commentsStore'; import routes from '../routes/routes'; const RouterApp = (props, location) => { diff --git a/client/app/bundles/Comments/startup/ServerApp.jsx b/client/app/bundles/Comments/startup/ServerApp.jsx index d1a07339..38664e8b 100644 --- a/client/app/bundles/Comments/startup/ServerApp.jsx +++ b/client/app/bundles/Comments/startup/ServerApp.jsx @@ -1,7 +1,7 @@ import React from 'react'; import { Provider } from 'react-redux'; -import createStore from '../stores/commentsStore'; +import createStore from '../store/commentsStore'; import NonRouterCommentScreen from '../components/NonRouterCommentScreen'; const App = props => { diff --git a/client/app/bundles/Comments/startup/ServerRouterApp.jsx b/client/app/bundles/Comments/startup/ServerRouterApp.jsx index 86e6939c..f89e4dcc 100644 --- a/client/app/bundles/Comments/startup/ServerRouterApp.jsx +++ b/client/app/bundles/Comments/startup/ServerRouterApp.jsx @@ -2,7 +2,7 @@ import React from 'react'; import { Provider } from 'react-redux'; import { match, RoutingContext } from 'react-router'; -import createStore from '../stores/commentsStore'; +import createStore from '../store/commentsStore'; import routes from '../routes/routes'; const RouterApp = (props, location) => { diff --git a/client/app/bundles/Comments/stores/commentsStore.js b/client/app/bundles/Comments/store/commentsStore.js similarity index 100% rename from client/app/bundles/Comments/stores/commentsStore.js rename to client/app/bundles/Comments/store/commentsStore.js diff --git a/client/test/components/CommentList_spec.jsx b/client/test/components/CommentList_spec.jsx index 376a90ec..82c0bd7c 100644 --- a/client/test/components/CommentList_spec.jsx +++ b/client/test/components/CommentList_spec.jsx @@ -1,7 +1,7 @@ import { React, expect, TestUtils } from '../test_helper'; import { List, Map } from 'immutable'; -import CommentList from '../../app/components/CommentList'; -import Comment from '../../app/components/Comment'; +import CommentList from '../../app/bundles/Comments/components/CommentList'; +import Comment from '../../app/bundles/Comments/components/Comment'; const { renderIntoDocument, diff --git a/client/test/components/Comment_spec.jsx b/client/test/components/Comment_spec.jsx index f36accbb..5efb21e4 100644 --- a/client/test/components/Comment_spec.jsx +++ b/client/test/components/Comment_spec.jsx @@ -1,5 +1,5 @@ import { React, expect, TestUtils } from '../test_helper'; -import Comment from '../../app/components/Comment'; +import Comment from '../../app/bundles/Comments/components/Comment'; const { renderIntoDocument,