boring_generators 0.12.0 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +2 -2
  3. data/.gitignore +1 -0
  4. data/CHANGELOG.md +82 -45
  5. data/CONTRIBUTING.md +17 -0
  6. data/Gemfile.lock +2 -2
  7. data/README.md +22 -0
  8. data/lib/boring_generators/generator_helper.rb +34 -0
  9. data/lib/boring_generators/version.rb +1 -1
  10. data/lib/generators/boring/active_storage/azure/install/install_generator.rb +1 -1
  11. data/lib/generators/boring/annotate/install/install_generator.rb +52 -0
  12. data/lib/generators/boring/audit/install/install_generator.rb +1 -1
  13. data/lib/generators/boring/avo/install/install_generator.rb +25 -0
  14. data/lib/generators/boring/cancancan/install/install_generator.rb +34 -0
  15. data/lib/generators/boring/devise/doorkeeper/install/install_generator.rb +190 -0
  16. data/lib/generators/boring/devise/install/install_generator.rb +11 -0
  17. data/lib/generators/boring/dotenv/install/install_generator.rb +51 -0
  18. data/lib/generators/boring/dotenv/install/templates/.env +3 -0
  19. data/lib/generators/boring/factory_bot/install/install_generator.rb +1 -1
  20. data/lib/generators/boring/faker/install/install_generator.rb +1 -1
  21. data/lib/generators/boring/favicon/build/build_generator.rb +1 -1
  22. data/lib/generators/boring/figjam/install/install_generator.rb +33 -0
  23. data/lib/generators/boring/honeybadger/install/install_generator.rb +47 -0
  24. data/lib/generators/boring/honeybadger/install/templates/README +6 -0
  25. data/lib/generators/boring/honeybadger/install/templates/honeybadger.yml.tt +26 -0
  26. data/lib/generators/boring/letter_opener/install/install_generator.rb +38 -0
  27. data/lib/generators/boring/oauth/google/install/install_generator.rb +2 -2
  28. data/lib/generators/boring/pronto/base_generator.rb +78 -0
  29. data/lib/generators/boring/pronto/github_action/install/install_generator.rb +27 -0
  30. data/lib/generators/boring/pronto/github_action/install/templates/pronto.yml.tt +53 -0
  31. data/lib/generators/boring/pronto/gitlab_ci/install/install_generator.rb +112 -0
  32. data/lib/generators/boring/pronto/gitlab_ci/install/templates/.gitlab-ci.yml.tt +22 -0
  33. data/lib/generators/boring/pronto/gitlab_ci/install/templates/README +7 -0
  34. data/lib/generators/boring/rack_mini_profiler/install/install_generator.rb +38 -0
  35. data/lib/generators/boring/rails_erd/install/install_generator.rb +35 -0
  36. data/lib/generators/boring/rspec/install/install_generator.rb +1 -1
  37. data/lib/generators/boring/rswag/install/install_generator.rb +166 -0
  38. data/lib/generators/boring/rswag/install/templates/README +10 -0
  39. data/lib/generators/boring/sentry/install/install_generator.rb +48 -0
  40. data/lib/generators/boring/sentry/install/templates/sentry.rb +7 -0
  41. data/lib/generators/boring/vcr/install/install_generator.rb +125 -0
  42. data/lib/generators/boring/vcr/install/templates/rspec/vcr.rb.tt +8 -0
  43. data/lib/generators/boring/webmock/install/install_generator.rb +87 -0
  44. data/lib/generators/boring/whenever/install/install_generator.rb +25 -0
  45. data/tmp/templates/app_template/.ruby-version +1 -1
  46. data/tmp/templates/app_template/Gemfile +1 -1
  47. data/tmp/templates/app_template/config/boot.rb +1 -1
  48. metadata +30 -2
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "boring_generators/generator_helper"
4
+
5
+ module Boring
6
+ module Dotenv
7
+ class InstallGenerator < Rails::Generators::Base
8
+ include BoringGenerators::GeneratorHelper
9
+
10
+ desc "Adds dotenv gem to the application"
11
+ source_root File.expand_path("templates", __dir__)
12
+
13
+ def add_dotenv_gem
14
+ return if gem_installed?("dotenv-rails")
15
+
16
+ say "Adding dotenv gem", :green
17
+
18
+ check_and_install_gem "dotenv-rails", group: :development
19
+ end
20
+
21
+ def configure_dotenv_gem
22
+ say "Configuring dotenv gem", :green
23
+
24
+ template ".env", ".env"
25
+
26
+ create_file ".gitignore" unless File.exist?(".gitignore")
27
+
28
+ FileUtils.cp(".env", ".env.sample")
29
+
30
+ add_env_files_to_gitignore
31
+ end
32
+
33
+ private
34
+
35
+ def add_env_files_to_gitignore
36
+ if File.readlines(".gitignore").any? { |line| line.include?(".env") }
37
+ return
38
+ end
39
+
40
+ ignore_content = <<~ENV_FILE_NAMES
41
+ \n
42
+ # Ignore all environment files (except templates).
43
+ /.env
44
+ !/.env.*
45
+ ENV_FILE_NAMES
46
+
47
+ insert_into_file(".gitignore", ignore_content)
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,3 @@
1
+ # Add your environment variables here
2
+ # Example:
3
+ # SECRET_KEY_BASE=your_secret_key
@@ -14,7 +14,7 @@ module Boring
14
14
  def add_factory_bot_gem
