Sha256: 17cc9ba7f98d916c851e085e94dcf2618928a9e789db55a80c148f9f2ea37f63

Contents?: true

Size: 1.59 KB

Versions: 1

Compression:

Stored size: 1.59 KB

Contents

# frozen_string_literal: true

module DependencyBumper
  class Cli < Thor
    DEFAULT_CONFIGURATION = {
      'skip' => {},
      'outdated_level' => 'strict',
      'update' => {
        'default' => 'minor',
        'major' => {},
        'minor' => {},
        'patch' => {}
      },
      'git' => {
        'commit' => {
          'gpgsign' => false
        }
      }
    }.freeze

    package_name 'Dependency Bumper'

    option :config, type: :string
    option :git, type: :boolean
    option :dry, type: :boolean
    desc 'bump_gems', 'update dependencies of your Ruby project'
    long_desc <<-LONGDESC
     `bump_gems` will update dependencies of your Ruby project

    If you give --git option it will create a branch and commit message will include information about updated gems.

    --dry option will change Gemfile.lock but won't install gems.

    This gem looks for a config file called bumper_config.json by default and if it doesn't find it, it will use default

    configuration. You can point out another folder for configuration.

    Examples \n
    > $ dbump bump_gems --git --config myconfig.json \n
    > $ dbump bump_gems --dry \n
    > $ dbump bump_gems \n

    LONGDESC

    def bump_gems
      path = options.fetch(:config, '.bumper_config.json')
      Updater.new(load_config(Pathname.new(path)), options.slice(:dry, :git)).run
    end

    private

    def load_config(config_file)
      return JSON.parse(config_file.read) if config_file.exist?

      Console.logger.info("Couldn\'t find #{config_file} file, falling back to default values")
      DEFAULT_CONFIGURATION
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dependency_bumper-0.1.0 lib/dependency_bumper/cli.rb