diff --git a/docs/tutorial-v2.md b/docs/tutorial-v2.md index 9a684b36f..1e71fbcbe 100644 --- a/docs/tutorial-v2.md +++ b/docs/tutorial-v2.md @@ -48,7 +48,7 @@ npm run rails-server Visit http://localhost:3000/hello_world and see your React On Rails app running! ``` -npm run node-server-hot +npm run express-server ``` diff --git a/lib/generators/react_on_rails/base_generator.rb b/lib/generators/react_on_rails/base_generator.rb index 7549282f3..1bb707815 100644 --- a/lib/generators/react_on_rails/base_generator.rb +++ b/lib/generators/react_on_rails/base_generator.rb @@ -192,6 +192,24 @@ def force_application_scss_naming_if_necessary new_name = File.join(destination_root, "#{base_path}application.scss") File.rename(bad_name, new_name) end + + def print_helpful_message + message = <<-MSG.strip_heredoc + + What to do next: + + - Ensure your bundle and npm are up to date. + + bundle && npm i + + - Run the npm rails-server command to load the rails server. + + npm run rails-server + + - Visit http://localhost:3000/hello_world and see your React On Rails app running! + MSG + GeneratorMessages.add_info(message) + end end end end diff --git a/lib/generators/react_on_rails/react_with_redux_generator.rb b/lib/generators/react_on_rails/react_with_redux_generator.rb index 884335990..32511bfa1 100644 --- a/lib/generators/react_on_rails/react_with_redux_generator.rb +++ b/lib/generators/react_on_rails/react_with_redux_generator.rb @@ -45,6 +45,17 @@ def template_appropriate_version_of_hello_world_app_client location = "client/app/bundles/HelloWorld/startup" template("redux/base/#{location}/HelloWorldAppClient.jsx.tt", "#{location}/#{filename}") end + + def print_helpful_message + message = <<-MSG + - Run the npm express-server command to load the node server with hot reloading support. + + npm run express-server + + - Visit http://localhost:4000 and see your React On Rails app running using the Webpack Dev server. + MSG + GeneratorMessages.add_info(message) + end end end end diff --git a/lib/generators/react_on_rails/templates/base/base/package.json b/lib/generators/react_on_rails/templates/base/base/package.json index 63de03fdf..3799abfda 100644 --- a/lib/generators/react_on_rails/templates/base/base/package.json +++ b/lib/generators/react_on_rails/templates/base/base/package.json @@ -10,7 +10,7 @@ "scripts": { "postinstall": "cd client && npm install", "test": "rspec && (cd client && npm run lint)", - "node-server-hot": "echo 'visit http://localhost:4000' && cd client && npm start", + "express-server": "echo 'visit http://localhost:4000' && cd client && npm start", "rails-server": "echo 'visit http://localhost:3000/hello_world' && foreman start -f Procfile.dev" }, "repository": { diff --git a/spec/react_on_rails/generators/install_generator_spec.rb b/spec/react_on_rails/generators/install_generator_spec.rb index a50d783c5..c92de5114 100644 --- a/spec/react_on_rails/generators/install_generator_spec.rb +++ b/spec/react_on_rails/generators/install_generator_spec.rb @@ -228,4 +228,39 @@ .to include(GeneratorMessages.format_error(expected)) end end + + context "with helpful message" do + specify "base generator contains a helpful message" do + run_generator_test_with_args(%w()) + expected = <<-MSG.strip_heredoc + + What to do next: + + - Ensure your bundle and npm are up to date. + + bundle && npm i + + - Run the npm rails-server command to load the rails server. + + npm run rails-server + + - 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 + + specify "react with redux generator contains a helpful message" do + run_generator_test_with_args(%w(--redux)) + expected = <<-MSG + - Run the npm express-server command to load the node server with hot reloading support. + + npm run express-server + + - Visit http://localhost:4000 and see your React On Rails app running using the Webpack Dev server. + MSG + expect(GeneratorMessages.output) + .to include(GeneratorMessages.format_info(expected)) + end + end end