15
15
  log :adding, "FactoryBot"
16
16
  Bundler.with_unbundled_env do
17
- run "bundle add factory_bot_rails --group='developement,test'"
17
+ run "bundle add factory_bot_rails --group='development,test'"
18
18
  end
19
19
  end
20
20
 
@@ -9,7 +9,7 @@ module Boring
9
9
  def add_faker_gem
10
10
  log :adding, "faker"
11
11
  Bundler.with_unbundled_env do
12
- run "bundle add faker --group='developement,test'"
12
+ run "bundle add faker --group='development,test'"
13
13
  end
14
14
  end
15
15
  end
@@ -39,7 +39,7 @@ module Boring
39
39
  end
40
40
 
41
41
  def create_favicon_directory
42
- unless File.exists?(FILE_FAVICO_DIR)
42
+ unless File.exist?(FILE_FAVICO_DIR)
43
43
  Dir.mkdir FILE_FAVICO_DIR
44
44
  end
45
45
  end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Boring
4
+ module Figjam
5
+ class InstallGenerator < Rails::Generators::Base
6
+ desc 'Adds figjam gem to the app'
7
+
8
+ def add_figjam_gem
9
+ say 'Adding figjam gem', :green
10
+
11
+ Bundler.with_unbundled_env do
12
+ run 'bundle add figjam'
13
+ end
14
+ end
15
+
16
+ def configure_figjam
17
+ say 'Configuring figjam', :green
18
+
19
+ Bundler.with_unbundled_env do
20
+ run 'bundle exec figjam install'
21
+ end
22
+
23
+ FileUtils.cp('config/application.yml', 'config/application.yml.sample')
24
+
25
+ unless File.exist?('.gitignore')
26
+ create_file '.gitignore'
27
+ end
28
+
29
+ insert_into_file('.gitignore', "\n/config/application.yml\n")
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Boring
4
+ module Honeybadger
5
+ class InstallGenerator < Rails::Generators::Base
6
+ source_root File.expand_path("templates", __dir__)
7
+ desc 'Adds honeybadger to the app'
8
+
9
+ class_option :use_env_variable, type: :boolean, aliases: "-ev",
10
+ desc: 'Use ENV variable for devise_jwt_secret_key. By default Rails credentials will be used.'
11
+
12
+ def add_honeybadger_gem
13
+ say 'Adding Honeybadger gem', :green
14
+
15
+ Bundler.with_unbundled_env do
16
+ run 'bundle add honeybadger'
17
+ end
18
+ end
19
+
20
+ def configure_honeybadger_gem
21
+ say 'Setting up Honeybadger', :green
22
+
23
+ @api_key = honeybadger_api_key
24
+
25
+ template 'honeybadger.yml', 'config/honeybadger.yml'
26
+
27
+ show_readme
28
+ end
29
+
30
+ private
31
+
32
+ def show_readme
33
+ readme_template = File.read(File.join(self.class.source_root, 'README'))
34
+ readme_content = ERB.new(readme_template).result(binding)
35
+ say readme_content
36
+ end
37
+
38
+ def honeybadger_api_key
39
+ if options[:use_env_variable]
40
+ "ENV['HONEYBADGER_API_KEY']"
41
+ else
42
+ "Rails.application.credentials.dig(:honeybadger, :api_key)"
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,6 @@
1
+ ===============================================================================
2
+
3
+ The API key for Honeybadger will be used from <%= @api_key %>.
4
+ You can change these values if they don't match with your app.
5
+
6
+ ===============================================================================
@@ -0,0 +1,26 @@
1
+ ---
2
+ # For more options, see https://docs.honeybadger.io/lib/ruby/gem-reference/configuration
3
+
4
+ api_key: <%= @api_key %>
5
+
6
+ # The environment your app is running in.
7
+ env: "<%= Rails.env %>"
8
+
9
+ # The absolute path to your project folder.
10
+ root: "<%= Rails.root.to_s %>"
11
+
12
+ # Honeybadger won't report errors in these environments.
13
+ development_environments:
14
+ - test
15
+ - development
16
+ - cucumber
17
+
18
+ # By default, Honeybadger won't report errors in the development_environments.
19
+ # You can override this by explicitly setting report_data to true or false.
20
+ # report_data: true
21
+
22
+ # The current Git revision of your project. Defaults to the last commit hash.
23
+ # revision: null
24
+
25
+ # Enable verbose debug logging (useful for troubleshooting).
26
+ debug: false
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Boring
4
+ module LetterOpener
5
+ class InstallGenerator < Rails::Generators::Base
6
+ desc "Adds letter_opener gem for previewing email in development environment"
7
+
8
+ def add_letter_opener_gem
9
+ say "Adding letter_opener gem", :green
10
+
11
+ gem_content = <<~RUBY.indent(2)
12
+ \n# Preview email in the default browser instead of sending it to real mailbox
13
+ gem "letter_opener"
14
+ RUBY
15
+
16
+ insert_into_file "Gemfile", gem_content, after: /group :development do/
17
+
18
+ Bundler.with_unbundled_env do
19
+ run "bundle install"
20
+ end
21
+ end
22
+
23
+ def configure_letter_opener
24
+ say "Configuring letter_opener", :green
25
+
26
+ configuration_content = <<~RUBY.chomp.indent(2)
27
+ \n# Preview email in the browser instead of sending it
28
+ config.action_mailer.delivery_method = :letter_opener
29
+ config.action_mailer.perform_deliveries = true
30
+ RUBY
31
+
32
+ gsub_file "config/environments/development.rb",
33
+ /end\Z/,
34
+ "#{configuration_content}\nend"
35
+ end
36
+ end
37
+ end
38
+ end
@@ -14,8 +14,8 @@ module Boring
14
14
  desc "Adds Google OmniAuth to the application"
