Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
26 changes: 16 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,22 @@ _Requires creating a free account._
- Node.js >= 20 (CI tested: 20 - 22)
- A JavaScript package manager (npm, yarn, pnpm, or bun)

# Support

- [Click to join **React + Rails Slack**](https://join.slack.com/t/reactrails/shared_invite/zt-38oicm9d0-OO0V~bdg4aYNuZuUbRFSXg).

- [**Subscribe**](https://app.mailerlite.com/webforms/landing/l1d9x5) for announcements of new releases of React on Rails and of our latest [blog articles](https://blog.shakacode.com) and tutorials.
- [Discussions](https://github.com/shakacode/react_on_rails/discussions): Post your questions regarding React on Rails
- **[forum.shakacode.com](https://forum.shakacode.com)**: Other discussions
- **[@railsonmaui on Twitter](https://twitter.com/railsonmaui)**
- _See [NEWS.md](https://github.com/shakacode/react_on_rails/tree/master/NEWS.md) for more notes over time._
- See [Projects](https://github.com/shakacode/react_on_rails/tree/master/PROJECTS.md) using and [KUDOS](https://github.com/shakacode/react_on_rails/tree/master/KUDOS.md) for React on Rails. Please submit yours! Please edit either page or [email us](mailto:[email protected]) and we'll add your info. We also **love stars** as it helps us attract new users and contributors.
<!-- TROUBLESHOOTING_LINKS_START -->
# 🆘 Get Help & Support

**Need immediate help?** Here are your options, ordered by response time:

- 🚀 **Professional Support**: [[email protected]](mailto:[email protected]) - Fastest resolution for bugs, upgrades, and consulting
- 💬 **React + Rails Slack**: [Join our community](https://invite.reactrails.com) - Chat with other developers
- 🆓 **GitHub Issues**: [Report bugs](https://github.com/shakacode/react_on_rails/issues) - Community support
- 📖 **Discussions**: [Ask questions](https://github.com/shakacode/react_on_rails/discussions) - General help

**Additional Resources:**
- [**Subscribe**](https://app.mailerlite.com/webforms/landing/l1d9x5) for announcements of new releases and tutorials
- **[forum.shakacode.com](https://forum.shakacode.com)** - Development discussions
- **[@railsonmaui on Twitter](https://twitter.com/railsonmaui)** - Updates and tips
- [Projects using React on Rails](https://github.com/shakacode/react_on_rails/tree/master/PROJECTS.md) - Submit yours!
<!-- TROUBLESHOOTING_LINKS_END -->

## Contributing

Expand Down
50 changes: 50 additions & 0 deletions lib/react_on_rails/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def self.invoke_and_exit_if_failed(cmd, failure_message)
MSG

puts wrap_message(msg)
puts ""
puts extract_troubleshooting_section

# Rspec catches exit without! in the exit callbacks
exit!(1)
Expand Down Expand Up @@ -278,5 +280,53 @@ def self.prepend_to_file_if_text_not_present(file:, text_to_prepend:, regex:)

puts "Prepended\n#{text_to_prepend}to #{file}."
end

# Extract troubleshooting section from README.md for error messages
def self.extract_troubleshooting_section
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to cache it, we don't want to do all this on every exception!

readme_path = File.join(gem_root, "README.md")
return default_troubleshooting_section unless File.exist?(readme_path)

readme_content = File.read(readme_path)

# Extract content between the markers
start_marker = "<!-- TROUBLESHOOTING_LINKS_START -->"
end_marker = "<!-- TROUBLESHOOTING_LINKS_END -->"

if readme_content.include?(start_marker) && readme_content.include?(end_marker)
start_pos = readme_content.index(start_marker) + start_marker.length
end_pos = readme_content.index(end_marker)

extracted = readme_content[start_pos...end_pos].strip
# Convert markdown to terminal-friendly text
convert_markdown_to_terminal(extracted)
else
default_troubleshooting_section
end
rescue StandardError
default_troubleshooting_section
end

private_class_method def self.convert_markdown_to_terminal(markdown_text)
markdown_text
.gsub(/^#\s+(.+)$/, "\n📞 \\1") # Convert # headers
.gsub(/\*\*(.+?)\*\*/, "\\1") # Remove bold markdown
.gsub(/\[([^\]]+)\]\([^)]+\)/, "\\1") # Convert links to just text
.gsub(/^-\s+/, " • ") # Convert bullets
.gsub(/🚀\s+\*\*Professional Support\*\*/, "🚀 Professional Support") # Clean up specific formatting
end

private_class_method def self.default_troubleshooting_section
<<~DEFAULT
📞 Get Help & Support:
• 🚀 Professional Support: [email protected] (fastest resolution)
• 💬 React + Rails Slack: https://invite.reactrails.com
• 🆓 GitHub Issues: https://github.com/shakacode/react_on_rails/issues
• 📖 Discussions: https://github.com/shakacode/react_on_rails/discussions
DEFAULT
end

private_class_method def self.gem_root
File.expand_path("../..", __dir__)
end
end
end
24 changes: 19 additions & 5 deletions lib/tasks/generate_packs.rake
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,24 @@ namespace :react_on_rails do
puts Rainbow("=" * 80).red
end

def show_help_and_support
puts ""
troubleshooting_content = ReactOnRails::Utils.extract_troubleshooting_section
# Display the troubleshooting content with color formatting
troubleshooting_content.split("\n").each do |line|
case line
when /^📞/
puts Rainbow(line).magenta.bold
when /^\s*•\s*🚀/
puts Rainbow(line).yellow
when /^\s*•/
puts Rainbow(line).cyan
else
puts Rainbow(line).white unless line.strip.empty?
end
end
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Terminal output loses actual URLs (link text only).

Because Utils.convert_markdown_to_terminal strips links to plain text, this colored printer will show “Join our community” without the invite URL. Fix the conversion in Utils to preserve “text: URL”. See my comment in utils.rb Lines 309-316.

🤖 Prompt for AI Agents
In lib/tasks/generate_packs.rake around lines 126 to 142, the terminal help
printer displays link text but loses actual URLs because
ReactOnRails::Utils.convert_markdown_to_terminal strips links; update
Utils.convert_markdown_to_terminal (see lib/.../utils.rb lines ~309-316) to
preserve links by replacing markdown links [text](url) with "text: url" (or
"text — url") instead of removing the URL, ensure the function handles multiple
links per line and edge cases (reference-style links, parentheses in URLs), and
add/update unit tests to assert that "Join our community" becomes "Join our
community: https://invite.url" in the extracted troubleshooting output.


# rubocop:disable Metrics/AbcSize
def handle_standard_error(error)
puts ""
Expand All @@ -142,11 +160,7 @@ namespace :react_on_rails do
puts Rainbow(" 2. Check Rails logs: tail -f log/development.log").white
puts Rainbow(" 3. Verify all dependencies are installed: bundle install && npm install").white
puts Rainbow(" 4. Clear cache: rm -rf tmp/cache").white
puts ""
puts Rainbow("📞 GET HELP:").magenta.bold
puts Rainbow(" • Create an issue: https://github.com/shakacode/react_on_rails/issues").cyan
puts Rainbow(" • Community discussions: https://github.com/shakacode/react_on_rails/discussions").cyan
puts Rainbow(" • Professional support: https://www.shakacode.com/react-on-rails-pro").cyan
show_help_and_support
puts Rainbow("=" * 80).red
end
# rubocop:enable Metrics/AbcSize
Expand Down
Loading