react_on_rails 11.1.8 → 12.0.0.pre.beta.1

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.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +320 -0
  3. data/.eslintignore +2 -1
  4. data/.eslintrc +30 -2
  5. data/.github/FUNDING.yml +1 -0
  6. data/.gitignore +3 -1
  7. data/.prettierignore +10 -0
  8. data/.prettierrc +23 -0
  9. data/.release-it.json +3 -0
  10. data/.rubocop.yml +37 -11
  11. data/.travis.yml +10 -20
  12. data/CHANGELOG.md +89 -3
  13. data/CONTRIBUTING.md +61 -80
  14. data/Gemfile +3 -5
  15. data/{COMM-LICENSE → REACT-ON-RAILS-PRO-LICENSE} +6 -9
  16. data/README.md +121 -71
  17. data/Rakefile +0 -7
  18. data/SUMMARY.md +10 -12
  19. data/book.json +5 -5
  20. data/docs/additional-reading/asset-pipeline.md +8 -16
  21. data/docs/additional-reading/images.md +1 -1
  22. data/docs/additional-reading/rails_view_rendering_from_inline_javascript.md +2 -1
  23. data/docs/additional-reading/react-helmet.md +30 -10
  24. data/docs/additional-reading/react-router.md +52 -75
  25. data/docs/additional-reading/server-rendering-tips.md +12 -7
  26. data/docs/additional-reading/upgrade-webpacker-v3-to-v4.md +10 -0
  27. data/docs/api/javascript-api.md +3 -3
  28. data/docs/api/redux-store-api.md +4 -2
  29. data/docs/api/view-helpers-api.md +17 -14
  30. data/docs/basics/configuration.md +64 -61
  31. data/docs/basics/deployment.md +1 -2
  32. data/docs/basics/i18n.md +44 -22
  33. data/docs/basics/installation-into-an-existing-rails-app.md +2 -2
  34. data/docs/basics/minitest-configuration.md +31 -0
  35. data/docs/basics/react-server-rendering.md +1 -1
  36. data/docs/basics/recommended-project-structure.md +1 -1
  37. data/docs/basics/{generator-functions-and-railscontext.md → render-functions-and-railscontext.md} +59 -21
  38. data/docs/basics/rspec-configuration.md +2 -2
  39. data/docs/basics/upgrading-react-on-rails.md +61 -3
  40. data/docs/basics/webpack-configuration.md +15 -1
  41. data/docs/contributor-info/errors-with-hooks.md +45 -0
  42. data/docs/contributor-info/pull-requests.md +44 -0
  43. data/docs/misc/doctrine.md +1 -1
  44. data/docs/{misc-pending → outdated}/code-splitting.md +13 -9
  45. data/docs/{additional-reading → outdated}/heroku-deployment.md +0 -6
  46. data/docs/{basics → outdated}/how-react-on-rails-works.md +3 -3
  47. data/docs/{misc-pending → outdated}/manual-installation-overview.md +5 -5
  48. data/docs/{additional-reading → outdated}/rails-assets-relative-paths.md +3 -3
  49. data/docs/{misc-pending → outdated}/rails-assets.md +4 -7
  50. data/docs/{misc → outdated}/rails3.md +0 -0
  51. data/docs/testimonials/hvmn.md +3 -3
  52. data/docs/testimonials/resortpass.md +13 -0
  53. data/docs/testimonials/testimonials.md +11 -1
  54. data/docs/tutorial.md +69 -28
  55. data/jest.config.js +4 -0
  56. data/lib/generators/react_on_rails/base_generator.rb +2 -2
  57. data/lib/generators/react_on_rails/dev_tests_generator.rb +2 -1
  58. data/lib/generators/react_on_rails/generator_helper.rb +4 -6
  59. data/lib/generators/react_on_rails/install_generator.rb +2 -0
  60. data/lib/generators/react_on_rails/templates/base/base/Procfile.dev +3 -1
  61. data/lib/generators/react_on_rails/templates/base/base/Procfile.dev-hmr +18 -0
  62. data/lib/generators/react_on_rails/templates/base/base/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx +20 -40
  63. data/lib/generators/react_on_rails/templates/redux/base/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx +4 -8
  64. data/lib/generators/react_on_rails/templates/redux/base/app/javascript/bundles/HelloWorld/store/helloWorldStore.js +1 -3
  65. data/lib/react_on_rails.rb +4 -1
  66. data/lib/react_on_rails/configuration.rb +15 -23
  67. data/lib/react_on_rails/error.rb +2 -0
  68. data/lib/react_on_rails/git_utils.rb +2 -0
  69. data/lib/react_on_rails/helper.rb +111 -162
  70. data/lib/react_on_rails/json_output.rb +1 -1
  71. data/lib/react_on_rails/json_parse_error.rb +2 -0
  72. data/lib/react_on_rails/locales/base.rb +142 -0
  73. data/lib/react_on_rails/locales/to_js.rb +37 -0
  74. data/lib/react_on_rails/locales/to_json.rb +27 -0
  75. data/lib/react_on_rails/prerender_error.rb +11 -15
  76. data/lib/react_on_rails/react_component/render_options.rb +4 -0
  77. data/lib/react_on_rails/server_rendering_js_code.rb +42 -0
  78. data/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb +71 -51
  79. data/lib/react_on_rails/test_helper/ensure_assets_compiled.rb +7 -8
  80. data/lib/react_on_rails/utils.rb +15 -20
  81. data/lib/react_on_rails/version.rb +1 -1
  82. data/lib/react_on_rails/version_checker.rb +5 -1
  83. data/lib/react_on_rails/webpacker_utils.rb +16 -2
  84. data/lib/tasks/assets.rake +5 -45
  85. data/lib/tasks/locale.rake +8 -2
  86. data/package-scripts.yml +49 -0
  87. data/package.json +41 -31
  88. data/rakelib/dummy_apps.rake +1 -9
  89. data/rakelib/example_type.rb +3 -1
  90. data/rakelib/examples.rake +3 -0
  91. data/rakelib/lint.rake +2 -7
  92. data/rakelib/node_package.rake +2 -2
  93. data/rakelib/release.rake +3 -8
  94. data/rakelib/run_rspec.rake +5 -18
  95. data/react_on_rails.gemspec +3 -5
  96. data/tsconfig.json +14 -0
  97. data/webpackConfigLoader.js +5 -4
  98. data/yarn.lock +7042 -2327
  99. metadata +39 -57
  100. data/Gemfile.rails32 +0 -74
  101. data/docs/additional-reading/babel.md +0 -5
  102. data/docs/additional-reading/hot-reloading-rails-development-asset-pipeline.md +0 -47
  103. data/docs/api/ruby-api-hot-reload-view-helpers.md +0 -44
  104. data/lib/generators/react_on_rails/templates/base/base/Procfile.dev-server +0 -12
  105. data/lib/react_on_rails/assets_precompile.rb +0 -150
  106. data/lib/react_on_rails/locales_to_js.rb +0 -136
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ReactOnRails
4
- VERSION = "11.1.8".freeze
4
+ VERSION = "12.0.0-beta.1"
5
5
  end