15
15
  source_root File.expand_path("templates", __dir__)
16
16
 
17
- def add_github_omniauth_gem
18
- say "Adding GitHub OmniAuth gem", :green
17
+ def add_google_omniauth_gem
18
+ say "Adding Google OmniAuth gem", :green
19
19
  Bundler.with_unbundled_env do
20
20
  run "bundle add omniauth-google-oauth2"
21
21
  end
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "boring_generators/generator_helper"
4
+
5
+ module Boring
6
+ module Pronto
7
+ class BaseGenerator < Rails::Generators::Base
8
+ desc "Adds Pronto gem with various extensions"
9
+
10
+ class_option :skip_extensions,
11
+ type: :array,
12
+ aliases: "-se",
13
+ desc:
14
+ "List of extensions to skip. Available options: brakeman, flay, reek, rubocop",
15
+ enum: %w[brakeman flay reek rubocop],
16
+ default: []
17
+
18
+ include BoringGenerators::GeneratorHelper
19
+
20
+ def add_pronto_gems
21
+ say "Adding pronto gems", :green
22
+
23
+ gem_content = <<~RUBY.strip
24
+ #{pronto_gem_content}
25
+ #{pronto_brakemen_gem_content}
26
+ #{pronto_flay_gem_content}
27
+ #{pronto_reek_gem_content}
28
+ #{pronto_rubocop_gem_content}
29
+ RUBY
30
+
31
+ return if gem_content.blank?
32
+
33
+ insert_into_file "Gemfile", "\n#{gem_content}\n"
34
+
35
+ Bundler.with_unbundled_env { run "bundle install" }
36
+ end
37
+
38
+ private
39
+
40
+ def pronto_gem_content
41
+ return if gem_installed?("pronto")
42
+
43
+ <<~RUBY.strip
44
+ # Pronto is a code linter runner that can be used with git and GitHub pull requests
45
+ gem "pronto"
46
+ RUBY
47
+ end
48
+
49
+ def pronto_brakemen_gem_content
50
+ return if options[:skip_extensions].include?("brakeman")
51
+ return if gem_installed?("pronto-brakeman")
52
+
53
+ "gem \"pronto-brakeman\", require: false"
54
+ end
55
+
56
+ def pronto_flay_gem_content
57
+ return if options[:skip_extensions].include?("flay")
58
+ return if gem_installed?("pronto-flay")
59
+
60
+ "gem \"pronto-flay\", require: false"
61
+ end
62
+
63
+ def pronto_reek_gem_content
64
+ return if options[:skip_extensions].include?("reek")
65
+ return if gem_installed?("pronto-reek")
66
+
67
+ "gem \"pronto-reek\", require: false"
68
+ end
69
+
70
+ def pronto_rubocop_gem_content
71
+ return if options[:skip_extensions].include?("rubocop")
72
+ return if gem_installed?("pronto-rubocop")
73
+
74
+ "gem \"pronto-rubocop\", require: false"
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "generators/boring/pronto/base_generator"
4
+ require "boring_generators/generator_helper"
5
+
6
+ module Boring
7
+ module Pronto
8
+ module GithubAction
9
+ class InstallGenerator < Boring::Pronto::BaseGenerator
10
+ desc "Adds Pronto configurations to Github Action"
11
+ source_root File.expand_path("templates", __dir__)
12
+
13
+ class_option :ruby_version, type: :string, aliases: "-rv"
14
+
15
+ include BoringGenerators::GeneratorHelper
16
+
17
+ def add_pronto_configuration_for_github_action
18
+ say "Adding Pronto configurations to .github/workflows/pronto.yml", :green
19
+
20
+ @ruby_version = options.ruby_version || app_ruby_version
21
+
22
+ template("pronto.yml", ".github/workflows/pronto.yml")
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,53 @@
1
+ on: [pull_request]
2
+
3
+ name: Pronto
4
+
5
+ jobs:
6
+ pronto:
7
+ runs-on: ubuntu-latest
8
+ permissions:
9
+ contents: read
10
+ pull-requests: write
11
+ statuses: write
12
+ steps:
13
+ - name: Checkout code
14
+ uses: actions/checkout@v2
15
+ with:
16
+ fetch-depth: 0
17
+
18
+ - name: Setup Ruby
19
+ uses: ruby/setup-ruby@v1
20
+ with:
21
+ ruby-version: <%= @ruby_version %>
22
+ - name: Ruby gem cache
23
+ uses: actions/cache@v1
24
+ with:
25
+ path: vendor/bundle
26
+ key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
27
+ restore-keys: |
28
+ ${{ runner.os }}-gems-
29
+ - name: Install gems
30
+ run: |
31
+ bundle config path vendor/bundle
32
+ bundle install --jobs 4 --retry 3
33
+
34
+ - name: Setup Node
35
+ uses: actions/setup-node@v1
36
+ with:
37
+ node-version: 10.13.0
38
+ - name: Find yarn cache location
39
+ id: yarn-cache
40
+ run: echo "::set-output name=dir::$(yarn cache dir)"
41
+ - name: JS package cache
42
+ uses: actions/cache@v1
43
+ with:
44
+ path: ${{ steps.yarn-cache.outputs.dir }}
45
+ key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
46
+ restore-keys: |
47
+ ${{ runner.os }}-yarn-
48
+ - name: Install packages
49
+ run: |
50
+ yarn install --pure-lockfile
51
+ - name: Run Pronto
52
+ run: |
53
+ PRONTO_PULL_REQUEST_ID="${{ github.event.pull_request.number }}" PRONTO_GITHUB_ACCESS_TOKEN="${{ github.token }}" bundle exec pronto run -f github_status github_pr -c origin/${{ github.base_ref }}
@@ -0,0 +1,112 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "generators/boring/pronto/base_generator"
4
+ require "boring_generators/generator_helper"
5
+
6
+ module Boring
7
+ module Pronto
8
+ module GitlabCi
9
+ class InstallGenerator < Boring::Pronto::BaseGenerator
10
+ desc "Adds Pronto gem with various extensions and configures it for Gitlab CI"
11
+ source_root File.expand_path("templates", __dir__)
12
+
13
+ class_option :ruby_version, type: :string, aliases: "-rv"
14
+
15
+ include BoringGenerators::GeneratorHelper
16
+
17
+ def add_configuration
18
+ @ruby_version = options.ruby_version || app_ruby_version
19
+
20
+ if File.exist?(".gitlab-ci.yml")
21
+ add_pronto_configuration
22
+ add_lint_stage
23
+ show_readme
24
+ else
25
+ create_gitlab_ci_with_pronto
26
+ end
27
+ end
28
+
29
+ private
30
+
31
+ def create_gitlab_ci_with_pronto
32
+ say "Creating .gitlab-ci.yml with Pronto configurations", :yellow
33
+ template ".gitlab-ci.yml", ".gitlab-ci.yml"
34
+ end
35
+
36
+ def add_pronto_configuration
37
+ return if pronto_configuration_exists?
38
+
39
+ say "Adding Pronto configurations to .gitlab-ci.yml", :green
40
+ inject_into_file ".gitlab-ci.yml", pronto_ci_content, before: /\Z/
41
+ end
42
+
43
+ def add_lint_stage
44
+ return if lint_stage_exists?
45
+
46
+ if stages_exists?
47
+ inject_into_file ".gitlab-ci.yml",
48
+ optimize_indentation("\n- lint", 2).chomp,
49
+ after: /stages:/
50
+ else
51
+ inject_into_file ".gitlab-ci.yml",
52
+ stages_configuration,
53
+ before: /pronto:/
54
+ end
55
+ end
56
+
57
+ def show_readme
58
+ readme "README"
59
+ end
60
+
61
+ def pronto_configuration_exists?
62
+ gitlab_ci_file_content["pronto"]
63
+ end
64
+
65
+ def lint_stage_exists?
66
+ gitlab_ci_file_content["stages"] &&
67
+ gitlab_ci_file_content["stages"].include?("lint")
68
+ end
69
+
70
+ def stages_exists?
71
+ gitlab_ci_file_content["stages"]
72
+ end
73
+
74
+ def gitlab_ci_file_content
75
+ @gitlab_ci_file_content ||=
76
+ YAML.safe_load(File.open(".gitlab-ci.yml"), aliases: true) || {}
77
+ end
78
+
79
+ def pronto_ci_content
80
+ <<~RUBY
81
+ pronto:
82
+ image: ruby:#{@ruby_version}
83
+ stage: lint
84
+ only:
85
+ # run pronto on merge requests and when new changes are pushed to it
86
+ - merge_requests
87
+ variables:
88
+ PRONTO_GITLAB_API_PRIVATE_TOKEN: $PRONTO_ACCESS_TOKEN
89
+ before_script:
90
+ # Install cmake required for rugged gem (Pronto depends on it)
91
+ - apt-get update && apt-get install -y cmake
92
+ # use bundler version same as the one that bundled the Gemfile
93
+ - gem install bundler -v "$(grep -A 1 "BUNDLED WITH" Gemfile.lock | tail -n 1)" --no-document
94
+ - bundle install --jobs $(nproc)
95
+ script:
96
+ # Pronto fails with the error "revspec 'origin/{target_branch}' because Gitlab fetches changes with git depth set to 20 by default. You can remove this line if you update Gitlab CI setting to clone the full project.
97
+ - git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
98
+ # Run pronto on branch of current merge request
99
+ - bundle exec pronto run -f gitlab_mr -c origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
100
+ RUBY
101
+ end
102
+
103
+ def stages_configuration
104
+ <<~RUBY
105
+ stages:
106
+ - lint
107
+ RUBY
108
+ end
109
+ end
110
+ end
111
+ end
112
+ end
@@ -0,0 +1,22 @@
1
+ stages:
2
+ - lint
3
+
4
+ pronto:
5
+ image: ruby:<%= @ruby_version %>
6
+ stage: lint
7
+ only:
8
+ # run pronto on merge requests and when new changes are pushed to it
9
+ - merge_requests
10
+ variables:
11
+ PRONTO_GITLAB_API_PRIVATE_TOKEN: $PRONTO_ACCESS_TOKEN
12
+ before_script:
13
+ # Install cmake required for rugged gem (Pronto depends on it)
14
+ - apt-get update && apt-get install -y cmake
15
+ # use bundler version same as the one that bundled the Gemfile
16
+ - gem install bundler -v "$(grep -A 1 "BUNDLED WITH" Gemfile.lock | tail -n 1)" --no-document
17
+ - bundle install --jobs $(nproc)
18
+ script:
19
+ # Pronto fails with the error "revspec 'origin/{target_branch}' because Gitlab fetches changes with git depth set to 20 by default. You can remove this line if you update Gitlab CI setting to clone the full project.
20
+ - git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
21
+ # Run pronto on branch of current merge request
22
+ - bundle exec pronto run -f gitlab_mr -c origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
@@ -0,0 +1,7 @@
1
+
2
+ ===============================================================================
3
+
4
+ ❗️❗️
5
+ Pronto needs your Private Gitlab API token for posting comments in the merge request. It is configured as "PRONTO_ACCESS_TOKEN" inside .gitlab-ci.yml, don't forget to configure this variable in your Gitlab Project settings before pushing your new changes to git.
6
+
7
+ ===============================================================================
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'boring_generators/generator_helper'
4
+
5
+ module Boring
6
+ module RackMiniProfiler
7
+ class InstallGenerator < Rails::Generators::Base
8
+ include BoringGenerators::GeneratorHelper
9
+
10
+ desc "Adds rack-mini-profiler to the application"
11
+
12
+ def add_rack_mini_profiler_gem
13
+ say "Adding rack-mini-profiler gem", :green
14
+
15
+ return if gem_installed?("rack-mini-profiler")
16
+
17
+ rack_mini_profiler_gems_content = <<~RUBY
18
+ \t# Profiler for your Rails application
19
+ \tgem 'rack-mini-profiler', require: false\n
20
+ RUBY
21
+
22
+ insert_into_file "Gemfile",
23
+ rack_mini_profiler_gems_content,
24
+ after: /group :development do\n/
25
+
26
+ Bundler.with_unbundled_env { run "bundle install" }
27
+ end
28
+
29
+ def configure_rack_mini_profiler
30
+ say "Configuring rack mini profiler", :green
31
+
32
+ Bundler.with_unbundled_env do
33
+ run "bundle exec rails g rack_mini_profiler:install"
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'boring_generators/generator_helper'
4
+
5
+ module Boring
6
+ module RailsErd
7
+ class InstallGenerator < Rails::Generators::Base
8
+ include BoringGenerators::GeneratorHelper
9
+
10
+ desc 'Adds rails-erd gem to the app for generating ERD diagrams'
11
+
12
+ def add_rails_erd_gem
13
+ if gem_installed?("rails-erd")
14
+ say "rails-erd is already in the Gemfile, skipping it ...", :yellow
15
+ else
16
+ say "Adding rails-erd gem", :green
17
+ gem_content = <<~RUBY
18
+ \n
19
+ \tgem "rails-erd"
20
+ RUBY
21
+ insert_into_file "Gemfile", gem_content, after: /group :development do/
22
+ bundle_install
23
+ end
24
+ end
25
+
26
+ def configure_rails_erd_gem
27
+ say 'Configuring rails-erd gem', :green
28
+
29
+ Bundler.with_unbundled_env do
30
+ run 'bundle exec rails g erd:install'
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -14,7 +14,7 @@ module Boring
14
14
  def add_rspec_gem
15
15
  log :adding, "rspec-rails"
16
16
  Bundler.with_unbundled_env do
17
- run "bundle add rspec-rails --group='developement,test'"
17
+ run "bundle add rspec-rails --group='development,test'"
18
18
  end
19
19
  end
20
20