Class: Homebrew::DevCmd::VendorGems Private

Inherits:
AbstractCommand show all
Defined in:
dev-cmd/vendor-gems.rb,
sorbet/rbi/dsl/homebrew/dev_cmd/vendor_gems.rbi

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

Defined Under Namespace

Classes: Args

Instance Method Summary collapse

Methods inherited from AbstractCommand

command, command_name, dev_cmd?, #initialize, parser, #raise_sh_command_error!

Constructor Details

This class inherits a constructor from Homebrew::AbstractCommand

Instance Method Details

#argsHomebrew::DevCmd::VendorGems::Args

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



10
# File 'sorbet/rbi/dsl/homebrew/dev_cmd/vendor_gems.rbi', line 10

def args; end

#runvoid

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'dev-cmd/vendor-gems.rb', line 27

def run
  Homebrew.install_bundler!

  ENV["BUNDLE_WITH"] = Homebrew.valid_gem_groups.join(":")

  ohai "cd #{HOMEBREW_LIBRARY_PATH}"
  HOMEBREW_LIBRARY_PATH.cd do
    if args.update
      ohai "bundle update"
      safe_system "bundle", "update", *args.update

      unless args.no_commit?
        ohai "git add Gemfile.lock"
        system "git", "add", "Gemfile.lock"
      end
    end

    ohai "bundle install --standalone"
    safe_system "bundle", "install", "--standalone"

    ohai "bundle pristine"
    safe_system "bundle", "pristine"

    ohai "bundle clean"
    safe_system "bundle", "clean"

    # Workaround Bundler 2.4.21 issue where platforms may be removed.
    # Although we don't use 2.4.21, Dependabot does as it currently ignores your lockfile version.
    # https://github.com/rubygems/rubygems/issues/7169
    safe_system "bundle", "lock", "--add-platform", "aarch64-linux", "arm-linux"
    system "git", "add", "Gemfile.lock" unless args.no_commit?

    if args.non_bundler_gems?
      %w[
        mechanize
      ].each do |gem|
        (HOMEBREW_LIBRARY_PATH/"vendor/gems").cd do
          Pathname.glob("#{gem}-*/").each { |path| FileUtils.rm_r(path) }
        end
        ohai "gem install #{gem}"
        safe_system "gem", "install", gem, "--install-dir", "vendor",
                    "--no-document", "--no-wrappers", "--ignore-dependencies", "--force"
        (HOMEBREW_LIBRARY_PATH/"vendor/gems").cd do
          source = Pathname.glob("#{gem}-*/").first
          next if source.blank?

          # We cannot use `#ln_sf` here because that has unintended consequences when
          # the symlink we want to create exists and points to an existing directory.
          FileUtils.rm_f gem
          FileUtils.ln_s source, gem
        end
      end
    end

    unless args.no_commit?
      ohai "git add vendor"
      system "git", "add", "vendor"

      Utils::Git.set_name_email!
      Utils::Git.setup_gpg!

      ohai "git commit"
      system "git", "commit", "--message", "brew vendor-gems: commit updates."
    end
  end
end