@@ -5,7 +5,8 @@ module ReactOnRails
5
5
  # against each otherat runtime.
6
6
  class VersionChecker
7
7
  attr_reader :node_package_version
8
- MAJOR_MINOR_PATCH_VERSION_REGEX = /(\d+)\.(\d+)\.(\d+)/
8
+
9
+ MAJOR_MINOR_PATCH_VERSION_REGEX = /(\d+)\.(\d+)\.(\d+)/.freeze
9
10
 
10
11
  def self.build
11
12
  new(NodePackageVersion.build)
@@ -20,6 +21,7 @@ module ReactOnRails
20
21
  # warning if they do not.
21
22
  def raise_if_gem_and_node_package_versions_differ
22
23
  return if node_package_version.relative_path?
24
+
23
25
  node_major_minor_patch = node_package_version.major_minor_patch
24
26
  gem_major_minor_patch = gem_major_minor_patch_version
25
27
  versions_match = node_major_minor_patch[0] == gem_major_minor_patch[0] &&
@@ -99,10 +101,12 @@ module ReactOnRails
99
101
 
100
102
  def major_minor_patch
101
103
  return if relative_path?
104
+
102
105
  match = raw.match(MAJOR_MINOR_PATCH_VERSION_REGEX)
103
106
  unless match
