react_on_rails 12.0.0 → 12.1.0
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/.circleci/config.yml +12 -2
- data/.eslintrc +2 -1
- data/.github/workflows/lint-js-and-ruby.yml +53 -0
- data/.github/workflows/main.yml +178 -0
- data/.github/workflows/package-js-tests.yml +35 -0
- data/.github/workflows/rspec-package-specs.yml +45 -0
- data/.prettierrc +0 -3
- data/.rubocop.yml +47 -38
- data/.travis.yml +8 -4
- data/CHANGELOG.md +58 -28
- data/CONTRIBUTING.md +4 -3
- data/Gemfile +1 -33
- data/Gemfile.development_dependencies +51 -0
- data/NEWS.md +5 -0
- data/README.md +116 -105
- data/SUMMARY.md +1 -1
- data/docs/{basics → additional-details}/generator-details.md +1 -6
- data/docs/{outdated → additional-details}/manual-installation-overview.md +6 -6
- data/docs/additional-details/recommended-project-structure.md +69 -0
- data/docs/additional-details/upgrade-webpacker-v3-to-v4.md +10 -0
- data/docs/api/javascript-api.md +5 -5
- data/docs/api/redux-store-api.md +5 -5
- data/docs/api/view-helpers-api.md +11 -12
- data/docs/basics/client-vs-server-rendering.md +4 -2
- data/docs/basics/configuration.md +43 -26
- data/docs/basics/deployment.md +2 -2
- data/docs/basics/hmr-and-hot-reloading-with-the-webpack-dev-server.md +64 -9
- 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 +8 -5
- data/docs/basics/render-functions-and-railscontext.md +1 -1
- data/docs/basics/rspec-configuration.md +10 -10
- data/docs/{tutorial.md → basics/tutorial.md} +28 -30
- data/docs/basics/upgrading-react-on-rails.md +52 -15
- data/docs/basics/webpack-configuration.md +14 -22
- 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/home.md +382 -0
- data/docs/{outdated → javascript}/code-splitting.md +8 -8
- data/docs/javascript/converting-from-custom-webpack-config-to-rails-webpacker-config.md +10 -0
- data/docs/{additional-reading → javascript}/images.md +5 -6
- data/docs/{additional-reading → javascript}/react-router.md +1 -1
- data/docs/{additional-reading → javascript}/server-rendering-tips.md +4 -1
- data/docs/{articles.md → misc/articles.md} +1 -1
- data/docs/misc/doctrine.md +5 -6
- 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/{additional-reading → rails}/convert-rails-5-api-only-app.md +1 -1
- data/docs/rails-webpacker-react-integration-options.md +182 -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 +8 -2
- 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 +23 -17
- 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/server_rendering_pool/ruby_embedded_java_script.rb +6 -6
- data/lib/react_on_rails/test_helper/webpack_assets_compiler.rb +1 -1
- data/lib/react_on_rails/test_helper.rb +2 -0
- data/lib/react_on_rails/utils.rb +24 -4
- data/lib/react_on_rails/version.rb +1 -1
- data/lib/react_on_rails/webpacker_utils.rb +9 -5
- data/lib/tasks/assets.rake +35 -14
- data/package.json +24 -29
- data/rakelib/docker.rake +0 -5
- data/rakelib/examples.rake +1 -1
- data/rakelib/lint.rake +4 -10
- data/rakelib/release.rake +28 -16
- data/rakelib/run_rspec.rake +10 -11
- data/rakelib/task_helpers.rb +16 -4
- data/react_on_rails.gemspec +3 -17
- data/yarn.lock +2272 -4960
- metadata +50 -224
- data/docs/additional-reading/upgrade-webpacker-v3-to-v4.md +0 -10
- data/docs/additional-reading/webpack-dev-server.md +0 -15
- data/docs/basics/recommended-project-structure.md +0 -77
- data/ruby-lint.yml +0 -25
- /data/docs/{basics → additional-details}/migrating-from-react-rails.md +0 -0
- /data/docs/{additional-reading → additional-details}/updating-dependencies.md +0 -0
- /data/docs/{additional-reading → deployment}/elastic-beanstalk.md +0 -0
- /data/docs/{basics → deployment}/heroku-deployment.md +0 -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/{additional-reading → javascript}/credits.md +0 -0
- /data/docs/{additional-reading → javascript}/foreman-issues.md +0 -0
- /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}/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/{coding-style → misc}/style.md +0 -0
- /data/docs/{additional-reading → misc}/tips.md +0 -0
- /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/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?
|
|
@@ -71,7 +71,11 @@ module ReactOnRails
|
|
|
71
71
|
# 1. Using same bundle for both server and client, so server bundle will be hashed in manifest
|
|
72
72
|
# 2. Using a different bundle (different Webpack config), so file is not hashed, and
|
|
73
73
|
# bundle_js_path will throw so the default path is used without a hash.
|
|
74
|
-
# 3.
|
|
74
|
+
# 3. The third option of having the server bundle hashed and a different configuration than
|
|
75
|
+
# the client bundle is not supported for 2 reasons:
|
|
76
|
+
# a. The webpack manifest plugin would have a race condition where the same manifest.json
|
|
77
|
+
# is edited by both the webpack-dev-server
|
|
78
|
+
# b. There is no good reason to hash the server bundle name.
|
|
75
79
|
return @server_bundle_path if @server_bundle_path && !Rails.env.development?
|
|
76
80
|
|
|
77
81
|
bundle_name = ReactOnRails.configuration.server_bundle_js_file
|
|
@@ -114,9 +118,11 @@ module ReactOnRails
|
|
|
114
118
|
end
|
|
115
119
|
end
|
|
116
120
|
|
|
121
|
+
# rubocop:disable Naming/VariableNumber
|
|
117
122
|
def self.rails_version_less_than_4_1_1
|
|
118
123
|
rails_version_less_than("4.1.1")
|
|
119
124
|
end
|
|
125
|
+
# rubocop:enable Naming/VariableNumber
|
|
120
126
|
|
|
121
127
|
module Required
|
|
122
128
|
def required(arg_name)
|
|
@@ -152,15 +158,29 @@ module ReactOnRails
|
|
|
152
158
|
end
|
|
153
159
|
|
|
154
160
|
def self.gem_available?(name)
|
|
155
|
-
Gem
|
|
161
|
+
Gem.loaded_specs[name].present?
|
|
156
162
|
rescue Gem::LoadError
|
|
157
163
|
false
|
|
158
164
|
rescue StandardError
|
|
159
165
|
Gem.available?(name).present?
|
|
160
166
|
end
|
|
161
167
|
|
|
168
|
+
# Todo -- remove this for v13, as we don't need both boolean and number
|
|
162
169
|
def self.react_on_rails_pro?
|
|
163
|
-
@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
|
|
164
184
|
end
|
|
165
185
|
|
|
166
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?
|
|
@@ -28,10 +32,10 @@ module ReactOnRails
|
|
|
28
32
|
# Next line will throw if the file or manifest does not exist
|
|
29
33
|
hashed_bundle_name = Webpacker.manifest.lookup!(bundle_name)
|
|
30
34
|
|
|
31
|
-
#
|
|
32
|
-
#
|
|
33
|
-
#
|
|
34
|
-
# would mean that the bundle is created by
|
|
35
|
+
# Support for hashing the server-bundle and having that built
|
|
36
|
+
# the webpack-dev-server is provided by the config value
|
|
37
|
+
# "same_bundle_for_client_and_server" where a value of true
|
|
38
|
+
# would mean that the bundle is created by the webpack-dev-server
|
|
35
39
|
is_server_bundle = bundle_name == ReactOnRails.configuration.server_bundle_js_file
|
|
36
40
|
|
|
37
41
|
if Webpacker.dev_server.running? && (!is_server_bundle ||
|
data/lib/tasks/assets.rake
CHANGED
|
@@ -6,40 +6,60 @@
|
|
|
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
|
|
13
12
|
# the build command.
|
|
14
13
|
ENV["WEBPACKER_PRECOMPILE"] = "false"
|
|
15
14
|
|
|
15
|
+
precompile_tasks = lambda {
|
|
16
|
+
Rake::Task["react_on_rails:assets:webpack"].invoke
|
|
17
|
+
puts "Invoking task webpacker:clean from React on Rails"
|
|
18
|
+
|
|
19
|
+
# VERSIONS is per the rails/webpacker clean method definition.
|
|
20
|
+
# We set it very big so that it is not used, and then clean just
|
|
21
|
+
# removes files older than 1 hour.
|
|
22
|
+
versions = 100_000
|
|
23
|
+
Rake::Task["webpacker:clean"].invoke(versions)
|
|
24
|
+
}
|
|
25
|
+
|
|
16
26
|
if Rake::Task.task_defined?("assets:precompile")
|
|
17
27
|
Rake::Task["assets:precompile"].enhance do
|
|
18
|
-
|
|
19
|
-
puts "Invoking task webpacker:clean from React on Rails"
|
|
20
|
-
Rake::Task["webpacker:clean"].invoke
|
|
28
|
+
precompile_tasks.call
|
|
21
29
|
end
|
|
22
30
|
else
|
|
23
|
-
Rake::Task.define_task("assets:precompile"
|
|
24
|
-
|
|
31
|
+
Rake::Task.define_task("assets:precompile") do
|
|
32
|
+
precompile_tasks.call
|
|
33
|
+
end
|
|
25
34
|
end
|
|
26
35
|
end
|
|
27
36
|
|
|
28
37
|
# Sprockets independent tasks
|
|
38
|
+
# rubocop:disable Metrics/BlockLength
|
|
29
39
|
namespace :react_on_rails do
|
|
30
40
|
namespace :assets do
|
|
31
41
|
desc <<-DESC.strip_heredoc
|
|
32
|
-
Compile assets with webpack
|
|
33
|
-
Uses command defined with ReactOnRails.configuration.build_production_command
|
|
34
|
-
sh "#{ReactOnRails::Utils.prepend_cd_node_modules_directory('<ReactOnRails.configuration.build_production_command>')}"
|
|
35
|
-
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
|
|
36
46
|
configuration file config/webpack/production.js exists.
|
|
37
47
|
DESC
|
|
38
48
|
task webpack: :locale do
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
|
43
63
|
else
|
|
44
64
|
msg = <<~MSG
|
|
45
65
|
React on Rails is aborting webpack compilation from task react_on_rails:assets:webpack
|
|
@@ -55,3 +75,4 @@ namespace :react_on_rails do
|
|
|
55
75
|
end
|
|
56
76
|
end
|
|
57
77
|
end
|
|
78
|
+
# rubocop:enable Metrics/BlockLength
|
data/package.json
CHANGED
|
@@ -1,56 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-on-rails",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.1.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/examples.rake
CHANGED
data/rakelib/lint.rake
CHANGED
|
@@ -2,18 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
require_relative "task_helpers"
|
|
4
4
|
|
|
5
|
-
namespace :lint do
|
|
5
|
+
namespace :lint do
|
|
6
6
|
include ReactOnRails::TaskHelpers
|
|
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 # rubocop:disable Metrics/BlockLength
|
|
|
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).
|
|
@@ -19,19 +28,11 @@ which are installed via `bundle install` and `yarn`
|
|
|
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,19 +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 = "$(yarn bin)/release-it"
|
|
61
|
+
release_it_command = +"$(yarn bin)/release-it"
|
|
64
62
|
release_it_command << " #{npm_version}" unless npm_version.strip.empty?
|
|
65
63
|
release_it_command << " --non-interactive --npm.publish"
|
|
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
|
-
unless is_dry_run
|
|
71
|
-
|
|
72
|
-
|
|
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
|
|
73
79
|
end
|
|
74
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
|