-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (41 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
# frozen_string_literal: true
require "formula"
require "language/node"
require "fileutils"
class ShopifyCliAT3 < Formula
desc "A CLI tool to build for the Shopify platform"
homepage "https://github.com/shopify/cli#readme"
url "https://registry.npmjs.org/@shopify/cli/-/cli-3.59.0.tgz"
sha256 "6d437ffe47062ad1c33c5ea2757477b614618105259a8ce5dea1fdd1510cfa69"
license "MIT"
depends_on "node"
depends_on "ruby"
depends_on "git"
livecheck do
url :stable
end
def install
existing_cli_path = `which shopify`
unless existing_cli_path.empty? || existing_cli_path.include?("homebrew")
opoo <<~WARNING
We've detected an installation of the Shopify CLI at #{existing_cli_path} that's not managed by Homebrew.
Please ensure that the Homebrew line in your shell configuration is at the bottom so that Homebrew-managed
tools take precedence.
WARNING
end
system "npm", "install", *Language::Node.std_npm_install_args(libexec)
original_executable_path = "#{libexec}/bin/shopify"
executable_path = "#{original_executable_path}3"
new_original_executable_path = "#{executable_path}-original"
FileUtils.move(original_executable_path, new_original_executable_path)
executable_content = <<~SCRIPT
#!/usr/bin/env #{Formula["node"].opt_bin}/node
process.env.SHOPIFY_RUBY_BINDIR = "#{Formula["ruby"].opt_bin}"
process.env.SHOPIFY_HOMEBREW_FORMULA = "shopify-cli@3"
import("#{new_original_executable_path}")
SCRIPT
File.write executable_path, executable_content
FileUtils.chmod("+x", executable_path)
bin.install_symlink executable_path
end
end