104
107
  raise ReactOnRails::Error, "Cannot parse version number '#{raw}' (wildcard versions are not supported)"
105
108
  end
109
+
106
110
  [match[1], match[2], match[3]]
107
111
  end
108
112
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ReactOnRails
2
4
  module WebpackerUtils
3
5
  def self.using_webpacker?
@@ -6,17 +8,28 @@ module ReactOnRails
6
8
 
7
9
  def self.dev_server_running?
8
10
  return false unless using_webpacker?
11
+
9
12
  Webpacker.dev_server.running?
10
13
  end
11
14
 
12
- def self.bundle_js_file_path_from_webpacker(bundle_name)
15
+ # This returns either a URL for the webpack-dev-server, non-server bundle or
16
+ # the hashed server bundle if using the same bundle for the client.
17
+ # Otherwise returns a file path.
18
+ def self.bundle_js_uri_from_webpacker(bundle_name)
13
19
  # Note Webpacker 3.4.3 manifest lookup is inside of the public_output_path
14
20
  # [2] (pry) ReactOnRails::WebpackerUtils: 0> Webpacker.manifest.lookup("app-bundle.js")
15
21
  # "/webpack/development/app-bundle-c1d2b6ab73dffa7d9c0e.js"
16
22
  # Next line will throw if the file or manifest does not exist
17
23
  hashed_bundle_name = Webpacker.manifest.lookup!(bundle_name)
18
24
 
19
- if Webpacker.dev_server.running?
25
+ # support for hashing the server-bundle and having that built
26
+ # by a webpack watch process and not served by the webpack-dev-server, then we
27
+ # need an extra config value "same_bundle_for_client_and_server" where a value of false
28
+ # would mean that the bundle is created by a separate webpack watch process.
29
+ is_server_bundle = bundle_name == ReactOnRails.configuration.server_bundle_js_file
30
+
31
+ if Webpacker.dev_server.running? && (!is_server_bundle ||
32
+ ReactOnRails.configuration.same_bundle_for_client_and_server)
20
33
  "#{Webpacker.dev_server.protocol}://#{Webpacker.dev_server.host_with_port}#{hashed_bundle_name}"
21
34
  else
22
35
  File.expand_path(File.join("public", hashed_bundle_name)).to_s
@@ -44,6 +57,7 @@ module ReactOnRails
44
57
 
45
58
  def self.check_manifest_not_cached
46
59
  return unless using_webpacker? && Webpacker.config.cache_manifest?
60
+
47
61
  msg = <<-MSG.strip_heredoc
48
62
  ERROR: you have enabled cache_manifest in the #{Rails.env} env when using the
49
63
  ReactOnRails::TestHelper.configure_rspec_to_compile_assets helper
@@ -1,48 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "react_on_rails/assets_precompile"
4
3
  require "active_support"
5
4
 
6
- if defined?(Sprockets)
7
- namespace :react_on_rails do
8
- namespace :assets do
9
- desc "Creates non-digested symlinks for the assets in the public asset dir"
10
- task symlink_non_digested_assets: :"assets:environment" do
11
- ReactOnRails::AssetsPrecompile.new.symlink_non_digested_assets
12
- end
13
-
14
- desc "Cleans all broken symlinks for the assets in the public asset dir"
15
- task delete_broken_symlinks: :"assets:environment" do
16
- ReactOnRails::AssetsPrecompile.new.delete_broken_symlinks
17
- end
18
-
19
- # In this task, set prerequisites for the assets:precompile task
20
- desc <<-DESC.strip_heredoc
21
- Create webpack assets before calling assets:environment
22
- The webpack task must run before assets:environment task.
23
- Otherwise Sprockets cannot find the files that webpack produces.
24
- This is the secret sauce for how a Heroku deployment knows to create the webpack generated JavaScript files.
25
- DESC
26
- task compile_environment: :webpack do
27
- Rake::Task["assets:environment"].invoke
28
- end
29
-
30
- desc "Delete assets created with webpack, in the generated assetst directory (/app/assets/webpack)"
31
- task clobber: :environment do
32
- ReactOnRails::AssetsPrecompile.new.clobber
33
- end
34
- end
5
+ if Rake::Task.task_defined?("assets:precompile")
6
+ Rake::Task["assets:precompile"].enhance do
7
+ Rake::Task["react_on_rails:assets:webpack"].invoke
35
8
  end
