Class: Depec::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/depec/cli.rb

Instance Method Summary collapse

Instance Method Details

#analyze(dir) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/depec/cli.rb', line 18

def analyze(dir)
  result = Depec::Analyzer.new(dir, YAML.load_file(options["config"])).analyze
  if options["output"]
    File.open(options["output"], "w+") do |f|
      f.write(result.to_json)
    end
  else
    puts JSON.pretty_generate(result)
  end
end

#initObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/depec/cli.rb', line 30

def init
  prompt = TTY::Prompt.new
  initializer = Depec::Initializer.new

  answers = {
    ruby: prompt.yes?("? Do you want to know whether Ruby is used?: "),
    ruby_version: prompt.yes?("? Do you want to know Ruby version?: "),
    bundler_version: prompt.yes?("? Do you want to know Bundler version?: "),
    gem_version: prompt.ask("? Gem name that do you want to know version: ", default: "rails, jekyll", convert: :array),
    node: prompt.yes?("? Do you want to know whether Node.js is used?: "),
    node_version: prompt.yes?("? Do you want to know Node.js version?: "),
    npm_version: prompt.ask("? Npm package name that do you want to know version: ", default: "vue, react", convert: :array),
    circle_ci: prompt.yes?("? Do you want to know whether CircleCI is used?: "),
    circle_ci_images: prompt.yes?("? Do you want to know CircleCI images?: "),
    github_actions: prompt.yes?("? Do you want to know whether GitHub Actions is used?: "),
  }

  config = initializer.processAnswers(answers)

  File.open(Depec::DEFAULT_CONFIG_FILE, 'w+') do |f|
    f.write(YAML.dump(config))
  end
end