Class: Homebrew::DevCmd::GenerateCaskApi Private

Inherits:
AbstractCommand show all
Defined in:
sorbet/rbi/dsl/homebrew/dev_cmd/generate_cask_api.rbi,
dev-cmd/generate-cask-api.rb

Overview

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

DO NOT EDIT MANUALLY This is an autogenerated file for dynamic methods in Homebrew::DevCmd::GenerateCaskApi. Please instead update this file by running bin/tapioca dsl Homebrew::DevCmd::GenerateCaskApi.

Defined Under Namespace

Classes: Args

Constant Summary collapse

CASK_JSON_TEMPLATE =

This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

<<~EOS
  ---
  layout: cask_json
  ---
  {{ content }}
EOS

Instance Method Summary collapse

Methods inherited from AbstractCommand

command, command_name, dev_cmd?, #initialize, parser

Constructor Details

This class inherits a constructor from Homebrew::AbstractCommand

Instance Method Details

#argsHomebrew::DevCmd::GenerateCaskApi::Args

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



9
# File 'sorbet/rbi/dsl/homebrew/dev_cmd/generate_cask_api.rbi', line 9

def args; end

#runvoid

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'dev-cmd/generate-cask-api.rb', line 31

def run
  tap = CoreCaskTap.instance
  raise TapUnavailableError, tap.name unless tap.installed?

  unless args.dry_run?
    directories = ["_data/cask", "api/cask", "api/cask-source", "cask", "api/internal/v3"].freeze
    FileUtils.rm_rf directories
    FileUtils.mkdir_p directories
  end

  Homebrew.with_no_api_env do
    tap_migrations_json = JSON.dump(tap.tap_migrations)
    File.write("api/cask_tap_migrations.json", tap_migrations_json) unless args.dry_run?

    Cask::Cask.generating_hash!

    tap.cask_files.each do |path|
      cask = Cask::CaskLoader.load(path)
      name = cask.token
      json = JSON.pretty_generate(cask.to_hash_with_variations)
      cask_source = path.read
      html_template_name = html_template(name)

      unless args.dry_run?
        File.write("_data/cask/#{name}.json", "#{json}\n")
        File.write("api/cask/#{name}.json", CASK_JSON_TEMPLATE)
        File.write("api/cask-source/#{name}.rb", cask_source)
        File.write("cask/#{name}.html", html_template_name)
      end
    rescue
      onoe "Error while generating data for cask '#{path.stem}'."
      raise
    end

    homebrew_cask_tap_json = JSON.generate(tap.to_internal_api_hash)
    File.write("api/internal/v3/homebrew-cask.json", homebrew_cask_tap_json) unless args.dry_run?
  end
end