36
-
37
- # These tasks run as pre-requisites of assets:precompile.
38
- # Note, it's not possible to refer to ReactOnRails configuration values at this point.
39
- Rake::Task["assets:precompile"]
40
- .clear_prerequisites
41
- .enhance([:environment, "react_on_rails:assets:compile_environment"])
42
- .enhance do
43
- Rake::Task["react_on_rails:assets:symlink_non_digested_assets"].invoke
44
- Rake::Task["react_on_rails:assets:delete_broken_symlinks"].invoke
45
- end
9
+ else
10
+ Rake::Task.define_task("assets:precompile" => ["react_on_rails:assets:webpack"])
46
11
  end
47
12
 
48
13
  # Sprockets independent tasks
@@ -55,11 +20,6 @@ namespace :react_on_rails do
55
20
  sh "#{ReactOnRails::Utils.prepend_cd_node_modules_directory('<ReactOnRails.configuration.build_production_command>')}"
56
21
  DESC
57
22
  task webpack: :locale do
58
- if Rake::Task.task_defined?("webpacker:compile")
59
- # TODO: Eventually, this will need reconsideration if we use any of the Webpacker compilation
60
- Rake::Task["webpacker:compile"].clear
61
- end
62
-
63
23
  if ReactOnRails.configuration.build_production_command.present?
