react_on_rails 13.3.5 → 14.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +100 -62
  3. data/Gemfile.development_dependencies +10 -9
  4. data/README.md +7 -2
  5. data/lib/generators/react_on_rails/adapt_for_older_shakapacker_generator.rb +41 -0
  6. data/lib/generators/react_on_rails/base_generator.rb +13 -49
  7. data/lib/generators/react_on_rails/dev_tests_generator.rb +1 -1
  8. data/lib/generators/react_on_rails/generator_messages.rb +40 -0
  9. data/lib/generators/react_on_rails/install_generator.rb +21 -0
  10. data/lib/generators/react_on_rails/templates/base/base/Procfile.dev +2 -2
  11. data/lib/generators/react_on_rails/templates/base/base/Procfile.dev-static +2 -2
  12. data/lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb +2 -2
  13. data/lib/generators/react_on_rails/templates/base/base/config/{webpacker.yml → shakapacker.yml} +3 -3
  14. data/lib/generators/react_on_rails/templates/base/base/config/webpack/commonWebpackConfig.js.tt +3 -1
  15. data/lib/generators/react_on_rails/templates/dev_tests/spec/rails_helper.rb +2 -2
  16. data/lib/generators/react_on_rails/templates/dev_tests/spec/system/hello_world_spec.rb +1 -1
  17. data/lib/react_on_rails/configuration.rb +39 -25
  18. data/lib/react_on_rails/git_utils.rb +3 -3
  19. data/lib/react_on_rails/helper.rb +25 -13
  20. data/lib/react_on_rails/json_output.rb +0 -17
  21. data/lib/react_on_rails/locales/base.rb +4 -4
  22. data/lib/react_on_rails/locales/to_js.rb +1 -1
  23. data/lib/react_on_rails/packs_generator.rb +4 -4
  24. data/lib/react_on_rails/react_component/render_options.rb +1 -1
  25. data/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb +10 -12
  26. data/lib/react_on_rails/test_helper/webpack_assets_status_checker.rb +3 -3
  27. data/lib/react_on_rails/test_helper.rb +2 -2
  28. data/lib/react_on_rails/utils.rb +2 -8
  29. data/lib/react_on_rails/version.rb +1 -1
  30. data/lib/react_on_rails/version_checker.rb +2 -2
  31. data/lib/react_on_rails/webpacker_utils.rb +6 -0
  32. data/lib/tasks/assets.rake +1 -1
  33. data/react_on_rails.gemspec +4 -4
  34. metadata +6 -131
  35. data/.bookignore +0 -15
  36. data/.circleci/config.yml +0 -338
  37. data/.coveralls.yml +0 -1
  38. data/.dockerignore +0 -2
  39. data/.eslintignore +0 -17
  40. data/.eslintrc +0 -53
  41. data/.github/FUNDING.yml +0 -1
  42. data/.github/ISSUE_TEMPLATE/bug_report.md +0 -23
  43. data/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  44. data/.github/PULL_REQUEST_TEMPLATE.md +0 -19
  45. data/.github/workflows/lint-js-and-ruby.yml +0 -54
  46. data/.github/workflows/main.yml +0 -183
  47. data/.github/workflows/package-js-tests.yml +0 -35
  48. data/.github/workflows/rspec-package-specs.yml +0 -46
  49. data/.gitignore +0 -33
  50. data/.npmignore +0 -22
  51. data/.prettierignore +0 -14
  52. data/.prettierrc +0 -20
  53. data/.rspec +0 -2
  54. data/.rubocop.yml +0 -134
  55. data/.scss-lint.yml +0 -205
  56. data/.travis.yml +0 -61
  57. data/book.json +0 -18
  58. data/docs/additional-details/generator-details.md +0 -56
  59. data/docs/additional-details/manual-installation-overview.md +0 -30
  60. data/docs/additional-details/migrating-from-react-rails.md +0 -17
  61. data/docs/additional-details/recommended-project-structure.md +0 -69
  62. data/docs/additional-details/updating-dependencies.md +0 -31
  63. data/docs/additional-details/upgrade-webpacker-v3-to-v4.md +0 -10
  64. data/docs/api/javascript-api.md +0 -99
  65. data/docs/api/redux-store-api.md +0 -102
  66. data/docs/api/view-helpers-api.md +0 -133
  67. data/docs/contributor-info/errors-with-hooks.md +0 -45
  68. data/docs/contributor-info/generator-testing.md +0 -11
  69. data/docs/contributor-info/linters.md +0 -68
  70. data/docs/contributor-info/pull-requests.md +0 -42
  71. data/docs/contributor-info/releasing.md +0 -76
  72. data/docs/deployment/elastic-beanstalk.md +0 -63
  73. data/docs/deployment/heroku-deployment.md +0 -35
  74. data/docs/getting-started.md +0 -195
  75. data/docs/guides/client-vs-server-rendering.md +0 -27
  76. data/docs/guides/configuration.md +0 -289
  77. data/docs/guides/deployment.md +0 -5
  78. data/docs/guides/file-system-based-automated-bundle-generation.md +0 -205
  79. data/docs/guides/hmr-and-hot-reloading-with-the-webpack-dev-server.md +0 -104
  80. data/docs/guides/how-react-on-rails-works.md +0 -44
  81. data/docs/guides/how-to-conditionally-server-render-based-on-device-type.md +0 -40
  82. data/docs/guides/how-to-use-different-files-for-client-and-server-rendering.md +0 -98
  83. data/docs/guides/i18n.md +0 -87
  84. data/docs/guides/installation-into-an-existing-rails-app.md +0 -66
  85. data/docs/guides/minitest-configuration.md +0 -31
  86. data/docs/guides/rails-webpacker-react-integration-options.md +0 -213
  87. data/docs/guides/react-on-rails-overview.md +0 -30
  88. data/docs/guides/react-server-rendering.md +0 -32
  89. data/docs/guides/render-functions-and-railscontext.md +0 -205
  90. data/docs/guides/rspec-configuration.md +0 -73
  91. data/docs/guides/tutorial.md +0 -374
  92. data/docs/guides/upgrading-react-on-rails.md +0 -304
  93. data/docs/guides/webpack-configuration.md +0 -42
  94. data/docs/home.md +0 -23
  95. data/docs/javascript/angular-js-integration-migration.md +0 -28
  96. data/docs/javascript/asset-pipeline.md +0 -12
  97. data/docs/javascript/capistrano-deployment.md +0 -18
  98. data/docs/javascript/code-splitting.md +0 -165
  99. data/docs/javascript/converting-from-custom-webpack-config-to-rails-webpacker-config.md +0 -10
  100. data/docs/javascript/credits.md +0 -10
  101. data/docs/javascript/foreman-issues.md +0 -15
  102. data/docs/javascript/images.md +0 -57
  103. data/docs/javascript/node-dependencies-and-npm.md +0 -19
  104. data/docs/javascript/react-and-redux.md +0 -36
  105. data/docs/javascript/react-helmet.md +0 -100
  106. data/docs/javascript/react-router.md +0 -90
  107. data/docs/javascript/server-rendering-tips.md +0 -55
  108. data/docs/javascript/troubleshooting-when-using-webpacker.md +0 -90
  109. data/docs/javascript/webpack-v1-notes.md +0 -23
  110. data/docs/javascript/webpack.md +0 -22
  111. data/docs/misc/articles.md +0 -20
  112. data/docs/misc/code_of_conduct.md +0 -13
  113. data/docs/misc/doctrine.md +0 -77
  114. data/docs/misc/style.md +0 -33
  115. data/docs/misc/tips.md +0 -10
  116. data/docs/outdated/deferred-rendering.md +0 -39
  117. data/docs/outdated/rails-assets-relative-paths.md +0 -195
  118. data/docs/outdated/rails-assets.md +0 -77
  119. data/docs/outdated/rails3.md +0 -9
  120. data/docs/rails/convert-rails-5-api-only-app.md +0 -19
  121. data/docs/rails/rails-engine-integration.md +0 -32
  122. data/docs/rails/rails_view_rendering_from_inline_javascript.md +0 -36
  123. data/docs/rails/turbolinks.md +0 -124
  124. data/docs/react-on-rails-pro/react-on-rails-pro.md +0 -43
  125. data/docs/testimonials/hvmn.md +0 -25
  126. data/docs/testimonials/resortpass.md +0 -13
  127. data/docs/testimonials/testimonials.md +0 -28
  128. data/jest.config.js +0 -4
  129. data/package-scripts.yml +0 -49
  130. data/package.json +0 -96
  131. data/rakelib/docker.rake +0 -26
  132. data/rakelib/dummy_apps.rake +0 -30
  133. data/rakelib/example_type.rb +0 -96
  134. data/rakelib/examples.rake +0 -64
  135. data/rakelib/examples_config.yml +0 -14
  136. data/rakelib/lint.rake +0 -30
  137. data/rakelib/node_package.rake +0 -15
  138. data/rakelib/release.rake +0 -92
  139. data/rakelib/run_rspec.rake +0 -103
  140. data/rakelib/task_helpers.rb +0 -62
  141. data/script/bootstrap +0 -33
  142. data/script/release +0 -3
  143. data/script/setup +0 -23
  144. data/script/test +0 -38
  145. data/webpackConfigLoader.js +0 -71
  146. data/yarn.lock +0 -7010
