Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,9 @@ yalc add react-on-rails

### Testing the Generator

The generators are covered by generator tests using Rails's generator testing helpers, but it never hurts to do a sanity check and explore the API. See [generator_testing_script.md](generator_testing_script.md) for a script on how to run the generator on a fresh project.
The generators are covered by generator tests using Rails's generator testing helpers, but it never hurts to do a sanity check and explore the API. See [generator-testing.md](docs/contributor-info/generator-testing.md) for a script on how to run the generator on a fresh project.

`rake run_rspec:example_basic` is a great way to run tests on one generator. Once that works, you should run `rake run_rspec:examples`. Be aware that this will create a hug number of files under a `/gen-examples` directory. You should be sure to exclude this directory from your IDE and delete it once your testing is done.
`rake run_rspec:shakapacker_examples_basic` is a great way to run tests on one generator. Once that works, you should run `rake run_rspec:shakapacker_examples`. Be aware that this will create a huge number of files under a `/gen-examples` directory. You should be sure to exclude this directory from your IDE and delete it once your testing is done.

### Linting

Expand Down
12 changes: 4 additions & 8 deletions lib/generators/react_on_rails/dev_tests_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,10 @@ def replace_prerender_if_server_rendering

def add_yarn_relative_install_script_in_package_json
package_json = File.join(destination_root, "package.json")
contents = File.read(package_json)
replacement_value = <<-STRING
"scripts": {
"postinstall": "yalc link react-on-rails",
STRING
new_client_package_json_contents = contents.gsub(/ {2}"scripts": {/,
replacement_value)
File.open(package_json, "w+") { |f| f.puts new_client_package_json_contents }
contents = JSON.parse(File.read(package_json))
contents["scripts"] ||= {}
contents["scripts"]["postinstall"] = "yalc link react-on-rails"
File.open(package_json, "w+") { |f| f.puts JSON.pretty_generate(contents) }
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions script/convert
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ new_config = File.expand_path("../spec/dummy/config/webpacker.yml", __dir__)

File.rename(old_config, new_config)

gsub_file_content("../Gemfile.development_dependencies", 'gem "shakapacker", "8.0.0"', 'gem "shakapacker", "6.6.0"')
gsub_file_content("../Gemfile.development_dependencies", /gem "shakapacker", "[^"]*"/, 'gem "shakapacker", "6.6.0"')

# The below packages don't work on the oldest supported Node version and aren't needed there anyway
gsub_file_content("../package.json", /"knip": "[^"]*",/, "")
gsub_file_content("../package.json", %r{"@arethetypeswrong/cli": "[^"]*",}, "")
gsub_file_content("../package.json", %r{"@testing-library/dom": "[^"]*",}, "")
gsub_file_content("../package.json", %r{"@testing-library/react": "[^"]*",}, "")

gsub_file_content("../spec/dummy/package.json", '"shakapacker": "8.0.0",', '"shakapacker": "6.6.0",')
gsub_file_content("../spec/dummy/package.json", /"shakapacker": "[^"]*",/, '"shakapacker": "6.6.0",')

gsub_file_content("../spec/dummy/config/webpack/commonWebpackConfig.js", /generateWebpackConfig(\(\))?/,
"webpackConfig")
Expand Down
Loading