react_on_rails 9.0.0.beta.11 → 9.0.0.beta.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.eslintignore +2 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +5 -0
- data/.travis.yml +11 -0
- data/CHANGELOG.md +24 -9
- data/Gemfile +2 -2
- data/Gemfile.rails32 +74 -0
- data/README.md +17 -12
- data/Rakefile +8 -1
- data/app/helpers/react_on_rails_helper.rb +1 -1
- data/docs/additional-reading/asset-pipeline.md +20 -0
- data/docs/additional-reading/hot-reloading-rails-development.md +0 -75
- data/docs/additional-reading/rspec-configuration.md +6 -23
- data/{lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb.tt → docs/basics/configuration.md} +78 -41
- data/docs/basics/generator.md +0 -5
- data/docs/basics/installation-overview.md +5 -4
- data/docs/tutorial.md +25 -13
- data/lib/generators/USAGE +0 -4
- data/lib/generators/react_on_rails/base_generator.rb +41 -81
- data/lib/generators/react_on_rails/dev_tests_generator.rb +7 -5
- data/lib/generators/react_on_rails/install_generator.rb +5 -10
- data/lib/generators/react_on_rails/react_no_redux_generator.rb +10 -9
- data/lib/generators/react_on_rails/react_with_redux_generator.rb +27 -17
- data/lib/generators/react_on_rails/templates/.eslintrc +2 -0
- data/lib/generators/react_on_rails/templates/base/base/Procfile.dev +4 -0
- data/lib/generators/react_on_rails/templates/base/base/Procfile.dev-server +5 -0
- data/lib/generators/react_on_rails/templates/base/base/{client/app → app/javascript}/bundles/HelloWorld/components/HelloWorld.jsx +0 -0
- data/lib/generators/react_on_rails/templates/base/base/{client/app/bundles/HelloWorld/startup/registration.jsx.tt → app/javascript/packs/registration.js.tt} +0 -0
- data/lib/generators/react_on_rails/templates/base/base/app/views/hello_world/index.html.erb.tt +0 -1
- data/lib/generators/react_on_rails/templates/base/base/app/views/layouts/{hello_world.html.erb.tt → hello_world.html.erb} +3 -3
- data/lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb +41 -0
- data/lib/generators/react_on_rails/templates/dev_tests/.eslintrc +25 -0
- data/lib/generators/react_on_rails/templates/dev_tests/spec/rails_helper.rb +0 -1
- data/lib/generators/react_on_rails/templates/dev_tests/spec/spec_helper.rb +2 -0
- data/lib/generators/react_on_rails/templates/redux/base/{client/app/bundles/HelloWorld/actions/helloWorldActionCreators.jsx → app/javascript/bundles/HelloWorld/actions/helloWorldActionCreators.js} +0 -0
- data/lib/generators/react_on_rails/templates/redux/base/{client/app → app/javascript}/bundles/HelloWorld/components/HelloWorld.jsx +0 -0
- data/lib/generators/react_on_rails/templates/redux/base/{client/app/bundles/HelloWorld/constants/helloWorldConstants.jsx → app/javascript/bundles/HelloWorld/constants/helloWorldConstants.js} +0 -0
- data/lib/generators/react_on_rails/templates/redux/base/{client/app/bundles/HelloWorld/containers/HelloWorldContainer.jsx → app/javascript/bundles/HelloWorld/containers/HelloWorldContainer.js} +0 -0
- data/lib/generators/react_on_rails/templates/redux/base/{client/app/bundles/HelloWorld/reducers/helloWorldReducer.jsx → app/javascript/bundles/HelloWorld/reducers/helloWorldReducer.js} +0 -0
- data/lib/generators/react_on_rails/templates/redux/base/{client/app → app/javascript}/bundles/HelloWorld/startup/HelloWorldApp.jsx +0 -0
- data/lib/generators/react_on_rails/templates/redux/base/{client/app/bundles/HelloWorld/store/helloWorldStore.jsx → app/javascript/bundles/HelloWorld/store/helloWorldStore.js} +0 -0
- data/lib/react_on_rails/configuration.rb +15 -10
- data/lib/react_on_rails/server_rendering_pool/exec.rb +21 -8
- data/lib/react_on_rails/test_helper.rb +6 -6
- data/lib/react_on_rails/test_helper/ensure_assets_compiled.rb +1 -1
- data/lib/react_on_rails/test_helper/webpack_assets_compiler.rb +3 -1
- data/lib/react_on_rails/test_helper/webpack_assets_status_checker.rb +10 -6
- data/lib/react_on_rails/utils.rb +34 -3
- data/lib/react_on_rails/version.rb +1 -1
- data/lib/react_on_rails/version_checker.rb +1 -1
- data/lib/tasks/assets.rake +10 -2
- data/package.json +6 -2
- data/rakelib/dummy_apps.rake +9 -0
- data/rakelib/example_type.rb +8 -19
- data/rakelib/examples.rake +3 -5
- data/rakelib/run_rspec.rake +17 -0
- data/yarn.lock +29 -0
- metadata +19 -23
- data/lib/generators/react_on_rails/node_generator.rb +0 -24
- data/lib/generators/react_on_rails/templates/base/base/Procfile.dev.tt +0 -4
- data/lib/generators/react_on_rails/templates/base/base/client/.babelrc +0 -3
- data/lib/generators/react_on_rails/templates/base/base/client/REACT_ON_RAILS_CLIENT_README.md +0 -9
- data/lib/generators/react_on_rails/templates/base/base/client/package.json.tt +0 -36
- data/lib/generators/react_on_rails/templates/base/base/client/webpack.config.js +0 -78
- data/lib/generators/react_on_rails/templates/base/base/config/webpacker.yml +0 -28
- data/lib/generators/react_on_rails/templates/base/base/package.json.tt +0 -8
- data/lib/generators/react_on_rails/templates/node/base/client/node/package.json +0 -10
- data/lib/generators/react_on_rails/templates/node/base/client/node/server.js +0 -105
@@ -1,24 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "rails/generators"
|
4
|
-
|
5
|
-
module ReactOnRails
|
6
|
-
module Generators
|
7
|
-
class NodeGenerator < Rails::Generators::Base
|
8
|
-
Rails::Generators.hide_namespace(namespace)
|
9
|
-
source_root(File.expand_path("../templates", __FILE__))
|
10
|
-
|
11
|
-
def create_node_directory
|
12
|
-
empty_directory("client/node")
|
13
|
-
end
|
14
|
-
|
15
|
-
def copy_base_redux_files
|
16
|
-
base_path = "node/base/"
|
17
|
-
%w[client/node/server.js
|
18
|
-
client/node/package.json].each do |file|
|
19
|
-
copy_file(base_path + file, file)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
data/lib/generators/react_on_rails/templates/base/base/client/REACT_ON_RAILS_CLIENT_README.md
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
Client folder generated by the React on Rails gem.
|
2
|
-
|
3
|
-
See documentation [at github.com/shakacode/react_on_rails](https://github.com/shakacode/react_on_rails) for details on how it is organized.
|
4
|
-
|
5
|
-
If you need additional help, please consider:
|
6
|
-
|
7
|
-
* [Our ShakaCode Forum for React on Rails](https://forum.shakacode.com/c/rails/reactonrails).
|
8
|
-
* Joining our Slack discussion room by [emailing us a bit about you and your project](mailto:contact@shakacode.com).
|
9
|
-
* [Hiring us](https://forum.shakacode.com/c/rails/reactonrails) for coaching and custom web application development for your project.
|
@@ -1,36 +0,0 @@
|
|
1
|
-
<%- require "react_on_rails/version_syntax_converter" -%>
|
2
|
-
{
|
3
|
-
"name": "<%= app_name %>",
|
4
|
-
"private": true,
|
5
|
-
"scripts": {
|
6
|
-
"build:test": "NODE_ENV=test webpack --config webpack.config.js",
|
7
|
-
"build:production": "NODE_ENV=production webpack -p --config webpack.config.js",
|
8
|
-
"build:development": "NODE_ENV=development webpack -w --config webpack.config.js"
|
9
|
-
},
|
10
|
-
"cacheDirectories": ["node_modules", "client/node_modules"],
|
11
|
-
"dependencies": {
|
12
|
-
"babel-cli": "^6.24.1",
|
13
|
-
"babel-core": "^6.25.0",
|
14
|
-
"babel-loader": "^7.1.1",
|
15
|
-
"babel-runtime": "^6.25.0",
|
16
|
-
"babel-polyfill": "^6.23.0",
|
17
|
-
"babel-preset-es2015": "^6.24.1",
|
18
|
-
"babel-preset-react": "^6.24.1",
|
19
|
-
"babel-preset-stage-2": "^6.24.1",
|
20
|
-
"es5-shim": "^4.5.9",
|
21
|
-
"expose-loader": "^0.7.3",
|
22
|
-
"imports-loader": "^0.7.1",
|
23
|
-
"js-yaml": "^3.9.1",
|
24
|
-
"react": "^15.6.1",
|
25
|
-
"react-dom": "^15.6.1",
|
26
|
-
"react-on-rails": "<%= VersionSyntaxConverter.new.rubygem_to_npm %>",
|
27
|
-
<%- if options.redux? -%>
|
28
|
-
"react-redux": "^5.0.5",
|
29
|
-
"redux": "^3.7.2",
|
30
|
-
<%- end -%>
|
31
|
-
"webpack": "^3.4.1",
|
32
|
-
"webpack-manifest-plugin": "^1.2.1"
|
33
|
-
},
|
34
|
-
"devDependencies": {
|
35
|
-
}
|
36
|
-
}
|
@@ -1,78 +0,0 @@
|
|
1
|
-
// For inspiration on your webpack configuration, see:
|
2
|
-
// https://github.com/shakacode/react_on_rails/tree/master/spec/dummy/client
|
3
|
-
// https://github.com/shakacode/react-webpack-rails-tutorial/tree/master/client
|
4
|
-
|
5
|
-
const webpack = require('webpack');
|
6
|
-
const { resolve } = require('path');
|
7
|
-
|
8
|
-
const ManifestPlugin = require('webpack-manifest-plugin');
|
9
|
-
const webpackConfigLoader = require('react-on-rails/webpackConfigLoader');
|
10
|
-
|
11
|
-
const configPath = resolve('..', 'config');
|
12
|
-
const { devBuild, output } = webpackConfigLoader(configPath);
|
13
|
-
|
14
|
-
const config = {
|
15
|
-
|
16
|
-
context: resolve(__dirname),
|
17
|
-
|
18
|
-
entry: {
|
19
|
-
'hello-world-bundle': [
|
20
|
-
'es5-shim/es5-shim',
|
21
|
-
'es5-shim/es5-sham',
|
22
|
-
'babel-polyfill',
|
23
|
-
'./app/bundles/HelloWorld/startup/registration',
|
24
|
-
],
|
25
|
-
},
|
26
|
-
|
27
|
-
output: {
|
28
|
-
// Name comes from the entry section.
|
29
|
-
filename: '[name]-[chunkhash].js',
|
30
|
-
|
31
|
-
// Leading slash is necessary
|
32
|
-
publicPath: `/${output.publicPath}`,
|
33
|
-
path: output.path,
|
34
|
-
},
|
35
|
-
|
36
|
-
resolve: {
|
37
|
-
extensions: ['.js', '.jsx'],
|
38
|
-
},
|
39
|
-
|
40
|
-
plugins: [
|
41
|
-
new webpack.EnvironmentPlugin({
|
42
|
-
NODE_ENV: 'development', // use 'development' unless process.env.NODE_ENV is defined
|
43
|
-
DEBUG: false,
|
44
|
-
}),
|
45
|
-
new ManifestPlugin({
|
46
|
-
publicPath: output.publicPath,
|
47
|
-
writeToFileEmit: true }),
|
48
|
-
],
|
49
|
-
|
50
|
-
module: {
|
51
|
-
rules: [
|
52
|
-
{
|
53
|
-
test: require.resolve('react'),
|
54
|
-
use: {
|
55
|
-
loader: 'imports-loader',
|
56
|
-
options: {
|
57
|
-
shim: 'es5-shim/es5-shim',
|
58
|
-
sham: 'es5-shim/es5-sham',
|
59
|
-
},
|
60
|
-
},
|
61
|
-
},
|
62
|
-
{
|
63
|
-
test: /\.jsx?$/,
|
64
|
-
use: 'babel-loader',
|
65
|
-
exclude: /node_modules/,
|
66
|
-
},
|
67
|
-
],
|
68
|
-
},
|
69
|
-
};
|
70
|
-
|
71
|
-
module.exports = config;
|
72
|
-
|
73
|
-
if (devBuild) {
|
74
|
-
console.log('Webpack dev build for Rails'); // eslint-disable-line no-console
|
75
|
-
module.exports.devtool = 'eval-source-map';
|
76
|
-
} else {
|
77
|
-
console.log('Webpack production build for Rails'); // eslint-disable-line no-console
|
78
|
-
}
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# Note: Base output directory of /public is assumed for static files
|
2
|
-
default: &default
|
3
|
-
# Critical to set compile as false for React on Rails projects
|
4
|
-
compile: false
|
5
|
-
custom_compile: true
|
6
|
-
# Cache manifest.json for performance
|
7
|
-
cache_manifest: false
|
8
|
-
|
9
|
-
development:
|
10
|
-
<<: *default
|
11
|
-
# generated files for development, in /public/webpack/development
|
12
|
-
public_output_path: webpack/development
|
13
|
-
|
14
|
-
dev_server:
|
15
|
-
host: localhost
|
16
|
-
port: 3035
|
17
|
-
hmr: true
|
18
|
-
|
19
|
-
test:
|
20
|
-
<<: *default
|
21
|
-
# generated files for test, in /public/webpack/test
|
22
|
-
public_output_path: webpack/test
|
23
|
-
|
24
|
-
production:
|
25
|
-
<<: *default
|
26
|
-
# generated files for production, in /public/webpack/production
|
27
|
-
public_output_path: webpack/production
|
28
|
-
cache_manifest: true
|
@@ -1,105 +0,0 @@
|
|
1
|
-
const net = require('net');
|
2
|
-
const fs = require('fs');
|
3
|
-
|
4
|
-
const bundlePath = '../../app/assets/webpack/';
|
5
|
-
let bundleFileName = 'server-bundle.js';
|
6
|
-
|
7
|
-
let currentArg;
|
8
|
-
|
9
|
-
class Handler {
|
10
|
-
constructor() {
|
11
|
-
this.queue = [];
|
12
|
-
this.initialized = false;
|
13
|
-
}
|
14
|
-
|
15
|
-
initialize() {
|
16
|
-
console.log(`Processing ${this.queue.length} pending requests`);
|
17
|
-
let callback;
|
18
|
-
|
19
|
-
// eslint-disable-next-line no-cond-assign
|
20
|
-
while (callback = this.queue.pop()) {
|
21
|
-
callback();
|
22
|
-
}
|
23
|
-
|
24
|
-
this.initialized = true;
|
25
|
-
}
|
26
|
-
|
27
|
-
handle(connection) {
|
28
|
-
const callback = () => {
|
29
|
-
const terminator = '\r\n\0';
|
30
|
-
let request = '';
|
31
|
-
connection.setEncoding('utf8');
|
32
|
-
connection.on('data', (data) => {
|
33
|
-
console.log(`Processing chunk: ${data}`);
|
34
|
-
request += data;
|
35
|
-
if (data.slice(-terminator.length) === terminator) {
|
36
|
-
request = request.slice(0, -terminator.length);
|
37
|
-
|
38
|
-
// eslint-disable-next-line no-eval
|
39
|
-
const response = eval(request);
|
40
|
-
connection.write(`${response}${terminator}`);
|
41
|
-
request = '';
|
42
|
-
}
|
43
|
-
});
|
44
|
-
};
|
45
|
-
|
46
|
-
if (this.initialized) {
|
47
|
-
callback();
|
48
|
-
} else {
|
49
|
-
this.queue.push(callback);
|
50
|
-
}
|
51
|
-
}
|
52
|
-
}
|
53
|
-
|
54
|
-
const handler = new Handler();
|
55
|
-
|
56
|
-
process.argv.forEach((val) => {
|
57
|
-
if (val[0] === '-') {
|
58
|
-
currentArg = val.slice(1);
|
59
|
-
return;
|
60
|
-
}
|
61
|
-
|
62
|
-
if (currentArg === 's') {
|
63
|
-
bundleFileName = val;
|
64
|
-
}
|
65
|
-
});
|
66
|
-
|
67
|
-
function loadBundle() {
|
68
|
-
if (handler.initialized) {
|
69
|
-
console.log('Reloading server bundle must be implemented by restarting the node process!');
|
70
|
-
return;
|
71
|
-
}
|
72
|
-
|
73
|
-
/* eslint-disable */
|
74
|
-
require(bundlePath + bundleFileName);
|
75
|
-
/* eslint-enable */
|
76
|
-
console.log(`Loaded server bundle: ${bundlePath}${bundleFileName}`);
|
77
|
-
handler.initialize();
|
78
|
-
}
|
79
|
-
|
80
|
-
try {
|
81
|
-
fs.mkdirSync(bundlePath);
|
82
|
-
} catch (e) {
|
83
|
-
if (e.code !== 'EEXIST') {
|
84
|
-
throw e;
|
85
|
-
} else {
|
86
|
-
loadBundle();
|
87
|
-
}
|
88
|
-
}
|
89
|
-
|
90
|
-
fs.watchFile(bundlePath + bundleFileName, (curr) => {
|
91
|
-
if (curr && curr.blocks && curr.blocks > 0) {
|
92
|
-
loadBundle();
|
93
|
-
}
|
94
|
-
});
|
95
|
-
|
96
|
-
const unixServer = net.createServer((connection) => {
|
97
|
-
handler.handle(connection);
|
98
|
-
});
|
99
|
-
|
100
|
-
unixServer.listen('node.sock');
|
101
|
-
|
102
|
-
process.on('SIGINT', () => {
|
103
|
-
unixServer.close();
|
104
|
-
process.exit();
|
105
|
-
});
|