react_on_rails 13.4.0 → 14.0.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/CHANGELOG.md +24 -2
- data/Gemfile.development_dependencies +10 -8
- data/README.md +2 -2
- data/lib/generators/react_on_rails/base_generator.rb +10 -2
- data/lib/generators/react_on_rails/dev_tests_generator.rb +1 -1
- data/lib/generators/react_on_rails/templates/base/base/config/shakapacker.yml +1 -1
- data/lib/generators/react_on_rails/templates/dev_tests/spec/rails_helper.rb +2 -2
- data/lib/generators/react_on_rails/templates/dev_tests/spec/system/hello_world_spec.rb +1 -1
- data/lib/react_on_rails/configuration.rb +39 -25
- data/lib/react_on_rails/git_utils.rb +3 -3
- data/lib/react_on_rails/helper.rb +2 -2
- data/lib/react_on_rails/json_output.rb +0 -17
- data/lib/react_on_rails/locales/base.rb +4 -4
- data/lib/react_on_rails/locales/to_js.rb +1 -1
- data/lib/react_on_rails/packs_generator.rb +2 -4
- data/lib/react_on_rails/react_component/render_options.rb +1 -1
- data/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb +9 -9
- data/lib/react_on_rails/test_helper/webpack_assets_status_checker.rb +3 -3
- data/lib/react_on_rails/test_helper.rb +2 -2
- data/lib/react_on_rails/utils.rb +2 -8
- data/lib/react_on_rails/version.rb +1 -1
- data/lib/react_on_rails/version_checker.rb +2 -2
- data/lib/react_on_rails/webpacker_utils.rb +6 -0
- data/lib/tasks/assets.rake +1 -1
- data/react_on_rails.gemspec +4 -4
- metadata +4 -132
- data/.bookignore +0 -15
- data/.circleci/config.yml +0 -338
- data/.coveralls.yml +0 -1
- data/.dockerignore +0 -2
- data/.eslintignore +0 -17
- data/.eslintrc +0 -53
- data/.github/FUNDING.yml +0 -1
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -23
- data/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- data/.github/PULL_REQUEST_TEMPLATE.md +0 -19
- data/.github/workflows/lint-js-and-ruby.yml +0 -54
- data/.github/workflows/main.yml +0 -183
- data/.github/workflows/package-js-tests.yml +0 -35
- data/.github/workflows/rspec-package-specs.yml +0 -46
- data/.gitignore +0 -33
- data/.npmignore +0 -22
- data/.prettierignore +0 -14
- data/.prettierrc +0 -20
- data/.rspec +0 -2
- data/.rubocop.yml +0 -134
- data/.scss-lint.yml +0 -205
- data/.travis.yml +0 -61
- data/book.json +0 -18
- data/docs/additional-details/generator-details.md +0 -56
- data/docs/additional-details/manual-installation-overview.md +0 -30
- data/docs/additional-details/migrating-from-react-rails.md +0 -17
- data/docs/additional-details/recommended-project-structure.md +0 -69
- data/docs/additional-details/tips-for-usage-with-sp6.md +0 -15
- data/docs/additional-details/updating-dependencies.md +0 -31
- data/docs/additional-details/upgrade-webpacker-v3-to-v4.md +0 -10
- data/docs/api/javascript-api.md +0 -99
- data/docs/api/redux-store-api.md +0 -102
- data/docs/api/view-helpers-api.md +0 -133
- data/docs/contributor-info/errors-with-hooks.md +0 -45
- data/docs/contributor-info/generator-testing.md +0 -11
- data/docs/contributor-info/linters.md +0 -68
- data/docs/contributor-info/pull-requests.md +0 -42
- data/docs/contributor-info/releasing.md +0 -76
- data/docs/deployment/elastic-beanstalk.md +0 -63
- data/docs/deployment/heroku-deployment.md +0 -39
- data/docs/getting-started.md +0 -196
- data/docs/guides/client-vs-server-rendering.md +0 -27
- data/docs/guides/configuration.md +0 -289
- data/docs/guides/deployment.md +0 -5
- data/docs/guides/file-system-based-automated-bundle-generation.md +0 -197
- data/docs/guides/hmr-and-hot-reloading-with-the-webpack-dev-server.md +0 -104
- data/docs/guides/how-react-on-rails-works.md +0 -44
- data/docs/guides/how-to-conditionally-server-render-based-on-device-type.md +0 -40
- data/docs/guides/how-to-use-different-files-for-client-and-server-rendering.md +0 -98
- data/docs/guides/i18n.md +0 -87
- data/docs/guides/installation-into-an-existing-rails-app.md +0 -66
- data/docs/guides/minitest-configuration.md +0 -31
- data/docs/guides/rails-webpacker-react-integration-options.md +0 -213
- data/docs/guides/react-on-rails-overview.md +0 -29
- data/docs/guides/react-server-rendering.md +0 -32
- data/docs/guides/render-functions-and-railscontext.md +0 -205
- data/docs/guides/rspec-configuration.md +0 -73
- data/docs/guides/tutorial.md +0 -371
- data/docs/guides/upgrading-react-on-rails.md +0 -304
- data/docs/guides/webpack-configuration.md +0 -42
- data/docs/home.md +0 -23
- data/docs/javascript/angular-js-integration-migration.md +0 -28
- data/docs/javascript/asset-pipeline.md +0 -12
- data/docs/javascript/capistrano-deployment.md +0 -18
- data/docs/javascript/code-splitting.md +0 -165
- data/docs/javascript/converting-from-custom-webpack-config-to-rails-webpacker-config.md +0 -10
- data/docs/javascript/credits.md +0 -10
- data/docs/javascript/foreman-issues.md +0 -15
- data/docs/javascript/images.md +0 -57
- data/docs/javascript/node-dependencies-and-npm.md +0 -19
- data/docs/javascript/react-and-redux.md +0 -36
- data/docs/javascript/react-helmet.md +0 -100
- data/docs/javascript/react-router.md +0 -90
- data/docs/javascript/server-rendering-tips.md +0 -55
- data/docs/javascript/troubleshooting-when-using-shakapacker.md +0 -77
- data/docs/javascript/troubleshooting-when-using-webpacker.md +0 -90
- data/docs/javascript/webpack-v1-notes.md +0 -23
- data/docs/javascript/webpack.md +0 -22
- data/docs/misc/articles.md +0 -20
- data/docs/misc/code_of_conduct.md +0 -13
- data/docs/misc/doctrine.md +0 -77
- data/docs/misc/style.md +0 -33
- data/docs/misc/tips.md +0 -10
- data/docs/outdated/deferred-rendering.md +0 -39
- data/docs/outdated/rails-assets-relative-paths.md +0 -195
- data/docs/outdated/rails-assets.md +0 -77
- data/docs/outdated/rails3.md +0 -9
- data/docs/rails/convert-rails-5-api-only-app.md +0 -19
- data/docs/rails/rails-engine-integration.md +0 -32
- data/docs/rails/rails_view_rendering_from_inline_javascript.md +0 -36
- data/docs/rails/turbolinks.md +0 -124
- data/docs/react-on-rails-pro/react-on-rails-pro.md +0 -43
- data/docs/testimonials/hvmn.md +0 -25
- data/docs/testimonials/resortpass.md +0 -13
- data/docs/testimonials/testimonials.md +0 -28
- data/jest.config.js +0 -4
- data/package-scripts.yml +0 -49
- data/package.json +0 -96
- data/rakelib/docker.rake +0 -26
- data/rakelib/dummy_apps.rake +0 -30
- data/rakelib/example_type.rb +0 -96
- data/rakelib/examples.rake +0 -64
- data/rakelib/examples_config.yml +0 -14
- data/rakelib/lint.rake +0 -30
- data/rakelib/node_package.rake +0 -15
- data/rakelib/release.rake +0 -92
- data/rakelib/run_rspec.rake +0 -103
- data/rakelib/task_helpers.rb +0 -62
- data/script/bootstrap +0 -33
- data/script/release +0 -3
- data/script/setup +0 -23
- data/script/test +0 -38
- data/webpackConfigLoader.js +0 -71
- data/yarn.lock +0 -7010
data/package-scripts.yml
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
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
|
data/package.json
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "react-on-rails",
|
|
3
|
-
"version": "13.4.0",
|
|
4
|
-
"description": "react-on-rails JavaScript for react_on_rails Ruby gem",
|
|
5
|
-
"main": "node_package/lib/ReactOnRails.js",
|
|
6
|
-
"directories": {
|
|
7
|
-
"doc": "docs"
|
|
8
|
-
},
|
|
9
|
-
"devDependencies": {
|
|
10
|
-
"@babel/cli": "^7.20.7",
|
|
11
|
-
"@babel/core": "^7.20.12",
|
|
12
|
-
"@babel/plugin-transform-runtime": "^7.19.6",
|
|
13
|
-
"@babel/plugin-transform-typescript": "^7.20.13",
|
|
14
|
-
"@babel/preset-env": "^7.20.2",
|
|
15
|
-
"@babel/preset-react": "^7.18.6",
|
|
16
|
-
"@babel/types": "^7.20.7",
|
|
17
|
-
"@types/jest": "^28.1.3",
|
|
18
|
-
"@types/react": "^16.14.35",
|
|
19
|
-
"@types/react-dom": "^16.9.17",
|
|
20
|
-
"@types/turbolinks": "^5.2.0",
|
|
21
|
-
"@types/webpack-env": "^1.18.0",
|
|
22
|
-
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
|
23
|
-
"@typescript-eslint/parser": "^4.33.0",
|
|
24
|
-
"babelify": "^10.0.0",
|
|
25
|
-
"blue-tape": "^1.0.0",
|
|
26
|
-
"create-react-class": "^15.7.0",
|
|
27
|
-
"eslint": "^7.32.0",
|
|
28
|
-
"eslint-config-prettier": "^7.0.0",
|
|
29
|
-
"eslint-config-shakacode": "^16.0.1",
|
|
30
|
-
"eslint-plugin-import": "^2.27.5",
|
|
31
|
-
"eslint-plugin-jsx-a11y": "^6.7.1",
|
|
32
|
-
"eslint-plugin-prettier": "^3.4.1",
|
|
33
|
-
"eslint-plugin-react": "^7.32.1",
|
|
34
|
-
"jest": "^28.1.3",
|
|
35
|
-
"jest-environment-jsdom": "^28.1.3",
|
|
36
|
-
"jsdom": "^16.4.0",
|
|
37
|
-
"nps": "^5.9.3",
|
|
38
|
-
"prettier": "^2.8.3",
|
|
39
|
-
"prettier-eslint-cli": "^5.0.0",
|
|
40
|
-
"prop-types": "^15.8.1",
|
|
41
|
-
"react": "^16.14.0",
|
|
42
|
-
"react-dom": "^16.14.0",
|
|
43
|
-
"react-transform-hmr": "^1.0.4",
|
|
44
|
-
"redux": "^4.2.0",
|
|
45
|
-
"ts-jest": "^28.0.8",
|
|
46
|
-
"typescript": "^4.9.4"
|
|
47
|
-
},
|
|
48
|
-
"dependencies": {
|
|
49
|
-
"@babel/runtime-corejs3": "^7.12.5",
|
|
50
|
-
"concurrently": "^5.1.0"
|
|
51
|
-
},
|
|
52
|
-
"peerDependencies": {
|
|
53
|
-
"js-yaml": ">= 3.0.0",
|
|
54
|
-
"react": ">= 16",
|
|
55
|
-
"react-dom": ">= 16"
|
|
56
|
-
},
|
|
57
|
-
"files": [
|
|
58
|
-
"node_package/lib",
|
|
59
|
-
"webpackConfigLoader.js"
|
|
60
|
-
],
|
|
61
|
-
"scripts": {
|
|
62
|
-
"test": "jest node_package/tests",
|
|
63
|
-
"clean": "rm -rf node_package/lib",
|
|
64
|
-
"start": "nps",
|
|
65
|
-
"prepare": "yarn run build",
|
|
66
|
-
"build": "yarn run clean && yarn run tsc --declaration",
|
|
67
|
-
"build-watch": "yarn run clean && yarn run tsc --watch",
|
|
68
|
-
"lint": "nps eslint",
|
|
69
|
-
"check": "yarn run lint && yarn run test && yarn run type-check",
|
|
70
|
-
"type-check": "yarn run tsc --noEmit --noErrorTruncation",
|
|
71
|
-
"prerelease": "yarn run check && yarn run clean && yarn run build",
|
|
72
|
-
"release:patch": "node_package/scripts/release patch",
|
|
73
|
-
"release:minor": "node_package/scripts/release minor",
|
|
74
|
-
"release:major": "node_package/scripts/release major",
|
|
75
|
-
"dummy:install": "rake dummy_apps",
|
|
76
|
-
"dummy:spec": "rake run_rspec:dummy"
|
|
77
|
-
},
|
|
78
|
-
"repository": {
|
|
79
|
-
"type": "git",
|
|
80
|
-
"url": "git+https://github.com/shakacode/react_on_rails.git"
|
|
81
|
-
},
|
|
82
|
-
"keywords": [
|
|
83
|
-
"react",
|
|
84
|
-
"webpack",
|
|
85
|
-
"JavaScript",
|
|
86
|
-
"Ruby",
|
|
87
|
-
"on",
|
|
88
|
-
"Rails"
|
|
89
|
-
],
|
|
90
|
-
"author": "justin.gordon@gmail.com",
|
|
91
|
-
"license": "MIT",
|
|
92
|
-
"bugs": {
|
|
93
|
-
"url": "https://github.com/shakacode/react_on_rails/issues"
|
|
94
|
-
},
|
|
95
|
-
"homepage": "https://github.com/shakacode/react_on_rails#readme"
|
|
96
|
-
}
|
data/rakelib/docker.rake
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
namespace :docker do
|
|
4
|
-
desc "Run Rubocop linter from docker"
|
|
5
|
-
task :rubocop do
|
|
6
|
-
sh "docker-compose run lint rake lint:rubocop"
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
desc "Run scss-lint linter from docker"
|
|
10
|
-
task :scss do
|
|
11
|
-
sh "docker-compose run lint rake lint:scss"
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
desc "Run eslint linter from docker"
|
|
15
|
-
task :eslint do
|
|
16
|
-
sh "docker-compose run lint rake lint:eslint"
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
desc "Run all linting from docker"
|
|
20
|
-
task :lint do
|
|
21
|
-
sh "docker-compose run lint rake lint"
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
desc "Runs all linters from docker. Run `rake -D docker` to see all available lint options"
|
|
26
|
-
task docker: ["docker:lint"]
|
data/rakelib/dummy_apps.rake
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "task_helpers"
|
|
4
|
-
|
|
5
|
-
namespace :dummy_apps do
|
|
6
|
-
include ReactOnRails::TaskHelpers
|
|
7
|
-
|
|
8
|
-
task :yarn_install do
|
|
9
|
-
yarn_install_cmd = "yarn install --mutex network"
|
|
10
|
-
sh_in_dir(dummy_app_dir, yarn_install_cmd)
|
|
11
|
-
sh_in_dir(dummy_app_dir, "yalc link react-on-rails")
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
task dummy_app: [:yarn_install] do
|
|
15
|
-
dummy_app_dir = File.join(gem_root, "spec/dummy")
|
|
16
|
-
bundle_install_in(dummy_app_dir)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
task :generate_packs do
|
|
20
|
-
dummy_app_dir = File.join(gem_root, "spec/dummy")
|
|
21
|
-
sh_in_dir(dummy_app_dir, "bundle exec rake react_on_rails:generate_packs")
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
task dummy_apps: %i[dummy_app node_package generate_packs] do
|
|
25
|
-
puts "Prepared all Dummy Apps"
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
desc "Prepares all dummy apps by installing dependencies"
|
|
30
|
-
task dummy_apps: ["dummy_apps:dummy_apps"]
|
data/rakelib/example_type.rb
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "rake"
|
|
4
|
-
require "pathname"
|
|
5
|
-
|
|
6
|
-
require_relative "task_helpers"
|
|
7
|
-
|
|
8
|
-
# Defines the ExampleType class, where each object represents a unique type of example
|
|
9
|
-
# app that we can generate.
|
|
10
|
-
module ReactOnRails
|
|
11
|
-
module TaskHelpers
|
|
12
|
-
class ExampleType
|
|
13
|
-
def self.all
|
|
14
|
-
@all ||= []
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def self.namespace_name
|
|
18
|
-
"examples"
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
attr_reader :name, :generator_options
|
|
22
|
-
|
|
23
|
-
def initialize(name: nil, generator_options: nil)
|
|
24
|
-
@name = name
|
|
25
|
-
@generator_options = generator_options
|
|
26
|
-
self.class.all << self
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def name_pretty
|
|
30
|
-
"#{@name} example app"
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def dir
|
|
34
|
-
File.join(examples_dir, name)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def dir_exist?
|
|
38
|
-
Dir.exist?(dir)
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def gemfile
|
|
42
|
-
File.join(dir, "Gemfile")
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
# Gems we need to add to the Gemfile before bundle installing
|
|
46
|
-
def required_gems
|
|
47
|
-
relative_gem_root = Pathname(gem_root).relative_path_from(Pathname(dir))
|
|
48
|
-
[
|
|
49
|
-
"gem 'react_on_rails', path: '#{relative_gem_root}'",
|
|
50
|
-
"gem 'shakapacker'"
|
|
51
|
-
]
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
# Options we pass when running `rails new` from the command-line.
|
|
55
|
-
attr_writer :rails_options
|
|
56
|
-
|
|
57
|
-
def rails_options
|
|
58
|
-
@rails_options ||= if ReactOnRails::Utils.rails_version_less_than("7.0")
|
|
59
|
-
"--skip-bundle --skip-spring --skip-git --skip-test-unit --skip-active-record -J"
|
|
60
|
-
else
|
|
61
|
-
"--skip-bundle --skip-spring --skip-git --skip-test-unit --skip-active-record -j webpack"
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
%w[gen clobber npm_install build_webpack_bundles].each do |task_type|
|
|
66
|
-
method_name_normal = "#{task_type}_task_name" # ex: `clean_task_name`
|
|
67
|
-
method_name_short = "#{method_name_normal}_short" # ex: `clean_task_name_short`
|
|
68
|
-
|
|
69
|
-
define_method(method_name_normal) { "#{self.class.namespace_name}:#{task_type}_#{name}" }
|
|
70
|
-
define_method(method_name_short) { "#{task_type}_#{name}" }
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def rspec_task_name_short
|
|
74
|
-
"example_#{name}"
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
def rspec_task_name
|
|
78
|
-
"run_rspec:#{rspec_task_name_short}"
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
# Assumes we are inside a rails app's folder and necessary gems have been installed
|
|
82
|
-
def generator_shell_commands
|
|
83
|
-
shell_commands = []
|
|
84
|
-
shell_commands << "rails generate react_on_rails:install #{generator_options} --ignore-warnings --force"
|
|
85
|
-
shell_commands << "rails generate react_on_rails:dev_tests #{generator_options}"
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
private
|
|
89
|
-
|
|
90
|
-
# Defines globs that scoop up all files (including dotfiles) in given directory
|
|
91
|
-
def all_files_in_dir(p_dir)
|
|
92
|
-
[File.join(p_dir, "**", "*"), File.join(p_dir, "**", ".*")]
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
end
|
data/rakelib/examples.rake
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Defines tasks related to generating example apps using the gem's generator.
|
|
4
|
-
# Allows us to create and test apps generated using a wide range of options.
|
|
5
|
-
#
|
|
6
|
-
# Also see example_type.rb
|
|
7
|
-
|
|
8
|
-
require "yaml"
|
|
9
|
-
require "rails/version"
|
|
10
|
-
|
|
11
|
-
require_relative "example_type"
|
|
12
|
-
require_relative "task_helpers"
|
|
13
|
-
|
|
14
|
-
namespace :examples do # rubocop:disable Metrics/BlockLength
|
|
15
|
-
include ReactOnRails::TaskHelpers
|
|
16
|
-
# Loads data from examples_config.yml and instantiates corresponding ExampleType objects
|
|
17
|
-
examples_config_file = File.expand_path("examples_config.yml", __dir__)
|
|
18
|
-
examples_config = symbolize_keys(YAML.safe_load(File.read(examples_config_file)))
|
|
19
|
-
examples_config[:example_type_data].each { |example_type_data| ExampleType.new(**symbolize_keys(example_type_data)) }
|
|
20
|
-
|
|
21
|
-
# Define tasks for each example type
|
|
22
|
-
ExampleType.all.each do |example_type|
|
|
23
|
-
# CLOBBER
|
|
24
|
-
desc "Clobbers (deletes) #{example_type.name_pretty}"
|
|
25
|
-
task example_type.clobber_task_name_short do
|
|
26
|
-
rm_rf(example_type.dir)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
# GENERATE
|
|
30
|
-
desc "Generates #{example_type.name_pretty}"
|
|
31
|
-
task example_type.gen_task_name_short => example_type.clobber_task_name do
|
|
32
|
-
mkdir_p(example_type.dir)
|
|
33
|
-
example_type.rails_options += "--skip-javascript"
|
|
34
|
-
sh_in_dir(examples_dir, "rails new #{example_type.name} #{example_type.rails_options}")
|
|
35
|
-
sh_in_dir(example_type.dir, "touch .gitignore")
|
|
36
|
-
append_to_gemfile(example_type.gemfile, example_type.required_gems)
|
|
37
|
-
bundle_install_in(example_type.dir)
|
|
38
|
-
sh_in_dir(example_type.dir, "rake webpacker:install")
|
|
39
|
-
sh_in_dir(example_type.dir, example_type.generator_shell_commands)
|
|
40
|
-
sh_in_dir(example_type.dir, "yarn")
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
desc "Clobbers (deletes) all example apps"
|
|
45
|
-
task :clobber do
|
|
46
|
-
rm_rf(examples_dir)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
desc "Generates all example apps"
|
|
50
|
-
task gen_all: ExampleType.all.map(&:gen_task_name)
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
desc "Generates all example apps. Run `rake -D examples` to see all available options"
|
|
54
|
-
task examples: ["examples:gen_all"]
|
|
55
|
-
|
|
56
|
-
private
|
|
57
|
-
|
|
58
|
-
# Appends each string in an array as a new line of text in the given Gemfile.
|
|
59
|
-
# Automatically adds line returns.
|
|
60
|
-
def append_to_gemfile(gemfile, lines)
|
|
61
|
-
old_text = File.read(gemfile)
|
|
62
|
-
new_text = lines.reduce(old_text) { |a, e| a << "#{e}\n" }
|
|
63
|
-
File.open(gemfile, "w") { |f| f.puts(new_text) }
|
|
64
|
-
end
|
data/rakelib/examples_config.yml
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
example_type_data:
|
|
2
|
-
-
|
|
3
|
-
name: basic
|
|
4
|
-
generator_options: ""
|
|
5
|
-
-
|
|
6
|
-
name: basic-server-rendering
|
|
7
|
-
generator_options: --example-server-rendering
|
|
8
|
-
-
|
|
9
|
-
name: redux
|
|
10
|
-
generator_options: --redux
|
|
11
|
-
-
|
|
12
|
-
name: redux-server-rendering
|
|
13
|
-
generator_options: --redux --example-server-rendering
|
|
14
|
-
|
data/rakelib/lint.rake
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "task_helpers"
|
|
4
|
-
|
|
5
|
-
namespace :lint do
|
|
6
|
-
include ReactOnRails::TaskHelpers
|
|
7
|
-
|
|
8
|
-
desc "Run Rubocop as shell"
|
|
9
|
-
task :rubocop do
|
|
10
|
-
sh_in_dir(gem_root, "bundle exec rubocop --version", "bundle exec rubocop .")
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
desc "Run scss-lint as shell"
|
|
14
|
-
task :scss do
|
|
15
|
-
sh_in_dir(gem_root, "bundle exec scss-lint spec/dummy/app/assets/stylesheets/")
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
desc "Run eslint as shell"
|
|
19
|
-
task :eslint do
|
|
20
|
-
sh_in_dir(gem_root, "yarn run eslint --version", "yarn run eslint .")
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
desc "Run all eslint & rubocop linters. Skip scss"
|
|
24
|
-
task lint: %i[eslint rubocop] do
|
|
25
|
-
puts "Completed all linting"
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
desc "Runs all linters. Run `rake -D lint` to see all available lint options"
|
|
30
|
-
task lint: ["lint:lint"]
|
data/rakelib/node_package.rake
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "task_helpers"
|
|
4
|
-
|
|
5
|
-
namespace :node_package do
|
|
6
|
-
include ReactOnRails::TaskHelpers
|
|
7
|
-
|
|
8
|
-
task :build do
|
|
9
|
-
puts "Building Node Package and running 'yalc publish'"
|
|
10
|
-
sh "yarn run build && yalc publish"
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
desc "Prepares node_package by building and symlinking any example/dummy apps present"
|
|
15
|
-
task node_package: "node_package:build"
|
data/rakelib/release.rake
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "bundler"
|
|
4
|
-
require_relative "task_helpers"
|
|
5
|
-
require_relative File.join(gem_root, "lib", "react_on_rails", "version_syntax_converter")
|
|
6
|
-
require_relative File.join(gem_root, "lib", "react_on_rails", "git_utils")
|
|
7
|
-
require_relative File.join(gem_root, "lib", "react_on_rails", "utils")
|
|
8
|
-
|
|
9
|
-
class RaisingMessageHandler
|
|
10
|
-
def add_error(error)
|
|
11
|
-
raise error
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
# rubocop:disable Metrics/BlockLength
|
|
16
|
-
|
|
17
|
-
desc("Releases both the gem and node package using the given version.
|
|
18
|
-
|
|
19
|
-
IMPORTANT: the gem version must be in valid rubygem format (no dashes).
|
|
20
|
-
It will be automatically converted to a valid yarn semver by the rake task
|
|
21
|
-
for the node package version. This only makes a difference for pre-release
|
|
22
|
-
versions such as `3.0.0.beta.1` (yarn version would be `3.0.0-beta.1`).
|
|
23
|
-
|
|
24
|
-
This task depends on the gem-release (ruby gem) and release-it (node package)
|
|
25
|
-
which are installed via `bundle install` and `yarn global add release-it`
|
|
26
|
-
|
|
27
|
-
1st argument: The new version in rubygem format (no dashes). Pass no argument to
|
|
28
|
-
automatically perform a patch version bump.
|
|
29
|
-
2nd argument: Perform a dry run by passing 'true' as a second argument.
|
|
30
|
-
|
|
31
|
-
Note, accept defaults for npmjs options. Script will pause to get 2FA tokens.
|
|
32
|
-
|
|
33
|
-
Example: `rake release[2.1.0,false]`")
|
|
34
|
-
task :release, %i[gem_version dry_run tools_install] do |_t, args|
|
|
35
|
-
include ReactOnRails::TaskHelpers
|
|
36
|
-
|
|
37
|
-
# Check if there are uncommited changes
|
|
38
|
-
ReactOnRails::GitUtils.uncommitted_changes?(RaisingMessageHandler.new)
|
|
39
|
-
args_hash = args.to_hash
|
|
40
|
-
|
|
41
|
-
is_dry_run = ReactOnRails::Utils.object_to_boolean(args_hash[:dry_run])
|
|
42
|
-
|
|
43
|
-
gem_version = args_hash.fetch(:gem_version, "")
|
|
44
|
-
|
|
45
|
-
npm_version = if gem_version.strip.empty?
|
|
46
|
-
""
|
|
47
|
-
else
|
|
48
|
-
ReactOnRails::VersionSyntaxConverter.new.rubygem_to_npm(gem_version)
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
# Having the examples prevents publishing
|
|
52
|
-
Rake::Task["examples:clobber"].invoke
|
|
53
|
-
# Delete any react_on_rails.gemspec except the root one
|
|
54
|
-
sh_in_dir(gem_root, "find . -mindepth 2 -name 'react_on_rails.gemspec' -delete")
|
|
55
|
-
|
|
56
|
-
# See https://github.com/svenfuchs/gem-release
|
|
57
|
-
sh_in_dir(gem_root, "git pull --rebase")
|
|
58
|
-
sh_in_dir(gem_root, "gem bump --no-commit #{gem_version.strip.empty? ? '' : %(--version #{gem_version})}")
|
|
59
|
-
|
|
60
|
-
# Update dummy app's Gemfile.lock
|
|
61
|
-
bundle_install_in(dummy_app_dir)
|
|
62
|
-
|
|
63
|
-
puts "Carefully add your OTP for NPM. If you get an error, 'git reset --hard' and start over."
|
|
64
|
-
# Will bump the yarn version, commit, tag the commit, push to repo, and release on yarn
|
|
65
|
-
release_it_command = +"release-it"
|
|
66
|
-
release_it_command << " #{npm_version}" unless npm_version.strip.empty?
|
|
67
|
-
release_it_command << " --npm.publish --no-git.requireCleanWorkingDir"
|
|
68
|
-
release_it_command << " --dry-run --verbose" if is_dry_run
|
|
69
|
-
sh_in_dir(gem_root, release_it_command)
|
|
70
|
-
|
|
71
|
-
# Release the new gem version
|
|
72
|
-
|
|
73
|
-
puts "Carefully add your OTP for Rubygems. If you get an error, run 'gem release' again."
|
|
74
|
-
sh_in_dir(gem_root, "gem release") unless is_dry_run
|
|
75
|
-
|
|
76
|
-
msg = <<~MSG
|
|
77
|
-
Once you have successfully published, run these commands to update the spec apps:
|
|
78
|
-
|
|
79
|
-
cd #{dummy_app_dir}; bundle update react_on_rails
|
|
80
|
-
cd #{gem_root}#{' '}
|
|
81
|
-
git commit -a -m 'Update Gemfile.lock for spec app'
|
|
82
|
-
git push
|
|
83
|
-
MSG
|
|
84
|
-
puts msg
|
|
85
|
-
end
|
|
86
|
-
# rubocop:enable Metrics/BlockLength
|
|
87
|
-
|
|
88
|
-
task :test do
|
|
89
|
-
unbundled_sh_in_dir(gem_root, "cd #{dummy_app_dir}; bundle update react_on_rails")
|
|
90
|
-
sh_in_dir(gem_root, "git commit -a -m 'Update Gemfile.lock for spec app'")
|
|
91
|
-
sh_in_dir(gem_root, "git push")
|
|
92
|
-
end
|
data/rakelib/run_rspec.rake
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "coveralls/rake/task" if ENV["USE_COVERALLS"] == "TRUE"
|
|
4
|
-
|
|
5
|
-
require "pathname"
|
|
6
|
-
|
|
7
|
-
require_relative "task_helpers"
|
|
8
|
-
require_relative "example_type"
|
|
9
|
-
|
|
10
|
-
# rubocop:disable Metrics/BlockLength
|
|
11
|
-
namespace :run_rspec do
|
|
12
|
-
include ReactOnRails::TaskHelpers
|
|
13
|
-
|
|
14
|
-
spec_dummy_dir = File.join("spec", "dummy")
|
|
15
|
-
|
|
16
|
-
desc "Run RSpec for top level only"
|
|
17
|
-
task :gem do
|
|
18
|
-
run_tests_in("", rspec_args: File.join("spec", "react_on_rails"))
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
desc "Runs dummy rspec with turbolinks"
|
|
22
|
-
task dummy: ["dummy_apps:dummy_app"] do
|
|
23
|
-
run_tests_in(spec_dummy_dir)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
desc "Runs dummy rspec without turbolinks"
|
|
27
|
-
task dummy_no_turbolinks: ["dummy_apps:dummy_app"] do
|
|
28
|
-
run_tests_in(spec_dummy_dir,
|
|
29
|
-
env_vars: "DISABLE_TURBOLINKS=TRUE",
|
|
30
|
-
command_name: "dummy_no_turbolinks")
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
# Dynamically define Rake tasks for each example app found in the examples directory
|
|
34
|
-
ExampleType.all.each do |example_type|
|
|
35
|
-
desc "Runs RSpec for #{example_type.name_pretty} only"
|
|
36
|
-
task example_type.rspec_task_name_short => example_type.gen_task_name do
|
|
37
|
-
run_tests_in(File.join(examples_dir, example_type.name)) # have to use relative path
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
desc "Runs Rspec for example apps only"
|
|
42
|
-
task examples: "examples:gen_all" do
|
|
43
|
-
ExampleType.all.each { |example_type| Rake::Task[example_type.rspec_task_name].invoke }
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
Coveralls::RakeTask.new if ENV["USE_COVERALLS"] == "TRUE"
|
|
47
|
-
|
|
48
|
-
desc "run all tests no examples"
|
|
49
|
-
task all_but_examples: %i[gem dummy_no_turbolinks dummy js_tests] do
|
|
50
|
-
puts "Completed all RSpec tests"
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
desc "run all dummy tests"
|
|
54
|
-
task all_dummy: %i[dummy_no_turbolinks dummy] do
|
|
55
|
-
puts "Completed all RSpec tests"
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
desc "run all tests"
|
|
59
|
-
task run_rspec: %i[all_but_examples examples] do
|
|
60
|
-
puts "Completed all RSpec tests"
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
# rubocop:enable Metrics/BlockLength
|
|
64
|
-
|
|
65
|
-
desc "js tests (same as 'yarn run test')"
|
|
66
|
-
task :js_tests do
|
|
67
|
-
sh "yarn run test"
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
msg = <<-DESC.strip_heredoc
|
|
71
|
-
Runs all tests, run `rake -D run_rspec` to see all available test options.
|
|
72
|
-
"rake run_rspec:example_basic" is a good way to run only one generator test.
|
|
73
|
-
DESC
|
|
74
|
-
desc msg
|
|
75
|
-
task run_rspec: ["run_rspec:run_rspec"]
|
|
76
|
-
|
|
77
|
-
private
|
|
78
|
-
|
|
79
|
-
def calc_path(dir)
|
|
80
|
-
if dir.is_a?(String)
|
|
81
|
-
if dir.start_with?(File::SEPARATOR)
|
|
82
|
-
Pathname.new(dir)
|
|
83
|
-
else
|
|
84
|
-
Pathname.new(File.join(gem_root, dir))
|
|
85
|
-
end
|
|
86
|
-
else
|
|
87
|
-
dir
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
# Runs rspec in the given directory.
|
|
92
|
-
# If string is passed and it's not absolute, it's converted relative to root of the gem.
|
|
93
|
-
# TEST_ENV_COMMAND_NAME is used to make SimpleCov.command_name unique in order to
|
|
94
|
-
# prevent a name collision. Defaults to the given directory's name.
|
|
95
|
-
def run_tests_in(dir, options = {})
|
|
96
|
-
path = calc_path(dir)
|
|
97
|
-
|
|
98
|
-
command_name = options.fetch(:command_name, path.basename)
|
|
99
|
-
rspec_args = options.fetch(:rspec_args, "")
|
|
100
|
-
env_vars = +"#{options.fetch(:env_vars, '')} TEST_ENV_COMMAND_NAME=\"#{command_name}\""
|
|
101
|
-
env_vars << "COVERAGE=true" if ENV["USE_COVERALLS"]
|
|
102
|
-
sh_in_dir(path.realpath, "#{env_vars} bundle exec rspec #{rspec_args}")
|
|
103
|
-
end
|
data/rakelib/task_helpers.rb
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module ReactOnRails
|
|
4
|
-
module TaskHelpers
|
|
5
|
-
# Returns the root folder of the react_on_rails gem
|
|
6
|
-
def gem_root
|
|
7
|
-
File.expand_path("..", __dir__)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
# Returns the folder where examples are located
|
|
11
|
-
def examples_dir
|
|
12
|
-
File.join(gem_root, "gen-examples", "examples")
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def dummy_app_dir
|
|
16
|
-
File.join(gem_root, "spec/dummy")
|
|
17
|
-
end
|
|
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
|
-
|
|
24
|
-
# Executes a string or an array of strings in a shell in the given directory
|
|
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
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def bundle_install_in(dir)
|
|
38
|
-
unbundled_sh_in_dir(dir, "bundle install")
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def bundle_install_in_no_turbolinks(dir)
|
|
42
|
-
sh_in_dir(dir, "DISABLE_TURBOLINKS=TRUE bundle install")
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
# Runs bundle exec using that directory's Gemfile
|
|
46
|
-
def bundle_exec(dir: nil, args: nil, env_vars: "")
|
|
47
|
-
sh_in_dir(dir, "#{env_vars} #{args}")
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def generators_source_dir
|
|
51
|
-
File.join(gem_root, "lib/generators/react_on_rails")
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def symbolize_keys(hash)
|
|
55
|
-
hash.each_with_object({}) do |(key, value), new_hash|
|
|
56
|
-
new_key = key.is_a?(String) ? key.to_sym : key
|
|
57
|
-
new_value = value.is_a?(Hash) ? symbolize_keys(value) : value
|
|
58
|
-
new_hash[new_key] = new_value
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
end
|