Class: Rolemodel::GithubGenerator
- Inherits:
-
GeneratorBase
- Object
- Rails::Generators::Base
- GeneratorBase
- Rolemodel::GithubGenerator
- Defined in:
- lib/generators/rolemodel/github/github_generator.rb
Constant Summary collapse
- GITHUB_ACTIONS_REPO =
'https://github.com/RoleModel/actions.git'
Instance Method Summary collapse
- #install_dependabot_and_codeowners ⇒ Object
- #install_github_config ⇒ Object
- #set_rm_actions_version ⇒ Object
- #set_webdriver ⇒ Object
- #update_database_yml_for_ci ⇒ Object
Instance Method Details
#install_dependabot_and_codeowners ⇒ Object
30 31 32 33 34 35 |
# File 'lib/generators/rolemodel/github/github_generator.rb', line 30 def install_dependabot_and_codeowners copy_file 'dependabot.yml', '.github/dependabot.yml', force: true copy_file 'CODEOWNERS', '.github/CODEOWNERS' say '👉 See CODEOWNERS file for important instructions.', %i[bold red on_blue] end |
#install_github_config ⇒ Object
24 25 26 27 28 |
# File 'lib/generators/rolemodel/github/github_generator.rb', line 24 def install_github_config directory 'instructions', '.github/instructions' directory 'workflows', '.github/workflows', force: true template 'pull_request_template.md', '.github/pull_request_template.md' end |
#set_rm_actions_version ⇒ Object
15 16 17 18 |
# File 'lib/generators/rolemodel/github/github_generator.rb', line 15 def set_rm_actions_version = `git ls-remote --tags #{GITHUB_ACTIONS_REPO}` rescue 'refs/tags/v3' @rm_actions_version = .scan(%r{refs/tags/v(\d+)\s*$}).flatten.max_by(&:to_i) end |
#set_webdriver ⇒ Object
20 21 22 |
# File 'lib/generators/rolemodel/github/github_generator.rb', line 20 def set_webdriver @webdriver = .playwright? ? 'playwright' : 'selenium' end |
#update_database_yml_for_ci ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/generators/rolemodel/github/github_generator.rb', line 37 def update_database_yml_for_ci insert_into_file 'config/database.yml', after: /database: .*_test.*\n/ do optimize_indentation <<~YML, 2 <% if ENV.has_key?("POSTGRES_USER") %> username: <%= ENV.fetch("POSTGRES_USER") %> password: <%= ENV.fetch("POSTGRES_PASSWORD") { nil } %> host: localhost <% end %> YML end end |