Skip to content

Commit

Permalink
Helpful Message After Generator Install
Browse files Browse the repository at this point in the history
- Added a helpful message after base generator install.
- Added a helpful message after react with redux generator install.
- Added tests for both messages.
- Change 'npm run node-server-hot' to 'npm run express-server'
  • Loading branch information
aaronvb committed Jan 18, 2016
1 parent 8e728c9 commit cb1fa73
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 1 deletion.
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 node-server-hot command to load the node server with hot reloading support.
npm run node-server-hot
- 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 cb1fa73

Please sign in to comment.