react_on_rails 4.0.0.beta.1 → 4.0.0.beta.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.eslintignore +1 -0
- data/.gitignore +2 -1
- data/.jscsrc +1 -0
- data/.rubocop.yml +3 -0
- data/.travis.yml +1 -1
- data/CHANGELOG.md +12 -4
- data/Gemfile +0 -5
- data/README.md +10 -3
- data/Rakefile +3 -0
- data/app/helpers/react_on_rails_helper.rb +21 -18
- data/docs/additional_reading/manual_installation.md +2 -2
- data/docs/additional_reading/optional_configuration.md +1 -1
- data/docs/additional_reading/rspec_configuration.md +3 -1
- data/docs/additional_reading/turbolinks.md +4 -3
- data/docs/contributing.md +1 -1
- data/docs/tutorial-v2.md +1 -1
- data/lib/generators/react_on_rails/base_generator.rb +20 -16
- data/lib/generators/react_on_rails/bootstrap_generator.rb +1 -1
- data/lib/generators/react_on_rails/templates/base/base/Procfile.dev-hot.tt +1 -1
- data/lib/generators/react_on_rails/templates/base/base/Procfile.dev.tt +1 -1
- data/lib/generators/react_on_rails/templates/base/base/client/webpack.client.rails.config.js +1 -1
- data/lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb.tt +11 -1
- data/lib/generators/react_on_rails/templates/base/base/lib/tasks/assets.rake.tt +1 -1
- data/lib/generators/react_on_rails/templates/base/server_rendering/client/webpack.server.rails.config.js +1 -1
- data/lib/react_on_rails/configuration.rb +51 -11
- data/lib/react_on_rails/controller.rb +2 -2
- data/lib/react_on_rails/server_rendering_pool.rb +2 -2
- data/lib/react_on_rails/test_helper.rb +31 -25
- data/lib/react_on_rails/test_helper/ensure_assets_compiled.rb +84 -34
- data/lib/react_on_rails/test_helper/webpack_assets_compiler.rb +20 -12
- data/lib/react_on_rails/test_helper/webpack_assets_status_checker.rb +35 -32
- data/lib/react_on_rails/test_helper/webpack_process_checker.rb +17 -13
- data/lib/react_on_rails/utils.rb +5 -0
- data/lib/react_on_rails/version.rb +1 -1
- data/package.json +1 -2
- data/rakelib/node_package.rake +1 -8
- data/rakelib/run_rspec.rake +29 -10
- metadata +3 -3
@@ -5,28 +5,32 @@ module ReactOnRails
|
|
5
5
|
class WebpackProcessChecker
|
6
6
|
def initialize
|
7
7
|
@printed_once = {}
|
8
|
+
@needs_client_compile = true
|
9
|
+
@needs_server_compile = Utils.server_rendering_is_enabled?
|
10
|
+
@wait_longer = false
|
8
11
|
end
|
9
12
|
|
10
|
-
|
13
|
+
# Return true if we should keep waiting
|
14
|
+
# type is either client or server
|
15
|
+
def client_running?
|
11
16
|
client_running = check_running_for_type("client")
|
12
|
-
return
|
17
|
+
return false unless client_running
|
18
|
+
end
|
13
19
|
|
14
|
-
|
15
|
-
|
20
|
+
def server_running?
|
21
|
+
if Utils.server_rendering_is_enabled?
|
22
|
+
return true if check_running_for_type("server")
|
23
|
+
end
|
24
|
+
false
|
25
|
+
end
|
16
26
|
|
17
|
-
|
27
|
+
def hot_running?
|
28
|
+
_response = `pgrep -fl 'babel-node +server-rails-hot.js'`
|
29
|
+
Utils.last_process_completed_successfully?
|
18
30
|
end
|
19
31
|
|
20
32
|
private
|
21
33
|
|
22
|
-
# We only want to do this if server rendering is enabled.
|
23
|
-
def fail_if_only_running_for_one_type(client_running, server_running)
|
24
|
-
return unless client_running ^ server_running
|
25
|
-
raise "\n\nError: detected webpack is not running for both types of assets:\n"\
|
26
|
-
"***Webpack Client Process Running?: #{client_running}\n"\
|
27
|
-
"***Webpack Server Process Running?: #{server_running}"
|
28
|
-
end
|
29
|
-
|
30
34
|
def check_running_for_type(type)
|
31
35
|
type = type.to_sym
|
32
36
|
|
data/lib/react_on_rails/utils.rb
CHANGED
@@ -13,5 +13,10 @@ module ReactOnRails
|
|
13
13
|
def self.last_process_completed_successfully?
|
14
14
|
$CHILD_STATUS.exitstatus == 0
|
15
15
|
end
|
16
|
+
|
17
|
+
def self.default_server_bundle_js_file_path
|
18
|
+
File.join(ReactOnRails.configuration.generated_assets_dir,
|
19
|
+
ReactOnRails.configuration.server_bundle_js_file)
|
20
|
+
end
|
16
21
|
end
|
17
22
|
end
|
data/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-on-rails",
|
3
|
-
"version": "4.0.0-beta.
|
3
|
+
"version": "4.0.0-beta.2",
|
4
4
|
"description": "react-on-rails JavaScript for react_on_rails Ruby gem",
|
5
5
|
"main": "node_package/lib/ReactOnRails.js",
|
6
6
|
"directories": {
|
@@ -47,7 +47,6 @@
|
|
47
47
|
"scripts": {
|
48
48
|
"test": "node_package/scripts/test",
|
49
49
|
"clean": "node_package/scripts/clean",
|
50
|
-
"symlink-node-package": "node_package/scripts/symlink-node-package",
|
51
50
|
"prepublish": "npm run build",
|
52
51
|
"build": "node_package/scripts/build",
|
53
52
|
"build-watch": "$(npm bin)/babel --watch --out-dir node_package/lib node_package/src",
|
data/rakelib/node_package.rake
CHANGED
@@ -5,14 +5,7 @@ namespace :node_package do
|
|
5
5
|
task :build do
|
6
6
|
sh "npm run build"
|
7
7
|
end
|
8
|
-
|
9
|
-
desc "Has all examples and dummy apps use local node_package folder for react-on-rails node dependency"
|
10
|
-
task :symlink do
|
11
|
-
sh_in_dir(gem_root, "npm run symlink-node-package")
|
12
|
-
end
|
13
8
|
end
|
14
9
|
|
15
10
|
desc "Prepares node_package by building and symlinking any example/dummy apps present"
|
16
|
-
task node_package: "node_package:build"
|
17
|
-
Rake::Task["node_package:symlink"].invoke
|
18
|
-
end
|
11
|
+
task node_package: "node_package:build"
|
data/rakelib/run_rspec.rake
CHANGED
@@ -7,6 +7,8 @@ require_relative "example_type"
|
|
7
7
|
include ReactOnRails::TaskHelpers
|
8
8
|
|
9
9
|
namespace :run_rspec do
|
10
|
+
spec_dummy_dir = File.join("spec", "dummy")
|
11
|
+
|
10
12
|
desc "Run RSpec for top level only"
|
11
13
|
task :gem do
|
12
14
|
run_tests_in("", rspec_args: File.join("spec", "react_on_rails"))
|
@@ -14,12 +16,14 @@ namespace :run_rspec do
|
|
14
16
|
|
15
17
|
desc "Runs dummy rspec with turbolinks"
|
16
18
|
task dummy: ["dummy_apps:dummy_app"] do
|
17
|
-
|
19
|
+
clean_gen_assets(spec_dummy_dir)
|
20
|
+
run_tests_in(spec_dummy_dir)
|
18
21
|
end
|
19
22
|
|
20
23
|
desc "Runs dummy rspec without turbolinks"
|
21
24
|
task dummy_no_turbolinks: ["dummy_apps:dummy_app"] do
|
22
|
-
|
25
|
+
clean_gen_assets(spec_dummy_dir)
|
26
|
+
run_tests_in(spec_dummy_dir,
|
23
27
|
env_vars: "DISABLE_TURBOLINKS=TRUE",
|
24
28
|
command_name: "dummy_no_turbolinks")
|
25
29
|
bundle_install_in(dummy_app_dir)
|
@@ -27,7 +31,8 @@ namespace :run_rspec do
|
|
27
31
|
|
28
32
|
desc "Runs dummy respec with turbolinks 5"
|
29
33
|
task dummy_turbolinks_5: ["dummy_apps:dummy_app_with_turbolinks_5"] do
|
30
|
-
|
34
|
+
clean_gen_assets(spec_dummy_dir)
|
35
|
+
run_tests_in(spec_dummy_dir, env_vars:
|
31
36
|
"ENABLE_TURBOLINKS_5=TRUE BUNDLE_GEMFILE=#{dummy_app_dir}/Gemfile")
|
32
37
|
end
|
33
38
|
|
@@ -51,8 +56,13 @@ namespace :run_rspec do
|
|
51
56
|
|
52
57
|
Coveralls::RakeTask.new
|
53
58
|
|
59
|
+
desc "run all tests no examples"
|
60
|
+
task all_but_examples: [:gem, :dummy, :dummy_no_turbolinks, :dummy_turbolinks_5, :empty, :js_tests] do
|
61
|
+
puts "Completed all RSpec tests"
|
62
|
+
end
|
63
|
+
|
54
64
|
desc "run all tests"
|
55
|
-
task run_rspec: [:
|
65
|
+
task run_rspec: [:all_but_examples, :examples] do
|
56
66
|
puts "Completed all RSpec tests"
|
57
67
|
end
|
58
68
|
end
|
@@ -66,12 +76,7 @@ desc "Runs all tests. Run `rake -D run_rspec` to see all available test options"
|
|
66
76
|
task run_rspec: ["run_rspec:run_rspec"]
|
67
77
|
|
68
78
|
private
|
69
|
-
|
70
|
-
# Runs rspec in the given directory.
|
71
|
-
# If string is passed and it's not absolute, it's converted relative to root of the gem.
|
72
|
-
# TEST_ENV_COMMAND_NAME is used to make SimpleCov.command_name unique in order to
|
73
|
-
# prevent a name collision. Defaults to the given directory's name.
|
74
|
-
def run_tests_in(dir, options = {})
|
79
|
+
def calc_path(dir)
|
75
80
|
if dir.is_a?(String)
|
76
81
|
path = if dir.start_with?(File::SEPARATOR)
|
77
82
|
Pathname.new(dir)
|
@@ -81,9 +86,23 @@ def run_tests_in(dir, options = {})
|
|
81
86
|
else
|
82
87
|
path = dir
|
83
88
|
end
|
89
|
+
path
|
90
|
+
end
|
91
|
+
|
92
|
+
# Runs rspec in the given directory.
|
93
|
+
# If string is passed and it's not absolute, it's converted relative to root of the gem.
|
94
|
+
# TEST_ENV_COMMAND_NAME is used to make SimpleCov.command_name unique in order to
|
95
|
+
# prevent a name collision. Defaults to the given directory's name.
|
96
|
+
def run_tests_in(dir, options = {})
|
97
|
+
path = calc_path(dir)
|
84
98
|
|
85
99
|
command_name = options.fetch(:command_name, path.basename)
|
86
100
|
rspec_args = options.fetch(:rspec_args, "")
|
87
101
|
env_vars = %(#{options.fetch(:env_vars, '')} COVERAGE=true TEST_ENV_COMMAND_NAME="#{command_name}")
|
88
102
|
sh_in_dir(path.realpath, "#{env_vars} bundle exec rspec #{rspec_args}")
|
89
103
|
end
|
104
|
+
|
105
|
+
def clean_gen_assets(dir)
|
106
|
+
path = calc_path(dir)
|
107
|
+
sh_in_dir(path.realpath, "npm run build:clean")
|
108
|
+
end
|
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: 4.0.0.beta.
|
4
|
+
version: 4.0.0.beta.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Gordon
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: connection_pool
|
@@ -462,7 +462,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
462
462
|
version: 1.3.1
|
463
463
|
requirements: []
|
464
464
|
rubyforge_project:
|
465
|
-
rubygems_version: 2.
|
465
|
+
rubygems_version: 2.6.1
|
466
466
|
signing_key:
|
467
467
|
specification_version: 4
|
468
468
|
summary: Rails with react server rendering with webpack.
|