Skip to content

Commit

Permalink
feat: add ERD
Browse files Browse the repository at this point in the history
  • Loading branch information
jacky-le-goldenowl committed Oct 20, 2024
1 parent 211eaca commit 19ed94b
Show file tree
Hide file tree
Showing 10 changed files with 733 additions and 32 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ group :development do
gem 'ruby-lsp-rails'
gem 'web-console'
gem 'bullet'
gem 'rails-mermaid_erd'
end

group :test do
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ GEM
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
rails-mermaid_erd (0.5.0)
rails (>= 5.2)
railties (7.2.1.1)
actionpack (= 7.2.1.1)
activesupport (= 7.2.1.1)
Expand Down Expand Up @@ -554,6 +556,7 @@ DEPENDENCIES
puma (>= 5.0)
pundit (~> 2.4)
rails (~> 7.2.0)
rails-mermaid_erd
redis (>= 4.0.1)
rolify
rspec-rails
Expand Down
7 changes: 7 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,10 @@ desc 'Apply auto-corrections'
task fix: %w[eslint:autocorrect stylelint:autocorrect rubocop:autocorrect_all] do
puts '>>>>>> [OK] All fixes applied!'
end

# Trigger run mermaid_erd after db:migrate
Rake::Task['db:migrate'].enhance do
puts 'Running mermaid_erd after db:migrate...'
system('bundle exec rails mermaid_erd')
puts '>>>>>> Generated mermaid_erd done!'
end
5 changes: 5 additions & 0 deletions app/controllers/docs_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class DocsController < ApplicationController
def erd
render file: Rails.root.join('docs/erd.html'), layout: false
end
end
1 change: 1 addition & 0 deletions config/mermaid_erd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
result_path: docs/erd.html
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
Rails.application.routes.draw do
if Rails.env.development?
mount Lookbook::Engine, at: '/lookbook'
# ERD
get '/erd', to: 'docs#erd'
end

authenticate :user, lambda { |u| u.has_role?(:super_admin) } do
Expand Down
714 changes: 714 additions & 0 deletions docs/erd.html

Large diffs are not rendered by default.

13 changes: 0 additions & 13 deletions lib/tasks/eslint.rake

This file was deleted.

6 changes: 0 additions & 6 deletions lib/tasks/rubocop.rake

This file was deleted.

13 changes: 0 additions & 13 deletions lib/tasks/stylelint.rake

This file was deleted.

0 comments on commit 19ed94b

Please sign in to comment.