mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Move include Kernel
into .rbi
files again and split up existing .rbi
files.
This commit is contained in:
parent
e509b1317e
commit
61b79318ed
29
Library/Homebrew/cli/args.rbi
Normal file
29
Library/Homebrew/cli/args.rbi
Normal file
@ -0,0 +1,29 @@
|
||||
# typed: strict
|
||||
|
||||
module Homebrew
|
||||
module CLI
|
||||
class Args < OpenStruct
|
||||
def devel?; end
|
||||
|
||||
def HEAD?; end
|
||||
|
||||
def include_test?; end
|
||||
|
||||
def build_bottle?; end
|
||||
|
||||
def build_universal?; end
|
||||
|
||||
def build_from_source?; end
|
||||
|
||||
def named_args; end
|
||||
|
||||
def force_bottle?; end
|
||||
|
||||
def debug?; end
|
||||
|
||||
def quiet?; end
|
||||
|
||||
def verbose?; end
|
||||
end
|
||||
end
|
||||
end
|
15
Library/Homebrew/compat/cli/parser.rbi
Normal file
15
Library/Homebrew/compat/cli/parser.rbi
Normal file
@ -0,0 +1,15 @@
|
||||
# typed: strict
|
||||
|
||||
module Homebrew
|
||||
module CLI
|
||||
class Parser
|
||||
module Compat
|
||||
include Kernel
|
||||
|
||||
module DeprecatedArgs
|
||||
include Kernel
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
9
Library/Homebrew/compat/dependencies_helpers.rbi
Normal file
9
Library/Homebrew/compat/dependencies_helpers.rbi
Normal file
@ -0,0 +1,9 @@
|
||||
# typed: strict
|
||||
|
||||
module DependenciesHelpers
|
||||
module Compat
|
||||
include Kernel
|
||||
|
||||
def args_includes_ignores(args); end
|
||||
end
|
||||
end
|
7
Library/Homebrew/compat/extend/nil.rbi
Normal file
7
Library/Homebrew/compat/extend/nil.rbi
Normal file
@ -0,0 +1,7 @@
|
||||
# typed: strict
|
||||
|
||||
class NilClass
|
||||
module Compat
|
||||
include Kernel
|
||||
end
|
||||
end
|
7
Library/Homebrew/compat/extend/string.rbi
Normal file
7
Library/Homebrew/compat/extend/string.rbi
Normal file
@ -0,0 +1,7 @@
|
||||
# typed: strict
|
||||
|
||||
class String
|
||||
module Compat
|
||||
include Kernel
|
||||
end
|
||||
end
|
11
Library/Homebrew/compat/formula.rbi
Normal file
11
Library/Homebrew/compat/formula.rbi
Normal file
@ -0,0 +1,11 @@
|
||||
# typed: strict
|
||||
|
||||
class Formula
|
||||
module Compat
|
||||
include Kernel
|
||||
|
||||
def any_installed_keg; end
|
||||
|
||||
def latest_installed_prefix; end
|
||||
end
|
||||
end
|
11
Library/Homebrew/compat/os/mac.rbi
Normal file
11
Library/Homebrew/compat/os/mac.rbi
Normal file
@ -0,0 +1,11 @@
|
||||
# typed: strict
|
||||
|
||||
module OS
|
||||
module Mac
|
||||
class << self
|
||||
module Compat
|
||||
include Kernel
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
5
Library/Homebrew/dependable.rbi
Normal file
5
Library/Homebrew/dependable.rbi
Normal file
@ -0,0 +1,5 @@
|
||||
# typed: strict
|
||||
|
||||
module Dependable
|
||||
def tags; end
|
||||
end
|
5
Library/Homebrew/dependencies_helpers.rbi
Normal file
5
Library/Homebrew/dependencies_helpers.rbi
Normal file
@ -0,0 +1,5 @@
|
||||
# typed: strict
|
||||
|
||||
module DependenciesHelpers
|
||||
include Kernel
|
||||
end
|
@ -3,8 +3,11 @@
|
||||
|
||||
require "formula"
|
||||
require "os/linux/glibc"
|
||||
require "system_command"
|
||||
|
||||
module SystemConfig
|
||||
include SystemCommand::Mixin
|
||||
|
||||
HOST_RUBY_PATH = "/usr/bin/ruby"
|
||||
|
||||
class << self
|
||||
|
@ -1,8 +1,12 @@
|
||||
# typed: true
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "system_command"
|
||||
|
||||
module SystemConfig
|
||||
class << self
|
||||
include SystemCommand::Mixin
|
||||
|
||||
undef describe_java, describe_homebrew_ruby
|
||||
|
||||
def describe_java
|
||||
|
5
Library/Homebrew/global.rbi
Normal file
5
Library/Homebrew/global.rbi
Normal file
@ -0,0 +1,5 @@
|
||||
# typed: strict
|
||||
|
||||
module Homebrew
|
||||
include Kernel
|
||||
end
|
7
Library/Homebrew/help.rbi
Normal file
7
Library/Homebrew/help.rbi
Normal file
@ -0,0 +1,7 @@
|
||||
# typed: strict
|
||||
|
||||
module Homebrew
|
||||
module Help
|
||||
include Kernel
|
||||
end
|
||||
end
|
7
Library/Homebrew/install.rbi
Normal file
7
Library/Homebrew/install.rbi
Normal file
@ -0,0 +1,7 @@
|
||||
# typed: strict
|
||||
|
||||
module Homebrew
|
||||
module Install
|
||||
include Kernel
|
||||
end
|
||||
end
|
9
Library/Homebrew/language/perl.rbi
Normal file
9
Library/Homebrew/language/perl.rbi
Normal file
@ -0,0 +1,9 @@
|
||||
# typed: strict
|
||||
|
||||
module Language
|
||||
module Perl
|
||||
module Shebang
|
||||
include Kernel
|
||||
end
|
||||
end
|
||||
end
|
7
Library/Homebrew/os/linux.rbi
Normal file
7
Library/Homebrew/os/linux.rbi
Normal file
@ -0,0 +1,7 @@
|
||||
# typed: strict
|
||||
|
||||
module OS
|
||||
module Linux
|
||||
include ::Kernel
|
||||
end
|
||||
end
|
7
Library/Homebrew/os/mac.rbi
Normal file
7
Library/Homebrew/os/mac.rbi
Normal file
@ -0,0 +1,7 @@
|
||||
# typed: strict
|
||||
|
||||
module OS
|
||||
module Mac
|
||||
include Kernel
|
||||
end
|
||||
end
|
@ -1,37 +0,0 @@
|
||||
# typed: strict
|
||||
|
||||
module Homebrew::CLI
|
||||
class Args < OpenStruct
|
||||
def devel?; end
|
||||
|
||||
def HEAD?; end
|
||||
|
||||
def include_test?; end
|
||||
|
||||
def build_bottle?; end
|
||||
|
||||
def build_universal?; end
|
||||
|
||||
def build_from_source?; end
|
||||
|
||||
def named_args; end
|
||||
|
||||
def force_bottle?; end
|
||||
|
||||
def debug?; end
|
||||
|
||||
def quiet?; end
|
||||
|
||||
def verbose?; end
|
||||
end
|
||||
|
||||
|
||||
class Parser
|
||||
module Compat
|
||||
include Kernel
|
||||
module DeprecatedArgs
|
||||
include Kernel
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -1,65 +0,0 @@
|
||||
# typed: strict
|
||||
|
||||
module Homebrew
|
||||
include Kernel
|
||||
end
|
||||
|
||||
module Homebrew::Help
|
||||
include Kernel
|
||||
end
|
||||
|
||||
module Homebrew::Fetch
|
||||
def args; end
|
||||
end
|
||||
|
||||
module Homebrew::Install
|
||||
include Kernel
|
||||
end
|
||||
|
||||
module Language::Perl::Shebang
|
||||
include Kernel
|
||||
end
|
||||
|
||||
module Dependable
|
||||
def tags; end
|
||||
end
|
||||
|
||||
module DependenciesHelpers
|
||||
include Kernel
|
||||
|
||||
module Compat
|
||||
include Kernel
|
||||
|
||||
def args_includes_ignores(args); end
|
||||
end
|
||||
end
|
||||
|
||||
class Formula
|
||||
module Compat
|
||||
include Kernel
|
||||
|
||||
def latest_version_installed?; end
|
||||
|
||||
def active_spec; end
|
||||
|
||||
def any_installed_keg; end
|
||||
|
||||
def latest_installed_prefix; end
|
||||
|
||||
def patches; end
|
||||
end
|
||||
end
|
||||
|
||||
class NilClass
|
||||
module Compat
|
||||
include Kernel
|
||||
end
|
||||
end
|
||||
|
||||
class String
|
||||
module Compat
|
||||
include Kernel
|
||||
|
||||
def chomp; end
|
||||
end
|
||||
end
|
@ -1,22 +0,0 @@
|
||||
# typed: true
|
||||
|
||||
module OS
|
||||
module Linux
|
||||
include Kernel
|
||||
|
||||
def which(cmd, path = ENV["PATH"])
|
||||
end
|
||||
end
|
||||
|
||||
module Mac
|
||||
include Kernel
|
||||
end
|
||||
end
|
||||
|
||||
module OS::Mac
|
||||
class << self
|
||||
module Compat
|
||||
include Kernel
|
||||
end
|
||||
end
|
||||
end
|
@ -1,4 +1,4 @@
|
||||
# typed: false
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Add your extra requires here
|
||||
|
@ -7,13 +7,16 @@ require "plist"
|
||||
require "shellwords"
|
||||
|
||||
require "extend/io"
|
||||
require "extend/predicable"
|
||||
require "extend/hash_validator"
|
||||
using HashValidator
|
||||
|
||||
# Make `system_command` available everywhere.
|
||||
# Class for running sub-processes and capturing their output and exit status.
|
||||
#
|
||||
# @api private
|
||||
module Kernel
|
||||
class SystemCommand
|
||||
# Helper functions for calling `SystemCommand.run`.
|
||||
module Mixin
|
||||
def system_command(*args)
|
||||
SystemCommand.run(*args)
|
||||
end
|
||||
@ -23,10 +26,6 @@ module Kernel
|
||||
end
|
||||
end
|
||||
|
||||
# Class for running sub-processes and capturing their output and exit status.
|
||||
#
|
||||
# @api private
|
||||
class SystemCommand
|
||||
include Context
|
||||
extend Predicable
|
||||
|
||||
@ -248,3 +247,7 @@ class SystemCommand
|
||||
private :warn_plist_garbage
|
||||
end
|
||||
end
|
||||
|
||||
# Make `system_command` available everywhere.
|
||||
# FIXME: Include this explicitly only where it is needed.
|
||||
include SystemCommand::Mixin # rubocop:disable Style/MixinUsage
|
||||
|
@ -5,12 +5,15 @@ require "hardware"
|
||||
require "software_spec"
|
||||
require "development_tools"
|
||||
require "extend/ENV"
|
||||
require "system_command"
|
||||
|
||||
# Helper module for querying information about the system configuration.
|
||||
#
|
||||
# @api private
|
||||
module SystemConfig
|
||||
class << self
|
||||
include SystemCommand::Mixin
|
||||
|
||||
def clang
|
||||
@clang ||= if DevelopmentTools.installed?
|
||||
DevelopmentTools.clang_version
|
||||
|
@ -1,10 +1,14 @@
|
||||
# typed: false
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "system_command"
|
||||
|
||||
# Module containing all available strategies for unpacking archives.
|
||||
#
|
||||
# @api private
|
||||
module UnpackStrategy
|
||||
include SystemCommand::Mixin
|
||||
|
||||
# Helper module for identifying the file type.
|
||||
module Magic
|
||||
# Length of the longest regex (currently Tar).
|
||||
|
@ -1,10 +1,13 @@
|
||||
# typed: true
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "system_command"
|
||||
|
||||
module UnpackStrategy
|
||||
# Strategy for unpacking Fossil repositories.
|
||||
class Fossil
|
||||
include UnpackStrategy
|
||||
extend SystemCommand::Mixin
|
||||
|
||||
using Magic
|
||||
|
||||
|
@ -1,10 +1,13 @@
|
||||
# typed: true
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "system_command"
|
||||
|
||||
module UnpackStrategy
|
||||
# Strategy for unpacking tar archives.
|
||||
class Tar
|
||||
include UnpackStrategy
|
||||
extend SystemCommand::Mixin
|
||||
|
||||
using Magic
|
||||
|
||||
|
@ -8,7 +8,6 @@ module Utils
|
||||
#
|
||||
# @api private
|
||||
module Inreplace
|
||||
include Kernel
|
||||
extend T::Sig
|
||||
|
||||
# Error during replacement.
|
||||
|
7
Library/Homebrew/utils/inreplace.rbi
Normal file
7
Library/Homebrew/utils/inreplace.rbi
Normal file
@ -0,0 +1,7 @@
|
||||
# typed: strict
|
||||
|
||||
module Utils
|
||||
module Inreplace
|
||||
include Kernel
|
||||
end
|
||||
end
|
@ -6,8 +6,6 @@ module Utils
|
||||
#
|
||||
# @api private
|
||||
module Link
|
||||
include Kernel
|
||||
|
||||
module_function
|
||||
|
||||
def link_src_dst_dirs(src_dir, dst_dir, command, link_dir: false)
|
||||
|
7
Library/Homebrew/utils/link.rbi
Normal file
7
Library/Homebrew/utils/link.rbi
Normal file
@ -0,0 +1,7 @@
|
||||
# typed: strict
|
||||
|
||||
module Utils
|
||||
module Link
|
||||
include Kernel
|
||||
end
|
||||
end
|
@ -6,8 +6,6 @@ module Utils
|
||||
#
|
||||
# @api private
|
||||
module Shebang
|
||||
include Kernel
|
||||
|
||||
module_function
|
||||
|
||||
# Specification on how to rewrite a given shebang.
|
||||
|
7
Library/Homebrew/utils/shebang.rbi
Normal file
7
Library/Homebrew/utils/shebang.rbi
Normal file
@ -0,0 +1,7 @@
|
||||
# typed: strict
|
||||
|
||||
module Utils
|
||||
module Shebang
|
||||
include Kernel
|
||||
end
|
||||
end
|
@ -3,7 +3,6 @@
|
||||
|
||||
module Utils
|
||||
module Shell
|
||||
include Kernel
|
||||
extend T::Sig
|
||||
|
||||
module_function
|
||||
|
7
Library/Homebrew/utils/shell.rbi
Normal file
7
Library/Homebrew/utils/shell.rbi
Normal file
@ -0,0 +1,7 @@
|
||||
# typed: strict
|
||||
|
||||
module Utils
|
||||
module Shell
|
||||
include Kernel
|
||||
end
|
||||
end
|
@ -8,10 +8,10 @@ module Utils
|
||||
#
|
||||
# @api private
|
||||
module Svn
|
||||
include Kernel
|
||||
class << self
|
||||
extend T::Sig
|
||||
|
||||
module_function
|
||||
include SystemCommand::Mixin
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def available?
|
||||
@ -30,10 +30,9 @@ module Utils
|
||||
def remote_exists?(url)
|
||||
return true unless available?
|
||||
|
||||
# OK to unconditionally trust here because we're just checking if
|
||||
# a URL exists.
|
||||
quiet_system "svn", "ls", url, "--depth", "empty",
|
||||
"--non-interactive", "--trust-server-cert"
|
||||
# OK to unconditionally trust here because we're just checking if a URL exists.
|
||||
system_command("svn", args: ["ls", url, "--depth", "empty",
|
||||
"--non-interactive", "--trust-server-cert"], print_stderr: false).success?
|
||||
end
|
||||
|
||||
def clear_version_cache
|
||||
@ -41,3 +40,4 @@ module Utils
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -6,10 +6,7 @@ module Utils
|
||||
#
|
||||
# @api private
|
||||
module Tar
|
||||
include Kernel
|
||||
|
||||
module_function
|
||||
|
||||
class << self
|
||||
TAR_FILE_EXTENSIONS = %w[.tar .tb2 .tbz .tbz2 .tgz .tlz .txz .tZ].freeze
|
||||
|
||||
def available?
|
||||
@ -39,3 +36,4 @@ module Utils
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -5,14 +5,12 @@
|
||||
#
|
||||
# @api private
|
||||
module Tty
|
||||
include Kernel
|
||||
extend T::Sig
|
||||
|
||||
@stream = $stdout
|
||||
|
||||
module_function
|
||||
class << self
|
||||
extend T::Sig
|
||||
|
||||
sig { params(stream: IO, _block: T.proc.params(arg0: IO).void).void }
|
||||
sig { params(stream: T.any(IO, StringIO), _block: T.proc.params(arg0: T.any(IO, StringIO)).void).void }
|
||||
def with(stream, &_block)
|
||||
previous_stream = @stream
|
||||
@stream = stream
|
||||
@ -72,13 +70,6 @@ module Tty
|
||||
|
||||
CODES = COLOR_CODES.merge(STYLE_CODES).freeze
|
||||
|
||||
sig { params(code: Integer).returns(T.self_type) }
|
||||
def append_to_escape_sequence(code)
|
||||
@escape_sequence ||= []
|
||||
@escape_sequence << code
|
||||
self
|
||||
end
|
||||
|
||||
sig { returns(String) }
|
||||
def current_escape_sequence
|
||||
return "" if @escape_sequence.nil?
|
||||
@ -92,13 +83,15 @@ module Tty
|
||||
end
|
||||
|
||||
CODES.each do |name, code|
|
||||
define_singleton_method(name) do
|
||||
append_to_escape_sequence(code)
|
||||
define_method(name) do
|
||||
@escape_sequence ||= []
|
||||
@escape_sequence << code
|
||||
self
|
||||
end
|
||||
end
|
||||
|
||||
SPECIAL_CODES.each do |name, code|
|
||||
define_singleton_method(name) do
|
||||
define_method(name) do
|
||||
if @stream.tty?
|
||||
"\033[#{code}"
|
||||
else
|
||||
@ -124,3 +117,4 @@ module Tty
|
||||
@stream.tty?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -10,9 +10,10 @@ require "system_command"
|
||||
#
|
||||
# @api private
|
||||
class User < SimpleDelegator
|
||||
include Kernel
|
||||
extend T::Sig
|
||||
|
||||
include SystemCommand::Mixin
|
||||
|
||||
# Return whether the user has an active GUI session.
|
||||
sig { returns(T::Boolean) }
|
||||
def gui?
|
||||
|
Loading…
x
Reference in New Issue
Block a user