From 14a6054d11b55d265ac1b642d77ce670f6134562 Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Mon, 7 Oct 2024 18:30:55 -0700 Subject: [PATCH] Restore constants needed by homebrew-test-bot --- Library/Homebrew/cask/cask.rb | 2 +- Library/Homebrew/extend/on_system.rbi | 6 - Library/Homebrew/extend/os/mac/keg.rb | 8 ++ Library/Homebrew/keg.rb | 27 ++++- Library/Homebrew/livecheck.rb | 3 +- Library/Homebrew/sorbet/rbi/dsl/cask/dsl.rbi | 107 +++++++++++++++++ Library/Homebrew/sorbet/rbi/dsl/formula.rbi | 113 ++++++++++++++++++ .../sorbet/rbi/dsl/homebrew/service.rbi | 113 ++++++++++++++++++ .../sorbet/rbi/dsl/pour_bottle_check.rbi | 113 ++++++++++++++++++ Library/Homebrew/sorbet/rbi/dsl/resource.rbi | 113 ++++++++++++++++++ .../Homebrew/sorbet/rbi/dsl/software_spec.rbi | 113 ++++++++++++++++++ .../sorbet/tapioca/compilers/on_system.rb | 76 ++++++++++++ 12 files changed, 785 insertions(+), 9 deletions(-) delete mode 100644 Library/Homebrew/extend/on_system.rbi create mode 100644 Library/Homebrew/sorbet/rbi/dsl/cask/dsl.rbi create mode 100644 Library/Homebrew/sorbet/rbi/dsl/formula.rbi create mode 100644 Library/Homebrew/sorbet/rbi/dsl/homebrew/service.rbi create mode 100644 Library/Homebrew/sorbet/rbi/dsl/pour_bottle_check.rbi create mode 100644 Library/Homebrew/sorbet/rbi/dsl/resource.rbi create mode 100644 Library/Homebrew/sorbet/rbi/dsl/software_spec.rbi create mode 100644 Library/Homebrew/sorbet/tapioca/compilers/on_system.rb diff --git a/Library/Homebrew/cask/cask.rb b/Library/Homebrew/cask/cask.rb index 475e0478fd6ce4..a939c4512a847a 100644 --- a/Library/Homebrew/cask/cask.rb +++ b/Library/Homebrew/cask/cask.rb @@ -117,7 +117,7 @@ def refresh @dsl.language_eval end - DSL::DSL_METHODS.each do |method_name| + ::Cask::DSL::DSL_METHODS.each do |method_name| define_method(method_name) { |&block| @dsl.send(method_name, &block) } end diff --git a/Library/Homebrew/extend/on_system.rbi b/Library/Homebrew/extend/on_system.rbi deleted file mode 100644 index 15534bb4b4dbca..00000000000000 --- a/Library/Homebrew/extend/on_system.rbi +++ /dev/null @@ -1,6 +0,0 @@ -# typed: strict - -module OnSystem::MacOSOnly - sig { params(arm: T.nilable(String), intel: T.nilable(String)).returns(T.nilable(String)) } - def on_arch_conditional(arm: nil, intel: nil); end -end diff --git a/Library/Homebrew/extend/os/mac/keg.rb b/Library/Homebrew/extend/os/mac/keg.rb index aae4eb6ad35523..ec38822576fb60 100644 --- a/Library/Homebrew/extend/os/mac/keg.rb +++ b/Library/Homebrew/extend/os/mac/keg.rb @@ -3,6 +3,14 @@ require "system_command" +class Keg + GENERIC_MUST_BE_WRITABLE_DIRECTORIES = (remove_const :MUST_BE_WRITABLE_DIRECTORIES).freeze + MUST_BE_WRITABLE_DIRECTORIES = ( + GENERIC_MUST_BE_WRITABLE_DIRECTORIES + + [HOMEBREW_PREFIX/"Frameworks"] + ).sort.uniq.freeze +end + module OS module Mac module Keg diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index 0b0f67d2564cdb..ca715ac983727d 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -78,7 +78,32 @@ def to_s # Locale-specific directories have the form `language[_territory][.codeset][@modifier]` LOCALEDIR_RX = %r{(locale|man)/([a-z]{2}|C|POSIX)(_[A-Z]{2})?(\.[a-zA-Z\-0-9]+(@.+)?)?} INFOFILE_RX = %r{info/([^.].*?\.info(\.gz)?|dir)$} - + KEG_LINK_DIRECTORIES = %w[ + bin etc include lib sbin share var + ].freeze + MUST_EXIST_SUBDIRECTORIES = ( + KEG_LINK_DIRECTORIES - %w[var] + %w[ + opt + var/homebrew/linked + ] + ).map { |dir| HOMEBREW_PREFIX/dir }.sort.uniq.freeze + MUST_BE_WRITABLE_DIRECTORIES = ( + %w[ + etc/bash_completion.d lib/pkgconfig + share/aclocal share/doc share/info share/locale share/man + share/man/man1 share/man/man2 share/man/man3 share/man/man4 + share/man/man5 share/man/man6 share/man/man7 share/man/man8 + share/zsh share/zsh/site-functions + var/log + ].map { |dir| HOMEBREW_PREFIX/dir } + MUST_EXIST_SUBDIRECTORIES + [ + HOMEBREW_CACHE, + HOMEBREW_CELLAR, + HOMEBREW_LOCKS, + HOMEBREW_LOGS, + HOMEBREW_REPOSITORY, + Language::Python.homebrew_site_packages, + ] + ).sort.uniq.freeze # These paths relative to the keg's share directory should always be real # directories in the prefix, never symlinks. SHARE_PATHS = %w[ diff --git a/Library/Homebrew/livecheck.rb b/Library/Homebrew/livecheck.rb index 2b2aef45ed50a9..300caafdd3bedf 100644 --- a/Library/Homebrew/livecheck.rb +++ b/Library/Homebrew/livecheck.rb @@ -2,7 +2,8 @@ # frozen_string_literal: true require "livecheck/constants" -require "cask/cask" + +module Cask; class Cask; end; end # The {Livecheck} class implements the DSL methods used in a formula's, cask's # or resource's `livecheck` block and stores related instance variables. Most diff --git a/Library/Homebrew/sorbet/rbi/dsl/cask/dsl.rbi b/Library/Homebrew/sorbet/rbi/dsl/cask/dsl.rbi new file mode 100644 index 00000000000000..f4bb089b3af3a9 --- /dev/null +++ b/Library/Homebrew/sorbet/rbi/dsl/cask/dsl.rbi @@ -0,0 +1,107 @@ +# typed: true + +# DO NOT EDIT MANUALLY +# This is an autogenerated file for dynamic methods in `Cask::DSL`. +# Please instead update this file by running `bin/tapioca dsl Cask::DSL`. + + +class Cask::DSL + sig { params(arm: T.nilable(String), intel: T.nilable(String)).returns(T.nilable(String)) } + def on_arch_conditional(arm: nil, intel: nil); end + + sig { type_parameters(:U).params(block: T.proc.returns(T.type_parameter(:U))).returns(T.type_parameter(:U)) } + def on_arm(&block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_big_sur(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_catalina(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_el_capitan(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_high_sierra(or_condition = nil, &block); end + + sig { type_parameters(:U).params(block: T.proc.returns(T.type_parameter(:U))).returns(T.type_parameter(:U)) } + def on_intel(&block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_mojave(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_monterey(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_sequoia(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_sierra(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_sonoma(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_ventura(or_condition = nil, &block); end +end diff --git a/Library/Homebrew/sorbet/rbi/dsl/formula.rbi b/Library/Homebrew/sorbet/rbi/dsl/formula.rbi new file mode 100644 index 00000000000000..12e3678b0d9a2c --- /dev/null +++ b/Library/Homebrew/sorbet/rbi/dsl/formula.rbi @@ -0,0 +1,113 @@ +# typed: true + +# DO NOT EDIT MANUALLY +# This is an autogenerated file for dynamic methods in `Formula`. +# Please instead update this file by running `bin/tapioca dsl Formula`. + + +class Formula + sig { params(arm: T.nilable(String), intel: T.nilable(String)).returns(T.nilable(String)) } + def on_arch_conditional(arm: nil, intel: nil); end + + sig { type_parameters(:U).params(block: T.proc.returns(T.type_parameter(:U))).returns(T.type_parameter(:U)) } + def on_arm(&block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_big_sur(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_catalina(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_el_capitan(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_high_sierra(or_condition = nil, &block); end + + sig { type_parameters(:U).params(block: T.proc.returns(T.type_parameter(:U))).returns(T.type_parameter(:U)) } + def on_intel(&block); end + + sig { type_parameters(:U).params(block: T.proc.returns(T.type_parameter(:U))).returns(T.type_parameter(:U)) } + def on_linux(&block); end + + sig { type_parameters(:U).params(block: T.proc.returns(T.type_parameter(:U))).returns(T.type_parameter(:U)) } + def on_macos(&block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_mojave(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_monterey(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_sequoia(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_sierra(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_sonoma(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_ventura(or_condition = nil, &block); end +end diff --git a/Library/Homebrew/sorbet/rbi/dsl/homebrew/service.rbi b/Library/Homebrew/sorbet/rbi/dsl/homebrew/service.rbi new file mode 100644 index 00000000000000..3e4558aa10f69f --- /dev/null +++ b/Library/Homebrew/sorbet/rbi/dsl/homebrew/service.rbi @@ -0,0 +1,113 @@ +# typed: true + +# DO NOT EDIT MANUALLY +# This is an autogenerated file for dynamic methods in `Homebrew::Service`. +# Please instead update this file by running `bin/tapioca dsl Homebrew::Service`. + + +class Homebrew::Service + sig { params(arm: T.nilable(String), intel: T.nilable(String)).returns(T.nilable(String)) } + def on_arch_conditional(arm: nil, intel: nil); end + + sig { type_parameters(:U).params(block: T.proc.returns(T.type_parameter(:U))).returns(T.type_parameter(:U)) } + def on_arm(&block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_big_sur(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_catalina(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_el_capitan(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_high_sierra(or_condition = nil, &block); end + + sig { type_parameters(:U).params(block: T.proc.returns(T.type_parameter(:U))).returns(T.type_parameter(:U)) } + def on_intel(&block); end + + sig { type_parameters(:U).params(block: T.proc.returns(T.type_parameter(:U))).returns(T.type_parameter(:U)) } + def on_linux(&block); end + + sig { type_parameters(:U).params(block: T.proc.returns(T.type_parameter(:U))).returns(T.type_parameter(:U)) } + def on_macos(&block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_mojave(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_monterey(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_sequoia(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_sierra(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_sonoma(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_ventura(or_condition = nil, &block); end +end diff --git a/Library/Homebrew/sorbet/rbi/dsl/pour_bottle_check.rbi b/Library/Homebrew/sorbet/rbi/dsl/pour_bottle_check.rbi new file mode 100644 index 00000000000000..8726220ad1bfab --- /dev/null +++ b/Library/Homebrew/sorbet/rbi/dsl/pour_bottle_check.rbi @@ -0,0 +1,113 @@ +# typed: true + +# DO NOT EDIT MANUALLY +# This is an autogenerated file for dynamic methods in `PourBottleCheck`. +# Please instead update this file by running `bin/tapioca dsl PourBottleCheck`. + + +class PourBottleCheck + sig { params(arm: T.nilable(String), intel: T.nilable(String)).returns(T.nilable(String)) } + def on_arch_conditional(arm: nil, intel: nil); end + + sig { type_parameters(:U).params(block: T.proc.returns(T.type_parameter(:U))).returns(T.type_parameter(:U)) } + def on_arm(&block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_big_sur(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_catalina(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_el_capitan(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_high_sierra(or_condition = nil, &block); end + + sig { type_parameters(:U).params(block: T.proc.returns(T.type_parameter(:U))).returns(T.type_parameter(:U)) } + def on_intel(&block); end + + sig { type_parameters(:U).params(block: T.proc.returns(T.type_parameter(:U))).returns(T.type_parameter(:U)) } + def on_linux(&block); end + + sig { type_parameters(:U).params(block: T.proc.returns(T.type_parameter(:U))).returns(T.type_parameter(:U)) } + def on_macos(&block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_mojave(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_monterey(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_sequoia(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_sierra(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_sonoma(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_ventura(or_condition = nil, &block); end +end diff --git a/Library/Homebrew/sorbet/rbi/dsl/resource.rbi b/Library/Homebrew/sorbet/rbi/dsl/resource.rbi new file mode 100644 index 00000000000000..a8a90d18011df1 --- /dev/null +++ b/Library/Homebrew/sorbet/rbi/dsl/resource.rbi @@ -0,0 +1,113 @@ +# typed: true + +# DO NOT EDIT MANUALLY +# This is an autogenerated file for dynamic methods in `Resource`. +# Please instead update this file by running `bin/tapioca dsl Resource`. + + +class Resource + sig { params(arm: T.nilable(String), intel: T.nilable(String)).returns(T.nilable(String)) } + def on_arch_conditional(arm: nil, intel: nil); end + + sig { type_parameters(:U).params(block: T.proc.returns(T.type_parameter(:U))).returns(T.type_parameter(:U)) } + def on_arm(&block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_big_sur(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_catalina(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_el_capitan(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_high_sierra(or_condition = nil, &block); end + + sig { type_parameters(:U).params(block: T.proc.returns(T.type_parameter(:U))).returns(T.type_parameter(:U)) } + def on_intel(&block); end + + sig { type_parameters(:U).params(block: T.proc.returns(T.type_parameter(:U))).returns(T.type_parameter(:U)) } + def on_linux(&block); end + + sig { type_parameters(:U).params(block: T.proc.returns(T.type_parameter(:U))).returns(T.type_parameter(:U)) } + def on_macos(&block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_mojave(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_monterey(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_sequoia(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_sierra(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_sonoma(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_ventura(or_condition = nil, &block); end +end diff --git a/Library/Homebrew/sorbet/rbi/dsl/software_spec.rbi b/Library/Homebrew/sorbet/rbi/dsl/software_spec.rbi new file mode 100644 index 00000000000000..ab7d2a3efa58da --- /dev/null +++ b/Library/Homebrew/sorbet/rbi/dsl/software_spec.rbi @@ -0,0 +1,113 @@ +# typed: true + +# DO NOT EDIT MANUALLY +# This is an autogenerated file for dynamic methods in `SoftwareSpec`. +# Please instead update this file by running `bin/tapioca dsl SoftwareSpec`. + + +class SoftwareSpec + sig { params(arm: T.nilable(String), intel: T.nilable(String)).returns(T.nilable(String)) } + def on_arch_conditional(arm: nil, intel: nil); end + + sig { type_parameters(:U).params(block: T.proc.returns(T.type_parameter(:U))).returns(T.type_parameter(:U)) } + def on_arm(&block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_big_sur(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_catalina(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_el_capitan(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_high_sierra(or_condition = nil, &block); end + + sig { type_parameters(:U).params(block: T.proc.returns(T.type_parameter(:U))).returns(T.type_parameter(:U)) } + def on_intel(&block); end + + sig { type_parameters(:U).params(block: T.proc.returns(T.type_parameter(:U))).returns(T.type_parameter(:U)) } + def on_linux(&block); end + + sig { type_parameters(:U).params(block: T.proc.returns(T.type_parameter(:U))).returns(T.type_parameter(:U)) } + def on_macos(&block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_mojave(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_monterey(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_sequoia(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_sierra(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_sonoma(or_condition = nil, &block); end + + sig do + type_parameters(:U) + .params( + or_condition: T.nilable(Symbol), + block: T.proc.returns(T.type_parameter(:U)) + ).returns(T.type_parameter(:U)) + end + def on_ventura(or_condition = nil, &block); end +end diff --git a/Library/Homebrew/sorbet/tapioca/compilers/on_system.rb b/Library/Homebrew/sorbet/tapioca/compilers/on_system.rb new file mode 100644 index 00000000000000..292ede7bb1fc14 --- /dev/null +++ b/Library/Homebrew/sorbet/tapioca/compilers/on_system.rb @@ -0,0 +1,76 @@ +# typed: strict +# frozen_string_literal: true + +require_relative "../../../global" +require "cask/dsl" +require "formula" +require "resource" +require "service" +require "software_spec" + +module Tapioca + module Compilers + class OnSystemCompiler < Tapioca::Dsl::Compiler + ConstantType = type_member { { fixed: T.any(T::Class[OnSystem::MacOSAndLinux], T::Class[OnSystem::MacOSOnly]) } } + + sig { override.returns(T::Enumerable[T::Class[T.anything]]) } + def self.gather_constants + on_system_classes = all_classes.select do |klass| + klass < OnSystem::MacOSAndLinux || klass < OnSystem::MacOSOnly + end + # don't redundantly generate methods for subclasses + on_system_classes - on_system_classes.flat_map(&:subclasses) + end + + sig { override.void } + def decorate + root.create_class(T.must(constant.name)) do |klass| + # from setup_arch_methods + OnSystem::ARCH_OPTIONS.each do |arch| + klass.create_method("on_#{arch}") do |method| + method.add_block_param("block") + method.add_sig(type_params: ["U"]) do |sig| + sig.add_param("block", "T.proc.returns(T.type_parameter(:U))") + sig.return_type = "T.type_parameter(:U)" + end + end + end + klass.create_method( + "on_arch_conditional", + parameters: [ + create_kw_opt_param("arm", type: "T.nilable(String)", default: "nil"), + create_kw_opt_param("intel", type: "T.nilable(String)", default: "nil"), + ], + return_type: "T.nilable(String)" + ) + + # from setup_macos_methods + MacOSVersion::SYMBOLS.each_key do |os_name| + klass.create_method("on_#{os_name}") do |method| + method.add_opt_param("or_condition", "nil") + method.add_block_param("block") + method.add_sig(type_params: ["U"]) do |sig| + sig.add_param("or_condition", "T.nilable(Symbol)") + sig.add_param("block", "T.proc.returns(T.type_parameter(:U))") + sig.return_type = "T.type_parameter(:U)" + end + end + end + + if constant < OnSystem::MacOSAndLinux + # from setup_base_os_methods + OnSystem::BASE_OS_OPTIONS.each do |base_os| + klass.create_method("on_#{base_os}") do |method| + method.add_block_param("block") + method.add_sig(type_params: ["U"]) do |sig| + sig.add_param("block", "T.proc.returns(T.type_parameter(:U))") + sig.return_type = "T.type_parameter(:U)" + end + end + end + end + end + end + end + end +end