Merge pull request #16937 from Homebrew/ported-cmds
Convert next batch of dev commands to use AbstractCommand
This commit is contained in:
commit
999ecf8b54
@ -17,7 +17,7 @@ module Homebrew
|
|||||||
|
|
||||||
class << self
|
class << self
|
||||||
sig { returns(String) }
|
sig { returns(String) }
|
||||||
def command_name = Utils.underscore(T.must(name).split("::").fetch(-1)).tr("_", "-")
|
def command_name = Utils.underscore(T.must(name).split("::").fetch(-1)).tr("_", "-").delete_suffix("-cmd")
|
||||||
|
|
||||||
# @return the AbstractCommand subclass associated with the brew CLI command name.
|
# @return the AbstractCommand subclass associated with the brew CLI command name.
|
||||||
sig { params(name: String).returns(T.nilable(T.class_of(AbstractCommand))) }
|
sig { params(name: String).returns(T.nilable(T.class_of(AbstractCommand))) }
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
# typed: true
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "abstract_command"
|
||||||
require "cli/parser"
|
require "cli/parser"
|
||||||
require "csv"
|
require "csv"
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "formula"
|
require "formula"
|
||||||
@ -9,11 +9,9 @@ require "utils/pypi"
|
|||||||
require "cask/cask_loader"
|
require "cask/cask_loader"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module_function
|
module DevCmd
|
||||||
|
class Create < AbstractCommand
|
||||||
sig { returns(CLI::Parser) }
|
cmd_args do
|
||||||
def create_args
|
|
||||||
Homebrew::CLI::Parser.new do
|
|
||||||
description <<~EOS
|
description <<~EOS
|
||||||
Generate a formula or, with `--cask`, a cask for the downloadable file at <URL>
|
Generate a formula or, with `--cask`, a cask for the downloadable file at <URL>
|
||||||
and open it in the editor. Homebrew will attempt to automatically derive the
|
and open it in the editor. Homebrew will attempt to automatically derive the
|
||||||
@ -67,24 +65,23 @@ module Homebrew
|
|||||||
|
|
||||||
named_args :url, number: 1
|
named_args :url, number: 1
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
# Create a formula from a tarball URL.
|
# Create a formula from a tarball URL.
|
||||||
sig { void }
|
sig { override.void }
|
||||||
def create
|
def run
|
||||||
args = create_args.parse
|
|
||||||
|
|
||||||
path = if args.cask?
|
path = if args.cask?
|
||||||
create_cask(args:)
|
create_cask
|
||||||
else
|
else
|
||||||
create_formula(args:)
|
create_formula
|
||||||
end
|
end
|
||||||
|
|
||||||
exec_editor path
|
exec_editor path
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { params(args: CLI::Args).returns(Pathname) }
|
private
|
||||||
def create_cask(args:)
|
|
||||||
|
sig { returns(Pathname) }
|
||||||
|
def create_cask
|
||||||
url = args.named.first
|
url = args.named.first
|
||||||
name = if args.set_name.blank?
|
name = if args.set_name.blank?
|
||||||
stem = Pathname.new(url).stem.rpartition("=").last
|
stem = Pathname.new(url).stem.rpartition("=").last
|
||||||
@ -155,8 +152,8 @@ module Homebrew
|
|||||||
cask_path
|
cask_path
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { params(args: CLI::Args).returns(Pathname) }
|
sig { returns(Pathname) }
|
||||||
def create_formula(args:)
|
def create_formula
|
||||||
mode = if args.autotools?
|
mode = if args.autotools?
|
||||||
:autotools
|
:autotools
|
||||||
elsif args.cmake?
|
elsif args.cmake?
|
||||||
@ -238,3 +235,5 @@ module Homebrew
|
|||||||
gots.empty? ? nil : gots
|
gots.empty? ? nil : gots
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
@ -1,14 +1,15 @@
|
|||||||
# typed: strict
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "abstract_command"
|
||||||
require "cli/parser"
|
require "cli/parser"
|
||||||
require "test_runner_formula"
|
require "test_runner_formula"
|
||||||
require "github_runner_matrix"
|
require "github_runner_matrix"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
sig { returns(Homebrew::CLI::Parser) }
|
module DevCmd
|
||||||
def self.determine_test_runners_args
|
class DetermineTestRunners < AbstractCommand
|
||||||
Homebrew::CLI::Parser.new do
|
cmd_args do
|
||||||
usage_banner <<~EOS
|
usage_banner <<~EOS
|
||||||
`determine-test-runners` {<testing-formulae> [<deleted-formulae>]|--all-supported}
|
`determine-test-runners` {<testing-formulae> [<deleted-formulae>]|--all-supported}
|
||||||
|
|
||||||
@ -30,12 +31,9 @@ module Homebrew
|
|||||||
|
|
||||||
hide_from_man_page!
|
hide_from_man_page!
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
sig { void }
|
|
||||||
def self.determine_test_runners
|
|
||||||
args = determine_test_runners_args.parse
|
|
||||||
|
|
||||||
|
sig { override.void }
|
||||||
|
def run
|
||||||
if args.no_named? && !args.all_supported?
|
if args.no_named? && !args.all_supported?
|
||||||
raise Homebrew::CLI::MinNamedArgumentsError, 1
|
raise Homebrew::CLI::MinNamedArgumentsError, 1
|
||||||
elsif args.all_supported? && !args.no_named?
|
elsif args.all_supported? && !args.no_named?
|
||||||
@ -60,3 +58,5 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
@ -1,15 +1,14 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "abstract_command"
|
||||||
require "cli/parser"
|
require "cli/parser"
|
||||||
require "utils/github"
|
require "utils/github"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module_function
|
module DevCmd
|
||||||
|
class DispatchBuildBottle < AbstractCommand
|
||||||
sig { returns(CLI::Parser) }
|
cmd_args do
|
||||||
def dispatch_build_bottle_args
|
|
||||||
Homebrew::CLI::Parser.new do
|
|
||||||
description <<~EOS
|
description <<~EOS
|
||||||
Build bottles for these formulae with GitHub Actions.
|
Build bottles for these formulae with GitHub Actions.
|
||||||
EOS
|
EOS
|
||||||
@ -35,11 +34,9 @@ module Homebrew
|
|||||||
conflicts "--linux", "--linux-self-hosted"
|
conflicts "--linux", "--linux-self-hosted"
|
||||||
named_args :formula, min: 1
|
named_args :formula, min: 1
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def dispatch_build_bottle
|
|
||||||
args = dispatch_build_bottle_args.parse
|
|
||||||
|
|
||||||
|
sig { override.void }
|
||||||
|
def run
|
||||||
tap = Tap.fetch(args.tap || CoreTap.instance.name)
|
tap = Tap.fetch(args.tap || CoreTap.instance.name)
|
||||||
user, repo = tap.full_name.split("/")
|
user, repo = tap.full_name.split("/")
|
||||||
ref = "master"
|
ref = "master"
|
||||||
@ -92,3 +89,5 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
@ -1,15 +1,14 @@
|
|||||||
# typed: strict
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "abstract_command"
|
||||||
require "formula"
|
require "formula"
|
||||||
require "cli/parser"
|
require "cli/parser"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module_function
|
module DevCmd
|
||||||
|
class Edit < AbstractCommand
|
||||||
sig { returns(CLI::Parser) }
|
cmd_args do
|
||||||
def edit_args
|
|
||||||
Homebrew::CLI::Parser.new do
|
|
||||||
description <<~EOS
|
description <<~EOS
|
||||||
Open a <formula>, <cask> or <tap> in the editor set by `EDITOR` or `HOMEBREW_EDITOR`,
|
Open a <formula>, <cask> or <tap> in the editor set by `EDITOR` or `HOMEBREW_EDITOR`,
|
||||||
or open the Homebrew repository for editing if no argument is provided.
|
or open the Homebrew repository for editing if no argument is provided.
|
||||||
@ -26,8 +25,57 @@ module Homebrew
|
|||||||
|
|
||||||
named_args [:formula, :cask, :tap], without_api: true
|
named_args [:formula, :cask, :tap], without_api: true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { override.void }
|
||||||
|
def run
|
||||||
|
ENV["COLORTERM"] = ENV.fetch("HOMEBREW_COLORTERM", nil)
|
||||||
|
|
||||||
|
unless (HOMEBREW_REPOSITORY/".git").directory?
|
||||||
|
odie <<~EOS
|
||||||
|
Changes will be lost!
|
||||||
|
The first time you `brew update`, all local changes will be lost; you should
|
||||||
|
thus `brew update` before you `brew edit`!
|
||||||
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
|
paths = if args.named.empty?
|
||||||
|
# Sublime requires opting into the project editing path,
|
||||||
|
# as opposed to VS Code which will infer from the .vscode path
|
||||||
|
if which_editor(silent: true) == "subl"
|
||||||
|
["--project", "#{HOMEBREW_REPOSITORY}/.sublime/homebrew.sublime-project"]
|
||||||
|
else
|
||||||
|
# If no formulae are listed, open the project root in an editor.
|
||||||
|
[HOMEBREW_REPOSITORY]
|
||||||
|
end
|
||||||
|
else
|
||||||
|
expanded_paths = args.named.to_paths
|
||||||
|
expanded_paths.each do |path|
|
||||||
|
raise_with_message!(path, args.cask?) unless path.exist?
|
||||||
|
end
|
||||||
|
|
||||||
|
if expanded_paths.any? do |path|
|
||||||
|
!Homebrew::EnvConfig.no_install_from_api? &&
|
||||||
|
!Homebrew::EnvConfig.no_env_hints? &&
|
||||||
|
(core_formula_path?(path) || core_cask_path?(path) || core_formula_tap?(path) || core_cask_tap?(path))
|
||||||
|
end
|
||||||
|
opoo <<~EOS
|
||||||
|
`brew install` ignores locally edited casks and formulae if
|
||||||
|
HOMEBREW_NO_INSTALL_FROM_API is not set.
|
||||||
|
EOS
|
||||||
|
end
|
||||||
|
expanded_paths
|
||||||
|
end
|
||||||
|
|
||||||
|
if args.print_path?
|
||||||
|
paths.each { puts _1 }
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
exec_editor(*paths)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
sig { params(path: Pathname).returns(T::Boolean) }
|
sig { params(path: Pathname).returns(T::Boolean) }
|
||||||
def core_formula_path?(path)
|
def core_formula_path?(path)
|
||||||
path.fnmatch?("**/homebrew-core/Formula/**.rb", File::FNM_DOTMATCH)
|
path.fnmatch?("**/homebrew-core/Formula/**.rb", File::FNM_DOTMATCH)
|
||||||
@ -80,54 +128,6 @@ module Homebrew
|
|||||||
Run #{Formatter.identifier(command)} to #{action}!
|
Run #{Formatter.identifier(command)} to #{action}!
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
end
|
||||||
sig { void }
|
|
||||||
def edit
|
|
||||||
args = edit_args.parse
|
|
||||||
|
|
||||||
ENV["COLORTERM"] = ENV.fetch("HOMEBREW_COLORTERM", nil)
|
|
||||||
|
|
||||||
unless (HOMEBREW_REPOSITORY/".git").directory?
|
|
||||||
odie <<~EOS
|
|
||||||
Changes will be lost!
|
|
||||||
The first time you `brew update`, all local changes will be lost; you should
|
|
||||||
thus `brew update` before you `brew edit`!
|
|
||||||
EOS
|
|
||||||
end
|
|
||||||
|
|
||||||
paths = if args.named.empty?
|
|
||||||
# Sublime requires opting into the project editing path,
|
|
||||||
# as opposed to VS Code which will infer from the .vscode path
|
|
||||||
if which_editor(silent: true) == "subl"
|
|
||||||
["--project", "#{HOMEBREW_REPOSITORY}/.sublime/homebrew.sublime-project"]
|
|
||||||
else
|
|
||||||
# If no formulae are listed, open the project root in an editor.
|
|
||||||
[HOMEBREW_REPOSITORY]
|
|
||||||
end
|
|
||||||
else
|
|
||||||
expanded_paths = args.named.to_paths
|
|
||||||
expanded_paths.each do |path|
|
|
||||||
raise_with_message!(path, args.cask?) unless path.exist?
|
|
||||||
end
|
|
||||||
|
|
||||||
if expanded_paths.any? do |path|
|
|
||||||
(core_formula_path?(path) || core_cask_path?(path) || core_formula_tap?(path) || core_cask_tap?(path)) &&
|
|
||||||
!Homebrew::EnvConfig.no_install_from_api? &&
|
|
||||||
!Homebrew::EnvConfig.no_env_hints?
|
|
||||||
end
|
|
||||||
opoo <<~EOS
|
|
||||||
`brew install` ignores locally edited casks and formulae if
|
|
||||||
HOMEBREW_NO_INSTALL_FROM_API is not set.
|
|
||||||
EOS
|
|
||||||
end
|
|
||||||
expanded_paths
|
|
||||||
end
|
|
||||||
|
|
||||||
if args.print_path?
|
|
||||||
paths.each(&method(:puts))
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
exec_editor(*paths)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
# typed: true
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "abstract_command"
|
||||||
require "cli/parser"
|
require "cli/parser"
|
||||||
require "utils/git"
|
require "utils/git"
|
||||||
require "formulary"
|
require "formulary"
|
||||||
@ -8,11 +9,11 @@ require "software_spec"
|
|||||||
require "tap"
|
require "tap"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
|
module DevCmd
|
||||||
|
class Extract < AbstractCommand
|
||||||
BOTTLE_BLOCK_REGEX = / bottle (?:do.+?end|:[a-z]+)\n\n/m
|
BOTTLE_BLOCK_REGEX = / bottle (?:do.+?end|:[a-z]+)\n\n/m
|
||||||
|
|
||||||
sig { returns(CLI::Parser) }
|
cmd_args do
|
||||||
def self.extract_args
|
|
||||||
Homebrew::CLI::Parser.new do
|
|
||||||
usage_banner "`extract` [`--version=`] [`--force`] <formula> <tap>"
|
usage_banner "`extract` [`--version=`] [`--force`] <formula> <tap>"
|
||||||
description <<~EOS
|
description <<~EOS
|
||||||
Look through repository history to find the most recent version of <formula> and
|
Look through repository history to find the most recent version of <formula> and
|
||||||
@ -29,11 +30,9 @@ module Homebrew
|
|||||||
|
|
||||||
named_args [:formula, :tap], number: 2, without_api: true
|
named_args [:formula, :tap], number: 2, without_api: true
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def self.extract
|
|
||||||
args = extract_args.parse
|
|
||||||
|
|
||||||
|
sig { override.void }
|
||||||
|
def run
|
||||||
if (tap_with_name = args.named.first&.then { Tap.with_formula_name(_1) })
|
if (tap_with_name = args.named.first&.then { Tap.with_formula_name(_1) })
|
||||||
source_tap, name = tap_with_name
|
source_tap, name = tap_with_name
|
||||||
else
|
else
|
||||||
@ -149,9 +148,10 @@ module Homebrew
|
|||||||
path.write result
|
path.write result
|
||||||
end
|
end
|
||||||
|
|
||||||
# @private
|
private
|
||||||
|
|
||||||
sig { params(repo: Pathname, name: String, file: Pathname, rev: String).returns(T.nilable(Formula)) }
|
sig { params(repo: Pathname, name: String, file: Pathname, rev: String).returns(T.nilable(Formula)) }
|
||||||
def self.formula_at_revision(repo, name, file, rev)
|
def formula_at_revision(repo, name, file, rev)
|
||||||
return if rev.empty?
|
return if rev.empty?
|
||||||
|
|
||||||
contents = Utils::Git.last_revision_of_file(repo, file, before_commit: rev)
|
contents = Utils::Git.last_revision_of_file(repo, file, before_commit: rev)
|
||||||
@ -161,7 +161,7 @@ module Homebrew
|
|||||||
with_monkey_patch { Formulary.from_contents(name, file, contents, ignore_errors: true) }
|
with_monkey_patch { Formulary.from_contents(name, file, contents, ignore_errors: true) }
|
||||||
end
|
end
|
||||||
|
|
||||||
private_class_method def self.with_monkey_patch
|
def with_monkey_patch
|
||||||
# Since `method_defined?` is not a supported type guard, the use of `alias_method` below is not typesafe:
|
# Since `method_defined?` is not a supported type guard, the use of `alias_method` below is not typesafe:
|
||||||
BottleSpecification.class_eval do
|
BottleSpecification.class_eval do
|
||||||
T.unsafe(self).alias_method :old_method_missing, :method_missing if method_defined?(:method_missing)
|
T.unsafe(self).alias_method :old_method_missing, :method_missing if method_defined?(:method_missing)
|
||||||
@ -185,7 +185,10 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
DependencyCollector.class_eval do
|
DependencyCollector.class_eval do
|
||||||
T.unsafe(self).alias_method :old_parse_symbol_spec, :parse_symbol_spec if method_defined?(:parse_symbol_spec)
|
if method_defined?(:parse_symbol_spec)
|
||||||
|
T.unsafe(self).alias_method :old_parse_symbol_spec,
|
||||||
|
:parse_symbol_spec
|
||||||
|
end
|
||||||
define_method(:parse_symbol_spec) do |*|
|
define_method(:parse_symbol_spec) do |*|
|
||||||
# do nothing
|
# do nothing
|
||||||
end
|
end
|
||||||
@ -222,3 +225,5 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
@ -1,32 +1,31 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "abstract_command"
|
||||||
require "formula"
|
require "formula"
|
||||||
require "cli/parser"
|
require "cli/parser"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module_function
|
module DevCmd
|
||||||
|
class FormulaCmd < AbstractCommand
|
||||||
sig { returns(CLI::Parser) }
|
cmd_args do
|
||||||
def formula_args
|
|
||||||
Homebrew::CLI::Parser.new do
|
|
||||||
description <<~EOS
|
description <<~EOS
|
||||||
Display the path where <formula> is located.
|
Display the path where <formula> is located.
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
named_args :formula, min: 1, without_api: true
|
named_args :formula, min: 1, without_api: true
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def formula
|
|
||||||
args = formula_args.parse
|
|
||||||
|
|
||||||
|
sig { override.void }
|
||||||
|
def run
|
||||||
formula_paths = args.named.to_paths(only: :formula).select(&:exist?)
|
formula_paths = args.named.to_paths(only: :formula).select(&:exist?)
|
||||||
if formula_paths.blank? && args.named
|
if formula_paths.blank? && args.named
|
||||||
.to_paths(only: :cask)
|
.to_paths(only: :cask)
|
||||||
.any?(&:exist?)
|
.any?(&:exist?)
|
||||||
odie "Found casks but did not find formulae!"
|
odie "Found casks but did not find formulae!"
|
||||||
end
|
end
|
||||||
formula_paths.each(&method(:puts))
|
formula_paths.each { puts _1 }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,16 +1,22 @@
|
|||||||
# typed: true
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "abstract_command"
|
||||||
require "cli/parser"
|
require "cli/parser"
|
||||||
require "cask/cask"
|
require "cask/cask"
|
||||||
require "formula"
|
require "formula"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module_function
|
module DevCmd
|
||||||
|
class GenerateCaskApi < AbstractCommand
|
||||||
|
CASK_JSON_TEMPLATE = <<~EOS
|
||||||
|
---
|
||||||
|
layout: cask_json
|
||||||
|
---
|
||||||
|
{{ content }}
|
||||||
|
EOS
|
||||||
|
|
||||||
sig { returns(CLI::Parser) }
|
cmd_args do
|
||||||
def generate_cask_api_args
|
|
||||||
Homebrew::CLI::Parser.new do
|
|
||||||
description <<~EOS
|
description <<~EOS
|
||||||
Generate `homebrew/cask` API data files for <#{HOMEBREW_API_WWW}>.
|
Generate `homebrew/cask` API data files for <#{HOMEBREW_API_WWW}>.
|
||||||
The generated files are written to the current directory.
|
The generated files are written to the current directory.
|
||||||
@ -20,28 +26,9 @@ module Homebrew
|
|||||||
|
|
||||||
named_args :none
|
named_args :none
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
CASK_JSON_TEMPLATE = <<~EOS
|
|
||||||
---
|
|
||||||
layout: cask_json
|
|
||||||
---
|
|
||||||
{{ content }}
|
|
||||||
EOS
|
|
||||||
|
|
||||||
def html_template(title)
|
|
||||||
<<~EOS
|
|
||||||
---
|
|
||||||
title: #{title}
|
|
||||||
layout: cask
|
|
||||||
---
|
|
||||||
{{ content }}
|
|
||||||
EOS
|
|
||||||
end
|
|
||||||
|
|
||||||
def generate_cask_api
|
|
||||||
args = generate_cask_api_args.parse
|
|
||||||
|
|
||||||
|
sig { override.void }
|
||||||
|
def run
|
||||||
tap = CoreCaskTap.instance
|
tap = CoreCaskTap.instance
|
||||||
raise TapUnavailableError, tap.name unless tap.installed?
|
raise TapUnavailableError, tap.name unless tap.installed?
|
||||||
|
|
||||||
@ -79,4 +66,18 @@ module Homebrew
|
|||||||
File.write("api/internal/v3/homebrew-cask.json", homebrew_cask_tap_json) unless args.dry_run?
|
File.write("api/internal/v3/homebrew-cask.json", homebrew_cask_tap_json) unless args.dry_run?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def html_template(title)
|
||||||
|
<<~EOS
|
||||||
|
---
|
||||||
|
title: #{title}
|
||||||
|
layout: cask
|
||||||
|
---
|
||||||
|
{{ content }}
|
||||||
|
EOS
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -5,11 +5,16 @@ require "cli/parser"
|
|||||||
require "formula"
|
require "formula"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module_function
|
module DevCmd
|
||||||
|
class GenerateFormulaApi < AbstractCommand
|
||||||
|
FORMULA_JSON_TEMPLATE = <<~EOS
|
||||||
|
---
|
||||||
|
layout: formula_json
|
||||||
|
---
|
||||||
|
{{ content }}
|
||||||
|
EOS
|
||||||
|
|
||||||
sig { returns(CLI::Parser) }
|
cmd_args do
|
||||||
def generate_formula_api_args
|
|
||||||
Homebrew::CLI::Parser.new do
|
|
||||||
description <<~EOS
|
description <<~EOS
|
||||||
Generate `homebrew/core` API data files for <#{HOMEBREW_API_WWW}>.
|
Generate `homebrew/core` API data files for <#{HOMEBREW_API_WWW}>.
|
||||||
The generated files are written to the current directory.
|
The generated files are written to the current directory.
|
||||||
@ -19,29 +24,9 @@ module Homebrew
|
|||||||
|
|
||||||
named_args :none
|
named_args :none
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
FORMULA_JSON_TEMPLATE = <<~EOS
|
|
||||||
---
|
|
||||||
layout: formula_json
|
|
||||||
---
|
|
||||||
{{ content }}
|
|
||||||
EOS
|
|
||||||
|
|
||||||
def html_template(title)
|
|
||||||
<<~EOS
|
|
||||||
---
|
|
||||||
title: #{title}
|
|
||||||
layout: formula
|
|
||||||
redirect_from: /formula-linux/#{title}
|
|
||||||
---
|
|
||||||
{{ content }}
|
|
||||||
EOS
|
|
||||||
end
|
|
||||||
|
|
||||||
def generate_formula_api
|
|
||||||
args = generate_formula_api_args.parse
|
|
||||||
|
|
||||||
|
sig { override.void }
|
||||||
|
def run
|
||||||
tap = CoreTap.instance
|
tap = CoreTap.instance
|
||||||
raise TapUnavailableError, tap.name unless tap.installed?
|
raise TapUnavailableError, tap.name unless tap.installed?
|
||||||
|
|
||||||
@ -80,4 +65,19 @@ module Homebrew
|
|||||||
File.write("_data/formula_canonical.json", "#{canonical_json}\n") unless args.dry_run?
|
File.write("_data/formula_canonical.json", "#{canonical_json}\n") unless args.dry_run?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def html_template(title)
|
||||||
|
<<~EOS
|
||||||
|
---
|
||||||
|
title: #{title}
|
||||||
|
layout: formula
|
||||||
|
redirect_from: /formula-linux/#{title}
|
||||||
|
---
|
||||||
|
{{ content }}
|
||||||
|
EOS
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,27 +1,26 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "abstract_command"
|
||||||
require "formula"
|
require "formula"
|
||||||
require "completions"
|
require "completions"
|
||||||
require "manpages"
|
require "manpages"
|
||||||
require "system_command"
|
require "system_command"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
extend SystemCommand::Mixin
|
module DevCmd
|
||||||
|
class GenerateManCompletions < AbstractCommand
|
||||||
|
include SystemCommand::Mixin
|
||||||
|
|
||||||
sig { returns(CLI::Parser) }
|
cmd_args do
|
||||||
def self.generate_man_completions_args
|
|
||||||
Homebrew::CLI::Parser.new do
|
|
||||||
description <<~EOS
|
description <<~EOS
|
||||||
Generate Homebrew's manpages and shell completions.
|
Generate Homebrew's manpages and shell completions.
|
||||||
EOS
|
EOS
|
||||||
named_args :none
|
named_args :none
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def self.generate_man_completions
|
|
||||||
args = generate_man_completions_args.parse
|
|
||||||
|
|
||||||
|
sig { override.void }
|
||||||
|
def run
|
||||||
Commands.rebuild_internal_commands_completion_list
|
Commands.rebuild_internal_commands_completion_list
|
||||||
Manpages.regenerate_man_pages(quiet: args.quiet?)
|
Manpages.regenerate_man_pages(quiet: args.quiet?)
|
||||||
Completions.update_shell_completions!
|
Completions.update_shell_completions!
|
||||||
@ -36,3 +35,5 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
@ -1,14 +1,13 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "abstract_command"
|
||||||
require "cli/parser"
|
require "cli/parser"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module_function
|
module DevCmd
|
||||||
|
class InstallBundlerGems < AbstractCommand
|
||||||
sig { returns(CLI::Parser) }
|
cmd_args do
|
||||||
def install_bundler_gems_args
|
|
||||||
Homebrew::CLI::Parser.new do
|
|
||||||
description <<~EOS
|
description <<~EOS
|
||||||
Install Homebrew's Bundler gems.
|
Install Homebrew's Bundler gems.
|
||||||
EOS
|
EOS
|
||||||
@ -23,11 +22,9 @@ module Homebrew
|
|||||||
|
|
||||||
named_args :none
|
named_args :none
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def install_bundler_gems
|
|
||||||
args = install_bundler_gems_args.parse
|
|
||||||
|
|
||||||
|
sig { override.void }
|
||||||
|
def run
|
||||||
groups = args.groups || args.add_groups || []
|
groups = args.groups || args.add_groups || []
|
||||||
|
|
||||||
if groups.delete("all")
|
if groups.delete("all")
|
||||||
@ -39,3 +36,5 @@ module Homebrew
|
|||||||
Homebrew.install_bundler_gems!(groups:)
|
Homebrew.install_bundler_gems!(groups:)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
# typed: true
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "abstract_command"
|
||||||
require "formulary"
|
require "formulary"
|
||||||
require "cask/cask_loader"
|
require "cask/cask_loader"
|
||||||
require "cli/parser"
|
require "cli/parser"
|
||||||
@ -27,11 +28,9 @@ class Symbol
|
|||||||
end
|
end
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module_function
|
module DevCmd
|
||||||
|
class Irb < AbstractCommand
|
||||||
sig { returns(CLI::Parser) }
|
cmd_args do
|
||||||
def irb_args
|
|
||||||
Homebrew::CLI::Parser.new do
|
|
||||||
description <<~EOS
|
description <<~EOS
|
||||||
Enter the interactive Homebrew Ruby shell.
|
Enter the interactive Homebrew Ruby shell.
|
||||||
EOS
|
EOS
|
||||||
@ -41,12 +40,13 @@ module Homebrew
|
|||||||
env: :pry,
|
env: :pry,
|
||||||
description: "Use Pry instead of IRB. Implied if `HOMEBREW_PRY` is set."
|
description: "Use Pry instead of IRB. Implied if `HOMEBREW_PRY` is set."
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def irb
|
|
||||||
# work around IRB modifying ARGV.
|
# work around IRB modifying ARGV.
|
||||||
args = irb_args.parse(ARGV.dup.freeze)
|
sig { params(argv: T.nilable(T::Array[String])).void }
|
||||||
|
def initialize(argv = nil) = super(argv || ARGV.dup.freeze)
|
||||||
|
|
||||||
|
sig { override.void }
|
||||||
|
def run
|
||||||
clean_argv
|
clean_argv
|
||||||
|
|
||||||
if args.examples?
|
if args.examples?
|
||||||
@ -88,6 +88,8 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
# Remove the `--debug`, `--verbose` and `--quiet` options which cause problems
|
# Remove the `--debug`, `--verbose` and `--quiet` options which cause problems
|
||||||
# for IRB and have already been parsed by the CLI::Parser.
|
# for IRB and have already been parsed by the CLI::Parser.
|
||||||
def clean_argv
|
def clean_argv
|
||||||
@ -97,3 +99,5 @@ module Homebrew
|
|||||||
ARGV.reject! { |arg| global_options.include?(arg) }
|
ARGV.reject! { |arg| global_options.include?(arg) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
@ -1,16 +1,15 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "abstract_command"
|
||||||
require "cache_store"
|
require "cache_store"
|
||||||
require "linkage_checker"
|
require "linkage_checker"
|
||||||
require "cli/parser"
|
require "cli/parser"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module_function
|
module DevCmd
|
||||||
|
class Linkage < AbstractCommand
|
||||||
sig { returns(CLI::Parser) }
|
cmd_args do
|
||||||
def linkage_args
|
|
||||||
Homebrew::CLI::Parser.new do
|
|
||||||
description <<~EOS
|
description <<~EOS
|
||||||
Check the library links from the given <formula> kegs. If no <formula> are
|
Check the library links from the given <formula> kegs. If no <formula> are
|
||||||
provided, check all kegs. Raises an error if run on uninstalled formulae.
|
provided, check all kegs. Raises an error if run on uninstalled formulae.
|
||||||
@ -30,11 +29,9 @@ module Homebrew
|
|||||||
|
|
||||||
named_args :installed_formula
|
named_args :installed_formula
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def linkage
|
|
||||||
args = linkage_args.parse
|
|
||||||
|
|
||||||
|
sig { override.void }
|
||||||
|
def run
|
||||||
CacheStoreDatabase.use(:linkage) do |db|
|
CacheStoreDatabase.use(:linkage) do |db|
|
||||||
kegs = if args.named.to_default_kegs.empty?
|
kegs = if args.named.to_default_kegs.empty?
|
||||||
Formula.installed.filter_map(&:any_installed_keg)
|
Formula.installed.filter_map(&:any_installed_keg)
|
||||||
@ -58,3 +55,5 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
@ -1,17 +1,16 @@
|
|||||||
# typed: true
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "abstract_command"
|
||||||
require "cli/parser"
|
require "cli/parser"
|
||||||
require "formula"
|
require "formula"
|
||||||
require "livecheck/livecheck"
|
require "livecheck/livecheck"
|
||||||
require "livecheck/strategy"
|
require "livecheck/strategy"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module_function
|
module DevCmd
|
||||||
|
class LivecheckCmd < AbstractCommand
|
||||||
sig { returns(CLI::Parser) }
|
cmd_args do
|
||||||
def livecheck_args
|
|
||||||
Homebrew::CLI::Parser.new do
|
|
||||||
description <<~EOS
|
description <<~EOS
|
||||||
Check for newer versions of formulae and/or casks from upstream.
|
Check for newer versions of formulae and/or casks from upstream.
|
||||||
If no formula or cask argument is passed, the list of formulae and
|
If no formula or cask argument is passed, the list of formulae and
|
||||||
@ -48,27 +47,9 @@ module Homebrew
|
|||||||
|
|
||||||
named_args [:formula, :cask], without_api: true
|
named_args [:formula, :cask], without_api: true
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def watchlist_path
|
|
||||||
@watchlist_path ||= begin
|
|
||||||
watchlist = File.expand_path(Homebrew::EnvConfig.livecheck_watchlist)
|
|
||||||
|
|
||||||
unless File.exist?(watchlist)
|
|
||||||
previous_default_watchlist = File.expand_path("~/.brew_livecheck_watchlist")
|
|
||||||
if File.exist?(previous_default_watchlist)
|
|
||||||
odisabled "~/.brew_livecheck_watchlist", "~/.homebrew/livecheck_watchlist.txt"
|
|
||||||
watchlist = previous_default_watchlist
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
watchlist
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def livecheck
|
|
||||||
args = livecheck_args.parse
|
|
||||||
|
|
||||||
|
sig { override.void }
|
||||||
|
def run
|
||||||
Homebrew.install_bundler_gems!(groups: ["livecheck"])
|
Homebrew.install_bundler_gems!(groups: ["livecheck"])
|
||||||
|
|
||||||
all = args.eval_all?
|
all = args.eval_all?
|
||||||
@ -80,7 +61,7 @@ module Homebrew
|
|||||||
|
|
||||||
formulae_and_casks_to_check = Homebrew.with_no_api_env do
|
formulae_and_casks_to_check = Homebrew.with_no_api_env do
|
||||||
if args.tap
|
if args.tap
|
||||||
tap = Tap.fetch(args.tap)
|
tap = Tap.fetch(T.must(args.tap))
|
||||||
formulae = args.cask? ? [] : tap.formula_files.map { |path| Formulary.factory(path) }
|
formulae = args.cask? ? [] : tap.formula_files.map { |path| Formulary.factory(path) }
|
||||||
casks = args.formula? ? [] : tap.cask_files.map { |path| Cask::CaskLoader.load(path) }
|
casks = args.formula? ? [] : tap.cask_files.map { |path| Cask::CaskLoader.load(path) }
|
||||||
formulae + casks
|
formulae + casks
|
||||||
@ -136,4 +117,24 @@ module Homebrew
|
|||||||
|
|
||||||
Livecheck.run_checks(formulae_and_casks_to_check, **options)
|
Livecheck.run_checks(formulae_and_casks_to_check, **options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def watchlist_path
|
||||||
|
@watchlist_path ||= begin
|
||||||
|
watchlist = File.expand_path(Homebrew::EnvConfig.livecheck_watchlist)
|
||||||
|
|
||||||
|
unless File.exist?(watchlist)
|
||||||
|
previous_default_watchlist = File.expand_path("~/.brew_livecheck_watchlist")
|
||||||
|
if File.exist?(previous_default_watchlist)
|
||||||
|
odisabled "~/.brew_livecheck_watchlist", "~/.homebrew/livecheck_watchlist.txt"
|
||||||
|
watchlist = previous_default_watchlist
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
watchlist
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,15 +1,14 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "abstract_command"
|
||||||
require "cli/parser"
|
require "cli/parser"
|
||||||
require "utils/github"
|
require "utils/github"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module_function
|
module DevCmd
|
||||||
|
class PrAutomerge < AbstractCommand
|
||||||
sig { returns(CLI::Parser) }
|
cmd_args do
|
||||||
def pr_automerge_args
|
|
||||||
Homebrew::CLI::Parser.new do
|
|
||||||
description <<~EOS
|
description <<~EOS
|
||||||
Find pull requests that can be automatically merged using `brew pr-publish`.
|
Find pull requests that can be automatically merged using `brew pr-publish`.
|
||||||
EOS
|
EOS
|
||||||
@ -40,11 +39,9 @@ module Homebrew
|
|||||||
|
|
||||||
named_args :none
|
named_args :none
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def pr_automerge
|
|
||||||
args = pr_automerge_args.parse
|
|
||||||
|
|
||||||
|
sig { override.void }
|
||||||
|
def run
|
||||||
without_labels = args.without_labels || [
|
without_labels = args.without_labels || [
|
||||||
"do not merge",
|
"do not merge",
|
||||||
"new formula",
|
"new formula",
|
||||||
@ -58,7 +55,7 @@ module Homebrew
|
|||||||
query += args.ignore_failures? ? " -status:pending" : " status:success"
|
query += args.ignore_failures? ? " -status:pending" : " status:success"
|
||||||
query += " review:approved" unless args.without_approval?
|
query += " review:approved" unless args.without_approval?
|
||||||
query += " label:\"#{args.with_label}\"" if args.with_label
|
query += " label:\"#{args.with_label}\"" if args.with_label
|
||||||
without_labels&.each { |label| query += " -label:\"#{label}\"" }
|
without_labels.each { |label| query += " -label:\"#{label}\"" }
|
||||||
odebug "Searching: #{query}"
|
odebug "Searching: #{query}"
|
||||||
|
|
||||||
prs = GitHub.search_issues query
|
prs = GitHub.search_issues query
|
||||||
@ -85,3 +82,5 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
@ -1,15 +1,14 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "abstract_command"
|
||||||
require "cli/parser"
|
require "cli/parser"
|
||||||
require "utils/github"
|
require "utils/github"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module_function
|
module DevCmd
|
||||||
|
class PrPublish < AbstractCommand
|
||||||
sig { returns(CLI::Parser) }
|
cmd_args do
|
||||||
def pr_publish_args
|
|
||||||
Homebrew::CLI::Parser.new do
|
|
||||||
description <<~EOS
|
description <<~EOS
|
||||||
Publish bottles for a pull request with GitHub Actions.
|
Publish bottles for a pull request with GitHub Actions.
|
||||||
Requires write access to the repository.
|
Requires write access to the repository.
|
||||||
@ -31,11 +30,9 @@ module Homebrew
|
|||||||
|
|
||||||
named_args :pull_request, min: 1
|
named_args :pull_request, min: 1
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def pr_publish
|
|
||||||
args = pr_publish_args.parse
|
|
||||||
|
|
||||||
|
sig { override.void }
|
||||||
|
def run
|
||||||
tap = Tap.fetch(args.tap || CoreTap.instance.name)
|
tap = Tap.fetch(args.tap || CoreTap.instance.name)
|
||||||
workflow = args.workflow || "publish-commit-bottles.yml"
|
workflow = args.workflow || "publish-commit-bottles.yml"
|
||||||
ref = args.branch || "master"
|
ref = args.branch || "master"
|
||||||
@ -73,3 +70,5 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
@ -39,6 +39,11 @@ RSpec.describe Homebrew::AbstractCommand do
|
|||||||
expect(described_class.command("test-cat")).to be(TestCat)
|
expect(described_class.command("test-cat")).to be(TestCat)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "removes -cmd suffix from command name" do
|
||||||
|
require "dev-cmd/formula"
|
||||||
|
expect(Homebrew::DevCmd::FormulaCmd.command_name).to eq("formula")
|
||||||
|
end
|
||||||
|
|
||||||
describe "when command name is overridden" do
|
describe "when command name is overridden" do
|
||||||
before do
|
before do
|
||||||
tac = Class.new(described_class) do
|
tac = Class.new(described_class) do
|
||||||
@ -61,7 +66,7 @@ RSpec.describe Homebrew::AbstractCommand do
|
|||||||
["cmd", "dev-cmd"].each do |dir|
|
["cmd", "dev-cmd"].each do |dir|
|
||||||
Dir[File.join(__dir__, "../#{dir}", "*.rb")].each { require(_1) }
|
Dir[File.join(__dir__, "../#{dir}", "*.rb")].each { require(_1) }
|
||||||
end
|
end
|
||||||
test_classes = ["Cat", "Tac"]
|
test_classes = ["TestCat", "Tac"]
|
||||||
|
|
||||||
described_class.subclasses.each do |klass|
|
described_class.subclasses.each do |klass|
|
||||||
next if test_classes.include?(klass.name)
|
next if test_classes.include?(klass.name)
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
RSpec.shared_examples "parseable arguments" do |argv: []|
|
RSpec.shared_examples "parseable arguments" do |argv: nil|
|
||||||
subject(:method_name) { "#{command_name.tr("-", "_")}_args" }
|
subject(:method_name) { "#{command_name.tr("-", "_")}_args" }
|
||||||
|
|
||||||
let(:command_name) do |example|
|
let(:command_name) do |example|
|
||||||
@ -9,6 +9,8 @@ RSpec.shared_examples "parseable arguments" do |argv: []|
|
|||||||
|
|
||||||
it "can parse arguments" do
|
it "can parse arguments" do
|
||||||
if described_class
|
if described_class
|
||||||
|
argv ||= described_class.parser.instance_variable_get(:@min_named_args)&.times&.map { "argument" }
|
||||||
|
argv ||= []
|
||||||
cmd = described_class.new(argv)
|
cmd = described_class.new(argv)
|
||||||
expect(cmd.args).to be_a Homebrew::CLI::Args
|
expect(cmd.args).to be_a Homebrew::CLI::Args
|
||||||
else
|
else
|
||||||
|
|||||||
@ -30,7 +30,7 @@ RSpec.describe Homebrew::DevCmd::Bottle do
|
|||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
it_behaves_like "parseable arguments", argv: ["foo"]
|
it_behaves_like "parseable arguments"
|
||||||
|
|
||||||
it "builds a bottle for the given Formula", :integration_test do
|
it "builds a bottle for the given Formula", :integration_test do
|
||||||
install_test_formula "testball", build_bottle: true
|
install_test_formula "testball", build_bottle: true
|
||||||
|
|||||||
@ -4,5 +4,5 @@ require "cmd/shared_examples/args_parse"
|
|||||||
require "dev-cmd/bump-cask-pr"
|
require "dev-cmd/bump-cask-pr"
|
||||||
|
|
||||||
RSpec.describe Homebrew::DevCmd::BumpCaskPr do
|
RSpec.describe Homebrew::DevCmd::BumpCaskPr do
|
||||||
it_behaves_like "parseable arguments", argv: ["foo"]
|
it_behaves_like "parseable arguments"
|
||||||
end
|
end
|
||||||
|
|||||||
@ -4,5 +4,5 @@ require "cmd/shared_examples/args_parse"
|
|||||||
require "dev-cmd/bump-revision"
|
require "dev-cmd/bump-revision"
|
||||||
|
|
||||||
RSpec.describe Homebrew::DevCmd::BumpRevision do
|
RSpec.describe Homebrew::DevCmd::BumpRevision do
|
||||||
it_behaves_like "parseable arguments", argv: ["foo"]
|
it_behaves_like "parseable arguments"
|
||||||
end
|
end
|
||||||
|
|||||||
@ -4,5 +4,5 @@ require "cmd/shared_examples/args_parse"
|
|||||||
require "dev-cmd/bump-unversioned-casks"
|
require "dev-cmd/bump-unversioned-casks"
|
||||||
|
|
||||||
RSpec.describe Homebrew::DevCmd::BumpUnversionedCasks do
|
RSpec.describe Homebrew::DevCmd::BumpUnversionedCasks do
|
||||||
it_behaves_like "parseable arguments", argv: ["foo"]
|
it_behaves_like "parseable arguments"
|
||||||
end
|
end
|
||||||
|
|||||||
@ -4,7 +4,7 @@ require "cmd/shared_examples/args_parse"
|
|||||||
require "dev-cmd/cat"
|
require "dev-cmd/cat"
|
||||||
|
|
||||||
RSpec.describe Homebrew::DevCmd::Cat do
|
RSpec.describe Homebrew::DevCmd::Cat do
|
||||||
it_behaves_like "parseable arguments", argv: ["foo"]
|
it_behaves_like "parseable arguments"
|
||||||
|
|
||||||
it "prints the content of a given Formula", :integration_test do
|
it "prints the content of a given Formula", :integration_test do
|
||||||
formula_file = setup_test_formula "testball"
|
formula_file = setup_test_formula "testball"
|
||||||
|
|||||||
@ -4,7 +4,7 @@ require "cmd/shared_examples/args_parse"
|
|||||||
require "dev-cmd/command"
|
require "dev-cmd/command"
|
||||||
|
|
||||||
RSpec.describe Homebrew::DevCmd::Command do
|
RSpec.describe Homebrew::DevCmd::Command do
|
||||||
it_behaves_like "parseable arguments", argv: ["foo"]
|
it_behaves_like "parseable arguments"
|
||||||
|
|
||||||
it "returns the file for a given command", :integration_test do
|
it "returns the file for a given command", :integration_test do
|
||||||
expect { brew "command", "info" }
|
expect { brew "command", "info" }
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "cmd/shared_examples/args_parse"
|
require "cmd/shared_examples/args_parse"
|
||||||
|
require "dev-cmd/create"
|
||||||
|
|
||||||
RSpec.describe "brew create" do
|
RSpec.describe Homebrew::DevCmd::Create do
|
||||||
let(:url) { "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz" }
|
let(:url) { "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz" }
|
||||||
let(:formula_file) { CoreTap.instance.new_formula_path("testball") }
|
let(:formula_file) { CoreTap.instance.new_formula_path("testball") }
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
require "dev-cmd/determine-test-runners"
|
require "dev-cmd/determine-test-runners"
|
||||||
require "cmd/shared_examples/args_parse"
|
require "cmd/shared_examples/args_parse"
|
||||||
|
|
||||||
RSpec.describe "brew determine-test-runners" do
|
RSpec.describe Homebrew::DevCmd::DetermineTestRunners do
|
||||||
def get_runners(file)
|
def get_runners(file)
|
||||||
runner_line = File.open(file).first
|
runner_line = File.open(file).first
|
||||||
json_text = runner_line[/runners=(.*)/, 1]
|
json_text = runner_line[/runners=(.*)/, 1]
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "cmd/shared_examples/args_parse"
|
require "cmd/shared_examples/args_parse"
|
||||||
|
require "dev-cmd/dispatch-build-bottle"
|
||||||
|
|
||||||
RSpec.describe "brew dispatch-build-bottle" do
|
RSpec.describe Homebrew::DevCmd::DispatchBuildBottle do
|
||||||
it_behaves_like "parseable arguments"
|
it_behaves_like "parseable arguments"
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "cmd/shared_examples/args_parse"
|
require "cmd/shared_examples/args_parse"
|
||||||
|
require "dev-cmd/edit"
|
||||||
|
|
||||||
RSpec.describe "brew edit" do
|
RSpec.describe Homebrew::DevCmd::Edit do
|
||||||
it_behaves_like "parseable arguments"
|
it_behaves_like "parseable arguments"
|
||||||
|
|
||||||
it "opens a given Formula in an editor", :integration_test do
|
it "opens a given Formula in an editor", :integration_test do
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "cmd/shared_examples/args_parse"
|
require "cmd/shared_examples/args_parse"
|
||||||
|
require "dev-cmd/extract"
|
||||||
|
|
||||||
RSpec.describe "brew extract" do
|
RSpec.describe Homebrew::DevCmd::Extract do
|
||||||
it_behaves_like "parseable arguments"
|
it_behaves_like "parseable arguments"
|
||||||
|
|
||||||
context "when extracting a formula" do
|
context "when extracting a formula" do
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "cmd/shared_examples/args_parse"
|
require "cmd/shared_examples/args_parse"
|
||||||
|
require "dev-cmd/formula"
|
||||||
|
|
||||||
RSpec.describe "brew formula" do
|
RSpec.describe Homebrew::DevCmd::FormulaCmd do
|
||||||
it_behaves_like "parseable arguments"
|
it_behaves_like "parseable arguments"
|
||||||
|
|
||||||
it "prints a given Formula's path", :integration_test do
|
it "prints a given Formula's path", :integration_test do
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "cmd/shared_examples/args_parse"
|
require "cmd/shared_examples/args_parse"
|
||||||
|
require "dev-cmd/generate-cask-api"
|
||||||
|
|
||||||
RSpec.describe "brew generate-cask-api" do
|
RSpec.describe Homebrew::DevCmd::GenerateCaskApi do
|
||||||
it_behaves_like "parseable arguments"
|
it_behaves_like "parseable arguments"
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "cmd/shared_examples/args_parse"
|
require "cmd/shared_examples/args_parse"
|
||||||
|
require "dev-cmd/generate-formula-api"
|
||||||
|
|
||||||
RSpec.describe "brew generate-formula-api" do
|
RSpec.describe Homebrew::DevCmd::GenerateFormulaApi do
|
||||||
it_behaves_like "parseable arguments"
|
it_behaves_like "parseable arguments"
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "cmd/shared_examples/args_parse"
|
require "cmd/shared_examples/args_parse"
|
||||||
|
require "dev-cmd/generate-man-completions"
|
||||||
|
|
||||||
RSpec.describe "brew generate-man-completions" do
|
RSpec.describe Homebrew::DevCmd::GenerateManCompletions do
|
||||||
it_behaves_like "parseable arguments"
|
it_behaves_like "parseable arguments"
|
||||||
end
|
end
|
||||||
|
|||||||
@ -0,0 +1,8 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "cmd/shared_examples/args_parse"
|
||||||
|
require "dev-cmd/install-bundler-gems"
|
||||||
|
|
||||||
|
RSpec.describe Homebrew::DevCmd::InstallBundlerGems do
|
||||||
|
it_behaves_like "parseable arguments"
|
||||||
|
end
|
||||||
@ -1,8 +1,9 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "cmd/shared_examples/args_parse"
|
require "cmd/shared_examples/args_parse"
|
||||||
|
require "dev-cmd/irb"
|
||||||
|
|
||||||
RSpec.describe "brew irb" do
|
RSpec.describe Homebrew::DevCmd::Irb do
|
||||||
it_behaves_like "parseable arguments"
|
it_behaves_like "parseable arguments"
|
||||||
|
|
||||||
describe "integration test" do
|
describe "integration test" do
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "cmd/shared_examples/args_parse"
|
require "cmd/shared_examples/args_parse"
|
||||||
|
require "dev-cmd/linkage"
|
||||||
|
|
||||||
RSpec.describe "brew linkage" do
|
RSpec.describe Homebrew::DevCmd::Linkage do
|
||||||
it_behaves_like "parseable arguments"
|
it_behaves_like "parseable arguments"
|
||||||
|
|
||||||
it "works when no arguments are provided", :integration_test do
|
it "works when no arguments are provided", :integration_test do
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "cmd/shared_examples/args_parse"
|
require "cmd/shared_examples/args_parse"
|
||||||
|
require "dev-cmd/livecheck"
|
||||||
|
|
||||||
RSpec.describe "brew livecheck" do
|
RSpec.describe Homebrew::DevCmd::LivecheckCmd do
|
||||||
it_behaves_like "parseable arguments"
|
it_behaves_like "parseable arguments"
|
||||||
|
|
||||||
it "reports the latest version of a Formula", :integration_test, :needs_network do
|
it "reports the latest version of a Formula", :integration_test, :needs_network do
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "cmd/shared_examples/args_parse"
|
require "cmd/shared_examples/args_parse"
|
||||||
|
require "dev-cmd/pr-automerge"
|
||||||
|
|
||||||
RSpec.describe "brew pr-automerge" do
|
RSpec.describe Homebrew::DevCmd::PrAutomerge do
|
||||||
it_behaves_like "parseable arguments"
|
it_behaves_like "parseable arguments"
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "cmd/shared_examples/args_parse"
|
require "cmd/shared_examples/args_parse"
|
||||||
|
require "dev-cmd/pr-publish"
|
||||||
|
|
||||||
RSpec.describe "brew pr-publish" do
|
RSpec.describe Homebrew::DevCmd::PrPublish do
|
||||||
it_behaves_like "parseable arguments"
|
it_behaves_like "parseable arguments"
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user