@@ -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
@@ -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
@@ -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"]
@@ -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
@@ -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
@@ -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
data/script/bootstrap DELETED
@@ -1,33 +0,0 @@
1
- #!/bin/sh
2
-
3
- # script/bootstrap: Resolve all dependencies that the application requires to
4
- # run.
5
-
6
- set -e
7
-
8
- cd "$(dirname "$0")/.."
9
-
10
- if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ]; then
11
- brew update
12
-
13
- brew bundle check 2>&1 >/dev/null || {
14
- echo "==> Installing Homebrew dependencies…"
15
- brew bundle
16
- }
17
- fi
18
-
19
- if [ -f ".ruby-version" ] && [ -z "$(rbenv version-name 2>/dev/null)" ]; then
20
- echo "==> Installing Ruby…"
21
- rbenv install --skip-existing
22
- which bundle 2>&1 >/dev/null || {
23
- gem install bundler
24
- rbenv rehash
25
- }
26
- fi
27
-
28
- if [ -f "Gemfile" ]; then
29
- echo "==> Installing gem dependencies…"
30
- bundle check --path vendor/gems 2>&1 >/dev/null || {
31
- bundle install --path vendor/gems --quiet --without production
32
- }
33
- fi
data/script/release DELETED
@@ -1,3 +0,0 @@
1
- #!/bin/bash
2
-
3
- echo "See `rake -D release`"
data/script/setup DELETED
@@ -1,23 +0,0 @@
1
- #!/bin/sh
2
-
3
- # script/setup: Set up application for the first time after cloning, or set it
4
- # back to the initial first unused state.
5
-
6
- set -e
7
-
8
- cd "$(dirname "$0")/.."
9
-
10
- script/bootstrap
11
-
12
- echo "===> Setting up DB..."
13
- # reset database to a fresh state.
14
- bin/rake db:create db:reset
15
-
16
- if [ -z "$RAILS_ENV" ] && [ -z "$RACK_ENV" ]; then
17
- # Only things for a development environment will run inside here
18
- # Do things that need to be done to the application to set up for the first
19
- # time. Or things needed to be run to to reset the application back to first
20
- # use experience. These things are scoped to the application's domain.
21
- fi
22
-
23
- echo "==> App is now ready to go!"
data/script/test DELETED
@@ -1,38 +0,0 @@
1
- #!/bin/sh
2
-
3
- # script/test: Run test suite for application. Optionally pass in a path to an
4
- # individual test file to run a single test.
5
-
6
-
7
- set -e
8
-
9
- cd "$(dirname "$0")/.."
10
-
11
- [ -z "$DEBUG" ] || set -x
12
-
13
- export RACK_ROOT=$(cd "$(dirname $0)"/.. && pwd)
14
-
15
- if [ "$RAILS_ENV" = "test" ] || [ "$RACK_ENV" = "test" ]; then
16
- # if executed and the environment is already set to `test`, then we want a
17
- # clean from scratch application. This almost always means a ci environment,
18
- # since we set the environment to `test` directly in `script/cibuild`.
19
- script/setup
20
- else
21
- # if the environment isn't set to `test`, set it to `test` and update the
22
- # application to ensure all dependencies are met as well as any other things
23
- # that need to be up to date, like db migrations. The environement not having
24
- # already been set to `test` almost always means this is being called on it's
25
- # own from a `development` environment.
26
- export RAILS_ENV="test" RACK_ENV="test"
27
-
28
- script/update
29
- fi
30
-
31
- echo "===> Running tests..."
32
-
33
- if [ -n "$1" ]; then
34
- # pass arguments to test call. This is useful for calling a single test.
35
- bin/rake test "$1"
36
- else
37
- bin/rake test
38
- fi
@@ -1,71 +0,0 @@
1
- /**
2
- * TODO: THIS SHOULD BE REMOVED
3
- *
4
- * Allow defaults for the config/webpacker.yml. Thee values in this file MUST match values
5
- * in https://github.com/rails/webpacker/blob/master/lib/install/config/webpacker.yml
6
- *
7
- * NOTE: for HMR reloading, env.WEBPACKER_HMR value will override any config value. This env value
8
- * should be set to TRUE to turn this on.
9
- */
10
-
11
- const { join, resolve } = require('path');
12
- const { env } = require('process');
13
- const { safeLoad } = require('js-yaml');
14
- const { readFileSync } = require('fs');
15
-
16
- function removeOuterSlashes(string) {
17
- return string.replace(/^\/*/, '').replace(/\/*$/, '');
18
- }
19
-
20
- function formatPublicPath(settings) {
21
- if (settings.dev_server) {
22
- const { host } = settings.dev_server;
23
- const { port } = settings.dev_server;
24
- const path = settings.public_output_path;
25
- const hostWithHttp = `http://${host}:${port}`;
26
-
27
- let formattedHost = removeOuterSlashes(hostWithHttp);
28
- if (formattedHost && !/^http/i.test(formattedHost)) {
29
- formattedHost = `//${formattedHost}`;
30
- }
31
- const formattedPath = removeOuterSlashes(path);
32
- return `${formattedHost}/${formattedPath}/`;
33
- }
34
-
35
- const publicOuterPathWithoutOutsideSlashes = removeOuterSlashes(settings.public_output_path);
36
- return `//${publicOuterPathWithoutOutsideSlashes}/`;
37
- }
38
-
39
- /**
40
- * @param configPath, location where webpacker.yml will be found
41
- * Return values are consistent with Webpacker's js helpers
42
- * For example, you might define:
43
- * const isHMR = settings.dev_server && settings.dev_server.hmr
44
- * @returns {{
45
- settings,
46
- resolvedModules,
47
- output: { path, publicPath, publicPathWithHost }
48
- }}
49
- */
50
- const configLoader = (configPath) => {
51
- // Some test environments might not have the NODE_ENV set, so we'll have fallbacks.
52
- const configEnv = env.NODE_ENV || env.RAILS_ENV || 'development';
53
- const ymlConfigPath = join(configPath, 'webpacker.yml');
54
- const settings = safeLoad(readFileSync(ymlConfigPath, 'utf8'))[configEnv];
55
-
56
- // NOTE: Rails path is hard coded to `/public`
57
- const output = {
58
- // Next line differs from the webpacker definition as we use the configPath to create
59
- // the relative path.
60
- path: resolve(configPath, '..', 'public', settings.public_output_path),
61
- publicPath: `/${settings.public_output_path}/`.replace(/([^:]\/)\/+/g, '$1'),
62
- publicPathWithHost: formatPublicPath(settings),
63
- };
64
-
65
- return {
66
- settings,
67
- output,
68
- };
69
- };
70
-
71
- module.exports = configLoader;