diff --git a/lib/generators/react_on_rails/templates/base/base/package.json.tt b/lib/generators/react_on_rails/templates/base/base/package.json.tt index a51297705..ceed84bce 100644 --- a/lib/generators/react_on_rails/templates/base/base/package.json.tt +++ b/lib/generators/react_on_rails/templates/base/base/package.json.tt @@ -4,11 +4,10 @@ "private": true, "engines": { "node": "6.9.0", - "npm": "4.1.1", - "yarn": "3.5.0" + "npm": "4.1.1" }, "scripts": { - "postinstall": "cd client && yarn", + "postinstall": "cd client && yarn install", "rails-server": "echo 'visit http://localhost:3000/hello_world' && foreman start -f Procfile.dev", "test": "rspec" } diff --git a/lib/react_on_rails/test_helper.rb b/lib/react_on_rails/test_helper.rb index 1fcb50b17..58457fb73 100644 --- a/lib/react_on_rails/test_helper.rb +++ b/lib/react_on_rails/test_helper.rb @@ -19,7 +19,7 @@ module TestHelper # once per test run. # # If you do not want to be slowed down by re-compiling webpack assets from scratch every test - # run, you can call `npm run build:client` (and `npm run build:server` if doing server + # run, you can call `yarn run build:client` (and `yarn run build:server` if doing server # rendering) to have webpack recompile these files in the background, which will be *much* # faster. The helper looks for these processes and will abort recompiling if it finds them # to be running. diff --git a/lib/react_on_rails/test_helper/node_process_launcher.rb b/lib/react_on_rails/test_helper/node_process_launcher.rb index d1c2c91be..6f770a234 100644 --- a/lib/react_on_rails/test_helper/node_process_launcher.rb +++ b/lib/react_on_rails/test_helper/node_process_launcher.rb @@ -5,7 +5,7 @@ def self.launch_node path = "#{::Rails.root}/client/node" puts "Launching NodeJS server at #{path}" - system("cd #{path} && npm start &") + system("cd #{path} && yarn start &") sleep(1) end end diff --git a/lib/react_on_rails/version_checker.rb b/lib/react_on_rails/version_checker.rb index c46d0b512..75790530b 100644 --- a/lib/react_on_rails/version_checker.rb +++ b/lib/react_on_rails/version_checker.rb @@ -1,5 +1,5 @@ module ReactOnRails - # Responsible for checking versions of rubygem versus npm node package + # Responsible for checking versions of rubygem versus yarn node package # against each otherat runtime. class VersionChecker attr_reader :node_package_version, :logger diff --git a/package.json b/package.json index e324266f8..5daed987b 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "build-watch": "babel --watch --out-dir node_package/lib node_package/src", "eslint": "eslint .", "flow": "flow check node_package", - "lint": "yarn run eslint && yarn run jscs && yarn run flow", + "lint": "yarn run eslint && yarn run flow", "check": "yarn run lint && yarn run flow && yarn run test", "prerelease": "yarn run check && yarn run clean && yarn run build", "release:patch": "node_package/scripts/release patch", diff --git a/rakelib/lint.rake b/rakelib/lint.rake index d7596006e..8f27770d7 100644 --- a/rakelib/lint.rake +++ b/rakelib/lint.rake @@ -23,11 +23,6 @@ namespace :lint do sh_in_dir(gem_root, "yarn run eslint") end - desc "Run jscs from shell" - task :jscs do - sh_in_dir(gem_root, "yarn run jscs") - end - desc "Run flow from shell" task :flow do sh_in_dir(gem_root, "yarn run flow") diff --git a/spec/dummy/Procfile.dev.no.turbolinks b/spec/dummy/Procfile.dev.no.turbolinks index 0f9b219d9..78cd060d7 100644 --- a/spec/dummy/Procfile.dev.no.turbolinks +++ b/spec/dummy/Procfile.dev.no.turbolinks @@ -1,3 +1,3 @@ -client: sh -c 'rm app/assets/webpack/* || true && cd client && npm run build:dev:client' -server: sh -c 'cd client && npm run build:dev:server' +client: sh -c 'rm app/assets/webpack/* || true && cd client && yarn run build:dev:client' +server: sh -c 'cd client && yarn run build:dev:server' web: DISABLE_TURBOLINKS=TRUE bin/rails s -b 0.0.0.0 diff --git a/spec/dummy/Procfile.hot b/spec/dummy/Procfile.hot index e6f929dc9..9f73263bc 100644 --- a/spec/dummy/Procfile.hot +++ b/spec/dummy/Procfile.hot @@ -3,7 +3,7 @@ rails: REACT_ON_RAILS_ENV=HOT rails s -b 0.0.0.0 # Run the hot reload server for client development -hot-assets: HOT_RAILS_PORT=3500 npm run hot-assets +hot-assets: HOT_RAILS_PORT=3500 yarn run hot-assets # Keep the JS fresh for server rendering. Remove if not server rendering -rails-server-assets: npm run build:dev:server +rails-server-assets: yarn run build:dev:server diff --git a/spec/dummy/Procfile.spec b/spec/dummy/Procfile.spec index 27a1bae7a..035185301 100644 --- a/spec/dummy/Procfile.spec +++ b/spec/dummy/Procfile.spec @@ -3,7 +3,7 @@ # in rails_helper.rb. # Build client assets, watching for changes. -rails-client-assets: npm run build:dev:client +rails-client-assets: yarn run build:dev:client # Build server assets, watching for changes. Remove if not server rendering. -rails-server-assets: npm run build:dev:server +rails-server-assets: yarn run build:dev:server diff --git a/spec/dummy/Procfile.static b/spec/dummy/Procfile.static index b48bcd1ba..5c9da41ce 100644 --- a/spec/dummy/Procfile.static +++ b/spec/dummy/Procfile.static @@ -2,7 +2,7 @@ rails: REACT_ON_RAILS_ENV= rails s -b 0.0.0.0 # Build client assets, watching for changes. -rails-client-assets: sh -c 'npm run build:dev:client' +rails-client-assets: sh -c 'yarn run build:dev:client' # Build server assets, watching for changes. Remove if not server rendering. -rails-server-assets: sh -c 'npm run build:dev:server' +rails-server-assets: sh -c 'yarn run build:dev:server' diff --git a/spec/dummy/Procfile.static.no.turbolinks b/spec/dummy/Procfile.static.no.turbolinks index a54d4649d..f2f58c06c 100644 --- a/spec/dummy/Procfile.static.no.turbolinks +++ b/spec/dummy/Procfile.static.no.turbolinks @@ -2,7 +2,7 @@ rails: DISABLE_TURBOLINKS=TRUE REACT_ON_RAILS_ENV= rails s -b 0.0.0.0 # Build client assets, watching for changes. -rails-client-assets: sh -c 'npm run build:dev:client' +rails-client-assets: sh -c 'yarn run build:dev:client' # Build server assets, watching for changes. Remove if not server rendering. -rails-server-assets: sh -c 'npm run build:dev:server' +rails-server-assets: sh -c 'yarn run build:dev:server' diff --git a/spec/dummy/client/package.json b/spec/dummy/client/package.json index 3fa95b812..2801bbe41 100644 --- a/spec/dummy/client/package.json +++ b/spec/dummy/client/package.json @@ -33,7 +33,7 @@ "postcss-loader": "^1.2.1", "react": "^15.4.1", "react-dom": "^15.4.1", - "react-on-rails": "../../..", + "react-on-rails": "file:../../..", "react-redux": "^5.0.1", "react-router": "^3.0.0", "redux": "^3.6.0", @@ -63,10 +63,10 @@ "fs": false }, "scripts": { - "lint": "npm run eslint --silent", + "lint": "yarn run eslint --silent", "eslint": "eslint --ext .js,.jsx .", - "test": "npm run build:test && rspec", - "build:test": "npm run build:client && npm run build:server", + "test": "yarn run build:test && rspec", + "build:test": "yarn run build:client && yarn run build:server", "build:production:client": "NODE_ENV=production webpack --config webpack.client.rails.build.config.js", "build:production:server": "NODE_ENV=production webpack --config webpack.server.rails.build.config.js", "build:client": "webpack --config webpack.client.rails.build.config.js", @@ -74,7 +74,7 @@ "build:dev:server": "webpack -w --config webpack.server.rails.build.config.js", "build:server": "webpack --config webpack.server.rails.build.config.js", "hot-assets": "babel-node server-rails-hot.js", - "install-react-on-rails": "npm install 'react-on-rails@../../..'" + "install-react-on-rails": "yarn 'file:../../..'" }, "author": "", "license": "ISC" diff --git a/spec/dummy/client/server-rails-hot.js b/spec/dummy/client/server-rails-hot.js index 679ff0347..eb1c6c62d 100644 --- a/spec/dummy/client/server-rails-hot.js +++ b/spec/dummy/client/server-rails-hot.js @@ -1,7 +1,7 @@ /* eslint no-var: 0, no-console: 0, import/no-extraneous-dependencies: 0 */ /* eslint-disable comma-dangle */ -// This file is used by the npm script: +// This file is used by the yarn script: // "hot-assets": "babel-node server-rails-hot.js" // // This is what creates the hot assets so that you can edit assets, JavaScript and Sass, diff --git a/spec/dummy/client/webpack.client.rails.build.config.js b/spec/dummy/client/webpack.client.rails.build.config.js index 828dd15e7..c68473857 100644 --- a/spec/dummy/client/webpack.client.rails.build.config.js +++ b/spec/dummy/client/webpack.client.rails.build.config.js @@ -1,5 +1,5 @@ // Run like this: -// cd client && npm run build:client +// cd client && yarn run build:client // Note that Foreman (Procfile.dev) has also been configured to take care of this. /* eslint-disable comma-dangle */ diff --git a/spec/dummy/config/initializers/react_on_rails.rb b/spec/dummy/config/initializers/react_on_rails.rb index 940b4a86b..b9bf8b0a8 100644 --- a/spec/dummy/config/initializers/react_on_rails.rb +++ b/spec/dummy/config/initializers/react_on_rails.rb @@ -27,13 +27,13 @@ def self.custom_context(view_context) config.server_bundle_js_file = "server-bundle.js" # If you are using the ReactOnRails::TestHelper.configure_rspec_to_compile_assets(config) - # with rspec then this controls what npm command is run + # with rspec then this controls what yarn command is run # to automatically refresh your webpack assets on every test run. - config.npm_build_test_command = "npm run build:test" + config.npm_build_test_command = "yarn run build:test" # This configures the script to run to build the production assets by webpack. Set this to nil # if you don't want react_on_rails building this file for you. - config.npm_build_production_command = "npm run build:production" + config.npm_build_production_command = "yarn run build:production" ################################################################################ # CLIENT RENDERING OPTIONS diff --git a/spec/dummy/lib/tasks/assets.rake b/spec/dummy/lib/tasks/assets.rake index 6ae0f5968..dd5213761 100644 --- a/spec/dummy/lib/tasks/assets.rake +++ b/spec/dummy/lib/tasks/assets.rake @@ -14,10 +14,10 @@ namespace :assets do desc "Compile assets with webpack" task :webpack do - sh "cd client && npm run build:client" + sh "cd client && yarn run build:client" # Skip next line if not doing server rendering - sh "cd client && npm run build:server" + sh "cd client && yarn run build:server" end task :clobber do diff --git a/spec/react_on_rails/generators/dev_tests_generator_spec.rb b/spec/react_on_rails/generators/dev_tests_generator_spec.rb index 1eed60ee8..89380f02d 100644 --- a/spec/react_on_rails/generators/dev_tests_generator_spec.rb +++ b/spec/react_on_rails/generators/dev_tests_generator_spec.rb @@ -24,7 +24,7 @@ it "changes package.json to use local react-on-rails version of module" do assert_file("client/package.json") do |contents| - assert_match('"react-on-rails": "../../../.."', contents) + assert_match('"react-on-rails": "file:../../../.."', contents) refute_match('"react-on-rails": "ReactOnRails::VERSION"', contents) end end diff --git a/spec/react_on_rails/generators/install_generator_spec.rb b/spec/react_on_rails/generators/install_generator_spec.rb index fc616fe78..051b5506f 100644 --- a/spec/react_on_rails/generators/install_generator_spec.rb +++ b/spec/react_on_rails/generators/install_generator_spec.rb @@ -87,9 +87,9 @@ What to do next: - - Ensure your bundle and npm are up to date. + - Ensure your bundle and yarn installs of dependencies are up to date. - bundle && npm i + bundle && yarn - Run the foreman command to start the rails server and run webpack in watch mode. @@ -107,6 +107,20 @@ specify "react with redux generator contains a helpful message" do run_generator_test_with_args(%w(--redux)) + expected = <<-MSG.strip_heredoc + + What to do next: + + - Ensure your bundle and yarn installs of dependencies are up to date. + + bundle && yarn + + - Run the foreman command to start the rails server and run webpack in watch mode. + + foreman start -f Procfile.dev + + - Visit http://localhost:3000/hello_world and see your React On Rails app running! + MSG expect(GeneratorMessages.output) .to include(GeneratorMessages.format_info(expected)) end @@ -123,7 +137,7 @@ specify "when npm is exist" do stub_const("RUBY_PLATFORM", "linux") - allow(@install_generator).to receive(:`).with("which npm").and_return("/path/to/bin") + allow(@install_generator).to receive(:`).with("which yarn").and_return("/path/to/bin") expect(@install_generator.send(:missing_npm?)).to eq false end end @@ -139,7 +153,7 @@ specify "when npm is missing" do stub_const("RUBY_PLATFORM", "linux") - allow(@install_generator).to receive(:`).with("which npm").and_return("") + allow(@install_generator).to receive(:`).with("which yarn").and_return("") expect(@install_generator.send(:missing_npm?)).to eq true end end @@ -155,7 +169,7 @@ specify "when npm is exist" do stub_const("RUBY_PLATFORM", "mswin") - allow(@install_generator).to receive(:`).with("where npm").and_return("/path/to/bin") + allow(@install_generator).to receive(:`).with("where yarn").and_return("/path/to/bin") expect(@install_generator.send(:missing_npm?)).to eq false end end @@ -171,7 +185,7 @@ specify "when npm is missing" do stub_const("RUBY_PLATFORM", "mswin") - allow(@install_generator).to receive(:`).with("where npm").and_return("") + allow(@install_generator).to receive(:`).with("where yarn").and_return("") expect(@install_generator.send(:missing_npm?)).to eq true end end