# frozen_string_literal: true require "rails/generators" module RailsTemplate18f module Generators class CircleciGenerator < ::Rails::Generators::Base include Base include PipelineOptions desc <<~DESC Description: Install CircleCI pipeline files DESC def install_needed_gems gem_name = "rspec_junit_formatter" return if gem_installed? gem_name gem gem_name, "~> 0.5", group: :test bundle_install end def install_pipeline directory "circleci", ".circleci" copy_file "docker-compose.ci.yml" template "Dockerfile" copy_file "bin/ci-server-start", mode: :preserve end def update_readme if file_content("README.md").match?(/^## CI\/CD$/) insert_into_file "README.md", readme_cicd, after: "## CI/CD\n" insert_into_file "README.md", readme_staging_deploy, after: "#### Staging\n" insert_into_file "README.md", readme_prod_deploy, after: "#### Production\n" insert_into_file "README.md", readme_credentials, after: "#### Credentials and other Secrets\n" else append_to_file "README.md", <<~EOM ## CI/CD #{readme_cicd} ### Deployment #### Staging #{readme_staging_deploy} #### Production #{readme_prod_deploy} #### Credentials and other Secrets #{readme_credentials} EOM end end def update_boundary_diagram boundary_filename = "doc/compliance/apps/application.boundary.md" insert_into_file boundary_filename, <