Class: Merci::Command

Inherits:
Bundler::Plugin::API
  • Object
show all
Defined in:
lib/merci.rb

Instance Method Summary collapse

Instance Method Details

#exec(_cmd, _args) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/merci.rb', line 10

def exec(_cmd, _args)
  unless Bundler.settings['BUNDLE_MERCI_GITHUB_TOKEN']
    token = Bundler.ui.ask("Please input a valid github token. You can generate a token using this link https://github.com/settings/tokens/new?scopes=public_repo&description=Token%20for%20Bundler%20merci\n")
    Bundler.settings.set_global('BUNDLE_MERCI_GITHUB_TOKEN', token)
  end

  sources = Bundler.definition.specs.each_with_object([]) do |spec, github_sources|
    next unless direct_dependency?(spec) && hosted_on_rubygem?(spec)

    source_code = source_code_uri(spec)
    github_sources << source_code if source_code
  end

  Bundler.ui.info('Starring dependencies your project depends on. Hold tight!')

  repo_ids = execute_graphql_request(graphql_repo_template(sources))
  execute_graphql_request(graphql_add_star_template(repo_ids))

  Bundler.ui.info('Successfully starred all the repo your project depends on!')
end