64
24
  sh ReactOnRails::Utils.prepend_cd_node_modules_directory(
65
25
  ReactOnRails.configuration.build_production_command
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "react_on_rails/locales_to_js"
3
+ require "react_on_rails/locales/base"
4
+ require "react_on_rails/locales/to_js"
5
+ require "react_on_rails/locales/to_json"
4
6
  require "active_support"
5
7
 
6
8
  namespace :react_on_rails do
@@ -10,6 +12,10 @@ namespace :react_on_rails do
10
12
  the "ReactOnRails.configuration.i18n_dir".
11
13
  DESC
12
14
  task locale: :environment do
13
- ReactOnRails::LocalesToJs.new
15
+ if ReactOnRails.configuration.i18n_output_format&.downcase == "js"
16
+ ReactOnRails::Locales::ToJs.new
17
+ else
18
+ ReactOnRails::Locales::ToJson.new
19
+ end
14
20
  end
15
21
  end
@@ -0,0 +1,49 @@
1
+ scripts:
2
+ lint:
3
+ description: Run all linters (eslint, tsc)
4
+ script: concurrently --prefix "[{name}]" --names "ESLINT" -c "blue,yellow,magenta,orange" "nps eslint"
5
+
6
+ eslint:
7
+ default:
8
+ description: Run eslint.
9
+ script: eslint . --ext ".js,.jsx,.ts"
10
+ fix:
11
+ description: Run eslint and auto-fix.
12
+ script: nps "eslint --fix"
13
+ debug:
14
+ description: Run eslint in debug mode.
15
+ script: DEBUG=eslint:cli-engine nps eslint
16
+
17
+ format:
18
+ default:
19
+ description: Format files using prettier.
20
+ script: concurrently --prefix "[{name}]" --names "ts,js,json" -c "yellow,magenta,green" "nps format.js" "nps format.json"
21
+ listDifferent:
22
+ description: Check that all files were formatted using prettier.
23
+ script: |
24
+ concurrently \
25
+ --prefix "[{name}]" \
26
+ --names "ts,js,json" \
27
+ -c "yellow,magenta" \
28
+ "nps format.js.listDifferent" \
29
+ "nps format.json.listDifferent"
30
+ js:
31
+ default:
32
+ description: Run prettier-eslint on JS.
33
+ #script: prettier "packages/**/*.@(js|jsx)" "spec/dummy/client/app/**/*.@(js|jsx)" "webpack.config.babel.js" "webpack/**/*.js" --write
34
+ script: prettier "**/*.@(js|jsx)" --write
35
+ listDifferent:
36
+ description: Check if any JS files would change by running prettier-eslint.
37
+ # script: prettier "**/*.@(js|jsx)" "webpack.config.babel.js" "webpack/**/*.js" --list-different
38
+ script: prettier "**/*.@(js|jsx)" --list-different
39
+ json:
40
+ default:
41
+ description: Run prettier on JSON files.
42
+ script: rm -rf packages/vm-renderer/tests/tmp && prettier "**/*.json" --write
43
+ listDifferent:
44
+ description: Check if any JSON files would change by running prettier-eslint.
45
+ script: prettier "**/*.json" --list-different
46
+
47
+ renderer:
48
+ description: Starts the node renderer.
49
+ script: node renderer.js
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-on-rails",
3
- "version": "11.1.8",
3
+ "version": "12.0.0-beta.1",
4
4
  "description": "react-on-rails JavaScript for react_on_rails Ruby gem",
5
5
  "main": "node_package/lib/ReactOnRails.js",
6
6
  "directories": {
@@ -9,62 +9,75 @@
9
9
  "devDependencies": {
10
10
  "@babel/cli": "^7.0.0",
11
11
  "@babel/core": "^7.0.0",
12
- "@babel/plugin-transform-flow-strip-types": "^7.0.0",
13
12
  "@babel/plugin-transform-runtime": "^7.0.0",
13
+ "@babel/plugin-transform-typescript": "^7.8.7",
14
14
  "@babel/preset-env": "^7.0.0",
15
15
  "@babel/preset-react": "^7.0.0",
16
16
  "@babel/types": "^7.0.0",
17
+ "@types/jest": "^25.1.4",
18
+ "@types/node": "^13.9.0",
19
+ "@types/react": "^16.9.23",
20
+ "@types/react-dom": "^16.9.5",
21
+ "@types/turbolinks": "^5.2.0",
22
+ "@typescript-eslint/eslint-plugin": "^2.23.0",
23
+ "@typescript-eslint/parser": "^2.23.0",
17
24
  "babel-loader": "^8.0.2",
18
- "babel-tape-runner": "^3.0.0",
19
- "babelify": "^7.3.0",
25
+ "babelify": "^10.0.0",
20
26
  "blue-tape": "^1.0.0",
21
27
  "create-react-class": "^15.6.0",
22
- "eslint": "^3.19.0",
23
- "eslint-config-shakacode": "^15.0.0",
28
+ "eslint": "^6.8.0",
29
+ "eslint-config-prettier": "^6.10.1",
30
+ "eslint-config-shakacode": "^16.0.1",
24
31
  "eslint-plugin-import": "^2.6.1",
25
- "eslint-plugin-jsx-a11y": "^5.1.1",
32
+ "eslint-plugin-jsx-a11y": "^6.1.2",
33
+ "eslint-plugin-prettier": "^3.0.0",
26
34
  "eslint-plugin-react": "^7.1.0",
27
- "flow-bin": "^0.51.1",
35
+ "jest": "^25.1.0",
28
36
  "jsdom": "^11.1.0",
37
+ "nps": "^5.9.3",
38
+ "prettier": "^2.0.1",
39
+ "prettier-eslint-cli": "^5.0.0",
29
40
  "prop-types": "^15.5.10",
30
- "react": "^15.6.1",
31
- "react-dom": "^15.6.1",
41
+ "react": "^16.5.2",
42
+ "react-dom": "^16.5.2",
32
43
  "react-transform-hmr": "^1.0.4",
33
- "redux": "^3.7.2",
34
- "release-it": "^2.8.2",
35
- "tap-spec": "^4.1.1",
36
- "tape": "^4.7.0",
44
+ "redux": "^4.0.1",
45
+ "release-it": "^8.2.0",
46
+ "ts-jest": "^25.2.1",
47
+ "tslint-config-prettier": "^1.18.0",
48
+ "typescript": "^3.8.3",
37
49
  "webpack": "^3.4.1",
38
50
  "webpack-manifest-plugin": "^1.2.1"
39
51
  },
52
+ "dependencies": {
53
+ "@babel/runtime-corejs3": "^7.9.6",
54
+ "concurrently": "^5.1.0"
55
+ },
40
56
  "peerDependencies": {
41
57
  "js-yaml": ">= 3.0.0",
42
- "react": ">= 0.14",
43
- "react-dom": ">= 0.14"
58
+ "react": ">= 16",
59
+ "react-dom": ">= 16"
44
60
  },
45
61
  "files": [
46
62
  "node_package/lib",
47
63
  "webpackConfigLoader.js"
48
64
  ],
49
65
  "scripts": {
50
- "test": "babel-tape-runner -r node_package/tests/helpers/test_helper.js node_package/tests/*.js | tap-spec",
66
+ "test": "jest node_package/tests",
51
67
  "clean": "rm -rf node_package/lib",
68
+ "start": "nps",
52
69
  "prepare": "yarn run build",
53
- "prepublish": "npm run prepare",
54
- "babel": "babel --out-dir node_package/lib node_package/src",
55
- "build": "yarn run clean && yarn run babel",
56
- "build-watch": "babel --watch --out-dir node_package/lib node_package/src",
57
- "eslint": "eslint .",
58
- "flow": "flow check node_package",
59
- "lint": "yarn run eslint && yarn run flow",
60
- "check": "yarn run lint && yarn run flow && yarn run test",
70
+ "build": "yarn run clean && yarn run tsc --declaration",
71
+ "build-watch": "yarn run clean && yarn run tsc --watch",
72
+ "lint": "nps eslint",
73
+ "check": "yarn run lint && yarn run test && yarn run type-check",
74
+ "type-check": "yarn run tsc --noEmit --noErrorTruncation",
61
75
  "prerelease": "yarn run check && yarn run clean && yarn run build",
62
76
  "release:patch": "node_package/scripts/release patch",
63
77
  "release:minor": "node_package/scripts/release minor",
64
78
  "release:major": "node_package/scripts/release major",
65
79
  "dummy:install": "rake dummy_apps",
66
- "dummy:spec": "rake run_rspec:dummy",
67
- "install-react-on-rails": "yarn link"
80
+ "dummy:spec": "rake run_rspec:dummy"
68
81
  },
69
82
  "repository": {
70
83
  "type": "git",
@@ -83,8 +96,5 @@
83
96
  "bugs": {
84
97
  "url": "https://github.com/shakacode/react_on_rails/issues"
85
98
  },
86
- "homepage": "https://github.com/shakacode/react_on_rails#readme",
87
- "dependencies": {
88
- "@babel/runtime-corejs2": "^7.0.0"
89
- }
99
+ "homepage": "https://github.com/shakacode/react_on_rails#readme"
90
100
  }
@@ -8,6 +8,7 @@ namespace :dummy_apps do
8
8
  task :yarn_install do
9
9
  yarn_install_cmd = "yarn install --mutex network"
10
10
  sh_in_dir(dummy_app_dir, yarn_install_cmd)
11
+ sh_in_dir(dummy_app_dir, "yalc link react-on-rails")
11
12
  end
12
13
 
13
14
  task dummy_app: [:yarn_install] do
@@ -15,15 +16,6 @@ namespace :dummy_apps do
15
16
  bundle_install_in(dummy_app_dir)
16
17
  end
17
18
 
18
- task :dummy_no_webpacker do
19
- npm_install_cmd = "npm install"
20
- install_react_on_rails_cmd = "yarn run install-react-on-rails"
21
- dummy_app_dir = File.join(gem_root, "spec/dummy_no_webpacker")
22
- sh_in_dir(File.join(gem_root, "spec/dummy_no_webpacker/client"), npm_install_cmd)
23
- sh_in_dir(dummy_app_dir, install_react_on_rails_cmd)
24
- sh_in_dir(dummy_app_dir, "BUNDLE_GEMFILE=Gemfile.rails32 bundle install")
25
- end
26
-
27
19
  task dummy_apps: %i[dummy_app node_package] do
28
20
  puts "Prepared all Dummy Apps"
29
21
  end
@@ -49,8 +49,10 @@ module ReactOnRails
49
49
  end
50
50
 
51
51
  # Options we pass when running `rails new` from the command-line.
52
+ attr_writer :rails_options
53
+
52
54
  def rails_options
53
- "--skip-bundle --skip-spring --skip-git --skip-test-unit --skip-active-record"
55
+ @rails_options ||= "--skip-bundle --skip-spring --skip-git --skip-test-unit --skip-active-record"
54
56
  end
55
57
 
56
58
  %w[gen clobber npm_install build_webpack_bundles].each do |task_type|
@@ -6,6 +6,8 @@
6
6
  # Also see example_type.rb
7
7
 
8
8
  require "yaml"
9
+ require 'rails/version'
10
+
9
11
  require_relative "example_type"
10
12
  require_relative "task_helpers"
11
13
 
@@ -28,6 +30,7 @@ namespace :examples do # rubocop:disable Metrics/BlockLength
28
30
  desc "Generates #{example_type.name_pretty}"
29
31
  task example_type.gen_task_name_short => example_type.clobber_task_name do
30
32
  mkdir_p(example_type.dir)
33
+ example_type.rails_options += " --webpack" if Rails.version >= "5.1" && Rails.version < "6"
31
34
  sh_in_dir(examples_dir, "rails new #{example_type.name} #{example_type.rails_options}")
32
35
  sh_in_dir(example_type.dir, "touch .gitignore")
33
36
  sh_in_dir(example_type.dir, "rake webpacker:install")
@@ -26,13 +26,8 @@ namespace :lint do # rubocop:disable Metrics/BlockLength
26
26
  sh_in_dir(gem_root, "yarn run eslint")
27
27
  end
28
28
 
29
- desc "Run flow from shell"
30
- task :flow do
31
- sh_in_dir(gem_root, "yarn run flow")
32
- end
33
-
34
- desc "Run all eslint, flow, rubocop linters. Skip ruby-lint and scss"
35
- task lint: %i[eslint flow rubocop] do
29
+ desc "Run all eslint & rubocop linters. Skip ruby-lint and scss"
30
+ task lint: %i[eslint rubocop] do
36
31
  puts "Completed all linting"
37
32
  end
38
33
  end
@@ -6,8 +6,8 @@ namespace :node_package do
6
6
  include ReactOnRails::TaskHelpers
7
7
 
8
8
  task :build do
9
- puts "Building Node Package and running 'yarn link'"
10
- sh "yarn run build && yarn link"
9
+ puts "Building Node Package and running 'yalc publish'"
10
+ sh "yarn run build && yalc publish"
11
11
  end
12
12
  end
13
13
 
@@ -60,20 +60,15 @@ task :release, %i[gem_version dry_run tools_install] do |_t, args|
60
60
  sh_in_dir(gem_root, "git add .")
61
61
 
62
62
  # Will bump the yarn version, commit, tag the commit, push to repo, and release on yarn
63
- release_it_command = "$(yarn bin)/release-it --non-interactive --npm.publish".dup
64
- release_it_command << " --dry-run --verbose" if is_dry_run
63
+ release_it_command = "$(yarn bin)/release-it".dup
65
64
  release_it_command << " #{npm_version}" unless npm_version.strip.empty?
65
+ release_it_command << " --non-interactive --npm.publish"
66
+ release_it_command << " --dry-run --verbose" if is_dry_run
66
67
  sh_in_dir(gem_root, release_it_command)
67
68
 
68
69
  # Release the new gem version
69
70
  unless is_dry_run
70
71
  sh_in_dir(gem_root, "gem release")
71
-
72
- # Update master with new npm version
73
- sleep 5 # short pause to make sure npmjs has time to update
74
- sh_in_dir(File.join(gem_root, "spec", "dummy", "client"), "yarn add react-on-rails@#{npm_version} --exact")
75
- sh_in_dir(gem_root, "git commit -am 'Updated spec/dummy/client/package.json latest version'")
76
- sh_in_dir(gem_root, "git push")
77
72
  end
78
73
  end
79
74
  # rubocop:enable Metrics/BlockLength