Sha256: 65bc761851c55c2dbc004f11ecca4abd223be2c7b6580b13967cbf44ac8a354c

Contents?: true

Size: 1.65 KB

Versions: 3

Compression:

Stored size: 1.65 KB

Contents

# frozen_string_literal: true

require "thor"

require_relative "base"

module Neetob
  class CLI
    module Github
      module MakePr
        class ComplianceFix < Base
          attr_accessor :apps, :sandbox, :should_fix_nanos

          def initialize(apps, should_fix_nanos = false, sandbox = false)
            super()
            @apps = apps
            @sandbox = sandbox
            @should_fix_nanos = should_fix_nanos
          end

          def run
            matching_apps = should_fix_nanos ?
              add_org_suffix(find_all_matching_gems) :
              find_all_matching_apps(apps, :github, sandbox)
            delete_and_create_temp_neetob_dir
            matching_apps.each do |app|
              ui.info("\nWorking on #{app}\n")
              begin
                clone_app_in_tmp_dir(app)
                check_and_delete_remote_branch(app)
                bundle_install(app)
                fix_neeto_audit(app)
                ui.info(add_commmit_and_push_changes(app))
                delete_local_feature_branch(app)
                res = client.create_pull_request(app, "main", BRANCH_NAME, PR_TITLE)
                ui.success("PR created in \"#{app}\" project successfully.")
              rescue StandardError => e
                ExceptionHandler.new(e).process
              end
            end
            `rm -rf /tmp/neetob`
          end

          private

            def bundle_install(app)
              `#{cd_to_app_in_tmp_dir(app)} && bundle install`
            end

            def fix_neeto_audit(app)
              `#{cd_to_app_in_tmp_dir(app)} && bundle exec neeto-audit -a`
            end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
neetob-0.2.2 lib/neetob/cli/github/make_pr/compliance_fix.rb
neetob-0.2.1 lib/neetob/cli/github/make_pr/compliance_fix.rb
neetob-0.2.0 lib/neetob/cli/github/make_pr/compliance_fix.rb