Skip to content

Commit

Permalink
Merge pull request #210 from aaronvb/generator_helpful_messages
Browse files Browse the repository at this point in the history
Helpful Message After Generator Install
  • Loading branch information
justin808 committed Jan 19, 2016
2 parents 1ff5b0b + 89dd8b4 commit 4768113
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/tutorial-v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

<img src="http://forum.shakacode.com/uploads/default/original/1X/5bd396a7f9c0764929b693fb79eb6685ec6f62cf.png" width="470" height="499">
Expand Down
18 changes: 18 additions & 0 deletions lib/generators/react_on_rails/base_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 11 additions & 0 deletions lib/generators/react_on_rails/react_with_redux_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
35 changes: 35 additions & 0 deletions spec/react_on_rails/generators/install_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 4768113

Please sign in to comment.