react_on_rails 12.0.3.beta.0 → 12.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +12 -2
- data/.eslintrc +2 -1
- data/.github/workflows/lint-js-and-ruby.yml +3 -3
- data/.github/workflows/main.yml +6 -6
- data/.github/workflows/package-js-tests.yml +2 -2
- data/.github/workflows/rspec-package-specs.yml +2 -2
- data/.prettierrc +0 -3
- data/.rubocop.yml +46 -38
- data/CHANGELOG.md +32 -13
- data/CONTRIBUTING.md +3 -2
- data/Gemfile +1 -33
- data/Gemfile.development_dependencies +51 -0
- data/NEWS.md +0 -1
- data/README.md +63 -55
- data/docs/{basics → additional-details}/generator-details.md +1 -6
- data/docs/{outdated → additional-details}/manual-installation-overview.md +6 -6
- data/docs/{basics → additional-details}/migrating-from-react-rails.md +0 -0
- data/docs/{additional-reading → additional-details}/recommended-project-structure.md +0 -0
- data/docs/{additional-reading → additional-details}/updating-dependencies.md +0 -0
- data/docs/additional-details/upgrade-webpacker-v3-to-v4.md +10 -0
- data/docs/api/javascript-api.md +2 -2
- data/docs/api/redux-store-api.md +3 -3
- data/docs/api/view-helpers-api.md +7 -8
- data/docs/basics/client-vs-server-rendering.md +3 -3
- data/docs/basics/configuration.md +42 -25
- data/docs/basics/deployment.md +2 -2
- data/docs/{outdated → basics}/how-react-on-rails-works.md +8 -9
- data/docs/basics/installation-into-an-existing-rails-app.md +13 -6
- data/docs/basics/react-server-rendering.md +3 -3
- data/docs/basics/rspec-configuration.md +10 -10
- data/docs/{tutorial.md → basics/tutorial.md} +23 -31
- data/docs/basics/upgrading-react-on-rails.md +32 -12
- data/docs/basics/webpack-configuration.md +4 -6
- data/docs/contributor-info/linters.md +5 -6
- data/docs/contributor-info/pull-requests.md +2 -4
- data/docs/contributor-info/releasing.md +1 -1
- data/docs/{additional-reading → deployment}/elastic-beanstalk.md +0 -0
- data/docs/{basics → deployment}/heroku-deployment.md +0 -0
- data/docs/home.md +382 -0
- data/docs/{additional-reading → javascript}/angular-js-integration-migration.md +0 -0
- data/docs/{additional-reading → javascript}/asset-pipeline.md +0 -0
- data/docs/{additional-reading → javascript}/capistrano-deployment.md +0 -0
- data/docs/{outdated → javascript}/code-splitting.md +5 -5
- data/docs/{additional-reading → javascript}/converting-from-custom-webpack-config-to-rails-webpacker-config.md +3 -3
- data/docs/{additional-reading → javascript}/credits.md +0 -0
- data/docs/{additional-reading → javascript}/foreman-issues.md +0 -0
- data/docs/{additional-reading → javascript}/images.md +5 -6
- data/docs/{additional-reading → javascript}/node-dependencies-and-npm.md +0 -0
- data/docs/{additional-reading → javascript}/react-and-redux.md +0 -0
- data/docs/{additional-reading → javascript}/react-helmet.md +0 -0
- data/docs/{additional-reading → javascript}/react-router.md +0 -0
- data/docs/{additional-reading → javascript}/server-rendering-tips.md +0 -0
- data/docs/{additional-reading → javascript}/troubleshooting-when-using-webpacker.md +0 -0
- data/docs/{additional-reading → javascript}/webpack-v1-notes.md +0 -0
- data/docs/{additional-reading → javascript}/webpack.md +0 -0
- data/docs/{articles.md → misc/articles.md} +1 -1
- data/docs/misc/doctrine.md +5 -5
- data/docs/{coding-style → misc}/style.md +0 -0
- data/docs/{additional-reading → misc}/tips.md +0 -0
- data/docs/outdated/deferred-rendering.md +39 -0
- data/docs/outdated/rails-assets-relative-paths.md +3 -3
- data/docs/outdated/rails-assets.md +8 -8
- data/docs/outdated/rails3.md +2 -2
- data/docs/rails-webpacker-react-integration-options.md +182 -0
- data/docs/{additional-reading → rails}/convert-rails-5-api-only-app.md +1 -1
- data/docs/{additional-reading → rails}/rails-engine-integration.md +0 -0
- data/docs/{additional-reading → rails}/rails_view_rendering_from_inline_javascript.md +0 -0
- data/docs/{additional-reading → rails}/turbolinks.md +0 -0
- data/docs/testimonials/testimonials.md +6 -6
- data/lib/generators/react_on_rails/base_generator.rb +8 -1
- data/lib/generators/react_on_rails/dev_tests_generator.rb +1 -1
- data/lib/generators/react_on_rails/templates/dev_tests/spec/rails_helper.rb +4 -1
- data/lib/generators/react_on_rails/templates/dev_tests/spec/simplecov_helper.rb +1 -1
- data/lib/generators/react_on_rails/templates/dev_tests/spec/{features → system}/hello_world_spec.rb +2 -2
- data/lib/react_on_rails/configuration.rb +2 -0
- data/lib/react_on_rails/git_utils.rb +3 -3
- data/lib/react_on_rails/helper.rb +30 -11
- data/lib/react_on_rails/locales/base.rb +3 -3
- data/lib/react_on_rails/locales/to_js.rb +0 -4
- data/lib/react_on_rails/locales/to_json.rb +0 -4
- data/lib/react_on_rails/prerender_error.rb +1 -1
- data/lib/react_on_rails/react_component/render_options.rb +16 -7
- data/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb +8 -6
- data/lib/react_on_rails/test_helper.rb +2 -0
- data/lib/react_on_rails/test_helper/webpack_assets_compiler.rb +1 -1
- data/lib/react_on_rails/utils.rb +19 -3
- data/lib/react_on_rails/version.rb +1 -1
- data/lib/react_on_rails/webpacker_utils.rb +5 -1
- data/lib/tasks/assets.rake +20 -11
- data/package.json +24 -29
- data/rakelib/docker.rake +0 -5
- data/rakelib/lint.rake +3 -9
- data/rakelib/release.rake +29 -15
- data/rakelib/run_rspec.rake +10 -11
- data/rakelib/task_helpers.rb +16 -4
- data/react_on_rails.gemspec +3 -17
- data/yarn.lock +2549 -5169
- metadata +48 -228
- data/.release-it.json +0 -3
- data/docs/additional-reading/upgrade-webpacker-v3-to-v4.md +0 -10
- data/docs/additional-reading/webpack-dev-server.md +0 -15
- data/ruby-lint.yml +0 -25
@@ -52,6 +52,7 @@ module ReactOnRails
|
|
52
52
|
# don't provide one.
|
53
53
|
# webpack_generated_files List of files to check for up-to-date-status, defaulting to
|
54
54
|
# webpack_generated_files in your configuration
|
55
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
55
56
|
def self.ensure_assets_compiled(webpack_assets_status_checker: nil,
|
56
57
|
webpack_assets_compiler: nil,
|
57
58
|
source_path: nil,
|
@@ -96,4 +97,5 @@ module ReactOnRails
|
|
96
97
|
).call
|
97
98
|
end
|
98
99
|
end
|
100
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
99
101
|
end
|
@@ -8,7 +8,7 @@ module ReactOnRails
|
|
8
8
|
def compile_assets
|
9
9
|
if ReactOnRails.configuration.build_test_command.blank?
|
10
10
|
msg = <<~MSG
|
11
|
-
You are using the React on Rails test helper.
|
11
|
+
You are using the React on Rails test helper.
|
12
12
|
Either you used:
|
13
13
|
ReactOnRails::TestHelper.configure_rspec_to_compile_assets or
|
14
14
|
ReactOnRails::TestHelper.ensure_assets_compiled
|
data/lib/react_on_rails/utils.rb
CHANGED
@@ -34,7 +34,7 @@ module ReactOnRails
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def self.object_to_boolean(value)
|
37
|
-
[true, "true", "yes", 1, "1", "t"].include?(value.
|
37
|
+
[true, "true", "yes", 1, "1", "t"].include?(value.instance_of?(String) ? value.downcase : value)
|
38
38
|
end
|
39
39
|
|
40
40
|
def self.server_rendering_is_enabled?
|
@@ -118,9 +118,11 @@ module ReactOnRails
|
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
121
|
+
# rubocop:disable Naming/VariableNumber
|
121
122
|
def self.rails_version_less_than_4_1_1
|
122
123
|
rails_version_less_than("4.1.1")
|
123
124
|
end
|
125
|
+
# rubocop:enable Naming/VariableNumber
|
124
126
|
|
125
127
|
module Required
|
126
128
|
def required(arg_name)
|
@@ -156,15 +158,29 @@ module ReactOnRails
|
|
156
158
|
end
|
157
159
|
|
158
160
|
def self.gem_available?(name)
|
159
|
-
Gem
|
161
|
+
Gem.loaded_specs[name].present?
|
160
162
|
rescue Gem::LoadError
|
161
163
|
false
|
162
164
|
rescue StandardError
|
163
165
|
Gem.available?(name).present?
|
164
166
|
end
|
165
167
|
|
168
|
+
# Todo -- remove this for v13, as we don't need both boolean and number
|
166
169
|
def self.react_on_rails_pro?
|
167
|
-
@react_on_rails_pro
|
170
|
+
return @react_on_rails_pro if defined?(@react_on_rails_pro)
|
171
|
+
|
172
|
+
@react_on_rails_pro = gem_available?("react_on_rails_pro")
|
173
|
+
end
|
174
|
+
|
175
|
+
# Return an empty string if React on Rails Pro is not installed
|
176
|
+
def self.react_on_rails_pro_version
|
177
|
+
return @react_on_rails_pro_version if defined?(@react_on_rails_pro_version)
|
178
|
+
|
179
|
+
@react_on_rails_pro_version = if react_on_rails_pro?
|
180
|
+
Gem.loaded_specs["react_on_rails_pro"].version.to_s
|
181
|
+
else
|
182
|
+
""
|
183
|
+
end
|
168
184
|
end
|
169
185
|
|
170
186
|
def self.smart_trim(str, max_length = 1000)
|
@@ -2,8 +2,12 @@
|
|
2
2
|
|
3
3
|
module ReactOnRails
|
4
4
|
module WebpackerUtils
|
5
|
+
# TODO: V13 code should be cleaned up so that the webpacker gem is required.
|
6
|
+
# This check should only be done at startup.
|
5
7
|
def self.using_webpacker?
|
6
|
-
|
8
|
+
return @using_webpacker if defined?(@using_webpacker)
|
9
|
+
|
10
|
+
@using_webpacker = ReactOnRails::Utils.gem_available?("webpacker")
|
7
11
|
end
|
8
12
|
|
9
13
|
def self.webpacker_webpack_production_config_exists?
|
data/lib/tasks/assets.rake
CHANGED
@@ -6,7 +6,6 @@
|
|
6
6
|
require "active_support"
|
7
7
|
|
8
8
|
ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
|
9
|
-
ENV["NODE_ENV"] ||= "development"
|
10
9
|
|
11
10
|
unless ReactOnRails::WebpackerUtils.webpacker_webpack_production_config_exists?
|
12
11
|
# Ensure that rails/webpacker does not call bin/webpack if we're providing
|
@@ -20,8 +19,8 @@ unless ReactOnRails::WebpackerUtils.webpacker_webpack_production_config_exists?
|
|
20
19
|
# VERSIONS is per the rails/webpacker clean method definition.
|
21
20
|
# We set it very big so that it is not used, and then clean just
|
22
21
|
# removes files older than 1 hour.
|
23
|
-
|
24
|
-
Rake::Task["webpacker:clean"].invoke(
|
22
|
+
versions = 100_000
|
23
|
+
Rake::Task["webpacker:clean"].invoke(versions)
|
25
24
|
}
|
26
25
|
|
27
26
|
if Rake::Task.task_defined?("assets:precompile")
|
@@ -40,17 +39,27 @@ end
|
|
40
39
|
namespace :react_on_rails do
|
41
40
|
namespace :assets do
|
42
41
|
desc <<-DESC.strip_heredoc
|
43
|
-
Compile assets with webpack
|
44
|
-
Uses command defined with ReactOnRails.configuration.build_production_command
|
45
|
-
sh "#{ReactOnRails::Utils.prepend_cd_node_modules_directory('<ReactOnRails.configuration.build_production_command>')}"
|
46
|
-
Note: This command is not automatically added to assets:precompile if the rails/webpacker
|
42
|
+
Compile assets with webpack
|
43
|
+
Uses command defined with ReactOnRails.configuration.build_production_command
|
44
|
+
sh "#{ReactOnRails::Utils.prepend_cd_node_modules_directory('<ReactOnRails.configuration.build_production_command>')}"
|
45
|
+
Note: This command is not automatically added to assets:precompile if the rails/webpacker
|
47
46
|
configuration file config/webpack/production.js exists.
|
48
47
|
DESC
|
49
48
|
task webpack: :locale do
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
49
|
+
build_production_command = ReactOnRails.configuration.build_production_command
|
50
|
+
if build_production_command.present?
|
51
|
+
if build_production_command.is_a?(String)
|
52
|
+
sh ReactOnRails::Utils.prepend_cd_node_modules_directory(
|
53
|
+
build_production_command
|
54
|
+
).to_s
|
55
|
+
elsif build_production_command.methods.include?(:call)
|
56
|
+
build_production_command.call
|
57
|
+
else
|
58
|
+
msg = "ReactonRails.configuration.build_production_command is improperly configured. "\
|
59
|
+
"Value = #{build_production_command} with class #{build_production_command.class}"
|
60
|
+
puts Rainbow(msg).red
|
61
|
+
exit!(1)
|
62
|
+
end
|
54
63
|
else
|
55
64
|
msg = <<~MSG
|
56
65
|
React on Rails is aborting webpack compilation from task react_on_rails:assets:webpack
|
data/package.json
CHANGED
@@ -1,56 +1,51 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-on-rails",
|
3
|
-
"version": "12.
|
3
|
+
"version": "12.2.0",
|
4
4
|
"description": "react-on-rails JavaScript for react_on_rails Ruby gem",
|
5
5
|
"main": "node_package/lib/ReactOnRails.js",
|
6
6
|
"directories": {
|
7
7
|
"doc": "docs"
|
8
8
|
},
|
9
9
|
"devDependencies": {
|
10
|
-
"@babel/cli": "^7.
|
11
|
-
"@babel/core": "^7.
|
12
|
-
"@babel/plugin-transform-runtime": "^7.
|
13
|
-
"@babel/plugin-transform-typescript": "^7.
|
14
|
-
"@babel/preset-env": "^7.
|
15
|
-
"@babel/preset-react": "^7.
|
16
|
-
"@babel/types": "^7.
|
17
|
-
"@types/jest": "^
|
18
|
-
"@types/node": "^
|
10
|
+
"@babel/cli": "^7.12.10",
|
11
|
+
"@babel/core": "^7.12.10",
|
12
|
+
"@babel/plugin-transform-runtime": "^7.12.10",
|
13
|
+
"@babel/plugin-transform-typescript": "^7.12.1",
|
14
|
+
"@babel/preset-env": "^7.12.10",
|
15
|
+
"@babel/preset-react": "^7.12.10",
|
16
|
+
"@babel/types": "^7.12.10",
|
17
|
+
"@types/jest": "^26.0.18",
|
18
|
+
"@types/node": "^14.14.11",
|
19
19
|
"@types/react": "^16.9.23",
|
20
20
|
"@types/react-dom": "^16.9.5",
|
21
21
|
"@types/turbolinks": "^5.2.0",
|
22
|
-
"@typescript-eslint/eslint-plugin": "^
|
23
|
-
"@typescript-eslint/parser": "^
|
24
|
-
"babel-loader": "^8.0.2",
|
22
|
+
"@typescript-eslint/eslint-plugin": "^4.10.0",
|
23
|
+
"@typescript-eslint/parser": "^4.10.0",
|
25
24
|
"babelify": "^10.0.0",
|
26
25
|
"blue-tape": "^1.0.0",
|
27
26
|
"create-react-class": "^15.6.0",
|
28
|
-
"eslint": "^
|
29
|
-
"eslint-config-prettier": "^
|
27
|
+
"eslint": "^7.15.0",
|
28
|
+
"eslint-config-prettier": "^7.0.0",
|
30
29
|
"eslint-config-shakacode": "^16.0.1",
|
31
|
-
"eslint-plugin-import": "^2.
|
32
|
-
"eslint-plugin-jsx-a11y": "^6.1
|
33
|
-
"eslint-plugin-prettier": "^3.
|
34
|
-
"eslint-plugin-react": "^7.
|
35
|
-
"jest": "^
|
36
|
-
"jsdom": "^
|
30
|
+
"eslint-plugin-import": "^2.22.1",
|
31
|
+
"eslint-plugin-jsx-a11y": "^6.4.1",
|
32
|
+
"eslint-plugin-prettier": "^3.3.0",
|
33
|
+
"eslint-plugin-react": "^7.21.5",
|
34
|
+
"jest": "^26.6.3",
|
35
|
+
"jsdom": "^16.4.0",
|
37
36
|
"nps": "^5.9.3",
|
38
|
-
"prettier": "^2.
|
37
|
+
"prettier": "^2.2.1",
|
39
38
|
"prettier-eslint-cli": "^5.0.0",
|
40
39
|
"prop-types": "^15.5.10",
|
41
40
|
"react": "^16.5.2",
|
42
41
|
"react-dom": "^16.5.2",
|
43
42
|
"react-transform-hmr": "^1.0.4",
|
44
43
|
"redux": "^4.0.1",
|
45
|
-
"
|
46
|
-
"
|
47
|
-
"tslint-config-prettier": "^1.18.0",
|
48
|
-
"typescript": "^3.8.3",
|
49
|
-
"webpack": "^3.4.1",
|
50
|
-
"webpack-manifest-plugin": "^1.2.1"
|
44
|
+
"ts-jest": "^26.4.4",
|
45
|
+
"typescript": "^4.1.2"
|
51
46
|
},
|
52
47
|
"dependencies": {
|
53
|
-
"@babel/runtime-corejs3": "^7.
|
48
|
+
"@babel/runtime-corejs3": "^7.12.5",
|
54
49
|
"concurrently": "^5.1.0"
|
55
50
|
},
|
56
51
|
"peerDependencies": {
|
data/rakelib/docker.rake
CHANGED
@@ -6,11 +6,6 @@ namespace :docker do
|
|
6
6
|
sh "docker-compose run lint rake lint:rubocop"
|
7
7
|
end
|
8
8
|
|
9
|
-
desc "Run ruby-lint linter from docker"
|
10
|
-
task :ruby do
|
11
|
-
sh "docker-compose run lint rake lint:ruby"
|
12
|
-
end
|
13
|
-
|
14
9
|
desc "Run scss-lint linter from docker"
|
15
10
|
task :scss do
|
16
11
|
sh "docker-compose run lint rake lint:scss"
|
data/rakelib/lint.rake
CHANGED
@@ -7,13 +7,7 @@ namespace :lint do
|
|
7
7
|
|
8
8
|
desc "Run Rubocop as shell"
|
9
9
|
task :rubocop do
|
10
|
-
sh_in_dir(gem_root, "bundle exec rubocop .")
|
11
|
-
end
|
12
|
-
|
13
|
-
desc "Run ruby-lint as shell"
|
14
|
-
task :ruby do
|
15
|
-
puts "See /ruby-lint.yml for what directories are included."
|
16
|
-
sh_in_dir(gem_root, "bundle exec ruby-lint .")
|
10
|
+
sh_in_dir(gem_root, "bundle exec rubocop --version", "bundle exec rubocop .")
|
17
11
|
end
|
18
12
|
|
19
13
|
desc "Run scss-lint as shell"
|
@@ -23,10 +17,10 @@ namespace :lint do
|
|
23
17
|
|
24
18
|
desc "Run eslint as shell"
|
25
19
|
task :eslint do
|
26
|
-
sh_in_dir(gem_root, "yarn run eslint")
|
20
|
+
sh_in_dir(gem_root, "yarn run eslint --version", "yarn run eslint .")
|
27
21
|
end
|
28
22
|
|
29
|
-
desc "Run all eslint & rubocop linters. Skip
|
23
|
+
desc "Run all eslint & rubocop linters. Skip scss"
|
30
24
|
task lint: %i[eslint rubocop] do
|
31
25
|
puts "Completed all linting"
|
32
26
|
end
|
data/rakelib/release.rake
CHANGED
@@ -4,6 +4,15 @@ require_relative "task_helpers"
|
|
4
4
|
require_relative File.join(gem_root, "lib", "react_on_rails", "version_syntax_converter")
|
5
5
|
require_relative File.join(gem_root, "lib", "react_on_rails", "git_utils")
|
6
6
|
require_relative File.join(gem_root, "lib", "react_on_rails", "utils")
|
7
|
+
|
8
|
+
class RaisingMessageHandler
|
9
|
+
def add_error(error)
|
10
|
+
raise error
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# rubocop:disable Metrics/BlockLength
|
15
|
+
|
7
16
|
desc("Releases both the gem and node package using the given version.
|
8
17
|
|
9
18
|
IMPORTANT: the gem version must be in valid rubygem format (no dashes).
|
@@ -12,26 +21,18 @@ for the node package version. This only makes a difference for pre-release
|
|
12
21
|
versions such as `3.0.0.beta.1` (yarn version would be `3.0.0-beta.1`).
|
13
22
|
|
14
23
|
This task depends on the gem-release (ruby gem) and release-it (node package)
|
15
|
-
which are installed via `bundle install` and `yarn`
|
24
|
+
which are installed via `bundle install` and `yarn global add release-it`
|
16
25
|
|
17
26
|
1st argument: The new version in rubygem format (no dashes). Pass no argument to
|
18
27
|
automatically perform a patch version bump.
|
19
28
|
2nd argument: Perform a dry run by passing 'true' as a second argument.
|
20
29
|
|
21
30
|
Example: `rake release[2.1.0,false]`")
|
22
|
-
|
23
|
-
# rubocop:disable Metrics/BlockLength
|
24
31
|
task :release, %i[gem_version dry_run tools_install] do |_t, args|
|
25
32
|
include ReactOnRails::TaskHelpers
|
26
33
|
|
27
|
-
class MessageHandler
|
28
|
-
def add_error(error)
|
29
|
-
raise error
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
34
|
# Check if there are uncommited changes
|
34
|
-
ReactOnRails::GitUtils.uncommitted_changes?(
|
35
|
+
ReactOnRails::GitUtils.uncommitted_changes?(RaisingMessageHandler.new)
|
35
36
|
args_hash = args.to_hash
|
36
37
|
|
37
38
|
is_dry_run = ReactOnRails::Utils.object_to_boolean(args_hash[:dry_run])
|
@@ -56,17 +57,30 @@ task :release, %i[gem_version dry_run tools_install] do |_t, args|
|
|
56
57
|
# Update dummy app's Gemfile.lock
|
57
58
|
bundle_install_in(dummy_app_dir)
|
58
59
|
|
59
|
-
# Stage changes so far
|
60
|
-
sh_in_dir(gem_root, "git add .")
|
61
|
-
|
62
60
|
# Will bump the yarn version, commit, tag the commit, push to repo, and release on yarn
|
63
|
-
release_it_command = "
|
61
|
+
release_it_command = +"release-it"
|
64
62
|
release_it_command << " #{npm_version}" unless npm_version.strip.empty?
|
65
|
-
release_it_command << " --non-interactive --npm.publish"
|
63
|
+
release_it_command << " --non-interactive --npm.publish --no-git.requireCleanWorkingDir"
|
66
64
|
release_it_command << " --dry-run --verbose" if is_dry_run
|
67
65
|
sh_in_dir(gem_root, release_it_command)
|
68
66
|
|
69
67
|
# Release the new gem version
|
70
68
|
sh_in_dir(gem_root, "gem release") unless is_dry_run
|
69
|
+
|
70
|
+
msg = <<~MSG
|
71
|
+
Once you have successfully published, run these commands to update the spec apps:
|
72
|
+
|
73
|
+
cd #{dummy_app_dir}; bundle update react_on_rails
|
74
|
+
cd #{gem_root}#{' '}
|
75
|
+
git commit -a -m 'Update Gemfile.lock for spec app'
|
76
|
+
git push
|
77
|
+
MSG
|
78
|
+
puts msg
|
71
79
|
end
|
72
80
|
# rubocop:enable Metrics/BlockLength
|
81
|
+
|
82
|
+
task :test do
|
83
|
+
unbundled_sh_in_dir(gem_root, "cd #{dummy_app_dir}; bundle update react_on_rails")
|
84
|
+
sh_in_dir(gem_root, "git commit -a -m 'Update Gemfile.lock for spec app'")
|
85
|
+
sh_in_dir(gem_root, "git push")
|
86
|
+
end
|
data/rakelib/run_rspec.rake
CHANGED
@@ -86,16 +86,15 @@ task run_rspec: ["run_rspec:run_rspec"]
|
|
86
86
|
private
|
87
87
|
|
88
88
|
def calc_path(dir)
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
path
|
89
|
+
if dir.is_a?(String)
|
90
|
+
if dir.start_with?(File::SEPARATOR)
|
91
|
+
Pathname.new(dir)
|
92
|
+
else
|
93
|
+
Pathname.new(File.join(gem_root, dir))
|
94
|
+
end
|
95
|
+
else
|
96
|
+
dir
|
97
|
+
end
|
99
98
|
end
|
100
99
|
|
101
100
|
# Runs rspec in the given directory.
|
@@ -107,7 +106,7 @@ def run_tests_in(dir, options = {})
|
|
107
106
|
|
108
107
|
command_name = options.fetch(:command_name, path.basename)
|
109
108
|
rspec_args = options.fetch(:rspec_args, "")
|
110
|
-
env_vars = "#{options.fetch(:env_vars, '')} TEST_ENV_COMMAND_NAME=\"#{command_name}\""
|
109
|
+
env_vars = +"#{options.fetch(:env_vars, '')} TEST_ENV_COMMAND_NAME=\"#{command_name}\""
|
111
110
|
env_vars << "COVERAGE=true" if ENV["USE_COVERALLS"]
|
112
111
|
sh_in_dir(path.realpath, "#{env_vars} bundle exec rspec #{rspec_args}")
|
113
112
|
end
|
data/rakelib/task_helpers.rb
CHANGED
@@ -16,14 +16,26 @@ module ReactOnRails
|
|
16
16
|
File.join(gem_root, "spec/dummy")
|
17
17
|
end
|
18
18
|
|
19
|
+
# Executes a string or an array of strings in a shell in the given directory in an unbundled environment
|
20
|
+
def sh_in_dir(dir, *shell_commands)
|
21
|
+
shell_commands.flatten.each { |shell_command| sh %(cd #{dir} && #{shell_command.strip}) }
|
22
|
+
end
|
23
|
+
|
19
24
|
# Executes a string or an array of strings in a shell in the given directory
|
20
|
-
def
|
21
|
-
|
22
|
-
|
25
|
+
def unbundled_sh_in_dir(dir, *shell_commands)
|
26
|
+
Dir.chdir(dir) do
|
27
|
+
# Without `with_unbundled_env`, running bundle in the child directories won't correctly
|
28
|
+
# update the Gemfile.lock
|
29
|
+
Bundler.with_unbundled_env do
|
30
|
+
shell_commands.flatten.each do |shell_command|
|
31
|
+
sh(shell_command.strip)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
23
35
|
end
|
24
36
|
|
25
37
|
def bundle_install_in(dir)
|
26
|
-
|
38
|
+
unbundled_sh_in_dir(dir, "bundle install")
|
27
39
|
end
|
28
40
|
|
29
41
|
def bundle_install_in_no_turbolinks(dir)
|
data/react_on_rails.gemspec
CHANGED
@@ -32,27 +32,13 @@ Gem::Specification.new do |s|
|
|
32
32
|
s.add_dependency "rainbow", "~> 3.0"
|
33
33
|
s.add_dependency "webpacker", ">= 4.0"
|
34
34
|
|
35
|
-
s.add_development_dependency "awesome_print"
|
36
35
|
s.add_development_dependency "bundler", "~> 2"
|
37
|
-
s.add_development_dependency "coveralls"
|
38
36
|
s.add_development_dependency "gem-release"
|
39
|
-
s.add_development_dependency "generator_spec"
|
40
|
-
s.add_development_dependency "listen"
|
41
|
-
s.add_development_dependency "pry"
|
42
|
-
s.add_development_dependency "pry-byebug"
|
43
|
-
s.add_development_dependency "pry-doc"
|
44
|
-
s.add_development_dependency "pry-rescue"
|
45
|
-
s.add_development_dependency "pry-state"
|
46
|
-
s.add_development_dependency "rails", "~> 5.2"
|
47
|
-
|
48
|
-
s.add_development_dependency "rake", "~> 10.0"
|
49
|
-
s.add_development_dependency "rspec"
|
50
|
-
s.add_development_dependency "rubocop", "0.85.0"
|
51
|
-
|
52
37
|
s.post_install_message = '
|
53
38
|
--------------------------------------------------------------------------------
|
54
|
-
|
55
|
-
which
|
39
|
+
Checkout https://www.shakacode.com/react-on-rails-pro for information about
|
40
|
+
"React on Rails Pro" which includes one hour a month of support and a gem for
|
41
|
+
better performance, via caching helpers, and our node rendering server.
|
56
42
|
--------------------------------------------------------------------------------
|
57
43
|
'
|
58
44
|
end
|