mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Merge pull request #15582 from Bo98/no-api-migrate
Migrate remaining no-api commands to new scoped system
This commit is contained in:
commit
66c6e5b5f6
@ -862,6 +862,7 @@ fi
|
||||
AUTO_UPDATE_CASK_TAP_COMMANDS=(
|
||||
bump
|
||||
bump-cask-pr
|
||||
bump-unversioned-casks
|
||||
)
|
||||
if check-array-membership "${HOMEBREW_COMMAND}" "${AUTO_UPDATE_CASK_TAP_COMMANDS[@]}"
|
||||
then
|
||||
@ -896,37 +897,6 @@ if [[ -f "${HOMEBREW_LIBRARY}/Homebrew/dev-cmd/${HOMEBREW_COMMAND}.sh" ]] ||
|
||||
[[ -f "${HOMEBREW_LIBRARY}/Homebrew/dev-cmd/${HOMEBREW_COMMAND}.rb" ]]
|
||||
then
|
||||
export HOMEBREW_DEVELOPER_COMMAND="1"
|
||||
|
||||
if [[ -z "${HOMEBREW_NO_INSTALL_FROM_API}" ]]
|
||||
then
|
||||
NO_INSTALL_FROM_API_COMMANDS=(
|
||||
bottle
|
||||
bump-cask-pr
|
||||
bump-formula-pr
|
||||
bump-revision
|
||||
bump-unversioned-casks
|
||||
bump
|
||||
cat
|
||||
create
|
||||
edit
|
||||
extract
|
||||
formula
|
||||
generate-cask-api
|
||||
generate-formula-api
|
||||
livecheck
|
||||
pr-pull
|
||||
pr-upload
|
||||
update-python-resources
|
||||
)
|
||||
|
||||
if check-array-membership "${HOMEBREW_COMMAND}" "${NO_INSTALL_FROM_API_COMMANDS[@]}"
|
||||
then
|
||||
export HOMEBREW_NO_INSTALL_FROM_API=1
|
||||
export HOMEBREW_AUTOMATICALLY_SET_NO_INSTALL_FROM_API=1
|
||||
fi
|
||||
|
||||
unset NO_INSTALL_FROM_API_COMMANDS
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -n "${HOMEBREW_DEVELOPER_COMMAND}" && -z "${HOMEBREW_DEVELOPER}" ]]
|
||||
|
@ -98,7 +98,7 @@ module Homebrew
|
||||
conflicts "--formula", "--cask"
|
||||
conflicts "--installed", "--all"
|
||||
|
||||
named_args [:formula, :cask]
|
||||
named_args [:formula, :cask], without_api: true
|
||||
end
|
||||
end
|
||||
|
||||
@ -123,7 +123,7 @@ module Homebrew
|
||||
ENV.activate_extensions!
|
||||
ENV.setup_build_environment
|
||||
|
||||
audit_formulae, audit_casks = with_no_api_env do # audit requires full Ruby source
|
||||
audit_formulae, audit_casks = Homebrew.with_no_api_env do # audit requires full Ruby source
|
||||
if args.tap
|
||||
Tap.fetch(args.tap).then do |tap|
|
||||
[
|
||||
@ -217,7 +217,7 @@ module Homebrew
|
||||
# Audit requires full Ruby source so disable API.
|
||||
# We shouldn't do this for taps however so that we don't unnecessarily require a full Homebrew/core clone.
|
||||
fa = if f.core_formula?
|
||||
with_no_api_env(&audit_proc)
|
||||
Homebrew.with_no_api_env(&audit_proc)
|
||||
else
|
||||
audit_proc.call
|
||||
end
|
||||
|
@ -86,7 +86,7 @@ module Homebrew
|
||||
|
||||
conflicts "--no-rebuild", "--keep-old"
|
||||
|
||||
named_args [:installed_formula, :file], min: 1
|
||||
named_args [:installed_formula, :file], min: 1, without_api: true
|
||||
end
|
||||
end
|
||||
|
||||
@ -311,6 +311,7 @@ module Homebrew
|
||||
|
||||
tap = CoreTap.instance
|
||||
end
|
||||
raise TapUnavailableError, tap.name unless tap.installed?
|
||||
|
||||
return ofail "Formula has no stable version: #{formula.full_name}" unless formula.stable
|
||||
|
||||
|
@ -52,7 +52,7 @@ module Homebrew
|
||||
conflicts "--dry-run", "--write"
|
||||
conflicts "--no-audit", "--online"
|
||||
|
||||
named_args :cask, number: 1
|
||||
named_args :cask, number: 1, without_api: true
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -85,7 +85,7 @@ module Homebrew
|
||||
conflicts "--no-audit", "--online"
|
||||
conflicts "--url", "--tag"
|
||||
|
||||
named_args :formula, max: 1
|
||||
named_args :formula, max: 1, without_api: true
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -25,7 +25,7 @@ module Homebrew
|
||||
|
||||
conflicts "--dry-run", "--write-only"
|
||||
|
||||
named_args :formula, min: 1
|
||||
named_args :formula, min: 1, without_api: true
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -25,7 +25,7 @@ module Homebrew
|
||||
flag "--state-file=",
|
||||
description: "File for caching state."
|
||||
|
||||
named_args [:cask, :tap], min: 1
|
||||
named_args [:cask, :tap], min: 1, without_api: true
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -33,7 +33,7 @@ module Homebrew
|
||||
conflicts "--cask", "--formula"
|
||||
conflicts "--no-pull-requests", "--open-pr"
|
||||
|
||||
named_args [:formula, :cask]
|
||||
named_args [:formula, :cask], without_api: true
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -18,7 +18,7 @@ module Homebrew
|
||||
|
||||
conflicts "--formula", "--cask"
|
||||
|
||||
named_args [:formula, :cask], min: 1
|
||||
named_args [:formula, :cask], min: 1, without_api: true
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -188,19 +188,24 @@ module Homebrew
|
||||
EOS
|
||||
end
|
||||
|
||||
if Formula.aliases.include? fc.name
|
||||
realname = Formulary.canonical_name(fc.name)
|
||||
odie <<~EOS
|
||||
The formula '#{realname}' is already aliased to '#{fc.name}'.
|
||||
Please check that you are not creating a duplicate.
|
||||
To force creation use `--force`.
|
||||
EOS
|
||||
Homebrew.with_no_api_env do
|
||||
if Formula.aliases.include? fc.name
|
||||
realname = Formulary.canonical_name(fc.name)
|
||||
odie <<~EOS
|
||||
The formula '#{realname}' is already aliased to '#{fc.name}'.
|
||||
Please check that you are not creating a duplicate.
|
||||
To force creation use `--force`.
|
||||
EOS
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
fc.generate!
|
||||
|
||||
PyPI.update_python_resources! Formula[fc.name], ignore_non_pypi_packages: true if args.python?
|
||||
formula = Homebrew.with_no_api_env do
|
||||
Formula[fc.name]
|
||||
end
|
||||
PyPI.update_python_resources! formula, ignore_non_pypi_packages: true if args.python?
|
||||
|
||||
puts "Please run `brew audit --new #{fc.name}` before submitting, thanks."
|
||||
fc.path
|
||||
|
@ -24,7 +24,7 @@ module Homebrew
|
||||
|
||||
conflicts "--formula", "--cask"
|
||||
|
||||
named_args [:formula, :cask]
|
||||
named_args [:formula, :cask], without_api: true
|
||||
end
|
||||
end
|
||||
|
||||
@ -76,10 +76,9 @@ module Homebrew
|
||||
end.presence
|
||||
end
|
||||
|
||||
if Homebrew::EnvConfig.automatically_set_no_install_from_api? &&
|
||||
!Homebrew::EnvConfig.no_env_hints?
|
||||
if !Homebrew::EnvConfig.no_install_from_api? && !Homebrew::EnvConfig.no_env_hints?
|
||||
paths.each do |path|
|
||||
next if !path.fnmatch?("**/homebrew-core/Formula/**/*.rb") && !path.fnmatch?("**/homebrew-cask/Casks/**/*.rb")
|
||||
next if !path.fnmatch?("**/homebrew-core/Formula/*.rb") && !path.fnmatch?("**/homebrew-cask/Casks/*.rb")
|
||||
|
||||
opoo <<~EOS
|
||||
Unless `HOMEBREW_NO_INSTALL_FROM_API` is set when running
|
||||
|
@ -88,7 +88,7 @@ module Homebrew
|
||||
switch "-f", "--force",
|
||||
description: "Overwrite the destination formula if it already exists."
|
||||
|
||||
named_args [:formula, :tap], number: 2
|
||||
named_args [:formula, :tap], number: 2, without_api: true
|
||||
end
|
||||
end
|
||||
|
||||
@ -98,11 +98,11 @@ module Homebrew
|
||||
if (match = args.named.first.match(HOMEBREW_TAP_FORMULA_REGEX))
|
||||
name = match[3].downcase
|
||||
source_tap = Tap.fetch(match[1], match[2])
|
||||
raise TapFormulaUnavailableError.new(source_tap, name) unless source_tap.installed?
|
||||
else
|
||||
name = args.named.first.downcase
|
||||
source_tap = CoreTap.instance
|
||||
end
|
||||
raise TapFormulaUnavailableError.new(source_tap, name) unless source_tap.installed?
|
||||
|
||||
destination_tap = Tap.fetch(args.named.second)
|
||||
unless Homebrew::EnvConfig.developer?
|
||||
|
@ -14,7 +14,7 @@ module Homebrew
|
||||
Display the path where <formula> is located.
|
||||
EOS
|
||||
|
||||
named_args :formula, min: 1
|
||||
named_args :formula, min: 1, without_api: true
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -43,6 +43,7 @@ module Homebrew
|
||||
args = generate_cask_api_args.parse
|
||||
|
||||
tap = Tap.default_cask_tap
|
||||
raise TapUnavailableError, tap.name unless tap.installed?
|
||||
|
||||
unless args.dry_run?
|
||||
directories = ["_data/cask", "api/cask", "api/cask-source", "cask"].freeze
|
||||
@ -50,22 +51,24 @@ module Homebrew
|
||||
FileUtils.mkdir_p directories
|
||||
end
|
||||
|
||||
Cask::Cask.generating_hash!
|
||||
Homebrew.with_no_api_env do
|
||||
Cask::Cask.generating_hash!
|
||||
|
||||
tap.cask_files.each do |path|
|
||||
cask = Cask::CaskLoader.load(path)
|
||||
name = cask.token
|
||||
json = JSON.pretty_generate(cask.to_hash_with_variations)
|
||||
tap.cask_files.each do |path|
|
||||
cask = Cask::CaskLoader.load(path)
|
||||
name = cask.token
|
||||
json = JSON.pretty_generate(cask.to_hash_with_variations)
|
||||
|
||||
unless args.dry_run?
|
||||
File.write("_data/cask/#{name}.json", "#{json}\n")
|
||||
File.write("api/cask/#{name}.json", CASK_JSON_TEMPLATE)
|
||||
File.write("api/cask-source/#{name}.rb", path.read)
|
||||
File.write("cask/#{name}.html", html_template(name))
|
||||
unless args.dry_run?
|
||||
File.write("_data/cask/#{name}.json", "#{json}\n")
|
||||
File.write("api/cask/#{name}.json", CASK_JSON_TEMPLATE)
|
||||
File.write("api/cask-source/#{name}.rb", path.read)
|
||||
File.write("cask/#{name}.html", html_template(name))
|
||||
end
|
||||
rescue
|
||||
onoe "Error while generating data for cask '#{path.stem}'."
|
||||
raise
|
||||
end
|
||||
rescue
|
||||
onoe "Error while generating data for cask '#{path.stem}'."
|
||||
raise
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -44,6 +44,7 @@ module Homebrew
|
||||
args = generate_formula_api_args.parse
|
||||
|
||||
tap = CoreTap.instance
|
||||
raise TapUnavailableError, tap.name unless tap.installed?
|
||||
|
||||
unless args.dry_run?
|
||||
directories = ["_data/formula", "api/formula", "formula"]
|
||||
@ -51,25 +52,27 @@ module Homebrew
|
||||
FileUtils.mkdir_p directories
|
||||
end
|
||||
|
||||
Formulary.enable_factory_cache!
|
||||
Formula.generating_hash!
|
||||
Homebrew.with_no_api_env do
|
||||
Formulary.enable_factory_cache!
|
||||
Formula.generating_hash!
|
||||
|
||||
tap.formula_names.each do |name|
|
||||
formula = Formulary.factory(name)
|
||||
name = formula.name
|
||||
json = JSON.pretty_generate(formula.to_hash_with_variations)
|
||||
tap.formula_names.each do |name|
|
||||
formula = Formulary.factory(name)
|
||||
name = formula.name
|
||||
json = JSON.pretty_generate(formula.to_hash_with_variations)
|
||||
|
||||
unless args.dry_run?
|
||||
File.write("_data/formula/#{name.tr("+", "_")}.json", "#{json}\n")
|
||||
File.write("api/formula/#{name}.json", FORMULA_JSON_TEMPLATE)
|
||||
File.write("formula/#{name}.html", html_template(name))
|
||||
unless args.dry_run?
|
||||
File.write("_data/formula/#{name.tr("+", "_")}.json", "#{json}\n")
|
||||
File.write("api/formula/#{name}.json", FORMULA_JSON_TEMPLATE)
|
||||
File.write("formula/#{name}.html", html_template(name))
|
||||
end
|
||||
rescue
|
||||
onoe "Error while generating data for formula '#{name}'."
|
||||
raise
|
||||
end
|
||||
rescue
|
||||
onoe "Error while generating data for formula '#{name}'."
|
||||
raise
|
||||
end
|
||||
|
||||
canonical_json = JSON.pretty_generate(tap.formula_renames.merge(tap.alias_table))
|
||||
File.write("_data/formula_canonical.json", "#{canonical_json}\n") unless args.dry_run?
|
||||
canonical_json = JSON.pretty_generate(tap.formula_renames.merge(tap.alias_table))
|
||||
File.write("_data/formula_canonical.json", "#{canonical_json}\n") unless args.dry_run?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -48,7 +48,7 @@ module Homebrew
|
||||
conflicts "--tap=", "--eval-all", "--installed"
|
||||
conflicts "--cask", "--formula"
|
||||
|
||||
named_args [:formula, :cask]
|
||||
named_args [:formula, :cask], without_api: true
|
||||
end
|
||||
end
|
||||
|
||||
@ -66,40 +66,42 @@ module Homebrew
|
||||
puts Homebrew::EnvConfig.livecheck_watchlist if Homebrew::EnvConfig.livecheck_watchlist.present?
|
||||
end
|
||||
|
||||
formulae_and_casks_to_check = if args.tap
|
||||
tap = Tap.fetch(args.tap)
|
||||
formulae = args.cask? ? [] : tap.formula_files.map { |path| Formulary.factory(path) }
|
||||
casks = args.formula? ? [] : tap.cask_files.map { |path| Cask::CaskLoader.load(path) }
|
||||
formulae + casks
|
||||
elsif args.installed?
|
||||
formulae = args.cask? ? [] : Formula.installed
|
||||
casks = args.formula? ? [] : Cask::Caskroom.casks
|
||||
formulae + casks
|
||||
elsif all
|
||||
formulae = args.cask? ? [] : Formula.all
|
||||
casks = args.formula? ? [] : Cask::Cask.all
|
||||
formulae + casks
|
||||
elsif args.named.present?
|
||||
if args.formula?
|
||||
args.named.to_formulae
|
||||
elsif args.cask?
|
||||
args.named.to_casks
|
||||
else
|
||||
args.named.to_formulae_and_casks
|
||||
end
|
||||
elsif File.exist?(WATCHLIST_PATH)
|
||||
begin
|
||||
names = Pathname.new(WATCHLIST_PATH).read.lines
|
||||
.reject { |line| line.start_with?("#") || line.blank? }
|
||||
.map(&:strip)
|
||||
formulae_and_casks_to_check = Homebrew.with_no_api_env do
|
||||
if args.tap
|
||||
tap = Tap.fetch(args.tap)
|
||||
formulae = args.cask? ? [] : tap.formula_files.map { |path| Formulary.factory(path) }
|
||||
casks = args.formula? ? [] : tap.cask_files.map { |path| Cask::CaskLoader.load(path) }
|
||||
formulae + casks
|
||||
elsif args.installed?
|
||||
formulae = args.cask? ? [] : Formula.installed
|
||||
casks = args.formula? ? [] : Cask::Caskroom.casks
|
||||
formulae + casks
|
||||
elsif all
|
||||
formulae = args.cask? ? [] : Formula.all
|
||||
casks = args.formula? ? [] : Cask::Cask.all
|
||||
formulae + casks
|
||||
elsif args.named.present?
|
||||
if args.formula?
|
||||
args.named.to_formulae
|
||||
elsif args.cask?
|
||||
args.named.to_casks
|
||||
else
|
||||
args.named.to_formulae_and_casks
|
||||
end
|
||||
elsif File.exist?(WATCHLIST_PATH)
|
||||
begin
|
||||
names = Pathname.new(WATCHLIST_PATH).read.lines
|
||||
.reject { |line| line.start_with?("#") || line.blank? }
|
||||
.map(&:strip)
|
||||
|
||||
named_args = CLI::NamedArgs.new(*names, parent: args)
|
||||
named_args.to_formulae_and_casks(ignore_unavailable: true)
|
||||
rescue Errno::ENOENT => e
|
||||
onoe e
|
||||
named_args = CLI::NamedArgs.new(*names, parent: args)
|
||||
named_args.to_formulae_and_casks(ignore_unavailable: true)
|
||||
rescue Errno::ENOENT => e
|
||||
onoe e
|
||||
end
|
||||
else
|
||||
raise UsageError, "A watchlist file is required when no arguments are given."
|
||||
end
|
||||
else
|
||||
raise UsageError, "A watchlist file is required when no arguments are given."
|
||||
end
|
||||
|
||||
formulae_and_casks_to_check = formulae_and_casks_to_check.sort_by do |formula_or_cask|
|
||||
|
@ -414,6 +414,7 @@ module Homebrew
|
||||
workflows = args.workflows.presence || ["tests.yml"]
|
||||
artifact = args.artifact || "bottles"
|
||||
tap = Tap.fetch(args.tap || CoreTap.instance.name)
|
||||
raise TapUnavailableError, tap.name unless tap.installed?
|
||||
|
||||
Utils::Git.set_name_email!(committer: args.committer.blank?)
|
||||
Utils::Git.setup_gpg!
|
||||
|
@ -40,7 +40,7 @@ module Homebrew
|
||||
conflicts "--formula", "--cask"
|
||||
conflicts "--only-cops", "--except-cops"
|
||||
|
||||
named_args [:file, :tap, :formula, :cask]
|
||||
named_args [:file, :tap, :formula, :cask], without_api: true
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -30,7 +30,7 @@ module Homebrew
|
||||
comma_array "--exclude-packages",
|
||||
description: "Exclude these packages when finding resources."
|
||||
|
||||
named_args :formula, min: 1
|
||||
named_args :formula, min: 1, without_api: true
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user