Skip to content

Commit 55b820a

Browse files
justin808claude
andcommitted
Add centralized help and support messaging system
- Extract help section from README.md into reusable component - Add Utils method to extract troubleshooting section dynamically - Update error handling in generate_packs task with colored output - Ensure help message updates when README.md changes 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 8678270 commit 55b820a

File tree

3 files changed

+83
-15
lines changed

3 files changed

+83
-15
lines changed

README.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -140,16 +140,22 @@ _Requires creating a free account._
140140
- Node.js >= 20 (CI tested: 20 - 22)
141141
- A JavaScript package manager (npm, yarn, pnpm, or bun)
142142

143-
# Support
144-
145-
- [Click to join **React + Rails Slack**](https://join.slack.com/t/reactrails/shared_invite/zt-38oicm9d0-OO0V~bdg4aYNuZuUbRFSXg).
146-
147-
- [**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.
148-
- [Discussions](https://github.com/shakacode/react_on_rails/discussions): Post your questions regarding React on Rails
149-
- **[forum.shakacode.com](https://forum.shakacode.com)**: Other discussions
150-
- **[@railsonmaui on Twitter](https://twitter.com/railsonmaui)**
151-
- _See [NEWS.md](https://github.com/shakacode/react_on_rails/tree/master/NEWS.md) for more notes over time._
152-
- 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.
143+
<!-- TROUBLESHOOTING_LINKS_START -->
144+
# 🆘 Get Help & Support
145+
146+
**Need immediate help?** Here are your options, ordered by response time:
147+
148+
- 🚀 **Professional Support**: [[email protected]](mailto:[email protected]) - Fastest resolution for bugs, upgrades, and consulting
149+
- 💬 **React + Rails Slack**: [Join our community](https://invite.reactrails.com) - Chat with other developers
150+
- 🆓 **GitHub Issues**: [Report bugs](https://github.com/shakacode/react_on_rails/issues) - Community support
151+
- 📖 **Discussions**: [Ask questions](https://github.com/shakacode/react_on_rails/discussions) - General help
152+
153+
**Additional Resources:**
154+
- [**Subscribe**](https://app.mailerlite.com/webforms/landing/l1d9x5) for announcements of new releases and tutorials
155+
- **[forum.shakacode.com](https://forum.shakacode.com)** - Development discussions
156+
- **[@railsonmaui on Twitter](https://twitter.com/railsonmaui)** - Updates and tips
157+
- [Projects using React on Rails](https://github.com/shakacode/react_on_rails/tree/master/PROJECTS.md) - Submit yours!
158+
<!-- TROUBLESHOOTING_LINKS_END -->
153159

154160
## Contributing
155161

lib/react_on_rails/utils.rb

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,5 +278,53 @@ def self.prepend_to_file_if_text_not_present(file:, text_to_prepend:, regex:)
278278

279279
puts "Prepended\n#{text_to_prepend}to #{file}."
280280
end
281+
282+
# Extract troubleshooting section from README.md for error messages
283+
def self.extract_troubleshooting_section
284+
readme_path = File.join(gem_root, "README.md")
285+
return default_troubleshooting_section unless File.exist?(readme_path)
286+
287+
readme_content = File.read(readme_path)
288+
289+
# Extract content between the markers
290+
start_marker = "<!-- TROUBLESHOOTING_LINKS_START -->"
291+
end_marker = "<!-- TROUBLESHOOTING_LINKS_END -->"
292+
293+
if readme_content.include?(start_marker) && readme_content.include?(end_marker)
294+
start_pos = readme_content.index(start_marker) + start_marker.length
295+
end_pos = readme_content.index(end_marker)
296+
297+
extracted = readme_content[start_pos...end_pos].strip
298+
# Convert markdown to terminal-friendly text
299+
convert_markdown_to_terminal(extracted)
300+
else
301+
default_troubleshooting_section
302+
end
303+
rescue StandardError
304+
default_troubleshooting_section
305+
end
306+
307+
private_class_method def self.convert_markdown_to_terminal(markdown_text)
308+
markdown_text
309+
.gsub(/^#\s+(.+)$/, "\n📞 \\1") # Convert # headers
310+
.gsub(/\*\*(.+?)\*\*/, "\\1") # Remove bold markdown
311+
.gsub(/\[([^\]]+)\]\([^)]+\)/, "\\1") # Convert links to just text
312+
.gsub(/^-\s+/, " • ") # Convert bullets
313+
.gsub(/🚀\s+\*\*Professional Support\*\*/, "🚀 Professional Support") # Clean up specific formatting
314+
end
315+
316+
private_class_method def self.default_troubleshooting_section
317+
<<~DEFAULT
318+
📞 Get Help & Support:
319+
• 🚀 Professional Support: [email protected] (fastest resolution)
320+
• 💬 React + Rails Slack: https://invite.reactrails.com
321+
• 🆓 GitHub Issues: https://github.com/shakacode/react_on_rails/issues
322+
• 📖 Discussions: https://github.com/shakacode/react_on_rails/discussions
323+
DEFAULT
324+
end
325+
326+
private_class_method def self.gem_root
327+
File.expand_path("../..", __dir__)
328+
end
281329
end
282330
end

lib/tasks/generate_packs.rake

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,24 @@ namespace :react_on_rails do
123123
puts Rainbow("=" * 80).red
124124
end
125125

126+
def show_help_and_support
127+
puts ""
128+
troubleshooting_content = ReactOnRails::Utils.extract_troubleshooting_section
129+
# Display the troubleshooting content with color formatting
130+
troubleshooting_content.split("\n").each do |line|
131+
case line
132+
when /^📞/
133+
puts Rainbow(line).magenta.bold
134+
when /^\s*•\s*🚀/
135+
puts Rainbow(line).yellow
136+
when /^\s*•/
137+
puts Rainbow(line).cyan
138+
else
139+
puts Rainbow(line).white unless line.strip.empty?
140+
end
141+
end
142+
end
143+
126144
# rubocop:disable Metrics/AbcSize
127145
def handle_standard_error(error)
128146
puts ""
@@ -142,11 +160,7 @@ namespace :react_on_rails do
142160
puts Rainbow(" 2. Check Rails logs: tail -f log/development.log").white
143161
puts Rainbow(" 3. Verify all dependencies are installed: bundle install && npm install").white
144162
puts Rainbow(" 4. Clear cache: rm -rf tmp/cache").white
145-
puts ""
146-
puts Rainbow("📞 GET HELP:").magenta.bold
147-
puts Rainbow(" • Create an issue: https://github.com/shakacode/react_on_rails/issues").cyan
148-
puts Rainbow(" • Community discussions: https://github.com/shakacode/react_on_rails/discussions").cyan
149-
puts Rainbow(" • Professional support: https://www.shakacode.com/react-on-rails-pro").cyan
163+
show_help_and_support
150164
puts Rainbow("=" * 80).red
151165
end
152166
# rubocop:enable Metrics/AbcSize

0 commit comments

Comments
 (0)