Class: Homebrew::DevCmd::GenerateInternalApi Private
- Inherits:
-
AbstractCommand
- Object
- AbstractCommand
- Homebrew::DevCmd::GenerateInternalApi
- Defined in:
- dev-cmd/generate-internal-api.rb,
sorbet/rbi/dsl/homebrew/dev_cmd/generate_internal_api.rbi
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.
Defined Under Namespace
Classes: Args
Instance Method Summary collapse
- #args ⇒ Homebrew::DevCmd::GenerateInternalApi::Args private
- #run ⇒ void private
Methods inherited from AbstractCommand
command, command_name, dev_cmd?, #initialize, parser, ruby_cmd?
Methods included from Utils::Output::Mixin
#issue_reporting_message, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_install_status, #pretty_installed, #pretty_outdated, #pretty_uninstalled, #pretty_upgradable
Constructor Details
This class inherits a constructor from Homebrew::AbstractCommand
Instance Method Details
#args ⇒ Homebrew::DevCmd::GenerateInternalApi::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.
10 |
# File 'sorbet/rbi/dsl/homebrew/dev_cmd/generate_internal_api.rbi', line 10 def args; end |
#run ⇒ void
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.
26 27 28 29 30 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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'dev-cmd/generate-internal-api.rb', line 26 def run core_tap = CoreTap.instance cask_tap = CoreCaskTap.instance raise TapUnavailableError, core_tap.name unless core_tap.installed? raise TapUnavailableError, cask_tap.name unless cask_tap.installed? unless args.dry_run? FileUtils.rm_rf "api/internal" FileUtils.mkdir_p "api/internal" end executables_path = Pathname("api/internal/executables.txt") # Use the existing executables database as the API generation source. # It is generated from GitHub Packages metadata, not generated API JSON. if !args.dry_run? && !Homebrew::API.download_executables_file_from_github_packages!(executables_path) odie "Failed to download #{executables_path}" end executables = ExecutablesDB.new(executables_path.to_s).to_hash Homebrew.with_no_api_env do Formulary.enable_factory_cache! Formula. Cask::Cask. all_formulae = {} all_casks = {} latest_macos = MacOSVersion.new(HOMEBREW_MACOS_NEWEST_SUPPORTED).to_sym Homebrew::SimulateSystem.with(os: latest_macos, arch: :arm) do core_tap.formula_names.each do |name| formula = Formulary.factory(name) name = formula.name all_formulae[name] = formula.to_hash_with_variations all_formulae[name]["executables"] = executables[name] if executables.key?(name) rescue onoe "Error while generating data for formula '#{name}'." raise end cask_tap.cask_files.each do |path| cask = Cask::CaskLoader.load(path) name = cask.token all_casks[name] = cask.to_hash_with_variations rescue onoe "Error while generating data for cask '#{path.stem}'." raise end end OnSystem::VALID_OS_ARCH_TAGS.each do |bottle_tag| formulae = all_formulae.to_h do |name, hash| hash = Homebrew::API::Formula::FormulaStructGenerator.generate_formula_struct_hash(hash, bottle_tag:) .serialize(bottle_tag:) [name, hash] end casks = all_casks.to_h do |token, hash| hash = Homebrew::API::Cask::CaskStructGenerator.generate_cask_struct_hash(hash, bottle_tag:) .serialize [token, hash] end json_contents = { metadata: { homebrew_version: HOMEBREW_VERSION, bottle_tag: bottle_tag.to_s, generated_at: Time.now.to_i, }, formulae:, casks:, formula_aliases: core_tap.alias_table, formula_renames: core_tap.formula_renames, cask_renames: cask_tap.cask_renames, formula_tap_git_head: core_tap.git_head, cask_tap_git_head: cask_tap.git_head, formula_tap_migrations: core_tap.tap_migrations, cask_tap_migrations: cask_tap.tap_migrations, } File.write("api/internal/packages.#{bottle_tag}.json", JSON.generate(json_contents)) unless args.dry_run? end end end |