Class: Bundler::Codegraph::Command

Inherits:
Plugin::API
  • Object
show all
Defined in:
lib/bundler/codegraph/command.rb

Overview

bundle codegraph-index [--force]

Indexes every gem of the current bundle, and runs codegraph sync on the indexes already there — which also completes one a killed run left partial. Loaded only from plugins.rb, so the rest of the gem stays testable without Bundler's plugin API.

Constant Summary collapse

FORCE_FLAG =
'--force'
STATUS_LABELS =

Labels for the statuses worth reporting; anything else is silent noise.

{
  indexed:         'indexed',
  synced:          'synchronized',
  already_indexed: 'already indexed',
  excluded:        'excluded',
  no_ruby:         'no Ruby source',
  missing:         'not installed',
  unavailable:     'codegraph not found',
  disabled:        'disabled',
  failed:          'failed',
}.freeze
HELP_FLAGS =
%w[--help -h].freeze
USAGE =
<<~USAGE
  Usage: bundle codegraph-index [--force]

  Indexes every gem of the bundle with codegraph, and syncs the indexes already there.

    --force  rebuild every index from scratch
USAGE

Instance Method Summary collapse

Instance Method Details

#exec(_command_name, args) ⇒ Object

Exits non-zero (through a Bundler::BundlerError) on an unknown argument, when the binary is missing — before walking the bundle, rather than reporting every gem as codegraph not found — and once every gem was tried when any of them failed, so a script can tell. --help is what bundle help codegraph-index passes.



44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/bundler/codegraph/command.rb', line 44

def exec(_command_name, args)
  return Bundler.ui.info(USAGE) if args.intersect?(HELP_FLAGS)

  force  = force?(args)
  config = Config.new
  ensure_executable(config)
  Codegraph.warn_untrusted_runtime_dir(Bundler.ui, config)

  results = Backfill.new(gem_specs, config: config, force: force, sync: true, reporter: method(:report)).call
  Bundler.ui.info("\n#{summary(results)}")
  ensure_no_failure(results)
end